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
79
80
|
#ifndef _API_VM_H_
#define _API_VM_H_
#include <stddef.h>
#include <stdbool.h>
typedef enum
{
MODULE_PLAIN,
MODULE_NATIVE,
} UwUVMModuleType;
typedef enum
{
EX_UNINIT,
EX_INTLIT,
EX_STRLIT,
EX_ARGNUM,
EX_FNNAME,
EX_FNCALL,
} UwUVMExpressionType;
typedef struct
{
void *(*clone)(void *data);
void (*delet)(void *data);
char *(*print)(void *data);
} UwUVMType;
typedef struct
{
void *data;
UwUVMType *type;
} UwUVMValue;
typedef struct UwUVMArgs
{
size_t num;
UwUVMValue **evaluated;
struct UwUVMExpression *unevaluated;
struct UwUVMArgs *super;
} UwUVMArgs;
typedef UwUVMValue (*UwUVMNativeFunction)(UwUVMArgs *args);
typedef struct
{
UwUVMModuleType type;
union
{
struct UwUVMExpression *plain;
UwUVMNativeFunction native;
} value;
} UwUVMFunction;
typedef struct UwUVMExpression
{
UwUVMExpressionType type;
union
{
struct
{
UwUVMFunction *function;
struct UwUVMExpression *args;
size_t num_args;
} cll_value;
long int_value;
char *str_value;
UwUVMFunction *ref_value;
} value;
} UwUVMExpression;
UwUVMValue uwuvm_clone_value(UwUVMValue value);
void uwuvm_delet_value(UwUVMValue value);
char *uwuvm_print_value(UwUVMValue value);
UwUVMValue uwuvm_get_arg(UwUVMArgs *args, size_t i);
UwUVMValue uwuvm_evaluate_expression(UwUVMExpression *expression, UwUVMArgs *args);
UwUVMValue uwuvm_call_function(UwUVMFunction *function, size_t num_args, UwUVMExpression *unevaluated_args, UwUVMArgs *super_args);
#endif
|