浏览代码

bugfixes in module init / bindings

Nicolas Cannasse 8 年之前
父节点
当前提交
d4ecc6ae8e
共有 2 个文件被更改,包括 11 次插入6 次删除
  1. 1 1
      src/module.c
  2. 10 5
      src/std/obj.c

+ 1 - 1
src/module.c

@@ -325,7 +325,7 @@ int hl_module_init( hl_module *m, void *stack_top_val ) {
 			}
 			break;
 		case HENUM:
-			hl_init_enum(t->tenum);
+			hl_init_enum(t);
 			t->tenum->global_value = ((int)(int_val)t->tenum->global_value) ? (void**)(int_val)(m->globals_data + m->globals_indexes[(int)(int_val)t->tenum->global_value-1]) : NULL;
 			break;
 		case HVIRTUAL:

+ 10 - 5
src/std/obj.c

@@ -179,12 +179,17 @@ HL_PRIM hl_runtime_obj *hl_get_obj_rt( hl_type *ot ) {
 		}
 		for(i=0;i<o->nbindings;i++) {
 			int j;
+			int fid = o->bindings[i<<1];
 			bool found = false;
-			for(j=0;j<p->nbindings;j++)
-				if( o->bindings[i<<1] == p->bindings[j].fid ) {
-					found = true;
-					break;
-				}
+			hl_type_obj *pp = p ? p->t->obj : NULL;
+			while( pp && !found ) {
+				for(j=0;j<pp->nbindings;j++)
+					if( pp->bindings[j<<1] == fid ) {
+						found = true;
+						break;
+					}
+				pp = pp->super ? pp->super->obj : NULL;
+			}
 			if( !found )
 				t->nbindings++;
 		}