blueloveTH 1 éve
szülő
commit
8bbb9fc5f3
3 módosított fájl, 7 hozzáadás és 3 törlés
  1. 3 1
      src/compiler/compiler.c
  2. 3 1
      src/public/values.c
  3. 1 1
      src2/main.c

+ 3 - 1
src/compiler/compiler.c

@@ -934,7 +934,9 @@ static void BinaryExpr__emit_(Expr* self_, Ctx* ctx) {
 
     Ctx__emit_(ctx, opcode, arg, self->line);
 
-    c11__foreach(int, &jmps, i) { Ctx__patch_jump(ctx, *i); }
+    for(int i = 0; i < jmps.count; i++) {
+        Ctx__patch_jump(ctx, c11__getitem(int, &jmps, i));
+    }
 }
 
 BinaryExpr* BinaryExpr__new(int line, TokenIndex op, bool inplace) {

+ 3 - 1
src/public/values.c

@@ -80,7 +80,9 @@ void py_newfunction2(py_Ref out,
                      const py_Ref upvalue) {}
 
 void py_newnativefunc(py_Ref out, py_CFunction f) {
-
+    out->type = tp_nativefunc;
+    out->is_ptr = false;
+    out->_cfunc = f;
 }
 
 void py_bindmethod(py_Type type, const char *name, py_CFunction f){

+ 1 - 1
src2/main.c

@@ -25,7 +25,7 @@ int main(int argc, char** argv) {
 #endif
 
     py_initialize();
-    const char* source = "[1, 'a']";
+    const char* source = "[1+2, 'a']";
 
     py_Ref r0 = py_reg(0);
     if(py_eval(source, r0)){