diff options
author | Matthias Andreas Benkard <matthias@benkard.de> | 2008-08-23 16:34:08 +0200 |
---|---|---|
committer | Matthias Andreas Benkard <matthias@benkard.de> | 2008-08-23 16:34:08 +0200 |
commit | ad05662ae05336aa5db20f9d34d5c1d5bba9d6c2 (patch) | |
tree | 14c0f6321acb8532a3a3d92a957404dfa1f66ee8 /MLKInterpreter.m | |
parent | 13dc1ca7ca1d785313517b9f8d78e63414cb43df (diff) |
Make compilers pluggable at runtime.
Diffstat (limited to 'MLKInterpreter.m')
-rw-r--r-- | MLKInterpreter.m | 58 |
1 files changed, 31 insertions, 27 deletions
diff --git a/MLKInterpreter.m b/MLKInterpreter.m index 0cdf904..7fd59ad 100644 --- a/MLKInterpreter.m +++ b/MLKInterpreter.m @@ -35,6 +35,7 @@ #import "MLKRoot.h" #import "MLKSymbol.h" #import "NSObject-MLKPrinting.h" +#import "globals.h" #import "runtime-compatibility.h" #import "special-symbols.h" #import "util.h" @@ -1230,34 +1231,37 @@ fprintf (stderr, "| "); fprintf (stderr, "LOAD: %s\n", [formdesc UTF8String]); -#ifdef USE_LLVM - expansion = code; - result = [MLKLLVMCompiler eval:code]; -#else // !USE_LLVM - expansion = denullify([[MLKInterpreter - eval:code - inLexicalContext:[MLKLexicalContext - globalContext] - withEnvironment:[MLKLexicalEnvironment - globalEnvironment] - mode:not_compile_time_mode] - objectAtIndex:0]); - - if ([code isKindOfClass:[MLKCons class]] && [code cdr]) - formdesc = [NSString stringWithFormat:@"(%@ %@ ...)", - MLKPrintToString([expansion car]), - MLKPrintToString([[expansion cdr] car])]; + if (MLKLoadCompilesP) + { + expansion = code; + result = [MLKDefaultCompiler eval:code]; + } else - formdesc = MLKPrintToString(expansion); - - //fprintf (stderr, "; LOAD: %s\n", [formdesc UTF8String]); - result = [MLKInterpreter - eval:expansion - inLexicalContext:[MLKLexicalContext globalContext] - withEnvironment:[MLKLexicalEnvironment globalEnvironment] - expandOnly:NO]; - //NSLog (@"; LOAD: Top-level form evaluated."); -#endif //!USE_LLVM + { + expansion = denullify([[MLKInterpreter + eval:code + inLexicalContext:[MLKLexicalContext + globalContext] + withEnvironment:[MLKLexicalEnvironment + globalEnvironment] + mode:not_compile_time_mode] + objectAtIndex:0]); + + if ([code isKindOfClass:[MLKCons class]] && [code cdr]) + formdesc = [NSString stringWithFormat:@"(%@ %@ ...)", + MLKPrintToString([expansion car]), + MLKPrintToString([[expansion cdr] car])]; + else + formdesc = MLKPrintToString(expansion); + + //fprintf (stderr, "; LOAD: %s\n", [formdesc UTF8String]); + result = [MLKInterpreter + eval:expansion + inLexicalContext:[MLKLexicalContext globalContext] + withEnvironment:[MLKLexicalEnvironment globalEnvironment] + expandOnly:NO]; + //NSLog (@"; LOAD: Top-level form evaluated."); + } LRELEASE (pool); |