2 #include "structdefs.h"
5 extern int classsize[];
10 #include "SimpleHash.h"
12 struct SimpleHash * activetasks;
13 struct parameterwrapper * objectqueues[NUMCLASSES];
15 int main(int argc, char **argv) {
17 /* Allocate startup object */
18 struct ___StartupObject___ *startupobject=(struct ___StartupObject___*) allocate_new(STARTUPTYPE);
19 struct ArrayObject * stringarray=allocate_newarray(STRINGARRAYTYPE, argc);
21 activetasks=allocateSimpleHash(50);
25 flagorand(startupobject,1,0xFFFFFFFF);
27 /* Build array of strings */
29 startupobject->___parameters___=stringarray;
32 int length=strlen(argv[i]);
33 struct ___String___ *newstring=NewString(argv[i],length);
34 ((void **)(((char *)& stringarray->___length___)+sizeof(int)))[i]=newstring;
39 void flagorand(void * ptr, int ormask, int andmask) {
40 int flag=((int *)ptr)[1];
41 struct QueueItem *flagptr=(struct QueueItem *)(((int*)ptr)[2]);
45 /*Remove from all queues */
46 while(flagptr!=NULL) {
47 struct QueueItem * next=flagptr->nextqueue;
48 removeItem(flagptr->queue, flagptr);
53 struct QueueItem *tmpptr;
54 struct parameterwrapper * parameter=objectqueues[((int *)ptr)[0]];
57 while(parameter!=NULL) {
58 for(i=0;i<parameter->numberofterms;i++) {
59 int andmask=parameter->intarray[i*2];
60 int checkmask=parameter->intarray[i*2+1];
61 if ((flag&andmask)==checkmask) {
62 struct QueueItem * qitem=addNewItem(parameter->queue, ptr);
67 tmpptr->nextqueue=qitem;
70 SimpleHashadd(activetasks, (int)parameter->task, (int)parameter->task);
74 parameter=parameter->next;
76 ((struct QueueItem **)ptr)[2]=flagptr;
81 void * pointerarray[MAXTASKPARAMS];
83 while(SimpleHashcountset(activetasks)!=0) {
84 struct taskdescriptor * task=(struct taskdescriptor *) SimpleHashfirstkey(activetasks);
86 for(i=0;i<task->numParameters;i++) {
87 struct parameterwrapper * parameter=(struct parameterwrapper *) task->descriptorarray[i]->queue;
88 struct Queue * queue=parameter->queue;
90 SimpleHashremove(activetasks, (int)task, (int)task);
93 pointerarray[i]=getTail(queue)->objectptr;
95 ((void (*) (void **)) task->taskptr)(pointerarray);
101 for(i=0;i<numtasks;i++) {
102 struct taskdescriptor * task=taskarray[i];
105 for(j=0;j<task->numParameters;j++) {
106 struct parameterdescriptor *param=task->descriptorarray[j];
107 struct parameterwrapper * parameter=RUNMALLOC(sizeof(struct parameterwrapper));
108 struct parameterwrapper ** ptr=&objectqueues[param->type];
110 param->queue=parameter;
111 parameter->queue=createQueue();
112 parameter->numberofterms=param->numberterms;
113 parameter->intarray=param->intarray;
114 parameter->task=task;
115 /* Link new queue in */
124 int ___Object______hashcode____(struct ___Object___ * ___this___) {
125 return (int) ___this___;
128 void ___System______printString____L___String___(struct ___String___ * s) {
129 struct ArrayObject * chararray=s->___string___;
131 for(i=0;i<chararray->___length___;i++) {
132 short s= ((short *)(((char *)& chararray->___length___)+sizeof(int)))[i];
137 void * allocate_new(int type) {
138 void * v=FREEMALLOC(classsize[type]);
143 struct ArrayObject * allocate_newarray(int type, int length) {
144 struct ArrayObject * v=FREEMALLOC(sizeof(struct ArrayObject)+length*classsize[type]);
146 v->___length___=length;
150 struct ___String___ * NewString(char *str,int length) {
151 struct ArrayObject * chararray=allocate_newarray(CHARARRAYTYPE, length);
152 struct ___String___ * strobj=allocate_new(STRINGTYPE);
154 strobj->___string___=chararray;
155 for(i=0;i<length;i++) {
156 ((short *)(((char *)& chararray->___length___)+sizeof(int)))[i]=(short)str[i]; }
160 void failedboundschk() {
161 printf("Array out of bounds\n");
165 void failednullptr() {
166 printf("Dereferenced a null pointer\n");