ArchWizard

DGD/

source navigation ]
diff markup ]
identifier search ]
file search ]
Version: [ 1.0.a0 ] [ 1.1 ] [ 1.2 ] [ 1.2p1 ] [ 1.2p2 ] [ 1.2p3 ] [ 1.2p4 ] [ 1.2.151 ]

  1 # define I_INSTR_MASK           0x1f    /* instruction mask */
  2 
  3 # define I_PUSH_ZERO             0
  4 # define I_PUSH_ONE              1
  5 # define I_PUSH_INT1             2      /* 1 signed */
  6 # define I_PUSH_INT4             3      /* 4 signed */
  7 # define I_PUSH_FLOAT            4      /* 6 unsigned */
  8 # define I_PUSH_STRING           5      /* 1 unsigned */
  9 # define I_PUSH_NEAR_STRING      6      /* 1 unsigned, 1 unsigned */
 10 # define I_PUSH_FAR_STRING       7      /* 1 unsigned, 2 unsigned */
 11 # define I_PUSH_LOCAL            8      /* 1 signed */
 12 # define I_PUSH_GLOBAL           9      /* 1 unsigned */
 13 # define I_PUSH_FAR_GLOBAL      10      /* 1 unsigned, 1 unsigned */
 14 # define I_PUSH_LOCAL_LVAL      11      /* 1 signed */
 15 # define I_PUSH_GLOBAL_LVAL     12      /* 1 unsigned */
 16 # define I_PUSH_FAR_GLOBAL_LVAL 13      /* 1 unsigned, 1 unsigned */
 17 # define I_INDEX                14
 18 # define I_INDEX_LVAL           15
 19 # define I_AGGREGATE            16      /* 1 unsigned, 2 unsigned */
 20 # define I_SPREAD               17      /* 1 signed */
 21 # define I_CAST                 18      /* 1 unsigned */
 22 # define I_FETCH                19
 23 # define I_STORE                20
 24 # define I_JUMP                 21      /* 2 unsigned */
 25 # define I_JUMP_ZERO            22      /* 2 unsigned */
 26 # define I_JUMP_NONZERO         23      /* 2 unsigned */
 27 # define I_SWITCH               24      /* n */
 28 # define I_CALL_KFUNC           25      /* 1 unsigned (+ 1 unsigned) */
 29 # define I_CALL_AFUNC           26      /* 1 unsigned, 1 unsigned */
 30 # define I_CALL_DFUNC           27      /* 1 unsigned, 1 unsigned, 1 unsigned */
 31 # define I_CALL_FUNC            28      /* 2 unsigned, 1 unsigned */
 32 # define I_CATCH                29      /* 2 unsigned */
 33 # define I_RLIMITS              30
 34 # define I_RETURN               31
 35 
 36 # define I_LINE_MASK            0xc0    /* line add bits */
 37 # define I_POP_BIT              0x20    /* pop 1 after instruction */
 38 # define I_TYPE_BIT             I_POP_BIT /* lvalue typechecks assignment */
 39 # define I_LINE_SHIFT           6
 40 
 41 
 42 # define FETCH1S(pc)    SCHAR(*(pc)++)
 43 # define FETCH1U(pc)    UCHAR(*(pc)++)
 44 # define FETCH2S(pc, v) ((short) (v = *(pc)++ << 8, v |= UCHAR(*(pc)++)))
 45 # define FETCH2U(pc, v) ((unsigned short) (v = *(pc)++ << 8, \
 46                                            v |= UCHAR(*(pc)++)))
 47 # define FETCH3S(pc, v) ((Int) (v = *(pc)++ << 8, \
 48                                 v |= UCHAR(*(pc)++), v <<= 8, \
 49                                 v |= UCHAR(*(pc)++)))
 50 # define FETCH3U(pc, v) ((Uint) (v = UCHAR(*(pc)++) << 8, \
 51                                  v |= UCHAR(*(pc)++), v <<= 8, \
 52                                  v |= UCHAR(*(pc)++)))
 53 # define FETCH4S(pc, v) ((Int) (v = *(pc)++ << 8, \
 54                                 v |= UCHAR(*(pc)++), v <<= 8, \
 55                                 v |= UCHAR(*(pc)++), v <<= 8, \
 56                                 v |= UCHAR(*(pc)++)))
 57 # define FETCH4U(pc, v) ((Uint) (v = *(pc)++ << 8, \
 58                                  v |= UCHAR(*(pc)++), v <<= 8, \
 59                                  v |= UCHAR(*(pc)++), v <<= 8, \
 60                                  v |= UCHAR(*(pc)++)))
 61 
 62 
 63 # define T_TYPE         0x0f    /* type mask */
 64 # define T_NIL          0x00
 65 # define T_INT          0x01
 66 # define T_FLOAT        0x02
 67 # define T_STRING       0x03
 68 # define T_OBJECT       0x04
 69 # define T_ARRAY        0x05    /* value type only */
 70 # define T_MAPPING      0x06
 71 # define T_RESERVED     0x07    /* reserved for add-on packages */
 72 # define T_MIXED        0x08    /* declaration type only */
 73 # define T_VOID         0x09    /* function return type only */
 74 # define T_LVALUE       0x0a    /* address of a value */
 75 # define T_SLVALUE      0x0b    /* indexed string lvalue */
 76 # define T_ALVALUE      0x0c    /* indexed array lvalue */
 77 # define T_MLVALUE      0x0d    /* indexed mapping lvalue */
 78 # define T_SALVALUE     0x0e    /* indexed string indexed array lvalue */
 79 # define T_SMLVALUE     0x0f    /* indexed string indexed mapping lvalue */
 80 
 81 # define T_VARARGS      0x10    /* or'ed with declaration type */
 82 # define T_ELLIPSIS     0x10    /* or'ed with declaration type */
 83 
 84 # define T_REF          0xe0    /* reference count mask */
 85 # define REFSHIFT       5
 86 
 87 # define T_ARITHMETIC(t) ((t) <= T_FLOAT)
 88 # define T_ARITHSTR(t)  ((t) <= T_STRING)
 89 # define T_POINTER(t)   ((t) >= T_STRING)
 90 # define T_INDEXED(t)   ((t) >= T_ARRAY)        /* only T_ARRAY and T_MAPPING */
 91 
 92 # define TYPENAMES      { "nil", "int", "float", "string", "object", \
 93                           "array", "mapping", "reserved", "mixed", "void" }
 94 
 95 struct _value_ {
 96     char type;                  /* value type */
 97     bool modified;              /* dirty bit */
 98     uindex oindex;              /* index in object table */
 99     union {
100         Int number;             /* number */
101         Uint objcnt;            /* object creation count */
102         string *string;         /* string */
103         array *array;           /* array or mapping */
104         value *lval;            /* lvalue: variable */
105     } u;
106 };
107 
108 # define VAL_NIL(v)     ((v)->type == nil_type && (v)->u.number == 0)
109 # define VAL_TRUE(v)    ((v)->u.number != 0 || (v)->type > T_FLOAT ||   \
110                          ((v)->type == T_FLOAT && (v)->oindex != 0))
111 
112 # define PUSH_INTVAL(f, i)      ((--(f)->sp)->u.number = (i),           \
113                                  (f)->sp->type = T_INT)
114 # define PUT_INTVAL(v, i)       ((v)->u.number = (i), (v)->type = T_INT)
115 # define PUT_INT(v, i)          ((v)->u.number = (i))
116 # define PUSH_FLTVAL(f, fl)     ((--(f)->sp)->oindex = (fl).high,       \
117                                  (f)->sp->u.objcnt = (fl).low,          \
118                                  (f)->sp->type = T_FLOAT)
119 # define PUSH_FLTCONST(f, h, l) ((--(f)->sp)->oindex = (h),             \
120                                  (f)->sp->u.objcnt = (l),               \
121                                  (f)->sp->type = T_FLOAT)
122 # define PUT_FLTVAL(v, fl)      ((v)->oindex = (fl).high,               \
123                                  (v)->u.objcnt = (fl).low,              \
124                                  (v)->type = T_FLOAT)
125 # define PUT_FLT(v, fl)         ((v)->oindex = (fl).high,               \
126                                  (v)->u.objcnt = (fl).low)
127 # define GET_FLT(v, fl)         ((fl).high = (v)->oindex,               \
128                                  (fl).low = (v)->u.objcnt)
129 # define PUSH_STRVAL(f, s)      (str_ref((--(f)->sp)->u.string = (s)),  \
130                                  (f)->sp->type = T_STRING)
131 # define PUT_STRVAL(v, s)       (str_ref((v)->u.string = (s)),          \
132                                  (v)->type = T_STRING)
133 # define PUT_STRVAL_NOREF(v, s) ((v)->u.string = (s), (v)->type = T_STRING)
134 # define PUT_STR(v, s)          (str_ref((v)->u.string = (s)))
135 # define PUSH_OBJVAL(f, o)      ((--(f)->sp)->oindex = (o)->index,      \
136                                  (f)->sp->u.objcnt = (o)->count,        \
137                                  (f)->sp->type = T_OBJECT)
138 # define PUT_OBJVAL(v, o)       ((v)->oindex = (o)->index,              \
139                                  (v)->u.objcnt = (o)->count,            \
140                                  (v)->type = T_OBJECT)
141 # define PUT_OBJ(v, o)          ((v)->oindex = (o)->index,              \
142                                  (v)->u.objcnt = (o)->count)
143 # define PUSH_ARRVAL(f, a)      (arr_ref((--(f)->sp)->u.array = (a)),   \
144                                  (f)->sp->type = T_ARRAY)
145 # define PUT_ARRVAL(v, a)       (arr_ref((v)->u.array = (a)),           \
146                                  (v)->type = T_ARRAY)
147 # define PUT_ARRVAL_NOREF(v, a) ((v)->u.array = (a), (v)->type = T_ARRAY)
148 # define PUT_ARR(v, a)          (arr_ref((v)->u.array = (a)))
149 # define PUSH_MAPVAL(f, m)      (arr_ref((--(f)->sp)->u.array = (m)),   \
150                                  (f)->sp->type = T_MAPPING)
151 # define PUT_MAPVAL(v, m)       (arr_ref((v)->u.array = (m)),           \
152                                  (v)->type = T_MAPPING)
153 # define PUT_MAPVAL_NOREF(v, m) ((v)->u.array = (m), (v)->type = T_MAPPING)
154 # define PUT_MAP(v, m)          (arr_ref((v)->u.array = (m)))
155 
156 # define VFLT_ISZERO(v) FLT_ISZERO((v)->oindex, (v)->u.objcnt)
157 # define VFLT_ISONE(v)  FLT_ISONE((v)->oindex, (v)->u.objcnt)
158 # define VFLT_HASH(v)   ((v)->oindex ^ (v)->u.objcnt)
159 
160 # define DESTRUCTED(v)  (OBJR((v)->oindex)->count != (v)->u.objcnt)
161 
162 
163 # define C_PRIVATE      0x01
164 # define C_STATIC       0x02
165 # define C_NOMASK       0x04
166 # define C_VARARGS      0x08
167 # define C_ATOMIC       0x10
168 # define C_TYPECHECKED  0x20
169 # define C_COMPILED     0x40
170 # define C_KFUN_VARARGS 0x40
171 # define C_UNDEFINED    0x80
172 
173 
174 # define SWITCH_INT     0
175 # define SWITCH_RANGE   1
176 # define SWITCH_STRING  2
177 
178 
179 typedef struct _rlinfo_ {
180     Int maxdepth;               /* max stack depth */
181     Int ticks;                  /* ticks left */
182     bool nodepth;               /* no stack depth checking */
183     bool noticks;               /* no ticks checking */
184     struct _rlinfo_ *next;      /* next in linked list */
185 } rlinfo;
186 
187 struct _frame_ {
188     frame *prev;                /* previous stack frame */
189     uindex oindex;              /* current object index */
190     control *ctrl;              /* object control block */
191     dataspace *data;            /* dataspace of current object */
192     control *p_ctrl;            /* program control block */
193     unsigned short p_index;     /* program index */
194     unsigned short nargs;       /* # arguments */
195     bool external;              /* TRUE if it's an external call */
196     bool sos;                   /* stack on stack */
197     uindex foffset;             /* program function offset */
198     struct _dfuncdef_ *func;    /* current function */
199     char *prog;                 /* start of program */
200     char *pc;                   /* program counter */
201     value *stack;               /* local value stack */
202     value *sp;                  /* stack pointer */
203     value *lip;                 /* lvalue index pointer */
204     value *argp;                /* argument pointer (previous sp) */
205     value *fp;                  /* frame pointer (at end of local stack) */
206     string *lvstr;              /* last indexed lvalue string */
207     Int depth;                  /* stack depth */
208     rlinfo *rlim;               /* rlimits info */
209     Int level;                  /* plane level */
210     bool atomic;                /* within uncaught atomic code */
211 };
212 
213 extern void     i_init          P((char*, int));
214 extern void     i_ref_value     P((value*));
215 extern void     i_del_value     P((value*));
216 extern void     i_copy          P((value*, value*, unsigned int));
217 extern void     i_grow_stack    P((frame*, int));
218 extern void     i_push_value    P((frame*, value*));
219 extern void     i_pop           P((frame*, int));
220 extern void     i_reverse       P((frame*, int));
221 extern void     i_odest         P((frame*, object*));
222 extern void     i_string        P((frame*, int, unsigned int));
223 extern void     i_aggregate     P((frame*, unsigned int));
224 extern void     i_map_aggregate P((frame*, unsigned int));
225 extern int      i_spread        P((frame*, int, int));
226 extern void     i_global        P((frame*, int, int));
227 extern void     i_global_lvalue P((frame*, int, int, int));
228 extern void     i_index         P((frame*));
229 extern void     i_index_lvalue  P((frame*, int));
230 extern char    *i_typename      P((char*, unsigned int));
231 extern void     i_cast          P((value*, unsigned int));
232 extern void     i_fetch         P((frame*));
233 extern void     i_store         P((frame*));
234 extern Int      i_get_depth     P((frame*));
235 extern Int      i_get_ticks     P((frame*));
236 extern void     i_new_rlimits   P((frame*, Int, Int));
237 extern void     i_set_rlimits   P((frame*, rlinfo*));
238 extern frame   *i_set_sp        P((frame*, value*));
239 extern object  *i_prev_object   P((frame*, int));
240 extern char    *i_prev_program  P((frame*, int));
241 extern void     i_typecheck     P((frame*, char*, char*, char*, int, int));
242 extern void     i_catcherr      P((frame*, Int));
243 extern void     i_funcall       P((frame*, object*, int, int, int));
244 extern bool     i_call          P((frame*, object*, char*, unsigned int, int,
245                                    int));
246 extern bool     i_call_tracei   P((frame*, Int, value*));
247 extern array   *i_call_trace    P((frame*));
248 extern bool     i_call_critical P((frame*, char*, int, int));
249 extern void     i_runtime_error P((frame*, Int));
250 extern void     i_atomic_error  P((frame*, Int));
251 extern frame   *i_restore       P((frame*, Int));
252 extern void     i_clear         P((void));
253 
254 extern frame *cframe;
255 extern int nil_type;
256 extern value zero_int, zero_float, nil_value;
257 
258 # define i_add_ticks(f, t)      ((f)->rlim->ticks -= (t))
259 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.