runtime stuff for instanceof
authorbdemsky <bdemsky>
Fri, 13 Feb 2009 06:59:02 +0000 (06:59 +0000)
committerbdemsky <bdemsky>
Fri, 13 Feb 2009 06:59:02 +0000 (06:59 +0000)
Robust/src/Runtime/runtime.c

index 5c598ba433fea151d419ff92c42be4bdc2863482..95f4d54cee79bf928117db30cf927cdb9224ea5d 100644 (file)
@@ -13,6 +13,8 @@
 #endif
 
 extern int classsize[];
+extern int typearray[];
+extern int typearray2[];
 jmp_buf error_handler;
 int instructioncount;
 
@@ -30,6 +32,24 @@ int instaccum=0;
 #include "dmalloc.h"
 #endif
 
+int instanceof(struct ___Object___ *ptr, int type) {
+  int i=ptr->type;
+  do {
+    if (i==type)
+      return 1;
+    i=typearray[i];
+  } while(i!=-1);
+  i=ptr->type;
+  if (i>NUMCLASSES) {
+    do {
+      if (i==type)
+       return 1;
+      i=typearray2[i-NUMCLASSES];
+    } while(i!=-1);
+  }
+  return 0;
+}
+
 void exithandler(int sig, siginfo_t *info, void * uap) {
   exit(0);
 }