-
Notifications
You must be signed in to change notification settings - Fork 0
/
bcValue.h
95 lines (84 loc) · 1.48 KB
/
bcValue.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/**
* @file bcValue.h
*
* BadCode Value Structures.
*
*/
#pragma once
#ifndef DECI_SPACE_BADCODE_VALUE_HEADER
#define DECI_SPACE_BADCODE_VALUE_HEADER
/**
* Available data types to box
*/
typedef enum bcDataType_t
{
BC_NULL = 0, /**< Null object */
BC_INTEGER, /**< Int64 */
BC_NUMBER, /**< Float64 */
BC_STRING, /**< Character string */
BC_LIST, /**< Linear List */
BC_DICT, /**< Key-Value Storage */
BC_REF, /**< Reference */
BC_FUNC, /**< Interpretable function */
BC_NATIVE, /**< Native C-function */
BC_CODE, /**< Code block */
BC_DATA_TYPE_TOTAL
} bcDataType_t;
/**
* Abstract value type.
*/
typedef struct bcValue_t
{
bcDataType_t type; /**< Value type */
int32_t refCount; /**< reference counter */
} bcValue_t;
/**
* BC_INTEGER.
*/
typedef struct bcInteger_t
{
bcValue_t head;
int64_t data;
} bcInteger_t;
/**
* BC_NUMBER.
*/
typedef struct bcNumber_t
{
bcValue_t head;
double data;
} bcNumber_t;
/**
* BC_STRING.
*/
typedef struct bcString_t
{
bcValue_t head;
size_t len;
char data[];
} bcString_t;
/**
* BC_NATIVE.
*/
typedef struct bcNative_t
{
bcValue_t head;
void (*func)(BC_CORE);
} bcNative_t;
/**
* BC_REF.
*/
typedef struct bcRef_t
{
bcValue_t head;
BC_VALUE data;
} bcRef_t;
/**
* BC_DICT.
*/
typedef struct bcNameDict_t
{
char* name;
uint32_t index;
} bcNameDict_t;
#endif /* DECI_SPACE_BADCODE_VALUE_HEADER */