diff options
Diffstat (limited to 'src/interp')
-rw-r--r-- | src/interp/compiler.boot | 35 | ||||
-rw-r--r-- | src/interp/spad.lisp | 20 |
2 files changed, 36 insertions, 19 deletions
diff --git a/src/interp/compiler.boot b/src/interp/compiler.boot index 5aa9e6cb..78a8145c 100644 --- a/src/interp/compiler.boot +++ b/src/interp/compiler.boot @@ -1874,6 +1874,41 @@ compMatch(["%Match",subject,altBlock],m,e) == code := ["LET",[[sn,se]],["COND",:nreverse altsCode]] [code,m,savedEnv] + +--% Entry point to the compiler + +preprocessParseTree pt == + $postStack := [] + pf := parseTransform postTransform pt + $postStack = nil => pf + displayPreCompilationErrors() + nil + +++ Takes a parse tree `pt', typecheck it and compile it down +++ to VM instructions. +compileParseTree pt == + pt = nil => nil + CURSTRM: local := $OutputStream + pf := preprocessParseTree pt + pf = nil => nil -- stop if preprocessing was a disaster. + -- Don't go further if only preprocessing was requested. + $PrintOnly => + FORMAT(true,'"~S =====>~%",$currentLine) + PRETTYPRINT pf + -- Now start actual compilation. + $x: local := nil -- ??? + $m: local := nil -- ??? + $s: local := nil -- ??? + $exitModeStack: local := [] -- Used by the compiler proper + -- We don't usually call the compiler to process interpreter + -- input, however attempt to second guess nevertheless. + if $InteractiveMode then + processInteractive(pf,nil) + else if T := compTopLevel(pf,$EmptyMode,$InteractiveFrame) then + [.,.,$InteractiveFrame] := T + TERPRI() + + --% Register compilers for special forms. -- Those compilers are on the `SPECIAL' property of the corresponding -- special form operator symbol. diff --git a/src/interp/spad.lisp b/src/interp/spad.lisp index 83283cfb..aefc8608 100644 --- a/src/interp/spad.lisp +++ b/src/interp/spad.lisp @@ -293,25 +293,7 @@ (|$genSDVar| 0) (|$VariableCount| 0) (|$previousTime| (TEMPUS-FUGIT))) - (prog ((CURSTRM |$OutputStream|) |$s| |$x| |$m| u) - (declare (special CURSTRM |$s| |$x| |$m|)) - (SETQ |$exitModeStack| ()) - (SETQ |$postStack| nil) - (SETQ |$TraceFlag| T) - (if (NOT X) (RETURN NIL)) - (setq X (|parseTransform| (|postTransform| X))) - ;; (if |$TranslateOnly| (RETURN (SETQ |$Translation| X))) - (when |$postStack| (|displayPreCompilationErrors|) (RETURN NIL)) - (COND (|$PrintOnly| - (format t "~S =====>~%" |$currentLine|) - (RETURN (PRETTYPRINT X)))) - (if |$InteractiveMode| - (|processInteractive| X NIL) - (if (setq U (|compTopLevel| X |$EmptyMode| - |$InteractiveFrame|)) - (SETQ |$InteractiveFrame| (third U)))) - (if |$semanticErrorStack| (|displaySemanticErrors|)) - (TERPRI)))) + (|compileParseTree| X))) (MAKEPROP 'END_UNIT 'KEY T) |