Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
485 | heavyiron | 1 | |
2 | |||
3 | |||
4 | { fields@struct equ name |
||
5 | match child parent, name \{ fields@struct equ child,fields@\#parent \} |
||
6 | sub@struct equ |
||
7 | struc db [val] \{ \common fields@struct equ fields@struct,.,db, |
||
8 | struc dw [val] \{ \common fields@struct equ fields@struct,.,dw, |
||
9 | struc du [val] \{ \common fields@struct equ fields@struct,.,du, |
||
10 | struc dd [val] \{ \common fields@struct equ fields@struct,.,dd, |
||
11 | struc dp [val] \{ \common fields@struct equ fields@struct,.,dp, |
||
12 | struc dq [val] \{ \common fields@struct equ fields@struct,.,dq, |
||
13 | struc dt [val] \{ \common fields@struct equ fields@struct,.,dt, |
||
14 | struc rb count \{ fields@struct equ fields@struct,.,db,count dup (?) \} |
||
15 | struc rw count \{ fields@struct equ fields@struct,.,dw,count dup (?) \} |
||
16 | struc rd count \{ fields@struct equ fields@struct,.,dd,count dup (?) \} |
||
17 | struc rp count \{ fields@struct equ fields@struct,.,dp,count dup (?) \} |
||
18 | struc rq count \{ fields@struct equ fields@struct,.,dq,count dup (?) \} |
||
19 | struc rt count \{ fields@struct equ fields@struct,.,dt,count dup (?) \} |
||
20 | macro db [val] \{ \common \local anonymous |
||
21 | fields@struct equ fields@struct,anonymous,db, |
||
22 | macro dw [val] \{ \common \local anonymous |
||
23 | fields@struct equ fields@struct,anonymous,dw, |
||
24 | macro du [val] \{ \common \local anonymous |
||
25 | fields@struct equ fields@struct,anonymous,du, |
||
26 | macro dd [val] \{ \common \local anonymous |
||
27 | fields@struct equ fields@struct,anonymous,dd, |
||
28 | macro dp [val] \{ \common \local anonymous |
||
29 | fields@struct equ fields@struct,anonymous,dp, |
||
30 | macro dq [val] \{ \common \local anonymous |
||
31 | fields@struct equ fields@struct,anonymous,dq, |
||
32 | macro dt [val] \{ \common \local anonymous |
||
33 | fields@struct equ fields@struct,anonymous,dt, |
||
34 | macro rb count \{ \local anonymous |
||
35 | fields@struct equ fields@struct,anonymous,db,count dup (?) \} |
||
36 | macro rw count \{ \local anonymous |
||
37 | fields@struct equ fields@struct,anonymous,dw,count dup (?) \} |
||
38 | macro rd count \{ \local anonymous |
||
39 | fields@struct equ fields@struct,anonymous,dd,count dup (?) \} |
||
40 | macro rp count \{ \local anonymous |
||
41 | fields@struct equ fields@struct,anonymous,dp,count dup (?) \} |
||
42 | macro rq count \{ \local anonymous |
||
43 | fields@struct equ fields@struct,anonymous,dq,count dup (?) \} |
||
44 | macro rt count \{ \local anonymous |
||
45 | fields@struct equ fields@struct,anonymous,dt,count dup (?) \} |
||
46 | macro union \{ fields@struct equ fields@struct,,union,< |
||
47 | sub@struct equ union \} |
||
48 | macro struct \{ fields@struct equ fields@struct,,substruct,< |
||
49 | sub@struct equ substruct \} |
||
50 | virtual at 0 } |
||
51 | |||
52 | |||
53 | { match , sub@struct \{ restruc db,dw,du,dd,dp,dq,dt |
||
54 | restruc rb,rw,rd,rp,rq,rt |
||
55 | purge db,dw,du,dd,dp,dq,dt |
||
56 | purge rb,rw,rd,rp,rq,rt |
||
57 | purge union,struct |
||
58 | match name=,fields,fields@struct \\{ fields@struct equ |
||
59 | make@struct name,fields |
||
60 | fields@\\#name equ fields \\} |
||
61 | end virtual \} |
||
62 | match any, sub@struct \{ fields@struct equ fields@struct> \} |
||
63 | restore sub@struct } |
||
64 | |||
65 | |||
66 | { common |
||
67 | if $ |
||
68 | display 'Error: definition of ',`name,' contains illegal instructions.',0Dh,0Ah |
||
69 | err |
||
70 | end if |
||
71 | local define |
||
72 | define equ name |
||
73 | forward |
||
74 | local sub |
||
75 | match , field \{ make@substruct type,name,sub def |
||
76 | define equ define,.,sub, \} |
||
77 | match any, field \{ define equ define,.#field,type, |
||
78 | common |
||
79 | match fields, define \{ define@struct fields \} } |
||
80 | |||
81 | |||
82 | { common |
||
83 | local list |
||
84 | list equ |
||
85 | forward |
||
86 | if ~ field eq . |
||
87 | name#field type def |
||
88 | sizeof.#name#field = $ - name#field |
||
89 | else |
||
90 | rb sizeof.#type |
||
91 | end if |
||
92 | local value |
||
93 | match any, list \{ list equ list, \} |
||
94 | list equ list |
||
95 | common |
||
96 | sizeof.#name = $ |
||
97 | restruc name |
||
98 | match values, list \{ |
||
99 | struc name value \\{ |
||
100 | match any, fields@struct \\\{ fields@struct equ fields@struct,.,name, |
||
101 | match , fields@struct \\\{ label . |
||
102 | forward |
||
103 | match , value \\\\{ field type def \\\\} |
||
104 | match any, value \\\\{ field type value |
||
105 | if ~ field eq . |
||
106 | rb sizeof.#name#field - ($-field) |
||
107 | end if \\\\} |
||
108 | common \\\} \\} \} } |
||
109 | |||
110 | |||
111 | { macro make@substruct substruct,parent,name,[field,type,def] |
||
112 | \{ \common |
||
113 | \local define |
||
114 | define equ parent,name |
||
115 | \forward |
||
116 | \local sub |
||
117 | match , field \\{ match any, type \\\{ enable@substruct |
||
118 | make@substruct type,name,sub def |
||
119 | purge make@substruct |
||
120 | define equ define,.,sub, \\\} \\} |
||
121 | match any, field \\{ define equ define,.\#field,type, |
||
122 | \common |
||
123 | match fields, define \\{ define@\#substruct fields \\} \} } |
||
124 | |||
125 | |||
126 | |||
127 | |||
128 | { common |
||
129 | virtual at 0 |
||
130 | forward |
||
131 | if ~ field eq . |
||
132 | virtual at 0 |
||
133 | parent#field type def |
||
134 | sizeof.#parent#field = $ - parent#field |
||
135 | end virtual |
||
136 | if sizeof.#parent#field > $ |
||
137 | rb sizeof.#parent#field - $ |
||
138 | end if |
||
139 | else if sizeof.#type > $ |
||
140 | rb sizeof.#type - $ |
||
141 | end if |
||
142 | common |
||
143 | sizeof.#name = $ |
||
144 | end virtual |
||
145 | struc name [value] \{ \common |
||
146 | label .\#name |
||
147 | last@union equ |
||
148 | forward |
||
149 | match any, last@union \\{ virtual at .\#name |
||
150 | field type def |
||
151 | end virtual \\} |
||
152 | match , last@union \\{ match , value \\\{ field type def \\\} |
||
153 | match any, value \\\{ field type value \\\} \\} |
||
154 | last@union equ field |
||
155 | common rb sizeof.#name - ($ - .\#name) \} } |
||
156 | |||
157 | |||
158 | { common |
||
159 | virtual at 0 |
||
160 | forward |
||
161 | if ~ field eq . |
||
162 | parent#field type def |
||
163 | sizeof.#parent#field = $ - parent#field |
||
164 | else |
||
165 | rb sizeof.#type |
||
166 | end if |
||
167 | local value |
||
168 | common |
||
169 | sizeof.#name = $ |
||
170 | end virtual |
||
171 | struc name value \{ |
||
172 | label .\#name |
||
173 | forward |
||
174 | match , value \\{ field type def \\} |
||
175 | match any, value \\{ field type value |
||
176 | if ~ field eq . |
||
177 | rb sizeof.#parent#field - ($-field) |
||
178 | end if \\} |
||
179 | common \} } |
||
180 | > |