Explorar el Código

more hot reload system

Nicolas Cannasse hace 6 años
padre
commit
bba3bcaf34
Se han modificado 4 ficheros con 7 adiciones y 2 borrados
  1. 1 1
      src/code.c
  2. 1 0
      src/hlmodule.h
  3. 1 0
      src/main.c
  4. 4 1
      src/module.c

+ 1 - 1
src/code.c

@@ -344,7 +344,7 @@ static void hl_read_function( hl_reader *r, hl_function *f ) {
 }
 
 #undef CHK_ERROR
-#define CHK_ERROR() if( r->error ) { if( c ) hl_free(&c->alloc); *error_msg = r->error; return NULL; }
+#define CHK_ERROR() if( r->error ) { if( c ) hl_free(&c->alloc); *error_msg = (char*)r->error; return NULL; }
 #define EXIT(msg) { ERROR(msg); CHK_ERROR(); }
 #define ALLOC(v,ptr,count) v = (ptr *)hl_zalloc(&c->alloc,count*sizeof(ptr))
 

+ 1 - 0
src/hlmodule.h

@@ -115,6 +115,7 @@ const char* hl_op_name( int op );
 
 hl_module *hl_module_alloc( hl_code *code );
 int hl_module_init( hl_module *m, bool hot_reload );
+void hl_module_patch( hl_module *m, hl_code *code );
 void hl_module_free( hl_module *m );
 bool hl_module_debug( hl_module *m, int port, bool wait );
 

+ 1 - 0
src/main.c

@@ -96,6 +96,7 @@ static bool check_reload( main_context *m ) {
 	hl_code *code = load_code(m->file, &error_msg, false);
 	if( code == NULL )
 		return false;
+	hl_module_patch(m, code);
 	m->file_time = time;
 	hl_code_free(code);
 	return true;

+ 4 - 1
src/module.c

@@ -320,7 +320,7 @@ static void disabled_primitive() {
 	hl_error("This library primitive has been disabled");
 }
 
-int hl_module_init( hl_module *m ) {
+int hl_module_init( hl_module *m, bool hot_reload ) {
 	int i;
 	jit_ctx *ctx;
 	// RESET globals
@@ -499,6 +499,9 @@ int hl_module_init( hl_module *m ) {
 	return 1;
 }
 
+void hl_module_patch( hl_module *m, hl_code *c ) {
+}
+
 void hl_module_free( hl_module *m ) {
 	hl_free(&m->ctx.alloc);
 	hl_free_executable_memory(m->code, m->codesize);