hyc

Hydrogen Compiler written in C
git clone git://git.kocotian.pl/hyc.git
Log | Files | Refs | README | LICENSE

commit bc1f2c5008a5a9d23ce941cd48cb82226bcfe6d4
parent 3e5cea0c0ea3c4f89a9de6cbe00a6a7a29785d66
Author: kocotian <kocotian@kocotian.pl>
Date:   Mon, 26 Jul 2021 19:20:21 +0000

Compiling functions call

Diffstat:
Mtarget/x86_64-linux.c | 11+++++++++++
1 file changed, 11 insertions(+), 0 deletions(-)

diff --git a/target/x86_64-linux.c b/target/x86_64-linux.c @@ -37,6 +37,7 @@ static void compileExpressionUnaryAddressof(Compiler *compiler, ASTExpressionUna static void compileExpressionUnaryValuefrom(Compiler *compiler, ASTExpressionUnary expr); static void compileExpressionUnaryPreincrement(Compiler *compiler, ASTExpressionUnary expr); static void compileExpressionUnaryPredecrement(Compiler *compiler, ASTExpressionUnary expr); +static void compileExpressionFunctionCall(Compiler *compiler, ASTExpressionFunctionCall expr); static void compileExpression(Compiler *compiler, union ASTExpression *expression); static void compileStatementCompound(Compiler *compiler, ASTStatementCompound stat); @@ -126,6 +127,13 @@ compileExpressionUnaryPredecrement(Compiler *compiler, ASTExpressionUnary expr) } static void +compileExpressionFunctionCall(Compiler *compiler, ASTExpressionFunctionCall expr) +{ + compileExpression(compiler, expr.callexpr); + asmTextAppend(compiler, "\tcall r15\n\tmov r15, rax"); +} + +static void compileExpression(Compiler *compiler, union ASTExpression *expression) { switch (expression->type) { @@ -156,6 +164,9 @@ compileExpression(Compiler *compiler, union ASTExpression *expression) case ASTExpressionUnaryPredecrement_T: compileExpressionUnaryPredecrement(compiler, expression->Unary); break; + case ASTExpressionFunctionCall_T: + compileExpressionFunctionCall(compiler, expression->FunctionCall); + break; default: break; } }