diff options
author | Matthias Andreas Benkard <matthias@benkard.de> | 2008-09-02 18:45:47 +0200 |
---|---|---|
committer | Matthias Andreas Benkard <matthias@benkard.de> | 2008-09-02 18:45:47 +0200 |
commit | 8926f88cfb4085b27fc04ba926f85ca4f039f453 (patch) | |
tree | 6124f69f5ac53adfe1484f0b1404afdd719fca7d | |
parent | fbb077569838b79f9232cb0c50c5f8721e8a822a (diff) |
LLVM compiler: Support heap allocation for lambda lists.
-rw-r--r-- | MLKLLVMCompiler.mm | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/MLKLLVMCompiler.mm b/MLKLLVMCompiler.mm index bd64136..8f52b59 100644 --- a/MLKLLVMCompiler.mm +++ b/MLKLLVMCompiler.mm @@ -623,11 +623,9 @@ static Constant // Access the closure data array from within the closure. builder.SetInsertPoint (initBlock); - Value *local_closure_var = builder.CreateAlloca (PointerTy, NULL, "closure_variable"); Value *local_closure_value_ptr = builder.CreateGEP (closure_data_arg, position); - builder.CreateStore (local_closure_value_ptr, local_closure_var); - [_bodyContext locallySetBindingValue:local_closure_var + [_bodyContext locallySetBindingValue:local_closure_value_ptr forSymbol:symbol]; closure_data_size++; @@ -707,6 +705,20 @@ static Constant NULL), ap); + if ([_bodyContext variableHeapAllocationForSymbol:_lambdaListName]) + { + Value *mlkbinding = [_compiler insertClassLookup:@"MLKBinding"]; + Value *currentLambdaList = builder.CreateLoad (lambdaList); + std::vector<Value *> args (1, currentLambdaList); + Value *lambdaBinding = [_compiler insertMethodCall:@"bindingWithValue:" + onObject:mlkbinding + withArgumentVector:&args]; + [_bodyContext setBindingValue:lambdaBinding + forSymbol:_lambdaListName]; + } + else + [_bodyContext setValueValue:lambdaList forSymbol:_lambdaListName]; + NSEnumerator *e = [_bodyForms objectEnumerator]; MLKForm *form; Value *value = NULL; @@ -720,7 +732,6 @@ static Constant while ((form = [e nextObject])) { //NSLog (@"%LAMBDA: Processing subform."); - [form->_context setValueValue:lambdaList forSymbol:_lambdaListName]; value = [form processForLLVM]; } |