-
Notifications
You must be signed in to change notification settings - Fork 0
/
yun_symtable.h
73 lines (61 loc) · 1.35 KB
/
yun_symtable.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
/**
* pozen@yl:~>file 'yun_symtable.h'
* pozen@yl:~>brief 'symbol table'
* pozen@yl:~>date 'Oct 5, 2011'
* pozen@yl:~>author 'pozen'
*/
#ifndef __YUN_SYMTABLE_H_
#define __YUN_SYMTABLE_H_
//#include <stddef.h>
#include "yun_lex.h"
/* symbol type */
//typedef enum SymType { FUNC = 0, UINT, USHORT, UCHAR,\
ULONG, LONGLONG, ULONGLONG, CHAR, INT, SHORT, LONG, FLOAT, DOUBLE, STRING, CONST }SymType;
typedef enum SymType { FUNC = 0, NUMBER, CHAR, STRING, CONST }SymType;
/* symbol value */
typedef struct SymValue
{
union
{
int int_val;
//uint uint_val;
short short_val;
//ushort ushort_val;
char char_val;
//uchar uchar_val;
long long_val;
//ulong ulong_val;
long long ll_val;
//unsigned long long ull_val;
float float_val;
double double_val;
yl_number _number;
char *str_val;
struct /*for array*/
{
void *addr;
short unit_size;
short len;
};
};
}SymValue;
typedef struct Symbol
{
char *name; /*0 == const type*/
struct SymValue value;
SymType type;
unsigned int index;
int offset;
struct Symbol *addr;
struct Symbol *next;
void *func_info;
}Symbol;
#define SYMBOL_TABLE_LEN 257 /* hash */
typedef struct SymbolTable
{
size_t len;
Symbol *table[SYMBOL_TABLE_LEN];
}SymbolTable;
Symbol *sym_create_node( char *name, SymValue value, size_t type );
void sym_destroy_node( Symbol *node );
#endif /* YUN_SYMTABLE_H_ */