--- parser3/src/main/compile.y 2001/03/29 15:00:21 1.121 +++ parser3/src/main/compile.y 2001/04/06 10:20:36 1.124 @@ -5,7 +5,7 @@ Author: Alexander Petrosyan (http://design.ru/paf) - $Id: compile.y,v 1.121 2001/03/29 15:00:21 paf Exp $ + $Id: compile.y,v 1.124 2001/04/06 10:20:36 paf Exp $ */ /** @@ -113,6 +113,7 @@ all: one_big_piece { Method& method=*NEW Method(POOL, *main_method_name, + Method::CT_ANY, 0, 0, /*min, max numbered_params_count*/ 0/*param_names*/, 0/*local_names*/, $1/*parser_code*/, 0/*native_code*/); @@ -136,7 +137,7 @@ control_method: '@' STRING '\n' YYERROR; } if(command==CLASS_NAME) { - if(PC.cclass!=&PC.request->ROOT) { // already changed from default? + if(PC.cclass) { // already changed from default? strcpy(PC.error, "class already have a name '"); strncat(PC.error, PC.cclass->name().cstr(), 100); strcat(PC.error, "'"); @@ -148,8 +149,6 @@ control_method: '@' STRING '\n' // creating the class PC.cclass=NEW VClass(POOL); PC.cclass->set_name(*name); - // defaulting base. may change with @BASE - PC.cclass->set_base(PC.request->ROOT); // append to request's classes PC.request->classes().put(*name, PC.cclass); } else { @@ -162,7 +161,7 @@ control_method: '@' STRING '\n' PC.request->use_file( PC.request->absolute(*LA2S(strings_code, i))); } else if(command==BASE_NAME) { - if(PC.cclass->base()!=&PC.request->ROOT) { // already changed from default? + if(PC.cclass->base()) { // already changed from default? strcpy(PC.error, "class already have a base '"); strncat(PC.error, PC.cclass->base()->name().cstr(), 100); strcat(PC.error, "'"); @@ -222,6 +221,7 @@ code_method: '@' STRING bracketed_maybe_ Method& method=*NEW Method(POOL, *name, + Method::CT_ANY, 0, 0/*min,max numbered_params_count*/, params_names, locals_names, $7, 0); @@ -345,8 +345,15 @@ call: call_value { call_value: '^' call_name store_params EON { /* ^field.$method{vasya} */ $$=$2; /* with_xxx,diving code; stack: context,method_junction */ O($$, OP_GET_METHOD_FRAME); /* stack: context,method_frame */ - P($$, $3); /* filling method_frame.store_params */ - O($$, OP_CALL); /* method_frame=pop; ncontext=pop; call(ncontext,method_frame) stack: value */ + + YYSTYPE params_code=$3; + if(params_code->size()==3) // probably [] case. [OP_VALUE + Unknown + STORE_PARAM] + if(Value *value=LA2V(params_code)) // it is OP_VALUE + value? + if(!value->is_defined()) // value is VUnknown? + params_code=0; // ^zzz[] case. don't append lone empty param. + if(params_code) + P($$, params_code); // filling method_frame.store_params + O($$, OP_CALL); // method_frame=pop; ncontext=pop; call(ncontext,method_frame) stack: value }; call_name: name_without_curly_rdive; @@ -357,16 +364,7 @@ store_param: | store_round_param | store_curly_param ; -store_square_param: '[' store_code_param_parts ']' { - YYSTYPE params_code=$2; - if(params_code->size()==3) // probably [] case. [OP_VALUE + Unknown + STORE_PARAM] - if(!LA2V(params_code)->is_defined()) { // value is VUnknown? - $$=N(POOL); // ^zzz[] case. don't append lone empty param. - break; - } - - $$=params_code; -}; +store_square_param: '[' store_code_param_parts ']' {$$=$2}; store_round_param: '(' store_expr_param_parts ')' {$$=$2}; store_curly_param: '{' store_curly_param_parts '}' {$$=$2}; store_code_param_parts: