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 for(i=0;i<parameter->numberofterms;i++) {
58 int andmask=parameter->intarray[i*2];
59 int checkmask=parameter->intarray[i*2+1];
60 if ((flag&andmask)==checkmask) {
61 struct QueueItem * qitem=addNewItem(parameter->queue, ptr);
66 tmpptr->nextqueue=qitem;
69 SimpleHashadd(activetasks, (int)parameter->task, (int)parameter->task);
73 ((struct QueueItem **)ptr)[2]=flagptr;
78 void * pointerarray[MAXTASKPARAMS];
82 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);
100 void processtasks() {
102 for(i=0;i<numtasks;i++) {
103 struct taskdescriptor * task=taskarray[i];
106 for(j=0;j<task->numParameters;j++) {
107 struct parameterdescriptor *param=task->descriptorarray[j];
108 struct parameterwrapper * parameter=RUNMALLOC(sizeof(struct parameterwrapper));
109 struct parameterwrapper ** ptr=&objectqueues[param->type];
111 param->queue=parameter;
112 parameter->queue=createQueue();
113 parameter->numberofterms=param->numberterms;
114 parameter->intarray=param->intarray;
115 parameter->task=task;
116 /* Link new queue in */
125 int ___Object______hashcode____(struct ___Object___ * ___this___) {
126 return (int) ___this___;
129 void ___System______printString____L___String___(struct ___String___ * s) {
130 struct ArrayObject * chararray=s->___string___;
132 for(i=0;i<chararray->___length___;i++) {
133 short s= ((short *)(((char *)& chararray->___length___)+sizeof(int)))[i];
138 void * allocate_new(int type) {
139 void * v=FREEMALLOC(classsize[type]);
144 struct ArrayObject * allocate_newarray(int type, int length) {
145 struct ArrayObject * v=FREEMALLOC(sizeof(struct ArrayObject)+length*classsize[type]);
147 v->___length___=length;
151 struct ___String___ * NewString(char *str,int length) {
152 struct ArrayObject * chararray=allocate_newarray(CHARARRAYTYPE, length);
153 struct ___String___ * strobj=allocate_new(STRINGTYPE);
155 strobj->___string___=chararray;
156 for(i=0;i<length;i++) {
157 ((short *)(((char *)& chararray->___length___)+sizeof(int)))[i]=(short)str[i]; }
161 void failedboundschk() {
162 printf("Array out of bounds\n");
166 void failednullptr() {
167 printf("Dereferenced a null pointer\n");