Subversion Repositories Kolibri OS

Rev

Rev 485 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
485 heavyiron 1
 
2
3
 
4
 { virtual at 0
4039 heavyiron 5
   fields@struct equ name
6
   match child parent, name \{ fields@struct equ child,fields@\#parent \}
485 heavyiron 7
   sub@struct equ
8
   struc db [val] \{ \common define field@struct .,db,
4039 heavyiron 9
			     fields@struct equ fields@struct,field@struct \}
10
   struc dw [val] \{ \common define field@struct .,dw,
11
			     fields@struct equ fields@struct,field@struct \}
12
   struc du [val] \{ \common define field@struct .,du,
13
			     fields@struct equ fields@struct,field@struct \}
14
   struc dd [val] \{ \common define field@struct .,dd,
15
			     fields@struct equ fields@struct,field@struct \}
16
   struc dp [val] \{ \common define field@struct .,dp,
17
			     fields@struct equ fields@struct,field@struct \}
18
   struc dq [val] \{ \common define field@struct .,dq,
19
			     fields@struct equ fields@struct,field@struct \}
20
   struc dt [val] \{ \common define field@struct .,dt,
21
			     fields@struct equ fields@struct,field@struct \}
22
   struc rb count \{ define field@struct .,db,count dup (?)
23
		     fields@struct equ fields@struct,field@struct \}
24
   struc rw count \{ define field@struct .,dw,count dup (?)
25
		     fields@struct equ fields@struct,field@struct \}
26
   struc rd count \{ define field@struct .,dd,count dup (?)
27
		     fields@struct equ fields@struct,field@struct \}
28
   struc rp count \{ define field@struct .,dp,count dup (?)
29
		     fields@struct equ fields@struct,field@struct \}
30
   struc rq count \{ define field@struct .,dq,count dup (?)
31
		     fields@struct equ fields@struct,field@struct \}
32
   struc rt count \{ define field@struct .,dt,count dup (?)
33
		     fields@struct equ fields@struct,field@struct \}
34
   macro db [val] \{ \common \local anonymous
485 heavyiron 35
		     define field@struct anonymous,db,
4039 heavyiron 36
		     fields@struct equ fields@struct,field@struct \}
37
   macro dw [val] \{ \common \local anonymous
485 heavyiron 38
		     define field@struct anonymous,dw,
4039 heavyiron 39
		     fields@struct equ fields@struct,field@struct \}
40
   macro du [val] \{ \common \local anonymous
485 heavyiron 41
		     define field@struct anonymous,du,
4039 heavyiron 42
		     fields@struct equ fields@struct,field@struct \}
43
   macro dd [val] \{ \common \local anonymous
485 heavyiron 44
		     define field@struct anonymous,dd,
4039 heavyiron 45
		     fields@struct equ fields@struct,field@struct \}
46
   macro dp [val] \{ \common \local anonymous
485 heavyiron 47
		     define field@struct anonymous,dp,
4039 heavyiron 48
		     fields@struct equ fields@struct,field@struct \}
49
   macro dq [val] \{ \common \local anonymous
485 heavyiron 50
		     define field@struct anonymous,dq,
4039 heavyiron 51
		     fields@struct equ fields@struct,field@struct \}
52
   macro dt [val] \{ \common \local anonymous
485 heavyiron 53
		     define field@struct anonymous,dt,
4039 heavyiron 54
		     fields@struct equ fields@struct,field@struct \}
55
   macro rb count \{ \local anonymous
485 heavyiron 56
		     define field@struct anonymous,db,count dup (?)
4039 heavyiron 57
		     fields@struct equ fields@struct,field@struct \}
58
   macro rw count \{ \local anonymous
485 heavyiron 59
		     define field@struct anonymous,dw,count dup (?)
4039 heavyiron 60
		     fields@struct equ fields@struct,field@struct \}
61
   macro rd count \{ \local anonymous
485 heavyiron 62
		     define field@struct anonymous,dd,count dup (?)
4039 heavyiron 63
		     fields@struct equ fields@struct,field@struct \}
64
   macro rp count \{ \local anonymous
485 heavyiron 65
		     define field@struct anonymous,dp,count dup (?)
4039 heavyiron 66
		     fields@struct equ fields@struct,field@struct \}
67
   macro rq count \{ \local anonymous
485 heavyiron 68
		     define field@struct anonymous,dq,count dup (?)
4039 heavyiron 69
		     fields@struct equ fields@struct,field@struct \}
70
   macro rt count \{ \local anonymous
485 heavyiron 71
		     define field@struct anonymous,dt,count dup (?)
4039 heavyiron 72
		     fields@struct equ fields@struct,field@struct \}
73
   macro union \{ fields@struct equ fields@struct,,union,<
485 heavyiron 74
		  sub@struct equ union \}
75
   macro struct \{ fields@struct equ fields@struct,,substruct,<
76
		  sub@struct equ substruct \} }
4039 heavyiron 77
485 heavyiron 78
 
79
 { match , sub@struct \{ restruc db,dw,du,dd,dp,dq,dt
80
			 restruc rb,rw,rd,rp,rq,rt
81
			 purge db,dw,du,dd,dp,dq,dt
82
			 purge rb,rw,rd,rp,rq,rt
83
			 purge union,struct
84
			 match name tail,fields@struct, \\{ if $
4039 heavyiron 85
							    display 'Error: definition of ',\\`name,' contains illegal instructions.',0Dh,0Ah
86
							    err
87
							    end if \\}
88
			 match name=,fields,fields@struct \\{ fields@struct equ
485 heavyiron 89
							      make@struct name,fields
90
							      define fields@\\#name fields \\}
4039 heavyiron 91
			 end virtual \}
485 heavyiron 92
   match any, sub@struct \{ fields@struct equ fields@struct> \}
93
   restore sub@struct }
94
95
 
96
 { common
97
    local define
98
    define equ name
99
   forward
100
    local sub
101
    match , field \{ make@substruct type,name,sub def
102
		     define equ define,.,sub, \}
103
    match any, field \{ define equ define,.#field,type, \}
104
   common
105
    match fields, define \{ define@struct fields \} }
106
107
 
108
 { common
109
    virtual
4039 heavyiron 110
    db `name
111
    load initial@struct byte from 0
112
    if initial@struct = '.'
113
    display 'Error: name of structure should not begin with a dot.',0Dh,0Ah
114
    err
115
    end if
116
    end virtual
117
    local list
485 heavyiron 118
    list equ
119
   forward
120
    if ~ field eq .
121
     name#field type def
122
     sizeof.#name#field = $ - name#field
123
    else
124
     label name#.#type
4039 heavyiron 125
     rb sizeof.#type
485 heavyiron 126
    end if
127
    local value
128
    match any, list \{ list equ list, \}
129
    list equ list 
130
   common
131
    sizeof.#name = $
132
    restruc name
133
    match values, list \{
134
    struc name value \\{ \\local \\..base
4039 heavyiron 135
    match any, fields@struct \\\{ fields@struct equ fields@struct,.,name, \\\}
485 heavyiron 136
    match , fields@struct \\\{ label \\..base
4039 heavyiron 137
   forward
485 heavyiron 138
     match , value \\\\{ field type def \\\\}
139
     match any, value \\\\{ field type value
140
			    if ~ field eq .
4039 heavyiron 141
			     rb sizeof.#name#field - ($-field)
142
			    end if \\\\}
143
   common label . at \\..base \\\}
144
   \\}
145
    macro name value \\{
146
    match any, fields@struct \\\{ \\\local anonymous
147
				  fields@struct equ fields@struct,anonymous,name, \\\}
148
    match , fields@struct \\\{
149
   forward
150
     match , value \\\\{ type def \\\\}
151
     match any, value \\\\{ \\\\local ..field
152
			   ..field = $
153
			   type value
154
			   if ~ field eq .
485 heavyiron 155
			    rb sizeof.#name#field - ($-..field)
4039 heavyiron 156
			   end if \\\\}
485 heavyiron 157
   common \\\} \\} \} }
158
159
 
160
 { macro make@substruct substruct,parent,name,[field,type,def]
161
    \{ \common
162
	\local define
163
	define equ parent,name
164
       \forward
165
	\local sub
166
	match , field \\{ match any, type \\\{ enable@substruct
167
					       make@substruct type,parent,sub def
4039 heavyiron 168
					       purge make@substruct
485 heavyiron 169
					       define equ define,.,sub, \\\} \\}
170
	match any, field \\{ define equ define,.\#field,type, \\}
171
       \common
172
	match fields, define \\{ define@\#substruct fields \\} \} }
173
174
 
175
176
 
177
 { common
178
    virtual at parent#.#name
4039 heavyiron 179
   forward
485 heavyiron 180
    if ~ field eq .
181
     virtual at parent#.#name
4039 heavyiron 182
      parent#field type def
485 heavyiron 183
      sizeof.#parent#field = $ - parent#field
184
     end virtual
185
     if sizeof.#parent#field > $ - parent#.#name
4039 heavyiron 186
      rb sizeof.#parent#field - ($ - parent#.#name)
187
     end if
485 heavyiron 188
    else
4039 heavyiron 189
     virtual at parent#.#name
190
      label parent#.#type
191
      type def
192
     end virtual
193
     label name#.#type at parent#.#name
194
     if sizeof.#type > $ - parent#.#name
195
      rb sizeof.#type - ($ - parent#.#name)
196
     end if
197
    end if
485 heavyiron 198
   common
199
    sizeof.#name = $ - parent#.#name
4039 heavyiron 200
    end virtual
485 heavyiron 201
    struc name [value] \{ \common
202
    label .\#name
203
    last@union equ
204
   forward
205
    match any, last@union \\{ virtual at .\#name
206
			       field type def
207
			      end virtual \\}
208
    match , last@union \\{ match , value \\\{ field type def \\\}
209
			   match any, value \\\{ field type value \\\} \\}
210
    last@union equ field
211
   common rb sizeof.#name - ($ - .\#name) \}
4039 heavyiron 212
    macro name [value] \{ \common \local ..anonymous
213
			  ..anonymous name value \} }
214
485 heavyiron 215
 
216
 { common
217
    virtual at parent#.#name
4039 heavyiron 218
   forward
485 heavyiron 219
    if ~ field eq .
220
     parent#field type def
221
     sizeof.#parent#field = $ - parent#field
222
    else
223
     label parent#.#type
4039 heavyiron 224
     rb sizeof.#type
485 heavyiron 225
    end if
226
   common
227
    sizeof.#name = $ - parent#.#name
4039 heavyiron 228
    end virtual
485 heavyiron 229
    struc name value \{
230
    label .\#name
231
   forward
232
     match , value \\{ field type def \\}
233
     match any, value \\{ field type value
234
			  if ~ field eq .
235
			   rb sizeof.#parent#field - ($-field)
236
			  end if \\}
237
   common \}
4039 heavyiron 238
    macro name value \{ \local ..anonymous
239
			..anonymous name \} }
240
>