aboutsummaryrefslogtreecommitdiff
path: root/lobject.h
diff options
context:
space:
mode:
Diffstat (limited to 'lobject.h')
-rw-r--r--lobject.h113
1 files changed, 55 insertions, 58 deletions
diff --git a/lobject.h b/lobject.h
index 710d4a6a..398155f2 100644
--- a/lobject.h
+++ b/lobject.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: $ 2** $Id: lobject.h,v 1.1 1997/09/16 19:25:59 roberto Exp roberto $
3** Type definitions for Lua objects 3** Type definitions for Lua objects
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -29,30 +29,43 @@ typedef unsigned short Word; /* unsigned 16 bits */
29typedef unsigned int IntPoint; /* unsigned with same size as a pointer (for hashing) */ 29typedef unsigned int IntPoint; /* unsigned with same size as a pointer (for hashing) */
30 30
31 31
32
33
34/* 32/*
35** String headers for string table 33** Lua TYPES
34** WARNING: if you change the order of this enumeration,
35** grep "ORDER LUA_T"
36*/ 36*/
37typedef enum {
38 LUA_T_NIL = -10,
39 LUA_T_NUMBER = -9,
40 LUA_T_STRING = -8,
41 LUA_T_ARRAY = -7, /* array==table */
42 LUA_T_PROTO = -6,
43 LUA_T_FUNCTION = -5,
44 LUA_T_CFUNCTION= -4,
45 LUA_T_MARK = -3,
46 LUA_T_CMARK = -2,
47 LUA_T_LINE = -1,
48 LUA_T_USERDATA = 0
49} lua_Type;
37 50
38#define NOT_USED 0xFFFE 51#define NUM_TYPES 11
52
53
54typedef union {
55 lua_CFunction f; /* LUA_T_CFUNCTION, LUA_T_CMARK */
56 real n; /* LUA_T_NUMBER */
57 struct TaggedString *ts; /* LUA_T_STRING, LUA_T_USERDATA */
58 struct TProtoFunc *tf; /* LUA_T_PROTO */
59 struct Closure *cl; /* LUA_T_FUNCTION, LUA_T_MARK */
60 struct Hash *a; /* LUA_T_ARRAY */
61 int i; /* LUA_T_LINE */
62} Value;
39 63
40typedef struct TaggedString { 64
41 int tag; /* if != LUA_T_STRING, this is a userdata */ 65typedef struct TObject {
42 union { 66 lua_Type ttype;
43 unsigned long hash; 67 Value value;
44 struct TaggedString *next; 68} TObject;
45 } uu;
46 union {
47 struct {
48 Word varindex; /* != NOT_USED if this is a symbol */
49 Word constindex; /* hint to reuse constant indexes */
50 } s;
51 void *v; /* if this is a userdata, here is its value */
52 } u;
53 int marked; /* for garbage collection; never collect (nor change) if > 1 */
54 char str[1]; /* \0 byte already reserved */
55} TaggedString;
56 69
57 70
58 71
@@ -66,6 +79,27 @@ typedef struct GCnode {
66 79
67 80
68/* 81/*
82** String headers for string table
83*/
84
85typedef struct TaggedString {
86 GCnode head;
87 int constindex; /* hint to reuse constants (= -1 if this is a userdata) */
88 unsigned long hash;
89 union {
90 TObject globalval;
91 struct {
92 void *v; /* if this is a userdata, here is its value */
93 int tag;
94 } d;
95 } u;
96 char str[1]; /* \0 byte already reserved */
97} TaggedString;
98
99
100
101
102/*
69** Function Prototypes 103** Function Prototypes
70*/ 104*/
71typedef struct TProtoFunc { 105typedef struct TProtoFunc {
@@ -87,43 +121,6 @@ typedef struct LocVar {
87 121
88 122
89 123
90/*
91** Lua TYPES
92** WARNING: if you change the order of this enumeration,
93** grep "ORDER LUA_T"
94*/
95typedef enum {
96 LUA_T_NIL = -10,
97 LUA_T_NUMBER = -9,
98 LUA_T_STRING = -8,
99 LUA_T_ARRAY = -7, /* array==table */
100 LUA_T_PROTO = -6,
101 LUA_T_FUNCTION = -5,
102 LUA_T_CFUNCTION= -4,
103 LUA_T_MARK = -3,
104 LUA_T_CMARK = -2,
105 LUA_T_LINE = -1,
106 LUA_T_USERDATA = 0
107} lua_Type;
108
109#define NUM_TYPES 11
110
111
112typedef union {
113 lua_CFunction f;
114 real n;
115 TaggedString *ts;
116 TProtoFunc *tf;
117 struct Closure *cl;
118 struct Hash *a;
119 int i;
120} Value;
121
122typedef struct TObject {
123 lua_Type ttype;
124 Value value;
125} TObject;
126
127 124
128/* Macros to access structure members */ 125/* Macros to access structure members */
129#define ttype(o) ((o)->ttype) 126#define ttype(o) ((o)->ttype)