--- parser3/src/main/compile_tools.h 2009/04/17 12:00:08 1.83 +++ parser3/src/main/compile_tools.h 2009/05/19 13:33:14 1.86 @@ -8,7 +8,7 @@ #ifndef COMPILE_TOOLS #define COMPILE_TOOLS -static const char * const IDENT_COMPILE_TOOLS_H="$Date: 2009/04/17 12:00:08 $"; +static const char * const IDENT_COMPILE_TOOLS_H="$Date: 2009/05/19 13:33:14 $"; #include "pa_opcode.h" #include "pa_types.h" @@ -201,6 +201,11 @@ inline void P(ArrayOperation& result, Ar result.append(code_array, offset); } +/// aPpend part of 'code_array', starting from offset, to 'result' +inline void P(ArrayOperation& result, ArrayOperation& code_array, int offset, int limit) { + result.append(code_array, offset, limit); +} + /// append cOde Array inline void OA(ArrayOperation& result, OP::OPCODE code, ArrayOperation* code_array) { result+=Operation(code); // append OP_CODE @@ -226,10 +231,10 @@ inline ArrayOperation* VL(Value* value, } /// Literal Array to(2) Value @return Value from literal Array OP+origin+Value -Value* LA2V(ArrayOperation& literal_string_array, int offset=0); +Value* LA2V(ArrayOperation& literal_string_array, int offset=0, OP::OPCODE code=OP::OP_VALUE); /// Literal Array to(2) String @return String value from literal Array OP+origin+String array -inline const String* LA2S(ArrayOperation& literal_string_array, int offset=0) { - if(Value* value=LA2V(literal_string_array, offset)) +inline const String* LA2S(ArrayOperation& literal_string_array, int offset=0, OP::OPCODE code=OP::OP_VALUE) { + if(Value* value=LA2V(literal_string_array, offset, code)) return value->get_string(); return 0; } @@ -238,6 +243,11 @@ inline void change_string_literal_to_wri literal_string_array.put(0, OP::OP_STRING__WRITE); } +bool maybe_change_first_opcode(ArrayOperation& opcodes, OP::OPCODE find, OP::OPCODE replace, bool strict=false); + +bool maybe_change_first_opcode(ArrayOperation& opcodes, OP::OPCODE find, OP::OPCODE last, OP::OPCODE replace); + +bool append_2ops_opcode(ArrayOperation& opcodes, ArrayOperation& diving_code, OP::OPCODE code, size_t offset); void maybe_change_string_literal_to_double_literal(ArrayOperation& literal_string_array);