From 1e4af96a0c4a3dbaf965cf4f69929dec1ae2395f Mon Sep 17 00:00:00 2001 From: dos-reis Date: Fri, 12 Dec 2008 20:11:49 +0000 Subject: r12453@gauss: gdr | 2008-12-12 09:39:28 -0600 Introduce Middle IL. --- src/interp/c-util.boot | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/interp/c-util.boot b/src/interp/c-util.boot index 32ef603c..17878a98 100644 --- a/src/interp/c-util.boot +++ b/src/interp/c-util.boot @@ -1240,6 +1240,57 @@ pushLocalVariable x == PUSH(x,$LocalVars) +--% +--% Middle Env to Back End Transformations. +--% + +--% e ::= +--% (%ilConst ) -- constant +--% (%ilInert ) -- inert form +--% (%ilCtx ) -- context +--% (%ilVar ) -- variable +--% (%ilLisp ) -- Lisp form +--% (%ilFun ) -- function object +--% (%ilMm ) -- modemap +--% (%ilLocal ) -- local function +--% (%ilCtor ) -- constructor +--% (%ilTag ) -- tag of union object +--% (%ilVal ) -- value of union object +--% (%ilCall ) -- a call +--% (%ilXLAM ) -- XLAM form +--% (%ilLAM ) -- LAMBDA form + +ilConstant(c,t) == ["%ilConst",c,t] +ilInert(e,t) == ["%ilInert",e,t] +ilVariable(n,t) == ["%ilVar",n,t] +ilContext(d,t) == ["%ilCtx",d,t] +ilLisp(e,t) == ["%ilLisp",e,t] +ilFun(e,t) == ["%ilFun",e,t] +ilModemap(e,t) == ["%ilMm",e,t] +ilLocal(n,t) == ["%ilLocal",n,t] +ilCall(op,args,t) == ["%ilCall",[op,:args],t] + +il2OldForm x == + atom x => x -- ideally should not happen + x is ["QUOTE",:.] => x -- idem. + case x of + %ilConst(c,.) => c + %ilInert(e,.) => e + %ilVar(n,.) => n + %ilCtx(e,.) => e + %ilLisp(e,.) => e + %ilMm(e,.) => e + %ilTag(e,.) => ["CAR",il2OldForm e] + %ilVal(e,.) => ["CAR",il2OldForm e] + otherwise => ilTransformInsns x + +ilTransformInsns form == + for insns in tails form repeat + rplac(first insns, il2OldForm first insns) + form + + +--% ++ Replace every middle end sub-forms in `x' with Lisp code. mutateToBackendCode: %Form -> %Void -- cgit v1.2.3