diff options
-rw-r--r-- | MLKLLVMCompiler.mm | 2 | ||||
-rw-r--r-- | MLKLexicalContext.h | 1 | ||||
-rw-r--r-- | MLKLexicalContext.m | 35 | ||||
-rw-r--r-- | special-symbols.h | 8 |
4 files changed, 34 insertions, 12 deletions
diff --git a/MLKLLVMCompiler.mm b/MLKLLVMCompiler.mm index 2aaa0e8..75b8770 100644 --- a/MLKLLVMCompiler.mm +++ b/MLKLLVMCompiler.mm @@ -548,7 +548,7 @@ static Constant [MLKPrintToString(_head) UTF8String]); // XXX - if (NO && [_context functionInline:_head]) + if ([_context functionIsInline:_head]) { InlineFunction (call); } diff --git a/MLKLexicalContext.h b/MLKLexicalContext.h index e350b63..0702704 100644 --- a/MLKLexicalContext.h +++ b/MLKLexicalContext.h @@ -93,6 +93,7 @@ -(void) addFunction:(MLKSymbol *)symbol; -(BOOL) variableIsLexical:(MLKSymbol *)symbol; +-(BOOL) functionIsInline:(MLKSymbol *)symbol; -(id) deepPropertyForVariable:(id)name key:(id)key; -(void) setDeepProperty:(id)object diff --git a/MLKLexicalContext.m b/MLKLexicalContext.m index 3f820a8..a1bb8e8 100644 --- a/MLKLexicalContext.m +++ b/MLKLexicalContext.m @@ -35,6 +35,7 @@ #import "MLKSymbol.h" #import "MLKInteger.h" #import "runtime-compatibility.h" +#import "special-symbols.h" #import "util.h" #include <stdlib.h> @@ -51,18 +52,10 @@ static MLKLexicalContext *global_context; -static MLKPackage *cl; -static MLKPackage *sys; -static MLKSymbol *SPECIAL; -static MLKSymbol *LEXICAL; - - @implementation MLKLexicalContext +(void) initialize { MLKLexicalEnvironment *globalenv = [MLKLexicalEnvironment globalEnvironment]; - cl = [MLKPackage findPackage:@"COMMON-LISP"]; - sys = [MLKPackage findPackage:@"TOILET-SYSTEM"]; global_context = [[self alloc] initWithParent:nil variables:[globalenv variables] @@ -72,9 +65,8 @@ static MLKSymbol *LEXICAL; compilerMacros:nil symbolMacros:nil declarations:nil]; - - SPECIAL = [cl intern:@"SPECIAL"]; - LEXICAL = [sys intern:@"LEXICAL"]; + + ensure_symbols (); } -(MLKLexicalContext *) initWithParent:(MLKLexicalContext *)aContext @@ -299,6 +291,27 @@ static MLKSymbol *LEXICAL; else return (_parent && [_parent variableIsLexical:symbol]); } +-(BOOL) functionIsInline:(MLKSymbol *)symbol +{ + if ([_functions containsObject:symbol]) + { + id rest = _declarations; + while (rest) + { + id item = [rest car]; + if ([item isKindOfClass:[MLKCons class]] && [[item cdr] car] == symbol) + { + if ([item car] == INLINE) + return YES; + else if ([item car] == NOTINLINE) + return NO; + } + rest = [rest cdr]; + } + } + else return (_parent && [_parent functionIsInline:symbol]); +} + -(void) addVariable:(MLKSymbol *)symbol { symbol = symbol ? (id)symbol : (id)[NSNull null]; diff --git a/special-symbols.h b/special-symbols.h index d7e7351..806c758 100644 --- a/special-symbols.h +++ b/special-symbols.h @@ -58,6 +58,10 @@ static MLKSymbol *LOAD_TOPLEVEL; static MLKSymbol *LOAD; static MLKSymbol *EXECUTE; static MLKSymbol *MULTIPLE_VALUE_CALL; +static MLKSymbol *INLINE; +static MLKSymbol *NOTINLINE; +static MLKSymbol *SPECIAL; +static MLKSymbol *LEXICAL; static void @@ -99,6 +103,10 @@ ensure_symbols () _LAMBDA = [sys intern:@"%LAMBDA"]; V_INITP = [sys intern:@"*SYSTEM-INITIALISED-P*"]; MULTIPLE_VALUE_CALL = [cl intern:@"MULTIPLE-VALUE-CALL"]; + INLINE = [cl intern:@"INLINE"]; + NOTINLINE = [cl intern:@"NOTINLINE"]; + SPECIAL = [cl intern:@"INLINE"]; + LEXICAL = [sys intern:@"NOTINLINE"]; COMPILE_TOPLEVEL = [keyword intern:@"COMPILE-TOPLEVEL"]; COMPILE = [cl intern:@"COMPILE"]; |