aboutsummaryrefslogtreecommitdiff
path: root/src/compiler/code_generator/code_generator.h
diff options
context:
space:
mode:
authorA404M <ahmadmahmoudiprogrammer@gmail.com>2024-09-22 19:34:43 +0330
committerA404M <ahmadmahmoudiprogrammer@gmail.com>2024-09-22 19:34:43 +0330
commitf79290084948f3cf140395c270c07cf29ca58e8d (patch)
treed716526678782153f3617bbf78984b4c4ebed380 /src/compiler/code_generator/code_generator.h
parentd2ab53c625d386a4fbc6a9d5a5eb29faab1b3f0c (diff)
Better errors
Added variables
Diffstat (limited to 'src/compiler/code_generator/code_generator.h')
-rw-r--r--src/compiler/code_generator/code_generator.h19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/compiler/code_generator/code_generator.h b/src/compiler/code_generator/code_generator.h
index da5b686..0f8b69d 100644
--- a/src/compiler/code_generator/code_generator.h
+++ b/src/compiler/code_generator/code_generator.h
@@ -2,10 +2,15 @@
#include <compiler/parser/parser.h>
+#include "compiler/tree_parser/tree_parser.h"
+#include "utils/types.h"
+
typedef enum Command {
COMMAND_NONE = 0,
COMMAND_CALL_FUNCTION,
COMMAND_PUSH_STRING,
+ COMMAND_PUSH_IDENTIFIER,
+ COMMAND_POP_IDENTIFIER,
} Command;
extern const char *COMMAND_STRINGS[];
@@ -20,21 +25,25 @@ typedef struct Instructions {
size_t size;
} Instructions;
+typedef SizedString CommandCallFunctionOperand;
+typedef SizedString CommandPushStringOperand;
+typedef SizedString CommandPushIdentifierOperand;
+typedef SizedString CommandPopIdentifierOperand;
+
extern void printInstruction(Instruction instruction);
extern void printInstructions(Instructions instructions);
extern void deleteInstruction(Instruction instruction);
extern void deleteInstructions(Instructions instructions);
-extern Instructions codeGenerator(ParsedNode *root);
+extern Instructions codeGenerator(SourceCode code);
+extern Instructions _codeGenerator(ParsedTree *root, SourceCode code);
-extern bool nodeToInstruction(ParsedNode *node, Instruction **instructions,
+extern bool nodeToInstruction(ParsedTree *tree, Instruction **instructions,
size_t *instructions_size,
- size_t *instructions_inserted);
+ size_t *instructions_inserted, SourceCode code);
extern void insertInstruction(const Instruction instruction,
Instruction **restrict instructions,
size_t *restrict instructions_size,
size_t *restrict instructions_inserted);
-
-extern SizedString *nodeToString(ParsedNode const *node);