--- parser3/src/main/compile.tab.C 2009/05/20 09:28:54 1.133 +++ parser3/src/main/compile.tab.C 2009/05/24 07:55:50 1.136 @@ -132,7 +132,7 @@ Copyright (c) 2001-2009 ArtLebedev Group (http://www.artlebedev.com) Author: Alexander Petrosyan (http://design.ru/paf) - $Id: compile.tab.C,v 1.133 2009/05/20 09:28:54 misha Exp $ + $Id: compile.tab.C,v 1.136 2009/05/24 07:55:50 misha 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, 360, 361, - 361, 362, 364, 365, 366, 420, 421, 421, 425, 430, - 431, 432, 433, 450, 455, 458, 459, 460, 462, 465, - 462, 473, 481, 488, 489, 490, 492, 498, 499, 499, - 503, 514, 517, 514, 541, 543, 543, 545, 546, 547, - 549, 552, 549, 555, 556, 558, 559, 562, 563, 566, - 567, 569, 572, 586, 591, 592, 593, 598, 598, 600, - 600, 601, 602, 610, 615, 618, 619, 620, 621, 623, - 627, 636, 639, 636, 647, 652, 652, 653, 659, 660, - 662, 679, 691, 693, 694, 695, 696, 697, 698, 699, - 700, 702, 703, 704, 705, 706, 707, 708, 709, 711, - 712, 713, 714, 715, 716, 717, 718, 719, 720, 721, - 722, 723, 724, 725, 726, 727, 728, 729, 730, 731, - 732, 733, 734, 735, 736, 737, 740, 745, 766, 771, - 772, 773, 775 + 313, 313, 314, 314, 315, 315, 315, 319, 356, 357, + 357, 358, 360, 361, 362, 413, 414, 414, 418, 434, + 435, 436, 437, 454, 459, 462, 463, 464, 466, 469, + 466, 477, 485, 492, 493, 494, 496, 502, 503, 503, + 507, 518, 521, 518, 549, 551, 551, 553, 554, 555, + 557, 560, 557, 563, 564, 566, 567, 570, 571, 574, + 575, 577, 580, 594, 599, 600, 601, 606, 606, 608, + 608, 609, 610, 618, 623, 626, 627, 628, 629, 631, + 635, 644, 647, 644, 655, 660, 660, 661, 667, 668, + 670, 687, 699, 701, 702, 703, 704, 705, 706, 707, + 708, 710, 711, 712, 713, 714, 715, 716, 717, 719, + 720, 721, 722, 723, 724, 725, 726, 727, 728, 729, + 730, 731, 732, 733, 734, 735, 736, 737, 738, 739, + 740, 741, 742, 743, 744, 745, 748, 753, 774, 779, + 780, 781, 783 }; #endif @@ -1630,11 +1630,7 @@ yyreduce: #endif { size_t count=code->count(); -#ifdef OPTIMIZE_BYTECODE_USE_TWO_OPERANDS_INSTRUCTIONS size_t len=6; -#else - size_t len=7; -#endif #ifdef OPTIMIZE_BYTECODE_GET_OBJECT_ELEMENT if( @@ -1666,17 +1662,17 @@ yyreduce: break; case 38: -#line 360 "compile.y" +#line 356 "compile.y" { yyval=yyvsp[0] ;} break; case 41: -#line 362 "compile.y" +#line 358 "compile.y" { yyval=yyvsp[-1] ;} break; case 44: -#line 366 "compile.y" +#line 362 "compile.y" { yyval=N(); YYSTYPE diving_code=yyvsp[0]; @@ -1691,21 +1687,18 @@ yyreduce: count>=4?4/*OP_VALUE+origin+string+OP_GET_ELEMENTx*/:3/*OP::OP_+origin+string*/); } - #ifdef OPTIMIZE_BYTECODE_GET_OBJECT_ELEMENT else if(maybe_make_get_object_element(*yyval, *diving_code, count)){ // optimisation for $object.field + ^object.method[ } #endif - #ifdef OPTIMIZE_BYTECODE_GET_OBJECT_VAR_ELEMENT else if(maybe_make_get_object_var_element(*yyval, *diving_code, count)){ // optimisation for $object.$var } #endif - #ifdef OPTIMIZE_BYTECODE_GET_ELEMENT else if(count==4){ // optimization O(*yyval, @@ -1734,25 +1727,36 @@ yyreduce: break; case 45: -#line 420 "compile.y" +#line 413 "compile.y" { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ;} break; case 47: -#line 421 "compile.y" +#line 414 "compile.y" { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ;} break; case 48: -#line 425 "compile.y" +#line 418 "compile.y" { - yyval=yyvsp[-1]; /* stack: context,name */ - P(*yyval, *yyvsp[0]); /* stack: context,name,constructor_value */ + yyval=N(); +#if defined(OPTIMIZE_BYTECODE_CONSTRUCT) || defined(OPTIMIZE_BYTECODE_CALL_CONSTRUCT) + if(maybe_make_root_or_write_construct(*yyval, *yyvsp[-1], *yyvsp[0])){ + // $a(1), $.a(1), $a[b], $.a[b] + // $a($b), $.a($b), $a[$b], $.a[$b] + // $a($b.c), $.a($b.c), $a[$b.c], $.a[$b.c] + // $a($b.$c), $.a($b.$c), $a[$b.$c], $.a[$b.$c] + } else +#endif + { + P(*yyval, *yyvsp[-1]); /* stack: context,name */ + P(*yyval, *yyvsp[0]); /* stack: context,name,constructor_value */ + } ;} break; case 52: -#line 433 "compile.y" +#line 437 "compile.y" { yyval=N(); YYSTYPE diving_code=yyvsp[0]; @@ -1773,7 +1777,7 @@ yyreduce: break; case 53: -#line 450 "compile.y" +#line 454 "compile.y" { yyval=N(); O(*yyval, OP::OP_WITH_WRITE); /* stack: starting context */ @@ -1782,12 +1786,12 @@ yyreduce: break; case 54: -#line 455 "compile.y" +#line 459 "compile.y" { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ;} break; case 58: -#line 462 "compile.y" +#line 466 "compile.y" { // allow $result_or_other_variable[ letters here any time ] *reinterpret_cast(&yyval)=PC.explicit_result; PC.explicit_result=false; @@ -1795,14 +1799,14 @@ yyreduce: break; case 59: -#line 465 "compile.y" +#line 469 "compile.y" { PC.explicit_result=*reinterpret_cast(&yyvsp[-1]); ;} break; case 60: -#line 467 "compile.y" +#line 471 "compile.y" { // stack: context, name yyval=yyvsp[-2]; // stack: context, name, value @@ -1811,7 +1815,7 @@ yyreduce: break; case 61: -#line 473 "compile.y" +#line 477 "compile.y" { yyval=N(); O(*yyval, OP::OP_PREPARE_TO_EXPRESSION); @@ -1822,7 +1826,7 @@ yyreduce: break; case 62: -#line 481 "compile.y" +#line 485 "compile.y" { // stack: context, name yyval=N(); @@ -1831,7 +1835,7 @@ yyreduce: break; case 66: -#line 492 "compile.y" +#line 496 "compile.y" { yyval=N(); OA(*yyval, OP::OP_OBJECT_POOL, yyvsp[0]); /* stack: empty write context */ @@ -1841,12 +1845,12 @@ yyreduce: break; case 69: -#line 499 "compile.y" +#line 503 "compile.y" { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ;} break; case 70: -#line 503 "compile.y" +#line 507 "compile.y" { #ifdef OPTIMIZE_BYTECODE_CUT_REM_OPERATOR if((*yyvsp[0]).count()) @@ -1861,24 +1865,28 @@ yyreduce: break; case 71: -#line 514 "compile.y" +#line 518 "compile.y" { PC.in_call_value=true; ;} break; case 72: -#line 517 "compile.y" +#line 521 "compile.y" { PC.in_call_value=false; ;} break; case 73: -#line 520 "compile.y" +#line 524 "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); +#else + const String* operator_name=LA2S(*yyvsp[-3], 1); +#endif if(operator_name && *operator_name == REM_OPERATOR_NAME){ yyval=N(); } else @@ -1899,12 +1907,12 @@ yyreduce: break; case 76: -#line 543 "compile.y" +#line 551 "compile.y" { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ;} break; case 80: -#line 549 "compile.y" +#line 557 "compile.y" { // allow ^call[ letters here any time ] *reinterpret_cast(&yyval)=PC.explicit_result; PC.explicit_result=false; @@ -1912,51 +1920,51 @@ yyreduce: break; case 81: -#line 552 "compile.y" +#line 560 "compile.y" { PC.explicit_result=*reinterpret_cast(&yyvsp[-1]); ;} break; case 82: -#line 554 "compile.y" +#line 562 "compile.y" {yyval=yyvsp[-2];} break; case 83: -#line 555 "compile.y" +#line 563 "compile.y" {yyval=yyvsp[-1];} break; case 84: -#line 556 "compile.y" +#line 564 "compile.y" {yyval=yyvsp[-1];} break; case 86: -#line 559 "compile.y" +#line 567 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]) ;} break; case 88: -#line 563 "compile.y" +#line 571 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]) ;} break; case 90: -#line 567 "compile.y" +#line 575 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]) ;} break; case 91: -#line 569 "compile.y" +#line 577 "compile.y" { yyval=yyvsp[0]; ;} break; case 92: -#line 572 "compile.y" +#line 580 "compile.y" { YYSTYPE expr_code=yyvsp[0]; if(expr_code->count()==3 @@ -1974,7 +1982,7 @@ yyreduce: break; case 93: -#line 586 "compile.y" +#line 594 "compile.y" { yyval=N(); OA(*yyval, OP::OP_CURLY_CODE__STORE_PARAM, yyvsp[0]); @@ -1982,17 +1990,17 @@ yyreduce: break; case 98: -#line 598 "compile.y" +#line 606 "compile.y" { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ;} break; case 100: -#line 600 "compile.y" +#line 608 "compile.y" { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ;} break; case 102: -#line 602 "compile.y" +#line 610 "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 @@ -2004,7 +2012,7 @@ yyreduce: break; case 103: -#line 610 "compile.y" +#line 618 "compile.y" { /* stack: context */ yyval=yyvsp[0]; /* stack: context,name */ @@ -2013,7 +2021,7 @@ yyreduce: break; case 109: -#line 623 "compile.y" +#line 631 "compile.y" { yyval=yyvsp[0]; O(*yyval, OP::OP_GET_ELEMENT); @@ -2021,7 +2029,7 @@ yyreduce: break; case 110: -#line 627 "compile.y" +#line 635 "compile.y" { YYSTYPE code; { @@ -2034,7 +2042,7 @@ yyreduce: break; case 111: -#line 636 "compile.y" +#line 644 "compile.y" { // allow $result_or_other_variable[ letters here any time ] *reinterpret_cast(&yyval)=PC.explicit_result; PC.explicit_result=false; @@ -2042,14 +2050,14 @@ yyreduce: break; case 112: -#line 639 "compile.y" +#line 647 "compile.y" { PC.explicit_result=*reinterpret_cast(&yyvsp[-1]); ;} break; case 113: -#line 641 "compile.y" +#line 649 "compile.y" { yyval=N(); OA(*yyval, OP::OP_OBJECT_POOL, yyvsp[-2]); /* stack: empty write context */ @@ -2059,7 +2067,7 @@ yyreduce: break; case 114: -#line 647 "compile.y" +#line 655 "compile.y" { yyval=N(); O(*yyval, OP::OP_WITH_READ); @@ -2068,12 +2076,12 @@ yyreduce: break; case 116: -#line 652 "compile.y" +#line 660 "compile.y" { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ;} break; case 117: -#line 653 "compile.y" +#line 661 "compile.y" { yyval=yyvsp[0]; O(*yyval, OP::OP_GET_ELEMENT__WRITE); @@ -2081,7 +2089,7 @@ yyreduce: break; case 120: -#line 662 "compile.y" +#line 670 "compile.y" { yyval=yyvsp[-1]; // stack: class name string if(*LA2S(*yyval) == BASE_NAME) { // pseudo BASE class @@ -2102,7 +2110,7 @@ yyreduce: break; case 121: -#line 679 "compile.y" +#line 687 "compile.y" { yyval=yyvsp[-1]; if(!PC.in_call_value) { @@ -2114,197 +2122,197 @@ yyreduce: break; case 128: -#line 698 "compile.y" +#line 706 "compile.y" { yyval = yyvsp[-1] ;} break; case 129: -#line 699 "compile.y" +#line 707 "compile.y" { yyval = yyvsp[-1] ;} break; case 130: -#line 700 "compile.y" +#line 708 "compile.y" { yyval = yyvsp[-1]; ;} break; case 131: -#line 702 "compile.y" +#line 710 "compile.y" { yyval=yyvsp[0]; O(*yyval, OP::OP_NEG) ;} break; case 132: -#line 703 "compile.y" +#line 711 "compile.y" { yyval=yyvsp[0] ;} break; case 133: -#line 704 "compile.y" +#line 712 "compile.y" { yyval=yyvsp[0]; O(*yyval, OP::OP_INV) ;} break; case 134: -#line 705 "compile.y" +#line 713 "compile.y" { yyval=yyvsp[0]; O(*yyval, OP::OP_NOT) ;} break; case 135: -#line 706 "compile.y" +#line 714 "compile.y" { yyval=yyvsp[0]; O(*yyval, OP::OP_DEF) ;} break; case 136: -#line 707 "compile.y" +#line 715 "compile.y" { yyval=yyvsp[0]; O(*yyval, OP::OP_IN) ;} break; case 137: -#line 708 "compile.y" +#line 716 "compile.y" { yyval=yyvsp[0]; O(*yyval, OP::OP_FEXISTS) ;} break; case 138: -#line 709 "compile.y" +#line 717 "compile.y" { yyval=yyvsp[0]; O(*yyval, OP::OP_DEXISTS) ;} break; case 139: -#line 711 "compile.y" +#line 719 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_SUB) ;} break; case 140: -#line 712 "compile.y" +#line 720 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_ADD) ;} break; case 141: -#line 713 "compile.y" +#line 721 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_MUL) ;} break; case 142: -#line 714 "compile.y" +#line 722 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_DIV) ;} break; case 143: -#line 715 "compile.y" +#line 723 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_MOD) ;} break; case 144: -#line 716 "compile.y" +#line 724 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_INTDIV) ;} break; case 145: -#line 717 "compile.y" +#line 725 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_BIN_SL) ;} break; case 146: -#line 718 "compile.y" +#line 726 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_BIN_SR) ;} break; case 147: -#line 719 "compile.y" +#line 727 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_BIN_AND) ;} break; case 148: -#line 720 "compile.y" +#line 728 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_BIN_OR) ;} break; case 149: -#line 721 "compile.y" +#line 729 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_BIN_XOR) ;} break; case 150: -#line 722 "compile.y" +#line 730 "compile.y" { yyval=yyvsp[-2]; OA(*yyval, OP::OP_NESTED_CODE, yyvsp[0]); O(*yyval, OP::OP_LOG_AND) ;} break; case 151: -#line 723 "compile.y" +#line 731 "compile.y" { yyval=yyvsp[-2]; OA(*yyval, OP::OP_NESTED_CODE, yyvsp[0]); O(*yyval, OP::OP_LOG_OR) ;} break; case 152: -#line 724 "compile.y" +#line 732 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_LOG_XOR) ;} break; case 153: -#line 725 "compile.y" +#line 733 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_NUM_LT) ;} break; case 154: -#line 726 "compile.y" +#line 734 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_NUM_GT) ;} break; case 155: -#line 727 "compile.y" +#line 735 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_NUM_LE) ;} break; case 156: -#line 728 "compile.y" +#line 736 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_NUM_GE) ;} break; case 157: -#line 729 "compile.y" +#line 737 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_NUM_EQ) ;} break; case 158: -#line 730 "compile.y" +#line 738 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_NUM_NE) ;} break; case 159: -#line 731 "compile.y" +#line 739 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_STR_LT) ;} break; case 160: -#line 732 "compile.y" +#line 740 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_STR_GT) ;} break; case 161: -#line 733 "compile.y" +#line 741 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_STR_LE) ;} break; case 162: -#line 734 "compile.y" +#line 742 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_STR_GE) ;} break; case 163: -#line 735 "compile.y" +#line 743 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_STR_EQ) ;} break; case 164: -#line 736 "compile.y" +#line 744 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_STR_NE) ;} break; case 165: -#line 737 "compile.y" +#line 745 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_IS) ;} break; case 166: -#line 740 "compile.y" +#line 748 "compile.y" { // optimized OP_STRING => OP_VALUE for doubles maybe_change_string_literal_to_double_literal(*(yyval=yyvsp[0])); @@ -2312,7 +2320,7 @@ yyreduce: break; case 167: -#line 745 "compile.y" +#line 753 "compile.y" { #ifdef OPTIMIZE_BYTECODE_STRING_POOL // it brakes ^if(" 09 "){...} @@ -2334,7 +2342,7 @@ yyreduce: break; case 168: -#line 766 "compile.y" +#line 774 "compile.y" { // optimized OP_STRING+OP_WRITE_VALUE => OP_STRING__WRITE change_string_literal_to_write_string_literal(*(yyval=yyvsp[0])) @@ -2342,22 +2350,22 @@ yyreduce: break; case 169: -#line 771 "compile.y" +#line 779 "compile.y" { yyval=VL(/*we know that we will not change it*/const_cast(&vvoid), 0, 0, 0) ;} break; case 170: -#line 772 "compile.y" +#line 780 "compile.y" { yyval = VL(/*we know that we will not change it*/const_cast(&vtrue), 0, 0, 0) ;} break; case 171: -#line 773 "compile.y" +#line 781 "compile.y" { yyval = VL(/*we know that we will not change it*/const_cast(&vfalse), 0, 0, 0) ;} break; case 172: -#line 775 "compile.y" +#line 783 "compile.y" { yyval=N() ;} break; @@ -2365,7 +2373,7 @@ yyreduce: } /* Line 1010 of yacc.c. */ -#line 2369 "compile.tab.C" +#line 2377 "compile.tab.C" yyvsp -= yylen; yyssp -= yylen; @@ -2590,7 +2598,7 @@ yyreturn: } -#line 777 "compile.y" +#line 785 "compile.y" #endif