From 876e8deb6e78457ef50e29db4db16f4fe4e09d33 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Sun, 16 May 2021 00:23:52 -0700 Subject: [PATCH] codegen fixes --- example.w | 4 +++- src/codegen.c | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/example.w b/example.w index 51b8942..1691b1c 100644 --- a/example.w +++ b/example.w @@ -54,6 +54,8 @@ struct Program myStruct.myInt = 4; } - return myStruct.myInt; + Console.PrintLine("%i", myStruct.myInt); + + return 0; } } diff --git a/src/codegen.c b/src/codegen.c index 87f9850..e7492fe 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -509,7 +509,7 @@ static LLVMValueRef CompileFunctionCallExpression( if (functionCallExpression->functionCallExpression.identifier->syntaxKind == AccessExpression) { LLVMTypeRef typeReference = FindStructType( - functionCallExpression->functionCallExpression.identifier->identifier.name + functionCallExpression->functionCallExpression.identifier->accessExpression.accessee->identifier.name ); if (typeReference != NULL) @@ -708,7 +708,7 @@ static LLVMBasicBlockRef CompileIfElseStatement(LLVMBuilderRef builder, LLVMValu for (i = 0; i < ifElseStatement->ifElseStatement.ifStatement->ifStatement.statementSequence->statementSequence.count; i += 1) { - CompileStatement(builder, function, ifElseStatement->ifStatement.statementSequence->statementSequence.sequence[i]); + CompileStatement(builder, function, ifElseStatement->ifElseStatement.ifStatement->ifStatement.statementSequence->statementSequence.sequence[i]); } LLVMBuildBr(builder, afterCond); @@ -900,13 +900,13 @@ static void CompileFunction( for (i = 0; i < functionSignature->functionSignature.arguments->functionSignatureArguments.count; i += 1) { - char *ptrName = strdup(functionSignature->functionSignature.arguments->functionSignatureArguments.sequence[i]->identifier.name); + char *ptrName = strdup(functionSignature->functionSignature.arguments->functionSignatureArguments.sequence[i]->declaration.identifier->identifier.name); strcat(ptrName, "_ptr"); LLVMValueRef argument = LLVMGetParam(function, i + !isStatic); LLVMValueRef argumentCopy = LLVMBuildAlloca(builder, LLVMTypeOf(argument), ptrName); LLVMBuildStore(builder, argument, argumentCopy); free(ptrName); - AddLocalVariable(scope, argumentCopy, NULL, functionSignature->functionSignature.arguments->functionSignatureArguments.sequence[i]->identifier.name); + AddLocalVariable(scope, argumentCopy, NULL, functionSignature->functionSignature.arguments->functionSignatureArguments.sequence[i]->declaration.identifier->identifier.name); } for (i = 0; i < functionBody->statementSequence.count; i += 1)