Annotation of parser3/src/main/compile_tools.h, revision 1.92

1.32      paf         1: /** @file
1.33      paf         2:        Parser: compiler support helper functions decls.
                      3: 
1.82      misha       4:        Copyright (c) 2001-2009 ArtLebedev Group (http://www.artlebedev.com)
1.58      paf         5:        Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
1.1       paf         6: */
                      7: 
                      8: #ifndef COMPILE_TOOLS
                      9: #define COMPILE_TOOLS
1.62      paf        10: 
1.92    ! misha      11: static const char * const IDENT_COMPILE_TOOLS_H="$Date: 2009-05-23 06:41:11 $";
1.1       paf        12: 
1.39      paf        13: #include "pa_opcode.h"
1.1       paf        14: #include "pa_types.h"
1.10      paf        15: #include "pa_vstring.h"
1.14      paf        16: #include "pa_request.h"
1.1       paf        17: 
1.68      paf        18: /// used to track source column number
                     19: #define TAB_SIZE 8
                     20: 
1.1       paf        21: enum lexical_state {
1.48      parser     22:        LS_USER, LS_NAME_SQUARE_PART,
1.65      paf        23:        LS_USER_COMMENT,
1.7       paf        24:        LS_DEF_NAME,
                     25:        LS_DEF_PARAMS,
                     26:        LS_DEF_LOCALS,
                     27:        LS_DEF_COMMENT,
1.18      paf        28:        LS_DEF_SPECIAL_BODY,
1.42      parser     29:        LS_EXPRESSION_STRING_QUOTED,
                     30:        LS_EXPRESSION_STRING_APOSTROFED,
1.48      parser     31:        LS_EXPRESSION_VAR_NAME_WITH_COLON, LS_EXPRESSION_VAR_NAME_WITHOUT_COLON,
1.65      paf        32:        LS_EXPRESSION_COMMENT,
1.48      parser     33:        LS_VAR_NAME_SIMPLE_WITH_COLON, LS_VAR_NAME_SIMPLE_WITHOUT_COLON,
1.1       paf        34:        LS_VAR_NAME_CURLY,
1.22      paf        35:        LS_VAR_ROUND,
1.18      paf        36:        LS_VAR_SQUARE,
1.1       paf        37:        LS_VAR_CURLY,
                     38:        LS_METHOD_NAME,
1.18      paf        39:        LS_METHOD_SQUARE,
1.1       paf        40:        LS_METHOD_CURLY,
1.22      paf        41:        LS_METHOD_ROUND,
1.1       paf        42:        LS_METHOD_AFTER
                     43: };
1.68      paf        44: 
                     45: struct Pos {
1.73      paf        46:        int line;
                     47:        int col;
                     48:        Pos(int aline, int acol): line(aline), col(acol) {}
1.68      paf        49:        Pos(): line(0), col(0) {}
                     50: 
                     51:        void clear() { line=col=0; }
                     52:        operator bool() { return col!=0; }
                     53: };
                     54: 
1.38      paf        55: /// compiler status
1.68      paf        56: class Parse_control {
                     57:        const String* main_alias;
                     58:        uint last_line_end_col;
                     59: public:
                     60:        const String& alias_method(const String& name);
1.38      paf        61:        //@{
                     62:        /// @name input
1.68      paf        63:        Request& request;
                     64:        VStateless_class* cclass;
1.79      misha      65:        VStateless_class* cclass_new;
1.78      misha      66:        ArrayClass* cclasses;
1.68      paf        67:        const char* source;
                     68:        uint file_no;
                     69:        Pos pos;
1.38      paf        70:        //@}
                     71:        //@{
                     72:        /// @name state; initially
1.45      parser     73:        bool trim_bof;
1.38      paf        74:        int pending_state; ///< i=0
1.69      paf        75:        String::Body string; ///< lexical string accumulator
1.68      paf        76:        Pos string_start;
1.1       paf        77:        
                     78: #define MAX_LEXICAL_STATES 100
1.38      paf        79:        enum lexical_state ls; ///< =LS_USER;
1.54      paf        80:        int ls_sp; ///< =0
                     81:        enum lexical_state ls_stack[MAX_LEXICAL_STATES];
1.38      paf        82:        int brackets_nestages[MAX_LEXICAL_STATES]; ///< brackets nestage on each state
1.46      parser     83: 
1.56      paf        84:        bool in_call_value;
1.74      paf        85:        bool explicit_result;
1.79      misha      86:        bool append;
1.38      paf        87:        //@}
1.1       paf        88:        
1.36      paf        89:        /// output: filled input 'methods' and 'error' if any
1.5       paf        90:        char error[MAX_STRING];
1.68      paf        91: 
                     92:        Parse_control(Request& arequest, 
                     93:                VStateless_class* aclass,
                     94:                const char* asource, const String* amain_alias, 
1.73      paf        95:                uint afile_no,
                     96:                int line_no_offset):
1.70      paf        97:                main_alias(amain_alias),
                     98:                last_line_end_col(0),
                     99: 
1.68      paf       100:                request(arequest), // input 
                    101: 
                    102:                // we were told the class to compile to?
                    103:                cclass(aclass), // until changed with @CLASS would consider operators loading
1.79      misha     104:                cclass_new(0)1.78      misha     105:                cclasses(new ArrayClass(1)),
1.70      paf       106:                source(asource), 
1.68      paf       107:                file_no(afile_no),
1.73      paf       108:                pos(line_no_offset, 0),
1.68      paf       109: 
                    110:                // initialize state
                    111:                trim_bof(true),
                    112:                pending_state(0),
                    113:                ls(LS_USER),
                    114:                ls_sp(0),
1.74      paf       115:                in_call_value(false),
1.79      misha     116:                explicit_result(false),
1.83      misha     117:                append(false) {
1.78      misha     118: 
                    119:                *cclasses+=aclass;
                    120:        }
1.68      paf       121: 
1.79      misha     122:        void class_add(){
                    123:                if(cclass_new){
                    124:                        cclass=cclass_new;
                    125:                        // append to request's classes
                    126:                        request.classes().put(cclass->name(), cclass);
                    127:                        *cclasses+=cclass;
                    128:                        cclass_new=0;
                    129:                        append=false;
                    130:                }
                    131:        }
                    132: 
1.81      misha     133:        VStateless_class* get_existed_class(VStateless_class* aclass){
                    134:                if(aclass){
                    135:                        if(Value* class_value=request.classes().get(aclass->name())){
                    136:                                return class_value->get_class();
1.79      misha     137:                        }
                    138:                }
1.81      misha     139:                return 0;
                    140:        }
                    141: 
                    142:        bool reuse_existed_class(VStateless_class* aclass){
                    143:                if(aclass->is_partial()){
                    144:                        cclass=aclass;
                    145:                        cclass_new=0;
                    146:                        append=true;
                    147:                        return true;
                    148:                } else {
                    149:                        return false;
                    150:                }
1.79      misha     151:        }
                    152: 
                    153:        void set_all_vars_local(){
                    154:                if(cclass_new){
1.81      misha     155:                        cclass_new->set_all_vars_local();
1.79      misha     156:                } else {
1.81      misha     157:                        cclass->set_all_vars_local();
1.79      misha     158:                }
                    159:        }
                    160: 
1.68      paf       161:        void pos_next_line() {
                    162:                pos.line++;
                    163:                last_line_end_col=pos.col;
                    164:                pos.col=0;
                    165:        }
1.77      paf       166:        void pos_next_c(int c) {
1.68      paf       167:                if(c=='\t')
                    168:                        pos.col=(pos.col+TAB_SIZE)&~(TAB_SIZE-1);
                    169:                else
                    170:                        pos.col++;
                    171:        }
                    172:        /// not precise in case of \t in the middle of the text
                    173:        void pos_prev_c() {
                    174:                if(pos.col==0) {
                    175:                        --pos.line;  pos.col=last_line_end_col;
                    176:                } else
                    177:                        --pos.col;
                    178:        }
                    179:        void ungetc() {
                    180:                source--;
                    181:                pos_prev_c();
                    182:        }
1.1       paf       183: };
                    184: 
1.36      paf       185: /// New array // return empty array
1.68      paf       186: inline ArrayOperation* N() {
                    187:        return new ArrayOperation;
1.3       paf       188: }
                    189: 
1.36      paf       190: /// Assembler instruction // append ordinary instruction to ops
1.80      misha     191: inline void O(ArrayOperation& result, OP::OPCODE code) {
1.68      paf       192:        result+=Operation(code);
1.3       paf       193: }
                    194: 
1.36      paf       195: /// aPpend 'code_array' to 'result'
1.68      paf       196: inline void P(ArrayOperation& result, ArrayOperation& code_array) {
                    197:        result.append(code_array);
1.11      paf       198: }
1.36      paf       199: /// aPpend part of 'code_array', starting from offset, to 'result'
1.68      paf       200: inline void P(ArrayOperation& result, ArrayOperation& code_array, int offset) {
                    201:        result.append(code_array, offset);
1.3       paf       202: }
1.53      paf       203: 
1.84      misha     204: /// aPpend part of 'code_array', starting from offset, to 'result'
                    205: inline void P(ArrayOperation& result, ArrayOperation& code_array, int offset, int limit) {
                    206:        result.append(code_array, offset, limit);
                    207: }
                    208: 
1.68      paf       209: /// append cOde Array
1.80      misha     210: inline void OA(ArrayOperation& result, OP::OPCODE code, ArrayOperation* code_array) {
1.68      paf       211:        result+=Operation(code); // append OP_CODE
                    212:        result+=Operation(code_array); // append 'code_array'
1.61      paf       213: }
1.1       paf       214: 
1.36      paf       215: /**
                    216:        Value Literal // returns array with 
1.68      paf       217:        - first op: OP_VALUE instruction
                    218:        - second op: origin (debug information)
                    219:        - third op: string itself
1.36      paf       220: */
1.68      paf       221: inline ArrayOperation* VL(Value* value, uint file_no, uint line, uint col) {
1.61      paf       222:        // empty ops array
1.68      paf       223:        ArrayOperation& result=*N();
1.61      paf       224: 
                    225:        // append 'value' to 'result'
1.80      misha     226:        result+=Operation(OP::OP_VALUE);
1.68      paf       227:        result+=Operation(file_no, line, col); // append origin
                    228:        result+=Operation(value); // append 'value'
                    229: 
                    230:        return &result;
1.61      paf       231: }
                    232: 
1.68      paf       233: /// Literal Array to(2) Value @return Value from literal Array OP+origin+Value
1.85      misha     234: Value* LA2V(ArrayOperation& literal_string_array, int offset=0, OP::OPCODE code=OP::OP_VALUE);
1.68      paf       235: /// Literal Array to(2) String  @return String value from literal Array OP+origin+String array
1.85      misha     236: inline const String* LA2S(ArrayOperation& literal_string_array, int offset=0, OP::OPCODE code=OP::OP_VALUE) {
                    237:        if(Value* value=LA2V(literal_string_array, offset, code))
1.37      paf       238:                return value->get_string();
                    239:        return 0;
1.36      paf       240: }
1.61      paf       241: 
1.68      paf       242: inline void change_string_literal_to_write_string_literal(ArrayOperation& literal_string_array) {
1.80      misha     243:        literal_string_array.put(0, OP::OP_STRING__WRITE);
1.61      paf       244: }
                    245: 
1.89      misha     246: void maybe_change_string_literal_to_double_literal(ArrayOperation& literal_string_array);
                    247: 
                    248: void change_string_literal_value(ArrayOperation& literal_string_array, const String& new_value);
                    249: 
                    250: void changetail_or_append(ArrayOperation& opcodes, 
                    251:                                                  OP::OPCODE find, bool with_argument, OP::OPCODE replace, OP::OPCODE notfound);
                    252: 
1.86      misha     253: bool maybe_change_first_opcode(ArrayOperation& opcodes, OP::OPCODE find, OP::OPCODE replace, bool strict=false);
                    254: 
                    255: bool maybe_change_first_opcode(ArrayOperation& opcodes, OP::OPCODE find, OP::OPCODE last, OP::OPCODE replace);
                    256: 
1.87      misha     257: bool maybe_make_get_object_element(ArrayOperation& opcodes, ArrayOperation& diving_code, size_t divine_count);
                    258: 
                    259: bool maybe_make_get_object_var_element(ArrayOperation& opcodes, ArrayOperation& diving_code, size_t divine_count);
1.68      paf       260: 
1.92    ! misha     261: #ifdef OPTIMIZE_BYTECODE_GET_OBJECT_ELEMENT
1.89      misha     262: // OP_VALUE+origin+value+OP_GET_ELEMENT+OP_VALUE+origin+value+OP_GET_ELEMENT => OP_GET_OBJECT_ELEMENT+origin+value+[OP_VALUE]+origin+value+OP_GET_ELEMENT
                    263: inline bool maybe_make_get_object_element(ArrayOperation& opcodes, ArrayOperation& diving_code, size_t divine_count){
                    264:        if(divine_count!=8)
                    265:                return false;
                    266: 
                    267:        assert(diving_code[0].code==OP::OP_VALUE);
                    268:        if(
                    269:                diving_code[4].code==OP::OP_VALUE
                    270:                && diving_code[divine_count-1].code==OP::OP_GET_ELEMENT
                    271:        ){
                    272:                O(opcodes, OP::OP_GET_OBJECT_ELEMENT);
                    273:                P(opcodes, diving_code, 1/*offset*/, 2/*limit*/); // copy origin+value
                    274:                P(opcodes, diving_code, 5, 3); // copy specified tail
                    275:                return true;
                    276:        }
                    277:        return false;
                    278: }
1.92    ! misha     279: #endif
1.88      misha     280: 
1.92    ! misha     281: #ifdef OPTIMIZE_BYTECODE_GET_OBJECT_VAR_ELEMENT
1.89      misha     282: // OP_VALUE+origin+value+OP_GET_ELEMENT+OP_WITH_READ+OP_VALUE+origin+value+OP_GET_ELEMENT+OP_GET_ELEMENT => OP_GET_OBJECT_VAR_ELEMENT+origin+value+[OP_VALUE]+origin+value+OP_GET_ELEMENT
                    283: inline bool maybe_make_get_object_var_element(ArrayOperation& opcodes, ArrayOperation& diving_code, size_t divine_count){
                    284:        if(divine_count!=10)
                    285:                return false;
                    286: 
                    287:        assert(diving_code[0].code==OP::OP_VALUE);
                    288:        if(
                    289:                diving_code[4].code==OP::OP_WITH_READ
                    290:                && diving_code[5].code==OP::OP_VALUE
                    291:                && diving_code[divine_count-1].code==OP::OP_GET_ELEMENT
                    292:        ){
                    293:                O(opcodes, OP::OP_GET_OBJECT_VAR_ELEMENT);
                    294:                P(opcodes, diving_code, 1/*offset*/, 2/*limit*/); // copy origin+value
                    295:                P(opcodes, diving_code, 6, 3); // copy specified tail
                    296:                return true;
                    297:        }
                    298:        return false;
                    299: }
1.92    ! misha     300: #endif
1.68      paf       301: 
1.92    ! misha     302: #if defined(OPTIMIZE_BYTECODE_CONSTRUCT) || defined(OPTIMIZE_BYTECODE_CALL_CONSTRUCT)
1.89      misha     303: inline bool maybe_make_root_or_write_construct(ArrayOperation& opcodes, ArrayOperation& var_ops, ArrayOperation& expr_ops){
                    304:        if(
                    305:                var_ops.count()==4
                    306:                && (var_ops[0].code==OP::OP_WITH_ROOT || var_ops[0].code==OP::OP_WITH_WRITE)
                    307:        ){
                    308:                // OP_WITH_ROOT|OP_WITH_WRITE
                    309:                // OP_VALUE
                    310:                // origin
                    311:                // value
                    312:                size_t count=expr_ops.count();
                    313: 
                    314:                ArrayOperation* source=0;
1.92    ! misha     315:                size_t offset=1;
        !           316:                size_t limit=2;
        !           317:                OP::OPCODE code=OP::OP_VALUE;
1.89      misha     318:                bool with_root=(var_ops[0].code==OP::OP_WITH_ROOT);
                    319: 
                    320:                if(
                    321:                        expr_ops[0].code==OP::OP_PREPARE_TO_EXPRESSION
                    322:                        && expr_ops[count-1].code==OP::OP_CONSTRUCT_EXPR
                    323:                ){
1.92    ! misha     324:                        switch(count){
1.91      misha     325: #ifdef OPTIMIZE_BYTECODE_CONSTRUCT
1.92    ! misha     326:                                case 5: // count
        !           327:                                        {
        !           328:                                                if(expr_ops[1].code==OP::OP_VALUE){
        !           329:                                                        //      $a(1) $.a(2)
        !           330:                                                        //      OP_PREPARE_TO_EXPRESSION
        !           331:                                                        //      OP_VALUE
        !           332:                                                        //      origin
        !           333:                                                        //      value
        !           334:                                                        //      OP_CONSTRUCT_EXPR
        !           335:                                                        O(opcodes, with_root ? OP::OP_ROOT_CONSTRUCT_EXPR : OP::OP_WRITE_CONSTRUCT_EXPR);
        !           336:                                                        source=&expr_ops;
        !           337:                                                        offset=2;
        !           338:                                                }
        !           339:                                                else if(expr_ops[1].code==OP::OP_VALUE__GET_ELEMENT){
        !           340:                                                        //      $a($b) or $.a($b)
        !           341:                                                        //      OP_PREPARE_TO_EXPRESSION
        !           342:                                                        //      OP_VALUE__GET_ELEMENT
        !           343:                                                        //      origin
        !           344:                                                        //      value
        !           345:                                                        //      OP_CONSTRUCT_EXPR
        !           346:                                                        O(opcodes, with_root ? OP::OP_ROOT_ELEMENT_CONSTRUCT_EXPR : OP::OP_WRITE_ELEMENT_CONSTRUCT_EXPR);
        !           347:                                                        source=&expr_ops;
        !           348:                                                        offset=2;
        !           349:                                                }
        !           350:                                                break;
        !           351:                                        }
        !           352: #endif
        !           353: 
1.91      misha     354: #ifdef OPTIMIZE_BYTECODE_CALL_CONSTRUCT
1.92    ! misha     355:                                case 7: // count
        !           356:                                        {
        !           357:                                                if(
        !           358:                                                        expr_ops[1].code==OP::OP_VALUE__GET_ELEMENT_OR_OPERATOR
        !           359:                                                        && expr_ops[4].code==OP::OP_CALL
        !           360:                                                ){
        !           361:                                                        //      $a(^b[]) $.a(^b[])
        !           362:                                                        //      OP_PREPARE_TO_EXPRESSION
        !           363:                                                        //      VALUE__GET_ELEMENT_OR_OPERATOR
        !           364:                                                        //      origin
        !           365:                                                        //      value
        !           366:                                                        //      OP_CALL
        !           367:                                                        //              <empty params>
        !           368:                                                        //      OP_CONSTRUCT_EXPR
        !           369:                                                        O(opcodes, with_root ? OP::OP_ROOT_CALL_CONSTRUCT_EXPR : OP::OP_WRITE_CALL_CONSTRUCT_EXPR);
        !           370:                                                        source=&expr_ops;
        !           371:                                                        offset=2;
        !           372:                                                        limit=4;
        !           373:                                                }
        !           374:                                                break;
        !           375:                                        }
        !           376: #endif
        !           377: 
1.91      misha     378: #ifdef OPTIMIZE_BYTECODE_CONSTRUCT
1.92    ! misha     379:                                case 8: // count
        !           380:                                        {
        !           381:                                                if(expr_ops[1].code==OP::OP_GET_OBJECT_ELEMENT){
        !           382:                                                        //      $a($b.c) or $.a($b.c)
        !           383:                                                        //      OP_PREPARE_TO_EXPRESSION
        !           384:                                                        //      OP_GET_OBJECT_ELEMENT
        !           385:                                                        //      origin
        !           386:                                                        //      value
        !           387:                                                        //      origin
        !           388:                                                        //      value
        !           389:                                                        //      OP_GET_ELEMENT
        !           390:                                                        //      OP_CONSTRUCT_EXPR
        !           391:                                                        O(opcodes, with_root ? OP::OP_ROOT_OBJECT_ELEMENT_CONSTRUCT_EXPR : OP::OP_WRITE_OBJECT_ELEMENT_CONSTRUCT_EXPR);
        !           392:                                                        source=&expr_ops;
        !           393:                                                        code=OP::OP_GET_OBJECT_ELEMENT;
        !           394:                                                        offset=2;
        !           395:                                                        limit=4;
        !           396:                                                }
        !           397:                                                else if(expr_ops[1].code==OP::OP_GET_OBJECT_VAR_ELEMENT){
        !           398:                                                        //      $a($b.c) or $.a($b.c)
        !           399:                                                        //      OP_PREPARE_TO_EXPRESSION
        !           400:                                                        //      OP_GET_OBJECT_VAR_ELEMENT
        !           401:                                                        //      origin
        !           402:                                                        //      value
        !           403:                                                        //      origin
        !           404:                                                        //      value
        !           405:                                                        //      OP_GET_ELEMENT
        !           406:                                                        //      OP_CONSTRUCT_EXPR
        !           407:                                                        O(opcodes, with_root ? OP::OP_ROOT_OBJECT_VAR_ELEMENT_CONSTRUCT_EXPR : OP::OP_WRITE_OBJECT_VAR_ELEMENT_CONSTRUCT_EXPR);
        !           408:                                                        source=&expr_ops;
        !           409:                                                        code=OP::OP_GET_OBJECT_VAR_ELEMENT;
        !           410:                                                        offset=2;
        !           411:                                                        limit=4;
        !           412:                                                }
        !           413:                                                break;
        !           414:                                        }
1.91      misha     415: #endif
1.92    ! misha     416:                        } // switch
        !           417: 
        !           418:                }
        !           419:                else if(expr_ops[count-1].code==OP::OP_CONSTRUCT_VALUE){
        !           420:                        switch(count){
        !           421:                                case 3: // count
        !           422:                                        {
        !           423:                                                if(expr_ops[0].code==OP::OP_OBJECT_POOL){
        !           424:                                                        ArrayOperation& pool_ops=*expr_ops[1].ops;
        !           425: 
        !           426:                                                        switch(pool_ops.count()){
1.89      misha     427: 
1.91      misha     428: #ifdef OPTIMIZE_BYTECODE_CONSTRUCT
1.92    ! misha     429:                                                                case 3: // pool_count
        !           430:                                                                        {
        !           431:                                                                                if(pool_ops[0].code==OP::OP_VALUE__GET_ELEMENT__WRITE){
        !           432:                                                                                        //      $a[$b] $.a[$b]
        !           433:                                                                                        //      OP_OBJECT_POOL
        !           434:                                                                                        //              OP_VALUE__GET_ELEMENT__WRITE
        !           435:                                                                                        //              origin
        !           436:                                                                                        //              value
        !           437:                                                                                        //      OP_CONSTRUCT_VALUE
        !           438:                                                                                        O(opcodes, with_root ? OP::OP_ROOT_ELEMENT_CONSTRUCT_VALUE : OP::OP_WRITE_ELEMENT_CONSTRUCT_VALUE);
        !           439:                                                                                        source=&pool_ops;
        !           440:                                                                                }
        !           441:                                                                                break;
        !           442:                                                                        }
        !           443: #endif
        !           444: 
1.91      misha     445: #ifdef OPTIMIZE_BYTECODE_CALL_CONSTRUCT
1.92    ! misha     446:                                                                case 5: // pool_count
        !           447:                                                                        {
        !           448:                                                                                if(
        !           449:                                                                                        pool_ops[0].code==OP::OP_VALUE__GET_ELEMENT_OR_OPERATOR
        !           450:                                                                                        && pool_ops[3].code==OP::OP_CALL__WRITE
        !           451:                                                                                ){
        !           452:                                                                                        //      $a[^b[]] $.a[^b[]]
        !           453:                                                                                        //      OP_OBJECT_POOL
        !           454:                                                                                        //              OP_VALUE__GET_ELEMENT_OR_OPERATOR
        !           455:                                                                                        //              origin
        !           456:                                                                                        //              value
        !           457:                                                                                        //              OP_CALL__WRITE
        !           458:                                                                                        //                      <empty params>
        !           459:                                                                                        //      OP_CONSTRUCT_VALUE
        !           460:                                                                                        O(opcodes, with_root ? OP::OP_ROOT_CALL_CONSTRUCT_VALUE : OP::OP_WRITE_CALL_CONSTRUCT_VALUE);
        !           461:                                                                                        source=&pool_ops;
        !           462:                                                                                        limit=4;
        !           463:                                                                                }
        !           464:                                                                                break;
        !           465:                                                                        }
        !           466: #endif
        !           467: 
        !           468: #ifdef OPTIMIZE_BYTECODE_CONSTRUCT
        !           469:                                                                case 6: // pool_count
        !           470:                                                                        {
        !           471:                                                                                if(pool_ops[0].code==OP::OP_GET_OBJECT_ELEMENT__WRITE){
        !           472:                                                                                        //      $a[$b.c] $.a[$b.c]
        !           473:                                                                                        //      OP_OBJECT_POOL
        !           474:                                                                                        //              OP_GET_OBJECT_ELEMENT__WRITE
        !           475:                                                                                        //              origin
        !           476:                                                                                        //              value
        !           477:                                                                                        //              origin
        !           478:                                                                                        //              value
        !           479:                                                                                        //              OP_GET_ELEMENT
        !           480:                                                                                        //      OP_CONSTRUCT_VALUE
        !           481:                                                                                        O(opcodes, with_root ? OP::OP_ROOT_OBJECT_ELEMENT_CONSTRUCT_VALUE : OP::OP_WRITE_OBJECT_ELEMENT_CONSTRUCT_VALUE);
        !           482:                                                                                        source=&pool_ops;
        !           483:                                                                                        code=OP::OP_GET_OBJECT_ELEMENT;
        !           484:                                                                                        limit=4;
        !           485:                                                                                }
        !           486:                                                                                else if(pool_ops[0].code==OP::OP_GET_OBJECT_VAR_ELEMENT__WRITE){
        !           487:                                                                                        //      $a[$b.$c] $.a[$b.$c]
        !           488:                                                                                        //      OP_OBJECT_POOL
        !           489:                                                                                        //              OP_GET_OBJECT_VAR_ELEMENT__WRITE
        !           490:                                                                                        //              origin
        !           491:                                                                                        //              value
        !           492:                                                                                        //              origin
        !           493:                                                                                        //              value
        !           494:                                                                                        //              OP_GET_ELEMENT
        !           495:                                                                                        //      OP_CONSTRUCT_VALUE
        !           496:                                                                                        O(opcodes, with_root ? OP::OP_ROOT_OBJECT_VAR_ELEMENT_CONSTRUCT_VALUE : OP::OP_WRITE_OBJECT_VAR_ELEMENT_CONSTRUCT_VALUE);
        !           497:                                                                                        source=&pool_ops;
        !           498:                                                                                        code=OP::OP_GET_OBJECT_VAR_ELEMENT__WRITE;
        !           499:                                                                                        limit=4;
        !           500:                                                                                }
        !           501:                                                                                break;
        !           502:                                                                        }
        !           503: #endif
        !           504:                                                        }
        !           505:                                                }
        !           506:                                                break;
        !           507:                                        }
        !           508: 
        !           509: #ifdef OPTIMIZE_BYTECODE_CONSTRUCT
        !           510:                                case 4: // count
        !           511:                                        {
        !           512:                                                if(expr_ops[0].code==OP::OP_VALUE){
        !           513:                                                        //      $a[b] $.a[b]
        !           514:                                                        //      OP_VALUE
        !           515:                                                        //      origin
        !           516:                                                        //      value
        !           517:                                                        //      OP_CONSTRUCT_VALUE
        !           518:                                                        O(opcodes, with_root ? OP::OP_ROOT_CONSTRUCT_VALUE : OP::OP_WRITE_CONSTRUCT_VALUE);
        !           519:                                                        source=&expr_ops;
        !           520:                                                }
        !           521:                                                break;
        !           522:                                        }
        !           523: #endif
        !           524:                        } // switch
1.89      misha     525:                }
1.68      paf       526: 
1.89      misha     527:                if(source){
                    528:                        P(opcodes, var_ops, 2/*offset*/, 2/*limit*/); // copy 1st origin+value
1.92    ! misha     529:                        if(limit!=2)
        !           530:                                O(opcodes, code);
1.89      misha     531:                        P(opcodes, *source, offset, limit);
                    532:                        return true;
                    533:                }
                    534:        }
                    535:        return false;
                    536: }
1.92    ! misha     537: #endif
1.61      paf       538: 
1.1       paf       539: 
1.68      paf       540: void push_LS(Parse_control& pc, lexical_state new_state);
                    541: void pop_LS(Parse_control& pc);
1.1       paf       542: 
                    543: #endif

E-mail: