-
Notifications
You must be signed in to change notification settings - Fork 0
/
MAS_dev.h
69 lines (52 loc) · 1.54 KB
/
MAS_dev.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
#ifndef _MAS_DEV_H_
#define _MAS_DEV_H_
#include "mas.h"
typedef struct MAS_Interpreter_tag MAS_Interpreter;
typedef struct MAS_String_tag MAS_String;
typedef struct MAS_Array_tag MAS_Array;
typedef struct MAS_Object_tag MAS_Object;
typedef struct LocalEnvironment_tag LocalEnvironment;
typedef enum {
MAS_FALSE = 0,
MAS_TRUE
} MAS_Boolean;
struct MAS_String_tag {
int ref_count;
char* string;
MAS_Boolean is_literal;
};
typedef struct {
char* name;
} MAS_NativePointerInfo;
typedef struct {
MAS_NativePointerInfo* info;
void* pointer;
} MAS_NativePointer;
typedef enum {
MAS_BOOLEAN_VALUE = 1,
MAS_INT_VALUE,
MAS_DOUBLE_VALUE,
MAS_STRING_VALUE,
MAS_NATIVE_POINTER_VALUE,
MAS_NULL_VALUE,
MAS_ARRAY_VALUE,
MAS_VALUE_TYPE_PLUS_1
} MAS_ValueType;
typedef struct {
MAS_ValueType type;
union {
MAS_Boolean boolean_value;
int int_value;
double double_value;
MAS_String* string_value; // deprecated
MAS_Object* object_value;
MAS_NativePointer native_pointer;
} u;
} MAS_Value;
//typedef MAS_Value (*MAS_NativeFunctionProc)(MAS_Interpreter* interp, int arg_count,
// MAS_Value* args);
typedef MAS_Value (*MAS_NativeFunctionProc)(MAS_Interpreter* interp, LocalEnvironment* env,
int arg_count, MAS_Value* args);
/* interface.c */
void MAS_add_native_function(char* name, MAS_NativeFunctionProc proc);
#endif /* MAS_DEV_H */