1 /* 2 * OpenBOR - http://www.chronocrash.com 3 * ----------------------------------------------------------------------- 4 * All rights reserved, see LICENSE in OpenBOR root for details. 5 * 6 * Copyright (c) 2004 - 2013 OpenBOR Team 7 */ 8 9 #ifndef INSTRUCTION_H 10 #define INSTRUCTION_H 11 #include "depends.h" 12 #include "Lexer.h" 13 #include "List.h" 14 #include "ScriptVariant.h" 15 16 typedef LPSTR Label; 17 18 typedef enum OpCode { CONSTSTR, CONSTDBL, CONSTINT, LOAD, SAVE, INC, DEC, FIELD, CALL, POS, NEG, 19 NOT, MUL, DIV, MOD, ERR, ADD, SUB, SHL, SHR, JUMP, PJUMP, GE, LE, LT, GT, EQ, NE, OR, AND, 20 BIT_OR, XOR, BIT_AND, NOOP, PUSH, POP, Branch_FALSE, Branch_TRUE, Branch_EQUAL, DATA, PARAM, 21 IMMEDIATE, DEFERRED, RET, CHECKARG, CLEAN, JUMPR, FUNCDECL, OPCODE_END 22 } OpCode; 23 24 typedef struct Instruction 25 { 26 unsigned OpCode; 27 unsigned jumpTargetType; 28 unsigned step; 29 Token *theToken; 30 CHAR *Label;//[MAX_STR_LEN+1]; 31 ScriptVariant *theVal; 32 ScriptVariant *theRef; 33 ScriptVariant *theRef2; 34 List *theRefList; 35 HRESULT (*functionRef)(ScriptVariant **, ScriptVariant **, int); 36 union 37 { 38 int theJumpTargetIndex; 39 struct Instruction **ptheJumpTarget; 40 //struct Instruction* theJumpTarget; 41 }; 42 } Instruction; 43 44 45 void Instruction_InitViaToken(Instruction *pins, OpCode code, Token *pToken ); 46 void Instruction_InitViaLabel(Instruction *pins, OpCode code, LPCSTR label ); 47 void Instruction_Init(Instruction *pins); 48 void Instruction_Clear(Instruction *pins); 49 50 void Instruction_NewData(Instruction *pins); 51 void Instruction_ConvertConstant(Instruction *pins); 52 53 void Instruction_ToString(Instruction *pins, LPSTR strRep); 54 #endif 55