--- parser3/src/main/compile.tab.C 2009/05/19 08:59:51 1.131 +++ parser3/src/main/compile.tab.C 2010/04/28 17:56:22 1.147 @@ -129,10 +129,10 @@ /** @file Parser: compiler(lexical parser and grammar). - Copyright (c) 2001-2005 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2001-2009 ArtLebedev Group (http://www.artlebedev.com) Author: Alexander Petrosyan (http://design.ru/paf) - $Id: compile.tab.C,v 1.131 2009/05/19 08:59:51 misha Exp $ + $Id: compile.tab.C,v 1.147 2010/04/28 17:56:22 pretender Exp $ */ /** @@ -459,21 +459,21 @@ static const unsigned short int yyrline[ 0, 132, 132, 139, 141, 141, 142, 144, 144, 146, 247, 247, 248, 248, 249, 250, 250, 252, 252, 302, 302, 303, 304, 304, 305, 305, 307, 307, 311, 311, - 313, 313, 314, 314, 315, 315, 315, 319, 348, 349, - 349, 350, 352, 353, 354, 410, 411, 411, 415, 420, - 421, 422, 423, 440, 445, 448, 449, 450, 452, 455, - 452, 463, 471, 478, 479, 480, 482, 488, 489, 489, - 493, 504, 507, 504, 531, 533, 533, 535, 536, 537, - 539, 542, 539, 545, 546, 548, 549, 552, 553, 556, - 557, 559, 562, 576, 581, 582, 583, 588, 588, 590, - 590, 591, 592, 600, 605, 608, 609, 610, 611, 613, - 617, 626, 629, 626, 637, 642, 642, 643, 649, 650, - 652, 669, 681, 683, 684, 685, 686, 687, 688, 689, - 690, 692, 693, 694, 695, 696, 697, 698, 699, 701, - 702, 703, 704, 705, 706, 707, 708, 709, 710, 711, - 712, 713, 714, 715, 716, 717, 718, 719, 720, 721, - 722, 723, 724, 725, 726, 727, 730, 735, 756, 761, - 762, 763, 765 + 313, 313, 314, 314, 315, 315, 315, 319, 360, 361, + 361, 362, 364, 365, 366, 419, 420, 420, 424, 437, + 438, 439, 440, 466, 471, 474, 475, 476, 478, 481, + 478, 489, 497, 504, 505, 506, 508, 514, 515, 515, + 519, 531, 534, 531, 578, 580, 580, 582, 583, 584, + 586, 589, 586, 592, 593, 595, 596, 599, 600, 603, + 604, 606, 609, 623, 628, 629, 630, 635, 635, 637, + 637, 638, 639, 647, 652, 655, 656, 657, 658, 660, + 664, 673, 676, 673, 684, 689, 689, 690, 696, 697, + 699, 716, 728, 730, 731, 732, 733, 734, 735, 736, + 737, 739, 740, 741, 742, 743, 744, 745, 746, 748, + 749, 750, 751, 752, 753, 754, 755, 756, 757, 758, + 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, + 769, 770, 771, 772, 773, 774, 777, 782, 803, 808, + 809, 810, 812 }; #endif @@ -1430,11 +1430,11 @@ yyreduce: case 2: #line 132 "compile.y" { - Method& method=*new Method(Method::CT_ANY, + Method* method=new Method(Method::CT_ANY, 0, 0, /*min, max numbered_params_count*/ 0/*param_names*/, 0/*local_names*/, yyvsp[0]/*parser_code*/, 0/*native_code*/); - PC.cclass->add_method(PC.alias_method(main_method_name), method); + PC.cclass->set_method(PC.alias_method(main_method_name), method); ;} break; @@ -1480,7 +1480,7 @@ yyreduce: } if(strings_code->count()==1*OPERATIONS_PER_OPVALUE) { const String& base_name=*LA2S(*strings_code); - if(Value* base_class_value=PC.request.classes().get(base_name)) { + if(Value* base_class_value=PC.request.get_class(base_name)) { // @CLASS == @BASE sanity check if(VStateless_class *base_class=base_class_value->get_class()) { if(PC.cclass==base_class) { @@ -1595,13 +1595,13 @@ yyreduce: case 18: #line 292 "compile.y" { - Method& method=*reinterpret_cast(yyvsp[-1]); + Method* method=reinterpret_cast(yyvsp[-1]); // fill in the code - method.parser_code=yyvsp[0]; + method->parser_code=yyvsp[0]; // register in class const String& name=*LA2S(*yyvsp[-6]); - PC.cclass->add_method(PC.alias_method(name), method); + PC.cclass->set_method(PC.alias_method(name), method); ;} break; @@ -1625,136 +1625,162 @@ yyreduce: { yyval=N(); YYSTYPE code=yyvsp[0]; + size_t count=code->count(); + #ifdef OPTIMIZE_BYTECODE_GET_ELEMENT - if(!replace_top_opcode(*code, OP::OP_VALUE__GET_ELEMENT, /*=>*/OP::OP_VALUE__GET_ELEMENT__WRITE)) -#endif - { -#ifdef OPTIMIZE_BYTECODE_GET_ELEMENT_FIELD - size_t count=code->count(); - if( -#ifdef OPTIMIZE_BYTECODE_USE_TWO_OPERANDS_INSTRUCTIONS - count==6 -#else - count==7 + if( + count!=3 + || !maybe_change_first_opcode(*code, OP::OP_VALUE__GET_ELEMENT, /*=>*/OP::OP_VALUE__GET_ELEMENT__WRITE) + ) +#endif + +#ifdef OPTIMIZE_BYTECODE_GET_SELF_ELEMENT + if( + count!=3 + || !maybe_change_first_opcode(*code, OP::OP_WITH_SELF__VALUE__GET_ELEMENT, /*=>*/OP::OP_WITH_SELF__VALUE__GET_ELEMENT__WRITE) + ) +#endif + +#ifdef OPTIMIZE_BYTECODE_GET_OBJECT_ELEMENT + if( + count!=5 + || !maybe_change_first_opcode(*code, OP::OP_GET_OBJECT_ELEMENT, /*=>*/OP::OP_GET_OBJECT_ELEMENT__WRITE) + ) +#endif + +#ifdef OPTIMIZE_BYTECODE_GET_OBJECT_VAR_ELEMENT + if( + count!=5 + || !maybe_change_first_opcode(*code, OP::OP_GET_OBJECT_VAR_ELEMENT, /*=>*/OP::OP_GET_OBJECT_VAR_ELEMENT__WRITE) + ) #endif - && (*code)[count-1].code==OP::OP_GET_ELEMENT - && replace_top_opcode(*code, OP::OP_GET_ELEMENT_FIELD, /*=>*/OP::OP_GET_ELEMENT_FIELD__WRITE) - ){ - //P(*$$, *code, 0/*offset*/, count-1/*limit*/); // someday skip last OP_GET_ELEMENT - //break; - } else -#endif - changetail_or_append(*code, - OP::OP_GET_ELEMENT, false, /*=>*/OP::OP_GET_ELEMENT__WRITE, - /*or */OP::OP_WRITE_VALUE - ); /* value=pop; wcontext.write(value) */ - } + { + changetail_or_append(*code, + OP::OP_GET_ELEMENT, false, /*=>*/OP::OP_GET_ELEMENT__WRITE, + /*or */OP::OP_WRITE_VALUE + ); /* value=pop; wcontext.write(value) */ + } + P(*yyval, *code); ;} break; case 38: -#line 348 "compile.y" +#line 360 "compile.y" { yyval=yyvsp[0] ;} break; case 41: -#line 350 "compile.y" +#line 362 "compile.y" { yyval=yyvsp[-1] ;} break; case 44: -#line 354 "compile.y" +#line 366 "compile.y" { yyval=N(); YYSTYPE diving_code=yyvsp[0]; - const String* first_name=LA2S(*diving_code); - // self.xxx... => xxx... - // OP_VALUE+origin+string+OP_GET_ELEMENT+... -> OP_WITH_SELF+... - if(first_name && *first_name==SELF_ELEMENT_NAME) { - O(*yyval, OP::OP_WITH_SELF); /* stack: starting context */ - P(*yyval, *diving_code, - /* skip over... */ - diving_code->count()>=4?4/*OP::OP_VALUE+origin+string+OP::OP_GET_ELEMENTx*/:3/*OP::OP_+origin+string*/); - } else { -#ifdef OPTIMIZE_BYTECODE_GET_ELEMENT - size_t count=diving_code->count(); - if(count==4){ // optimization - O(*yyval, - (PC.in_call_value) - ? OP::OP_VALUE__GET_ELEMENT_OR_OPERATOR // ^object[ : OP_VALUE+origin+string+OP_GET_ELEMENT => OP_VALUE__GET_ELEMENT_OR_OPERATOR+origin+string - : OP::OP_VALUE__GET_ELEMENT // $object : OP_VALUE+origin+string+OP_GET_ELEMENT => OP_VALUE__GET_ELEMENT+origin+string - ); - P(*yyval, *diving_code, 1/*offset*/, 2/*limit*/); // copy origin+value - } -#ifdef OPTIMIZE_BYTECODE_GET_ELEMENT_FIELD - else if( - count==8 - && (*diving_code)[7].code==OP::OP_GET_ELEMENT - && replace_top_opcode(*diving_code, OP::OP_VALUE, /*=>*/OP::OP_GET_ELEMENT_FIELD) - ){ - // optimisation for ^object.method[ + $object.field - // OP_VALUE+origin+value+OP_GET_ELEMENT+OP_VALUE+origin+value+OP_GET_ELEMENT => OP_GET_ELEMENT_FIELD+origin+value+OP_VALUE+origin+value+OP_GET_ELEMENT - // OP_VALUE+origin+value+OP_GET_ELEMENT+OP_VALUE+origin+value+OP_GET_ELEMENT - // offset 0 1 2 3 4 5 6 7 - P(*yyval, *diving_code, 0/*offset*/, 3/*limit*/); // copy OP_GET_ELEMENT_FIELD+origin+value (skip first OP_GET_ELEMENT) -#ifdef OPTIMIZE_BYTECODE_USE_TWO_OPERANDS_INSTRUCTIONS - P(*yyval, *diving_code, 5/*offset*/, 3/*limit*/); // copy origin+value+OP_GET_ELEMENT (last one is important!) -#else - P(*yyval, *diving_code, 4/*offset*/, 4/*limit*/); // copy OP_VALUE+origin+value+OP_GET_ELEMENT (last one is important!) + size_t count=diving_code->count(); + + if(maybe_make_self(*yyval, *diving_code, count)) { + // $self. + } else + +#ifdef OPTIMIZE_BYTECODE_GET_OBJECT_ELEMENT + if(maybe_make_get_object_element(*yyval, *diving_code, count)){ + // optimization for $object.field + ^object.method[ + } else #endif - } + +#ifdef OPTIMIZE_BYTECODE_GET_OBJECT_VAR_ELEMENT + if(maybe_make_get_object_var_element(*yyval, *diving_code, count)){ + // optimization for $object.$var + } else #endif - else { - O(*yyval, OP::OP_WITH_READ); /* stack: starting context */ - P(*yyval, *diving_code); - } + +#ifdef OPTIMIZE_BYTECODE_GET_ELEMENT + if( + count>=4 + && (*diving_code)[0].code==OP::OP_VALUE + && (*diving_code)[3].code==OP::OP_GET_ELEMENT + ){ + // optimization + O(*yyval, + (PC.in_call_value && count==4) + ? OP::OP_VALUE__GET_ELEMENT_OR_OPERATOR // ^object[ : OP_VALUE+origin+string+OP_GET_ELEMENT => OP_VALUE__GET_ELEMENT_OR_OPERATOR+origin+string + : OP::OP_VALUE__GET_ELEMENT // $object : OP_VALUE+origin+string+OP_GET_ELEMENT => OP_VALUE__GET_ELEMENT+origin+string + ); + P(*yyval, *diving_code, 1/*offset*/, 2/*limit*/); // copy origin+value + if(count>4) + P(*yyval, *diving_code, 4); // copy tail + } else { + O(*yyval, OP::OP_WITH_READ); /* stack: starting context */ + P(*yyval, *diving_code); + } #else + { O(*yyval, OP::OP_WITH_READ); /* stack: starting context */ // ^if OP_ELEMENT => ^if OP_ELEMENT_OR_OPERATOR // optimized OP_VALUE+origin+string+OP_GET_ELEMENT. => OP_VALUE+origin+string+OP_GET_ELEMENT_OR_OPERATOR. - if(PC.in_call_value && diving_code->count()==4) - diving_code->put(4-1, OP::OP_GET_ELEMENT_OR_OPERATOR); + if(PC.in_call_value && count==4) + diving_code->put(count-1, OP::OP_GET_ELEMENT_OR_OPERATOR); P(*yyval, *diving_code); -#endif } +#endif /* diving code; stack: current context */ ;} break; case 45: -#line 410 "compile.y" +#line 419 "compile.y" { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ;} break; case 47: -#line 411 "compile.y" +#line 420 "compile.y" { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ;} break; case 48: -#line 415 "compile.y" +#line 424 "compile.y" { - yyval=yyvsp[-1]; /* stack: context,name */ - P(*yyval, *yyvsp[0]); /* stack: context,name,constructor_value */ + yyval=N(); +#ifdef OPTIMIZE_BYTECODE_CONSTRUCT + if(maybe_optimize_construct(*yyval, *yyvsp[-1], *yyvsp[0])){ + // $a(expr), $.a(expr), $a[value], $.a[value], $self.a[value], $self.a(expr) + } else +#endif + { + P(*yyval, *yyvsp[-1]); /* stack: context,name */ + P(*yyval, *yyvsp[0]); /* stack: context,name,constructor_value */ + } ;} break; case 52: -#line 423 "compile.y" +#line 440 "compile.y" { yyval=N(); YYSTYPE diving_code=yyvsp[0]; - const String* first_name=LA2S(*diving_code); - // $self.xxx... => $xxx... - // OP_VALUE+origin+string+OP_GET_ELEMENT+... => OP_WITH_SELF+... - if(first_name && *first_name==SELF_ELEMENT_NAME) { - O(*yyval, OP::OP_WITH_SELF); /* stack: starting context */ - P(*yyval, *diving_code, - /* skip over... */ - diving_code->count()>=4?4/*OP::OP_VALUE+origin+string+OP::OP_GET_ELEMENTx*/:3/*OP::OP_+origin+string*/); - } else { + size_t count=diving_code->count(); + + if(maybe_make_self(*yyval, *diving_code, count)) { + // $self. + } else +#ifdef OPTIMIZE_BYTECODE_GET_ELEMENT + if( + count>=4 + && (*diving_code)[0].code==OP::OP_VALUE + && (*diving_code)[3].code==OP::OP_GET_ELEMENT + ){ + O(*yyval, OP::OP_WITH_ROOT__VALUE__GET_ELEMENT); + P(*yyval, *diving_code, 1/*offset*/, 2/*limit*/); // copy origin+value + if(count>4) + P(*yyval, *diving_code, 4); // tail + } else +#endif + { O(*yyval, OP::OP_WITH_ROOT); /* stack: starting context */ P(*yyval, *diving_code); } @@ -1763,7 +1789,7 @@ yyreduce: break; case 53: -#line 440 "compile.y" +#line 466 "compile.y" { yyval=N(); O(*yyval, OP::OP_WITH_WRITE); /* stack: starting context */ @@ -1772,12 +1798,12 @@ yyreduce: break; case 54: -#line 445 "compile.y" +#line 471 "compile.y" { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ;} break; case 58: -#line 452 "compile.y" +#line 478 "compile.y" { // allow $result_or_other_variable[ letters here any time ] *reinterpret_cast(&yyval)=PC.explicit_result; PC.explicit_result=false; @@ -1785,14 +1811,14 @@ yyreduce: break; case 59: -#line 455 "compile.y" +#line 481 "compile.y" { PC.explicit_result=*reinterpret_cast(&yyvsp[-1]); ;} break; case 60: -#line 457 "compile.y" +#line 483 "compile.y" { // stack: context, name yyval=yyvsp[-2]; // stack: context, name, value @@ -1801,7 +1827,7 @@ yyreduce: break; case 61: -#line 463 "compile.y" +#line 489 "compile.y" { yyval=N(); O(*yyval, OP::OP_PREPARE_TO_EXPRESSION); @@ -1812,7 +1838,7 @@ yyreduce: break; case 62: -#line 471 "compile.y" +#line 497 "compile.y" { // stack: context, name yyval=N(); @@ -1821,7 +1847,7 @@ yyreduce: break; case 66: -#line 482 "compile.y" +#line 508 "compile.y" { yyval=N(); OA(*yyval, OP::OP_OBJECT_POOL, yyvsp[0]); /* stack: empty write context */ @@ -1831,51 +1857,54 @@ yyreduce: break; case 69: -#line 489 "compile.y" +#line 515 "compile.y" { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ;} break; case 70: -#line 493 "compile.y" +#line 519 "compile.y" { #ifdef OPTIMIZE_BYTECODE_CUT_REM_OPERATOR if((*yyvsp[0]).count()) #endif { yyval=yyvsp[0]; /* stack: value */ - changetail_or_append(*yyval, - OP::OP_CALL, true, /*=>*/ OP::OP_CALL__WRITE, - /*or */OP::OP_WRITE_VALUE); /* value=pop; wcontext.write(value) */ + if(!maybe_change_first_opcode(*yyval, OP::OP_CONSTRUCT_OBJECT, /*=>*/OP::OP_CONSTRUCT_OBJECT__WRITE)) + changetail_or_append(*yyval, + OP::OP_CALL, true, /*=>*/ OP::OP_CALL__WRITE, + /*or */OP::OP_WRITE_VALUE); /* value=pop; wcontext.write(value) */ } ;} break; case 71: -#line 504 "compile.y" +#line 531 "compile.y" { PC.in_call_value=true; ;} break; case 72: -#line 507 "compile.y" +#line 534 "compile.y" { PC.in_call_value=false; ;} break; case 73: -#line 510 "compile.y" +#line 537 "compile.y" { /* ^field.$method{vasya} */ #ifdef OPTIMIZE_BYTECODE_CUT_REM_OPERATOR +#ifdef OPTIMIZE_BYTECODE_GET_ELEMENT const String* operator_name=LA2S(*yyvsp[-3], 0, OP::OP_VALUE__GET_ELEMENT_OR_OPERATOR); - if(operator_name && *operator_name == REM_OPERATOR_NAME){ +#else + const String* operator_name=LA2S(*yyvsp[-3], 1); +#endif + if(operator_name && *operator_name==REM_OPERATOR_NAME){ yyval=N(); } else #endif { - yyval=yyvsp[-3]; /* with_xxx,diving code; stack: context,method_junction */ - YYSTYPE params_code=yyvsp[-1]; if(params_code->count()==3) { // probably [] case. [OP::OP_VALUE+origin+Void] if(Value* value=LA2V(*params_code)) // it is OP_VALUE+origin+value? @@ -1883,18 +1912,36 @@ yyreduce: params_code=0; // ^zzz[] case. don't append lone empty param. } /* stack: context, method_junction */ - OA(*yyval, OP::OP_CALL, params_code); // method_frame=make frame(pop junction); ncontext=pop; call(ncontext,method_frame) stack: value + + YYSTYPE var_code=yyvsp[-3]; + if( + var_code->count()==8 + && (*var_code)[0].code==OP::OP_VALUE__GET_CLASS + && (*var_code)[3].code==OP::OP_PREPARE_TO_CONSTRUCT_OBJECT + && (*var_code)[4].code==OP::OP_VALUE + && (*var_code)[7].code==OP::OP_GET_ELEMENT + ){ + yyval=N(); + O(*yyval, OP::OP_CONSTRUCT_OBJECT); + P(*yyval, *var_code, 1/*offset*/, 2/*limit*/); // class name + P(*yyval, *var_code, 5/*offset*/, 2/*limit*/); // constructor name + OA(*yyval, params_code); + } else + { + yyval=var_code; /* with_xxx,diving code; stack: context,method_junction */ + OA(*yyval, OP::OP_CALL, params_code); // method_frame=make frame(pop junction); ncontext=pop; call(ncontext,method_frame) stack: value + } } ;} break; case 76: -#line 533 "compile.y" +#line 580 "compile.y" { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ;} break; case 80: -#line 539 "compile.y" +#line 586 "compile.y" { // allow ^call[ letters here any time ] *reinterpret_cast(&yyval)=PC.explicit_result; PC.explicit_result=false; @@ -1902,51 +1949,51 @@ yyreduce: break; case 81: -#line 542 "compile.y" +#line 589 "compile.y" { PC.explicit_result=*reinterpret_cast(&yyvsp[-1]); ;} break; case 82: -#line 544 "compile.y" +#line 591 "compile.y" {yyval=yyvsp[-2];} break; case 83: -#line 545 "compile.y" +#line 592 "compile.y" {yyval=yyvsp[-1];} break; case 84: -#line 546 "compile.y" +#line 593 "compile.y" {yyval=yyvsp[-1];} break; case 86: -#line 549 "compile.y" +#line 596 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]) ;} break; case 88: -#line 553 "compile.y" +#line 600 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]) ;} break; case 90: -#line 557 "compile.y" +#line 604 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]) ;} break; case 91: -#line 559 "compile.y" +#line 606 "compile.y" { yyval=yyvsp[0]; ;} break; case 92: -#line 562 "compile.y" +#line 609 "compile.y" { YYSTYPE expr_code=yyvsp[0]; if(expr_code->count()==3 @@ -1964,7 +2011,7 @@ yyreduce: break; case 93: -#line 576 "compile.y" +#line 623 "compile.y" { yyval=N(); OA(*yyval, OP::OP_CURLY_CODE__STORE_PARAM, yyvsp[0]); @@ -1972,17 +2019,17 @@ yyreduce: break; case 98: -#line 588 "compile.y" +#line 635 "compile.y" { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ;} break; case 100: -#line 590 "compile.y" +#line 637 "compile.y" { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ;} break; case 102: -#line 592 "compile.y" +#line 639 "compile.y" { // we know that name_advance1 not called from ^xxx context // so we'll not check for operator call possibility as we do in name_advance2 @@ -1994,7 +2041,7 @@ yyreduce: break; case 103: -#line 600 "compile.y" +#line 647 "compile.y" { /* stack: context */ yyval=yyvsp[0]; /* stack: context,name */ @@ -2003,7 +2050,7 @@ yyreduce: break; case 109: -#line 613 "compile.y" +#line 660 "compile.y" { yyval=yyvsp[0]; O(*yyval, OP::OP_GET_ELEMENT); @@ -2011,7 +2058,7 @@ yyreduce: break; case 110: -#line 617 "compile.y" +#line 664 "compile.y" { YYSTYPE code; { @@ -2024,7 +2071,7 @@ yyreduce: break; case 111: -#line 626 "compile.y" +#line 673 "compile.y" { // allow $result_or_other_variable[ letters here any time ] *reinterpret_cast(&yyval)=PC.explicit_result; PC.explicit_result=false; @@ -2032,14 +2079,14 @@ yyreduce: break; case 112: -#line 629 "compile.y" +#line 676 "compile.y" { PC.explicit_result=*reinterpret_cast(&yyvsp[-1]); ;} break; case 113: -#line 631 "compile.y" +#line 678 "compile.y" { yyval=N(); OA(*yyval, OP::OP_OBJECT_POOL, yyvsp[-2]); /* stack: empty write context */ @@ -2049,7 +2096,7 @@ yyreduce: break; case 114: -#line 637 "compile.y" +#line 684 "compile.y" { yyval=N(); O(*yyval, OP::OP_WITH_READ); @@ -2058,12 +2105,12 @@ yyreduce: break; case 116: -#line 642 "compile.y" +#line 689 "compile.y" { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ;} break; case 117: -#line 643 "compile.y" +#line 690 "compile.y" { yyval=yyvsp[0]; O(*yyval, OP::OP_GET_ELEMENT__WRITE); @@ -2071,7 +2118,7 @@ yyreduce: break; case 120: -#line 652 "compile.y" +#line 699 "compile.y" { yyval=yyvsp[-1]; // stack: class name string if(*LA2S(*yyval) == BASE_NAME) { // pseudo BASE class @@ -2082,17 +2129,13 @@ yyreduce: YYERROR; } } -#ifdef OPTIMIZE_BYTECODE_GET_CLASS // optimized OP_VALUE+origin+string+OP_GET_CLASS => OP_VALUE__GET_CLASS+origin+string - replace_top_opcode(*yyval, OP::OP_VALUE, OP::OP_VALUE__GET_CLASS, true/*assert if top opcode != OP_VALUE*/) -#else - O(*yyval, OP::OP_GET_CLASS); -#endif + maybe_change_first_opcode(*yyval, OP::OP_VALUE, OP::OP_VALUE__GET_CLASS) ;} break; case 121: -#line 669 "compile.y" +#line 716 "compile.y" { yyval=yyvsp[-1]; if(!PC.in_call_value) { @@ -2104,197 +2147,197 @@ yyreduce: break; case 128: -#line 688 "compile.y" +#line 735 "compile.y" { yyval = yyvsp[-1] ;} break; case 129: -#line 689 "compile.y" +#line 736 "compile.y" { yyval = yyvsp[-1] ;} break; case 130: -#line 690 "compile.y" +#line 737 "compile.y" { yyval = yyvsp[-1]; ;} break; case 131: -#line 692 "compile.y" +#line 739 "compile.y" { yyval=yyvsp[0]; O(*yyval, OP::OP_NEG) ;} break; case 132: -#line 693 "compile.y" +#line 740 "compile.y" { yyval=yyvsp[0] ;} break; case 133: -#line 694 "compile.y" +#line 741 "compile.y" { yyval=yyvsp[0]; O(*yyval, OP::OP_INV) ;} break; case 134: -#line 695 "compile.y" +#line 742 "compile.y" { yyval=yyvsp[0]; O(*yyval, OP::OP_NOT) ;} break; case 135: -#line 696 "compile.y" +#line 743 "compile.y" { yyval=yyvsp[0]; O(*yyval, OP::OP_DEF) ;} break; case 136: -#line 697 "compile.y" +#line 744 "compile.y" { yyval=yyvsp[0]; O(*yyval, OP::OP_IN) ;} break; case 137: -#line 698 "compile.y" +#line 745 "compile.y" { yyval=yyvsp[0]; O(*yyval, OP::OP_FEXISTS) ;} break; case 138: -#line 699 "compile.y" +#line 746 "compile.y" { yyval=yyvsp[0]; O(*yyval, OP::OP_DEXISTS) ;} break; case 139: -#line 701 "compile.y" +#line 748 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_SUB) ;} break; case 140: -#line 702 "compile.y" +#line 749 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_ADD) ;} break; case 141: -#line 703 "compile.y" +#line 750 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_MUL) ;} break; case 142: -#line 704 "compile.y" +#line 751 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_DIV) ;} break; case 143: -#line 705 "compile.y" +#line 752 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_MOD) ;} break; case 144: -#line 706 "compile.y" +#line 753 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_INTDIV) ;} break; case 145: -#line 707 "compile.y" +#line 754 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_BIN_SL) ;} break; case 146: -#line 708 "compile.y" +#line 755 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_BIN_SR) ;} break; case 147: -#line 709 "compile.y" +#line 756 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_BIN_AND) ;} break; case 148: -#line 710 "compile.y" +#line 757 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_BIN_OR) ;} break; case 149: -#line 711 "compile.y" +#line 758 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_BIN_XOR) ;} break; case 150: -#line 712 "compile.y" +#line 759 "compile.y" { yyval=yyvsp[-2]; OA(*yyval, OP::OP_NESTED_CODE, yyvsp[0]); O(*yyval, OP::OP_LOG_AND) ;} break; case 151: -#line 713 "compile.y" +#line 760 "compile.y" { yyval=yyvsp[-2]; OA(*yyval, OP::OP_NESTED_CODE, yyvsp[0]); O(*yyval, OP::OP_LOG_OR) ;} break; case 152: -#line 714 "compile.y" +#line 761 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_LOG_XOR) ;} break; case 153: -#line 715 "compile.y" +#line 762 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_NUM_LT) ;} break; case 154: -#line 716 "compile.y" +#line 763 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_NUM_GT) ;} break; case 155: -#line 717 "compile.y" +#line 764 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_NUM_LE) ;} break; case 156: -#line 718 "compile.y" +#line 765 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_NUM_GE) ;} break; case 157: -#line 719 "compile.y" +#line 766 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_NUM_EQ) ;} break; case 158: -#line 720 "compile.y" +#line 767 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_NUM_NE) ;} break; case 159: -#line 721 "compile.y" +#line 768 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_STR_LT) ;} break; case 160: -#line 722 "compile.y" +#line 769 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_STR_GT) ;} break; case 161: -#line 723 "compile.y" +#line 770 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_STR_LE) ;} break; case 162: -#line 724 "compile.y" +#line 771 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_STR_GE) ;} break; case 163: -#line 725 "compile.y" +#line 772 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_STR_EQ) ;} break; case 164: -#line 726 "compile.y" +#line 773 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_STR_NE) ;} break; case 165: -#line 727 "compile.y" +#line 774 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_IS) ;} break; case 166: -#line 730 "compile.y" +#line 777 "compile.y" { // optimized OP_STRING => OP_VALUE for doubles maybe_change_string_literal_to_double_literal(*(yyval=yyvsp[0])); @@ -2302,13 +2345,13 @@ yyreduce: break; case 167: -#line 735 "compile.y" +#line 782 "compile.y" { #ifdef OPTIMIZE_BYTECODE_STRING_POOL // it brakes ^if(" 09 "){...} YYSTYPE code=yyvsp[0]; yyval=N(); - if(code->count()==3 && replace_top_opcode(*code, OP::OP_STRING__WRITE, OP::OP_VALUE)){ + if(code->count()==3 && maybe_change_first_opcode(*code, OP::OP_STRING__WRITE, OP::OP_VALUE)){ // optimized OP_STRING__WRITE+origin+value => OP_VALUE+origin+value without starting OP_STRING_POOL P(*yyval, *code); } else { @@ -2324,7 +2367,7 @@ yyreduce: break; case 168: -#line 756 "compile.y" +#line 803 "compile.y" { // optimized OP_STRING+OP_WRITE_VALUE => OP_STRING__WRITE change_string_literal_to_write_string_literal(*(yyval=yyvsp[0])) @@ -2332,22 +2375,22 @@ yyreduce: break; case 169: -#line 761 "compile.y" +#line 808 "compile.y" { yyval=VL(/*we know that we will not change it*/const_cast(&vvoid), 0, 0, 0) ;} break; case 170: -#line 762 "compile.y" +#line 809 "compile.y" { yyval = VL(/*we know that we will not change it*/const_cast(&vtrue), 0, 0, 0) ;} break; case 171: -#line 763 "compile.y" +#line 810 "compile.y" { yyval = VL(/*we know that we will not change it*/const_cast(&vfalse), 0, 0, 0) ;} break; case 172: -#line 765 "compile.y" +#line 812 "compile.y" { yyval=N() ;} break; @@ -2355,7 +2398,7 @@ yyreduce: } /* Line 1010 of yacc.c. */ -#line 2359 "compile.tab.C" +#line 2406 "compile.tab.C" yyvsp -= yylen; yyssp -= yylen; @@ -2580,7 +2623,7 @@ yyreturn: } -#line 767 "compile.y" +#line 814 "compile.y" #endif @@ -3120,7 +3163,7 @@ default: case ']': case '}': case ')': case '"': case '\'': case '<': case '>': // these stand for HTML brackets AND expression binary ops - case '+': case '*': case '/': case '%': + case '+': case '*': case '/': case '\\': case '%': case '&': case '|': case '=': case '!': // common delimiters