From d2f326bbc766af34a2d1e5f0be4252eab41b2cac Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Mon, 1 Sep 2008 23:57:03 +0200 Subject: MLKLexicalContext: Add -variableIsGlobal:. --- MLKLLVMCompiler.mm | 4 ++-- MLKLexicalContext-MLKLLVMCompilation.mm | 3 +-- MLKLexicalContext.h | 1 + MLKLexicalContext.m | 5 +++++ 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/MLKLLVMCompiler.mm b/MLKLLVMCompiler.mm index e0d53dd..75e444b 100644 --- a/MLKLLVMCompiler.mm +++ b/MLKLLVMCompiler.mm @@ -458,7 +458,7 @@ static Constant onObject:dynctx withArgumentVector:&args]; } - else if ([_context contextForVariable:_form] == [MLKLexicalContext globalContext]) + else if ([_context variableIsGlobal:_form]) { //[_compiler insertTrace:@"Global."]; Value *binding = builder.Insert ([_context globalBindingValueForSymbol:_form]); @@ -825,7 +825,7 @@ static Constant onObject:dynctx withArgumentVector:&args]; } - else if ([_context contextForVariable:variable] == [MLKLexicalContext globalContext]) + else if ([_context variableIsGlobal:variable]) { Value *binding = builder.Insert ([_context globalBindingValueForSymbol:variable]); std::vector args (1, value); diff --git a/MLKLexicalContext-MLKLLVMCompilation.mm b/MLKLexicalContext-MLKLLVMCompilation.mm index d3a84b3..e670151 100644 --- a/MLKLexicalContext-MLKLLVMCompilation.mm +++ b/MLKLexicalContext-MLKLLVMCompilation.mm @@ -50,8 +50,7 @@ id MLKDummyUseLLVMLexicalContext = nil; if (flag) return [flag boolValue]; else - return (![self contextForVariable:name] - || [self contextForVariable:name] == [MLKLexicalContext globalContext]); + return (![self contextForVariable:name] || [self variableIsGlobal:name]); } -(Instruction *) functionCellValueForSymbol:(id)name diff --git a/MLKLexicalContext.h b/MLKLexicalContext.h index 2368636..3e703e5 100644 --- a/MLKLexicalContext.h +++ b/MLKLexicalContext.h @@ -93,6 +93,7 @@ -(void) addFunction:(MLKSymbol *)symbol; -(BOOL) variableIsLexical:(MLKSymbol *)symbol; +-(BOOL) variableIsGlobal:(id)name; -(BOOL) functionIsInline:(MLKSymbol *)symbol; -(id) deepPropertyForVariable:(id)name key:(id)key; diff --git a/MLKLexicalContext.m b/MLKLexicalContext.m index dd0dc9c..5f694ff 100644 --- a/MLKLexicalContext.m +++ b/MLKLexicalContext.m @@ -291,6 +291,11 @@ static MLKLexicalContext *global_context; else return (_parent && [_parent variableIsLexical:symbol]); } +-(BOOL) variableIsGlobal:(id)name +{ + return [self contextForVariable:name] == [MLKLexicalContext globalContext]; +} + -(BOOL) functionIsInline:(MLKSymbol *)symbol { if ([_functions containsObject:symbol]) -- cgit v1.2.3