Created
March 20, 2012 21:52
-
-
Save amorri40/2141678 to your computer and use it in GitHub Desktop.
Interpreters101_Thegccway
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
The gcc way | |
*/ | |
#define DISPATCH() \ | |
{ goto *op_table[*((stringOfBytecode)++) - 'a']; } | |
static void interpreter_the_gcc_way(const char* stringOfBytecode) { | |
static void* op_table[] = { | |
&&op_a, &&op_b, &&op_c, &&op_d, &&op_e | |
}; | |
DISPATCH(); | |
op_a: printf("Hell"); DISPATCH(); | |
op_b: printf("o"); DISPATCH(); | |
op_c: printf(" w"); DISPATCH(); | |
op_d: printf("rld!\n"); DISPATCH(); | |
op_e: return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment