Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3545 hidnplayr 1
 
2
3
 
4
 { virtual at 0
5
   fields@struct equ name
6
   match child parent, name \{ fields@struct equ child,fields@\#parent \}
7
   sub@struct equ
8
   struc db [val] \{ \common define field@struct .,db,
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
35
                     define field@struct anonymous,db,
36
                     fields@struct equ fields@struct,field@struct \}
37
   macro dw [val] \{ \common \local anonymous
38
                     define field@struct anonymous,dw,
39
                     fields@struct equ fields@struct,field@struct \}
40
   macro du [val] \{ \common \local anonymous
41
                     define field@struct anonymous,du,
42
                     fields@struct equ fields@struct,field@struct \}
43
   macro dd [val] \{ \common \local anonymous
44
                     define field@struct anonymous,dd,
45
                     fields@struct equ fields@struct,field@struct \}
46
   macro dp [val] \{ \common \local anonymous
47
                     define field@struct anonymous,dp,
48
                     fields@struct equ fields@struct,field@struct \}
49
   macro dq [val] \{ \common \local anonymous
50
                     define field@struct anonymous,dq,
51
                     fields@struct equ fields@struct,field@struct \}
52
   macro dt [val] \{ \common \local anonymous
53
                     define field@struct anonymous,dt,
54
                     fields@struct equ fields@struct,field@struct \}
55
   macro rb count \{ \local anonymous
56
                     define field@struct anonymous,db,count dup (?)
57
                     fields@struct equ fields@struct,field@struct \}
58
   macro rw count \{ \local anonymous
59
                     define field@struct anonymous,dw,count dup (?)
60
                     fields@struct equ fields@struct,field@struct \}
61
   macro rd count \{ \local anonymous
62
                     define field@struct anonymous,dd,count dup (?)
63
                     fields@struct equ fields@struct,field@struct \}
64
   macro rp count \{ \local anonymous
65
                     define field@struct anonymous,dp,count dup (?)
66
                     fields@struct equ fields@struct,field@struct \}
67
   macro rq count \{ \local anonymous
68
                     define field@struct anonymous,dq,count dup (?)
69
                     fields@struct equ fields@struct,field@struct \}
70
   macro rt count \{ \local anonymous
71
                     define field@struct anonymous,dt,count dup (?)
72
                     fields@struct equ fields@struct,field@struct \}
73
   macro union \{ fields@struct equ fields@struct,,union,<
74
                  sub@struct equ union \}
75
   macro struct \{ fields@struct equ fields@struct,,substruct,<
76
                  sub@struct equ substruct \} }
77
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 $
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
89
                                                              make@struct name,fields
90
                                                              define fields@\\#name fields \\}
91
                         end virtual \}
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
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
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
125
     rb sizeof.#type
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
135
    match any, fields@struct \\\{ fields@struct equ fields@struct,.,name, \\\}
136
    match , fields@struct \\\{ label \\..base
137
   forward
138
     match , value \\\\{ field type def \\\\}
139
     match any, value \\\\{ field type value
140
                            if ~ field eq .
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 .
155
                            rb sizeof.#name#field - ($-..field)
156
                           end if \\\\}
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
168
                                               purge make@substruct
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
179
   forward
180
    if ~ field eq .
181
     virtual at parent#.#name
182
      parent#field type def
183
      sizeof.#parent#field = $ - parent#field
184
     end virtual
185
     if sizeof.#parent#field > $ - parent#.#name
186
      rb sizeof.#parent#field - ($ - parent#.#name)
187
     end if
188
    else
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
198
   common
199
    sizeof.#name = $ - parent#.#name
200
    end virtual
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) \}
212
    macro name [value] \{ \common \local ..anonymous
213
                          ..anonymous name value \} }
214
215
 
216
 { common
217
    virtual at parent#.#name
218
   forward
219
    if ~ field eq .
220
     parent#field type def
221
     sizeof.#parent#field = $ - parent#field
222
    else
223
     label parent#.#type
224
     rb sizeof.#type
225
    end if
226
   common
227
    sizeof.#name = $ - parent#.#name
228
    end virtual
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 \}
238
    macro name value \{ \local ..anonymous
239
                        ..anonymous name \} }
240
>