-
Notifications
You must be signed in to change notification settings - Fork 1
/
execution.h
64 lines (61 loc) · 2.15 KB
/
execution.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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "memory.h"
#include "objects.h"
#include "compile.h"
void execute(struct ByCodeObject *co, struct ByArena *arena)
{
int param1, param2;
while (co)
{
// printf("sdfvdf");
switch (co->opcode)
{
case Assign:
printf("Instruction: ");
strcpy(arena->name, co->next->data.char_value);
// ByObject *obj = (ByObject *)malloc(sizeof(ByObject));
// obj->type = Integer;
// obj->value.int_value = co->next->next->data.int_value;
// arena->object = obj;
// arena->next = NULL;
printf("Assign %d to %s\n", co->next->next->data.int_value,
co->next->data.char_value);
ByObject *obj = ByObject_Create(Integer, co->next->next->data);
printf("Integer object created at <%p>\n", obj);
co = co->next->next->next;
break;
case Assign_List:
{
printf("Instruction: ");
strcpy(arena->name, co->next->data.char_value);
// ByObject *obj = (ByObject *)malloc(sizeof(ByObject));
// obj->type = Integer;
// obj->value.int_value = co->next->next->data.int_value;
// arena->object = obj;
// arena->next = NULL;
printf("Assign %d to %s\n", co->next->next->data.int_value,
co->next->data.char_value);
struct ByObject_List *obj2 = ByObject_List_Create(
Integer,
co->next->next->data,
co->next->next->next->data,
co->next->next->next->next->data);
printf("Integer object created at <%p>\n", obj2);
co = co->next->next->next;
break;
}
case Load:
printf("");
ByObject *obj3 = get_object(arena, co->next->data.char_value);
printf("Instruction: Load %s\n", co->next->data.char_value);
printf("%d\n", obj3->value.int_value);
co = co->next->next;
break;
default:
printf("");
break;
}
}
}