From: bdemsky Date: Fri, 13 Feb 2009 06:59:02 +0000 (+0000) Subject: runtime stuff for instanceof X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=2ca053bc2615b42533c42b6a94ff8db26c254a13;p=IRC.git runtime stuff for instanceof --- diff --git a/Robust/src/Runtime/runtime.c b/Robust/src/Runtime/runtime.c index 5c598ba4..95f4d54c 100644 --- a/Robust/src/Runtime/runtime.c +++ b/Robust/src/Runtime/runtime.c @@ -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); }