浏览代码

move op_names

blueloveTH 2 年之前
父节点
当前提交
a08efc0a6a
共有 3 个文件被更改,包括 7 次插入7 次删除
  1. 1 1
      amalgamate.py
  2. 0 6
      include/pocketpy/codeobject.h
  3. 6 0
      src/vm.cpp

+ 1 - 1
amalgamate.py

@@ -36,7 +36,7 @@ def remove_copied_include(text):
 			key = key[9:]
 			key = key[9:]
 		if key in ["user_config.h", "cJSONw.hpp"]:
 		if key in ["user_config.h", "cJSONw.hpp"]:
 			return m.group(0)
 			return m.group(0)
-		if key == "opcodes.h":
+		if "opcodes.h" in key:
 			return OPCODES_TEXT
 			return OPCODES_TEXT
 		assert key in copied, f"include {key} not found"
 		assert key in copied, f"include {key} not found"
 		return ""
 		return ""

+ 0 - 6
include/pocketpy/codeobject.h

@@ -13,12 +13,6 @@ enum Opcode: uint8_t {
     #undef OPCODE
     #undef OPCODE
 };
 };
 
 
-inline const char* OP_NAMES[] = {
-    #define OPCODE(name) #name,
-    #include "opcodes.h"
-    #undef OPCODE
-};
-
 struct Bytecode{
 struct Bytecode{
     uint8_t op;
     uint8_t op;
     uint16_t arg;
     uint16_t arg;

+ 6 - 0
src/vm.cpp

@@ -1,5 +1,11 @@
 #include "pocketpy/vm.h"
 #include "pocketpy/vm.h"
 
 
+static const char* OP_NAMES[] = {
+    #define OPCODE(name) #name,
+    #include "pocketpy/opcodes.h"
+    #undef OPCODE
+};
+
 namespace pkpy{
 namespace pkpy{
 
 
     struct JsonSerializer{
     struct JsonSerializer{