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 /* Build array of strings */
20 struct ArrayObject * stringarray=allocate_newarray(STRINGARRAYTYPE, argc);
21 startupobject->___parameters___=stringarray;
24 int length=strlen(argv[i]);
25 struct ___String___ *newstring=NewString(argv[i],length);
26 ((void **)(((char *)& stringarray->___length___)+sizeof(int)))[i]=newstring;
33 int ___Object______hashcode____(struct ___Object___ * ___this___) {
34 return (int) ___this___;
37 void ___System______printString____L___String___(struct ___String___ * s) {
38 struct ArrayObject * chararray=s->___string___;
40 for(i=0;i<chararray->___length___;i++) {
41 short s= ((short *)(((char *)& chararray->___length___)+sizeof(int)))[i];
46 void * allocate_new(int type) {
47 void * v=FREEMALLOC(classsize[type]);
52 struct ArrayObject * allocate_newarray(int type, int length) {
53 struct ArrayObject * v=FREEMALLOC(sizeof(struct ArrayObject)+length*classsize[type]);
55 v->___length___=length;
59 struct ___String___ * NewString(char *str,int length) {
60 struct ArrayObject * chararray=allocate_newarray(CHARARRAYTYPE, length);
61 struct ___String___ * strobj=allocate_new(STRINGTYPE);
63 strobj->___string___=chararray;
64 for(i=0;i<length;i++) {
65 ((short *)(((char *)& chararray->___length___)+sizeof(int)))[i]=(short)str[i]; }
69 void failedboundschk() {
70 printf("Array out of bounds\n");
74 void failednullptr() {
75 printf("Dereferenced a null pointer\n");