-
Notifications
You must be signed in to change notification settings - Fork 0
/
Compiler.h
77 lines (58 loc) · 1.62 KB
/
Compiler.h
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
#pragma once
#include <limits.h>
#include <assert.h>
#include <stdlib.h>
#include <Windows.h>
#define AddImm 4093
#define SubImm 4094
#define MulImm 4095
#define DivImm 4096
#define AddVar 4097
#define SubVar 4098
#define MulVar 4099
#define DivVar 4100
#define PrintVar 8191
#define PrintVarLn 8192
#define PrintLn 8193
#define CreateVar 16383
#define AssignFromImmediate 16384
#define AssignFromVariable 16385
#define IfImmEql 24574
#define IfVarEql 24575
#define ForImm 24576
#define ForVar 24577
#define EndIf 24578
#define EndFor 24579
#define EndProgram 24580
typedef struct INSTRUCTION
{
short Operands[8];
}INSTRUCTION;
typedef struct INSTRUCTION_ARRAY
{
INSTRUCTION* Instructions;
size_t Length;
}INSTRUCTION_ARRAY;
typedef struct BYTE_ARRAY
{
BYTE* Array;
size_t Length;
}BYTE_ARRAY;
typedef struct ProgramTextData
{
BYTE* Text;
BYTE* Data;
}ProgramTextData;
BOOL ScopeStarter(short Instruction);
BOOL ScopeEnder(short Instruction);
//Returns size of variable to create
//returns zero if not an instruction to create a variable
char VariableCreator(short Instruction);
short OperandsInInstruction(short Instruction);
DWORD GetIdentifierRVA(INSTRUCTION_ARRAY* Program, size_t StartIndex, short Identifier);
INSTRUCTION_ARRAY ConvertProgram(short* Program, size_t ProgramLength);
void CreateDataSection(INSTRUCTION_ARRAY* Instructions, BYTE* Data);
void CreateTextSection(INSTRUCTION_ARRAY* Instructions, BYTE* Text);
ProgramTextData ParseProgram(short* Program, size_t ProgramLength);
DWORD DistToScopeEnd(INSTRUCTION_ARRAY* Program, size_t StartIndex);
DWORD DistToScopeStart(INSTRUCTION_ARRAY* Program, size_t StartIndex);