--- parser3/src/include/pa_operation.h 2003/04/02 16:05:19 1.1.2.6.2.4 +++ parser3/src/include/pa_operation.h 2024/11/04 03:53:25 1.13 @@ -1,15 +1,15 @@ /** @file Parser: compiled code related decls. - Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2001-2024 Art. Lebedev Studio (http://www.artlebedev.com) - Author: Alexandr Petrosian (http://paf.design.ru) + Authors: Konstantin Morshnev , Alexandr Petrosian */ #ifndef OPERATION_H #define OPERATION_H -static const char* IDENT_OPERATION_H="$Date: 2003/04/02 16:05:19 $"; +#define IDENT_PA_OPERATION_H "$Id: pa_operation.h,v 1.13 2024/11/04 03:53:25 moko Exp $" #include "pa_array.h" #include "pa_opcode.h" @@ -27,44 +27,39 @@ typedef Array ArrayOperation; 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_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 { -public: - struct Info { - uint fcode:6; ///< operation code [at the moment, max=58. 2^6=64 - //@{ origin - uint file_no:7; ///< file number (max: 128): index in Request::files table - uint line:12; ///< line number (max: 4096) - uint col:7; ///< column number (max: 128) - //@} - OPCODE code() const { return (OPCODE)fcode; } - void set_code(OPCODE acode) { fcode=acode; } - } info; - OPCODE code() const { return info.code(); } - void set_code(OPCODE acode) { info.set_code(acode); } + 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; + } + }; + + OP::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* ops; ///< not an operation, but rather code array stored after argumented op /// needed to fill unused Array entries Operation() {} - Operation(OPCODE acode) { - info.fcode=acode; - info.file_no=0; - info.line=0; - info.col=0; - } - Operation(OPCODE acode, uint afile_no, uint aline, uint acol) { - info.fcode=acode; - info.file_no=afile_no; - info.line=aline; - info.col=acol; - } + Operation(OP::OPCODE acode): code(acode) {} + 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 + +#define OPERATIONS_PER_OPVALUE 3 + #endif