--- parser3/src/include/pa_operation.h 2003/01/30 09:34:30 1.1.2.2 +++ parser3/src/include/pa_operation.h 2003/07/24 11:31:21 1.2 @@ -1,7 +1,7 @@ /** @file Parser: compiled code related decls. - Copyright (c) 2001, 2003 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ @@ -9,47 +9,60 @@ #ifndef OPERATION_H #define OPERATION_H -static const char* IDENT_OPERATION_H="$Date: 2003/01/30 09:34:30 $"; +static const char* IDENT_OPERATION_H="$Date: 2003/07/24 11:31:21 $"; #include "pa_array.h" +#include "pa_opcode.h" +#include "pa_value.h" // forwards -enum OPCODE; -class Value; -class ArrayOperation; +union Operation; +typedef Array ArrayOperation; /** Parser source code got compiled into intermediate form of Operation-s, - which is executed afterwards. + which are executed afterwards. It is compiled into Array of Operation-s. Each Operation can be either OPCODE or data pointer, following the literal-instruction. - - OP_VALUE followed by Value* - - OP_CURLY_CODE__STORE_PARAM followed by Array* - - OP_EXPR_CODE__STORE_PARAM followed by Array* - - OP_NESTED_CODE followed by Array* + - OP_VALUE followed by Origin, followed by Value* + - OP_CURLY_CODE__STORE_PARAM followed by ArrayOperation* + - OP_EXPR_CODE__STORE_PARAM followed by ArrayOperation* + - OP_NESTED_CODE followed by ArrayOperation* */ union Operation { - //void *cast; ///< casting helper + struct Origin { + uint file_no:8; ///< file number (max: 255): index in Request::file_list + uint line:8+8; ///< line number (max: 64535) + uint col:8; ///< column number (max: 255) + + static Origin create(uint afile_no, uint aline, uint acol) { + Origin result={afile_no, aline, acol}; + return result;/* + result.file_no=afile_no; + result.line=aline; + result.col=acol;*/ + } + }; OPCODE code; ///< operation code + Origin origin; ///< not an operation, but rather debug information: [OP_VALUE; debug_info; Value*] Value* value; ///< not an operation, but rather value stored after argumented op - ArrayOperation* array; ///< not an operation, but rather code array stored after argumented op + ArrayOperation* ops; ///< not an operation, but rather code array stored after argumented op + /// needed to fill unused Array entries + Operation() {} Operation(OPCODE acode): code(acode) {} - Operation(Value *avalue): value(avalue) {} - Operation(ArrayOperation* aarray): array(aarray) {} + Operation(uint afile_no, uint aline, uint acol): + origin(Origin::create(afile_no, aline, acol)) {} + Operation(Value* avalue): value(avalue) {} + Operation(ArrayOperation* aops): ops(aops) {} }; +// defines -class ArrayOperation: public Array { -public: - /// goes through byte-code and deletes value/array, see execute.C - override ~ArrayOperation(); -}; -DECLARE_OBJECT_PTR(ArrayOperation); - +#define OPERATIONS_PER_OPVALUE 3 #endif