Browse code

bytecode_vm: do a 2nd pass over types to update array sizes.

TODO: in the future the .cbc should include these sizes itself.

Török Edvin authored on 2010/10/18 16:38:50
Showing 1 changed files
... ...
@@ -779,6 +779,13 @@ static int parseTypes(struct cli_bc *bc, unsigned char *buffer)
779 779
 		return CL_EMALFDB;
780 780
 	}
781 781
     }
782
+    for (i=(BC_START_TID - 65);i<bc->num_types-1;i++) {
783
+	struct cli_bc_type *ty = &bc->types[i];
784
+	if (ty->kind == DArrayType) {
785
+	    ty->size = ty->numElements*typesize(bc, ty->containedTypes[0]);
786
+	    ty->align = typealign(bc, ty->containedTypes[0]);
787
+	}
788
+    }
782 789
     return CL_SUCCESS;
783 790
 }
784 791
 
... ...
@@ -1959,6 +1966,7 @@ static int cli_bytecode_prepare_interpreter(struct cli_bc *bc)
1959 1959
 	    uint16_t ty = bcfunc->types[j];
1960 1960
 	    unsigned align;
1961 1961
 	    align = typealign(bc, ty);
1962
+	    assert(typesize(bc, ty));
1962 1963
 	    assert(align);
1963 1964
 	    bcfunc->numBytes  = (bcfunc->numBytes + align-1)&(~(align-1));
1964 1965
 	    map[j] = bcfunc->numBytes;