From 96870ab2cd94ba6e36585837b69048c544e6d6b6 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Sun, 17 Aug 2008 22:04:27 +0200 Subject: Promote special operators SET and %FSET to intrinsics. --- MLKInterpreter.m | 53 ----------------------------------------------------- 1 file changed, 53 deletions(-) (limited to 'MLKInterpreter.m') diff --git a/MLKInterpreter.m b/MLKInterpreter.m index 693c742..21adaea 100644 --- a/MLKInterpreter.m +++ b/MLKInterpreter.m @@ -1059,59 +1059,6 @@ else RETURN_VALUE (value); } - else if (car == SET) - { - id symbol = [[self eval:[[program cdr] car] - inLexicalContext:context - withEnvironment:lexenv - expandOnly:expandOnly] - objectAtIndex:0]; - id value = [[self eval:[[[program cdr] cdr] car] - inLexicalContext:context - withEnvironment:lexenv - expandOnly:expandOnly] - objectAtIndex:0]; - - if (expandOnly) - RETURN_VALUE ([MLKCons cons:SET - with:[MLKCons cons:symbol - with:[MLKCons cons:value - with:nil]]]); - - if ([dynamicContext bindingForSymbol:symbol]) - [dynamicContext setValue:value forSymbol:symbol]; - else - [[MLKDynamicContext globalContext] addValue:value - forSymbol:symbol]; - - return [NSArray arrayWithObject:symbol]; - } - else if (car == _FSET) - { - // Like SET, but for the function cell. - id symbol = [[self eval:[[program cdr] car] - inLexicalContext:context - withEnvironment:lexenv - expandOnly:expandOnly] - objectAtIndex:0]; - id value = [[self eval:[[[program cdr] cdr] car] - inLexicalContext:context - withEnvironment:lexenv - expandOnly:expandOnly] - objectAtIndex:0]; - - if (expandOnly) - RETURN_VALUE ([MLKCons cons:_FSET - with:[MLKCons cons:symbol - with:[MLKCons cons:value - with:nil]]]); - - [[MLKLexicalContext globalContext] addFunction:symbol]; - [[MLKLexicalEnvironment globalEnvironment] addFunction:value - forSymbol:symbol]; - - return [NSArray arrayWithObject:symbol]; - } else if (car == THROW) { id catchTag; -- cgit v1.2.3 From d86ccf58d5b462100d1f4ec5d016024543ec7f53 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Sun, 17 Aug 2008 22:43:25 +0200 Subject: Replace special operator %DEFMACRO with intrinsic function %MACROSET. --- MLKInterpreter.m | 40 ---------------------------------------- 1 file changed, 40 deletions(-) (limited to 'MLKInterpreter.m') diff --git a/MLKInterpreter.m b/MLKInterpreter.m index 21adaea..3f91814 100644 --- a/MLKInterpreter.m +++ b/MLKInterpreter.m @@ -289,46 +289,6 @@ return nil; } - else if (car == _DEFMACRO) - { - // No real lambda lists here. This SYS::%DEFMACRO is - // really as low-level as it gets. - id name = [[program cdr] car]; - id lambdaListAndBody = [[program cdr] cdr]; - - id function; - - if (expandOnly) - { - id lambdaList = [lambdaListAndBody car]; - id body = [lambdaListAndBody cdr]; - id body_expansion = - denullify([[self eval:[MLKCons cons:PROGN with:body] - inLexicalContext:context - withEnvironment:lexenv - expandOnly:expandOnly] - objectAtIndex:0]); - RETURN_VALUE ([MLKCons - cons:_DEFMACRO - with:[MLKCons - cons:name - with:[MLKCons - cons:lambdaList - with:[MLKCons - cons:body_expansion - with:nil]]]]); - } - - function = denullify([[self eval:[MLKCons cons:_LAMBDA with:lambdaListAndBody] - inLexicalContext:context - withEnvironment:lexenv - expandOnly:expandOnly] - objectAtIndex:0]); - - [context addMacro:function forSymbol:name]; - - RETURN_VALUE (name); - } else if (car == EVAL) { NSArray *evaluand = denullify([[self eval:[[program cdr] car] -- cgit v1.2.3 From a46dd37ba3832c9418c24d4b44f87d72df50585f Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Mon, 18 Aug 2008 01:00:01 +0200 Subject: LOAD: Always compile code when loading it. --- MLKInterpreter.m | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'MLKInterpreter.m') diff --git a/MLKInterpreter.m b/MLKInterpreter.m index 3f91814..540b9b5 100644 --- a/MLKInterpreter.m +++ b/MLKInterpreter.m @@ -29,6 +29,7 @@ #import "MLKInterpreter.h" #import "MLKLexicalContext.h" #import "MLKLexicalEnvironment.h" +#import "MLKLLVMCompiler.h" #import "MLKPackage.h" #import "MLKReader.h" #import "MLKRoot.h" @@ -1242,7 +1243,8 @@ if (code == eofValue) break; - if ([code isKindOfClass:[MLKCons class]] && [code cdr]) + if (MLKInstanceP(code) + && [code isKindOfClass:[MLKCons class]] && [code cdr]) formdesc = [NSString stringWithFormat:@"(%@ %@ ...)", MLKPrintToString([code car]), MLKPrintToString([[code cdr] car])]; @@ -1254,6 +1256,11 @@ for (i = 0; i < level; i++) 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 @@ -1277,6 +1284,7 @@ withEnvironment:[MLKLexicalEnvironment globalEnvironment] expandOnly:NO]; //NSLog (@"; LOAD: Top-level form evaluated."); +#endif //!USE_LLVM LRELEASE (pool); -- cgit v1.2.3 From bdfe4801295945b92f84b8c03cb2e0be485ae4f0 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Mon, 18 Aug 2008 01:19:06 +0200 Subject: Promote special operator APPLY to an intrinsic function. --- MLKInterpreter.m | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) (limited to 'MLKInterpreter.m') diff --git a/MLKInterpreter.m b/MLKInterpreter.m index 540b9b5..0cdf904 100644 --- a/MLKInterpreter.m +++ b/MLKInterpreter.m @@ -193,34 +193,7 @@ } } - if (car == APPLY) - { - MLKCons *rest = denullify([[self eval:[[[program cdr] cdr] car] - inLexicalContext:context - withEnvironment:lexenv - expandOnly:expandOnly] - objectAtIndex:0]); - - id function = denullify([[self eval:[[program cdr] car] - inLexicalContext:context - withEnvironment:lexenv - expandOnly:expandOnly] - objectAtIndex:0]); - - if (expandOnly) - RETURN_VALUE ([MLKCons cons:APPLY - with:[MLKCons cons:function - with:[MLKCons cons:rest - with:nil]]]); - - if ([function isKindOfClass:[MLKSymbol class]]) - function = [lexenv functionForSymbol:function]; - - return [function applyToArray:(rest - ? (id)[rest array] - : (id)[NSArray array])]; - } - else if (car == CATCH) + if (car == CATCH) { id catchTag; NSArray *values; -- cgit v1.2.3