Annotation of parser3/src/main/execute.C, revision 1.13

1.1       paf         1: /*
1.13    ! paf         2:   $Id: execute.C,v 1.12 2001/02/21 17:50:02 paf Exp $
1.1       paf         3: */
                      4: 
1.8       paf         5: #include "pa_array.h" 
1.1       paf         6: #include "code.h"
1.11      paf         7: #include "pa_request.h"
1.1       paf         8: 
                      9: #include <stdio.h>
                     10: 
1.11      paf        11: 
1.1       paf        12: char *opcode_name[]={
                     13:        "STRING",
                     14:        "CODE_ARRAY",
                     15:        "WITH_ROOT",    "WITH_SELF",    "WITH_READ",    "WITH_WRITE",
                     16:        "CONSTRUCT",
                     17:        "EXPRESSION_EVAL",      "MODIFY_EVAL",
                     18:        "WRITE",
                     19:        "GET_ELEMENT",  "GET_ELEMENT__WRITE",
                     20:        "CREATE_EWPOOL",        "REDUCE_EWPOOL",
                     21:        "CREATE_RWPOOL",        "REDUCE_RWPOOL",
                     22:        "GET_METHOD_FRAME",
                     23:        "CREATE_JUNCTION",
                     24:        "STORE_PARAM",
                     25:        "CALL"
                     26: };
                     27: 
1.9       paf        28: void dump(int level, const Array& ops) {
                     29:        int size=ops.size();
1.1       paf        30:        for(int i=0; i<size; i++) {
1.10      paf        31:                int code=reinterpret_cast<int>(ops.quick_get(i));
1.1       paf        32:                printf("%*s%s", level*4, "", opcode_name[code]);
                     33: 
                     34:                if(code==OP_STRING) {
1.12      paf        35:                        const String *string=static_cast<const String *>(ops.quick_get(++i));
                     36:                        printf(" \"%s\"", string->cstr());
1.1       paf        37:                }
                     38:                printf("\n");
                     39: 
                     40:                if(code==OP_CODE_ARRAY) {
1.10      paf        41:                        const Array *local_ops=reinterpret_cast<const Array *>(ops.quick_get(++i));
1.9       paf        42:                        dump(level+1, *local_ops);
1.1       paf        43:                }
                     44:        }
                     45: }
                     46: 
1.11      paf        47: void Request::execute(Array& ops) {
1.12      paf        48:        if(1) {
                     49:                puts("---------------------------");
                     50:                dump(0, ops);
                     51:                puts("---------------------------");
                     52:        }
                     53: 
1.11      paf        54:        int size=ops.size();
                     55:        for(int i=0; i<size; i++) {
                     56:                int code=reinterpret_cast<int>(ops.quick_get(i));
                     57:                printf("%s\n", opcode_name[code]);
                     58: 
                     59:                if(code==OP_CODE_ARRAY) {
                     60:                        const Array *local_ops=reinterpret_cast<const Array *>(ops.quick_get(++i));
                     61:                        //dump(level+1, *local_ops);
                     62:                }
1.13    ! paf        63:                
1.11      paf        64:                switch(code) {
                     65:                case OP_WITH_WRITE: 
                     66:                        {
1.13    ! paf        67:                                stack.push(wcontext);
        !            68:                                break;
1.11      paf        69:                        }
1.13    ! paf        70:                        
1.11      paf        71:                case OP_STRING:
                     72:                        {
1.13    ! paf        73:                                String *string=static_cast<String *>(ops.quick_get(++i));
        !            74:                                stack.push(string);
        !            75:                                break;
1.11      paf        76:                        }
1.13    ! paf        77:                        
1.11      paf        78:                case OP_CONSTRUCT:
                     79:                        {
1.13    ! paf        80:                                Value *value=static_cast<Value *>(stack.pop());
        !            81:                                String *name=static_cast<String *>(stack.pop());
        !            82:                                Value *ncontext=static_cast<Value *>(stack.pop());
        !            83:                                ncontext->put_element(*name, value);
        !            84:                                break;
1.11      paf        85:                        }
1.13    ! paf        86:                        
        !            87:                /*case OP_WRITE:
        !            88:                        {
        !            89:                                Value *value=static_cast<Value *>(stack.pop());
        !            90:                                wcontext.write(value);
        !            91:                                break;
        !            92:                        }*/
        !            93:                        
        !            94:                /*case OP_GET_ELEMENT:
1.11      paf        95:                        {
1.13    ! paf        96:                                String *name=static_cast<String *>(stack.pop());
        !            97:                                Value *ncontext=static_cast<Value *>(stack.pop());
        !            98:                                Value *value=ncontext->get_element(*name); // name áûâàåò method, òîãäà âûäà¸ò new junction(ÀÂÒÎÂÛ×ÈÑËßÒÜ=false, root,self,rcontext,wcontext,code)
        !            99:                                // name áûâàåò èìÿ junction, òîãäà èëè îñòàâëÿåò â ïîêîå, èëè âû÷èñëÿåò â çàâèñèìîñòè îò ôëàãà ÀÂÒÎÂÛ×ÈÑËßÒÜ
        !           100:                                stack.push(value);
        !           101:                                break;
        !           102:                        }*/
        !           103:                        
1.11      paf       104:                default:
                    105:                        printf("\tTODO\n");
                    106:                        break;
                    107:                }
                    108:        }
1.1       paf       109: }

E-mail: