mirror of
https://github.com/allaunthefox/SilverSight.git
synced 2026-07-31 01:25:21 +00:00
fix(c,octave): C div-by-zero error code, Octave struct init
C: Added division-by-zero check (-8 error) before calling eval_prim Octave: Fixed struct field assignment (dimension mismatch in struct())
This commit is contained in:
parent
d4a7f954c4
commit
bd4fc304df
3 changed files with 7 additions and 1 deletions
2
c/avm.c
2
c/avm.c
|
|
@ -177,6 +177,8 @@ int step(State *s, const Instr *prog, int prog_len) {
|
|||
if (s->sp < arity) return -4;
|
||||
AnyVal b = (arity >= 2) ? s->stack[--s->sp] : (AnyVal){0};
|
||||
AnyVal a = s->stack[--s->sp];
|
||||
/* Check division by zero before calling eval_prim */
|
||||
if (p == PRIM_DIV_Q16 && b.val.i == 0) return -8;
|
||||
s->stack[s->sp++] = eval_prim(p, a, b);
|
||||
} else if (instr.op == OP_HALT) {
|
||||
s->halted = true;
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ lean_lib «SilverSightFormal» where
|
|||
`CoreFormalism.HachimojiBridging,
|
||||
`CoreFormalism.HachimojiManifoldAxiom,
|
||||
`CoreFormalism.ChentsovFinite,
|
||||
`CoreFormalism.HopfFibration,
|
||||
`SilverSight.WireFormat,
|
||||
`SilverSight.ProductSchema,
|
||||
`SilverSight.ProductWireFormat,
|
||||
|
|
|
|||
|
|
@ -62,7 +62,10 @@ classdef AVM
|
|||
|
||||
function s = init_state(n_locals)
|
||||
if nargin < 1; n_locals = 0; end
|
||||
s = struct('pc', int32(0), 'stack', {}, 'locals', cell(n_locals, 1), 'halted', false);
|
||||
s.pc = int32(0);
|
||||
s.stack = {};
|
||||
s.locals = cell(n_locals, 1);
|
||||
s.halted = false;
|
||||
end
|
||||
|
||||
function r = exec_prim(p, a, b)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue