--- parser3/src/main/compile_tools.C 2002/02/08 07:27:46 1.44 +++ parser3/src/main/compile_tools.C 2002/04/15 08:13:10 1.48 @@ -2,9 +2,9 @@ Parser: compiler support helper functions. Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) - Author: Alexander Petrosyan (http://paf.design.ru) + Author: Alexandr Petrosian (http://paf.design.ru) - $Id: compile_tools.C,v 1.44 2002/02/08 07:27:46 paf Exp $ + $Id: compile_tools.C,v 1.48 2002/04/15 08:13:10 paf Exp $ */ #include "compile_tools.h" @@ -59,6 +59,25 @@ void PNC(Array/**/ *result, A *result+=code_array; } +void PJP(Array/**/ *result, Array/**/ *code_array) { + // append OP_CODE + Operation op; op.code=OP_OBJECT_POOL; + *result+=op.cast; + + // append 'vstring' + *result+=code_array; +} + +void PSP(Array/**/ *result, Array/**/ *code_array) { + // append OP_CODE + Operation op; op.code=OP_STRING_POOL; + *result+=op.cast; + + // append 'vstring' + *result+=code_array; +} + + Array *VL(Value *value) { // empty ops array @@ -87,17 +106,33 @@ void change_string_literal_to_write_stri Operation op; op.code=OP_STRING__WRITE; literal_string_array->put(0, op.cast); } +void changetail_or_append(Array *opcodes, OPCODE find, OPCODE replace, OPCODE notfound) { + if(int tail=opcodes->size()) { + --tail; + Operation op; + op.cast=opcodes->get(tail); + if(op.code==find) { + op.code=replace; + opcodes->put(tail, op.cast); + return; + } + } + + Operation op; op.code=notfound; + *opcodes+=op.cast; +} + void push_LS(parse_control& pc, lexical_state new_state) { if(pc.ls_sp=0) pc.ls=pc.ls_stack[pc.ls_sp]; else - throw Exception(0, 0, 0, "pop_LS: ls_stack underflow"); + throw Exception(0, 0, "pop_LS: ls_stack underflow"); }