An Example (2)
Inspect the following expression in the Transcript window:
(CCodeGenerator new initialize addClass: Person) codeString
You will get the following C representation of your Smalltalk code:
/* Automatically generated from Squeak on (12 November 1998 10:32:28 pm ) */
#include "sq.h"
#include "sqMachDep.h" /* needed only by the JIT virtual machine */
/* memory access macros */
#define byteAt(i) (*((unsigned char *) (i)))
#define byteAtput(i, val) (*((unsigned char *) (i)) = val)
#define longAt(i) (*((int *) (i)))
#define longAtput(i, val) (*((int *) (i)) = val)
int printCallStack(void);
void error(char *s);
void error(char *s) {
/* Print an error message and exit. */
static int printingStack = false;
printf("\n%s\n\n", s);
if (!printingStack) {
/* flag prevents recursive error when trying to print a broken stack */
printingStack = true;
printCallStack();
}
exit(-1);
}
/*** Variables ***/
int name;
/*** Function Prototypes ***/
int name(void);
int name(int aName);
int test(void);
int name(void) {
return name;
}
int name(int aName) {
name = aName;
}
int test(void) {
show(Transcript, printString(name));
}