소스 검색

support for global_value

Nicolas Cannasse 9 년 전
부모
커밋
e1f01bca3d
2개의 변경된 파일3개의 추가작업 그리고 0개의 파일을 삭제
  1. 2 0
      src/code.c
  2. 1 0
      src/module.c

+ 2 - 0
src/code.c

@@ -167,11 +167,13 @@ static void hl_read_type( hl_reader *r, hl_type *t ) {
 			int i;
 			const uchar *name = hl_get_ustring(r);
 			int super = INDEX();
+			int global = INDEX();
 			int nfields = UINDEX();
 			int nproto = UINDEX();
 			t->obj = (hl_type_obj*)hl_malloc(&r->code->alloc,sizeof(hl_type_obj));
 			t->obj->name = name;
 			t->obj->super = super < 0 ? NULL : r->code->types + super;
+			t->obj->global_value = (void**)(int_val)global;
 			t->obj->nfields = nfields;
 			t->obj->nproto = nproto;
 			t->obj->fields = (hl_obj_field*)hl_malloc(&r->code->alloc,sizeof(hl_obj_field)*nfields);

+ 1 - 0
src/module.c

@@ -184,6 +184,7 @@ int hl_module_init( hl_module *m ) {
 		switch( t->kind ) {
 		case HOBJ:
 			t->obj->m = &m->ctx;
+			t->obj->global_value = ((int)t->obj->global_value) < 0 ? NULL : m->globals_data + m->globals_indexes[(int)t->obj->global_value];
 			break;
 		case HENUM:
 			hl_init_enum(t->tenum);