--- parser3/src/main/compile.tab.C 2003/03/27 14:51:27 1.81.2.13.2.16 +++ parser3/src/main/compile.tab.C 2003/09/01 12:27:27 1.83.2.1 @@ -43,7 +43,7 @@ Copyright (c) 2001, 2003 ArtLebedev Group (http://www.artlebedev.com) Author: Alexander Petrosyan (http://design.ru/paf) - $Id: compile.tab.C,v 1.81.2.13.2.16 2003/03/27 14:51:27 paf Exp $ + $Id: compile.tab.C,v 1.83.2.1 2003/09/01 12:27:27 paf Exp $ */ /** @@ -57,7 +57,7 @@ -#: in iis make up specialized Pool object for that */ -#define YYSTYPE ArrayOperation* +#define YYSTYPE Array/**/ * #define YYPARSE_PARAM pc #define YYLEX_PARAM pc #define YYDEBUG 1 @@ -84,8 +84,9 @@ static int yylex(YYSTYPE *lvalp, void *p // local convinient inplace typecast & var #undef PC #define PC (*(parse_control *)pc) -#undef POOL #define POOL (*PC.pool) +#undef NEW +#define NEW new(POOL) #ifndef DOXYGEN #ifndef YYSTYPE #define YYSTYPE int @@ -210,22 +211,22 @@ static const short yyrhs[] = { 62, #if YYDEBUG != 0 static const short yyrline[] = { 0, - 115, 123, 125, 125, 126, 128, 128, 130, 202, 202, - 203, 203, 204, 205, 205, 207, 236, 236, 237, 238, - 238, 239, 239, 241, 241, 245, 245, 247, 247, 248, - 248, 249, 249, 249, 253, 260, 261, 261, 262, 263, - 265, 266, 288, 289, 289, 293, 297, 299, 300, 301, - 318, 323, 325, 327, 328, 330, 336, 344, 350, 352, - 353, 355, 361, 362, 362, 366, 372, 375, 378, 391, - 393, 393, 394, 396, 397, 399, 400, 401, 402, 404, - 406, 408, 410, 412, 414, 418, 422, 426, 428, 429, - 431, 440, 440, 442, 442, 443, 444, 452, 457, 459, - 461, 462, 463, 465, 469, 478, 484, 489, 489, 490, - 495, 497, 499, 511, 523, 528, 530, 531, 532, 533, - 534, 536, 537, 538, 539, 540, 541, 542, 543, 545, - 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, - 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, - 566, 567, 568, 569, 570, 571, 574, 583, 588, 589 + 116, 126, 128, 128, 129, 131, 131, 133, 200, 200, + 201, 201, 202, 203, 203, 205, 234, 234, 235, 236, + 236, 237, 237, 239, 239, 243, 243, 245, 245, 246, + 246, 247, 247, 247, 251, 258, 259, 259, 260, 261, + 263, 264, 286, 287, 287, 291, 295, 297, 298, 299, + 316, 321, 323, 325, 326, 328, 334, 342, 348, 350, + 351, 353, 359, 360, 360, 364, 370, 373, 376, 389, + 391, 391, 392, 394, 395, 397, 398, 399, 400, 402, + 404, 406, 408, 410, 412, 416, 420, 424, 426, 427, + 429, 438, 438, 440, 440, 441, 442, 450, 455, 457, + 459, 460, 461, 463, 467, 476, 482, 487, 487, 488, + 493, 495, 497, 509, 521, 526, 528, 529, 530, 531, + 532, 534, 535, 536, 537, 538, 539, 540, 541, 543, + 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, + 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, + 564, 565, 566, 567, 568, 569, 572, 581, 586, 587 }; #endif @@ -1032,21 +1033,23 @@ yyreduce: switch (yyn) { case 1: -#line 116 "compile.y" +#line 117 "compile.y" { - Method& method=*new Method(/*main_method_name, */Method::CT_ANY, + Method& method=*NEW Method(POOL, + PC.request->main_method_name, + 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(main_method_name, method); + PC.cclass->add_method(PC.request->main_method_name, method); ; break;} case 8: -#line 131 "compile.y" +#line 134 "compile.y" { - const String& command=*LA2S(*yyvsp[-2]); + const String& command=*LA2S(yyvsp[-2]); YYSTYPE strings_code=yyvsp[0]; - if(strings_code->count()<1*2) { + if(strings_code->size()<1*2) { strcpy(PC.error, "@"); strcat(PC.error, command.cstr()); strcat(PC.error, " is empty"); @@ -1059,22 +1062,21 @@ case 8: strcat(PC.error, "'"); YYERROR; } - if(strings_code->count()==1*2) { + if(strings_code->size()==1*2) { // new class' name - const String& name=*LA2S(*strings_code); + const String *name=LA2S(strings_code); // creating the class - VStateless_class* cclass=new VClass; - PC.cclass=cclass; - PC.cclass->set_name(name); + PC.cclass=NEW VClass(POOL); + PC.cclass->set_name(*name); // append to request's classes - PC.request.classes().put(name, cclass); + PC.request->classes().put(*name, PC.cclass); } else { strcpy(PC.error, "@"CLASS_NAME" must contain sole name"); YYERROR; } } else if(command==USE_CONTROL_METHOD_NAME) { - for(size_t i=0; icount(); i+=2) - PC.request.use_file(PC.request.main_class, *LA2S(*strings_code, i)); + for(int i=0; isize(); i+=2) + PC.request->use_file(PC.request->main_class, *LA2S(strings_code, i)); } else if(command==BASE_NAME) { if(PC.cclass->base_class()) { // already changed from default? strcpy(PC.error, "class already have a base '"); @@ -1082,26 +1084,22 @@ case 8: strcat(PC.error, "'"); YYERROR; } - if(strings_code->count()==1*2) { - const String& base_name=*LA2S(*strings_code); - if(Value* base_class_value=PC.request.classes().get(base_name)) { - // @CLASS == @BASE sanity check - if(VStateless_class *base_class=base_class_value->get_class()) { - if(PC.cclass==base_class) { - strcpy(PC.error, "@"CLASS_NAME" equals @"BASE_NAME); - YYERROR; - } - PC.cclass->get_class()->set_base(base_class); - } else { // they asked to derive from a class without methods ['env' & co] - strcpy(PC.error, base_name.cstr()); - strcat(PC.error, ": you can not derive from this class in @"BASE_NAME); - YYERROR; - } - } else { + if(strings_code->size()==1*2) { + const String& base_name=*LA2S(strings_code); + Value *vbase_class=static_cast( + PC.request->classes().get(base_name)); + VStateless_class *base_class=vbase_class?vbase_class->get_class():0; + if(!base_class) { strcpy(PC.error, base_name.cstr()); strcat(PC.error, ": undefined class in @"BASE_NAME); YYERROR; } + // @CLASS == @BASE sanity check + if(PC.cclass==base_class) { + strcpy(PC.error, "@"CLASS_NAME" equals @"BASE_NAME); + YYERROR; + } + PC.cclass->set_base(base_class); } else { strcpy(PC.error, "@"BASE_NAME" must contain sole name"); YYERROR; @@ -1116,557 +1114,557 @@ case 8: ; break;} case 12: -#line 203 "compile.y" -{ yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; +#line 201 "compile.y" +{ yyval=yyvsp[-1]; P(yyval, yyvsp[0]) ; break;} case 16: -#line 208 "compile.y" +#line 206 "compile.y" { - const String& name=*LA2S(*yyvsp[-5]); + const String *name=LA2S(yyvsp[-5]); YYSTYPE params_names_code=yyvsp[-4]; - ArrayString* params_names=0; - if(int size=params_names_code->count()) { - params_names=new ArrayString; + Array *params_names=0; + if(int size=params_names_code->size()) { + params_names=NEW Array(POOL); for(int i=0; icount()) { - locals_names=new ArrayString; + Array *locals_names=0; + if(int size=locals_names_code->size()) { + locals_names=NEW Array(POOL); for(int i=0; iadd_method(name, method); + PC.cclass->add_method(*name, method); ; break;} case 19: -#line 237 "compile.y" +#line 235 "compile.y" {yyval=yyvsp[-1]; break;} case 23: -#line 239 "compile.y" -{ yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]) ; +#line 237 "compile.y" +{ yyval=yyvsp[-2]; P(yyval, yyvsp[0]) ; break;} case 29: -#line 247 "compile.y" -{ yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; +#line 245 "compile.y" +{ yyval=yyvsp[-1]; P(yyval, yyvsp[0]) ; break;} case 35: -#line 253 "compile.y" +#line 251 "compile.y" { yyval=yyvsp[0]; /* stack: resulting value */ - changetail_or_append(*yyval, + changetail_or_append(yyval, OP_GET_ELEMENT, false, /*->*/OP_GET_ELEMENT__WRITE, /*or */OP_WRITE_VALUE ); /* value=pop; wcontext.write(value) */ ; break;} case 36: -#line 260 "compile.y" +#line 258 "compile.y" { yyval=yyvsp[0] ; break;} case 39: -#line 262 "compile.y" +#line 260 "compile.y" { yyval=yyvsp[-1] ; break;} case 42: -#line 266 "compile.y" +#line 264 "compile.y" { - yyval=N(); - ArrayOperation* diving_code=yyvsp[0]; - const String* first_name=LA2S(*diving_code); + yyval=N(POOL); + Array *diving_code=yyvsp[0]; + const String *first_name=LA2S(diving_code); // self.xxx... -> xxx... // OP_VALUE+string+OP_GET_ELEMENT+... -> OP_WITH_SELF+... if(first_name && *first_name==SELF_ELEMENT_NAME) { - O(*yyval, OP_WITH_SELF); /* stack: starting context */ - P(*yyval, *diving_code, + O(yyval, OP_WITH_SELF); /* stack: starting context */ + P(yyval, diving_code, /* skip over... */ - diving_code->count()>=3?3/*OP_VALUE+string+OP_GET_ELEMENTx*/:2/*OP_+string*/); + diving_code->size()>=3?3/*OP_VALUE+string+OP_GET_ELEMENTx*/:2/*OP_+string*/); } else { - O(*yyval, OP_WITH_READ); /* stack: starting context */ + O(yyval, OP_WITH_READ); /* stack: starting context */ // ^if ELEMENT -> ^if ELEMENT_OR_OPERATOR // OP_VALUE+string+OP_GET_ELEMENT. -> OP_VALUE+string+OP_GET_ELEMENT_OR_OPERATOR. - if(PC.in_call_value && diving_code->count()==3) - diving_code->put(2, OP_GET_ELEMENT_OR_OPERATOR); - P(*yyval, *diving_code); + if(PC.in_call_value && diving_code->size()==3) + diving_code->put_int(2, OP_GET_ELEMENT_OR_OPERATOR); + P(yyval, diving_code); } /* diving code; stack: current context */ ; break;} case 43: -#line 288 "compile.y" -{ yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; +#line 286 "compile.y" +{ yyval=yyvsp[-1]; P(yyval, yyvsp[0]) ; break;} case 45: -#line 289 "compile.y" -{ yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; +#line 287 "compile.y" +{ yyval=yyvsp[-1]; P(yyval, yyvsp[0]) ; break;} case 46: -#line 293 "compile.y" +#line 291 "compile.y" { yyval=yyvsp[-1]; /* stack: context,name */ - P(*yyval, *yyvsp[0]); /* stack: context,name,constructor_value */ + P(yyval, yyvsp[0]); /* stack: context,name,constructor_value */ ; break;} case 50: -#line 301 "compile.y" +#line 299 "compile.y" { - yyval=N(); - ArrayOperation* diving_code=yyvsp[0]; - const String* first_name=LA2S(*diving_code); + yyval=N(POOL); + Array *diving_code=yyvsp[0]; + const String *first_name=LA2S(diving_code); // $self.xxx... -> $xxx... // OP_VALUE+string+OP_GET_ELEMENT+... -> OP_WITH_SELF+... if(first_name && *first_name==SELF_ELEMENT_NAME) { - O(*yyval, OP_WITH_SELF); /* stack: starting context */ - P(*yyval, *diving_code, + O(yyval, OP_WITH_SELF); /* stack: starting context */ + P(yyval, diving_code, /* skip over... */ - diving_code->count()>=3?3/*OP_VALUE+string+OP_GET_ELEMENTx*/:2/*OP_+string*/); + diving_code->size()>=3?3/*OP_VALUE+string+OP_GET_ELEMENTx*/:2/*OP_+string*/); } else { - O(*yyval, OP_WITH_ROOT); /* stack: starting context */ - P(*yyval, *diving_code); + O(yyval, OP_WITH_ROOT); /* stack: starting context */ + P(yyval, diving_code); } /* diving code; stack: current context */ ; break;} case 51: -#line 318 "compile.y" +#line 316 "compile.y" { - yyval=N(); - O(*yyval, OP_WITH_WRITE); /* stack: starting context */ - P(*yyval, *yyvsp[0]); /* diving code; stack: context,name */ + yyval=N(POOL); + O(yyval, OP_WITH_WRITE); /* stack: starting context */ + P(yyval, yyvsp[0]); /* diving code; stack: context,name */ ; break;} case 52: -#line 323 "compile.y" -{ yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; +#line 321 "compile.y" +{ yyval=yyvsp[-1]; P(yyval, yyvsp[0]) ; break;} case 56: -#line 330 "compile.y" +#line 328 "compile.y" { // stack: context, name yyval=yyvsp[-1]; // stack: context, name, value - O(*yyval, OP_CONSTRUCT_VALUE); /* value=pop; name=pop; context=pop; construct(context,name,value) */ + O(yyval, OP_CONSTRUCT_VALUE); /* value=pop; name=pop; context=pop; construct(context,name,value) */ ; break;} case 57: -#line 336 "compile.y" +#line 334 "compile.y" { - yyval=N(); - O(*yyval, OP_PREPARE_TO_EXPRESSION); + yyval=N(POOL); + O(yyval, OP_PREPARE_TO_EXPRESSION); // stack: context, name - P(*yyval, *yyvsp[-1]); // stack: context, name, value - O(*yyval, OP_CONSTRUCT_EXPR); /* value=pop->as_expr_result; name=pop; context=pop; construct(context,name,value) */ + P(yyval, yyvsp[-1]); // stack: context, name, value + O(yyval, OP_CONSTRUCT_EXPR); /* value=pop->as_expr_result; name=pop; context=pop; construct(context,name,value) */ ; break;} case 58: -#line 344 "compile.y" +#line 342 "compile.y" { // stack: context, name - yyval=N(); - OA(*yyval, OP_CURLY_CODE__CONSTRUCT, yyvsp[-1]); /* code=pop; name=pop; context=pop; construct(context,name,junction(code)) */ + yyval=N(POOL); + OA(yyval, OP_CURLY_CODE__CONSTRUCT, yyvsp[-1]); /* code=pop; name=pop; context=pop; construct(context,name,junction(code)) */ ; break;} case 62: -#line 355 "compile.y" +#line 353 "compile.y" { - yyval=N(); - OA(*yyval, OP_OBJECT_POOL, yyvsp[0]); /* stack: empty write context */ + yyval=N(POOL); + OA(yyval, OP_OBJECT_POOL, yyvsp[0]); /* stack: empty write context */ /* some code that writes to that context */ /* context=pop; stack: context.value() */ ; break;} case 65: -#line 362 "compile.y" -{ yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; +#line 360 "compile.y" +{ yyval=yyvsp[-1]; P(yyval, yyvsp[0]) ; break;} case 66: -#line 366 "compile.y" +#line 364 "compile.y" { yyval=yyvsp[0]; /* stack: value */ - changetail_or_append(*yyval, + changetail_or_append(yyval, OP_CALL, true, /*->*/ OP_CALL__WRITE, /*or */OP_WRITE_VALUE); /* value=pop; wcontext.write(value) */ ; break;} case 67: -#line 372 "compile.y" +#line 370 "compile.y" { PC.in_call_value=true; ; break;} case 68: -#line 375 "compile.y" +#line 373 "compile.y" { PC.in_call_value=false; ; break;} case 69: -#line 378 "compile.y" +#line 376 "compile.y" { /* ^field.$method{vasya} */ yyval=yyvsp[-3]; /* with_xxx,diving code; stack: context,method_junction */ YYSTYPE params_code=yyvsp[-1]; - if(params_code->count()==3) { // probably [] case. [OP_VALUE + Void + STORE_PARAM] - if(Value* value=LA2V(*params_code)) // it is OP_VALUE + value? + if(params_code->size()==3) { // probably [] case. [OP_VALUE + Void + STORE_PARAM] + if(Value *value=LA2V(params_code)) // it is OP_VALUE + value? if(!value->is_defined()) // value is VVoid? params_code=0; // ^zzz[] case. don't append lone empty param. } /* stack: context, method_junction */ - OA(*yyval, OP_CALL, params_code); // method_frame=make frame(pop junction); ncontext=pop; call(ncontext,method_frame) stack: value + OA(yyval, OP_CALL, params_code); // method_frame=make frame(pop junction); ncontext=pop; call(ncontext,method_frame) stack: value ; break;} case 72: -#line 393 "compile.y" -{ yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; +#line 391 "compile.y" +{ yyval=yyvsp[-1]; P(yyval, yyvsp[0]) ; break;} case 76: -#line 399 "compile.y" +#line 397 "compile.y" {yyval=yyvsp[-1]; break;} case 77: -#line 400 "compile.y" +#line 398 "compile.y" {yyval=yyvsp[-1]; break;} case 78: -#line 401 "compile.y" +#line 399 "compile.y" {yyval=yyvsp[-1]; break;} case 80: -#line 404 "compile.y" -{ yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]) ; +#line 402 "compile.y" +{ yyval=yyvsp[-2]; P(yyval, yyvsp[0]) ; break;} case 82: -#line 408 "compile.y" -{ yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]) ; +#line 406 "compile.y" +{ yyval=yyvsp[-2]; P(yyval, yyvsp[0]) ; break;} case 84: -#line 412 "compile.y" -{ yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]) ; +#line 410 "compile.y" +{ yyval=yyvsp[-2]; P(yyval, yyvsp[0]) ; break;} case 85: -#line 414 "compile.y" +#line 412 "compile.y" { yyval=yyvsp[0]; - O(*yyval, OP_STORE_PARAM); + O(yyval, OP_STORE_PARAM); ; break;} case 86: -#line 418 "compile.y" +#line 416 "compile.y" { - yyval=N(); - OA(*yyval, OP_EXPR_CODE__STORE_PARAM, yyvsp[0]); + yyval=N(POOL); + OA(yyval, OP_EXPR_CODE__STORE_PARAM, yyvsp[0]); ; break;} case 87: -#line 422 "compile.y" +#line 420 "compile.y" { - yyval=N(); - OA(*yyval, OP_CURLY_CODE__STORE_PARAM, yyvsp[0]); + yyval=N(POOL); + OA(yyval, OP_CURLY_CODE__STORE_PARAM, yyvsp[0]); ; break;} case 91: -#line 431 "compile.y" +#line 429 "compile.y" { - yyval=N(); - O(*yyval, OP_PREPARE_TO_EXPRESSION); - P(*yyval, *yyvsp[0]); - O(*yyval, OP_WRITE_EXPR_RESULT); + yyval=N(POOL); + O(yyval, OP_PREPARE_TO_EXPRESSION); + P(yyval, yyvsp[0]); + O(yyval, OP_WRITE_EXPR_RESULT); ; break;} case 93: -#line 440 "compile.y" -{ yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; +#line 438 "compile.y" +{ yyval=yyvsp[-1]; P(yyval, yyvsp[0]) ; break;} case 95: -#line 442 "compile.y" -{ yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; +#line 440 "compile.y" +{ yyval=yyvsp[-1]; P(yyval, yyvsp[0]) ; break;} case 97: -#line 444 "compile.y" +#line 442 "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 /* stack: context */ yyval=yyvsp[0]; /* stack: context,name */ - O(*yyval, OP_GET_ELEMENT); /* name=pop; context=pop; stack: context.get_element(name) */ + O(yyval, OP_GET_ELEMENT); /* name=pop; context=pop; stack: context.get_element(name) */ ; break;} case 98: -#line 452 "compile.y" +#line 450 "compile.y" { /* stack: context */ yyval=yyvsp[0]; /* stack: context,name */ - O(*yyval, OP_GET_ELEMENT); /* name=pop; context=pop; stack: context.get_element(name) */ + O(yyval, OP_GET_ELEMENT); /* name=pop; context=pop; stack: context.get_element(name) */ ; break;} case 104: -#line 465 "compile.y" +#line 463 "compile.y" { yyval=yyvsp[0]; - O(*yyval, OP_GET_ELEMENT); + O(yyval, OP_GET_ELEMENT); ; break;} case 105: -#line 469 "compile.y" +#line 467 "compile.y" { - ArrayOperation* code; + Array *code; { - change_string_literal_to_write_string_literal(*(code=yyvsp[-1])); - P(*code, *yyvsp[0]); + change_string_literal_to_write_string_literal(code=yyvsp[-1]); + P(code, yyvsp[0]); } - yyval=N(); - OA(*yyval, OP_STRING_POOL, code); + yyval=N(POOL); + OA(yyval, OP_STRING_POOL, code); ; break;} case 106: -#line 478 "compile.y" +#line 476 "compile.y" { - yyval=N(); - OA(*yyval, OP_OBJECT_POOL, yyvsp[-1]); /* stack: empty write context */ + yyval=N(POOL); + OA(yyval, OP_OBJECT_POOL, yyvsp[-1]); /* stack: empty write context */ /* some code that writes to that context */ /* context=pop; stack: context.value() */ ; break;} case 107: -#line 484 "compile.y" +#line 482 "compile.y" { - yyval=N(); - O(*yyval, OP_WITH_READ); - P(*yyval, *yyvsp[0]); + yyval=N(POOL); + O(yyval, OP_WITH_READ); + P(yyval, yyvsp[0]); ; break;} case 109: -#line 489 "compile.y" -{ yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; +#line 487 "compile.y" +{ yyval=yyvsp[-1]; P(yyval, yyvsp[0]) ; break;} case 110: -#line 490 "compile.y" +#line 488 "compile.y" { yyval=yyvsp[0]; - O(*yyval, OP_GET_ELEMENT__WRITE); + O(yyval, OP_GET_ELEMENT__WRITE); ; break;} case 113: -#line 499 "compile.y" +#line 497 "compile.y" { yyval=yyvsp[-1]; // stack: class name string - if(*LA2S(*yyval) == BASE_NAME) { // pseude BASE class - if(VStateless_class* base=PC.cclass->base_class()) { - change_string_literal_value(*yyval, base->name()); + if(*LA2S(yyval) == BASE_NAME) { // pseude BASE class + if(VStateless_class *base=PC.cclass->base_class()) { + change_string_literal_value(yyval, base->name()); } else { strcpy(PC.error, "no base class declared"); YYERROR; } } - O(*yyval, OP_GET_CLASS); + O(yyval, OP_GET_CLASS); ; break;} case 114: -#line 511 "compile.y" +#line 509 "compile.y" { yyval=yyvsp[-1]; if(!PC.in_call_value) { strcpy(PC.error, ":: not allowed here"); YYERROR; } - O(*yyval, OP_PREPARE_TO_CONSTRUCT_OBJECT); + O(yyval, OP_PREPARE_TO_CONSTRUCT_OBJECT); ; break;} case 115: -#line 523 "compile.y" +#line 521 "compile.y" { // see OP_PREPARE_TO_EXPRESSION!! - if((yyval=yyvsp[0])->count()==2) // only one string literal in there? - change_string_literal_to_double_literal(*yyval); // make that string literal Double + if((yyval=yyvsp[0])->size()==2) // only one string literal in there? + change_string_literal_to_double_literal(yyval); // make that string literal Double ; break;} case 119: -#line 532 "compile.y" +#line 530 "compile.y" { yyval = yyvsp[-1]; ; break;} case 120: -#line 533 "compile.y" +#line 531 "compile.y" { yyval = yyvsp[-1]; ; break;} case 121: -#line 534 "compile.y" +#line 532 "compile.y" { yyval = yyvsp[-1]; ; break;} case 122: -#line 536 "compile.y" -{ yyval=yyvsp[0]; O(*yyval, OP_NEG) ; +#line 534 "compile.y" +{ yyval=yyvsp[0]; O(yyval, OP_NEG) ; break;} case 123: -#line 537 "compile.y" +#line 535 "compile.y" { yyval=yyvsp[0] ; break;} case 124: -#line 538 "compile.y" -{ yyval=yyvsp[0]; O(*yyval, OP_INV) ; +#line 536 "compile.y" +{ yyval=yyvsp[0]; O(yyval, OP_INV) ; break;} case 125: -#line 539 "compile.y" -{ yyval=yyvsp[0]; O(*yyval, OP_NOT) ; +#line 537 "compile.y" +{ yyval=yyvsp[0]; O(yyval, OP_NOT) ; break;} case 126: -#line 540 "compile.y" -{ yyval=yyvsp[0]; O(*yyval, OP_DEF) ; +#line 538 "compile.y" +{ yyval=yyvsp[0]; O(yyval, OP_DEF) ; break;} case 127: -#line 541 "compile.y" -{ yyval=yyvsp[0]; O(*yyval, OP_IN) ; +#line 539 "compile.y" +{ yyval=yyvsp[0]; O(yyval, OP_IN) ; break;} case 128: -#line 542 "compile.y" -{ yyval=yyvsp[0]; O(*yyval, OP_FEXISTS) ; +#line 540 "compile.y" +{ yyval=yyvsp[0]; O(yyval, OP_FEXISTS) ; break;} case 129: -#line 543 "compile.y" -{ yyval=yyvsp[0]; O(*yyval, OP_DEXISTS) ; +#line 541 "compile.y" +{ yyval=yyvsp[0]; O(yyval, OP_DEXISTS) ; break;} case 130: -#line 545 "compile.y" -{ yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_SUB) ; +#line 543 "compile.y" +{ yyval=yyvsp[-2]; P(yyval, yyvsp[0]); O(yyval, OP_SUB) ; break;} case 131: -#line 546 "compile.y" -{ yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_ADD) ; +#line 544 "compile.y" +{ yyval=yyvsp[-2]; P(yyval, yyvsp[0]); O(yyval, OP_ADD) ; break;} case 132: -#line 547 "compile.y" -{ yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_MUL) ; +#line 545 "compile.y" +{ yyval=yyvsp[-2]; P(yyval, yyvsp[0]); O(yyval, OP_MUL) ; break;} case 133: -#line 548 "compile.y" -{ yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_DIV) ; +#line 546 "compile.y" +{ yyval=yyvsp[-2]; P(yyval, yyvsp[0]); O(yyval, OP_DIV) ; break;} case 134: -#line 549 "compile.y" -{ yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_MOD) ; +#line 547 "compile.y" +{ yyval=yyvsp[-2]; P(yyval, yyvsp[0]); O(yyval, OP_MOD) ; break;} case 135: -#line 550 "compile.y" -{ yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_INTDIV) ; +#line 548 "compile.y" +{ yyval=yyvsp[-2]; P(yyval, yyvsp[0]); O(yyval, OP_INTDIV) ; break;} case 136: -#line 551 "compile.y" -{ yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_BIN_SL) ; +#line 549 "compile.y" +{ yyval=yyvsp[-2]; P(yyval, yyvsp[0]); O(yyval, OP_BIN_SL) ; break;} case 137: -#line 552 "compile.y" -{ yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_BIN_SR) ; +#line 550 "compile.y" +{ yyval=yyvsp[-2]; P(yyval, yyvsp[0]); O(yyval, OP_BIN_SR) ; break;} case 138: -#line 553 "compile.y" -{ yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_BIN_AND) ; +#line 551 "compile.y" +{ yyval=yyvsp[-2]; P(yyval, yyvsp[0]); O(yyval, OP_BIN_AND) ; break;} case 139: -#line 554 "compile.y" -{ yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_BIN_OR) ; +#line 552 "compile.y" +{ yyval=yyvsp[-2]; P(yyval, yyvsp[0]); O(yyval, OP_BIN_OR) ; break;} case 140: -#line 555 "compile.y" -{ yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_BIN_XOR) ; +#line 553 "compile.y" +{ yyval=yyvsp[-2]; P(yyval, yyvsp[0]); O(yyval, OP_BIN_XOR) ; break;} case 141: -#line 556 "compile.y" -{ yyval=yyvsp[-2]; OA(*yyval, OP_NESTED_CODE, yyvsp[0]); O(*yyval, OP_LOG_AND) ; +#line 554 "compile.y" +{ yyval=yyvsp[-2]; OA(yyval, OP_NESTED_CODE, yyvsp[0]); O(yyval, OP_LOG_AND) ; break;} case 142: -#line 557 "compile.y" -{ yyval=yyvsp[-2]; OA(*yyval, OP_NESTED_CODE, yyvsp[0]); O(*yyval, OP_LOG_OR) ; +#line 555 "compile.y" +{ yyval=yyvsp[-2]; OA(yyval, OP_NESTED_CODE, yyvsp[0]); O(yyval, OP_LOG_OR) ; break;} case 143: -#line 558 "compile.y" -{ yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_LOG_XOR) ; +#line 556 "compile.y" +{ yyval=yyvsp[-2]; P(yyval, yyvsp[0]); O(yyval, OP_LOG_XOR) ; break;} case 144: -#line 559 "compile.y" -{ yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_NUM_LT) ; +#line 557 "compile.y" +{ yyval=yyvsp[-2]; P(yyval, yyvsp[0]); O(yyval, OP_NUM_LT) ; break;} case 145: -#line 560 "compile.y" -{ yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_NUM_GT) ; +#line 558 "compile.y" +{ yyval=yyvsp[-2]; P(yyval, yyvsp[0]); O(yyval, OP_NUM_GT) ; break;} case 146: -#line 561 "compile.y" -{ yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_NUM_LE) ; +#line 559 "compile.y" +{ yyval=yyvsp[-2]; P(yyval, yyvsp[0]); O(yyval, OP_NUM_LE) ; break;} case 147: -#line 562 "compile.y" -{ yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_NUM_GE) ; +#line 560 "compile.y" +{ yyval=yyvsp[-2]; P(yyval, yyvsp[0]); O(yyval, OP_NUM_GE) ; break;} case 148: -#line 563 "compile.y" -{ yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_NUM_EQ) ; +#line 561 "compile.y" +{ yyval=yyvsp[-2]; P(yyval, yyvsp[0]); O(yyval, OP_NUM_EQ) ; break;} case 149: -#line 564 "compile.y" -{ yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_NUM_NE) ; +#line 562 "compile.y" +{ yyval=yyvsp[-2]; P(yyval, yyvsp[0]); O(yyval, OP_NUM_NE) ; break;} case 150: -#line 565 "compile.y" -{ yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_STR_LT) ; +#line 563 "compile.y" +{ yyval=yyvsp[-2]; P(yyval, yyvsp[0]); O(yyval, OP_STR_LT) ; break;} case 151: -#line 566 "compile.y" -{ yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_STR_GT) ; +#line 564 "compile.y" +{ yyval=yyvsp[-2]; P(yyval, yyvsp[0]); O(yyval, OP_STR_GT) ; break;} case 152: -#line 567 "compile.y" -{ yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_STR_LE) ; +#line 565 "compile.y" +{ yyval=yyvsp[-2]; P(yyval, yyvsp[0]); O(yyval, OP_STR_LE) ; break;} case 153: -#line 568 "compile.y" -{ yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_STR_GE) ; +#line 566 "compile.y" +{ yyval=yyvsp[-2]; P(yyval, yyvsp[0]); O(yyval, OP_STR_GE) ; break;} case 154: -#line 569 "compile.y" -{ yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_STR_EQ) ; +#line 567 "compile.y" +{ yyval=yyvsp[-2]; P(yyval, yyvsp[0]); O(yyval, OP_STR_EQ) ; break;} case 155: -#line 570 "compile.y" -{ yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_STR_NE) ; +#line 568 "compile.y" +{ yyval=yyvsp[-2]; P(yyval, yyvsp[0]); O(yyval, OP_STR_NE) ; break;} case 156: -#line 571 "compile.y" -{ yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_IS) ; +#line 569 "compile.y" +{ yyval=yyvsp[-2]; P(yyval, yyvsp[0]); O(yyval, OP_IS) ; break;} case 157: -#line 574 "compile.y" +#line 572 "compile.y" { - yyval=N(); - OA(*yyval, OP_STRING_POOL, yyvsp[0]); /* stack: empty write context */ + yyval=N(POOL); + OA(yyval, OP_STRING_POOL, yyvsp[0]); /* stack: empty write context */ /* some code that writes to that context */ /* context=pop; stack: context.get_string() */ ; break;} case 158: -#line 583 "compile.y" +#line 581 "compile.y" { // optimized from OP_STRING+OP_WRITE_VALUE to OP_STRING__WRITE - change_string_literal_to_write_string_literal(*(yyval=yyvsp[0])) + change_string_literal_to_write_string_literal(yyval=yyvsp[0]) ; break;} case 159: -#line 588 "compile.y" -{ yyval=VL(new VVoid()) ; +#line 586 "compile.y" +{ yyval=VL(NEW VVoid(POOL)) ; break;} case 160: -#line 589 "compile.y" -{ yyval=N() ; +#line 587 "compile.y" +{ yyval=N(POOL) ; break;} } /* the action file gets copied in in place of this dollarsign */ @@ -1890,7 +1888,7 @@ yyerrhandle: } return 1; } -#line 591 "compile.y" +#line 589 "compile.y" #endif @@ -1979,7 +1977,7 @@ default: case '"': case ':': if(end!=begin) { // append piece till ^ - PC.string.append_strdup(begin, end-begin); + PC.string->APPEND_CLEAN(begin, end-begin, PC.file, begin_line); } // reset piece 'begin' position & line begin=PC.source; // ->punctuation @@ -1993,19 +1991,20 @@ default: case '#': if(end!=begin) { // append piece till ^ - PC.string.append_strdup(begin, end-begin); + PC.string->APPEND_CLEAN(begin, end-begin, PC.file, begin_line); } // #HH ? if(PC.source[0]=='#' && PC.source[1] && PC.source[2]) { - char c= + char *hex=(char *)POOL.malloc(1); + hex[0]= hex_value[(unsigned char)PC.source[1]]*0x10+ hex_value[(unsigned char)PC.source[2]]; - if(c==0) { + if(hex[0]==0) { result=BAD_HEX_LITERAL; goto break2; // wrong hex value[no ^#00 chars allowed]: bail out } // append char(hex(HH)) - PC.string.append(c); + PC.string->APPEND_CLEAN(hex, 1, PC.file, begin_line); // skip over ^#HH PC.source+=3; PC.col+=3; @@ -2024,7 +2023,7 @@ default: if(c=='#' && PC.col==1) { if(end!=begin) { // append piece till # - PC.string.append_strdup(begin, end-begin); + PC.string->APPEND_CLEAN(begin, end-begin, PC.file, begin_line); } // fall into COMMENT lexical state [wait for \n] push_LS(PC, LS_USER_COMMENT); @@ -2167,7 +2166,7 @@ default: case '#': // comment start skipping if(end!=begin) { // append piece till # - PC.string.append_strdup(begin, end-begin); + PC.string->APPEND_CLEAN(begin, end-begin, PC.file, begin_line); } // fall into COMMENT lexical state [wait for \n] push_LS(PC, LS_EXPRESSION_COMMENT); @@ -2599,14 +2598,14 @@ break2: } if(end!=begin && PC.ls!=LS_USER_COMMENT) { // last piece still alive and not comment? // append it - PC.string.append_strdup(begin, end-begin); + PC.string->APPEND_CLEAN(begin, end-begin, PC.file, begin_line/*, start_col*/); } } - if(!PC.string.is_empty()) { // something accumulated? + if(PC.string->size()) { // something accumulated? // create STRING value: array of OP_VALUE+vstring - *lvalp=VL(new VString(*new String(PC.string, String::L_CLEAN))); + *lvalp=VL(NEW VString(*PC.string)); // new pieces storage - PC.string.clear(); + PC.string=NEW String(POOL); // make current result be pending for next call, return STRING for now PC.pending_state=result; result=STRING; } @@ -2623,5 +2622,5 @@ static int real_yyerror(parse_control *p static void yyprint(FILE *file, int type, YYSTYPE value) { if(type==STRING) - fprintf(file, " \"%s\"", LA2S(*value)->cstr()); + fprintf(file, " \"%s\"", LA2S(value)->cstr()); }