|
|
| version 1.103, 2012/03/16 09:24:12 | version 1.110, 2016/04/01 16:27:32 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: compiler support helper functions decls. | Parser: compiler support helper functions decls. |
| Copyright (c) 2001-2012 Art. Lebedev Studio (http://www.artlebedev.com) | Copyright (c) 2001-2015 Art. Lebedev Studio (http://www.artlebedev.com) |
| Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) | Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) |
| */ | */ |
| Line 124 public: | Line 124 public: |
| *cclasses+=aclass; | *cclasses+=aclass; |
| } | } |
| void class_add(){ | /// true if exception should be rised |
| bool class_add(){ | |
| if(cclass_new){ | if(cclass_new){ |
| cclass=cclass_new; | cclass=cclass_new; |
| // append to request's classes | |
| request.classes().put(cclass->name(), cclass); | |
| *cclasses+=cclass; | *cclasses+=cclass; |
| cclass_new=0; | cclass_new=0; |
| append=false; | append=false; |
| // append to request's classes | |
| if(!request.allow_class_replace) | |
| return request.classes().put_dont_replace(cclass->type(), cclass) != 0; | |
| request.classes().put(cclass->type(), cclass); | |
| } | } |
| return false; | |
| } | } |
| VStateless_class* get_existed_class(VStateless_class* aclass){ | VStateless_class* get_existed_class(VStateless_class* aclass){ |
| // checking existence of the class during processing @OPTIONS\npartial | // checking existence of the class during processing @OPTIONS\npartial |
| // method should't use get_class because the last one will call operator @autouse[] if the class wasn't loaded | // method should't use get_class because the last one will call operator @autouse[] if the class wasn't loaded |
| if(aclass) | if(aclass) |
| if(Value* class_value=request.classes().get(aclass->name())) | if(Value* class_value=request.classes().get(aclass->type())) |
| return class_value->get_class(); | return class_value->get_class(); |
| return 0; | return 0; |
| } | } |
| Line 261 void maybe_change_string_literal_to_doub | Line 265 void maybe_change_string_literal_to_doub |
| void change_string_literal_value(ArrayOperation& literal_string_array, const String& new_value); | void change_string_literal_value(ArrayOperation& literal_string_array, const String& new_value); |
| void changetail_or_append(ArrayOperation& opcodes, | inline bool change(ArrayOperation& opcodes, int pos, OP::OPCODE find, OP::OPCODE replace) { |
| OP::OPCODE find, bool with_argument, OP::OPCODE replace, OP::OPCODE notfound); | if(pos>=0) { |
| Operation& op=opcodes.get_ref(pos); | |
| if(op.code==find) { | |
| op.code=replace; | |
| return true; | |
| } | |
| } | |
| return false; | |
| } | |
| inline void change_or_append(ArrayOperation& opcodes, int pos, OP::OPCODE find, OP::OPCODE replace, OP::OPCODE notfound) { | |
| if(change(opcodes, pos, find, replace)) | |
| return; | |
| bool maybe_change_first_opcode(ArrayOperation& opcodes, OP::OPCODE find, OP::OPCODE replace); | opcodes+=Operation(notfound); |
| } | |
| bool change_first(ArrayOperation& opcodes, OP::OPCODE find, OP::OPCODE replace); | |
| #ifdef OPTIMIZE_BYTECODE_GET_OBJECT_ELEMENT | #ifdef OPTIMIZE_BYTECODE_GET_OBJECT_ELEMENT |
| // OP_VALUE+origin+value+OP_GET_ELEMENT+OP_VALUE+origin+value+OP_GET_ELEMENT => OP_GET_OBJECT_ELEMENT+origin+value+origin+value | // OP_VALUE+origin+value+OP_GET_ELEMENT+OP_VALUE+origin+value+OP_GET_ELEMENT => OP_GET_OBJECT_ELEMENT+origin+value+origin+value |
| Line 317 inline bool maybe_make_get_object_var_el | Line 335 inline bool maybe_make_get_object_var_el |
| bool maybe_make_self(ArrayOperation& opcodes, ArrayOperation& diving_code, size_t divine_count); | bool maybe_make_self(ArrayOperation& opcodes, ArrayOperation& diving_code, size_t divine_count); |
| #ifdef OPTIMIZE_BYTECODE_GET_ELEMENT__SPECIAL | |
| bool maybe_append_simple_diving_code(ArrayOperation& code, ArrayOperation& diving_code); | |
| bool is_special_element(ArrayOperation& opcodes); | |
| #endif | |
| #ifdef OPTIMIZE_BYTECODE_CONSTRUCT | #ifdef OPTIMIZE_BYTECODE_CONSTRUCT |
| inline bool maybe_optimize_construct(ArrayOperation& opcodes, ArrayOperation& var_ops, ArrayOperation& expr_ops){ | inline bool maybe_optimize_construct(ArrayOperation& opcodes, ArrayOperation& var_ops, ArrayOperation& expr_ops){ |
| Line 343 inline bool maybe_optimize_construct(Arr | Line 366 inline bool maybe_optimize_construct(Arr |
| with=0x30; | with=0x30; |
| break; | break; |
| } | } |
| default: break; | |
| } | } |
| if(with && var_ops[1].code==OP::OP_VALUE && var_ops.count()==4){ | if(with && var_ops[1].code==OP::OP_VALUE && var_ops.count()==4){ |