|
|
| version 1.67.2.1, 2003/01/30 09:14:01 | version 1.67.2.8, 2003/02/04 08:29:26 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: compiler support helper functions decls. | Parser: compiler support helper functions decls. |
| Copyright (c) 2001, 2003 ArtLebedev Group (http://www.artlebedev.com) | Copyright (c) 2001-2003 ArtLebedev Group (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 42 enum lexical_state { | Line 42 enum lexical_state { |
| struct parse_control { | struct parse_control { |
| //@{ | //@{ |
| /// @name input | /// @name input |
| Pool *pool; | Pool* pool; |
| Request *request; | Request* request; |
| VStateless_class *cclass; | VStateless_class* cclass; |
| #ifndef NO_STRING_ORIGIN | #ifndef NO_STRING_ORIGIN |
| const char *source; | const char* source; |
| const char *file; | const char* file; |
| #endif | #endif |
| int line, col; | int line, col; |
| //@} | //@} |
| Line 71 struct parse_control { | Line 71 struct parse_control { |
| }; | }; |
| /// New array // return empty array | /// New array // return empty array |
| inline ArrayCodePtr N() { | inline ArrayOperationPtr N() { |
| return new ArrayCode; | return ArrayOperationPtr(new ArrayOperation); |
| } | } |
| /// Assembler instruction // append ordinary instruction to ops | /// Assembler instruction // append ordinary instruction to ops |
| inline void O(Array/*<Operation>*/ *result, enum OPCODE code) { | inline void O(ArrayOperation& result, OPCODE code) { |
| Operation op; op.code=code; | result+=Operation(code); |
| *result+=op.cast; | |
| } | } |
| /// aPpend 'code_array' to 'result' | /// aPpend 'code_array' to 'result' |
| inline void P(Array/*<Operation>*/ *result, Array *code_array) { | inline void P(ArrayOperation& result, ArrayOperation& code_array) { |
| result->append_array(*code_array); | result.append(code_array); |
| } | } |
| /// aPpend part of 'code_array', starting from offset, to 'result' | /// aPpend part of 'code_array', starting from offset, to 'result' |
| inline void P(Array/*<Operation>*/ *result, Array *code_array, int offset) { | inline void P(ArrayOperation& result, ArrayOperation& code_array, int offset) { |
| result->append_array(*code_array, offset); | result.append(code_array, offset); |
| } | } |
| /// aPpend 'vstring' to 'result' | /// aPpend 'vstring' to 'result' |
| void PV(Array/*<Operation>*/ *result, Value *value); | inline void PV(ArrayOperation& result, ValuePtr value) { |
| result+=Operation(OP_VALUE); // append OP_VALUE | |
| inline void OA(Array/*<Operation>*/ *result, OPCODE opcode, Array/*<Operation>*/ *code_array) { | result+=Operation(value); // append 'value' |
| // append OP_CODE | } |
| Operation op; op.code=opcode; | |
| *result+=op.cast; | |
| // append 'vstring' | /// append cOde Array |
| *result+=code_array; | inline void OA(ArrayOperation& result, OPCODE code, ArrayOperationPtr code_array) { |
| result+=Operation(code); // append OP_CODE | |
| result+=Operation(code_array); // append 'code_array' | |
| } | } |
| /** | /** |
| Line 107 inline void OA(Array/*<Operation>*/ *res | Line 106 inline void OA(Array/*<Operation>*/ *res |
| - first: OP_VALUE instruction | - first: OP_VALUE instruction |
| - second op: string itself | - second op: string itself |
| */ | */ |
| inline Array *VL(Value *value) { | inline ArrayOperationPtr VL(ValuePtr value) { |
| // empty ops array | // empty ops array |
| Array *result=N(value->pool()); | ArrayOperationPtr result=N(); |
| // append 'value' to 'result' | // append 'value' to 'result' |
| PV(result, value); | PV(*result, value); |
| return result; | return result; |
| } | } |
| /// Literal Array to(2) Value @return Value from literal Array OP+Value | /// Literal Array to(2) Value @return Value from literal Array OP+Value |
| Value *LA2V(Array *literal_string_array, int offset=0); | ValuePtr LA2V(ArrayOperation& literal_string_array, int offset=0); |
| /// Literal Array to(2) String @return String value from literal Array OP+String array | /// Literal Array to(2) String @return String value from literal Array OP+String array |
| inline const String *LA2S(Array *literal_string_array, int offset=0) { | inline StringPtr LA2S(ArrayOperation& literal_string_array, int offset=0) { |
| if(Value *value=LA2V(literal_string_array, offset)) | if(ValuePtr value=LA2V(literal_string_array, offset)) |
| return value->get_string(); | return value->get_string(0); |
| return 0; | return StringPtr(0); |
| } | } |
| inline void change_string_literal_to_write_string_literal(Array *literal_string_array) { | inline void change_string_literal_to_write_string_literal(ArrayOperation& literal_string_array) { |
| Operation op; op.code=OP_STRING__WRITE; | literal_string_array[0].code=OP_STRING__WRITE; |
| literal_string_array->put(0, op.cast); | |
| } | } |
| void changetail_or_append(Array *opcodes, | |
| OPCODE find, bool with_argument, OPCODE replace, OPCODE notfound); | |
| void change_string_literal_to_double_literal(Array *literal_string_array); | void change_string_literal_to_double_literal(ArrayOperation& literal_string_array); |
| void change_string_literal_value(ArrayOperation& literal_string_array, StringPtr new_value); | |
| void changetail_or_append(ArrayOperation& opcodes, | |
| OPCODE find, bool with_argument, OPCODE replace, OPCODE notfound); | |
| void change_string_literal_value(Array *literal_string_array, const String& new_value); | |
| void push_LS(parse_control& pc, lexical_state new_state); | void push_LS(parse_control& pc, lexical_state new_state); |
| void pop_LS(parse_control& pc); | void pop_LS(parse_control& pc); |