Browse Source

Hot Reload: fix new global not initialized (#725)

Yuxiao Mao 9 months ago
parent
commit
07ead74fc2
1 changed files with 10 additions and 6 deletions
  1. 10 6
      src/module.c

+ 10 - 6
src/module.c

@@ -896,12 +896,16 @@ h_bool hl_module_patch( hl_module *m1, hl_code *c ) {
 	hl_module_add(m2);
 
 	// call entry point (will only update types)
-	if( m2->functions_ptrs[c->entrypoint] ) {
-		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);
+	for(i=modules_count-1;i>=0;i--) {
+		hl_module *m = cur_modules[i];
+		if( m->functions_ptrs[m->code->entrypoint] ) {
+			vclosure cl;
+			cl.t = m->code->functions[m->functions_indexes[m->code->entrypoint]].type;
+			cl.fun = m->functions_ptrs[m->code->entrypoint];
+			cl.hasValue = 0;
+			hl_dyn_call(&cl,NULL,0);
+			break;
+		}
 	}
 
 	return true;