From 0e1d7b240d69f6c332b27faeca503589139791ab Mon Sep 17 00:00:00 2001 From: dos-reis Date: Fri, 28 May 2010 19:37:58 +0000 Subject: More opcode expanders --- src/interp/g-util.boot | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/interp/g-util.boot b/src/interp/g-util.boot index 45b43dc8..18af0463 100644 --- a/src/interp/g-util.boot +++ b/src/interp/g-util.boot @@ -192,6 +192,13 @@ expandOr ["%or",:args] == ["OR",:expandToVMForm args] -- Arithmetic operations + +expandIabs ["%iabs",arg] == + ["ABS",expandToVMForm arg] + +expandIexp ["%iexp",:args] == + ["EXPT",:expandToVMForm args] + expandImul ["%imul",:args] == ["*",:expandToVMForm args] @@ -204,6 +211,15 @@ expandIsub ["%isub",:args] == expandIeq ["%ieq",:args] == ["EQL",:expandToVMForm args] +expandImin ["%imin",:args] == + ["MIN",:expandToVMForm args] + +expandImax ["%imax",:args] == + ["MAX",:expandToVMForm args] + +expandIgcd ["%igcd",:args] == + ["GCD",:expandToVMForm args] + -- Local variable bindings expandBind ["%bind",inits,body] == body := expandToVMForm body @@ -222,6 +238,15 @@ expandStore ["%store",place,value] == cons? place => ["SETF",place,value] ["SETQ",place,value] +-- List operators + +expandHead ["%head",x] == + ["CAR",expandToVMForm x] + +expandTail ["%tail",x] == + ["CDR",expandToVMForm x] + + ++ Table of opcode-expander pairs. for x in [ ["%not",:function expandNot], @@ -236,12 +261,20 @@ for x in [ ["%ge",:function expandGreaterEqual], ["%gt",:function expandGreater], + ["%iabs",:function expandIabs], ["%imul",:function expandImul], + ["%iexp",:function expandIexp], ["%iadd",:function expandIadd], ["%isub",:function expandIsub], + ["%imin",:function expandImin], + ["%imax",:function expandImax], + ["%igcd",:function expandIgcd], ["%ieq",:function expandIeq], + ["%head",:function expandHead], + ["%tail",:function expandTail], + ["%bind",:function expandBind], ["%store",:function expandStore], ["%dynval",:function expandDynval] -- cgit v1.2.3