aboutsummaryrefslogtreecommitdiff
path: root/src/compiler/fasm_generator/fasm_generator.h
blob: c6925ad9a222c2a78ee1d8c2f5ce504dfd71f8b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#pragma once

#include <compiler/tree_parser/tree_parser.h>
#include <fasm/lexer/lexer.h>
#include <stdint.h>

typedef struct FasmVariable {
  TreeDefineVariableMetadata const *variable;
  uint64_t value;
  bool isGlobal;
} FasmVariable;

typedef struct FasmVariables {
  FasmVariable *variables;
  size_t size;
} FasmVariables;

extern FasmLines generateFasm(SourceCode *code);
extern FasmLines generateFasmWithPrint(SourceCode *code);
extern FasmLines _generateFasm(const ParsedTree *root, SourceCode *code);

extern bool nodeToFasmLine(const ParsedTree *node, FasmLines *lines,
                           FasmVariables *variables[], size_t variables_size,
                           SourceCode *code);

extern void pushFasmLine(FasmLines *lines, FasmLine line);

extern size_t getSizeOfVariable(const TreeDefineVariableMetadata *variable);
extern FasmVariable getVariableFasmKeyValue(
    const TreeDefineVariableMetadata *variable, FasmVariables *variables[],
    size_t variables_size);