Quellcode durchsuchen

Add _OP_NOP to try solve the goto _POP_TRAP and RESOLVE_OUTERS, still need work on it

mingodad vor 9 Jahren
Ursprung
Commit
7fa8db67b8
3 geänderte Dateien mit 78 neuen und 73 gelöschten Zeilen
  1. 3 1
      SquiLu/squirrel/sqcompiler.cpp
  2. 73 72
      SquiLu/squirrel/sqopcodes.h
  3. 2 0
      SquiLu/squirrel/sqvm.cpp

+ 3 - 1
SquiLu/squirrel/sqcompiler.cpp

@@ -625,7 +625,9 @@ public:
 
 
             //if(_fs->_traps > 0)
             //if(_fs->_traps > 0)
 			//		_fs->AddInstruction(_OP_POPTRAP, _fs->_traps, 0);
 			//		_fs->AddInstruction(_OP_POPTRAP, _fs->_traps, 0);
-			RESOLVE_OUTERS();
+			//RESOLVE_OUTERS();
+			_fs->AddInstruction(_OP_NOP, 0, 0); //for _OP_POPTRAP
+			_fs->AddInstruction(_OP_NOP, 0, 0); //for OUTERS
 			_fs->AddInstruction(_OP_JMP, 0, -1234);
 			_fs->AddInstruction(_OP_JMP, 0, -1234);
 			SQGotoLabelsInfo info;
 			SQGotoLabelsInfo info;
 			info.name = id;
 			info.name = id;

+ 73 - 72
SquiLu/squirrel/sqopcodes.h

@@ -1,40 +1,40 @@
-/*	see copyright notice in squirrel.h */
-#ifndef _SQOPCODES_H_
-#define _SQOPCODES_H_
-
-#define MAX_FUNC_STACKSIZE 0xFF
-#define MAX_LITERALS ((SQInteger)0x7FFFFFFF)
-
-enum BitWiseOP {
-	BW_AND = 0,
-	BW_OR = 2,
-	BW_XOR = 3,
-	BW_SHIFTL = 4,
-	BW_SHIFTR = 5,
-	BW_USHIFTR = 6
-};
-
-enum CmpOP {
-	CMP_G = 0,
-	CMP_GE = 2,
-	CMP_L = 3,
-	CMP_LE = 4,
-	CMP_3W = 5
-};
-
-enum NewObjectType {
-	NOT_TABLE = 0,
-	NOT_ARRAY = 1,
-	NOT_CLASS = 2
-};
-
-enum AppendArrayType {
-	AAT_STACK = 0,
-	AAT_LITERAL = 1,
-	AAT_INT = 2,
-	AAT_FLOAT = 3,
-	AAT_BOOL = 4
-};
+/*	see copyright notice in squirrel.h */
+#ifndef _SQOPCODES_H_
+#define _SQOPCODES_H_
+
+#define MAX_FUNC_STACKSIZE 0xFF
+#define MAX_LITERALS ((SQInteger)0x7FFFFFFF)
+
+enum BitWiseOP {
+	BW_AND = 0,
+	BW_OR = 2,
+	BW_XOR = 3,
+	BW_SHIFTL = 4,
+	BW_SHIFTR = 5,
+	BW_USHIFTR = 6
+};
+
+enum CmpOP {
+	CMP_G = 0,
+	CMP_GE = 2,
+	CMP_L = 3,
+	CMP_LE = 4,
+	CMP_3W = 5
+};
+
+enum NewObjectType {
+	NOT_TABLE = 0,
+	NOT_ARRAY = 1,
+	NOT_CLASS = 2
+};
+
+enum AppendArrayType {
+	AAT_STACK = 0,
+	AAT_LITERAL = 1,
+	AAT_INT = 2,
+	AAT_FLOAT = 3,
+	AAT_BOOL = 4
+};
 
 
 #define SQ_OP_CODE_LIST() \
 #define SQ_OP_CODE_LIST() \
 	ENUM_OP(_OP_LINE, 0x00)\
 	ENUM_OP(_OP_LINE, 0x00)\
@@ -100,42 +100,43 @@ enum AppendArrayType {
 	ENUM_OP(_OP_CLOSE, 0x3C)\
 	ENUM_OP(_OP_CLOSE, 0x3C)\
 	ENUM_OP(_OP_EQI, 0x3D)\
 	ENUM_OP(_OP_EQI, 0x3D)\
 	ENUM_OP(_OP_NEI, 0x3E)\
 	ENUM_OP(_OP_NEI, 0x3E)\
-	ENUM_OP(_OP__LAST__, 0x3F)
+	ENUM_OP(_OP_NOP, 0x3F)\
+	ENUM_OP(_OP__LAST__, 0x40)
 
 
 //#define ENUM_OP(a,b) a = b,
 //#define ENUM_OP(a,b) a = b,
-//there is no point right now to manually number the opcodes
-#define ENUM_OP(a,b) a,
-enum SQOpcode
+//there is no point right now to manually number the opcodes
+#define ENUM_OP(a,b) a,
+enum SQOpcode
 {
 {
-    SQ_OP_CODE_LIST()
+    SQ_OP_CODE_LIST()
 };
 };
-#undef ENUM_OP
-
-struct SQInstructionDesc {
-	const SQChar *name;
-};
-
-struct SQInstruction
-{
-	SQInstruction(){};
-	SQInstruction(SQOpcode _op,SQInteger a0=0,SQInteger a1=0,SQInteger a2=0,SQInteger a3=0)
-	{	op = (unsigned char)_op;
-		_arg0 = (unsigned char)a0;_arg1 = (SQInt32)a1;
-		_arg2 = (unsigned char)a2;_arg3 = (unsigned char)a3;
-	}
-
-
-	SQInt32 _arg1;
-	unsigned char op;
-	unsigned char _arg0;
-	unsigned char _arg2;
-	unsigned char _arg3;
-};
-
-#include "squtils.h"
-typedef sqvector<SQInstruction> SQInstructionVec;
-
-#define NEW_SLOT_ATTRIBUTES_FLAG	0x01
-#define NEW_SLOT_STATIC_FLAG		0x02
-
-#endif // _SQOPCODES_H_
+#undef ENUM_OP
+
+struct SQInstructionDesc {
+	const SQChar *name;
+};
+
+struct SQInstruction
+{
+	SQInstruction(){};
+	SQInstruction(SQOpcode _op,SQInteger a0=0,SQInteger a1=0,SQInteger a2=0,SQInteger a3=0)
+	{	op = (unsigned char)_op;
+		_arg0 = (unsigned char)a0;_arg1 = (SQInt32)a1;
+		_arg2 = (unsigned char)a2;_arg3 = (unsigned char)a3;
+	}
+
+
+	SQInt32 _arg1;
+	unsigned char op;
+	unsigned char _arg0;
+	unsigned char _arg2;
+	unsigned char _arg3;
+};
+
+#include "squtils.h"
+typedef sqvector<SQInstruction> SQInstructionVec;
+
+#define NEW_SLOT_ATTRIBUTES_FLAG	0x01
+#define NEW_SLOT_STATIC_FLAG		0x02
+
+#endif // _SQOPCODES_H_

+ 2 - 0
SquiLu/squirrel/sqvm.cpp

@@ -817,6 +817,7 @@ bool SQVM::Execute(SQObjectPtr &closure, SQInteger nargs, SQInteger stackbase,SQ
 	OPCODE_PTR(CLOSE),
 	OPCODE_PTR(CLOSE),
 	OPCODE_PTR(EQI),
 	OPCODE_PTR(EQI),
 	OPCODE_PTR(NEI),
 	OPCODE_PTR(NEI),
+	OPCODE_PTR(NOP),
 };
 };
 #endif
 #endif
 
 
@@ -1040,6 +1041,7 @@ exception_restore:
 			OPCODE_TARGET(NEI) {
 			OPCODE_TARGET(NEI) {
 				TARGET = (!IsEqualIdentity(STK(arg2),COND_LITERAL))?true:false;
 				TARGET = (!IsEqualIdentity(STK(arg2),COND_LITERAL))?true:false;
 				continue;}
 				continue;}
+			OPCODE_TARGET(NOP) {continue;}
 			OPCODE_TARGET(ADD) { _ARITH_(+,TARGET,STK(arg2),STK(arg1)); continue;}
 			OPCODE_TARGET(ADD) { _ARITH_(+,TARGET,STK(arg2),STK(arg1)); continue;}
 			OPCODE_TARGET(SUB) { _ARITH_(-,TARGET,STK(arg2),STK(arg1)); continue;}
 			OPCODE_TARGET(SUB) { _ARITH_(-,TARGET,STK(arg2),STK(arg1)); continue;}
 			OPCODE_TARGET(MUL) { _ARITH_(*,TARGET,STK(arg2),STK(arg1)); continue;}
 			OPCODE_TARGET(MUL) { _ARITH_(*,TARGET,STK(arg2),STK(arg1)); continue;}