It was not computing the size of structs.
Bug: all bytecodes that had structs on the stack failed with internal
out-of-bounds errors.
Workaround: compiler will need to avoid putting structs on stack, or do so only
for FLEVEL == 0.96.2
... | ... |
@@ -222,6 +222,9 @@ int cli_bytecode_context_clear(struct cli_bc_ctx *ctx) |
222 | 222 |
|
223 | 223 |
static unsigned typesize(const struct cli_bc *bc, uint16_t type) |
224 | 224 |
{ |
225 |
+ struct cli_bc_type *ty; |
|
226 |
+ unsigned j; |
|
227 |
+ |
|
225 | 228 |
type &= 0x7fff; |
226 | 229 |
if (!type) |
227 | 230 |
return 0; |
... | ... |
@@ -233,7 +236,25 @@ static unsigned typesize(const struct cli_bc *bc, uint16_t type) |
233 | 233 |
return 4; |
234 | 234 |
if (type <= 64) |
235 | 235 |
return 8; |
236 |
- return bc->types[type-65].size; |
|
236 |
+ ty = &bc->types[type-65]; |
|
237 |
+ if (ty->size) |
|
238 |
+ return ty->size; |
|
239 |
+ switch (ty->kind) { |
|
240 |
+ case 2: |
|
241 |
+ case 3: |
|
242 |
+ for (j=0;j<ty->numElements;j++) |
|
243 |
+ ty->size += typesize(bc, ty->containedTypes[j]); |
|
244 |
+ break; |
|
245 |
+ case 4: |
|
246 |
+ ty->size = ty->numElements * typesize(bc, ty->containedTypes[0]); |
|
247 |
+ break; |
|
248 |
+ default: |
|
249 |
+ break; |
|
250 |
+ } |
|
251 |
+ if (!ty->size && ty->kind != DFunctionType) { |
|
252 |
+ cli_warnmsg("type %d size is 0\n", type-65); |
|
253 |
+ } |
|
254 |
+ return ty->size; |
|
237 | 255 |
} |
238 | 256 |
|
239 | 257 |
static unsigned typealign(const struct cli_bc *bc, uint16_t type) |