summaryrefslogtreecommitdiff
path: root/src/compiler/code-generator.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/code-generator.c')
-rw-r--r--src/compiler/code-generator.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/compiler/code-generator.c b/src/compiler/code-generator.c
index 27a0fdc..1969016 100644
--- a/src/compiler/code-generator.c
+++ b/src/compiler/code-generator.c
@@ -77,11 +77,18 @@ CodeGeneratorCodes *codeGenerator(AstTreeRoot *astTreeRoot) {
return NULL;
}
continue;
+ case AST_TREE_TOKEN_VALUE_U64: {
+ CodeGeneratorOperandU64 value = (AstTreeU64)variable->value->metadata;
+ generateCodePushCode(
+ codes, createGenerateCode(variable->name_begin, variable->name_end,
+ CODE_GENERATOR_INSTRUCTION_PRINT_U64,
+ (void *)value));
+ }
+ continue;
case AST_TREE_TOKEN_TYPE_TYPE:
case AST_TREE_TOKEN_TYPE_FUNCTION:
case AST_TREE_TOKEN_TYPE_VOID:
- case AST_TREE_TOKEN_VALUE_U64:
- case AST_TREE_TOKEN_CONSTANT:
+ case AST_TREE_TOKEN_VARIABLE:
case AST_TREE_TOKEN_KEYWORD_PRINT_U64:
case AST_TREE_TOKEN_FUNCTION_CALL:
case AST_TREE_TOKEN_TYPE_U64:
@@ -110,7 +117,7 @@ bool codeGeneratorAstTreeFunction(char *label_begin, char *label_end,
printLog("Not implemented");
exit(0);
}
- if (function->token != AST_TREE_TOKEN_CONSTANT) {
+ if (function->token != AST_TREE_TOKEN_VARIABLE) {
printLog("Not implemented");
exit(0);
}
@@ -132,7 +139,7 @@ bool codeGeneratorAstTreeFunction(char *label_begin, char *label_end,
codes, createGenerateCode(label_begin, label_end,
CODE_GENERATOR_INSTRUCTION_PRINT_U64,
(void *)value));
- } else if (metadata->token == AST_TREE_TOKEN_CONSTANT) {
+ } else if (metadata->token == AST_TREE_TOKEN_VARIABLE) {
AstTreeVariable *variable = metadata->metadata;
CodeGeneratorOperandU64 value = (AstTreeU64)variable->value->metadata;
generateCodePushCode(
@@ -146,7 +153,7 @@ bool codeGeneratorAstTreeFunction(char *label_begin, char *label_end,
}
goto OK;
case AST_TREE_TOKEN_VALUE_U64:
- case AST_TREE_TOKEN_CONSTANT:
+ case AST_TREE_TOKEN_VARIABLE:
case AST_TREE_TOKEN_FUNCTION:
case AST_TREE_TOKEN_TYPE_TYPE:
case AST_TREE_TOKEN_TYPE_FUNCTION:
@@ -168,8 +175,7 @@ bool codeGeneratorAstTreeFunction(char *label_begin, char *label_end,
return true;
}
-static const char TEMPLATE[] =
- "include 'stdlib/main.asm'\n";
+static const char TEMPLATE[] = "include 'stdlib/main.asm'\n";
static const size_t TEMPLATE_LEN =
sizeof(TEMPLATE) / sizeof(*TEMPLATE) - sizeof(*TEMPLATE);