1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2024-11-03 05:04:33 +00:00

Fix setting index value association

This commit is contained in:
David Schmenk 2024-07-28 12:53:06 -07:00
parent 2f9bd7d26c
commit ccc13a0a6f
3 changed files with 12 additions and 10 deletions

Binary file not shown.

View File

@ -1,14 +1,14 @@
(DEFINE
(TAILLOOP (LAMBDA (I M)
(COND ((AND (< I M) (PRIN I)),(TAILLOOP (+ 1 I) M))
(T,I))
(T,(- I 1)))
))
(PROGLOOP (LAMBDA (I M)
(PROG ()
A (PRIN I)
(SETQ I (+ I 1))
(IF (< I M) (GO A))
(RETURN I)
(RETURN (- I 1))
)))
(FORLOOP (LAMBDA (I M)
(FOR I I 1 (< I M) (PRIN I))

View File

@ -1237,11 +1237,11 @@ def natv_trace(symptr, expr)
end
def natv_for(symptr, expr)
var idxsym, idxint, ufunc, dlist
word[2] stepval
var index, ufunc, dlist
word[2] idxval, stepval
idxsym = expr=>car
if idxsym->type & TYPE_MASK <> SYM_TYPE
index = expr=>car
if index->type & TYPE_MASK <> SYM_TYPE
puts("For index not symbol\n")
return NULL
fin
@ -1252,8 +1252,9 @@ def natv_for(symptr, expr)
puts("FOR initial not integer\n")
return NULL
fin
set_assoc(idxsym, new_int(symptr=>intval[0], symptr=>intval[1]))
idxint = eval_expr(idxsym)
idxval[0] = symptr=>intval[0]
idxval[1] = symptr=>intval[1]
set_assoc(index, symptr)
symptr = eval_expr(expr=>car)
expr = expr=>cdr
if symptr->type <> NUM_INT
@ -1277,9 +1278,10 @@ def natv_for(symptr, expr)
sweep_stack[sweep_stack_top - 1] = eval_expr(expr=>car)
expr = expr=>cdr
loop
load32(idxint + intval) // Manipulate integer value directly!
load32(@idxval) // Update index value
add32(@stepval)
store32(idxint + intval)
store32(@idxval)
set_assoc(index, new_int(idxval[0], idxval[1]))
loop
return pop_sweep_stack
end