Slobodan Blazeski | 20 Jun 2010 12:08
Picon
Favicon

[stack] Semi-compilation

 

I've finished initial version of the interpreter (*). Currently my evaluator works using switch statements over the deque(**) of boxes and I want to split this deque into one deque holding data and another deque holding pointer to functions:
For 2 3 +
Currently : Box<primitive,Plus>,Box<float,*3>,Box<float,*2>,

Planned:
Data Box<float,*3>,Box<float,*2>
Code Box<*PlusFloat>,Box<*PushFloat>,Box<*PushFloat>,

What do you think about this? Or could you suggest a better approach

Slobodan
(*) http://www.bitbucket.org/bobiblazeski/lateral/
(**) Future of computation

__._,_.___
Recent Activity:
    .

    __,_._,___
    Slobodan Blazeski | 20 Jun 2010 20:57
    Picon
    Favicon

    [stack] Re: Semi-compilation

     



    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();

    __._,_.___
    Recent Activity:
      .

      __,_._,___

      Gmane