2 #include "structdefs.h"
5 extern int classsize[];
8 #define FREEMALLOC(x) GC_malloc(x)
10 #define FREEMALLOC(x) calloc(1,x)
14 int main(int argc, char **argv) {
16 /* Allocate startup object */
17 struct ___StartupObject___ *startupobject=(struct ___StartupObject___*) allocate_new(STARTUPTYPE);
19 flagor(startupobject,1);
21 /* Build array of strings */
22 struct ArrayObject * stringarray=allocate_newarray(STRINGARRAYTYPE, argc);
23 startupobject->___parameters___=stringarray;
26 int length=strlen(argv[i]);
27 struct ___String___ *newstring=NewString(argv[i],length);
28 ((void **)(((char *)& stringarray->___length___)+sizeof(int)))[i]=newstring;
33 void flagor(void * ptr, int ormask) {
34 ((int *)ptr)[1]|=ormask;
37 void flagand(void * ptr, int andmask) {
38 ((int *)ptr)[1]&=andmask;
44 int ___Object______hashcode____(struct ___Object___ * ___this___) {
45 return (int) ___this___;
48 void ___System______printString____L___String___(struct ___String___ * s) {
49 struct ArrayObject * chararray=s->___string___;
51 for(i=0;i<chararray->___length___;i++) {
52 short s= ((short *)(((char *)& chararray->___length___)+sizeof(int)))[i];
57 void * allocate_new(int type) {
58 void * v=FREEMALLOC(classsize[type]);
63 struct ArrayObject * allocate_newarray(int type, int length) {
64 struct ArrayObject * v=FREEMALLOC(sizeof(struct ArrayObject)+length*classsize[type]);
66 v->___length___=length;
70 struct ___String___ * NewString(char *str,int length) {
71 struct ArrayObject * chararray=allocate_newarray(CHARARRAYTYPE, length);
72 struct ___String___ * strobj=allocate_new(STRINGTYPE);
74 strobj->___string___=chararray;
75 for(i=0;i<length;i++) {
76 ((short *)(((char *)& chararray->___length___)+sizeof(int)))[i]=(short)str[i]; }
80 void failedboundschk() {
81 printf("Array out of bounds\n");
85 void failednullptr() {
86 printf("Dereferenced a null pointer\n");