Browse Source

moved hl_init_enum to libhl

Nicolas Cannasse 8 năm trước cách đây
mục cha
commit
40db17adc7
3 tập tin đã thay đổi với 17 bổ sung16 xóa
  1. 1 0
      src/hl.h
  2. 0 16
      src/module.c
  3. 16 0
      src/std/types.c

+ 1 - 0
src/hl.h

@@ -319,6 +319,7 @@ HL_API int hl_stack_size( hl_type *t );
 
 
 HL_API hl_runtime_obj *hl_get_obj_rt( hl_type *ot );
 HL_API hl_runtime_obj *hl_get_obj_rt( hl_type *ot );
 HL_API hl_runtime_obj *hl_get_obj_proto( hl_type *ot );
 HL_API hl_runtime_obj *hl_get_obj_proto( hl_type *ot );
+HL_API void hl_init_enum( hl_type *et );
 
 
 /* -------------------- VALUES ------------------------------ */
 /* -------------------- VALUES ------------------------------ */
 
 

+ 0 - 16
src/module.c

@@ -127,22 +127,6 @@ static int module_capture_stack( void **stack, int size ) {
 	return count;
 	return count;
 }
 }
 
 
-static void hl_init_enum( hl_type_enum *e ) {
-	int i, j;
-	for(i=0;i<e->nconstructs;i++) {
-		hl_enum_construct *c = &e->constructs[i];
-		c->hasptr = false;
-		c->size = sizeof(int); // index
-		for(j=0;j<c->nparams;j++) {
-			hl_type *t = c->params[j];
-			c->size += hl_pad_size(c->size,t);
-			c->offsets[j] = c->size;
-			if( hl_is_ptr(t) ) c->hasptr = true;
-			c->size += hl_type_size(t);
-		}
-	}
-}
-
 static void hl_module_types_dump( void (*fdump)( void *, int) ) {
 static void hl_module_types_dump( void (*fdump)( void *, int) ) {
 	int ntypes = cur_module->code->ntypes;
 	int ntypes = cur_module->code->ntypes;
 	int i, fcount = 0;
 	int i, fcount = 0;

+ 16 - 0
src/std/types.c

@@ -292,6 +292,22 @@ HL_PRIM vbyte* hl_type_name( hl_type *t ) {
 	return NULL;
 	return NULL;
 }
 }
 
 
+HL_PRIM void hl_init_enum( hl_type *et ) {
+	int i, j;
+	for(i=0;i<et->tenum->nconstructs;i++) {
+		hl_enum_construct *c = et->tenum->constructs + i;
+		c->hasptr = false;
+		c->size = sizeof(int); // index
+		for(j=0;j<c->nparams;j++) {
+			hl_type *t = c->params[j];
+			c->size += hl_pad_size(c->size,t);
+			c->offsets[j] = c->size;
+			if( hl_is_ptr(t) ) c->hasptr = true;
+			c->size += hl_type_size(t);
+		}
+	}
+}
+
 HL_PRIM varray* hl_type_enum_fields( hl_type *t ) {
 HL_PRIM varray* hl_type_enum_fields( hl_type *t ) {
 	varray *a = hl_alloc_array(&hlt_bytes,t->tenum->nconstructs);
 	varray *a = hl_alloc_array(&hlt_bytes,t->tenum->nconstructs);
 	int i;
 	int i;