summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MLKDynamicContext.m28
-rw-r--r--MLKLexicalContext.m35
-rw-r--r--MLKLexicalEnvironment.m35
3 files changed, 15 insertions, 83 deletions
diff --git a/MLKDynamicContext.m b/MLKDynamicContext.m
index d4e1ab6..a2bc151 100644
--- a/MLKDynamicContext.m
+++ b/MLKDynamicContext.m
@@ -37,15 +37,11 @@
#define MAKE_ENVIRONMENT(variable, parent, parent_member) \
- (variable \
- ? (id) [[MLKEnvironment alloc] \
- initWithParent:(parent \
- ? (id) parent_member \
- : nil) \
- values:variable] \
- : (id) (parent \
- ? (id) RETAIN (parent_member) \
- : [[MLKEnvironment alloc] init]));
+ [[MLKEnvironment alloc] \
+ initWithParent:(parent \
+ ? (id) parent_member \
+ : nil) \
+ values:variable]
static MLKDynamicContext *global_context;
@@ -373,25 +369,11 @@ static MLKDynamicContext *global_context;
-(void) addValue:(id)value forSymbol:(MLKSymbol *)symbol
{
- if (_parent && _environment == _parent->_environment)
- _environment = [[MLKEnvironment alloc] initWithParent:_parent->_environment
- values:nil];
- else if (!_environment)
- _environment = [[MLKEnvironment alloc] initWithParent:nil
- values:nil];
-
[[self environment] addValue:value forSymbol:symbol];
}
-(void) addBindingForSymbol:(MLKSymbol *)symbol
{
- if (_parent && _environment == _parent->_environment)
- _environment = [[MLKEnvironment alloc] initWithParent:_parent->_environment
- values:nil];
- else if (!_environment)
- _environment = [[MLKEnvironment alloc] initWithParent:nil
- values:nil];
-
[[self environment] addBindingForSymbol:symbol];
}
diff --git a/MLKLexicalContext.m b/MLKLexicalContext.m
index 545c3c1..a4c0ba2 100644
--- a/MLKLexicalContext.m
+++ b/MLKLexicalContext.m
@@ -38,15 +38,11 @@
#define MAKE_ENVIRONMENT(variable, parent, parent_member) \
- (variable \
- ? (id) [[MLKEnvironment alloc] \
- initWithParent:(parent \
- ? (id) parent_member \
- : nil) \
- values:variable] \
- : (id) (parent \
- ? (id) RETAIN (parent_member) \
- : [[MLKEnvironment alloc] init]));
+ [[MLKEnvironment alloc] \
+ initWithParent:(parent \
+ ? (id) parent_member \
+ : nil) \
+ values:variable]
static MLKLexicalContext *global_context;
@@ -138,13 +134,6 @@ static MLKSymbol *LEXICAL;
-(void) addMacro:(id <MLKFuncallable>)value forSymbol:(MLKSymbol *)symbol
{
- if (_parent && _macros == _parent->_macros)
- _macros = [[MLKEnvironment alloc] initWithParent:_parent->_macros
- values:nil];
- else if (!_macros)
- _macros = [[MLKEnvironment alloc] initWithParent:nil
- values:nil];
-
[_knownMacros addObject:symbol];
[_macros addValue:value forSymbol:symbol];
}
@@ -161,13 +150,6 @@ static MLKSymbol *LEXICAL;
-(void) addCompilerMacro:(id <MLKFuncallable>)value forSymbol:(MLKSymbol *)symbol
{
- if (_parent && _compilerMacros == _parent->_compilerMacros)
- _compilerMacros = [[MLKEnvironment alloc] initWithParent:_parent->_compilerMacros
- values:nil];
- else if (!_compilerMacros)
- _compilerMacros = [[MLKEnvironment alloc] initWithParent:nil
- values:nil];
-
[_knownCompilerMacros addObject:symbol];
[_compilerMacros addValue:value forSymbol:symbol];
}
@@ -184,13 +166,6 @@ static MLKSymbol *LEXICAL;
-(void) addSymbolMacro:(id <MLKFuncallable>)value forSymbol:(MLKSymbol *)symbol
{
- if (_parent && _symbolMacros == _parent->_symbolMacros)
- _symbolMacros = [[MLKEnvironment alloc] initWithParent:_parent->_symbolMacros
- values:nil];
- else if (!_symbolMacros)
- _symbolMacros = [[MLKEnvironment alloc] initWithParent:nil
- values:nil];
-
[_knownSymbolMacros addObject:symbol];
[_symbolMacros addValue:value forSymbol:symbol];
}
diff --git a/MLKLexicalEnvironment.m b/MLKLexicalEnvironment.m
index 78a3b93..c460111 100644
--- a/MLKLexicalEnvironment.m
+++ b/MLKLexicalEnvironment.m
@@ -37,15 +37,11 @@
#define MAKE_ENVIRONMENT(variable, parent, parent_member) \
- (variable \
- ? (id) [[MLKEnvironment alloc] \
- initWithParent:(parent \
- ? (id) parent_member \
- : nil) \
- values:variable] \
- : (id) (parent \
- ? (id) RETAIN (parent_member) \
- : [[MLKEnvironment alloc] init]));
+ [[MLKEnvironment alloc] \
+ initWithParent:(parent \
+ ? (id) parent_member \
+ : nil) \
+ values:variable]
static MLKLexicalEnvironment *global_environment;
@@ -115,25 +111,11 @@ static MLKLexicalEnvironment *global_environment;
-(void) addValue:(id)value forSymbol:(MLKSymbol *)symbol
{
- if (_parent && _variables == _parent->_variables)
- _variables = [[MLKEnvironment alloc] initWithParent:_parent->_variables
- values:nil];
- else if (!_variables)
- _variables = [[MLKEnvironment alloc] initWithParent:nil
- values:nil];
-
[_variables addValue:value forSymbol:symbol];
}
-(void) addBindingForSymbol:(MLKSymbol *)symbol
{
- if (_parent && _variables == _parent->_variables)
- _variables = [[MLKEnvironment alloc] initWithParent:_parent->_variables
- values:nil];
- else if (!_variables)
- _variables = [[MLKEnvironment alloc] initWithParent:nil
- values:nil];
-
[_variables addBindingForSymbol:symbol];
}
@@ -159,13 +141,6 @@ static MLKLexicalEnvironment *global_environment;
-(void) addFunction:(id)value forSymbol:(MLKSymbol *)symbol
{
- if (_parent && _functions == _parent->_functions)
- _functions = [[MLKEnvironment alloc] initWithParent:_parent->_functions
- values:nil];
- else if (!_functions)
- _functions = [[MLKEnvironment alloc] initWithParent:nil
- values:nil];
-
[_functions addValue:value forSymbol:symbol];
}