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

1.1       paf         1: /*
1.10    ! paf         2:   $Id: execute.C,v 1.9 2001/02/21 11:19:19 paf Exp $
1.1       paf         3: */
                      4: 
1.8       paf         5: #include "pa_array.h" 
1.1       paf         6: #include "code.h"
                      7: 
                      8: #include <stdio.h>
                      9: 
                     10: char *opcode_name[]={
                     11:        "STRING",
                     12:        "CODE_ARRAY",
                     13:        "WITH_ROOT",    "WITH_SELF",    "WITH_READ",    "WITH_WRITE",
                     14:        "CONSTRUCT",
                     15:        "EXPRESSION_EVAL",      "MODIFY_EVAL",
                     16:        "WRITE",
                     17:        "GET_ELEMENT",  "GET_ELEMENT__WRITE",
                     18:        "CREATE_EWPOOL",        "REDUCE_EWPOOL",
                     19:        "CREATE_RWPOOL",        "REDUCE_RWPOOL",
                     20:        "GET_METHOD_FRAME",
                     21:        "CREATE_JUNCTION",
                     22:        "STORE_PARAM",
                     23:        "CALL"
                     24: };
                     25: 
1.9       paf        26: void dump(int level, const Array& ops) {
                     27:        int size=ops.size();
1.1       paf        28:        for(int i=0; i<size; i++) {
1.10    ! paf        29:                int code=reinterpret_cast<int>(ops.quick_get(i));
1.1       paf        30:                printf("%*s%s", level*4, "", opcode_name[code]);
                     31: 
                     32:                if(code==OP_STRING) {
1.10    ! paf        33:                        printf(" \"%s\"", static_cast<const String *>(ops.quick_get(++i))->cstr());
1.1       paf        34:                }
                     35:                printf("\n");
                     36: 
                     37:                if(code==OP_CODE_ARRAY) {
1.10    ! paf        38:                        const Array *local_ops=reinterpret_cast<const Array *>(ops.quick_get(++i));
1.9       paf        39:                        dump(level+1, *local_ops);
1.1       paf        40:                }
                     41:        }
                     42: }
                     43: 
1.9       paf        44: void execute(Pool& pool, const Array& ops) {
1.2       paf        45:        puts("---------------------------");
1.1       paf        46:        dump(0, ops);
1.2       paf        47:        puts("---------------------------");
1.1       paf        48: }

E-mail: