@@ -45,83 +45,83 @@ static inline size_t zend_ast_list_size(uint32_t children) {
45
45
return sizeof (zend_ast_list ) - sizeof (zend_ast * ) + sizeof (zend_ast * ) * children ;
46
46
}
47
47
48
- ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_znode (znode * node ) {
48
+ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_znode (zend_ast_loc * loc , znode * node ) {
49
49
zend_ast_znode * ast ;
50
50
51
51
ast = zend_ast_alloc (sizeof (zend_ast_znode ));
52
52
ast -> kind = ZEND_AST_ZNODE ;
53
53
ast -> attr = 0 ;
54
- ast -> lineno = CG ( zend_lineno ) ;
54
+ ast -> lineno = loc -> start_line ;
55
55
ast -> node = * node ;
56
56
return (zend_ast * ) ast ;
57
57
}
58
58
59
- static zend_always_inline zend_ast * zend_ast_create_zval_int (zval * zv , uint32_t attr , uint32_t lineno ) {
59
+ static zend_always_inline zend_ast * zend_ast_create_zval_int (
60
+ zend_ast_loc * loc , zval * zv , uint32_t attr ) {
60
61
zend_ast_zval * ast ;
61
62
62
63
ast = zend_ast_alloc (sizeof (zend_ast_zval ));
63
64
ast -> kind = ZEND_AST_ZVAL ;
64
65
ast -> attr = attr ;
65
66
ZVAL_COPY_VALUE (& ast -> val , zv );
66
- Z_LINENO (ast -> val ) = lineno ;
67
+ Z_LINENO (ast -> val ) = loc -> start_line ;
67
68
return (zend_ast * ) ast ;
68
69
}
69
70
70
- ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_with_lineno (zval * zv , uint32_t lineno ) {
71
- return zend_ast_create_zval_int (zv , 0 , lineno );
71
+ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_ex (
72
+ zend_ast_loc * loc , zval * zv , zend_ast_attr attr ) {
73
+ return zend_ast_create_zval_int (loc , zv , attr );
72
74
}
73
75
74
- ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_ex ( zval * zv , zend_ast_attr attr ) {
75
- return zend_ast_create_zval_int (zv , attr , CG ( zend_lineno ) );
76
+ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval ( zend_ast_loc * loc , zval * zv ) {
77
+ return zend_ast_create_zval_int (loc , zv , 0 );
76
78
}
77
79
78
- ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval (zval * zv ) {
79
- return zend_ast_create_zval_int (zv , 0 , CG (zend_lineno ));
80
- }
81
-
82
- ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_from_str (zend_string * str ) {
80
+ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_from_str (zend_ast_loc * loc , zend_string * str ) {
83
81
zval zv ;
84
82
ZVAL_STR (& zv , str );
85
- return zend_ast_create_zval_int (& zv , 0 , CG ( zend_lineno ) );
83
+ return zend_ast_create_zval_int (loc , & zv , 0 );
86
84
}
87
85
88
- ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_from_long (zend_long lval ) {
86
+ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_from_long (zend_ast_loc * loc , zend_long lval ) {
89
87
zval zv ;
90
88
ZVAL_LONG (& zv , lval );
91
- return zend_ast_create_zval_int (& zv , 0 , CG ( zend_lineno ) );
89
+ return zend_ast_create_zval_int (loc , & zv , 0 );
92
90
}
93
91
94
- ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_constant (zend_string * name , zend_ast_attr attr ) {
92
+ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_constant (
93
+ zend_ast_loc * loc , zend_string * name , zend_ast_attr attr ) {
95
94
zend_ast_zval * ast ;
96
95
97
96
ast = zend_ast_alloc (sizeof (zend_ast_zval ));
98
97
ast -> kind = ZEND_AST_CONSTANT ;
99
98
ast -> attr = attr ;
100
99
ZVAL_STR (& ast -> val , name );
101
- Z_LINENO (ast -> val ) = CG ( zend_lineno ) ;
100
+ Z_LINENO (ast -> val ) = loc -> start_line ;
102
101
return (zend_ast * ) ast ;
103
102
}
104
103
105
- ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_class_const_or_name (zend_ast * class_name , zend_ast * name ) {
104
+ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_class_const_or_name (
105
+ zend_ast_loc * loc , zend_ast * class_name , zend_ast * name ) {
106
106
zend_string * name_str = zend_ast_get_str (name );
107
107
if (zend_string_equals_literal_ci (name_str , "class" )) {
108
108
zend_string_release (name_str );
109
- return zend_ast_create (ZEND_AST_CLASS_NAME , class_name );
109
+ return zend_ast_create (loc , ZEND_AST_CLASS_NAME , class_name );
110
110
} else {
111
- return zend_ast_create (ZEND_AST_CLASS_CONST , class_name , name );
111
+ return zend_ast_create (loc , ZEND_AST_CLASS_CONST , class_name , name );
112
112
}
113
113
}
114
114
115
115
ZEND_API zend_ast * zend_ast_create_decl (
116
- zend_ast_kind kind , uint32_t flags , uint32_t start_lineno , zend_string * doc_comment ,
116
+ zend_ast_loc * loc , zend_ast_kind kind , uint32_t flags , zend_string * doc_comment ,
117
117
zend_string * name , zend_ast * child0 , zend_ast * child1 , zend_ast * child2 , zend_ast * child3
118
118
) {
119
119
zend_ast_decl * ast ;
120
120
121
121
ast = zend_ast_alloc (sizeof (zend_ast_decl ));
122
122
ast -> kind = kind ;
123
123
ast -> attr = 0 ;
124
- ast -> start_lineno = start_lineno ;
124
+ ast -> start_lineno = loc -> start_line ;
125
125
ast -> end_lineno = CG (zend_lineno );
126
126
ast -> flags = flags ;
127
127
ast -> lex_pos = LANG_SCNG (yy_text );
@@ -136,63 +136,50 @@ ZEND_API zend_ast *zend_ast_create_decl(
136
136
}
137
137
138
138
#if ZEND_AST_SPEC
139
- ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_0 (zend_ast_kind kind ) {
139
+ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_0 (zend_ast_loc * loc , zend_ast_kind kind ) {
140
140
zend_ast * ast ;
141
141
142
142
ZEND_ASSERT (kind >> ZEND_AST_NUM_CHILDREN_SHIFT == 0 );
143
143
ast = zend_ast_alloc (zend_ast_size (0 ));
144
144
ast -> kind = kind ;
145
145
ast -> attr = 0 ;
146
- ast -> lineno = CG ( zend_lineno ) ;
146
+ ast -> lineno = loc -> start_line ;
147
147
148
148
return ast ;
149
149
}
150
150
151
- ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_1 (zend_ast_kind kind , zend_ast * child ) {
151
+ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_1 (
152
+ zend_ast_loc * loc , zend_ast_kind kind , zend_ast * child ) {
152
153
zend_ast * ast ;
153
- uint32_t lineno ;
154
154
155
155
ZEND_ASSERT (kind >> ZEND_AST_NUM_CHILDREN_SHIFT == 1 );
156
156
ast = zend_ast_alloc (zend_ast_size (1 ));
157
157
ast -> kind = kind ;
158
158
ast -> attr = 0 ;
159
159
ast -> child [0 ] = child ;
160
- if (child ) {
161
- lineno = zend_ast_get_lineno (child );
162
- } else {
163
- lineno = CG (zend_lineno );
164
- }
165
- ast -> lineno = lineno ;
166
- ast -> lineno = lineno ;
160
+ ast -> lineno = loc -> start_line ;
167
161
168
162
return ast ;
169
163
}
170
164
171
- ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_2 (zend_ast_kind kind , zend_ast * child1 , zend_ast * child2 ) {
165
+ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_2 (
166
+ zend_ast_loc * loc , zend_ast_kind kind , zend_ast * child1 , zend_ast * child2 ) {
172
167
zend_ast * ast ;
173
- uint32_t lineno ;
174
168
175
169
ZEND_ASSERT (kind >> ZEND_AST_NUM_CHILDREN_SHIFT == 2 );
176
170
ast = zend_ast_alloc (zend_ast_size (2 ));
177
171
ast -> kind = kind ;
178
172
ast -> attr = 0 ;
179
173
ast -> child [0 ] = child1 ;
180
174
ast -> child [1 ] = child2 ;
181
- if (child1 ) {
182
- lineno = zend_ast_get_lineno (child1 );
183
- } else if (child2 ) {
184
- lineno = zend_ast_get_lineno (child2 );
185
- } else {
186
- lineno = CG (zend_lineno );
187
- }
188
- ast -> lineno = lineno ;
175
+ ast -> lineno = loc -> start_line ;
189
176
190
177
return ast ;
191
178
}
192
179
193
- ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_3 (zend_ast_kind kind , zend_ast * child1 , zend_ast * child2 , zend_ast * child3 ) {
180
+ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_3 (
181
+ zend_ast_loc * loc , zend_ast_kind kind , zend_ast * child1 , zend_ast * child2 , zend_ast * child3 ) {
194
182
zend_ast * ast ;
195
- uint32_t lineno ;
196
183
197
184
ZEND_ASSERT (kind >> ZEND_AST_NUM_CHILDREN_SHIFT == 3 );
198
185
ast = zend_ast_alloc (zend_ast_size (3 ));
@@ -201,23 +188,14 @@ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_3(zend_ast_kind kind, zend_ast
201
188
ast -> child [0 ] = child1 ;
202
189
ast -> child [1 ] = child2 ;
203
190
ast -> child [2 ] = child3 ;
204
- if (child1 ) {
205
- lineno = zend_ast_get_lineno (child1 );
206
- } else if (child2 ) {
207
- lineno = zend_ast_get_lineno (child2 );
208
- } else if (child3 ) {
209
- lineno = zend_ast_get_lineno (child3 );
210
- } else {
211
- lineno = CG (zend_lineno );
212
- }
213
- ast -> lineno = lineno ;
191
+ ast -> lineno = loc -> start_line ;
214
192
215
193
return ast ;
216
194
}
217
195
218
- ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_4 (zend_ast_kind kind , zend_ast * child1 , zend_ast * child2 , zend_ast * child3 , zend_ast * child4 ) {
196
+ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_4 (
197
+ zend_ast_loc * loc , zend_ast_kind kind , zend_ast * child1 , zend_ast * child2 , zend_ast * child3 , zend_ast * child4 ) {
219
198
zend_ast * ast ;
220
- uint32_t lineno ;
221
199
222
200
ZEND_ASSERT (kind >> ZEND_AST_NUM_CHILDREN_SHIFT == 4 );
223
201
ast = zend_ast_alloc (zend_ast_size (4 ));
@@ -227,64 +205,45 @@ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_4(zend_ast_kind kind, zend_ast
227
205
ast -> child [1 ] = child2 ;
228
206
ast -> child [2 ] = child3 ;
229
207
ast -> child [3 ] = child4 ;
230
- if (child1 ) {
231
- lineno = zend_ast_get_lineno (child1 );
232
- } else if (child2 ) {
233
- lineno = zend_ast_get_lineno (child2 );
234
- } else if (child3 ) {
235
- lineno = zend_ast_get_lineno (child3 );
236
- } else if (child4 ) {
237
- lineno = zend_ast_get_lineno (child4 );
238
- } else {
239
- lineno = CG (zend_lineno );
240
- }
241
- ast -> lineno = lineno ;
208
+ ast -> lineno = loc -> start_line ;
242
209
243
210
return ast ;
244
211
}
245
212
246
- ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_list_0 (zend_ast_kind kind ) {
213
+ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_list_0 (zend_ast_loc * loc , zend_ast_kind kind ) {
247
214
zend_ast * ast ;
248
215
zend_ast_list * list ;
249
216
250
217
ast = zend_ast_alloc (zend_ast_list_size (4 ));
251
218
list = (zend_ast_list * ) ast ;
252
219
list -> kind = kind ;
253
220
list -> attr = 0 ;
254
- list -> lineno = CG ( zend_lineno ) ;
221
+ list -> lineno = loc -> start_line ;
255
222
list -> children = 0 ;
256
223
257
224
return ast ;
258
225
}
259
226
260
- ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_list_1 (zend_ast_kind kind , zend_ast * child ) {
227
+ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_list_1 (
228
+ zend_ast_loc * loc , zend_ast_kind kind , zend_ast * child ) {
261
229
zend_ast * ast ;
262
230
zend_ast_list * list ;
263
- uint32_t lineno ;
264
231
265
232
ast = zend_ast_alloc (zend_ast_list_size (4 ));
266
233
list = (zend_ast_list * ) ast ;
267
234
list -> kind = kind ;
268
235
list -> attr = 0 ;
269
236
list -> children = 1 ;
270
237
list -> child [0 ] = child ;
271
- if (child ) {
272
- lineno = zend_ast_get_lineno (child );
273
- if (lineno > CG (zend_lineno )) {
274
- lineno = CG (zend_lineno );
275
- }
276
- } else {
277
- lineno = CG (zend_lineno );
278
- }
279
- list -> lineno = lineno ;
238
+ list -> lineno = loc -> start_line ;
280
239
281
240
return ast ;
282
241
}
283
242
284
- ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_list_2 (zend_ast_kind kind , zend_ast * child1 , zend_ast * child2 ) {
243
+ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_list_2 (
244
+ zend_ast_loc * loc , zend_ast_kind kind , zend_ast * child1 , zend_ast * child2 ) {
285
245
zend_ast * ast ;
286
246
zend_ast_list * list ;
287
- uint32_t lineno ;
288
247
289
248
ast = zend_ast_alloc (zend_ast_list_size (4 ));
290
249
list = (zend_ast_list * ) ast ;
@@ -293,82 +252,57 @@ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_list_2(zend_ast_kind kind, zen
293
252
list -> children = 2 ;
294
253
list -> child [0 ] = child1 ;
295
254
list -> child [1 ] = child2 ;
296
- if (child1 ) {
297
- lineno = zend_ast_get_lineno (child1 );
298
- if (lineno > CG (zend_lineno )) {
299
- lineno = CG (zend_lineno );
300
- }
301
- } else if (child2 ) {
302
- lineno = zend_ast_get_lineno (child2 );
303
- if (lineno > CG (zend_lineno )) {
304
- lineno = CG (zend_lineno );
305
- }
306
- } else {
307
- list -> children = 0 ;
308
- lineno = CG (zend_lineno );
309
- }
310
- list -> lineno = lineno ;
255
+ list -> lineno = loc -> start_line ;
311
256
312
257
return ast ;
313
258
}
314
259
#else
315
- static zend_ast * zend_ast_create_from_va_list (zend_ast_kind kind , zend_ast_attr attr , va_list va ) {
260
+ static zend_ast * zend_ast_create_from_va_list (
261
+ zend_ast_loc * loc , zend_ast_kind kind , zend_ast_attr attr , va_list va ) {
316
262
uint32_t i , children = kind >> ZEND_AST_NUM_CHILDREN_SHIFT ;
317
263
zend_ast * ast ;
318
264
319
265
ast = zend_ast_alloc (zend_ast_size (children ));
320
266
ast -> kind = kind ;
321
267
ast -> attr = attr ;
322
- ast -> lineno = (uint32_t ) -1 ;
323
-
324
- for (i = 0 ; i < children ; ++ i ) {
325
- ast -> child [i ] = va_arg (va , zend_ast * );
326
- if (ast -> child [i ] != NULL ) {
327
- uint32_t lineno = zend_ast_get_lineno (ast -> child [i ]);
328
- if (lineno < ast -> lineno ) {
329
- ast -> lineno = lineno ;
330
- }
331
- }
332
- }
333
-
334
- if (ast -> lineno == UINT_MAX ) {
335
- ast -> lineno = CG (zend_lineno );
336
- }
268
+ ast -> lineno = loc -> start_line ;
337
269
338
270
return ast ;
339
271
}
340
272
341
- ZEND_API zend_ast * zend_ast_create_ex (zend_ast_kind kind , zend_ast_attr attr , ...) {
273
+ ZEND_API zend_ast * zend_ast_create_ex (
274
+ zend_ast_loc * loc , zend_ast_kind kind , zend_ast_attr attr , ...) {
342
275
va_list va ;
343
276
zend_ast * ast ;
344
277
345
278
va_start (va , attr );
346
- ast = zend_ast_create_from_va_list (kind , attr , va );
279
+ ast = zend_ast_create_from_va_list (loc , kind , attr , va );
347
280
va_end (va );
348
281
349
282
return ast ;
350
283
}
351
284
352
- ZEND_API zend_ast * zend_ast_create (zend_ast_kind kind , ...) {
285
+ ZEND_API zend_ast * zend_ast_create (zend_ast_loc * loc , zend_ast_kind kind , ...) {
353
286
va_list va ;
354
287
zend_ast * ast ;
355
288
356
289
va_start (va , kind );
357
- ast = zend_ast_create_from_va_list (kind , 0 , va );
290
+ ast = zend_ast_create_from_va_list (loc , kind , 0 , va );
358
291
va_end (va );
359
292
360
293
return ast ;
361
294
}
362
295
363
- ZEND_API zend_ast * zend_ast_create_list (uint32_t init_children , zend_ast_kind kind , ...) {
296
+ ZEND_API zend_ast * zend_ast_create_list (
297
+ zend_ast_loc * loc , uint32_t init_children , zend_ast_kind kind , ...) {
364
298
zend_ast * ast ;
365
299
zend_ast_list * list ;
366
300
367
301
ast = zend_ast_alloc (zend_ast_list_size (4 ));
368
302
list = (zend_ast_list * ) ast ;
369
303
list -> kind = kind ;
370
304
list -> attr = 0 ;
371
- list -> lineno = CG ( zend_lineno ) ;
305
+ list -> lineno = loc -> start_line ;
372
306
list -> children = 0 ;
373
307
374
308
{
@@ -378,12 +312,6 @@ ZEND_API zend_ast *zend_ast_create_list(uint32_t init_children, zend_ast_kind ki
378
312
for (i = 0 ; i < init_children ; ++ i ) {
379
313
zend_ast * child = va_arg (va , zend_ast * );
380
314
ast = zend_ast_list_add (ast , child );
381
- if (child != NULL ) {
382
- uint32_t lineno = zend_ast_get_lineno (child );
383
- if (lineno < ast -> lineno ) {
384
- ast -> lineno = lineno ;
385
- }
386
- }
387
315
}
388
316
va_end (va );
389
317
}
0 commit comments