summaryrefslogtreecommitdiff
path: root/MLKLexicalContext.m
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <matthias@benkard.de>2008-06-23 19:02:42 +0200
committerMatthias Andreas Benkard <matthias@benkard.de>2008-06-23 19:02:42 +0200
commit3aa255629a915314b71c04820833b683ff9234fc (patch)
treeef0ed440cadee353c3800cd8232ee483bf7508c0 /MLKLexicalContext.m
parent1c181e7b07ee551d6f76416972fe38ff411ffc40 (diff)
Initialise the global environment on startup.
Diffstat (limited to 'MLKLexicalContext.m')
-rw-r--r--MLKLexicalContext.m39
1 files changed, 27 insertions, 12 deletions
diff --git a/MLKLexicalContext.m b/MLKLexicalContext.m
index 2103989..82c7ae7 100644
--- a/MLKLexicalContext.m
+++ b/MLKLexicalContext.m
@@ -24,7 +24,9 @@
#import <Foundation/NSString.h>
#import "MLKCons.h"
+#import "MLKDynamicContext.h"
#import "MLKLexicalContext.h"
+#import "MLKLexicalEnvironment.h"
#import "MLKEnvironment.h"
#import "MLKLinkedList.h"
#import "MLKPackage.h"
@@ -57,9 +59,19 @@ static MLKSymbol *LEXICAL;
@implementation MLKLexicalContext
+(void) initialize
{
+ MLKDynamicContext *dynamic_context = [MLKDynamicContext globalContext];
+ MLKLexicalEnvironment *globalenv = [MLKLexicalEnvironment globalEnvironment];
cl = [MLKPackage findPackage:@"COMMON-LISP"];
sys = [MLKPackage findPackage:@"TOILET-SYSTEM"];
+ global_context = [[self alloc] initWithParent:nil
+ variables:[globalenv variables]
+ functions:[globalenv functions]
+ goTags:nil
+ macros:nil
+ symbolMacros:nil
+ declarations:nil];
+
SPECIAL = [cl intern:@"SPECIAL"];
LEXICAL = [sys intern:@"LEXICAL"];
}
@@ -76,26 +88,29 @@ static MLKSymbol *LEXICAL;
NSArray *e;
self = [super init];
- ASSIGN (_parent, (aContext ? aContext : [MLKLexicalContext globalContext]));
+ ASSIGN (_parent, (aContext ? aContext : [MLKLexicalContext globalContext]));
+
+ ASSIGN (_variableLocations, [NSMutableDictionary dictionary]);
e = [vars allObjects];
for (i = 0; i < [e count]; i++)
{
[self addVariable:[e objectAtIndex:i]];
}
+ ASSIGN (_functionLocations, [NSMutableDictionary dictionary]);
e = [functions allObjects];
for (i = 0; i < [e count]; i++)
{
- [self addVariable:[e objectAtIndex:i]];
+ [self addFunction:[e objectAtIndex:i]];
}
_goTags = MAKE_ENVIRONMENT (goTags, _parent, _parent->_goTags);
_macros = MAKE_ENVIRONMENT (macros, _parent, _parent->_macros);
_symbolMacros = MAKE_ENVIRONMENT (macros, _parent, _parent->_symbolMacros);
- _knownMacros = [macros allKeys];
- _knownSymbolMacros = [symbolMacros allKeys];
+ ASSIGN (_knownMacros, [macros allKeys]);
+ ASSIGN (_knownSymbolMacros, [symbolMacros allKeys]);
ASSIGN (_declarations, declarations);
return self;
@@ -197,15 +212,15 @@ static MLKSymbol *LEXICAL;
return YES;
}
+-(void) addVariable:(MLKSymbol *)symbol
+{
+ [_variableLocations setObject:[NSNull null] forKey:symbol];
+}
-
-// -(void) addVariable:(MLKSymbol *)symbol
-// {
-// }
-
-// -(void) addFunction:(MLKSymbol *)symbol
-// {
-// }
+-(void) addFunction:(MLKSymbol *)symbol
+{
+ [_functionLocations setObject:[NSNull null] forKey:symbol];
+}
-(void) dealloc
{