blob: eb3fe1da74e4c418b8533d9091583df277cc29eb (
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#pragma once
#include "ast.h"
#include <stdbool.h>
#include <stdint.h>
#define VARIABLES_MAX 64
enum TypeKind
{
KIND_VOID,
KIND_INT32,
KIND_BYTE,
KIND_SIZE,
KIND_ARRAY,
KIND_CHAR,
KIND_CHAR_CONSTANT,
KIND_VALUE
};
struct Type
{
enum TypeKind kind;
int64_t number;
};
struct Variable
{
char name[NAME_LENGTH_MAX + 1];
int64_t value;
bool declared;
};
struct Machine
{
struct Variable variables[VARIABLES_MAX];
};
enum RunStatus
{
RUN_DONE,
RUN_FAILED
};
void machine_init(struct Machine* machine);
enum RunStatus execute(struct Machine* machine, const struct Node* statement);
|