Explorar o código

fix append_type HOBJ with inheritance (close #442)

Nicolas Cannasse %!s(int64=4) %!d(string=hai) anos
pai
achega
f33b3f8815
Modificáronse 1 ficheiros con 11 adicións e 3 borrados
  1. 11 3
      src/module.c

+ 11 - 3
src/module.c

@@ -267,6 +267,8 @@ static void null_function() {
 	hl_error("Null function ptr");
 }
 
+static void append_fields( char **p, hl_type *t );
+
 static void append_type( char **p, hl_type *t ) {
 	*(*p)++ = TYPE_STR[t->kind];
 	switch( t->kind ) {
@@ -287,9 +289,7 @@ static void append_type( char **p, hl_type *t ) {
 		*(*p)++ = 'S';
 	case HOBJ:
 		{
-			int i;
-			for(i=0;i<t->obj->nfields;i++)
-				append_type(p,t->obj->fields[i].t);
+			append_fields(p, t);
 			*(*p)++ = '_';
 		}
 		break;
@@ -302,6 +302,14 @@ static void append_type( char **p, hl_type *t ) {
 	}
 }
 
+static void append_fields( char **p, hl_type *t ) {
+	int i;
+	if( t->obj->super )
+		append_fields(p, t->obj->super);
+	for(i=0;i<t->obj->nfields;i++)
+		append_type(p,t->obj->fields[i].t);
+}
+
 #define DISABLED_LIB_PTR ((void*)(int_val)2)
 
 static void *resolve_library( const char *lib, bool is_opt ) {