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 # include "dgd.h"
  2 # include "str.h"
  3 # include "array.h"
  4 # include "object.h"
  5 # include "xfloat.h"
  6 # include "interpret.h"
  7 # include "data.h"
  8 # include "table.h"
  9 
 10 /*
 11  * interface
 12  */
 13 # define DGD_EXT_KFUN(ekf, n)   kf_ext_kfun((ekf), (n))
 14 # define DGD_EXT_CALLBACK(r, s, d, f, c, e) \
 15                                 conf_ext_callback((r), (s), (d), (f), (c), (e))
 16 # define DGD_ERROR(m)           error((m))
 17 
 18 /*
 19  * types
 20  */
 21 # define DGD_INT_T              Int
 22 # define DGD_FLOAT_T            xfloat
 23 # define DGD_STRING_T           string*
 24 # define DGD_OBJECT_T           object*
 25 # define DGD_ARRAY_T            array*
 26 # define DGD_MAPPING_T          array*
 27 # define DGD_VALUE_T            value
 28 # define DGD_FRAME_T            frame*
 29 # define DGD_DATASPACE_T        dataspace*
 30 # define DGD_EXTKFUN_T          extkfunc
 31 # define DGD_EINDEX_T           eindex
 32 
 33 /*
 34  * prototype and value types
 35  */
 36 # define DGD_TYPE_VOID          T_VOID
 37 # define DGD_TYPE_NIL           T_NIL
 38 # define DGD_TYPE_INT           T_INT
 39 # define DGD_TYPE_FLOAT         T_FLOAT
 40 # define DGD_TYPE_STRING        T_STRING
 41 # define DGD_TYPE_OBJECT        T_OBJECT
 42 # define DGD_TYPE_ARRAY         T_ARRAY
 43 # define DGD_TYPE_MAPPING       T_MAPPING
 44 # define DGD_TYPE_MIXED         T_MIXED
 45 
 46 # define DGD_TYPE_ARRAY_OF(t)   ((t) + (1 << REFSHIFT))
 47 # define DGD_TYPE_VARARGS       T_VARARGS
 48 # define DGD_TYPE_ELLIPSIS      T_ELLIPSIS
 49 
 50 /*
 51  * frame
 52  */
 53 # define DGD_FRAME_OBJECT(f)    OBJW((f)->oindex)
 54 # define DGD_FRAME_PROGRAM(f)   OBJW((f)->p_ctrl->oindex)
 55 # define DGD_FRAME_DATASPACE(f) ((f)->data)
 56 # define DGD_FRAME_ARG(f, n, i) (*((f)->sp + (n) - ((i) + 1)))
 57 # define DGD_FRAME_ATOMIC(f)    ((f)->level != 0)
 58 
 59 /*
 60  * dataspace
 61  */
 62 # define DGD_DATA_GET_VAL(d)    (*d_get_extravar((d)))
 63 # define DGD_DATA_SET_VAL(d, v) d_set_extravar((d), &(v))
 64 
 65 /*
 66  * value
 67  */
 68 # define DGD_TYPEOF(v)          ((v).type)
 69 
 70 # define DGD_RETVAL_INT(v, i)   PUT_INTVAL((v), (i))
 71 # define DGD_RETVAL_FLT(v, f)   PUT_FLTVAL((v), (f))
 72 # define DGD_RETVAL_STR(v, s)   PUT_STRVAL((v), (s))
 73 # define DGD_RETVAL_OBJ(v, o)   PUT_OBJVAL((v), (o))
 74 # define DGD_RETVAL_ARR(v, a)   PUT_ARRVAL((v), (a))
 75 # define DGD_RETVAL_MAP(v, m)   PUT_MAPVAL((v), (m))
 76 
 77 /*
 78  * nil
 79  */
 80 # define DGD_NIL_VALUE          nil_value
 81 
 82 /*
 83  * int
 84  */
 85 # define DGD_INT_GETVAL(v)      ((v).u.number)
 86 # define DGD_INT_PUTVAL(v, i)   PUT_INTVAL(&(v), (i))
 87 
 88 /*
 89  * float
 90  */
 91 # define DGD_FLOAT_GETVAL(v, f)         GET_FLT(&(v), (f))
 92 # define DGD_FLOAT_PUTVAL(v, f)         PUT_FLTVAL(&(v), (f))
 93 # define DGD_FLOAT_GET(f, s, e, m)      ((((f).high | (f).low) == 0) ? \
 94                                           ((s) = 0, (e) = 0, (m) = 0) : \
 95                                           ((s) = (f).high >> 15, \
 96                                            (e) = (((f).high >> 4) & 0x7ff) - \
 97                                                  1023, \
 98                                            (m) = 0x10 | ((f).high & 0xf), \
 99                                            (m) <<= 32, (m) |= (f).low))
100 # define DGD_FLOAT_PUT(f, s, e, m)      ((f).high = (((m) == 0) ? 0 : \
101                                                       ((s) << 15) | \
102                                                       (((e) + 1023) << 4) | \
103                                                       (((m) >> 32) & 0xf)), \
104                                          (f).low = (m))
105 
106 /*
107  * string
108  */
109 # define DGD_STRING_GETVAL(v)           ((v).u.string)
110 # define DGD_STRING_PUTVAL(v, s)        PUT_STRVAL_NOREF(&(v), (s))
111 # define DGD_STRING_NEW(t, n)           str_new((t), (long) (n))
112 # define DGD_STRING_TEXT(s)             ((s)->text)
113 # define DGD_STRING_LENGTH(s)           ((s)->len)
114 
115 /*
116  * object
117  */
118 # define DGD_OBJECT_GETVAL(v)           OBJW((v).oindex)
119 # define DGD_OBJECT_PUTVAL(v, o)        PUT_OBJVAL(&(v), (o))
120 # define DGD_OBJECT_CHECKVAL(v, o)      ((v).u.objcnt == (o)->count)
121 # define DGD_OBJECT_DATASPACE(o)        o_dataspace((o))
122 # define DGD_OBJECT_NAME(buf, o)        o_name((buf), (o))
123 # define DGD_OBJECT_ISSPECIAL(o)        (((o)->flags & O_SPECIAL) != 0)
124 # define DGD_OBJECT_ISMARKED(o)         (((o)->flags & O_SPECIAL) == O_SPECIAL)
125 # define DGD_OBJECT_MARK(o)             ((o)->flags |= O_SPECIAL)
126 # define DGD_OBJECT_UNMARK(o)           ((o)->flags &= ~O_SPECIAL)
127 # define DGD_OBJECT_GET_EINDEX(o)       ((o)->etabi)
128 # define DGD_OBJECT_SET_EINDEX(o, e)    ((o)->etabi = (e))
129 
130 /*
131  * array
132  */
133 # define DGD_ARRAY_GETVAL(v)            ((v).u.array)
134 # define DGD_ARRAY_PUTVAL(v, a)         PUT_ARRVAL_NOREF(&(v), (a))
135 # define DGD_ARRAY_NEW(d, n)            arr_ext_new((d), (long) (n))
136 # define DGD_ARRAY_ELTS(a)              d_get_elts((a))
137 # define DGD_ARRAY_SIZE(a)              ((a)->size)
138 # define DGD_ARRAY_INDEX(a, i)          (d_get_elts((a))[(i)])
139 # define DGD_ARRAY_ASSIGN(d, a, i, v)   d_assign_elt((d), (a), \
140                                                     &d_get_elts((a))[(i)], &(v))
141 /*
142  * mapping
143  */
144 # define DGD_MAPPING_GETVAL(v)          ((v).u.array)
145 # define DGD_MAPPING_PUTVAL(v, m)       PUT_MAPVAL_NOREF(&(v), (m))
146 # define DGD_MAPPING_NEW(d)             map_new((d), 0L)
147 # define DGD_MAPPING_ELTS(m)            (map_compact((m)), d_get_elts((m)))
148 # define DGD_MAPPING_SIZE(m)            map_size((m))
149 # define DGD_MAPPING_INDEX(m, i)        (*map_index((m)->primary->data, (m), \
150                                                     &(i), (value *) NULL))
151 # define DGD_MAPPING_ASSIGN(d, m, i, v) map_index((d), (m), &(i), &(v))
152 

~ [ 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.