blueloveTH 3 anni fa
parent
commit
c329f83520
1 ha cambiato i file con 6 aggiunte e 13 eliminazioni
  1. 6 13
      src/vm.h

+ 6 - 13
src/vm.h

@@ -3,21 +3,15 @@
 #include "codeobject.h"
 #include "error.h"
 
-#define __DEF_PY_AS_C(type, ctype, ptype)                       \
+#define DEF_NATIVE(type, ctype, ptype)                          \
     inline ctype& Py##type##_AS_C(const PyVar& obj) {           \
-        check_type(obj, ptype);                                \
-        return OBJ_GET(ctype, obj);                           \
-    }
-
-#define __DEF_PY(type, ctype, ptype)                            \
+        check_type(obj, ptype);                                 \
+        return OBJ_GET(ctype, obj);                             \
+    }                                                           \
     inline PyVar Py##type(ctype value) {                        \
-        return new_object(ptype, value);                         \
+        return new_object(ptype, value);                        \
     }
 
-#define DEF_NATIVE(type, ctype, ptype)                          \
-    __DEF_PY(type, ctype, ptype)                                \
-    __DEF_PY_AS_C(type, ctype, ptype)
-
 
 class VM {
     std::stack< std::unique_ptr<Frame> > callstack;
@@ -55,8 +49,7 @@ class VM {
             } break;
             case OP_BUILD_INDEX_REF: {
                 PyVar index = frame->pop_value(this);
-                PyVarRef obj = frame->pop_value(this);
-                frame->push(PyRef(IndexRef(obj, index)));
+                frame->push(PyRef(IndexRef(frame->pop_value(this), index)));
             } break;
             case OP_STORE_REF: {
                 PyVar obj = frame->pop_value(this);