浏览代码

hot reload: call entry point again

Nicolas Cannasse 3 年之前
父节点
当前提交
015d788d47
共有 1 个文件被更改,包括 13 次插入0 次删除
  1. 13 0
      src/module.c

+ 13 - 0
src/module.c

@@ -464,6 +464,12 @@ static void hl_module_init_indexes( hl_module *m ) {
 			}
 		}
 	}
+
+	static hl_type_obj obj_entry = {0};
+	hl_function *fent = m->code->functions + m->functions_indexes[m->code->entrypoint];
+	obj_entry.name = USTR("");
+	fent->obj = &obj_entry;
+	fent->field.name = USTR("init");
 }
 
 static void hl_module_init_natives( hl_module *m ) {
@@ -819,6 +825,13 @@ h_bool hl_module_patch( hl_module *m1, hl_code *c ) {
 	}
 	hl_module_add(m2);
 
+	// call entry point (will only update types)
+	vclosure cl;
+	cl.t = c->functions[m2->functions_indexes[c->entrypoint]].type;
+	cl.fun = m2->functions_ptrs[c->entrypoint];
+	cl.hasValue = 0;
+	hl_dyn_call(&cl,NULL,0);
+
 	return true;
 }