-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkernel.h
101 lines (83 loc) · 1.72 KB
/
kernel.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
95
96
97
98
99
100
101
#ifndef KERNEL_H
#define KERNEL_H
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#define I32 int
#define U32 unsigned int
#define PTR uintptr_t
#define TRUE 1
#define FALSE 0
/*
* Types macro
*/
#define TYPE_SV 0
#define TYPE_AV 1
#define TYPE_HV 2
#define TYPE_UNDEF 3
typedef uintptr_t PTR;
/*
* Determines if V is SV, HV or AV
*/
typedef struct {
int type;
int ref_count;
// enum {TYPE_SV, TYPE_AV, TYPE_HV} type;
} HEAD;
/*
* The body of variable depends of type
*/
typedef union {
struct {
int iv; //int value
double nv; //double value
char* pv; //string value
int pv_len; //string length
PTR rv; //reference to variable
int type; //variable type int, double, string, ref
int ref_type; //type of referenced value if is reference
} sv;
struct {
PTR *entries; //table
int size; //size of table
int index; //current largest index
} av;
struct {
PTR *entries; //table
int size; //size of table
int index; //current largest index
int iter; //iterator
} hv;
} BODY;
/*
* Basic variable SV, AV, HV inherit from it
*/
typedef struct {
BODY* body;
HEAD* head;
} PerlVariable;
/*
* Types definitions
*/
typedef PerlVariable SV;
typedef PerlVariable AV;
typedef PerlVariable HV;
/*
* Hash key
*/
typedef struct {
char* hek_key;
U32 hek_hash;
I32 hek_len;
} HKEY;
/*
* Hash entry
*/
typedef struct {
HKEY* hent_next; /* next entry in chain */
HKEY* hent_hek; /* hash key */
PTR hent_val; /* scalar value that was hashed */
} HE;
HV *gv_symbol_table;
SV *g_undef;
#endif //KERNEL_H