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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
#pragma once
#include <fasm/lexer/lexer.h>
#include <stdint.h>
typedef struct FasmLinkedLine {
char const *begin;
char const *end;
FasmToken instruction;
uint8_t *operands;
size_t operands_size;
} FasmLinkedLine;
typedef struct FasmVariable {
char const *begin;
char const *end;
uint64_t value;
} FasmVariable;
typedef struct FasmLinkedLines {
FasmLinkedLine *lines;
size_t lines_size;
FasmVariable *variables;
size_t variables_size;
uint8_t *data;
size_t data_size;
} FasmLinkedLines;
extern void fasmVariablePrint(FasmVariable variable);
extern void fasmLinkedLinePrint(FasmLinkedLine line);
extern void fasmLinkedLinesPrint(FasmLinkedLines lines);
extern void fasmLinkedLineDeleteInner(FasmLinkedLine line);
extern void fasmLinkedLinesDeleteInner(FasmLinkedLines lines);
extern FasmLinkedLines fasmLinker(const FasmLines *lines,
SourceCode *sourceCode);
extern void fasmLinesSetVariables(FasmLinkedLines *linkedLines,
const FasmLines *lines,
SourceCode *sourceCode);
extern void fasmLinesSetLines(FasmLinkedLines *linkedLines,
const FasmLines *lines, SourceCode *sourceCode);
extern void fasmLinesSetData(FasmLinkedLines *linkedLines,
const FasmLines *lines, SourceCode *sourceCode);
extern FasmLinkedLine fasmLinesParseLine(FasmLinkedLines *linkedLines,
FasmLine line, SourceCode *sourceCode);
extern bool fasmLinkerOperandSizeCorrect(FasmToken token, int size);
extern size_t getSizeOfLine(const FasmLine line);
extern size_t getSizeOfLineOperands(const FasmLine line);
extern size_t getSizeOfLineOperandElementSize(const FasmLine line);
extern void fasmLinesPushVariable(FasmLinkedLines *linkedLines,
FasmVariable variable);
extern void fasmLinesPushLine(FasmLinkedLines *linkedLines,
FasmLinkedLine line);
extern void fasmLinesPushData(FasmLinkedLines *linkedLines, uint8_t *data,
size_t size);
extern FasmVariable fasmLinesGetVariable(const FasmLinkedLines *linkedLines,
char const *nameBegin,
char const *nameEnd);
extern bool isOperandString(FasmOperand operand);
extern uint64_t getOperandValue(FasmLinkedLines *linkedLines,
FasmOperand operand, SourceCode *sourceCode);
extern uint64_t strToInt(const char *begin, const char *end,
SourceCode *sourceCode);
extern uint64_t hexStrToInt(const char *begin, const char *end,
SourceCode *sourceCode);
extern uint64_t binStrToInt(const char *begin, const char *end,
SourceCode *sourceCode);
|