Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
2381 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
 
9026 Boppan 96
macro make@struct name,[field,type,def]
2381 hidnplayr 97
 { common
98
    local define
99
    define equ name
100
   forward
101
    local sub
102
    match , field \{ make@substruct type,name,sub def
103
                     define equ define,.,sub, \}
104
    match any, field \{ define equ define,.#field,type, \}
105
   common
106
    match fields, define \{ define@struct fields \} }
107
108
 
9026 Boppan 109
macro define@struct name,[field,type,def]
2381 hidnplayr 110
 { common
111
    virtual
112
    db `name
113
    load initial@struct byte from 0
114
    if initial@struct = '.'
115
    display 'Error: name of structure should not begin with a dot.',0Dh,0Ah
116
    err
117
    end if
118
    end virtual
119
    local list
120
    list equ
121
   forward
122
    if ~ field eq .
123
     name#field type def
124
     sizeof.#name#field = $ - name#field
125
    else
126
     label name#.#type
127
     rb sizeof.#type
128
    end if
129
    local value
130
    match any, list \{ list equ list, \}
131
    list equ list 
132
   common
133
    sizeof.#name = $
134
    restruc name
135
    match values, list \{
136
    struc name value \\{ \\local \\..base
137
    match any, fields@struct \\\{ fields@struct equ fields@struct,.,name, \\\}
138
    match , fields@struct \\\{ label \\..base
139
   forward
140
     match , value \\\\{ field type def \\\\}
141
     match any, value \\\\{ field type value
142
                            if ~ field eq .
143
                             rb sizeof.#name#field - ($-field)
144
                            end if \\\\}
145
   common label . at \\..base \\\}
146
   \\}
147
    macro name value \\{
148
    match any, fields@struct \\\{ \\\local anonymous
149
                                  fields@struct equ fields@struct,anonymous,name, \\\}
150
    match , fields@struct \\\{
151
   forward
152
     match , value \\\\{ type def \\\\}
153
     match any, value \\\\{ \\\\local ..field
154
                           ..field = $
155
                           type value
156
                           if ~ field eq .
157
                            rb sizeof.#name#field - ($-..field)
158
                           end if \\\\}
159
   common \\\} \\} \} }
160
161
 
9026 Boppan 162
macro enable@substruct
2381 hidnplayr 163
 { macro make@substruct substruct,parent,name,[field,type,def]
164
    \{ \common
165
        \local define
166
        define equ parent,name
167
       \forward
168
        \local sub
169
        match , field \\{ match any, type \\\{ enable@substruct
170
                                               make@substruct type,parent,sub def
171
                                               purge make@substruct
172
                                               define equ define,.,sub, \\\} \\}
173
        match any, field \\{ define equ define,.\#field,type, \\}
174
       \common
175
        match fields, define \\{ define@\#substruct fields \\} \} }
176
177
 
9026 Boppan 178
enable@substruct
2381 hidnplayr 179
180
 
9026 Boppan 181
macro define@union parent,name,[field,type,def]
2381 hidnplayr 182
 { common
183
    virtual at parent#.#name
184
   forward
185
    if ~ field eq .
186
     virtual at parent#.#name
187
      parent#field type def
188
      sizeof.#parent#field = $ - parent#field
189
     end virtual
190
     if sizeof.#parent#field > $ - parent#.#name
191
      rb sizeof.#parent#field - ($ - parent#.#name)
192
     end if
193
    else
194
     virtual at parent#.#name
195
      label parent#.#type
196
      type def
197
     end virtual
198
     label name#.#type at parent#.#name
199
     if sizeof.#type > $ - parent#.#name
200
      rb sizeof.#type - ($ - parent#.#name)
201
     end if
202
    end if
203
   common
204
    sizeof.#name = $ - parent#.#name
205
    end virtual
206
    struc name [value] \{ \common
207
    label .\#name
208
    last@union equ
209
   forward
210
    match any, last@union \\{ virtual at .\#name
211
                               field type def
212
                              end virtual \\}
213
    match , last@union \\{ match , value \\\{ field type def \\\}
214
                           match any, value \\\{ field type value \\\} \\}
215
    last@union equ field
216
   common rb sizeof.#name - ($ - .\#name) \}
217
    macro name [value] \{ \common \local ..anonymous
218
                          ..anonymous name value \} }
219
220
 
9026 Boppan 221
macro define@substruct parent,name,[field,type,def]
2381 hidnplayr 222
 { common
223
    virtual at parent#.#name
224
   forward
225
    if ~ field eq .
226
     parent#field type def
227
     sizeof.#parent#field = $ - parent#field
228
    else
229
     label parent#.#type
230
     rb sizeof.#type
231
    end if
232
   common
233
    sizeof.#name = $ - parent#.#name
234
    end virtual
235
    struc name value \{
236
    label .\#name
237
   forward
238
     match , value \\{ field type def \\}
239
     match any, value \\{ field type value
240
                          if ~ field eq .
241
                           rb sizeof.#parent#field - ($-field)
242
                          end if \\}
243
   common \}
244
    macro name value \{ \local ..anonymous
245
                        ..anonymous name \} }
246
>