--- parser3/src/main/compile.y 2016/07/20 16:36:49 1.283 +++ parser3/src/main/compile.y 2020/12/15 17:10:34 1.290 @@ -2,13 +2,13 @@ /** @file Parser: compiler(lexical parser and grammar). - Copyright (c) 2001-2015 Art. Lebedev Studio (http://www.artlebedev.com) + Copyright (c) 2001-2020 Art. Lebedev Studio (http://www.artlebedev.com) Author: Alexander Petrosyan (http://design.ru/paf) */ -volatile const char * IDENT_COMPILE_Y = "$Id: compile.y,v 1.283 2016/07/20 16:36:49 moko Exp $"; +volatile const char * IDENT_COMPILE_Y = "$Id: compile.y,v 1.290 2020/12/15 17:10:34 moko Exp $"; /** @todo parser4: @@ -143,7 +143,7 @@ static const VString vempty; %% all: one_big_piece { - Method* method=new Method(Method::CT_ANY, 0, 0 /*min, max numbered_params_count*/, 0 /*param_names*/, 0 /*local_names*/, $1 /*parser_code*/, 0 /*native_code*/); + Method* method=new Method(Method::CT_ANY, 0, 0 /*min, max numbered_params_count*/, 0 /*param_names*/, 0 /*local_names*/, $1 /*parser_code*/, 0 /*native_code*/, PC.cclass->is_vars_local()); PC.cclass->set_method(PC.alias_method(main_method_name), method); } | methods; @@ -167,9 +167,8 @@ control_method: '@' STRING '\n' // new class' name const String& name=LA2S(*strings_code)->trim(String::TRIM_END); // creating the class - VStateless_class* cclass=new VClass; + VStateless_class* cclass=new VClass(name.cstr(), PC.request.get_used_filespec(PC.file_no)); PC.cclass_new=cclass; - PC.cclass_new->set_type(name.cstr()); PC.append=false; } else { strcpy(PC.error, "@" CLASS_NAME " must contain only one line with class name (contains more then one)"); @@ -178,8 +177,7 @@ control_method: '@' STRING '\n' } else if(command==USE_CONTROL_METHOD_NAME) { CLASS_ADD; for(size_t i=0; icount(); i+=OPERATIONS_PER_OPVALUE){ - PC.request.use_file(PC.request.main_class, LA2S(*strings_code, i)->trim(String::TRIM_END), - PC.request.get_used_filename(PC.file_no), strings_code->get(i+1).origin); + PC.request.use_file(LA2S(*strings_code, i)->trim(String::TRIM_END), PC.request.get_used_filespec(PC.file_no), strings_code->get(i+1).origin); } } else if(command==BASE_NAME) { if(PC.append){ @@ -261,7 +259,8 @@ code_method: '@' STRING bracketed_maybe_ YYSTYPE locals_names_code=$4; ArrayString* locals_names=0; - bool all_vars_local=false; + bool all_vars_local=PC.cclass->is_vars_local(); + if(int size=locals_names_code->count()) { locals_names=new ArrayString; for(int i=0; iis_vars_local()) - all_vars_local=true; Method* method=new Method( //name, @@ -466,7 +463,6 @@ construct_square: '[' { ; construct_round: '(' expr_value ')' { $$=N(); - O(*$$, OP::OP_PREPARE_TO_EXPRESSION); // stack: context, name P(*$$, *$2); // stack: context, name, value O(*$$, OP::OP_CONSTRUCT_EXPR); /* value=pop->as_expr_result; name=pop; context=pop; construct(context,name,value) */ @@ -609,7 +605,6 @@ store_expr_param_part: expr_value { $$=expr_code; } else { YYSTYPE code=N(); - O(*code, OP::OP_PREPARE_TO_EXPRESSION); P(*code, *expr_code); O(*code, OP::OP_WRITE_EXPR_RESULT); $$=N();