diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1994-11-23 12:32:00 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1994-11-23 12:32:00 -0200 |
commit | d490555ec9d5efb886211f735694d4e7dd0c166d (patch) | |
tree | f9b75cdc3a6d4132dddc884280ae218a7f9beb5c /tree.h | |
parent | ad0ec203f60df5e2f8a3b294c9e8c1014280b8f1 (diff) | |
download | lua-d490555ec9d5efb886211f735694d4e7dd0c166d.tar.gz lua-d490555ec9d5efb886211f735694d4e7dd0c166d.tar.bz2 lua-d490555ec9d5efb886211f735694d4e7dd0c166d.zip |
garbage collection tag for strings organized in struct TaggedString
Diffstat (limited to 'tree.h')
-rw-r--r-- | tree.h | 23 |
1 files changed, 11 insertions, 12 deletions
@@ -1,34 +1,33 @@ | |||
1 | /* | 1 | /* |
2 | ** tree.h | 2 | ** tree.h |
3 | ** TecCGraf - PUC-Rio | 3 | ** TecCGraf - PUC-Rio |
4 | ** $Id: tree.h,v 1.4 1994/11/17 13:58:57 roberto Exp roberto $ | 4 | ** $Id: tree.h,v 1.5 1994/11/18 19:27:38 roberto Exp roberto $ |
5 | */ | 5 | */ |
6 | 6 | ||
7 | #ifndef tree_h | 7 | #ifndef tree_h |
8 | #define tree_h | 8 | #define tree_h |
9 | 9 | ||
10 | #include "opcode.h" | ||
11 | 10 | ||
11 | #define NOT_USED 0xFFFE | ||
12 | 12 | ||
13 | #define UNMARKED_STRING 0xFFFF | ||
14 | #define MARKED_STRING 0xFFFE | ||
15 | #define MAX_WORD 0xFFFD | ||
16 | 13 | ||
14 | typedef struct TaggedString | ||
15 | { | ||
16 | char marked; /* for garbage collection */ | ||
17 | char str[1]; /* \0 byte already reserved */ | ||
18 | } TaggedString; | ||
17 | 19 | ||
18 | typedef struct TreeNode | 20 | typedef struct TreeNode |
19 | { | 21 | { |
20 | struct TreeNode *right; | 22 | struct TreeNode *right; |
21 | struct TreeNode *left; | 23 | struct TreeNode *left; |
22 | Word varindex; /* if this is a symbol */ | 24 | unsigned short varindex; /* != NOT_USED if this is a symbol */ |
23 | Word constindex; /* if this is a constant; also used for garbage collection */ | 25 | unsigned short constindex; /* != NOT_USED if this is a constant */ |
24 | char str[1]; /* \0 byte already reserved */ | 26 | TaggedString ts; |
25 | } TreeNode; | 27 | } TreeNode; |
26 | 28 | ||
27 | 29 | ||
28 | #define indexstring(s) (*(((Word *)s)-1)) | 30 | TaggedString *lua_createstring (char *str); |
29 | |||
30 | |||
31 | char *lua_createstring (char *str); | ||
32 | TreeNode *lua_constcreate (char *str); | 31 | TreeNode *lua_constcreate (char *str); |
33 | int lua_strcollector (void); | 32 | int lua_strcollector (void); |
34 | TreeNode *lua_varnext (char *n); | 33 | TreeNode *lua_varnext (char *n); |