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

1.1       paf         1: /*
1.7     ! paf         2:   $Id: execute.C,v 1.6 2001/02/21 07:40:52 paf Exp $
1.1       paf         3: */
                      4: 
1.7     ! 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: 
                     26: void dump(int level, const Array *ops) {
1.2       paf        27:        if(!ops)
                     28:                return;
                     29: 
1.1       paf        30:        int size=ops->size();
                     31:        for(int i=0; i<size; i++) {
                     32:                int code=reinterpret_cast<int>(ops->raw_get(i));
                     33:                printf("%*s%s", level*4, "", opcode_name[code]);
                     34: 
                     35:                if(code==OP_STRING) {
                     36:                        printf(" \"%s\"", static_cast<const String *>(ops->raw_get(++i))->cstr());
                     37:                }
                     38:                printf("\n");
                     39: 
                     40:                if(code==OP_CODE_ARRAY) {
                     41:                        const Array *local_ops=reinterpret_cast<const Array *>(ops->raw_get(++i));
1.3       paf        42:                        dump(level+1, local_ops);
1.1       paf        43:                }
                     44:        }
                     45: }
                     46: 
                     47: void execute(Pool *pool, const Array *ops) {
                     48:        if(!ops)
                     49:                return;
                     50: 
1.2       paf        51:        puts("---------------------------");
1.1       paf        52:        dump(0, ops);
1.2       paf        53:        puts("---------------------------");
1.1       paf        54: }

E-mail: