Mercurial > repos > rhope
diff runtime/func.h @ 85:6d10b5b9ebc3
Make dispatch type selectable between replicated switch and computed goto
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 30 Jul 2010 23:49:19 +0000 |
parents | 0083b2f7b3c7 |
children | f51c4c17457c |
line wrap: on
line diff
--- a/runtime/func.h Fri Jul 30 23:48:31 2010 +0000 +++ b/runtime/func.h Fri Jul 30 23:49:19 2010 +0000 @@ -14,7 +14,22 @@ typedef returntype (*rhope_func)(calldata *); -typedef void (*special_func) (object *); +typedef void (*special_func) (object *); + +#ifdef MULTI_SWITCH +#define DispatchEntry(name) case FUNC_##name: goto f_##name; +#define ResumeEntry(num,name) case RES_##num##_##name: goto r##num##_##name; +#define DispatchVar +#define DISPATCH switch(func) { DispatchEntries } +#define EndEntry case END: goto DO_END; +#else +#define DispatchEntry(name) &&f_##name, +#define ResumeEntry(num,name) &&r##num##_##name, +#define DispatchVar void * funcs[] = { DispatchEntries }; +#define DISPATCH goto *funcs[func]; +#define EndEntry &&DO_END +#endif + #define MethodName(name,type) f_ ## name ## AT_ ## type