1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2025-02-09 04:30:37 +00:00

Continue with eval updates

This commit is contained in:
David Schmenk 2024-07-02 12:03:44 -07:00
parent 7e53d66c64
commit e5f1790da6

View File

@ -366,23 +366,36 @@ end
// Install default native functions
//
def eval_atom(atom)#2 // return type, val
var atomtype, atomval
when atom->type
is BOOL_FALSE
is BOOL_TRUE
is LIT_NUM
is VAR_NUM
is LIT_CHR
is VAR_CHR
is LIT_STR
is VAR_STR
is ARG_TYPE
wend
return atom->type, atomval
end
def natv_atom(expr)
return expr->type <> CONS_TYPE ?? @pred_true :: @pred_false
end
def natv_eq(expr)
var atom1, atom2, val1, val2
var type1, type2, val1, val2
atom1 = expr=>car=>prop
atom2 = expr=>cdr=>car=>prop
if atom1->type == LIT_NUM or atom1->type == VAR_NUM
val1 = atom1=>numval
type1, val1 = eval_atom(expr=>car=>prop)
type2, val2 = eval_atom(expr=>cdr=>car=>prop)
if type1 == type2
return val1 == val2 ?? @pred_true :: @pred_false
fin
if atom2->type == LIT_NUM or atom2->type == VAR_NUM
val2 = atom2=>numval
fin
return NULL
return @pred_false
end
def natv_cons(expr)