summaryrefslogtreecommitdiff
path: root/MLKLexicalContext.m
diff options
context:
space:
mode:
Diffstat (limited to 'MLKLexicalContext.m')
-rw-r--r--MLKLexicalContext.m55
1 files changed, 34 insertions, 21 deletions
diff --git a/MLKLexicalContext.m b/MLKLexicalContext.m
index 3f820a8..d5c6add 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];
@@ -313,12 +326,12 @@ static MLKSymbol *LEXICAL;
-(id) deepPropertyForVariable:(id)name key:(id)key
{
- NSDictionary *props = [_variableInfo objectForKey:name];
+ NSDictionary *props = [_variableInfo objectForKey:nullify(name)];
id property;
if (props && (property = [props objectForKey:key]))
return property;
- else if (!_parent || [_variables containsObject:name])
+ else if (!_parent || [_variables containsObject:nullify(name)])
return nil;
else
return [_parent deepPropertyForVariable:name key:key];
@@ -332,13 +345,13 @@ static MLKSymbol *LEXICAL;
// lexically apparent binding, the property is set in the global
// context. This does not make it pervasive, however.
- if (!_parent || [_variables containsObject:name])
+ if (!_parent || [_variables containsObject:nullify(name)])
{
- NSMutableDictionary *props = [_variableInfo objectForKey:name];
+ NSMutableDictionary *props = [_variableInfo objectForKey:nullify(name)];
if (!props)
{
props = [NSMutableDictionary dictionary];
- [_variableInfo setObject:props forKey:name];
+ [_variableInfo setObject:props forKey:nullify(name)];
}
[props setObject:object forKey:key];
}
@@ -350,12 +363,12 @@ static MLKSymbol *LEXICAL;
-(id) deepPropertyForFunction:(id)name key:(id)key
{
- NSDictionary *props = [_functionInfo objectForKey:name];
+ NSDictionary *props = [_functionInfo objectForKey:nullify(name)];
id property;
if (props && (property = [props objectForKey:key]))
return property;
- else if (!_parent || [_functions containsObject:name])
+ else if (!_parent || [_functions containsObject:nullify(name)])
return nil;
else
return [_parent deepPropertyForFunction:name key:key];
@@ -365,13 +378,13 @@ static MLKSymbol *LEXICAL;
forFunction:(id)name
key:(id)key
{
- if (!_parent || [_functions containsObject:name])
+ if (!_parent || [_functions containsObject:nullify(name)])
{
- NSMutableDictionary *props = [_functionInfo objectForKey:name];
+ NSMutableDictionary *props = [_functionInfo objectForKey:nullify(name)];
if (!props)
{
props = [NSMutableDictionary dictionary];
- [_functionInfo setObject:props forKey:name];
+ [_functionInfo setObject:props forKey:nullify(name)];
}
[props setObject:object forKey:key];
}