[stack] Re: Semi-compilation
"Slobodan Blazeski" <[email protected]> Sun, 20 Jun 2010 18:57:41 -0000
| Newsgroups | gmane.comp.lang.concatenative |
|---|---|
| Message-ID | <[email protected]> |
Sorry for not waiting for replies but I've rewrote the interpreter to use what I understand as threaded code. I've set the repository as private until is ready for public use. If you like to see the code mail me. Instead of data and code stack I've gone for the simpler version of one stack.
typedef void(*Word)();
struct Box {
Word word;
void* value;
Box(Word _word, void* _value) {
word = _word;
value = _value;
}
..
}
Few functions:
void evalAbs(){
evalUnary(&evalFloat,
new float(abs(getFloat(stack[0]))));}
void evalDivide() {
evalBinary(&evalFloat,
new float(getFloat(stack[0]) / getFloat(stack[1])));
}
...
static deque<Box> deck; // future of computation
static deque<Box> stack;// already computed
Now whole interpreter is below:
while(!deck.empty())
deck.front().word();