--- parser3/src/main/compile.y 2009/08/01 04:58:45 1.250 +++ parser3/src/main/compile.y 2010/07/05 01:38:14 1.256 @@ -5,7 +5,7 @@ Copyright (c) 2001-2009 ArtLebedev Group (http://www.artlebedev.com) Author: Alexander Petrosyan (http://design.ru/paf) - $Id: compile.y,v 1.250 2009/08/01 04:58:45 misha Exp $ + $Id: compile.y,v 1.256 2010/07/05 01:38:14 misha Exp $ */ /** @@ -130,11 +130,11 @@ static const VVoid vvoid; %% all: one_big_piece { - 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*/, $1/*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); } | methods; @@ -167,7 +167,7 @@ control_method: '@' STRING '\n' } } else if(command==USE_CONTROL_METHOD_NAME) { for(size_t i=0; icount(); i+=OPERATIONS_PER_OPVALUE) - PC.request.use_file(PC.request.main_class, *LA2S(*strings_code, i)); + PC.request.use_file(PC.request.main_class, *LA2S(*strings_code, i), PC.request.get_used_filename(PC.file_no)); } else if(command==BASE_NAME) { if(PC.append){ strcpy(PC.error, "can't set base while appending methods to class '"); @@ -184,7 +184,7 @@ control_method: '@' STRING '\n' } 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) { @@ -221,18 +221,24 @@ control_method: '@' STRING '\n' YYERROR; } } else { - // mark new class as partial. we can add methods to it later. + // marks the new class as partial. we will be able to add methods here later. PC.cclass_new->set_partial(); } } else { strcpy(PC.error, "'"OPTION_PARTIAL_CLASS"' option should be used straight after @"CLASS_NAME); YYERROR; } + } else if(option==method_call_type_static){ + PC.set_methods_call_type(Method::CT_STATIC); + } else if(option==method_call_type_dynamic){ + PC.set_methods_call_type(Method::CT_DYNAMIC); } else { strcpy(PC.error, "'"); strncat(PC.error, option.cstr(), MAX_STRING/2); strcat(PC.error, "' invalid option. valid options are " - "'"OPTION_PARTIAL_CLASS"' and '"OPTION_ALL_VARS_LOCAL_NAME"'"); + "'"OPTION_PARTIAL_CLASS"', '"OPTION_ALL_VARS_LOCAL_NAME"'" + ", '"METHOD_CALL_TYPE_STATIC"' and '"METHOD_CALL_TYPE_DYNAMIC"'" + ); YYERROR; } } @@ -281,22 +287,20 @@ code_method: '@' STRING bracketed_maybe_ Method* method=new Method( //name, - Method::CT_ANY, + GetMethodCallType(PC, LA2S(*$2)), 0, 0/*min,max numbered_params_count*/, params_names, locals_names, 0/*to be filled later in next {} */, 0, all_vars_local); *reinterpret_cast(&$$)=method; - - // todo: check [][;result;] } maybe_codes { - Method& method=*reinterpret_cast($7); + Method* method=reinterpret_cast($7); // fill in the code - method.parser_code=$8; + method->parser_code=$8; // register in class const String& name=*LA2S(*$2); - PC.cclass->add_method(PC.alias_method(name), method); + PC.cclass->set_method(PC.alias_method(name), method); }; maybe_bracketed_strings: empty | bracketed_maybe_strings; @@ -706,12 +710,8 @@ class_static_prefix: STRING ':' { YYERROR; } } -#ifdef OPTIMIZE_BYTECODE_GET_CLASS // optimized OP_VALUE+origin+string+OP_GET_CLASS => OP_VALUE__GET_CLASS+origin+string maybe_change_first_opcode(*$$, OP::OP_VALUE, OP::OP_VALUE__GET_CLASS) -#else - O(*$$, OP::OP_GET_CLASS); -#endif }; class_constructor_prefix: class_static_prefix ':' { $$=$1; @@ -1350,7 +1350,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