summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <matthias@benkard.de>2008-08-11 23:46:40 +0200
committerMatthias Andreas Benkard <matthias@benkard.de>2008-08-11 23:46:40 +0200
commit80a2cb47caaaac91384c72d49b8523b04e4c67e7 (patch)
tree212bd00841c2dfb5577a5a84f1a17ee61474e4c7
parent1bf467cd776bbbcb79ca11da2a2d94cf58753ba5 (diff)
Fix various errors in the compiler and semantic analyser.
-rw-r--r--MLKForm.m12
-rw-r--r--MLKLLVMCompiler.mm26
-rw-r--r--special-symbols.h4
3 files changed, 25 insertions, 17 deletions
diff --git a/MLKForm.m b/MLKForm.m
index 89ab36c..19b8dda 100644
--- a/MLKForm.m
+++ b/MLKForm.m
@@ -34,7 +34,7 @@
forCompiler:_compiler]
@implementation MLKForm
--(void) initialize
++(void) initialize
{
ensure_symbols ();
}
@@ -166,7 +166,11 @@
inContext:context
forCompiler:compiler];
- if ([_head isKindOfClass:[MLKCons class]])
+ if ([self class] != [MLKSimpleCompoundForm class])
+ {
+ return self;
+ }
+ else if ([_head isKindOfClass:[MLKCons class]])
{
LRELEASE (self);
return [MLKForm formWithObject:[MLKCons cons:FUNCALL
@@ -230,7 +234,7 @@
-(void) processBody:(id)object inContext:(MLKLexicalContext *)context
{
id rest;
- NSMutableArray *bodyForms;
+ NSMutableArray *bodyForms = [NSMutableArray array];
[self splitDeclarationsAndBody:object];
rest = _body;
@@ -877,8 +881,6 @@
-(id) complete
{
- MLKLexicalContext *newContext;
-
self = [super complete];
if ([_form isKindOfClass:[MLKCons class]])
diff --git a/MLKLLVMCompiler.mm b/MLKLLVMCompiler.mm
index 249ac39..6c1f0c3 100644
--- a/MLKLLVMCompiler.mm
+++ b/MLKLLVMCompiler.mm
@@ -55,7 +55,7 @@ static FunctionPassManager *fpm;
Value *v = NULL;
BasicBlock *block;
std::vector<const Type*> noargs (0, Type::VoidTy);
- FunctionType *function_type = FunctionType::get (PointerType::get (Type::VoidTy, 0),
+ FunctionType *function_type = FunctionType::get (PointerType::get (Type::Int8Ty, 0),
noargs,
false);
Function *function = Function::Create (function_type,
@@ -131,7 +131,7 @@ static FunctionPassManager *fpm;
Value *value;
if ([_bodyForms count] == 0)
- value = ConstantPointerNull::get (PointerType::get(Type::VoidTy, 0));
+ value = ConstantPointerNull::get (PointerType::get(Type::Int8Ty, 0));
while ((form = [e nextObject]))
{
@@ -218,8 +218,10 @@ static FunctionPassManager *fpm;
args.push_back ([form processForLLVM]);
}
- args.push_back (ConstantInt::get (PointerType::get (Type::VoidTy, 0),
- (uint64_t)MLKEndOfArgumentsMarker, false));
+ Value *endmarker = builder.CreateIntToPtr (ConstantInt::get(Type::Int64Ty,
+ (uint64_t)MLKEndOfArgumentsMarker,
+ false),
+ args.push_back (endmarker);
CallInst *call = builder.CreateCall (functionPtr,
args.begin(),
@@ -234,17 +236,14 @@ static FunctionPassManager *fpm;
@implementation MLKSimpleLambdaForm (MLKLLVMCompilation)
-(Value *) processForLLVM
{
- std::vector <const Type *> argtypes (1, PointerType::get(Type::VoidTy, 0));
- FunctionType *ftype = FunctionType::get (PointerType::get(Type::VoidTy, 0),
+ std::vector <const Type *> argtypes (1, PointerType::get(Type::Int8Ty, 0));
+ FunctionType *ftype = FunctionType::get (PointerType::get(Type::Int8Ty, 0),
argtypes,
true);
Function *function = Function::Create (ftype,
Function::ExternalLinkage,
"",
module);
- Value *endmarker = ConstantInt::get (PointerType::get (Type::VoidTy, 0),
- (uint64_t)MLKEndOfArgumentsMarker, false);
-
BasicBlock *initBlock = BasicBlock::Create ("init_function", function);
BasicBlock *loopBlock = BasicBlock::Create ("load_args");
BasicBlock *loopInitBlock = BasicBlock::Create ("load_args_init");
@@ -252,11 +251,16 @@ static FunctionPassManager *fpm;
builder.SetInsertPoint (initBlock);
+ Value *endmarker = builder.CreateIntToPtr (ConstantInt::get(Type::Int64Ty,
+ (uint64_t)MLKEndOfArgumentsMarker,
+ false),
+ PointerType::get(Type::Int8Ty, 0));
+
Value *ap = builder.CreateAlloca (Type::Int8Ty);
Value *nsmutablearray = [_compiler insertFindClass:@"NSMutableArray"];
Value *mlkcons = [_compiler insertFindClass:@"MLKCons"];
- Value *lambdaList = builder.CreateAlloca (PointerType::get (Type::VoidTy, 0));
+ Value *lambdaList = builder.CreateAlloca (PointerType::get (Type::Int8Ty, 0));
builder.CreateStore ([_compiler insertMethodCall:@"array"
onObject:nsmutablearray],
@@ -266,7 +270,7 @@ static FunctionPassManager *fpm;
builder.SetInsertPoint (loopInitBlock);
function->getBasicBlockList().push_back (loopInitBlock);
- Value *arg = builder.CreateVAArg (ap, PointerType::get(Type::VoidTy, 0));
+ Value *arg = builder.CreateVAArg (ap, PointerType::get(Type::Int8Ty, 0));
Value *cond = builder.CreateICmpEQ (arg, endmarker);
builder.CreateCondBr (cond, joinBlock, loopBlock);
builder.SetInsertPoint (loopBlock);
diff --git a/special-symbols.h b/special-symbols.h
index 2e80bf7..fa68ba7 100644
--- a/special-symbols.h
+++ b/special-symbols.h
@@ -19,7 +19,7 @@
#import "MLKSymbol.h"
#import "MLKPackage.h"
-static MLKPackage *cl;
+static MLKPackage *cl = nil;
static MLKPackage *sys;
static MLKPackage *keyword;
@@ -67,6 +67,8 @@ static MLKSymbol *MULTIPLE_VALUE_CALL;
static void
ensure_symbols ()
{
+ if (cl) return;
+
cl = [MLKPackage findPackage:@"COMMON-LISP"];
sys = [MLKPackage findPackage:@"TOILET-SYSTEM"];
keyword = [MLKPackage findPackage:@"KEYWORD"];