]>
Commit | Line | Data |
---|---|---|
1 | # 1 "jsxml.cpp" | |
2 | # 1 "<built-in>" | |
3 | # 1 "<command-line>" | |
4 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdc-predef.h" 1 3 4 | |
5 | # 1 "<command-line>" 2 | |
6 | # 1 "././js-confdefs.h" 1 | |
7 | # 1 "<command-line>" 2 | |
8 | # 1 "jsxml.cpp" | |
9 | # 40 "jsxml.cpp" | |
10 | # 1 "jsversion.h" 1 | |
11 | # 41 "jsxml.cpp" 2 | |
12 | ||
13 | ||
14 | ||
15 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 1 3 4 | |
16 | # 26 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 3 4 | |
17 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/features.h" 1 3 4 | |
18 | # 365 "/usr/powerpc64-unknown-linux-gnu/usr/include/features.h" 3 4 | |
19 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/cdefs.h" 1 3 4 | |
20 | # 410 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/cdefs.h" 3 4 | |
21 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/wordsize.h" 1 3 4 | |
22 | # 411 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/cdefs.h" 2 3 4 | |
23 | # 366 "/usr/powerpc64-unknown-linux-gnu/usr/include/features.h" 2 3 4 | |
24 | # 389 "/usr/powerpc64-unknown-linux-gnu/usr/include/features.h" 3 4 | |
25 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/gnu/stubs.h" 1 3 4 | |
26 | ||
27 | ||
28 | ||
29 | ||
30 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/wordsize.h" 1 3 4 | |
31 | # 6 "/usr/powerpc64-unknown-linux-gnu/usr/include/gnu/stubs.h" 2 3 4 | |
32 | ||
33 | ||
34 | ||
35 | ||
36 | ||
37 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/gnu/stubs-64-v1.h" 1 3 4 | |
38 | # 12 "/usr/powerpc64-unknown-linux-gnu/usr/include/gnu/stubs.h" 2 3 4 | |
39 | # 390 "/usr/powerpc64-unknown-linux-gnu/usr/include/features.h" 2 3 4 | |
40 | # 27 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 2 3 4 | |
41 | ||
42 | extern "C" { | |
43 | ||
44 | ||
45 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/math-vector.h" 1 3 4 | |
46 | # 27 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/math-vector.h" 3 4 | |
47 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/libm-simd-decl-stubs.h" 1 3 4 | |
48 | # 27 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/math-vector.h" 2 3 4 | |
49 | # 32 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 2 3 4 | |
50 | ||
51 | ||
52 | ||
53 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/huge_val.h" 1 3 4 | |
54 | # 36 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 2 3 4 | |
55 | ||
56 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/huge_valf.h" 1 3 4 | |
57 | # 38 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 2 3 4 | |
58 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/huge_vall.h" 1 3 4 | |
59 | # 39 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 2 3 4 | |
60 | ||
61 | ||
62 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/inf.h" 1 3 4 | |
63 | # 42 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 2 3 4 | |
64 | ||
65 | ||
66 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/nan.h" 1 3 4 | |
67 | # 45 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 2 3 4 | |
68 | ||
69 | ||
70 | ||
71 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/mathdef.h" 1 3 4 | |
72 | # 33 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/mathdef.h" 3 4 | |
73 | typedef float float_t; | |
74 | typedef double double_t; | |
75 | # 49 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 2 3 4 | |
76 | # 82 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 3 4 | |
77 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/mathcalls.h" 1 3 4 | |
78 | # 52 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/mathcalls.h" 3 4 | |
79 | ||
80 | ||
81 | extern double acos (double __x) throw (); extern double __acos (double __x) throw (); | |
82 | ||
83 | extern double asin (double __x) throw (); extern double __asin (double __x) throw (); | |
84 | ||
85 | extern double atan (double __x) throw (); extern double __atan (double __x) throw (); | |
86 | ||
87 | extern double atan2 (double __y, double __x) throw (); extern double __atan2 (double __y, double __x) throw (); | |
88 | ||
89 | ||
90 | extern double cos (double __x) throw (); extern double __cos (double __x) throw (); | |
91 | ||
92 | extern double sin (double __x) throw (); extern double __sin (double __x) throw (); | |
93 | ||
94 | extern double tan (double __x) throw (); extern double __tan (double __x) throw (); | |
95 | ||
96 | ||
97 | ||
98 | ||
99 | extern double cosh (double __x) throw (); extern double __cosh (double __x) throw (); | |
100 | ||
101 | extern double sinh (double __x) throw (); extern double __sinh (double __x) throw (); | |
102 | ||
103 | extern double tanh (double __x) throw (); extern double __tanh (double __x) throw (); | |
104 | ||
105 | ||
106 | ||
107 | ||
108 | extern void sincos (double __x, double *__sinx, double *__cosx) throw (); extern void __sincos (double __x, double *__sinx, double *__cosx) throw () | |
109 | ; | |
110 | ||
111 | ||
112 | ||
113 | ||
114 | ||
115 | extern double acosh (double __x) throw (); extern double __acosh (double __x) throw (); | |
116 | ||
117 | extern double asinh (double __x) throw (); extern double __asinh (double __x) throw (); | |
118 | ||
119 | extern double atanh (double __x) throw (); extern double __atanh (double __x) throw (); | |
120 | ||
121 | ||
122 | ||
123 | ||
124 | ||
125 | ||
126 | ||
127 | extern double exp (double __x) throw (); extern double __exp (double __x) throw (); | |
128 | ||
129 | ||
130 | extern double frexp (double __x, int *__exponent) throw (); extern double __frexp (double __x, int *__exponent) throw (); | |
131 | ||
132 | ||
133 | extern double ldexp (double __x, int __exponent) throw (); extern double __ldexp (double __x, int __exponent) throw (); | |
134 | ||
135 | ||
136 | extern double log (double __x) throw (); extern double __log (double __x) throw (); | |
137 | ||
138 | ||
139 | extern double log10 (double __x) throw (); extern double __log10 (double __x) throw (); | |
140 | ||
141 | ||
142 | extern double modf (double __x, double *__iptr) throw (); extern double __modf (double __x, double *__iptr) throw () __attribute__ ((__nonnull__ (2))); | |
143 | ||
144 | ||
145 | ||
146 | ||
147 | extern double exp10 (double __x) throw (); extern double __exp10 (double __x) throw (); | |
148 | ||
149 | extern double pow10 (double __x) throw (); extern double __pow10 (double __x) throw (); | |
150 | ||
151 | ||
152 | ||
153 | ||
154 | ||
155 | extern double expm1 (double __x) throw (); extern double __expm1 (double __x) throw (); | |
156 | ||
157 | ||
158 | extern double log1p (double __x) throw (); extern double __log1p (double __x) throw (); | |
159 | ||
160 | ||
161 | extern double logb (double __x) throw (); extern double __logb (double __x) throw (); | |
162 | ||
163 | ||
164 | ||
165 | ||
166 | ||
167 | ||
168 | extern double exp2 (double __x) throw (); extern double __exp2 (double __x) throw (); | |
169 | ||
170 | ||
171 | extern double log2 (double __x) throw (); extern double __log2 (double __x) throw (); | |
172 | ||
173 | ||
174 | ||
175 | ||
176 | ||
177 | ||
178 | ||
179 | ||
180 | extern double pow (double __x, double __y) throw (); extern double __pow (double __x, double __y) throw (); | |
181 | ||
182 | ||
183 | extern double sqrt (double __x) throw (); extern double __sqrt (double __x) throw (); | |
184 | ||
185 | ||
186 | ||
187 | ||
188 | ||
189 | extern double hypot (double __x, double __y) throw (); extern double __hypot (double __x, double __y) throw (); | |
190 | ||
191 | ||
192 | ||
193 | ||
194 | ||
195 | ||
196 | extern double cbrt (double __x) throw (); extern double __cbrt (double __x) throw (); | |
197 | ||
198 | ||
199 | ||
200 | ||
201 | ||
202 | ||
203 | ||
204 | ||
205 | extern double ceil (double __x) throw () __attribute__ ((__const__)); extern double __ceil (double __x) throw () __attribute__ ((__const__)); | |
206 | ||
207 | ||
208 | extern double fabs (double __x) throw () __attribute__ ((__const__)); extern double __fabs (double __x) throw () __attribute__ ((__const__)); | |
209 | ||
210 | ||
211 | extern double floor (double __x) throw () __attribute__ ((__const__)); extern double __floor (double __x) throw () __attribute__ ((__const__)); | |
212 | ||
213 | ||
214 | extern double fmod (double __x, double __y) throw (); extern double __fmod (double __x, double __y) throw (); | |
215 | ||
216 | ||
217 | ||
218 | ||
219 | extern int __isinf (double __value) throw () __attribute__ ((__const__)); | |
220 | ||
221 | ||
222 | extern int __finite (double __value) throw () __attribute__ ((__const__)); | |
223 | ||
224 | ||
225 | ||
226 | ||
227 | ||
228 | extern int isinf (double __value) throw () __attribute__ ((__const__)); | |
229 | ||
230 | ||
231 | extern int finite (double __value) throw () __attribute__ ((__const__)); | |
232 | ||
233 | ||
234 | extern double drem (double __x, double __y) throw (); extern double __drem (double __x, double __y) throw (); | |
235 | ||
236 | ||
237 | ||
238 | extern double significand (double __x) throw (); extern double __significand (double __x) throw (); | |
239 | ||
240 | ||
241 | ||
242 | ||
243 | ||
244 | extern double copysign (double __x, double __y) throw () __attribute__ ((__const__)); extern double __copysign (double __x, double __y) throw () __attribute__ ((__const__)); | |
245 | ||
246 | ||
247 | ||
248 | ||
249 | ||
250 | ||
251 | extern double nan (const char *__tagb) throw () __attribute__ ((__const__)); extern double __nan (const char *__tagb) throw () __attribute__ ((__const__)); | |
252 | ||
253 | ||
254 | ||
255 | ||
256 | ||
257 | extern int __isnan (double __value) throw () __attribute__ ((__const__)); | |
258 | ||
259 | ||
260 | ||
261 | extern int isnan (double __value) throw () __attribute__ ((__const__)); | |
262 | ||
263 | ||
264 | extern double j0 (double) throw (); extern double __j0 (double) throw (); | |
265 | extern double j1 (double) throw (); extern double __j1 (double) throw (); | |
266 | extern double jn (int, double) throw (); extern double __jn (int, double) throw (); | |
267 | extern double y0 (double) throw (); extern double __y0 (double) throw (); | |
268 | extern double y1 (double) throw (); extern double __y1 (double) throw (); | |
269 | extern double yn (int, double) throw (); extern double __yn (int, double) throw (); | |
270 | ||
271 | ||
272 | ||
273 | ||
274 | ||
275 | ||
276 | extern double erf (double) throw (); extern double __erf (double) throw (); | |
277 | extern double erfc (double) throw (); extern double __erfc (double) throw (); | |
278 | extern double lgamma (double) throw (); extern double __lgamma (double) throw (); | |
279 | ||
280 | ||
281 | ||
282 | ||
283 | ||
284 | ||
285 | extern double tgamma (double) throw (); extern double __tgamma (double) throw (); | |
286 | ||
287 | ||
288 | ||
289 | ||
290 | ||
291 | extern double gamma (double) throw (); extern double __gamma (double) throw (); | |
292 | ||
293 | ||
294 | ||
295 | ||
296 | ||
297 | ||
298 | extern double lgamma_r (double, int *__signgamp) throw (); extern double __lgamma_r (double, int *__signgamp) throw (); | |
299 | ||
300 | ||
301 | ||
302 | ||
303 | ||
304 | ||
305 | ||
306 | extern double rint (double __x) throw (); extern double __rint (double __x) throw (); | |
307 | ||
308 | ||
309 | extern double nextafter (double __x, double __y) throw () __attribute__ ((__const__)); extern double __nextafter (double __x, double __y) throw () __attribute__ ((__const__)); | |
310 | ||
311 | extern double nexttoward (double __x, long double __y) throw () __attribute__ ((__const__)); extern double __nexttoward (double __x, long double __y) throw () __attribute__ ((__const__)); | |
312 | ||
313 | ||
314 | ||
315 | extern double remainder (double __x, double __y) throw (); extern double __remainder (double __x, double __y) throw (); | |
316 | ||
317 | ||
318 | ||
319 | extern double scalbn (double __x, int __n) throw (); extern double __scalbn (double __x, int __n) throw (); | |
320 | ||
321 | ||
322 | ||
323 | extern int ilogb (double __x) throw (); extern int __ilogb (double __x) throw (); | |
324 | ||
325 | ||
326 | ||
327 | ||
328 | extern double scalbln (double __x, long int __n) throw (); extern double __scalbln (double __x, long int __n) throw (); | |
329 | ||
330 | ||
331 | ||
332 | extern double nearbyint (double __x) throw (); extern double __nearbyint (double __x) throw (); | |
333 | ||
334 | ||
335 | ||
336 | extern double round (double __x) throw () __attribute__ ((__const__)); extern double __round (double __x) throw () __attribute__ ((__const__)); | |
337 | ||
338 | ||
339 | ||
340 | extern double trunc (double __x) throw () __attribute__ ((__const__)); extern double __trunc (double __x) throw () __attribute__ ((__const__)); | |
341 | ||
342 | ||
343 | ||
344 | ||
345 | extern double remquo (double __x, double __y, int *__quo) throw (); extern double __remquo (double __x, double __y, int *__quo) throw (); | |
346 | ||
347 | ||
348 | ||
349 | ||
350 | ||
351 | ||
352 | extern long int lrint (double __x) throw (); extern long int __lrint (double __x) throw (); | |
353 | __extension__ | |
354 | extern long long int llrint (double __x) throw (); extern long long int __llrint (double __x) throw (); | |
355 | ||
356 | ||
357 | ||
358 | extern long int lround (double __x) throw (); extern long int __lround (double __x) throw (); | |
359 | __extension__ | |
360 | extern long long int llround (double __x) throw (); extern long long int __llround (double __x) throw (); | |
361 | ||
362 | ||
363 | ||
364 | extern double fdim (double __x, double __y) throw (); extern double __fdim (double __x, double __y) throw (); | |
365 | ||
366 | ||
367 | extern double fmax (double __x, double __y) throw () __attribute__ ((__const__)); extern double __fmax (double __x, double __y) throw () __attribute__ ((__const__)); | |
368 | ||
369 | ||
370 | extern double fmin (double __x, double __y) throw () __attribute__ ((__const__)); extern double __fmin (double __x, double __y) throw () __attribute__ ((__const__)); | |
371 | ||
372 | ||
373 | ||
374 | extern int __fpclassify (double __value) throw () | |
375 | __attribute__ ((__const__)); | |
376 | ||
377 | ||
378 | extern int __signbit (double __value) throw () | |
379 | __attribute__ ((__const__)); | |
380 | ||
381 | ||
382 | ||
383 | extern double fma (double __x, double __y, double __z) throw (); extern double __fma (double __x, double __y, double __z) throw (); | |
384 | ||
385 | ||
386 | ||
387 | ||
388 | ||
389 | ||
390 | ||
391 | ||
392 | extern int __issignaling (double __value) throw () | |
393 | __attribute__ ((__const__)); | |
394 | ||
395 | ||
396 | ||
397 | ||
398 | extern double scalb (double __x, double __n) throw (); extern double __scalb (double __x, double __n) throw (); | |
399 | # 83 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 2 3 4 | |
400 | # 101 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 3 4 | |
401 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/mathcalls.h" 1 3 4 | |
402 | # 52 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/mathcalls.h" 3 4 | |
403 | ||
404 | ||
405 | extern float acosf (float __x) throw (); extern float __acosf (float __x) throw (); | |
406 | ||
407 | extern float asinf (float __x) throw (); extern float __asinf (float __x) throw (); | |
408 | ||
409 | extern float atanf (float __x) throw (); extern float __atanf (float __x) throw (); | |
410 | ||
411 | extern float atan2f (float __y, float __x) throw (); extern float __atan2f (float __y, float __x) throw (); | |
412 | ||
413 | ||
414 | extern float cosf (float __x) throw (); extern float __cosf (float __x) throw (); | |
415 | ||
416 | extern float sinf (float __x) throw (); extern float __sinf (float __x) throw (); | |
417 | ||
418 | extern float tanf (float __x) throw (); extern float __tanf (float __x) throw (); | |
419 | ||
420 | ||
421 | ||
422 | ||
423 | extern float coshf (float __x) throw (); extern float __coshf (float __x) throw (); | |
424 | ||
425 | extern float sinhf (float __x) throw (); extern float __sinhf (float __x) throw (); | |
426 | ||
427 | extern float tanhf (float __x) throw (); extern float __tanhf (float __x) throw (); | |
428 | ||
429 | ||
430 | ||
431 | ||
432 | extern void sincosf (float __x, float *__sinx, float *__cosx) throw (); extern void __sincosf (float __x, float *__sinx, float *__cosx) throw () | |
433 | ; | |
434 | ||
435 | ||
436 | ||
437 | ||
438 | ||
439 | extern float acoshf (float __x) throw (); extern float __acoshf (float __x) throw (); | |
440 | ||
441 | extern float asinhf (float __x) throw (); extern float __asinhf (float __x) throw (); | |
442 | ||
443 | extern float atanhf (float __x) throw (); extern float __atanhf (float __x) throw (); | |
444 | ||
445 | ||
446 | ||
447 | ||
448 | ||
449 | ||
450 | ||
451 | extern float expf (float __x) throw (); extern float __expf (float __x) throw (); | |
452 | ||
453 | ||
454 | extern float frexpf (float __x, int *__exponent) throw (); extern float __frexpf (float __x, int *__exponent) throw (); | |
455 | ||
456 | ||
457 | extern float ldexpf (float __x, int __exponent) throw (); extern float __ldexpf (float __x, int __exponent) throw (); | |
458 | ||
459 | ||
460 | extern float logf (float __x) throw (); extern float __logf (float __x) throw (); | |
461 | ||
462 | ||
463 | extern float log10f (float __x) throw (); extern float __log10f (float __x) throw (); | |
464 | ||
465 | ||
466 | extern float modff (float __x, float *__iptr) throw (); extern float __modff (float __x, float *__iptr) throw () __attribute__ ((__nonnull__ (2))); | |
467 | ||
468 | ||
469 | ||
470 | ||
471 | extern float exp10f (float __x) throw (); extern float __exp10f (float __x) throw (); | |
472 | ||
473 | extern float pow10f (float __x) throw (); extern float __pow10f (float __x) throw (); | |
474 | ||
475 | ||
476 | ||
477 | ||
478 | ||
479 | extern float expm1f (float __x) throw (); extern float __expm1f (float __x) throw (); | |
480 | ||
481 | ||
482 | extern float log1pf (float __x) throw (); extern float __log1pf (float __x) throw (); | |
483 | ||
484 | ||
485 | extern float logbf (float __x) throw (); extern float __logbf (float __x) throw (); | |
486 | ||
487 | ||
488 | ||
489 | ||
490 | ||
491 | ||
492 | extern float exp2f (float __x) throw (); extern float __exp2f (float __x) throw (); | |
493 | ||
494 | ||
495 | extern float log2f (float __x) throw (); extern float __log2f (float __x) throw (); | |
496 | ||
497 | ||
498 | ||
499 | ||
500 | ||
501 | ||
502 | ||
503 | ||
504 | extern float powf (float __x, float __y) throw (); extern float __powf (float __x, float __y) throw (); | |
505 | ||
506 | ||
507 | extern float sqrtf (float __x) throw (); extern float __sqrtf (float __x) throw (); | |
508 | ||
509 | ||
510 | ||
511 | ||
512 | ||
513 | extern float hypotf (float __x, float __y) throw (); extern float __hypotf (float __x, float __y) throw (); | |
514 | ||
515 | ||
516 | ||
517 | ||
518 | ||
519 | ||
520 | extern float cbrtf (float __x) throw (); extern float __cbrtf (float __x) throw (); | |
521 | ||
522 | ||
523 | ||
524 | ||
525 | ||
526 | ||
527 | ||
528 | ||
529 | extern float ceilf (float __x) throw () __attribute__ ((__const__)); extern float __ceilf (float __x) throw () __attribute__ ((__const__)); | |
530 | ||
531 | ||
532 | extern float fabsf (float __x) throw () __attribute__ ((__const__)); extern float __fabsf (float __x) throw () __attribute__ ((__const__)); | |
533 | ||
534 | ||
535 | extern float floorf (float __x) throw () __attribute__ ((__const__)); extern float __floorf (float __x) throw () __attribute__ ((__const__)); | |
536 | ||
537 | ||
538 | extern float fmodf (float __x, float __y) throw (); extern float __fmodf (float __x, float __y) throw (); | |
539 | ||
540 | ||
541 | ||
542 | ||
543 | extern int __isinff (float __value) throw () __attribute__ ((__const__)); | |
544 | ||
545 | ||
546 | extern int __finitef (float __value) throw () __attribute__ ((__const__)); | |
547 | ||
548 | ||
549 | ||
550 | ||
551 | ||
552 | extern int isinff (float __value) throw () __attribute__ ((__const__)); | |
553 | ||
554 | ||
555 | extern int finitef (float __value) throw () __attribute__ ((__const__)); | |
556 | ||
557 | ||
558 | extern float dremf (float __x, float __y) throw (); extern float __dremf (float __x, float __y) throw (); | |
559 | ||
560 | ||
561 | ||
562 | extern float significandf (float __x) throw (); extern float __significandf (float __x) throw (); | |
563 | ||
564 | ||
565 | ||
566 | ||
567 | ||
568 | extern float copysignf (float __x, float __y) throw () __attribute__ ((__const__)); extern float __copysignf (float __x, float __y) throw () __attribute__ ((__const__)); | |
569 | ||
570 | ||
571 | ||
572 | ||
573 | ||
574 | ||
575 | extern float nanf (const char *__tagb) throw () __attribute__ ((__const__)); extern float __nanf (const char *__tagb) throw () __attribute__ ((__const__)); | |
576 | ||
577 | ||
578 | ||
579 | ||
580 | ||
581 | extern int __isnanf (float __value) throw () __attribute__ ((__const__)); | |
582 | ||
583 | ||
584 | ||
585 | extern int isnanf (float __value) throw () __attribute__ ((__const__)); | |
586 | ||
587 | ||
588 | extern float j0f (float) throw (); extern float __j0f (float) throw (); | |
589 | extern float j1f (float) throw (); extern float __j1f (float) throw (); | |
590 | extern float jnf (int, float) throw (); extern float __jnf (int, float) throw (); | |
591 | extern float y0f (float) throw (); extern float __y0f (float) throw (); | |
592 | extern float y1f (float) throw (); extern float __y1f (float) throw (); | |
593 | extern float ynf (int, float) throw (); extern float __ynf (int, float) throw (); | |
594 | ||
595 | ||
596 | ||
597 | ||
598 | ||
599 | ||
600 | extern float erff (float) throw (); extern float __erff (float) throw (); | |
601 | extern float erfcf (float) throw (); extern float __erfcf (float) throw (); | |
602 | extern float lgammaf (float) throw (); extern float __lgammaf (float) throw (); | |
603 | ||
604 | ||
605 | ||
606 | ||
607 | ||
608 | ||
609 | extern float tgammaf (float) throw (); extern float __tgammaf (float) throw (); | |
610 | ||
611 | ||
612 | ||
613 | ||
614 | ||
615 | extern float gammaf (float) throw (); extern float __gammaf (float) throw (); | |
616 | ||
617 | ||
618 | ||
619 | ||
620 | ||
621 | ||
622 | extern float lgammaf_r (float, int *__signgamp) throw (); extern float __lgammaf_r (float, int *__signgamp) throw (); | |
623 | ||
624 | ||
625 | ||
626 | ||
627 | ||
628 | ||
629 | ||
630 | extern float rintf (float __x) throw (); extern float __rintf (float __x) throw (); | |
631 | ||
632 | ||
633 | extern float nextafterf (float __x, float __y) throw () __attribute__ ((__const__)); extern float __nextafterf (float __x, float __y) throw () __attribute__ ((__const__)); | |
634 | ||
635 | extern float nexttowardf (float __x, long double __y) throw () __attribute__ ((__const__)); extern float __nexttowardf (float __x, long double __y) throw () __attribute__ ((__const__)); | |
636 | ||
637 | ||
638 | ||
639 | extern float remainderf (float __x, float __y) throw (); extern float __remainderf (float __x, float __y) throw (); | |
640 | ||
641 | ||
642 | ||
643 | extern float scalbnf (float __x, int __n) throw (); extern float __scalbnf (float __x, int __n) throw (); | |
644 | ||
645 | ||
646 | ||
647 | extern int ilogbf (float __x) throw (); extern int __ilogbf (float __x) throw (); | |
648 | ||
649 | ||
650 | ||
651 | ||
652 | extern float scalblnf (float __x, long int __n) throw (); extern float __scalblnf (float __x, long int __n) throw (); | |
653 | ||
654 | ||
655 | ||
656 | extern float nearbyintf (float __x) throw (); extern float __nearbyintf (float __x) throw (); | |
657 | ||
658 | ||
659 | ||
660 | extern float roundf (float __x) throw () __attribute__ ((__const__)); extern float __roundf (float __x) throw () __attribute__ ((__const__)); | |
661 | ||
662 | ||
663 | ||
664 | extern float truncf (float __x) throw () __attribute__ ((__const__)); extern float __truncf (float __x) throw () __attribute__ ((__const__)); | |
665 | ||
666 | ||
667 | ||
668 | ||
669 | extern float remquof (float __x, float __y, int *__quo) throw (); extern float __remquof (float __x, float __y, int *__quo) throw (); | |
670 | ||
671 | ||
672 | ||
673 | ||
674 | ||
675 | ||
676 | extern long int lrintf (float __x) throw (); extern long int __lrintf (float __x) throw (); | |
677 | __extension__ | |
678 | extern long long int llrintf (float __x) throw (); extern long long int __llrintf (float __x) throw (); | |
679 | ||
680 | ||
681 | ||
682 | extern long int lroundf (float __x) throw (); extern long int __lroundf (float __x) throw (); | |
683 | __extension__ | |
684 | extern long long int llroundf (float __x) throw (); extern long long int __llroundf (float __x) throw (); | |
685 | ||
686 | ||
687 | ||
688 | extern float fdimf (float __x, float __y) throw (); extern float __fdimf (float __x, float __y) throw (); | |
689 | ||
690 | ||
691 | extern float fmaxf (float __x, float __y) throw () __attribute__ ((__const__)); extern float __fmaxf (float __x, float __y) throw () __attribute__ ((__const__)); | |
692 | ||
693 | ||
694 | extern float fminf (float __x, float __y) throw () __attribute__ ((__const__)); extern float __fminf (float __x, float __y) throw () __attribute__ ((__const__)); | |
695 | ||
696 | ||
697 | ||
698 | extern int __fpclassifyf (float __value) throw () | |
699 | __attribute__ ((__const__)); | |
700 | ||
701 | ||
702 | extern int __signbitf (float __value) throw () | |
703 | __attribute__ ((__const__)); | |
704 | ||
705 | ||
706 | ||
707 | extern float fmaf (float __x, float __y, float __z) throw (); extern float __fmaf (float __x, float __y, float __z) throw (); | |
708 | ||
709 | ||
710 | ||
711 | ||
712 | ||
713 | ||
714 | ||
715 | ||
716 | extern int __issignalingf (float __value) throw () | |
717 | __attribute__ ((__const__)); | |
718 | ||
719 | ||
720 | ||
721 | ||
722 | extern float scalbf (float __x, float __n) throw (); extern float __scalbf (float __x, float __n) throw (); | |
723 | # 102 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 2 3 4 | |
724 | # 146 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 3 4 | |
725 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/mathcalls.h" 1 3 4 | |
726 | # 52 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/mathcalls.h" 3 4 | |
727 | ||
728 | ||
729 | extern long double acosl (long double __x) throw (); extern long double __acosl (long double __x) throw (); | |
730 | ||
731 | extern long double asinl (long double __x) throw (); extern long double __asinl (long double __x) throw (); | |
732 | ||
733 | extern long double atanl (long double __x) throw (); extern long double __atanl (long double __x) throw (); | |
734 | ||
735 | extern long double atan2l (long double __y, long double __x) throw (); extern long double __atan2l (long double __y, long double __x) throw (); | |
736 | ||
737 | ||
738 | extern long double cosl (long double __x) throw (); extern long double __cosl (long double __x) throw (); | |
739 | ||
740 | extern long double sinl (long double __x) throw (); extern long double __sinl (long double __x) throw (); | |
741 | ||
742 | extern long double tanl (long double __x) throw (); extern long double __tanl (long double __x) throw (); | |
743 | ||
744 | ||
745 | ||
746 | ||
747 | extern long double coshl (long double __x) throw (); extern long double __coshl (long double __x) throw (); | |
748 | ||
749 | extern long double sinhl (long double __x) throw (); extern long double __sinhl (long double __x) throw (); | |
750 | ||
751 | extern long double tanhl (long double __x) throw (); extern long double __tanhl (long double __x) throw (); | |
752 | ||
753 | ||
754 | ||
755 | ||
756 | extern void sincosl (long double __x, long double *__sinx, long double *__cosx) throw (); extern void __sincosl (long double __x, long double *__sinx, long double *__cosx) throw () | |
757 | ; | |
758 | ||
759 | ||
760 | ||
761 | ||
762 | ||
763 | extern long double acoshl (long double __x) throw (); extern long double __acoshl (long double __x) throw (); | |
764 | ||
765 | extern long double asinhl (long double __x) throw (); extern long double __asinhl (long double __x) throw (); | |
766 | ||
767 | extern long double atanhl (long double __x) throw (); extern long double __atanhl (long double __x) throw (); | |
768 | ||
769 | ||
770 | ||
771 | ||
772 | ||
773 | ||
774 | ||
775 | extern long double expl (long double __x) throw (); extern long double __expl (long double __x) throw (); | |
776 | ||
777 | ||
778 | extern long double frexpl (long double __x, int *__exponent) throw (); extern long double __frexpl (long double __x, int *__exponent) throw (); | |
779 | ||
780 | ||
781 | extern long double ldexpl (long double __x, int __exponent) throw (); extern long double __ldexpl (long double __x, int __exponent) throw (); | |
782 | ||
783 | ||
784 | extern long double logl (long double __x) throw (); extern long double __logl (long double __x) throw (); | |
785 | ||
786 | ||
787 | extern long double log10l (long double __x) throw (); extern long double __log10l (long double __x) throw (); | |
788 | ||
789 | ||
790 | extern long double modfl (long double __x, long double *__iptr) throw (); extern long double __modfl (long double __x, long double *__iptr) throw () __attribute__ ((__nonnull__ (2))); | |
791 | ||
792 | ||
793 | ||
794 | ||
795 | extern long double exp10l (long double __x) throw (); extern long double __exp10l (long double __x) throw (); | |
796 | ||
797 | extern long double pow10l (long double __x) throw (); extern long double __pow10l (long double __x) throw (); | |
798 | ||
799 | ||
800 | ||
801 | ||
802 | ||
803 | extern long double expm1l (long double __x) throw (); extern long double __expm1l (long double __x) throw (); | |
804 | ||
805 | ||
806 | extern long double log1pl (long double __x) throw (); extern long double __log1pl (long double __x) throw (); | |
807 | ||
808 | ||
809 | extern long double logbl (long double __x) throw (); extern long double __logbl (long double __x) throw (); | |
810 | ||
811 | ||
812 | ||
813 | ||
814 | ||
815 | ||
816 | extern long double exp2l (long double __x) throw (); extern long double __exp2l (long double __x) throw (); | |
817 | ||
818 | ||
819 | extern long double log2l (long double __x) throw (); extern long double __log2l (long double __x) throw (); | |
820 | ||
821 | ||
822 | ||
823 | ||
824 | ||
825 | ||
826 | ||
827 | ||
828 | extern long double powl (long double __x, long double __y) throw (); extern long double __powl (long double __x, long double __y) throw (); | |
829 | ||
830 | ||
831 | extern long double sqrtl (long double __x) throw (); extern long double __sqrtl (long double __x) throw (); | |
832 | ||
833 | ||
834 | ||
835 | ||
836 | ||
837 | extern long double hypotl (long double __x, long double __y) throw (); extern long double __hypotl (long double __x, long double __y) throw (); | |
838 | ||
839 | ||
840 | ||
841 | ||
842 | ||
843 | ||
844 | extern long double cbrtl (long double __x) throw (); extern long double __cbrtl (long double __x) throw (); | |
845 | ||
846 | ||
847 | ||
848 | ||
849 | ||
850 | ||
851 | ||
852 | ||
853 | extern long double ceill (long double __x) throw () __attribute__ ((__const__)); extern long double __ceill (long double __x) throw () __attribute__ ((__const__)); | |
854 | ||
855 | ||
856 | extern long double fabsl (long double __x) throw () __attribute__ ((__const__)); extern long double __fabsl (long double __x) throw () __attribute__ ((__const__)); | |
857 | ||
858 | ||
859 | extern long double floorl (long double __x) throw () __attribute__ ((__const__)); extern long double __floorl (long double __x) throw () __attribute__ ((__const__)); | |
860 | ||
861 | ||
862 | extern long double fmodl (long double __x, long double __y) throw (); extern long double __fmodl (long double __x, long double __y) throw (); | |
863 | ||
864 | ||
865 | ||
866 | ||
867 | extern int __isinfl (long double __value) throw () __attribute__ ((__const__)); | |
868 | ||
869 | ||
870 | extern int __finitel (long double __value) throw () __attribute__ ((__const__)); | |
871 | ||
872 | ||
873 | ||
874 | ||
875 | ||
876 | extern int isinfl (long double __value) throw () __attribute__ ((__const__)); | |
877 | ||
878 | ||
879 | extern int finitel (long double __value) throw () __attribute__ ((__const__)); | |
880 | ||
881 | ||
882 | extern long double dreml (long double __x, long double __y) throw (); extern long double __dreml (long double __x, long double __y) throw (); | |
883 | ||
884 | ||
885 | ||
886 | extern long double significandl (long double __x) throw (); extern long double __significandl (long double __x) throw (); | |
887 | ||
888 | ||
889 | ||
890 | ||
891 | ||
892 | extern long double copysignl (long double __x, long double __y) throw () __attribute__ ((__const__)); extern long double __copysignl (long double __x, long double __y) throw () __attribute__ ((__const__)); | |
893 | ||
894 | ||
895 | ||
896 | ||
897 | ||
898 | ||
899 | extern long double nanl (const char *__tagb) throw () __attribute__ ((__const__)); extern long double __nanl (const char *__tagb) throw () __attribute__ ((__const__)); | |
900 | ||
901 | ||
902 | ||
903 | ||
904 | ||
905 | extern int __isnanl (long double __value) throw () __attribute__ ((__const__)); | |
906 | ||
907 | ||
908 | ||
909 | extern int isnanl (long double __value) throw () __attribute__ ((__const__)); | |
910 | ||
911 | ||
912 | extern long double j0l (long double) throw (); extern long double __j0l (long double) throw (); | |
913 | extern long double j1l (long double) throw (); extern long double __j1l (long double) throw (); | |
914 | extern long double jnl (int, long double) throw (); extern long double __jnl (int, long double) throw (); | |
915 | extern long double y0l (long double) throw (); extern long double __y0l (long double) throw (); | |
916 | extern long double y1l (long double) throw (); extern long double __y1l (long double) throw (); | |
917 | extern long double ynl (int, long double) throw (); extern long double __ynl (int, long double) throw (); | |
918 | ||
919 | ||
920 | ||
921 | ||
922 | ||
923 | ||
924 | extern long double erfl (long double) throw (); extern long double __erfl (long double) throw (); | |
925 | extern long double erfcl (long double) throw (); extern long double __erfcl (long double) throw (); | |
926 | extern long double lgammal (long double) throw (); extern long double __lgammal (long double) throw (); | |
927 | ||
928 | ||
929 | ||
930 | ||
931 | ||
932 | ||
933 | extern long double tgammal (long double) throw (); extern long double __tgammal (long double) throw (); | |
934 | ||
935 | ||
936 | ||
937 | ||
938 | ||
939 | extern long double gammal (long double) throw (); extern long double __gammal (long double) throw (); | |
940 | ||
941 | ||
942 | ||
943 | ||
944 | ||
945 | ||
946 | extern long double lgammal_r (long double, int *__signgamp) throw (); extern long double __lgammal_r (long double, int *__signgamp) throw (); | |
947 | ||
948 | ||
949 | ||
950 | ||
951 | ||
952 | ||
953 | ||
954 | extern long double rintl (long double __x) throw (); extern long double __rintl (long double __x) throw (); | |
955 | ||
956 | ||
957 | extern long double nextafterl (long double __x, long double __y) throw () __attribute__ ((__const__)); extern long double __nextafterl (long double __x, long double __y) throw () __attribute__ ((__const__)); | |
958 | ||
959 | extern long double nexttowardl (long double __x, long double __y) throw () __attribute__ ((__const__)); extern long double __nexttowardl (long double __x, long double __y) throw () __attribute__ ((__const__)); | |
960 | ||
961 | ||
962 | ||
963 | extern long double remainderl (long double __x, long double __y) throw (); extern long double __remainderl (long double __x, long double __y) throw (); | |
964 | ||
965 | ||
966 | ||
967 | extern long double scalbnl (long double __x, int __n) throw (); extern long double __scalbnl (long double __x, int __n) throw (); | |
968 | ||
969 | ||
970 | ||
971 | extern int ilogbl (long double __x) throw (); extern int __ilogbl (long double __x) throw (); | |
972 | ||
973 | ||
974 | ||
975 | ||
976 | extern long double scalblnl (long double __x, long int __n) throw (); extern long double __scalblnl (long double __x, long int __n) throw (); | |
977 | ||
978 | ||
979 | ||
980 | extern long double nearbyintl (long double __x) throw (); extern long double __nearbyintl (long double __x) throw (); | |
981 | ||
982 | ||
983 | ||
984 | extern long double roundl (long double __x) throw () __attribute__ ((__const__)); extern long double __roundl (long double __x) throw () __attribute__ ((__const__)); | |
985 | ||
986 | ||
987 | ||
988 | extern long double truncl (long double __x) throw () __attribute__ ((__const__)); extern long double __truncl (long double __x) throw () __attribute__ ((__const__)); | |
989 | ||
990 | ||
991 | ||
992 | ||
993 | extern long double remquol (long double __x, long double __y, int *__quo) throw (); extern long double __remquol (long double __x, long double __y, int *__quo) throw (); | |
994 | ||
995 | ||
996 | ||
997 | ||
998 | ||
999 | ||
1000 | extern long int lrintl (long double __x) throw (); extern long int __lrintl (long double __x) throw (); | |
1001 | __extension__ | |
1002 | extern long long int llrintl (long double __x) throw (); extern long long int __llrintl (long double __x) throw (); | |
1003 | ||
1004 | ||
1005 | ||
1006 | extern long int lroundl (long double __x) throw (); extern long int __lroundl (long double __x) throw (); | |
1007 | __extension__ | |
1008 | extern long long int llroundl (long double __x) throw (); extern long long int __llroundl (long double __x) throw (); | |
1009 | ||
1010 | ||
1011 | ||
1012 | extern long double fdiml (long double __x, long double __y) throw (); extern long double __fdiml (long double __x, long double __y) throw (); | |
1013 | ||
1014 | ||
1015 | extern long double fmaxl (long double __x, long double __y) throw () __attribute__ ((__const__)); extern long double __fmaxl (long double __x, long double __y) throw () __attribute__ ((__const__)); | |
1016 | ||
1017 | ||
1018 | extern long double fminl (long double __x, long double __y) throw () __attribute__ ((__const__)); extern long double __fminl (long double __x, long double __y) throw () __attribute__ ((__const__)); | |
1019 | ||
1020 | ||
1021 | ||
1022 | extern int __fpclassifyl (long double __value) throw () | |
1023 | __attribute__ ((__const__)); | |
1024 | ||
1025 | ||
1026 | extern int __signbitl (long double __value) throw () | |
1027 | __attribute__ ((__const__)); | |
1028 | ||
1029 | ||
1030 | ||
1031 | extern long double fmal (long double __x, long double __y, long double __z) throw (); extern long double __fmal (long double __x, long double __y, long double __z) throw (); | |
1032 | ||
1033 | ||
1034 | ||
1035 | ||
1036 | ||
1037 | ||
1038 | ||
1039 | ||
1040 | extern int __issignalingl (long double __value) throw () | |
1041 | __attribute__ ((__const__)); | |
1042 | ||
1043 | ||
1044 | ||
1045 | ||
1046 | extern long double scalbl (long double __x, long double __n) throw (); extern long double __scalbl (long double __x, long double __n) throw (); | |
1047 | # 147 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 2 3 4 | |
1048 | # 162 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 3 4 | |
1049 | extern int signgam; | |
1050 | # 203 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 3 4 | |
1051 | enum | |
1052 | { | |
1053 | FP_NAN = | |
1054 | ||
1055 | 0, | |
1056 | FP_INFINITE = | |
1057 | ||
1058 | 1, | |
1059 | FP_ZERO = | |
1060 | ||
1061 | 2, | |
1062 | FP_SUBNORMAL = | |
1063 | ||
1064 | 3, | |
1065 | FP_NORMAL = | |
1066 | ||
1067 | 4 | |
1068 | }; | |
1069 | # 315 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 3 4 | |
1070 | typedef enum | |
1071 | { | |
1072 | _IEEE_ = -1, | |
1073 | _SVID_, | |
1074 | _XOPEN_, | |
1075 | _POSIX_, | |
1076 | _ISOC_ | |
1077 | } _LIB_VERSION_TYPE; | |
1078 | ||
1079 | ||
1080 | ||
1081 | ||
1082 | extern _LIB_VERSION_TYPE _LIB_VERSION; | |
1083 | # 338 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 3 4 | |
1084 | struct __exception | |
1085 | ||
1086 | ||
1087 | ||
1088 | { | |
1089 | int type; | |
1090 | char *name; | |
1091 | double arg1; | |
1092 | double arg2; | |
1093 | double retval; | |
1094 | }; | |
1095 | ||
1096 | ||
1097 | extern int matherr (struct __exception *__exc) throw (); | |
1098 | # 440 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 3 4 | |
1099 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/mathinline.h" 1 3 4 | |
1100 | # 61 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/mathinline.h" 3 4 | |
1101 | extern __inline __attribute__ ((__gnu_inline__)) int | |
1102 | __attribute__ ((__leaf__)) __signbitf (float __x) throw () | |
1103 | { | |
1104 | ||
1105 | return __builtin_signbitf (__x); | |
1106 | ||
1107 | ||
1108 | ||
1109 | ||
1110 | } | |
1111 | extern __inline __attribute__ ((__gnu_inline__)) int | |
1112 | __attribute__ ((__leaf__)) __signbit (double __x) throw () | |
1113 | { | |
1114 | ||
1115 | return __builtin_signbit (__x); | |
1116 | ||
1117 | ||
1118 | ||
1119 | ||
1120 | } | |
1121 | ||
1122 | extern __inline __attribute__ ((__gnu_inline__)) int | |
1123 | __attribute__ ((__leaf__)) __signbitl (long double __x) throw () | |
1124 | { | |
1125 | return __signbit ((double) __x); | |
1126 | } | |
1127 | # 116 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/mathinline.h" 3 4 | |
1128 | extern __inline __attribute__ ((__gnu_inline__)) double fdim (double __x, double __y) throw (); | |
1129 | extern __inline __attribute__ ((__gnu_inline__)) double | |
1130 | __attribute__ ((__leaf__)) fdim (double __x, double __y) throw () | |
1131 | { | |
1132 | return __x <= __y ? 0 : __x - __y; | |
1133 | } | |
1134 | ||
1135 | extern __inline __attribute__ ((__gnu_inline__)) float fdimf (float __x, float __y) throw (); | |
1136 | extern __inline __attribute__ ((__gnu_inline__)) float | |
1137 | __attribute__ ((__leaf__)) fdimf (float __x, float __y) throw () | |
1138 | { | |
1139 | return __x <= __y ? 0 : __x - __y; | |
1140 | } | |
1141 | # 441 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 2 3 4 | |
1142 | # 502 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 3 4 | |
1143 | } | |
1144 | # 45 "jsxml.cpp" 2 | |
1145 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 1 3 4 | |
1146 | # 32 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 3 4 | |
1147 | # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stddef.h" 1 3 4 | |
1148 | # 212 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stddef.h" 3 4 | |
1149 | typedef long unsigned int size_t; | |
1150 | # 33 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 2 3 4 | |
1151 | ||
1152 | extern "C" { | |
1153 | ||
1154 | ||
1155 | ||
1156 | ||
1157 | ||
1158 | ||
1159 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/waitflags.h" 1 3 4 | |
1160 | # 42 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 2 3 4 | |
1161 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/waitstatus.h" 1 3 4 | |
1162 | # 64 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/waitstatus.h" 3 4 | |
1163 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/endian.h" 1 3 4 | |
1164 | # 36 "/usr/powerpc64-unknown-linux-gnu/usr/include/endian.h" 3 4 | |
1165 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/endian.h" 1 3 4 | |
1166 | # 37 "/usr/powerpc64-unknown-linux-gnu/usr/include/endian.h" 2 3 4 | |
1167 | # 60 "/usr/powerpc64-unknown-linux-gnu/usr/include/endian.h" 3 4 | |
1168 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/byteswap.h" 1 3 4 | |
1169 | # 27 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/byteswap.h" 3 4 | |
1170 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/types.h" 1 3 4 | |
1171 | # 27 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/types.h" 3 4 | |
1172 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/wordsize.h" 1 3 4 | |
1173 | # 28 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/types.h" 2 3 4 | |
1174 | ||
1175 | ||
1176 | typedef unsigned char __u_char; | |
1177 | typedef unsigned short int __u_short; | |
1178 | typedef unsigned int __u_int; | |
1179 | typedef unsigned long int __u_long; | |
1180 | ||
1181 | ||
1182 | typedef signed char __int8_t; | |
1183 | typedef unsigned char __uint8_t; | |
1184 | typedef signed short int __int16_t; | |
1185 | typedef unsigned short int __uint16_t; | |
1186 | typedef signed int __int32_t; | |
1187 | typedef unsigned int __uint32_t; | |
1188 | ||
1189 | typedef signed long int __int64_t; | |
1190 | typedef unsigned long int __uint64_t; | |
1191 | ||
1192 | ||
1193 | ||
1194 | ||
1195 | ||
1196 | ||
1197 | ||
1198 | typedef long int __quad_t; | |
1199 | typedef unsigned long int __u_quad_t; | |
1200 | # 121 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/types.h" 3 4 | |
1201 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/typesizes.h" 1 3 4 | |
1202 | # 122 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/types.h" 2 3 4 | |
1203 | ||
1204 | ||
1205 | typedef unsigned long int __dev_t; | |
1206 | typedef unsigned int __uid_t; | |
1207 | typedef unsigned int __gid_t; | |
1208 | typedef unsigned long int __ino_t; | |
1209 | typedef unsigned long int __ino64_t; | |
1210 | typedef unsigned int __mode_t; | |
1211 | typedef unsigned long int __nlink_t; | |
1212 | typedef long int __off_t; | |
1213 | typedef long int __off64_t; | |
1214 | typedef int __pid_t; | |
1215 | typedef struct { int __val[2]; } __fsid_t; | |
1216 | typedef long int __clock_t; | |
1217 | typedef unsigned long int __rlim_t; | |
1218 | typedef unsigned long int __rlim64_t; | |
1219 | typedef unsigned int __id_t; | |
1220 | typedef long int __time_t; | |
1221 | typedef unsigned int __useconds_t; | |
1222 | typedef long int __suseconds_t; | |
1223 | ||
1224 | typedef int __daddr_t; | |
1225 | typedef int __key_t; | |
1226 | ||
1227 | ||
1228 | typedef int __clockid_t; | |
1229 | ||
1230 | ||
1231 | typedef void * __timer_t; | |
1232 | ||
1233 | ||
1234 | typedef long int __blksize_t; | |
1235 | ||
1236 | ||
1237 | ||
1238 | ||
1239 | typedef long int __blkcnt_t; | |
1240 | typedef long int __blkcnt64_t; | |
1241 | ||
1242 | ||
1243 | typedef unsigned long int __fsblkcnt_t; | |
1244 | typedef unsigned long int __fsblkcnt64_t; | |
1245 | ||
1246 | ||
1247 | typedef unsigned long int __fsfilcnt_t; | |
1248 | typedef unsigned long int __fsfilcnt64_t; | |
1249 | ||
1250 | ||
1251 | typedef long int __fsword_t; | |
1252 | ||
1253 | typedef long int __ssize_t; | |
1254 | ||
1255 | ||
1256 | typedef long int __syscall_slong_t; | |
1257 | ||
1258 | typedef unsigned long int __syscall_ulong_t; | |
1259 | ||
1260 | ||
1261 | ||
1262 | typedef __off64_t __loff_t; | |
1263 | typedef __quad_t *__qaddr_t; | |
1264 | typedef char *__caddr_t; | |
1265 | ||
1266 | ||
1267 | typedef long int __intptr_t; | |
1268 | ||
1269 | ||
1270 | typedef unsigned int __socklen_t; | |
1271 | # 28 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/byteswap.h" 2 3 4 | |
1272 | ||
1273 | ||
1274 | ||
1275 | ||
1276 | ||
1277 | ||
1278 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/byteswap-16.h" 1 3 4 | |
1279 | # 35 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/byteswap.h" 2 3 4 | |
1280 | # 43 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/byteswap.h" 3 4 | |
1281 | static __inline unsigned int | |
1282 | __bswap_32 (unsigned int __bsx) | |
1283 | { | |
1284 | return __builtin_bswap32 (__bsx); | |
1285 | } | |
1286 | # 74 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/byteswap.h" 3 4 | |
1287 | static __inline __uint64_t | |
1288 | __bswap_64 (__uint64_t __bsx) | |
1289 | { | |
1290 | return __builtin_bswap64 (__bsx); | |
1291 | } | |
1292 | # 61 "/usr/powerpc64-unknown-linux-gnu/usr/include/endian.h" 2 3 4 | |
1293 | # 65 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/waitstatus.h" 2 3 4 | |
1294 | ||
1295 | union wait | |
1296 | { | |
1297 | int w_status; | |
1298 | struct | |
1299 | { | |
1300 | ||
1301 | ||
1302 | ||
1303 | ||
1304 | ||
1305 | ||
1306 | ||
1307 | unsigned int:16; | |
1308 | unsigned int __w_retcode:8; | |
1309 | unsigned int __w_coredump:1; | |
1310 | unsigned int __w_termsig:7; | |
1311 | ||
1312 | } __wait_terminated; | |
1313 | struct | |
1314 | { | |
1315 | ||
1316 | ||
1317 | ||
1318 | ||
1319 | ||
1320 | ||
1321 | unsigned int:16; | |
1322 | unsigned int __w_stopsig:8; | |
1323 | unsigned int __w_stopval:8; | |
1324 | ||
1325 | } __wait_stopped; | |
1326 | }; | |
1327 | # 43 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 2 3 4 | |
1328 | # 95 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 3 4 | |
1329 | ||
1330 | ||
1331 | typedef struct | |
1332 | { | |
1333 | int quot; | |
1334 | int rem; | |
1335 | } div_t; | |
1336 | ||
1337 | ||
1338 | ||
1339 | typedef struct | |
1340 | { | |
1341 | long int quot; | |
1342 | long int rem; | |
1343 | } ldiv_t; | |
1344 | ||
1345 | ||
1346 | ||
1347 | ||
1348 | ||
1349 | ||
1350 | ||
1351 | __extension__ typedef struct | |
1352 | { | |
1353 | long long int quot; | |
1354 | long long int rem; | |
1355 | } lldiv_t; | |
1356 | ||
1357 | ||
1358 | # 139 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 3 4 | |
1359 | extern size_t __ctype_get_mb_cur_max (void) throw () __attribute__ ((__warn_unused_result__)); | |
1360 | ||
1361 | ||
1362 | ||
1363 | ||
1364 | extern double atof (const char *__nptr) | |
1365 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__)); | |
1366 | ||
1367 | extern int atoi (const char *__nptr) | |
1368 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__)); | |
1369 | ||
1370 | extern long int atol (const char *__nptr) | |
1371 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__)); | |
1372 | ||
1373 | ||
1374 | ||
1375 | ||
1376 | ||
1377 | __extension__ extern long long int atoll (const char *__nptr) | |
1378 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__)); | |
1379 | ||
1380 | ||
1381 | ||
1382 | ||
1383 | ||
1384 | extern double strtod (const char *__restrict __nptr, | |
1385 | char **__restrict __endptr) | |
1386 | throw () __attribute__ ((__nonnull__ (1))); | |
1387 | ||
1388 | ||
1389 | ||
1390 | ||
1391 | ||
1392 | extern float strtof (const char *__restrict __nptr, | |
1393 | char **__restrict __endptr) throw () __attribute__ ((__nonnull__ (1))); | |
1394 | ||
1395 | extern long double strtold (const char *__restrict __nptr, | |
1396 | char **__restrict __endptr) | |
1397 | throw () __attribute__ ((__nonnull__ (1))); | |
1398 | ||
1399 | ||
1400 | ||
1401 | ||
1402 | ||
1403 | extern long int strtol (const char *__restrict __nptr, | |
1404 | char **__restrict __endptr, int __base) | |
1405 | throw () __attribute__ ((__nonnull__ (1))); | |
1406 | ||
1407 | extern unsigned long int strtoul (const char *__restrict __nptr, | |
1408 | char **__restrict __endptr, int __base) | |
1409 | throw () __attribute__ ((__nonnull__ (1))); | |
1410 | ||
1411 | ||
1412 | ||
1413 | ||
1414 | __extension__ | |
1415 | extern long long int strtoq (const char *__restrict __nptr, | |
1416 | char **__restrict __endptr, int __base) | |
1417 | throw () __attribute__ ((__nonnull__ (1))); | |
1418 | ||
1419 | __extension__ | |
1420 | extern unsigned long long int strtouq (const char *__restrict __nptr, | |
1421 | char **__restrict __endptr, int __base) | |
1422 | throw () __attribute__ ((__nonnull__ (1))); | |
1423 | ||
1424 | ||
1425 | ||
1426 | ||
1427 | ||
1428 | __extension__ | |
1429 | extern long long int strtoll (const char *__restrict __nptr, | |
1430 | char **__restrict __endptr, int __base) | |
1431 | throw () __attribute__ ((__nonnull__ (1))); | |
1432 | ||
1433 | __extension__ | |
1434 | extern unsigned long long int strtoull (const char *__restrict __nptr, | |
1435 | char **__restrict __endptr, int __base) | |
1436 | throw () __attribute__ ((__nonnull__ (1))); | |
1437 | ||
1438 | # 235 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 3 4 | |
1439 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/xlocale.h" 1 3 4 | |
1440 | # 27 "/usr/powerpc64-unknown-linux-gnu/usr/include/xlocale.h" 3 4 | |
1441 | typedef struct __locale_struct | |
1442 | { | |
1443 | ||
1444 | struct __locale_data *__locales[13]; | |
1445 | ||
1446 | ||
1447 | const unsigned short int *__ctype_b; | |
1448 | const int *__ctype_tolower; | |
1449 | const int *__ctype_toupper; | |
1450 | ||
1451 | ||
1452 | const char *__names[13]; | |
1453 | } *__locale_t; | |
1454 | ||
1455 | ||
1456 | typedef __locale_t locale_t; | |
1457 | # 236 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 2 3 4 | |
1458 | ||
1459 | ||
1460 | ||
1461 | extern long int strtol_l (const char *__restrict __nptr, | |
1462 | char **__restrict __endptr, int __base, | |
1463 | __locale_t __loc) throw () __attribute__ ((__nonnull__ (1, 4))); | |
1464 | ||
1465 | extern unsigned long int strtoul_l (const char *__restrict __nptr, | |
1466 | char **__restrict __endptr, | |
1467 | int __base, __locale_t __loc) | |
1468 | throw () __attribute__ ((__nonnull__ (1, 4))); | |
1469 | ||
1470 | __extension__ | |
1471 | extern long long int strtoll_l (const char *__restrict __nptr, | |
1472 | char **__restrict __endptr, int __base, | |
1473 | __locale_t __loc) | |
1474 | throw () __attribute__ ((__nonnull__ (1, 4))); | |
1475 | ||
1476 | __extension__ | |
1477 | extern unsigned long long int strtoull_l (const char *__restrict __nptr, | |
1478 | char **__restrict __endptr, | |
1479 | int __base, __locale_t __loc) | |
1480 | throw () __attribute__ ((__nonnull__ (1, 4))); | |
1481 | ||
1482 | extern double strtod_l (const char *__restrict __nptr, | |
1483 | char **__restrict __endptr, __locale_t __loc) | |
1484 | throw () __attribute__ ((__nonnull__ (1, 3))); | |
1485 | ||
1486 | extern float strtof_l (const char *__restrict __nptr, | |
1487 | char **__restrict __endptr, __locale_t __loc) | |
1488 | throw () __attribute__ ((__nonnull__ (1, 3))); | |
1489 | ||
1490 | extern long double strtold_l (const char *__restrict __nptr, | |
1491 | char **__restrict __endptr, | |
1492 | __locale_t __loc) | |
1493 | throw () __attribute__ ((__nonnull__ (1, 3))); | |
1494 | ||
1495 | ||
1496 | ||
1497 | ||
1498 | ||
1499 | extern __inline __attribute__ ((__gnu_inline__)) int | |
1500 | __attribute__ ((__leaf__)) atoi (const char *__nptr) throw () | |
1501 | { | |
1502 | return (int) strtol (__nptr, (char **) __null, 10); | |
1503 | } | |
1504 | extern __inline __attribute__ ((__gnu_inline__)) long int | |
1505 | __attribute__ ((__leaf__)) atol (const char *__nptr) throw () | |
1506 | { | |
1507 | return strtol (__nptr, (char **) __null, 10); | |
1508 | } | |
1509 | ||
1510 | ||
1511 | ||
1512 | ||
1513 | __extension__ extern __inline __attribute__ ((__gnu_inline__)) long long int | |
1514 | __attribute__ ((__leaf__)) atoll (const char *__nptr) throw () | |
1515 | { | |
1516 | return strtoll (__nptr, (char **) __null, 10); | |
1517 | } | |
1518 | ||
1519 | # 305 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 3 4 | |
1520 | extern char *l64a (long int __n) throw () __attribute__ ((__warn_unused_result__)); | |
1521 | ||
1522 | ||
1523 | extern long int a64l (const char *__s) | |
1524 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__)); | |
1525 | ||
1526 | ||
1527 | ||
1528 | ||
1529 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/types.h" 1 3 4 | |
1530 | # 27 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/types.h" 3 4 | |
1531 | extern "C" { | |
1532 | ||
1533 | ||
1534 | ||
1535 | ||
1536 | ||
1537 | typedef __u_char u_char; | |
1538 | typedef __u_short u_short; | |
1539 | typedef __u_int u_int; | |
1540 | typedef __u_long u_long; | |
1541 | typedef __quad_t quad_t; | |
1542 | typedef __u_quad_t u_quad_t; | |
1543 | typedef __fsid_t fsid_t; | |
1544 | ||
1545 | ||
1546 | ||
1547 | ||
1548 | typedef __loff_t loff_t; | |
1549 | ||
1550 | ||
1551 | ||
1552 | typedef __ino_t ino_t; | |
1553 | ||
1554 | ||
1555 | ||
1556 | ||
1557 | ||
1558 | ||
1559 | typedef __ino64_t ino64_t; | |
1560 | ||
1561 | ||
1562 | ||
1563 | ||
1564 | typedef __dev_t dev_t; | |
1565 | ||
1566 | ||
1567 | ||
1568 | ||
1569 | typedef __gid_t gid_t; | |
1570 | ||
1571 | ||
1572 | ||
1573 | ||
1574 | typedef __mode_t mode_t; | |
1575 | ||
1576 | ||
1577 | ||
1578 | ||
1579 | typedef __nlink_t nlink_t; | |
1580 | ||
1581 | ||
1582 | ||
1583 | ||
1584 | typedef __uid_t uid_t; | |
1585 | ||
1586 | ||
1587 | ||
1588 | ||
1589 | ||
1590 | typedef __off_t off_t; | |
1591 | ||
1592 | ||
1593 | ||
1594 | ||
1595 | ||
1596 | ||
1597 | typedef __off64_t off64_t; | |
1598 | ||
1599 | ||
1600 | ||
1601 | ||
1602 | typedef __pid_t pid_t; | |
1603 | ||
1604 | ||
1605 | ||
1606 | ||
1607 | ||
1608 | typedef __id_t id_t; | |
1609 | ||
1610 | ||
1611 | ||
1612 | ||
1613 | typedef __ssize_t ssize_t; | |
1614 | ||
1615 | ||
1616 | ||
1617 | ||
1618 | ||
1619 | typedef __daddr_t daddr_t; | |
1620 | typedef __caddr_t caddr_t; | |
1621 | ||
1622 | ||
1623 | ||
1624 | ||
1625 | ||
1626 | typedef __key_t key_t; | |
1627 | # 132 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/types.h" 3 4 | |
1628 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/time.h" 1 3 4 | |
1629 | # 57 "/usr/powerpc64-unknown-linux-gnu/usr/include/time.h" 3 4 | |
1630 | ||
1631 | ||
1632 | typedef __clock_t clock_t; | |
1633 | ||
1634 | ||
1635 | ||
1636 | # 73 "/usr/powerpc64-unknown-linux-gnu/usr/include/time.h" 3 4 | |
1637 | ||
1638 | ||
1639 | typedef __time_t time_t; | |
1640 | ||
1641 | ||
1642 | ||
1643 | # 91 "/usr/powerpc64-unknown-linux-gnu/usr/include/time.h" 3 4 | |
1644 | typedef __clockid_t clockid_t; | |
1645 | # 103 "/usr/powerpc64-unknown-linux-gnu/usr/include/time.h" 3 4 | |
1646 | typedef __timer_t timer_t; | |
1647 | # 133 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/types.h" 2 3 4 | |
1648 | ||
1649 | ||
1650 | ||
1651 | typedef __useconds_t useconds_t; | |
1652 | ||
1653 | ||
1654 | ||
1655 | typedef __suseconds_t suseconds_t; | |
1656 | ||
1657 | ||
1658 | ||
1659 | ||
1660 | ||
1661 | # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stddef.h" 1 3 4 | |
1662 | # 147 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/types.h" 2 3 4 | |
1663 | ||
1664 | ||
1665 | ||
1666 | typedef unsigned long int ulong; | |
1667 | typedef unsigned short int ushort; | |
1668 | typedef unsigned int uint; | |
1669 | # 194 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/types.h" 3 4 | |
1670 | typedef int int8_t __attribute__ ((__mode__ (__QI__))); | |
1671 | typedef int int16_t __attribute__ ((__mode__ (__HI__))); | |
1672 | typedef int int32_t __attribute__ ((__mode__ (__SI__))); | |
1673 | typedef int int64_t __attribute__ ((__mode__ (__DI__))); | |
1674 | ||
1675 | ||
1676 | typedef unsigned int u_int8_t __attribute__ ((__mode__ (__QI__))); | |
1677 | typedef unsigned int u_int16_t __attribute__ ((__mode__ (__HI__))); | |
1678 | typedef unsigned int u_int32_t __attribute__ ((__mode__ (__SI__))); | |
1679 | typedef unsigned int u_int64_t __attribute__ ((__mode__ (__DI__))); | |
1680 | ||
1681 | typedef int register_t __attribute__ ((__mode__ (__word__))); | |
1682 | # 219 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/types.h" 3 4 | |
1683 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/select.h" 1 3 4 | |
1684 | # 30 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/select.h" 3 4 | |
1685 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/select.h" 1 3 4 | |
1686 | # 31 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/select.h" 2 3 4 | |
1687 | ||
1688 | ||
1689 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/sigset.h" 1 3 4 | |
1690 | # 22 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/sigset.h" 3 4 | |
1691 | typedef int __sig_atomic_t; | |
1692 | ||
1693 | ||
1694 | ||
1695 | ||
1696 | typedef struct | |
1697 | { | |
1698 | unsigned long int __val[(1024 / (8 * sizeof (unsigned long int)))]; | |
1699 | } __sigset_t; | |
1700 | # 34 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/select.h" 2 3 4 | |
1701 | ||
1702 | ||
1703 | ||
1704 | typedef __sigset_t sigset_t; | |
1705 | ||
1706 | ||
1707 | ||
1708 | ||
1709 | ||
1710 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/time.h" 1 3 4 | |
1711 | # 120 "/usr/powerpc64-unknown-linux-gnu/usr/include/time.h" 3 4 | |
1712 | struct timespec | |
1713 | { | |
1714 | __time_t tv_sec; | |
1715 | __syscall_slong_t tv_nsec; | |
1716 | }; | |
1717 | # 44 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/select.h" 2 3 4 | |
1718 | ||
1719 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/time.h" 1 3 4 | |
1720 | # 30 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/time.h" 3 4 | |
1721 | struct timeval | |
1722 | { | |
1723 | __time_t tv_sec; | |
1724 | __suseconds_t tv_usec; | |
1725 | }; | |
1726 | # 46 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/select.h" 2 3 4 | |
1727 | # 54 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/select.h" 3 4 | |
1728 | typedef long int __fd_mask; | |
1729 | # 64 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/select.h" 3 4 | |
1730 | typedef struct | |
1731 | { | |
1732 | ||
1733 | ||
1734 | ||
1735 | __fd_mask fds_bits[1024 / (8 * (int) sizeof (__fd_mask))]; | |
1736 | ||
1737 | ||
1738 | ||
1739 | ||
1740 | ||
1741 | } fd_set; | |
1742 | ||
1743 | ||
1744 | ||
1745 | ||
1746 | ||
1747 | ||
1748 | typedef __fd_mask fd_mask; | |
1749 | # 96 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/select.h" 3 4 | |
1750 | extern "C" { | |
1751 | # 106 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/select.h" 3 4 | |
1752 | extern int select (int __nfds, fd_set *__restrict __readfds, | |
1753 | fd_set *__restrict __writefds, | |
1754 | fd_set *__restrict __exceptfds, | |
1755 | struct timeval *__restrict __timeout); | |
1756 | # 118 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/select.h" 3 4 | |
1757 | extern int pselect (int __nfds, fd_set *__restrict __readfds, | |
1758 | fd_set *__restrict __writefds, | |
1759 | fd_set *__restrict __exceptfds, | |
1760 | const struct timespec *__restrict __timeout, | |
1761 | const __sigset_t *__restrict __sigmask); | |
1762 | ||
1763 | ||
1764 | ||
1765 | ||
1766 | ||
1767 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/select2.h" 1 3 4 | |
1768 | # 24 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/select2.h" 3 4 | |
1769 | extern long int __fdelt_chk (long int __d); | |
1770 | extern long int __fdelt_warn (long int __d) | |
1771 | __attribute__((__warning__ ("bit outside of fd_set selected"))); | |
1772 | # 129 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/select.h" 2 3 4 | |
1773 | ||
1774 | ||
1775 | } | |
1776 | # 220 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/types.h" 2 3 4 | |
1777 | ||
1778 | ||
1779 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/sysmacros.h" 1 3 4 | |
1780 | # 24 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/sysmacros.h" 3 4 | |
1781 | extern "C" { | |
1782 | ||
1783 | __extension__ | |
1784 | extern unsigned int gnu_dev_major (unsigned long long int __dev) | |
1785 | throw () __attribute__ ((__const__)); | |
1786 | __extension__ | |
1787 | extern unsigned int gnu_dev_minor (unsigned long long int __dev) | |
1788 | throw () __attribute__ ((__const__)); | |
1789 | __extension__ | |
1790 | extern unsigned long long int gnu_dev_makedev (unsigned int __major, | |
1791 | unsigned int __minor) | |
1792 | throw () __attribute__ ((__const__)); | |
1793 | ||
1794 | ||
1795 | __extension__ extern __inline __attribute__ ((__gnu_inline__)) __attribute__ ((__const__)) unsigned int | |
1796 | __attribute__ ((__leaf__)) gnu_dev_major (unsigned long long int __dev) throw () | |
1797 | { | |
1798 | return ((__dev >> 8) & 0xfff) | ((unsigned int) (__dev >> 32) & ~0xfff); | |
1799 | } | |
1800 | ||
1801 | __extension__ extern __inline __attribute__ ((__gnu_inline__)) __attribute__ ((__const__)) unsigned int | |
1802 | __attribute__ ((__leaf__)) gnu_dev_minor (unsigned long long int __dev) throw () | |
1803 | { | |
1804 | return (__dev & 0xff) | ((unsigned int) (__dev >> 12) & ~0xff); | |
1805 | } | |
1806 | ||
1807 | __extension__ extern __inline __attribute__ ((__gnu_inline__)) __attribute__ ((__const__)) unsigned long long int | |
1808 | __attribute__ ((__leaf__)) gnu_dev_makedev (unsigned int __major, unsigned int __minor) throw () | |
1809 | { | |
1810 | return ((__minor & 0xff) | ((__major & 0xfff) << 8) | |
1811 | | (((unsigned long long int) (__minor & ~0xff)) << 12) | |
1812 | | (((unsigned long long int) (__major & ~0xfff)) << 32)); | |
1813 | } | |
1814 | ||
1815 | } | |
1816 | # 223 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/types.h" 2 3 4 | |
1817 | ||
1818 | ||
1819 | ||
1820 | ||
1821 | ||
1822 | typedef __blksize_t blksize_t; | |
1823 | ||
1824 | ||
1825 | ||
1826 | ||
1827 | ||
1828 | ||
1829 | typedef __blkcnt_t blkcnt_t; | |
1830 | ||
1831 | ||
1832 | ||
1833 | typedef __fsblkcnt_t fsblkcnt_t; | |
1834 | ||
1835 | ||
1836 | ||
1837 | typedef __fsfilcnt_t fsfilcnt_t; | |
1838 | # 262 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/types.h" 3 4 | |
1839 | typedef __blkcnt64_t blkcnt64_t; | |
1840 | typedef __fsblkcnt64_t fsblkcnt64_t; | |
1841 | typedef __fsfilcnt64_t fsfilcnt64_t; | |
1842 | ||
1843 | ||
1844 | ||
1845 | ||
1846 | ||
1847 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/pthreadtypes.h" 1 3 4 | |
1848 | # 22 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/pthreadtypes.h" 3 4 | |
1849 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/wordsize.h" 1 3 4 | |
1850 | # 23 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/pthreadtypes.h" 2 3 4 | |
1851 | # 49 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/pthreadtypes.h" 3 4 | |
1852 | typedef unsigned long int pthread_t; | |
1853 | ||
1854 | ||
1855 | union pthread_attr_t | |
1856 | { | |
1857 | char __size[56]; | |
1858 | long int __align; | |
1859 | }; | |
1860 | ||
1861 | typedef union pthread_attr_t pthread_attr_t; | |
1862 | ||
1863 | ||
1864 | ||
1865 | ||
1866 | ||
1867 | typedef struct __pthread_internal_list | |
1868 | { | |
1869 | struct __pthread_internal_list *__prev; | |
1870 | struct __pthread_internal_list *__next; | |
1871 | } __pthread_list_t; | |
1872 | # 79 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/pthreadtypes.h" 3 4 | |
1873 | typedef union | |
1874 | { | |
1875 | struct __pthread_mutex_s | |
1876 | { | |
1877 | int __lock; | |
1878 | unsigned int __count; | |
1879 | int __owner; | |
1880 | ||
1881 | unsigned int __nusers; | |
1882 | ||
1883 | ||
1884 | ||
1885 | int __kind; | |
1886 | ||
1887 | short __spins; | |
1888 | short __elision; | |
1889 | __pthread_list_t __list; | |
1890 | # 113 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/pthreadtypes.h" 3 4 | |
1891 | } __data; | |
1892 | char __size[40]; | |
1893 | long int __align; | |
1894 | } pthread_mutex_t; | |
1895 | ||
1896 | typedef union | |
1897 | { | |
1898 | char __size[4]; | |
1899 | int __align; | |
1900 | } pthread_mutexattr_t; | |
1901 | ||
1902 | ||
1903 | ||
1904 | ||
1905 | typedef union | |
1906 | { | |
1907 | struct | |
1908 | { | |
1909 | int __lock; | |
1910 | unsigned int __futex; | |
1911 | __extension__ unsigned long long int __total_seq; | |
1912 | __extension__ unsigned long long int __wakeup_seq; | |
1913 | __extension__ unsigned long long int __woken_seq; | |
1914 | void *__mutex; | |
1915 | unsigned int __nwaiters; | |
1916 | unsigned int __broadcast_seq; | |
1917 | } __data; | |
1918 | char __size[48]; | |
1919 | __extension__ long long int __align; | |
1920 | } pthread_cond_t; | |
1921 | ||
1922 | typedef union | |
1923 | { | |
1924 | char __size[4]; | |
1925 | int __align; | |
1926 | } pthread_condattr_t; | |
1927 | ||
1928 | ||
1929 | ||
1930 | typedef unsigned int pthread_key_t; | |
1931 | ||
1932 | ||
1933 | ||
1934 | typedef int pthread_once_t; | |
1935 | ||
1936 | ||
1937 | ||
1938 | ||
1939 | ||
1940 | typedef union | |
1941 | { | |
1942 | ||
1943 | struct | |
1944 | { | |
1945 | int __lock; | |
1946 | unsigned int __nr_readers; | |
1947 | unsigned int __readers_wakeup; | |
1948 | unsigned int __writer_wakeup; | |
1949 | unsigned int __nr_readers_queued; | |
1950 | unsigned int __nr_writers_queued; | |
1951 | int __writer; | |
1952 | int __shared; | |
1953 | unsigned char __rwelision; | |
1954 | unsigned char __pad1[7]; | |
1955 | unsigned long int __pad2; | |
1956 | ||
1957 | ||
1958 | unsigned int __flags; | |
1959 | ||
1960 | } __data; | |
1961 | # 202 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/pthreadtypes.h" 3 4 | |
1962 | char __size[56]; | |
1963 | long int __align; | |
1964 | } pthread_rwlock_t; | |
1965 | ||
1966 | ||
1967 | typedef union | |
1968 | { | |
1969 | char __size[8]; | |
1970 | long int __align; | |
1971 | } pthread_rwlockattr_t; | |
1972 | ||
1973 | ||
1974 | ||
1975 | ||
1976 | ||
1977 | typedef volatile int pthread_spinlock_t; | |
1978 | ||
1979 | ||
1980 | ||
1981 | ||
1982 | typedef union | |
1983 | { | |
1984 | char __size[32]; | |
1985 | long int __align; | |
1986 | } pthread_barrier_t; | |
1987 | ||
1988 | typedef union | |
1989 | { | |
1990 | char __size[4]; | |
1991 | int __align; | |
1992 | } pthread_barrierattr_t; | |
1993 | # 271 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/types.h" 2 3 4 | |
1994 | ||
1995 | ||
1996 | } | |
1997 | # 315 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 2 3 4 | |
1998 | ||
1999 | ||
2000 | ||
2001 | ||
2002 | ||
2003 | ||
2004 | extern long int random (void) throw (); | |
2005 | ||
2006 | ||
2007 | extern void srandom (unsigned int __seed) throw (); | |
2008 | ||
2009 | ||
2010 | ||
2011 | ||
2012 | ||
2013 | extern char *initstate (unsigned int __seed, char *__statebuf, | |
2014 | size_t __statelen) throw () __attribute__ ((__nonnull__ (2))); | |
2015 | ||
2016 | ||
2017 | ||
2018 | extern char *setstate (char *__statebuf) throw () __attribute__ ((__nonnull__ (1))); | |
2019 | ||
2020 | ||
2021 | ||
2022 | ||
2023 | ||
2024 | ||
2025 | ||
2026 | struct random_data | |
2027 | { | |
2028 | int32_t *fptr; | |
2029 | int32_t *rptr; | |
2030 | int32_t *state; | |
2031 | int rand_type; | |
2032 | int rand_deg; | |
2033 | int rand_sep; | |
2034 | int32_t *end_ptr; | |
2035 | }; | |
2036 | ||
2037 | extern int random_r (struct random_data *__restrict __buf, | |
2038 | int32_t *__restrict __result) throw () __attribute__ ((__nonnull__ (1, 2))); | |
2039 | ||
2040 | extern int srandom_r (unsigned int __seed, struct random_data *__buf) | |
2041 | throw () __attribute__ ((__nonnull__ (2))); | |
2042 | ||
2043 | extern int initstate_r (unsigned int __seed, char *__restrict __statebuf, | |
2044 | size_t __statelen, | |
2045 | struct random_data *__restrict __buf) | |
2046 | throw () __attribute__ ((__nonnull__ (2, 4))); | |
2047 | ||
2048 | extern int setstate_r (char *__restrict __statebuf, | |
2049 | struct random_data *__restrict __buf) | |
2050 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
2051 | ||
2052 | ||
2053 | ||
2054 | ||
2055 | ||
2056 | ||
2057 | extern int rand (void) throw (); | |
2058 | ||
2059 | extern void srand (unsigned int __seed) throw (); | |
2060 | ||
2061 | ||
2062 | ||
2063 | ||
2064 | extern int rand_r (unsigned int *__seed) throw (); | |
2065 | ||
2066 | ||
2067 | ||
2068 | ||
2069 | ||
2070 | ||
2071 | ||
2072 | extern double drand48 (void) throw (); | |
2073 | extern double erand48 (unsigned short int __xsubi[3]) throw () __attribute__ ((__nonnull__ (1))); | |
2074 | ||
2075 | ||
2076 | extern long int lrand48 (void) throw (); | |
2077 | extern long int nrand48 (unsigned short int __xsubi[3]) | |
2078 | throw () __attribute__ ((__nonnull__ (1))); | |
2079 | ||
2080 | ||
2081 | extern long int mrand48 (void) throw (); | |
2082 | extern long int jrand48 (unsigned short int __xsubi[3]) | |
2083 | throw () __attribute__ ((__nonnull__ (1))); | |
2084 | ||
2085 | ||
2086 | extern void srand48 (long int __seedval) throw (); | |
2087 | extern unsigned short int *seed48 (unsigned short int __seed16v[3]) | |
2088 | throw () __attribute__ ((__nonnull__ (1))); | |
2089 | extern void lcong48 (unsigned short int __param[7]) throw () __attribute__ ((__nonnull__ (1))); | |
2090 | ||
2091 | ||
2092 | ||
2093 | ||
2094 | ||
2095 | struct drand48_data | |
2096 | { | |
2097 | unsigned short int __x[3]; | |
2098 | unsigned short int __old_x[3]; | |
2099 | unsigned short int __c; | |
2100 | unsigned short int __init; | |
2101 | __extension__ unsigned long long int __a; | |
2102 | ||
2103 | }; | |
2104 | ||
2105 | ||
2106 | extern int drand48_r (struct drand48_data *__restrict __buffer, | |
2107 | double *__restrict __result) throw () __attribute__ ((__nonnull__ (1, 2))); | |
2108 | extern int erand48_r (unsigned short int __xsubi[3], | |
2109 | struct drand48_data *__restrict __buffer, | |
2110 | double *__restrict __result) throw () __attribute__ ((__nonnull__ (1, 2))); | |
2111 | ||
2112 | ||
2113 | extern int lrand48_r (struct drand48_data *__restrict __buffer, | |
2114 | long int *__restrict __result) | |
2115 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
2116 | extern int nrand48_r (unsigned short int __xsubi[3], | |
2117 | struct drand48_data *__restrict __buffer, | |
2118 | long int *__restrict __result) | |
2119 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
2120 | ||
2121 | ||
2122 | extern int mrand48_r (struct drand48_data *__restrict __buffer, | |
2123 | long int *__restrict __result) | |
2124 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
2125 | extern int jrand48_r (unsigned short int __xsubi[3], | |
2126 | struct drand48_data *__restrict __buffer, | |
2127 | long int *__restrict __result) | |
2128 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
2129 | ||
2130 | ||
2131 | extern int srand48_r (long int __seedval, struct drand48_data *__buffer) | |
2132 | throw () __attribute__ ((__nonnull__ (2))); | |
2133 | ||
2134 | extern int seed48_r (unsigned short int __seed16v[3], | |
2135 | struct drand48_data *__buffer) throw () __attribute__ ((__nonnull__ (1, 2))); | |
2136 | ||
2137 | extern int lcong48_r (unsigned short int __param[7], | |
2138 | struct drand48_data *__buffer) | |
2139 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
2140 | ||
2141 | ||
2142 | ||
2143 | ||
2144 | ||
2145 | ||
2146 | ||
2147 | ||
2148 | ||
2149 | extern void *malloc (size_t __size) throw () __attribute__ ((__malloc__)) __attribute__ ((__warn_unused_result__)); | |
2150 | ||
2151 | extern void *calloc (size_t __nmemb, size_t __size) | |
2152 | throw () __attribute__ ((__malloc__)) __attribute__ ((__warn_unused_result__)); | |
2153 | ||
2154 | ||
2155 | ||
2156 | ||
2157 | ||
2158 | ||
2159 | ||
2160 | ||
2161 | ||
2162 | ||
2163 | extern void *realloc (void *__ptr, size_t __size) | |
2164 | throw () __attribute__ ((__warn_unused_result__)); | |
2165 | ||
2166 | extern void free (void *__ptr) throw (); | |
2167 | ||
2168 | ||
2169 | ||
2170 | ||
2171 | extern void cfree (void *__ptr) throw (); | |
2172 | ||
2173 | ||
2174 | ||
2175 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/alloca.h" 1 3 4 | |
2176 | # 24 "/usr/powerpc64-unknown-linux-gnu/usr/include/alloca.h" 3 4 | |
2177 | # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stddef.h" 1 3 4 | |
2178 | # 25 "/usr/powerpc64-unknown-linux-gnu/usr/include/alloca.h" 2 3 4 | |
2179 | ||
2180 | extern "C" { | |
2181 | ||
2182 | ||
2183 | ||
2184 | ||
2185 | ||
2186 | extern void *alloca (size_t __size) throw (); | |
2187 | ||
2188 | ||
2189 | ||
2190 | ||
2191 | ||
2192 | } | |
2193 | # 493 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 2 3 4 | |
2194 | ||
2195 | ||
2196 | ||
2197 | ||
2198 | ||
2199 | extern void *valloc (size_t __size) throw () __attribute__ ((__malloc__)) __attribute__ ((__warn_unused_result__)); | |
2200 | ||
2201 | ||
2202 | ||
2203 | ||
2204 | extern int posix_memalign (void **__memptr, size_t __alignment, size_t __size) | |
2205 | throw () __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__)); | |
2206 | ||
2207 | ||
2208 | ||
2209 | ||
2210 | extern void *aligned_alloc (size_t __alignment, size_t __size) | |
2211 | throw () __attribute__ ((__malloc__)) __attribute__ ((__alloc_size__ (2))) __attribute__ ((__warn_unused_result__)); | |
2212 | ||
2213 | ||
2214 | ||
2215 | ||
2216 | extern void abort (void) throw () __attribute__ ((__noreturn__)); | |
2217 | ||
2218 | ||
2219 | ||
2220 | extern int atexit (void (*__func) (void)) throw () __attribute__ ((__nonnull__ (1))); | |
2221 | ||
2222 | ||
2223 | ||
2224 | ||
2225 | extern "C++" int at_quick_exit (void (*__func) (void)) | |
2226 | throw () __asm ("at_quick_exit") __attribute__ ((__nonnull__ (1))); | |
2227 | ||
2228 | ||
2229 | ||
2230 | ||
2231 | ||
2232 | ||
2233 | ||
2234 | ||
2235 | ||
2236 | extern int on_exit (void (*__func) (int __status, void *__arg), void *__arg) | |
2237 | throw () __attribute__ ((__nonnull__ (1))); | |
2238 | ||
2239 | ||
2240 | ||
2241 | ||
2242 | ||
2243 | ||
2244 | extern void exit (int __status) throw () __attribute__ ((__noreturn__)); | |
2245 | ||
2246 | ||
2247 | ||
2248 | ||
2249 | ||
2250 | extern void quick_exit (int __status) throw () __attribute__ ((__noreturn__)); | |
2251 | ||
2252 | ||
2253 | ||
2254 | ||
2255 | ||
2256 | ||
2257 | ||
2258 | extern void _Exit (int __status) throw () __attribute__ ((__noreturn__)); | |
2259 | ||
2260 | ||
2261 | ||
2262 | ||
2263 | ||
2264 | ||
2265 | extern char *getenv (const char *__name) throw () __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__)); | |
2266 | ||
2267 | ||
2268 | ||
2269 | ||
2270 | ||
2271 | extern char *secure_getenv (const char *__name) | |
2272 | throw () __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__)); | |
2273 | ||
2274 | ||
2275 | ||
2276 | ||
2277 | ||
2278 | ||
2279 | extern int putenv (char *__string) throw () __attribute__ ((__nonnull__ (1))); | |
2280 | ||
2281 | ||
2282 | ||
2283 | ||
2284 | ||
2285 | extern int setenv (const char *__name, const char *__value, int __replace) | |
2286 | throw () __attribute__ ((__nonnull__ (2))); | |
2287 | ||
2288 | ||
2289 | extern int unsetenv (const char *__name) throw () __attribute__ ((__nonnull__ (1))); | |
2290 | ||
2291 | ||
2292 | ||
2293 | ||
2294 | ||
2295 | ||
2296 | extern int clearenv (void) throw (); | |
2297 | # 606 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 3 4 | |
2298 | extern char *mktemp (char *__template) throw () __attribute__ ((__nonnull__ (1))); | |
2299 | # 619 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 3 4 | |
2300 | extern int mkstemp (char *__template) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__)); | |
2301 | # 629 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 3 4 | |
2302 | extern int mkstemp64 (char *__template) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__)); | |
2303 | # 641 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 3 4 | |
2304 | extern int mkstemps (char *__template, int __suffixlen) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__)); | |
2305 | # 651 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 3 4 | |
2306 | extern int mkstemps64 (char *__template, int __suffixlen) | |
2307 | __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__)); | |
2308 | # 662 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 3 4 | |
2309 | extern char *mkdtemp (char *__template) throw () __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__)); | |
2310 | # 673 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 3 4 | |
2311 | extern int mkostemp (char *__template, int __flags) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__)); | |
2312 | # 683 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 3 4 | |
2313 | extern int mkostemp64 (char *__template, int __flags) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__)); | |
2314 | # 693 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 3 4 | |
2315 | extern int mkostemps (char *__template, int __suffixlen, int __flags) | |
2316 | __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__)); | |
2317 | # 705 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 3 4 | |
2318 | extern int mkostemps64 (char *__template, int __suffixlen, int __flags) | |
2319 | __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__)); | |
2320 | ||
2321 | ||
2322 | ||
2323 | ||
2324 | ||
2325 | ||
2326 | ||
2327 | ||
2328 | ||
2329 | extern int system (const char *__command) __attribute__ ((__warn_unused_result__)); | |
2330 | ||
2331 | ||
2332 | ||
2333 | ||
2334 | ||
2335 | ||
2336 | extern char *canonicalize_file_name (const char *__name) | |
2337 | throw () __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__)); | |
2338 | # 733 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 3 4 | |
2339 | extern char *realpath (const char *__restrict __name, | |
2340 | char *__restrict __resolved) throw () __attribute__ ((__warn_unused_result__)); | |
2341 | ||
2342 | ||
2343 | ||
2344 | ||
2345 | ||
2346 | ||
2347 | typedef int (*__compar_fn_t) (const void *, const void *); | |
2348 | ||
2349 | ||
2350 | typedef __compar_fn_t comparison_fn_t; | |
2351 | ||
2352 | ||
2353 | ||
2354 | typedef int (*__compar_d_fn_t) (const void *, const void *, void *); | |
2355 | ||
2356 | ||
2357 | ||
2358 | ||
2359 | ||
2360 | extern void *bsearch (const void *__key, const void *__base, | |
2361 | size_t __nmemb, size_t __size, __compar_fn_t __compar) | |
2362 | __attribute__ ((__nonnull__ (1, 2, 5))) __attribute__ ((__warn_unused_result__)); | |
2363 | ||
2364 | ||
2365 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/stdlib-bsearch.h" 1 3 4 | |
2366 | # 19 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/stdlib-bsearch.h" 3 4 | |
2367 | extern __inline __attribute__ ((__gnu_inline__)) void * | |
2368 | bsearch (const void *__key, const void *__base, size_t __nmemb, size_t __size, | |
2369 | __compar_fn_t __compar) | |
2370 | { | |
2371 | size_t __l, __u, __idx; | |
2372 | const void *__p; | |
2373 | int __comparison; | |
2374 | ||
2375 | __l = 0; | |
2376 | __u = __nmemb; | |
2377 | while (__l < __u) | |
2378 | { | |
2379 | __idx = (__l + __u) / 2; | |
2380 | __p = (void *) (((const char *) __base) + (__idx * __size)); | |
2381 | __comparison = (*__compar) (__key, __p); | |
2382 | if (__comparison < 0) | |
2383 | __u = __idx; | |
2384 | else if (__comparison > 0) | |
2385 | __l = __idx + 1; | |
2386 | else | |
2387 | return (void *) __p; | |
2388 | } | |
2389 | ||
2390 | return __null; | |
2391 | } | |
2392 | # 760 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 2 3 4 | |
2393 | ||
2394 | ||
2395 | ||
2396 | ||
2397 | extern void qsort (void *__base, size_t __nmemb, size_t __size, | |
2398 | __compar_fn_t __compar) __attribute__ ((__nonnull__ (1, 4))); | |
2399 | ||
2400 | extern void qsort_r (void *__base, size_t __nmemb, size_t __size, | |
2401 | __compar_d_fn_t __compar, void *__arg) | |
2402 | __attribute__ ((__nonnull__ (1, 4))); | |
2403 | ||
2404 | ||
2405 | ||
2406 | ||
2407 | extern int abs (int __x) throw () __attribute__ ((__const__)) __attribute__ ((__warn_unused_result__)); | |
2408 | extern long int labs (long int __x) throw () __attribute__ ((__const__)) __attribute__ ((__warn_unused_result__)); | |
2409 | ||
2410 | ||
2411 | ||
2412 | __extension__ extern long long int llabs (long long int __x) | |
2413 | throw () __attribute__ ((__const__)) __attribute__ ((__warn_unused_result__)); | |
2414 | ||
2415 | ||
2416 | ||
2417 | ||
2418 | ||
2419 | ||
2420 | ||
2421 | extern div_t div (int __numer, int __denom) | |
2422 | throw () __attribute__ ((__const__)) __attribute__ ((__warn_unused_result__)); | |
2423 | extern ldiv_t ldiv (long int __numer, long int __denom) | |
2424 | throw () __attribute__ ((__const__)) __attribute__ ((__warn_unused_result__)); | |
2425 | ||
2426 | ||
2427 | ||
2428 | ||
2429 | __extension__ extern lldiv_t lldiv (long long int __numer, | |
2430 | long long int __denom) | |
2431 | throw () __attribute__ ((__const__)) __attribute__ ((__warn_unused_result__)); | |
2432 | ||
2433 | # 811 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 3 4 | |
2434 | extern char *ecvt (double __value, int __ndigit, int *__restrict __decpt, | |
2435 | int *__restrict __sign) throw () __attribute__ ((__nonnull__ (3, 4))) __attribute__ ((__warn_unused_result__)); | |
2436 | ||
2437 | ||
2438 | ||
2439 | ||
2440 | extern char *fcvt (double __value, int __ndigit, int *__restrict __decpt, | |
2441 | int *__restrict __sign) throw () __attribute__ ((__nonnull__ (3, 4))) __attribute__ ((__warn_unused_result__)); | |
2442 | ||
2443 | ||
2444 | ||
2445 | ||
2446 | extern char *gcvt (double __value, int __ndigit, char *__buf) | |
2447 | throw () __attribute__ ((__nonnull__ (3))) __attribute__ ((__warn_unused_result__)); | |
2448 | ||
2449 | ||
2450 | ||
2451 | ||
2452 | extern char *qecvt (long double __value, int __ndigit, | |
2453 | int *__restrict __decpt, int *__restrict __sign) | |
2454 | throw () __attribute__ ((__nonnull__ (3, 4))) __attribute__ ((__warn_unused_result__)); | |
2455 | extern char *qfcvt (long double __value, int __ndigit, | |
2456 | int *__restrict __decpt, int *__restrict __sign) | |
2457 | throw () __attribute__ ((__nonnull__ (3, 4))) __attribute__ ((__warn_unused_result__)); | |
2458 | extern char *qgcvt (long double __value, int __ndigit, char *__buf) | |
2459 | throw () __attribute__ ((__nonnull__ (3))) __attribute__ ((__warn_unused_result__)); | |
2460 | ||
2461 | ||
2462 | ||
2463 | ||
2464 | extern int ecvt_r (double __value, int __ndigit, int *__restrict __decpt, | |
2465 | int *__restrict __sign, char *__restrict __buf, | |
2466 | size_t __len) throw () __attribute__ ((__nonnull__ (3, 4, 5))); | |
2467 | extern int fcvt_r (double __value, int __ndigit, int *__restrict __decpt, | |
2468 | int *__restrict __sign, char *__restrict __buf, | |
2469 | size_t __len) throw () __attribute__ ((__nonnull__ (3, 4, 5))); | |
2470 | ||
2471 | extern int qecvt_r (long double __value, int __ndigit, | |
2472 | int *__restrict __decpt, int *__restrict __sign, | |
2473 | char *__restrict __buf, size_t __len) | |
2474 | throw () __attribute__ ((__nonnull__ (3, 4, 5))); | |
2475 | extern int qfcvt_r (long double __value, int __ndigit, | |
2476 | int *__restrict __decpt, int *__restrict __sign, | |
2477 | char *__restrict __buf, size_t __len) | |
2478 | throw () __attribute__ ((__nonnull__ (3, 4, 5))); | |
2479 | ||
2480 | ||
2481 | ||
2482 | ||
2483 | ||
2484 | ||
2485 | extern int mblen (const char *__s, size_t __n) throw (); | |
2486 | ||
2487 | ||
2488 | extern int mbtowc (wchar_t *__restrict __pwc, | |
2489 | const char *__restrict __s, size_t __n) throw (); | |
2490 | ||
2491 | ||
2492 | extern int wctomb (char *__s, wchar_t __wchar) throw (); | |
2493 | ||
2494 | ||
2495 | ||
2496 | extern size_t mbstowcs (wchar_t *__restrict __pwcs, | |
2497 | const char *__restrict __s, size_t __n) throw (); | |
2498 | ||
2499 | extern size_t wcstombs (char *__restrict __s, | |
2500 | const wchar_t *__restrict __pwcs, size_t __n) | |
2501 | throw (); | |
2502 | ||
2503 | ||
2504 | ||
2505 | ||
2506 | ||
2507 | ||
2508 | ||
2509 | ||
2510 | extern int rpmatch (const char *__response) throw () __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__)); | |
2511 | # 898 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 3 4 | |
2512 | extern int getsubopt (char **__restrict __optionp, | |
2513 | char *const *__restrict __tokens, | |
2514 | char **__restrict __valuep) | |
2515 | throw () __attribute__ ((__nonnull__ (1, 2, 3))) __attribute__ ((__warn_unused_result__)); | |
2516 | ||
2517 | ||
2518 | ||
2519 | ||
2520 | ||
2521 | extern void setkey (const char *__key) throw () __attribute__ ((__nonnull__ (1))); | |
2522 | ||
2523 | ||
2524 | ||
2525 | ||
2526 | ||
2527 | ||
2528 | ||
2529 | extern int posix_openpt (int __oflag) __attribute__ ((__warn_unused_result__)); | |
2530 | ||
2531 | ||
2532 | ||
2533 | ||
2534 | ||
2535 | ||
2536 | ||
2537 | extern int grantpt (int __fd) throw (); | |
2538 | ||
2539 | ||
2540 | ||
2541 | extern int unlockpt (int __fd) throw (); | |
2542 | ||
2543 | ||
2544 | ||
2545 | ||
2546 | extern char *ptsname (int __fd) throw () __attribute__ ((__warn_unused_result__)); | |
2547 | ||
2548 | ||
2549 | ||
2550 | ||
2551 | ||
2552 | ||
2553 | extern int ptsname_r (int __fd, char *__buf, size_t __buflen) | |
2554 | throw () __attribute__ ((__nonnull__ (2))); | |
2555 | ||
2556 | ||
2557 | extern int getpt (void); | |
2558 | ||
2559 | ||
2560 | ||
2561 | ||
2562 | ||
2563 | ||
2564 | extern int getloadavg (double __loadavg[], int __nelem) | |
2565 | throw () __attribute__ ((__nonnull__ (1))); | |
2566 | ||
2567 | ||
2568 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/stdlib-float.h" 1 3 4 | |
2569 | # 24 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/stdlib-float.h" 3 4 | |
2570 | ||
2571 | extern __inline __attribute__ ((__gnu_inline__)) double | |
2572 | __attribute__ ((__leaf__)) atof (const char *__nptr) throw () | |
2573 | { | |
2574 | return strtod (__nptr, (char **) __null); | |
2575 | } | |
2576 | ||
2577 | # 955 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 2 3 4 | |
2578 | ||
2579 | ||
2580 | ||
2581 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/stdlib.h" 1 3 4 | |
2582 | # 23 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/stdlib.h" 3 4 | |
2583 | extern char *__realpath_chk (const char *__restrict __name, | |
2584 | char *__restrict __resolved, | |
2585 | size_t __resolvedlen) throw () __attribute__ ((__warn_unused_result__)); | |
2586 | extern char *__realpath_alias (const char *__restrict __name, char *__restrict __resolved) throw () __asm__ ("" "realpath") | |
2587 | ||
2588 | __attribute__ ((__warn_unused_result__)); | |
2589 | extern char *__realpath_chk_warn (const char *__restrict __name, char *__restrict __resolved, size_t __resolvedlen) throw () __asm__ ("" "__realpath_chk") | |
2590 | ||
2591 | ||
2592 | __attribute__ ((__warn_unused_result__)) | |
2593 | __attribute__((__warning__ ("second argument of realpath must be either NULL or at " "least PATH_MAX bytes long buffer"))) | |
2594 | ; | |
2595 | ||
2596 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) __attribute__ ((__warn_unused_result__)) char * | |
2597 | __attribute__ ((__leaf__)) realpath (const char *__restrict __name, char *__restrict __resolved) throw () | |
2598 | { | |
2599 | if (__builtin_object_size (__resolved, 2 > 1) != (size_t) -1) | |
2600 | { | |
2601 | ||
2602 | ||
2603 | ||
2604 | ||
2605 | return __realpath_chk (__name, __resolved, __builtin_object_size (__resolved, 2 > 1)); | |
2606 | } | |
2607 | ||
2608 | return __realpath_alias (__name, __resolved); | |
2609 | } | |
2610 | ||
2611 | ||
2612 | extern int __ptsname_r_chk (int __fd, char *__buf, size_t __buflen, | |
2613 | size_t __nreal) throw () __attribute__ ((__nonnull__ (2))); | |
2614 | extern int __ptsname_r_alias (int __fd, char *__buf, size_t __buflen) throw () __asm__ ("" "ptsname_r") | |
2615 | ||
2616 | __attribute__ ((__nonnull__ (2))); | |
2617 | extern int __ptsname_r_chk_warn (int __fd, char *__buf, size_t __buflen, size_t __nreal) throw () __asm__ ("" "__ptsname_r_chk") | |
2618 | ||
2619 | ||
2620 | __attribute__ ((__nonnull__ (2))) __attribute__((__warning__ ("ptsname_r called with buflen bigger than " "size of buf"))) | |
2621 | ; | |
2622 | ||
2623 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) int | |
2624 | __attribute__ ((__leaf__)) ptsname_r (int __fd, char *__buf, size_t __buflen) throw () | |
2625 | { | |
2626 | if (__builtin_object_size (__buf, 2 > 1) != (size_t) -1) | |
2627 | { | |
2628 | if (!__builtin_constant_p (__buflen)) | |
2629 | return __ptsname_r_chk (__fd, __buf, __buflen, __builtin_object_size (__buf, 2 > 1)); | |
2630 | if (__buflen > __builtin_object_size (__buf, 2 > 1)) | |
2631 | return __ptsname_r_chk_warn (__fd, __buf, __buflen, __builtin_object_size (__buf, 2 > 1)); | |
2632 | } | |
2633 | return __ptsname_r_alias (__fd, __buf, __buflen); | |
2634 | } | |
2635 | ||
2636 | ||
2637 | extern int __wctomb_chk (char *__s, wchar_t __wchar, size_t __buflen) | |
2638 | throw () __attribute__ ((__warn_unused_result__)); | |
2639 | extern int __wctomb_alias (char *__s, wchar_t __wchar) throw () __asm__ ("" "wctomb") | |
2640 | __attribute__ ((__warn_unused_result__)); | |
2641 | ||
2642 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) __attribute__ ((__warn_unused_result__)) int | |
2643 | __attribute__ ((__leaf__)) wctomb (char *__s, wchar_t __wchar) throw () | |
2644 | { | |
2645 | ||
2646 | ||
2647 | ||
2648 | ||
2649 | ||
2650 | ||
2651 | ||
2652 | if (__builtin_object_size (__s, 2 > 1) != (size_t) -1 && 16 > __builtin_object_size (__s, 2 > 1)) | |
2653 | return __wctomb_chk (__s, __wchar, __builtin_object_size (__s, 2 > 1)); | |
2654 | return __wctomb_alias (__s, __wchar); | |
2655 | } | |
2656 | ||
2657 | ||
2658 | extern size_t __mbstowcs_chk (wchar_t *__restrict __dst, | |
2659 | const char *__restrict __src, | |
2660 | size_t __len, size_t __dstlen) throw (); | |
2661 | extern size_t __mbstowcs_alias (wchar_t *__restrict __dst, const char *__restrict __src, size_t __len) throw () __asm__ ("" "mbstowcs") | |
2662 | ||
2663 | ||
2664 | ; | |
2665 | extern size_t __mbstowcs_chk_warn (wchar_t *__restrict __dst, const char *__restrict __src, size_t __len, size_t __dstlen) throw () __asm__ ("" "__mbstowcs_chk") | |
2666 | ||
2667 | ||
2668 | ||
2669 | __attribute__((__warning__ ("mbstowcs called with dst buffer smaller than len " "* sizeof (wchar_t)"))) | |
2670 | ; | |
2671 | ||
2672 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) size_t | |
2673 | __attribute__ ((__leaf__)) mbstowcs (wchar_t *__restrict __dst, const char *__restrict __src, size_t __len) throw () | |
2674 | ||
2675 | { | |
2676 | if (__builtin_object_size (__dst, 2 > 1) != (size_t) -1) | |
2677 | { | |
2678 | if (!__builtin_constant_p (__len)) | |
2679 | return __mbstowcs_chk (__dst, __src, __len, | |
2680 | __builtin_object_size (__dst, 2 > 1) / sizeof (wchar_t)); | |
2681 | ||
2682 | if (__len > __builtin_object_size (__dst, 2 > 1) / sizeof (wchar_t)) | |
2683 | return __mbstowcs_chk_warn (__dst, __src, __len, | |
2684 | __builtin_object_size (__dst, 2 > 1) / sizeof (wchar_t)); | |
2685 | } | |
2686 | return __mbstowcs_alias (__dst, __src, __len); | |
2687 | } | |
2688 | ||
2689 | ||
2690 | extern size_t __wcstombs_chk (char *__restrict __dst, | |
2691 | const wchar_t *__restrict __src, | |
2692 | size_t __len, size_t __dstlen) throw (); | |
2693 | extern size_t __wcstombs_alias (char *__restrict __dst, const wchar_t *__restrict __src, size_t __len) throw () __asm__ ("" "wcstombs") | |
2694 | ||
2695 | ||
2696 | ; | |
2697 | extern size_t __wcstombs_chk_warn (char *__restrict __dst, const wchar_t *__restrict __src, size_t __len, size_t __dstlen) throw () __asm__ ("" "__wcstombs_chk") | |
2698 | ||
2699 | ||
2700 | ||
2701 | __attribute__((__warning__ ("wcstombs called with dst buffer smaller than len"))); | |
2702 | ||
2703 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) size_t | |
2704 | __attribute__ ((__leaf__)) wcstombs (char *__restrict __dst, const wchar_t *__restrict __src, size_t __len) throw () | |
2705 | ||
2706 | { | |
2707 | if (__builtin_object_size (__dst, 2 > 1) != (size_t) -1) | |
2708 | { | |
2709 | if (!__builtin_constant_p (__len)) | |
2710 | return __wcstombs_chk (__dst, __src, __len, __builtin_object_size (__dst, 2 > 1)); | |
2711 | if (__len > __builtin_object_size (__dst, 2 > 1)) | |
2712 | return __wcstombs_chk_warn (__dst, __src, __len, __builtin_object_size (__dst, 2 > 1)); | |
2713 | } | |
2714 | return __wcstombs_alias (__dst, __src, __len); | |
2715 | } | |
2716 | # 959 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 2 3 4 | |
2717 | # 967 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 3 4 | |
2718 | } | |
2719 | # 46 "jsxml.cpp" 2 | |
2720 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/string.h" 1 3 4 | |
2721 | # 27 "/usr/powerpc64-unknown-linux-gnu/usr/include/string.h" 3 4 | |
2722 | extern "C" { | |
2723 | ||
2724 | ||
2725 | ||
2726 | ||
2727 | # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stddef.h" 1 3 4 | |
2728 | # 33 "/usr/powerpc64-unknown-linux-gnu/usr/include/string.h" 2 3 4 | |
2729 | ||
2730 | ||
2731 | ||
2732 | ||
2733 | ||
2734 | ||
2735 | ||
2736 | ||
2737 | ||
2738 | extern void *memcpy (void *__restrict __dest, const void *__restrict __src, | |
2739 | size_t __n) throw () __attribute__ ((__nonnull__ (1, 2))); | |
2740 | ||
2741 | ||
2742 | extern void *memmove (void *__dest, const void *__src, size_t __n) | |
2743 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
2744 | ||
2745 | ||
2746 | ||
2747 | ||
2748 | ||
2749 | ||
2750 | extern void *memccpy (void *__restrict __dest, const void *__restrict __src, | |
2751 | int __c, size_t __n) | |
2752 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
2753 | ||
2754 | ||
2755 | ||
2756 | ||
2757 | ||
2758 | extern void *memset (void *__s, int __c, size_t __n) throw () __attribute__ ((__nonnull__ (1))); | |
2759 | ||
2760 | ||
2761 | extern int memcmp (const void *__s1, const void *__s2, size_t __n) | |
2762 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); | |
2763 | ||
2764 | ||
2765 | ||
2766 | extern "C++" | |
2767 | { | |
2768 | extern void *memchr (void *__s, int __c, size_t __n) | |
2769 | throw () __asm ("memchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); | |
2770 | extern const void *memchr (const void *__s, int __c, size_t __n) | |
2771 | throw () __asm ("memchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); | |
2772 | ||
2773 | ||
2774 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) void * | |
2775 | memchr (void *__s, int __c, size_t __n) throw () | |
2776 | { | |
2777 | return __builtin_memchr (__s, __c, __n); | |
2778 | } | |
2779 | ||
2780 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) const void * | |
2781 | memchr (const void *__s, int __c, size_t __n) throw () | |
2782 | { | |
2783 | return __builtin_memchr (__s, __c, __n); | |
2784 | } | |
2785 | ||
2786 | } | |
2787 | ||
2788 | ||
2789 | ||
2790 | ||
2791 | ||
2792 | ||
2793 | ||
2794 | ||
2795 | ||
2796 | ||
2797 | extern "C++" void *rawmemchr (void *__s, int __c) | |
2798 | throw () __asm ("rawmemchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); | |
2799 | extern "C++" const void *rawmemchr (const void *__s, int __c) | |
2800 | throw () __asm ("rawmemchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); | |
2801 | ||
2802 | ||
2803 | ||
2804 | ||
2805 | ||
2806 | ||
2807 | ||
2808 | extern "C++" void *memrchr (void *__s, int __c, size_t __n) | |
2809 | throw () __asm ("memrchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); | |
2810 | extern "C++" const void *memrchr (const void *__s, int __c, size_t __n) | |
2811 | throw () __asm ("memrchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); | |
2812 | ||
2813 | ||
2814 | ||
2815 | ||
2816 | ||
2817 | ||
2818 | ||
2819 | ||
2820 | ||
2821 | extern char *strcpy (char *__restrict __dest, const char *__restrict __src) | |
2822 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
2823 | ||
2824 | extern char *strncpy (char *__restrict __dest, | |
2825 | const char *__restrict __src, size_t __n) | |
2826 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
2827 | ||
2828 | ||
2829 | extern char *strcat (char *__restrict __dest, const char *__restrict __src) | |
2830 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
2831 | ||
2832 | extern char *strncat (char *__restrict __dest, const char *__restrict __src, | |
2833 | size_t __n) throw () __attribute__ ((__nonnull__ (1, 2))); | |
2834 | ||
2835 | ||
2836 | extern int strcmp (const char *__s1, const char *__s2) | |
2837 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); | |
2838 | ||
2839 | extern int strncmp (const char *__s1, const char *__s2, size_t __n) | |
2840 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); | |
2841 | ||
2842 | ||
2843 | extern int strcoll (const char *__s1, const char *__s2) | |
2844 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); | |
2845 | ||
2846 | extern size_t strxfrm (char *__restrict __dest, | |
2847 | const char *__restrict __src, size_t __n) | |
2848 | throw () __attribute__ ((__nonnull__ (2))); | |
2849 | ||
2850 | # 162 "/usr/powerpc64-unknown-linux-gnu/usr/include/string.h" 3 4 | |
2851 | extern int strcoll_l (const char *__s1, const char *__s2, __locale_t __l) | |
2852 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2, 3))); | |
2853 | ||
2854 | extern size_t strxfrm_l (char *__dest, const char *__src, size_t __n, | |
2855 | __locale_t __l) throw () __attribute__ ((__nonnull__ (2, 4))); | |
2856 | ||
2857 | ||
2858 | ||
2859 | ||
2860 | extern char *strdup (const char *__s) | |
2861 | throw () __attribute__ ((__malloc__)) __attribute__ ((__nonnull__ (1))); | |
2862 | ||
2863 | ||
2864 | ||
2865 | ||
2866 | ||
2867 | ||
2868 | extern char *strndup (const char *__string, size_t __n) | |
2869 | throw () __attribute__ ((__malloc__)) __attribute__ ((__nonnull__ (1))); | |
2870 | # 206 "/usr/powerpc64-unknown-linux-gnu/usr/include/string.h" 3 4 | |
2871 | ||
2872 | ||
2873 | ||
2874 | extern "C++" | |
2875 | { | |
2876 | extern char *strchr (char *__s, int __c) | |
2877 | throw () __asm ("strchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); | |
2878 | extern const char *strchr (const char *__s, int __c) | |
2879 | throw () __asm ("strchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); | |
2880 | ||
2881 | ||
2882 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) char * | |
2883 | strchr (char *__s, int __c) throw () | |
2884 | { | |
2885 | return __builtin_strchr (__s, __c); | |
2886 | } | |
2887 | ||
2888 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) const char * | |
2889 | strchr (const char *__s, int __c) throw () | |
2890 | { | |
2891 | return __builtin_strchr (__s, __c); | |
2892 | } | |
2893 | ||
2894 | } | |
2895 | ||
2896 | ||
2897 | ||
2898 | ||
2899 | ||
2900 | ||
2901 | extern "C++" | |
2902 | { | |
2903 | extern char *strrchr (char *__s, int __c) | |
2904 | throw () __asm ("strrchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); | |
2905 | extern const char *strrchr (const char *__s, int __c) | |
2906 | throw () __asm ("strrchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); | |
2907 | ||
2908 | ||
2909 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) char * | |
2910 | strrchr (char *__s, int __c) throw () | |
2911 | { | |
2912 | return __builtin_strrchr (__s, __c); | |
2913 | } | |
2914 | ||
2915 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) const char * | |
2916 | strrchr (const char *__s, int __c) throw () | |
2917 | { | |
2918 | return __builtin_strrchr (__s, __c); | |
2919 | } | |
2920 | ||
2921 | } | |
2922 | ||
2923 | ||
2924 | ||
2925 | ||
2926 | ||
2927 | ||
2928 | ||
2929 | ||
2930 | ||
2931 | ||
2932 | extern "C++" char *strchrnul (char *__s, int __c) | |
2933 | throw () __asm ("strchrnul") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); | |
2934 | extern "C++" const char *strchrnul (const char *__s, int __c) | |
2935 | throw () __asm ("strchrnul") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); | |
2936 | ||
2937 | ||
2938 | ||
2939 | ||
2940 | ||
2941 | ||
2942 | ||
2943 | ||
2944 | ||
2945 | extern size_t strcspn (const char *__s, const char *__reject) | |
2946 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); | |
2947 | ||
2948 | ||
2949 | extern size_t strspn (const char *__s, const char *__accept) | |
2950 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); | |
2951 | ||
2952 | ||
2953 | extern "C++" | |
2954 | { | |
2955 | extern char *strpbrk (char *__s, const char *__accept) | |
2956 | throw () __asm ("strpbrk") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); | |
2957 | extern const char *strpbrk (const char *__s, const char *__accept) | |
2958 | throw () __asm ("strpbrk") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); | |
2959 | ||
2960 | ||
2961 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) char * | |
2962 | strpbrk (char *__s, const char *__accept) throw () | |
2963 | { | |
2964 | return __builtin_strpbrk (__s, __accept); | |
2965 | } | |
2966 | ||
2967 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) const char * | |
2968 | strpbrk (const char *__s, const char *__accept) throw () | |
2969 | { | |
2970 | return __builtin_strpbrk (__s, __accept); | |
2971 | } | |
2972 | ||
2973 | } | |
2974 | ||
2975 | ||
2976 | ||
2977 | ||
2978 | ||
2979 | ||
2980 | extern "C++" | |
2981 | { | |
2982 | extern char *strstr (char *__haystack, const char *__needle) | |
2983 | throw () __asm ("strstr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); | |
2984 | extern const char *strstr (const char *__haystack, const char *__needle) | |
2985 | throw () __asm ("strstr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); | |
2986 | ||
2987 | ||
2988 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) char * | |
2989 | strstr (char *__haystack, const char *__needle) throw () | |
2990 | { | |
2991 | return __builtin_strstr (__haystack, __needle); | |
2992 | } | |
2993 | ||
2994 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) const char * | |
2995 | strstr (const char *__haystack, const char *__needle) throw () | |
2996 | { | |
2997 | return __builtin_strstr (__haystack, __needle); | |
2998 | } | |
2999 | ||
3000 | } | |
3001 | ||
3002 | ||
3003 | ||
3004 | ||
3005 | ||
3006 | ||
3007 | ||
3008 | extern char *strtok (char *__restrict __s, const char *__restrict __delim) | |
3009 | throw () __attribute__ ((__nonnull__ (2))); | |
3010 | ||
3011 | ||
3012 | ||
3013 | ||
3014 | extern char *__strtok_r (char *__restrict __s, | |
3015 | const char *__restrict __delim, | |
3016 | char **__restrict __save_ptr) | |
3017 | throw () __attribute__ ((__nonnull__ (2, 3))); | |
3018 | ||
3019 | extern char *strtok_r (char *__restrict __s, const char *__restrict __delim, | |
3020 | char **__restrict __save_ptr) | |
3021 | throw () __attribute__ ((__nonnull__ (2, 3))); | |
3022 | ||
3023 | ||
3024 | ||
3025 | ||
3026 | ||
3027 | extern "C++" char *strcasestr (char *__haystack, const char *__needle) | |
3028 | throw () __asm ("strcasestr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); | |
3029 | extern "C++" const char *strcasestr (const char *__haystack, | |
3030 | const char *__needle) | |
3031 | throw () __asm ("strcasestr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); | |
3032 | # 377 "/usr/powerpc64-unknown-linux-gnu/usr/include/string.h" 3 4 | |
3033 | extern void *memmem (const void *__haystack, size_t __haystacklen, | |
3034 | const void *__needle, size_t __needlelen) | |
3035 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 3))); | |
3036 | ||
3037 | ||
3038 | ||
3039 | extern void *__mempcpy (void *__restrict __dest, | |
3040 | const void *__restrict __src, size_t __n) | |
3041 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
3042 | extern void *mempcpy (void *__restrict __dest, | |
3043 | const void *__restrict __src, size_t __n) | |
3044 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
3045 | ||
3046 | ||
3047 | ||
3048 | ||
3049 | ||
3050 | extern size_t strlen (const char *__s) | |
3051 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); | |
3052 | ||
3053 | ||
3054 | ||
3055 | ||
3056 | ||
3057 | extern size_t strnlen (const char *__string, size_t __maxlen) | |
3058 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); | |
3059 | ||
3060 | ||
3061 | ||
3062 | ||
3063 | ||
3064 | extern char *strerror (int __errnum) throw (); | |
3065 | ||
3066 | # 433 "/usr/powerpc64-unknown-linux-gnu/usr/include/string.h" 3 4 | |
3067 | extern char *strerror_r (int __errnum, char *__buf, size_t __buflen) | |
3068 | throw () __attribute__ ((__nonnull__ (2))) __attribute__ ((__warn_unused_result__)); | |
3069 | ||
3070 | ||
3071 | ||
3072 | ||
3073 | ||
3074 | extern char *strerror_l (int __errnum, __locale_t __l) throw (); | |
3075 | ||
3076 | ||
3077 | ||
3078 | ||
3079 | ||
3080 | extern void __bzero (void *__s, size_t __n) throw () __attribute__ ((__nonnull__ (1))); | |
3081 | ||
3082 | ||
3083 | ||
3084 | extern void bcopy (const void *__src, void *__dest, size_t __n) | |
3085 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
3086 | ||
3087 | ||
3088 | extern void bzero (void *__s, size_t __n) throw () __attribute__ ((__nonnull__ (1))); | |
3089 | ||
3090 | ||
3091 | extern int bcmp (const void *__s1, const void *__s2, size_t __n) | |
3092 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); | |
3093 | ||
3094 | ||
3095 | ||
3096 | extern "C++" | |
3097 | { | |
3098 | extern char *index (char *__s, int __c) | |
3099 | throw () __asm ("index") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); | |
3100 | extern const char *index (const char *__s, int __c) | |
3101 | throw () __asm ("index") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); | |
3102 | ||
3103 | ||
3104 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) char * | |
3105 | index (char *__s, int __c) throw () | |
3106 | { | |
3107 | return __builtin_index (__s, __c); | |
3108 | } | |
3109 | ||
3110 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) const char * | |
3111 | index (const char *__s, int __c) throw () | |
3112 | { | |
3113 | return __builtin_index (__s, __c); | |
3114 | } | |
3115 | ||
3116 | } | |
3117 | ||
3118 | ||
3119 | ||
3120 | ||
3121 | ||
3122 | ||
3123 | ||
3124 | extern "C++" | |
3125 | { | |
3126 | extern char *rindex (char *__s, int __c) | |
3127 | throw () __asm ("rindex") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); | |
3128 | extern const char *rindex (const char *__s, int __c) | |
3129 | throw () __asm ("rindex") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); | |
3130 | ||
3131 | ||
3132 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) char * | |
3133 | rindex (char *__s, int __c) throw () | |
3134 | { | |
3135 | return __builtin_rindex (__s, __c); | |
3136 | } | |
3137 | ||
3138 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) const char * | |
3139 | rindex (const char *__s, int __c) throw () | |
3140 | { | |
3141 | return __builtin_rindex (__s, __c); | |
3142 | } | |
3143 | ||
3144 | } | |
3145 | ||
3146 | ||
3147 | ||
3148 | ||
3149 | ||
3150 | ||
3151 | ||
3152 | extern int ffs (int __i) throw () __attribute__ ((__const__)); | |
3153 | ||
3154 | ||
3155 | ||
3156 | ||
3157 | extern int ffsl (long int __l) throw () __attribute__ ((__const__)); | |
3158 | __extension__ extern int ffsll (long long int __ll) | |
3159 | throw () __attribute__ ((__const__)); | |
3160 | ||
3161 | ||
3162 | ||
3163 | extern int strcasecmp (const char *__s1, const char *__s2) | |
3164 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); | |
3165 | ||
3166 | ||
3167 | extern int strncasecmp (const char *__s1, const char *__s2, size_t __n) | |
3168 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); | |
3169 | ||
3170 | ||
3171 | ||
3172 | ||
3173 | ||
3174 | extern int strcasecmp_l (const char *__s1, const char *__s2, | |
3175 | __locale_t __loc) | |
3176 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2, 3))); | |
3177 | ||
3178 | extern int strncasecmp_l (const char *__s1, const char *__s2, | |
3179 | size_t __n, __locale_t __loc) | |
3180 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2, 4))); | |
3181 | ||
3182 | ||
3183 | ||
3184 | ||
3185 | ||
3186 | extern char *strsep (char **__restrict __stringp, | |
3187 | const char *__restrict __delim) | |
3188 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
3189 | ||
3190 | ||
3191 | ||
3192 | ||
3193 | extern char *strsignal (int __sig) throw (); | |
3194 | ||
3195 | ||
3196 | extern char *__stpcpy (char *__restrict __dest, const char *__restrict __src) | |
3197 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
3198 | extern char *stpcpy (char *__restrict __dest, const char *__restrict __src) | |
3199 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
3200 | ||
3201 | ||
3202 | ||
3203 | extern char *__stpncpy (char *__restrict __dest, | |
3204 | const char *__restrict __src, size_t __n) | |
3205 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
3206 | extern char *stpncpy (char *__restrict __dest, | |
3207 | const char *__restrict __src, size_t __n) | |
3208 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
3209 | ||
3210 | ||
3211 | ||
3212 | ||
3213 | extern int strverscmp (const char *__s1, const char *__s2) | |
3214 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); | |
3215 | ||
3216 | ||
3217 | extern char *strfry (char *__string) throw () __attribute__ ((__nonnull__ (1))); | |
3218 | ||
3219 | ||
3220 | extern void *memfrob (void *__s, size_t __n) throw () __attribute__ ((__nonnull__ (1))); | |
3221 | ||
3222 | ||
3223 | ||
3224 | ||
3225 | ||
3226 | ||
3227 | ||
3228 | extern "C++" char *basename (char *__filename) | |
3229 | throw () __asm ("basename") __attribute__ ((__nonnull__ (1))); | |
3230 | extern "C++" const char *basename (const char *__filename) | |
3231 | throw () __asm ("basename") __attribute__ ((__nonnull__ (1))); | |
3232 | # 635 "/usr/powerpc64-unknown-linux-gnu/usr/include/string.h" 3 4 | |
3233 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/string3.h" 1 3 4 | |
3234 | # 23 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/string3.h" 3 4 | |
3235 | extern void __warn_memset_zero_len (void) __attribute__((__warning__ ("memset used with constant zero length parameter; this could be due to transposed parameters"))) | |
3236 | ; | |
3237 | # 49 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/string3.h" 3 4 | |
3238 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) void * | |
3239 | __attribute__ ((__leaf__)) memcpy (void *__restrict __dest, const void *__restrict __src, size_t __len) throw () | |
3240 | ||
3241 | { | |
3242 | return __builtin___memcpy_chk (__dest, __src, __len, __builtin_object_size (__dest, 0)); | |
3243 | } | |
3244 | ||
3245 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) void * | |
3246 | __attribute__ ((__leaf__)) memmove (void *__dest, const void *__src, size_t __len) throw () | |
3247 | { | |
3248 | return __builtin___memmove_chk (__dest, __src, __len, __builtin_object_size (__dest, 0)); | |
3249 | } | |
3250 | ||
3251 | ||
3252 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) void * | |
3253 | __attribute__ ((__leaf__)) mempcpy (void *__restrict __dest, const void *__restrict __src, size_t __len) throw () | |
3254 | ||
3255 | { | |
3256 | return __builtin___mempcpy_chk (__dest, __src, __len, __builtin_object_size (__dest, 0)); | |
3257 | } | |
3258 | # 77 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/string3.h" 3 4 | |
3259 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) void * | |
3260 | __attribute__ ((__leaf__)) memset (void *__dest, int __ch, size_t __len) throw () | |
3261 | { | |
3262 | ||
3263 | ||
3264 | ||
3265 | if (__builtin_constant_p (__len) && __len == 0 | |
3266 | && (!__builtin_constant_p (__ch) || __ch != 0)) | |
3267 | { | |
3268 | __warn_memset_zero_len (); | |
3269 | return __dest; | |
3270 | } | |
3271 | ||
3272 | return __builtin___memset_chk (__dest, __ch, __len, __builtin_object_size (__dest, 0)); | |
3273 | } | |
3274 | ||
3275 | ||
3276 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) void | |
3277 | __attribute__ ((__leaf__)) bcopy (const void *__src, void *__dest, size_t __len) throw () | |
3278 | { | |
3279 | (void) __builtin___memmove_chk (__dest, __src, __len, __builtin_object_size (__dest, 0)); | |
3280 | } | |
3281 | ||
3282 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) void | |
3283 | __attribute__ ((__leaf__)) bzero (void *__dest, size_t __len) throw () | |
3284 | { | |
3285 | (void) __builtin___memset_chk (__dest, '\0', __len, __builtin_object_size (__dest, 0)); | |
3286 | } | |
3287 | ||
3288 | ||
3289 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) char * | |
3290 | __attribute__ ((__leaf__)) strcpy (char *__restrict __dest, const char *__restrict __src) throw () | |
3291 | { | |
3292 | return __builtin___strcpy_chk (__dest, __src, __builtin_object_size (__dest, 2 > 1)); | |
3293 | } | |
3294 | ||
3295 | ||
3296 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) char * | |
3297 | __attribute__ ((__leaf__)) stpcpy (char *__restrict __dest, const char *__restrict __src) throw () | |
3298 | { | |
3299 | return __builtin___stpcpy_chk (__dest, __src, __builtin_object_size (__dest, 2 > 1)); | |
3300 | } | |
3301 | ||
3302 | ||
3303 | ||
3304 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) char * | |
3305 | __attribute__ ((__leaf__)) strncpy (char *__restrict __dest, const char *__restrict __src, size_t __len) throw () | |
3306 | ||
3307 | { | |
3308 | return __builtin___strncpy_chk (__dest, __src, __len, __builtin_object_size (__dest, 2 > 1)); | |
3309 | } | |
3310 | ||
3311 | ||
3312 | extern char *__stpncpy_chk (char *__dest, const char *__src, size_t __n, | |
3313 | size_t __destlen) throw (); | |
3314 | extern char *__stpncpy_alias (char *__dest, const char *__src, size_t __n) throw () __asm__ ("" "stpncpy") | |
3315 | ; | |
3316 | ||
3317 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) char * | |
3318 | __attribute__ ((__leaf__)) stpncpy (char *__dest, const char *__src, size_t __n) throw () | |
3319 | { | |
3320 | if (__builtin_object_size (__dest, 2 > 1) != (size_t) -1 | |
3321 | && (!__builtin_constant_p (__n) || __n <= __builtin_object_size (__dest, 2 > 1))) | |
3322 | return __stpncpy_chk (__dest, __src, __n, __builtin_object_size (__dest, 2 > 1)); | |
3323 | return __stpncpy_alias (__dest, __src, __n); | |
3324 | } | |
3325 | ||
3326 | ||
3327 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) char * | |
3328 | __attribute__ ((__leaf__)) strcat (char *__restrict __dest, const char *__restrict __src) throw () | |
3329 | { | |
3330 | return __builtin___strcat_chk (__dest, __src, __builtin_object_size (__dest, 2 > 1)); | |
3331 | } | |
3332 | ||
3333 | ||
3334 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) char * | |
3335 | __attribute__ ((__leaf__)) strncat (char *__restrict __dest, const char *__restrict __src, size_t __len) throw () | |
3336 | ||
3337 | { | |
3338 | return __builtin___strncat_chk (__dest, __src, __len, __builtin_object_size (__dest, 2 > 1)); | |
3339 | } | |
3340 | # 636 "/usr/powerpc64-unknown-linux-gnu/usr/include/string.h" 2 3 4 | |
3341 | ||
3342 | ||
3343 | ||
3344 | } | |
3345 | # 47 "jsxml.cpp" 2 | |
3346 | # 1 "jstypes.h" 1 | |
3347 | # 57 "jstypes.h" | |
3348 | # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stddef.h" 1 3 4 | |
3349 | # 147 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stddef.h" 3 4 | |
3350 | typedef long int ptrdiff_t; | |
3351 | # 58 "jstypes.h" 2 | |
3352 | # 1 "js-config.h" 1 | |
3353 | # 59 "jstypes.h" 2 | |
3354 | # 314 "jstypes.h" | |
3355 | # 1 "jsautocfg.h" 1 | |
3356 | # 315 "jstypes.h" 2 | |
3357 | # 338 "jstypes.h" | |
3358 | # 1 "jsinttypes.h" 1 | |
3359 | # 74 "jsinttypes.h" | |
3360 | # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stdint.h" 1 3 4 | |
3361 | # 9 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stdint.h" 3 4 | |
3362 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdint.h" 1 3 4 | |
3363 | # 26 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdint.h" 3 4 | |
3364 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/wchar.h" 1 3 4 | |
3365 | # 27 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdint.h" 2 3 4 | |
3366 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/wordsize.h" 1 3 4 | |
3367 | # 28 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdint.h" 2 3 4 | |
3368 | # 48 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdint.h" 3 4 | |
3369 | typedef unsigned char uint8_t; | |
3370 | typedef unsigned short int uint16_t; | |
3371 | ||
3372 | typedef unsigned int uint32_t; | |
3373 | ||
3374 | ||
3375 | ||
3376 | typedef unsigned long int uint64_t; | |
3377 | # 65 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdint.h" 3 4 | |
3378 | typedef signed char int_least8_t; | |
3379 | typedef short int int_least16_t; | |
3380 | typedef int int_least32_t; | |
3381 | ||
3382 | typedef long int int_least64_t; | |
3383 | ||
3384 | ||
3385 | ||
3386 | ||
3387 | ||
3388 | ||
3389 | typedef unsigned char uint_least8_t; | |
3390 | typedef unsigned short int uint_least16_t; | |
3391 | typedef unsigned int uint_least32_t; | |
3392 | ||
3393 | typedef unsigned long int uint_least64_t; | |
3394 | # 90 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdint.h" 3 4 | |
3395 | typedef signed char int_fast8_t; | |
3396 | ||
3397 | typedef long int int_fast16_t; | |
3398 | typedef long int int_fast32_t; | |
3399 | typedef long int int_fast64_t; | |
3400 | # 103 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdint.h" 3 4 | |
3401 | typedef unsigned char uint_fast8_t; | |
3402 | ||
3403 | typedef unsigned long int uint_fast16_t; | |
3404 | typedef unsigned long int uint_fast32_t; | |
3405 | typedef unsigned long int uint_fast64_t; | |
3406 | # 119 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdint.h" 3 4 | |
3407 | typedef long int intptr_t; | |
3408 | ||
3409 | ||
3410 | typedef unsigned long int uintptr_t; | |
3411 | # 134 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdint.h" 3 4 | |
3412 | typedef long int intmax_t; | |
3413 | typedef unsigned long int uintmax_t; | |
3414 | # 10 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stdint.h" 2 3 4 | |
3415 | # 75 "jsinttypes.h" 2 | |
3416 | ||
3417 | ||
3418 | ||
3419 | ||
3420 | typedef int8_t JSInt8; | |
3421 | typedef int16_t JSInt16; | |
3422 | typedef int32_t JSInt32; | |
3423 | typedef int64_t JSInt64; | |
3424 | typedef intptr_t JSIntPtr; | |
3425 | ||
3426 | typedef uint8_t JSUint8; | |
3427 | typedef uint16_t JSUint16; | |
3428 | typedef uint32_t JSUint32; | |
3429 | typedef uint64_t JSUint64; | |
3430 | typedef uintptr_t JSUintPtr; | |
3431 | # 339 "jstypes.h" 2 | |
3432 | ||
3433 | extern "C" { | |
3434 | # 352 "jstypes.h" | |
3435 | typedef int JSIntn; | |
3436 | typedef unsigned int JSUintn; | |
3437 | ||
3438 | ||
3439 | ||
3440 | ||
3441 | ||
3442 | ||
3443 | typedef double JSFloat64; | |
3444 | ||
3445 | ||
3446 | ||
3447 | ||
3448 | ||
3449 | ||
3450 | typedef size_t JSSize; | |
3451 | ||
3452 | ||
3453 | ||
3454 | ||
3455 | ||
3456 | ||
3457 | ||
3458 | typedef ptrdiff_t JSPtrdiff; | |
3459 | ||
3460 | ||
3461 | ||
3462 | ||
3463 | ||
3464 | ||
3465 | ||
3466 | typedef JSUintPtr JSUptrdiff; | |
3467 | # 393 "jstypes.h" | |
3468 | typedef JSIntn JSBool; | |
3469 | # 408 "jstypes.h" | |
3470 | typedef JSUint8 JSPackedBool; | |
3471 | ||
3472 | ||
3473 | ||
3474 | ||
3475 | typedef JSIntPtr JSWord; | |
3476 | typedef JSUintPtr JSUword; | |
3477 | ||
3478 | # 1 "jsotypes.h" 1 | |
3479 | # 76 "jsotypes.h" | |
3480 | typedef JSUintn uintn; | |
3481 | typedef JSUint64 uint64; | |
3482 | typedef JSUint32 uint32; | |
3483 | typedef JSUint16 uint16; | |
3484 | typedef JSUint8 uint8; | |
3485 | ||
3486 | ||
3487 | typedef JSIntn intn; | |
3488 | # 103 "jsotypes.h" | |
3489 | typedef JSInt64 int64; | |
3490 | ||
3491 | ||
3492 | typedef JSInt32 int32; | |
3493 | typedef JSInt16 int16; | |
3494 | typedef JSInt8 int8; | |
3495 | ||
3496 | ||
3497 | ||
3498 | ||
3499 | typedef JSFloat64 float64; | |
3500 | # 417 "jstypes.h" 2 | |
3501 | # 505 "jstypes.h" | |
3502 | } | |
3503 | # 48 "jsxml.cpp" 2 | |
3504 | # 1 "jsstdint.h" 1 | |
3505 | # 49 "jsxml.cpp" 2 | |
3506 | # 1 "jsbit.h" 1 | |
3507 | # 43 "jsbit.h" | |
3508 | # 1 "jscompat.h" 1 | |
3509 | # 48 "jscompat.h" | |
3510 | # 1 "jslong.h" 1 | |
3511 | # 52 "jslong.h" | |
3512 | extern "C" { | |
3513 | # 165 "jslong.h" | |
3514 | } | |
3515 | # 49 "jscompat.h" 2 | |
3516 | ||
3517 | typedef JSIntn intN; | |
3518 | typedef JSUintn uintN; | |
3519 | typedef JSUword jsuword; | |
3520 | typedef JSWord jsword; | |
3521 | typedef float float32; | |
3522 | # 44 "jsbit.h" 2 | |
3523 | # 1 "jsutil.h" 1 | |
3524 | # 51 "jsutil.h" | |
3525 | extern "C" { | |
3526 | ||
3527 | ||
3528 | ||
3529 | ||
3530 | ||
3531 | extern __attribute__((visibility ("default"))) void | |
3532 | JS_Assert(const char *s, const char *file, JSIntn ln); | |
3533 | # 133 "jsutil.h" | |
3534 | extern __attribute__((visibility ("default"))) void JS_Abort(void); | |
3535 | # 212 "jsutil.h" | |
3536 | static inline void* js_malloc(size_t bytes) { | |
3537 | return malloc(bytes); | |
3538 | } | |
3539 | ||
3540 | static inline void* js_calloc(size_t bytes) { | |
3541 | return calloc(bytes, 1); | |
3542 | } | |
3543 | ||
3544 | static inline void* js_realloc(void* p, size_t bytes) { | |
3545 | return realloc(p, bytes); | |
3546 | } | |
3547 | ||
3548 | static inline void js_free(void* p) { | |
3549 | free(p); | |
3550 | } | |
3551 | ||
3552 | ||
3553 | } | |
3554 | # 253 "jsutil.h" | |
3555 | template <class T> | |
3556 | __attribute__((always_inline)) inline T *js_new() { | |
3557 | void *memory = js_malloc(sizeof(T)); return memory ? new(memory) T () : __null; | |
3558 | } | |
3559 | ||
3560 | template <class T, class P1> | |
3561 | __attribute__((always_inline)) inline T *js_new(const P1 &p1) { | |
3562 | void *memory = js_malloc(sizeof(T)); return memory ? new(memory) T (p1) : __null; | |
3563 | } | |
3564 | ||
3565 | template <class T, class P1, class P2> | |
3566 | __attribute__((always_inline)) inline T *js_new(const P1 &p1, const P2 &p2) { | |
3567 | void *memory = js_malloc(sizeof(T)); return memory ? new(memory) T (p1, p2) : __null; | |
3568 | } | |
3569 | ||
3570 | template <class T, class P1, class P2, class P3> | |
3571 | __attribute__((always_inline)) inline T *js_new(const P1 &p1, const P2 &p2, const P3 &p3) { | |
3572 | void *memory = js_malloc(sizeof(T)); return memory ? new(memory) T (p1, p2, p3) : __null; | |
3573 | } | |
3574 | ||
3575 | template <class T, class P1, class P2, class P3, class P4> | |
3576 | __attribute__((always_inline)) inline T *js_new(const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4) { | |
3577 | void *memory = js_malloc(sizeof(T)); return memory ? new(memory) T (p1, p2, p3, p4) : __null; | |
3578 | } | |
3579 | ||
3580 | ||
3581 | ||
3582 | ||
3583 | ||
3584 | template <class T> | |
3585 | __attribute__((always_inline)) inline void js_delete(T *p) { | |
3586 | if (p) { | |
3587 | p->~T(); | |
3588 | js_free(p); | |
3589 | } | |
3590 | } | |
3591 | ||
3592 | static const int JSMinAlignment = 8; | |
3593 | ||
3594 | template <class T> | |
3595 | __attribute__((always_inline)) inline T *js_array_new(size_t n) { | |
3596 | ||
3597 | uint64 numBytes64 = uint64(JSMinAlignment) + uint64(sizeof(T)) * uint64(n); | |
3598 | size_t numBytes = size_t(numBytes64); | |
3599 | if (numBytes64 != numBytes) { | |
3600 | ((void) 0); | |
3601 | return __null; | |
3602 | } | |
3603 | void *memory = js_malloc(numBytes); | |
3604 | if (!memory) | |
3605 | return __null; | |
3606 | *(size_t *)memory = n; | |
3607 | memory = (void*)(uintptr_t(memory) + JSMinAlignment); | |
3608 | return new(memory) T[n]; | |
3609 | } | |
3610 | ||
3611 | template <class T> | |
3612 | __attribute__((always_inline)) inline void js_array_delete(T *p) { | |
3613 | if (p) { | |
3614 | void* p0 = (void *)(uintptr_t(p) - JSMinAlignment); | |
3615 | size_t n = *(size_t *)p0; | |
3616 | for (size_t i = 0; i < n; i++) | |
3617 | (p + i)->~T(); | |
3618 | js_free(p0); | |
3619 | } | |
3620 | } | |
3621 | # 416 "jsutil.h" | |
3622 | namespace js { | |
3623 | ||
3624 | template <class T> | |
3625 | __attribute__((always_inline)) inline static void | |
3626 | PodZero(T *t) | |
3627 | { | |
3628 | memset(t, 0, sizeof(T)); | |
3629 | } | |
3630 | ||
3631 | template <class T> | |
3632 | __attribute__((always_inline)) inline static void | |
3633 | PodZero(T *t, size_t nelem) | |
3634 | { | |
3635 | memset(t, 0, nelem * sizeof(T)); | |
3636 | } | |
3637 | # 439 "jsutil.h" | |
3638 | template <class T, size_t N> static void PodZero(T (&)[N]); | |
3639 | template <class T, size_t N> static void PodZero(T (&)[N], size_t); | |
3640 | ||
3641 | template <class T, size_t N> | |
3642 | __attribute__((always_inline)) inline static void | |
3643 | PodArrayZero(T (&t)[N]) | |
3644 | { | |
3645 | memset(t, 0, N * sizeof(T)); | |
3646 | } | |
3647 | ||
3648 | template <class T> | |
3649 | __attribute__((always_inline)) inline static void | |
3650 | PodCopy(T *dst, const T *src, size_t nelem) | |
3651 | { | |
3652 | ||
3653 | ((void) 0); | |
3654 | ((void) 0); | |
3655 | ||
3656 | if (nelem < 128) { | |
3657 | for (const T *srcend = src + nelem; src != srcend; ++src, ++dst) | |
3658 | *dst = *src; | |
3659 | } else { | |
3660 | memcpy(dst, src, nelem * sizeof(T)); | |
3661 | } | |
3662 | } | |
3663 | ||
3664 | } | |
3665 | # 45 "jsbit.h" 2 | |
3666 | ||
3667 | extern "C" { | |
3668 | ||
3669 | ||
3670 | ||
3671 | ||
3672 | typedef jsuword jsbitmap_t; | |
3673 | typedef jsbitmap_t jsbitmap; | |
3674 | # 67 "jsbit.h" | |
3675 | extern __attribute__((visibility ("default"))) JSIntn JS_CeilingLog2(JSUint32 i); | |
3676 | ||
3677 | ||
3678 | ||
3679 | ||
3680 | extern __attribute__((visibility ("default"))) JSIntn JS_FloorLog2(JSUint32 i); | |
3681 | # 255 "jsbit.h" | |
3682 | namespace js { | |
3683 | ||
3684 | inline size_t | |
3685 | CountTrailingZeros(size_t n) | |
3686 | { | |
3687 | ((void) 0); | |
3688 | ||
3689 | ||
3690 | ||
3691 | ||
3692 | ||
3693 | ||
3694 | ||
3695 | return __builtin_ctzll(n); | |
3696 | # 281 "jsbit.h" | |
3697 | } | |
3698 | ||
3699 | } | |
3700 | # 304 "jsbit.h" | |
3701 | } | |
3702 | # 50 "jsxml.cpp" 2 | |
3703 | # 1 "jsprf.h" 1 | |
3704 | # 61 "jsprf.h" | |
3705 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 1 3 4 | |
3706 | # 29 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4 | |
3707 | extern "C" { | |
3708 | ||
3709 | ||
3710 | ||
3711 | # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stddef.h" 1 3 4 | |
3712 | # 34 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 2 3 4 | |
3713 | # 44 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4 | |
3714 | struct _IO_FILE; | |
3715 | ||
3716 | ||
3717 | ||
3718 | typedef struct _IO_FILE FILE; | |
3719 | ||
3720 | ||
3721 | ||
3722 | ||
3723 | ||
3724 | # 64 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4 | |
3725 | typedef struct _IO_FILE __FILE; | |
3726 | # 74 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4 | |
3727 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/libio.h" 1 3 4 | |
3728 | # 31 "/usr/powerpc64-unknown-linux-gnu/usr/include/libio.h" 3 4 | |
3729 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/_G_config.h" 1 3 4 | |
3730 | # 15 "/usr/powerpc64-unknown-linux-gnu/usr/include/_G_config.h" 3 4 | |
3731 | # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stddef.h" 1 3 4 | |
3732 | # 16 "/usr/powerpc64-unknown-linux-gnu/usr/include/_G_config.h" 2 3 4 | |
3733 | ||
3734 | ||
3735 | ||
3736 | ||
3737 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/wchar.h" 1 3 4 | |
3738 | # 82 "/usr/powerpc64-unknown-linux-gnu/usr/include/wchar.h" 3 4 | |
3739 | typedef struct | |
3740 | { | |
3741 | int __count; | |
3742 | union | |
3743 | { | |
3744 | ||
3745 | unsigned int __wch; | |
3746 | ||
3747 | ||
3748 | ||
3749 | char __wchb[4]; | |
3750 | } __value; | |
3751 | } __mbstate_t; | |
3752 | # 21 "/usr/powerpc64-unknown-linux-gnu/usr/include/_G_config.h" 2 3 4 | |
3753 | typedef struct | |
3754 | { | |
3755 | __off_t __pos; | |
3756 | __mbstate_t __state; | |
3757 | } _G_fpos_t; | |
3758 | typedef struct | |
3759 | { | |
3760 | __off64_t __pos; | |
3761 | __mbstate_t __state; | |
3762 | } _G_fpos64_t; | |
3763 | # 32 "/usr/powerpc64-unknown-linux-gnu/usr/include/libio.h" 2 3 4 | |
3764 | # 49 "/usr/powerpc64-unknown-linux-gnu/usr/include/libio.h" 3 4 | |
3765 | # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stdarg.h" 1 3 4 | |
3766 | # 40 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stdarg.h" 3 4 | |
3767 | typedef __builtin_va_list __gnuc_va_list; | |
3768 | # 50 "/usr/powerpc64-unknown-linux-gnu/usr/include/libio.h" 2 3 4 | |
3769 | # 144 "/usr/powerpc64-unknown-linux-gnu/usr/include/libio.h" 3 4 | |
3770 | struct _IO_jump_t; struct _IO_FILE; | |
3771 | # 154 "/usr/powerpc64-unknown-linux-gnu/usr/include/libio.h" 3 4 | |
3772 | typedef void _IO_lock_t; | |
3773 | ||
3774 | ||
3775 | ||
3776 | ||
3777 | ||
3778 | struct _IO_marker { | |
3779 | struct _IO_marker *_next; | |
3780 | struct _IO_FILE *_sbuf; | |
3781 | ||
3782 | ||
3783 | ||
3784 | int _pos; | |
3785 | # 177 "/usr/powerpc64-unknown-linux-gnu/usr/include/libio.h" 3 4 | |
3786 | }; | |
3787 | ||
3788 | ||
3789 | enum __codecvt_result | |
3790 | { | |
3791 | __codecvt_ok, | |
3792 | __codecvt_partial, | |
3793 | __codecvt_error, | |
3794 | __codecvt_noconv | |
3795 | }; | |
3796 | # 245 "/usr/powerpc64-unknown-linux-gnu/usr/include/libio.h" 3 4 | |
3797 | struct _IO_FILE { | |
3798 | int _flags; | |
3799 | ||
3800 | ||
3801 | ||
3802 | ||
3803 | char* _IO_read_ptr; | |
3804 | char* _IO_read_end; | |
3805 | char* _IO_read_base; | |
3806 | char* _IO_write_base; | |
3807 | char* _IO_write_ptr; | |
3808 | char* _IO_write_end; | |
3809 | char* _IO_buf_base; | |
3810 | char* _IO_buf_end; | |
3811 | ||
3812 | char *_IO_save_base; | |
3813 | char *_IO_backup_base; | |
3814 | char *_IO_save_end; | |
3815 | ||
3816 | struct _IO_marker *_markers; | |
3817 | ||
3818 | struct _IO_FILE *_chain; | |
3819 | ||
3820 | int _fileno; | |
3821 | ||
3822 | ||
3823 | ||
3824 | int _flags2; | |
3825 | ||
3826 | __off_t _old_offset; | |
3827 | ||
3828 | ||
3829 | ||
3830 | unsigned short _cur_column; | |
3831 | signed char _vtable_offset; | |
3832 | char _shortbuf[1]; | |
3833 | ||
3834 | ||
3835 | ||
3836 | _IO_lock_t *_lock; | |
3837 | # 293 "/usr/powerpc64-unknown-linux-gnu/usr/include/libio.h" 3 4 | |
3838 | __off64_t _offset; | |
3839 | # 302 "/usr/powerpc64-unknown-linux-gnu/usr/include/libio.h" 3 4 | |
3840 | void *__pad1; | |
3841 | void *__pad2; | |
3842 | void *__pad3; | |
3843 | void *__pad4; | |
3844 | size_t __pad5; | |
3845 | ||
3846 | int _mode; | |
3847 | ||
3848 | char _unused2[15 * sizeof (int) - 4 * sizeof (void *) - sizeof (size_t)]; | |
3849 | ||
3850 | }; | |
3851 | ||
3852 | ||
3853 | ||
3854 | ||
3855 | ||
3856 | struct _IO_FILE_plus; | |
3857 | ||
3858 | extern struct _IO_FILE_plus _IO_2_1_stdin_; | |
3859 | extern struct _IO_FILE_plus _IO_2_1_stdout_; | |
3860 | extern struct _IO_FILE_plus _IO_2_1_stderr_; | |
3861 | # 338 "/usr/powerpc64-unknown-linux-gnu/usr/include/libio.h" 3 4 | |
3862 | typedef __ssize_t __io_read_fn (void *__cookie, char *__buf, size_t __nbytes); | |
3863 | ||
3864 | ||
3865 | ||
3866 | ||
3867 | ||
3868 | ||
3869 | ||
3870 | typedef __ssize_t __io_write_fn (void *__cookie, const char *__buf, | |
3871 | size_t __n); | |
3872 | ||
3873 | ||
3874 | ||
3875 | ||
3876 | ||
3877 | ||
3878 | ||
3879 | typedef int __io_seek_fn (void *__cookie, __off64_t *__pos, int __w); | |
3880 | ||
3881 | ||
3882 | typedef int __io_close_fn (void *__cookie); | |
3883 | ||
3884 | ||
3885 | ||
3886 | ||
3887 | typedef __io_read_fn cookie_read_function_t; | |
3888 | typedef __io_write_fn cookie_write_function_t; | |
3889 | typedef __io_seek_fn cookie_seek_function_t; | |
3890 | typedef __io_close_fn cookie_close_function_t; | |
3891 | ||
3892 | ||
3893 | typedef struct | |
3894 | { | |
3895 | __io_read_fn *read; | |
3896 | __io_write_fn *write; | |
3897 | __io_seek_fn *seek; | |
3898 | __io_close_fn *close; | |
3899 | } _IO_cookie_io_functions_t; | |
3900 | typedef _IO_cookie_io_functions_t cookie_io_functions_t; | |
3901 | ||
3902 | struct _IO_cookie_file; | |
3903 | ||
3904 | ||
3905 | extern void _IO_cookie_init (struct _IO_cookie_file *__cfile, int __read_write, | |
3906 | void *__cookie, _IO_cookie_io_functions_t __fns); | |
3907 | ||
3908 | ||
3909 | ||
3910 | ||
3911 | extern "C" { | |
3912 | ||
3913 | ||
3914 | extern int __underflow (_IO_FILE *); | |
3915 | extern int __uflow (_IO_FILE *); | |
3916 | extern int __overflow (_IO_FILE *, int); | |
3917 | # 434 "/usr/powerpc64-unknown-linux-gnu/usr/include/libio.h" 3 4 | |
3918 | extern int _IO_getc (_IO_FILE *__fp); | |
3919 | extern int _IO_putc (int __c, _IO_FILE *__fp); | |
3920 | extern int _IO_feof (_IO_FILE *__fp) throw (); | |
3921 | extern int _IO_ferror (_IO_FILE *__fp) throw (); | |
3922 | ||
3923 | extern int _IO_peekc_locked (_IO_FILE *__fp); | |
3924 | ||
3925 | ||
3926 | ||
3927 | ||
3928 | ||
3929 | extern void _IO_flockfile (_IO_FILE *) throw (); | |
3930 | extern void _IO_funlockfile (_IO_FILE *) throw (); | |
3931 | extern int _IO_ftrylockfile (_IO_FILE *) throw (); | |
3932 | # 464 "/usr/powerpc64-unknown-linux-gnu/usr/include/libio.h" 3 4 | |
3933 | extern int _IO_vfscanf (_IO_FILE * __restrict, const char * __restrict, | |
3934 | __gnuc_va_list, int *__restrict); | |
3935 | extern int _IO_vfprintf (_IO_FILE *__restrict, const char *__restrict, | |
3936 | __gnuc_va_list); | |
3937 | extern __ssize_t _IO_padn (_IO_FILE *, int, __ssize_t); | |
3938 | extern size_t _IO_sgetn (_IO_FILE *, void *, size_t); | |
3939 | ||
3940 | extern __off64_t _IO_seekoff (_IO_FILE *, __off64_t, int, int); | |
3941 | extern __off64_t _IO_seekpos (_IO_FILE *, __off64_t, int); | |
3942 | ||
3943 | extern void _IO_free_backup_area (_IO_FILE *) throw (); | |
3944 | # 526 "/usr/powerpc64-unknown-linux-gnu/usr/include/libio.h" 3 4 | |
3945 | } | |
3946 | # 75 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 2 3 4 | |
3947 | ||
3948 | ||
3949 | ||
3950 | ||
3951 | typedef __gnuc_va_list va_list; | |
3952 | # 108 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4 | |
3953 | ||
3954 | ||
3955 | typedef _G_fpos_t fpos_t; | |
3956 | ||
3957 | ||
3958 | ||
3959 | ||
3960 | ||
3961 | typedef _G_fpos64_t fpos64_t; | |
3962 | # 164 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4 | |
3963 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/stdio_lim.h" 1 3 4 | |
3964 | # 165 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 2 3 4 | |
3965 | ||
3966 | ||
3967 | ||
3968 | extern struct _IO_FILE *stdin; | |
3969 | extern struct _IO_FILE *stdout; | |
3970 | extern struct _IO_FILE *stderr; | |
3971 | ||
3972 | ||
3973 | ||
3974 | ||
3975 | ||
3976 | ||
3977 | ||
3978 | extern int remove (const char *__filename) throw (); | |
3979 | ||
3980 | extern int rename (const char *__old, const char *__new) throw (); | |
3981 | ||
3982 | ||
3983 | ||
3984 | ||
3985 | extern int renameat (int __oldfd, const char *__old, int __newfd, | |
3986 | const char *__new) throw (); | |
3987 | ||
3988 | ||
3989 | ||
3990 | ||
3991 | ||
3992 | ||
3993 | ||
3994 | ||
3995 | extern FILE *tmpfile (void) __attribute__ ((__warn_unused_result__)); | |
3996 | # 205 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4 | |
3997 | extern FILE *tmpfile64 (void) __attribute__ ((__warn_unused_result__)); | |
3998 | ||
3999 | ||
4000 | ||
4001 | extern char *tmpnam (char *__s) throw () __attribute__ ((__warn_unused_result__)); | |
4002 | ||
4003 | ||
4004 | ||
4005 | ||
4006 | ||
4007 | extern char *tmpnam_r (char *__s) throw () __attribute__ ((__warn_unused_result__)); | |
4008 | # 227 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4 | |
4009 | extern char *tempnam (const char *__dir, const char *__pfx) | |
4010 | throw () __attribute__ ((__malloc__)) __attribute__ ((__warn_unused_result__)); | |
4011 | ||
4012 | ||
4013 | ||
4014 | ||
4015 | ||
4016 | ||
4017 | ||
4018 | ||
4019 | extern int fclose (FILE *__stream); | |
4020 | ||
4021 | ||
4022 | ||
4023 | ||
4024 | extern int fflush (FILE *__stream); | |
4025 | ||
4026 | # 252 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4 | |
4027 | extern int fflush_unlocked (FILE *__stream); | |
4028 | # 262 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4 | |
4029 | extern int fcloseall (void); | |
4030 | ||
4031 | ||
4032 | ||
4033 | ||
4034 | ||
4035 | ||
4036 | ||
4037 | ||
4038 | ||
4039 | extern FILE *fopen (const char *__restrict __filename, | |
4040 | const char *__restrict __modes) __attribute__ ((__warn_unused_result__)); | |
4041 | ||
4042 | ||
4043 | ||
4044 | ||
4045 | extern FILE *freopen (const char *__restrict __filename, | |
4046 | const char *__restrict __modes, | |
4047 | FILE *__restrict __stream) __attribute__ ((__warn_unused_result__)); | |
4048 | # 295 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4 | |
4049 | ||
4050 | ||
4051 | extern FILE *fopen64 (const char *__restrict __filename, | |
4052 | const char *__restrict __modes) __attribute__ ((__warn_unused_result__)); | |
4053 | extern FILE *freopen64 (const char *__restrict __filename, | |
4054 | const char *__restrict __modes, | |
4055 | FILE *__restrict __stream) __attribute__ ((__warn_unused_result__)); | |
4056 | ||
4057 | ||
4058 | ||
4059 | ||
4060 | extern FILE *fdopen (int __fd, const char *__modes) throw () __attribute__ ((__warn_unused_result__)); | |
4061 | ||
4062 | ||
4063 | ||
4064 | ||
4065 | ||
4066 | extern FILE *fopencookie (void *__restrict __magic_cookie, | |
4067 | const char *__restrict __modes, | |
4068 | _IO_cookie_io_functions_t __io_funcs) throw () __attribute__ ((__warn_unused_result__)); | |
4069 | ||
4070 | ||
4071 | ||
4072 | ||
4073 | extern FILE *fmemopen (void *__s, size_t __len, const char *__modes) | |
4074 | throw () __attribute__ ((__warn_unused_result__)); | |
4075 | ||
4076 | ||
4077 | ||
4078 | ||
4079 | extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) throw () __attribute__ ((__warn_unused_result__)); | |
4080 | ||
4081 | ||
4082 | ||
4083 | ||
4084 | ||
4085 | ||
4086 | extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) throw (); | |
4087 | ||
4088 | ||
4089 | ||
4090 | extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf, | |
4091 | int __modes, size_t __n) throw (); | |
4092 | ||
4093 | ||
4094 | ||
4095 | ||
4096 | ||
4097 | extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf, | |
4098 | size_t __size) throw (); | |
4099 | ||
4100 | ||
4101 | extern void setlinebuf (FILE *__stream) throw (); | |
4102 | ||
4103 | ||
4104 | ||
4105 | ||
4106 | ||
4107 | ||
4108 | ||
4109 | ||
4110 | extern int fprintf (FILE *__restrict __stream, | |
4111 | const char *__restrict __format, ...); | |
4112 | ||
4113 | ||
4114 | ||
4115 | ||
4116 | extern int printf (const char *__restrict __format, ...); | |
4117 | ||
4118 | extern int sprintf (char *__restrict __s, | |
4119 | const char *__restrict __format, ...) throw (); | |
4120 | ||
4121 | ||
4122 | ||
4123 | ||
4124 | ||
4125 | extern int vfprintf (FILE *__restrict __s, const char *__restrict __format, | |
4126 | __gnuc_va_list __arg); | |
4127 | ||
4128 | ||
4129 | ||
4130 | ||
4131 | extern int vprintf (const char *__restrict __format, __gnuc_va_list __arg); | |
4132 | ||
4133 | extern int vsprintf (char *__restrict __s, const char *__restrict __format, | |
4134 | __gnuc_va_list __arg) throw (); | |
4135 | ||
4136 | ||
4137 | ||
4138 | ||
4139 | ||
4140 | extern int snprintf (char *__restrict __s, size_t __maxlen, | |
4141 | const char *__restrict __format, ...) | |
4142 | throw () __attribute__ ((__format__ (__printf__, 3, 4))); | |
4143 | ||
4144 | extern int vsnprintf (char *__restrict __s, size_t __maxlen, | |
4145 | const char *__restrict __format, __gnuc_va_list __arg) | |
4146 | throw () __attribute__ ((__format__ (__printf__, 3, 0))); | |
4147 | ||
4148 | ||
4149 | ||
4150 | ||
4151 | ||
4152 | ||
4153 | extern int vasprintf (char **__restrict __ptr, const char *__restrict __f, | |
4154 | __gnuc_va_list __arg) | |
4155 | throw () __attribute__ ((__format__ (__printf__, 2, 0))) __attribute__ ((__warn_unused_result__)); | |
4156 | extern int __asprintf (char **__restrict __ptr, | |
4157 | const char *__restrict __fmt, ...) | |
4158 | throw () __attribute__ ((__format__ (__printf__, 2, 3))) __attribute__ ((__warn_unused_result__)); | |
4159 | extern int asprintf (char **__restrict __ptr, | |
4160 | const char *__restrict __fmt, ...) | |
4161 | throw () __attribute__ ((__format__ (__printf__, 2, 3))) __attribute__ ((__warn_unused_result__)); | |
4162 | ||
4163 | ||
4164 | ||
4165 | ||
4166 | extern int vdprintf (int __fd, const char *__restrict __fmt, | |
4167 | __gnuc_va_list __arg) | |
4168 | __attribute__ ((__format__ (__printf__, 2, 0))); | |
4169 | extern int dprintf (int __fd, const char *__restrict __fmt, ...) | |
4170 | __attribute__ ((__format__ (__printf__, 2, 3))); | |
4171 | ||
4172 | ||
4173 | ||
4174 | ||
4175 | ||
4176 | ||
4177 | ||
4178 | ||
4179 | extern int fscanf (FILE *__restrict __stream, | |
4180 | const char *__restrict __format, ...) __attribute__ ((__warn_unused_result__)); | |
4181 | ||
4182 | ||
4183 | ||
4184 | ||
4185 | extern int scanf (const char *__restrict __format, ...) __attribute__ ((__warn_unused_result__)); | |
4186 | ||
4187 | extern int sscanf (const char *__restrict __s, | |
4188 | const char *__restrict __format, ...) throw (); | |
4189 | # 463 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4 | |
4190 | ||
4191 | ||
4192 | ||
4193 | ||
4194 | ||
4195 | ||
4196 | ||
4197 | ||
4198 | extern int vfscanf (FILE *__restrict __s, const char *__restrict __format, | |
4199 | __gnuc_va_list __arg) | |
4200 | __attribute__ ((__format__ (__scanf__, 2, 0))) __attribute__ ((__warn_unused_result__)); | |
4201 | ||
4202 | ||
4203 | ||
4204 | ||
4205 | ||
4206 | extern int vscanf (const char *__restrict __format, __gnuc_va_list __arg) | |
4207 | __attribute__ ((__format__ (__scanf__, 1, 0))) __attribute__ ((__warn_unused_result__)); | |
4208 | ||
4209 | ||
4210 | extern int vsscanf (const char *__restrict __s, | |
4211 | const char *__restrict __format, __gnuc_va_list __arg) | |
4212 | throw () __attribute__ ((__format__ (__scanf__, 2, 0))); | |
4213 | # 522 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4 | |
4214 | ||
4215 | ||
4216 | ||
4217 | ||
4218 | ||
4219 | ||
4220 | ||
4221 | ||
4222 | ||
4223 | extern int fgetc (FILE *__stream); | |
4224 | extern int getc (FILE *__stream); | |
4225 | ||
4226 | ||
4227 | ||
4228 | ||
4229 | ||
4230 | extern int getchar (void); | |
4231 | ||
4232 | # 550 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4 | |
4233 | extern int getc_unlocked (FILE *__stream); | |
4234 | extern int getchar_unlocked (void); | |
4235 | # 561 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4 | |
4236 | extern int fgetc_unlocked (FILE *__stream); | |
4237 | ||
4238 | ||
4239 | ||
4240 | ||
4241 | ||
4242 | ||
4243 | ||
4244 | ||
4245 | ||
4246 | ||
4247 | ||
4248 | extern int fputc (int __c, FILE *__stream); | |
4249 | extern int putc (int __c, FILE *__stream); | |
4250 | ||
4251 | ||
4252 | ||
4253 | ||
4254 | ||
4255 | extern int putchar (int __c); | |
4256 | ||
4257 | # 594 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4 | |
4258 | extern int fputc_unlocked (int __c, FILE *__stream); | |
4259 | ||
4260 | ||
4261 | ||
4262 | ||
4263 | ||
4264 | ||
4265 | ||
4266 | extern int putc_unlocked (int __c, FILE *__stream); | |
4267 | extern int putchar_unlocked (int __c); | |
4268 | ||
4269 | ||
4270 | ||
4271 | ||
4272 | ||
4273 | ||
4274 | extern int getw (FILE *__stream); | |
4275 | ||
4276 | ||
4277 | extern int putw (int __w, FILE *__stream); | |
4278 | ||
4279 | ||
4280 | ||
4281 | ||
4282 | ||
4283 | ||
4284 | ||
4285 | ||
4286 | extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream) | |
4287 | __attribute__ ((__warn_unused_result__)); | |
4288 | # 638 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4 | |
4289 | extern char *gets (char *__s) __attribute__ ((__warn_unused_result__)) __attribute__ ((__deprecated__)); | |
4290 | ||
4291 | ||
4292 | # 649 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4 | |
4293 | extern char *fgets_unlocked (char *__restrict __s, int __n, | |
4294 | FILE *__restrict __stream) __attribute__ ((__warn_unused_result__)); | |
4295 | # 665 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4 | |
4296 | extern __ssize_t __getdelim (char **__restrict __lineptr, | |
4297 | size_t *__restrict __n, int __delimiter, | |
4298 | FILE *__restrict __stream) __attribute__ ((__warn_unused_result__)); | |
4299 | extern __ssize_t getdelim (char **__restrict __lineptr, | |
4300 | size_t *__restrict __n, int __delimiter, | |
4301 | FILE *__restrict __stream) __attribute__ ((__warn_unused_result__)); | |
4302 | ||
4303 | ||
4304 | ||
4305 | ||
4306 | ||
4307 | ||
4308 | ||
4309 | extern __ssize_t getline (char **__restrict __lineptr, | |
4310 | size_t *__restrict __n, | |
4311 | FILE *__restrict __stream) __attribute__ ((__warn_unused_result__)); | |
4312 | ||
4313 | ||
4314 | ||
4315 | ||
4316 | ||
4317 | ||
4318 | ||
4319 | ||
4320 | extern int fputs (const char *__restrict __s, FILE *__restrict __stream); | |
4321 | ||
4322 | ||
4323 | ||
4324 | ||
4325 | ||
4326 | extern int puts (const char *__s); | |
4327 | ||
4328 | ||
4329 | ||
4330 | ||
4331 | ||
4332 | ||
4333 | extern int ungetc (int __c, FILE *__stream); | |
4334 | ||
4335 | ||
4336 | ||
4337 | ||
4338 | ||
4339 | ||
4340 | extern size_t fread (void *__restrict __ptr, size_t __size, | |
4341 | size_t __n, FILE *__restrict __stream) __attribute__ ((__warn_unused_result__)); | |
4342 | ||
4343 | ||
4344 | ||
4345 | ||
4346 | extern size_t fwrite (const void *__restrict __ptr, size_t __size, | |
4347 | size_t __n, FILE *__restrict __s); | |
4348 | ||
4349 | # 726 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4 | |
4350 | extern int fputs_unlocked (const char *__restrict __s, | |
4351 | FILE *__restrict __stream); | |
4352 | # 737 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4 | |
4353 | extern size_t fread_unlocked (void *__restrict __ptr, size_t __size, | |
4354 | size_t __n, FILE *__restrict __stream) __attribute__ ((__warn_unused_result__)); | |
4355 | extern size_t fwrite_unlocked (const void *__restrict __ptr, size_t __size, | |
4356 | size_t __n, FILE *__restrict __stream); | |
4357 | ||
4358 | ||
4359 | ||
4360 | ||
4361 | ||
4362 | ||
4363 | ||
4364 | ||
4365 | extern int fseek (FILE *__stream, long int __off, int __whence); | |
4366 | ||
4367 | ||
4368 | ||
4369 | ||
4370 | extern long int ftell (FILE *__stream) __attribute__ ((__warn_unused_result__)); | |
4371 | ||
4372 | ||
4373 | ||
4374 | ||
4375 | extern void rewind (FILE *__stream); | |
4376 | ||
4377 | # 773 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4 | |
4378 | extern int fseeko (FILE *__stream, __off_t __off, int __whence); | |
4379 | ||
4380 | ||
4381 | ||
4382 | ||
4383 | extern __off_t ftello (FILE *__stream) __attribute__ ((__warn_unused_result__)); | |
4384 | # 792 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4 | |
4385 | ||
4386 | ||
4387 | ||
4388 | ||
4389 | ||
4390 | ||
4391 | extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos); | |
4392 | ||
4393 | ||
4394 | ||
4395 | ||
4396 | extern int fsetpos (FILE *__stream, const fpos_t *__pos); | |
4397 | # 815 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4 | |
4398 | ||
4399 | ||
4400 | ||
4401 | extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence); | |
4402 | extern __off64_t ftello64 (FILE *__stream) __attribute__ ((__warn_unused_result__)); | |
4403 | extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos); | |
4404 | extern int fsetpos64 (FILE *__stream, const fpos64_t *__pos); | |
4405 | ||
4406 | ||
4407 | ||
4408 | ||
4409 | extern void clearerr (FILE *__stream) throw (); | |
4410 | ||
4411 | extern int feof (FILE *__stream) throw () __attribute__ ((__warn_unused_result__)); | |
4412 | ||
4413 | extern int ferror (FILE *__stream) throw () __attribute__ ((__warn_unused_result__)); | |
4414 | ||
4415 | ||
4416 | ||
4417 | ||
4418 | extern void clearerr_unlocked (FILE *__stream) throw (); | |
4419 | extern int feof_unlocked (FILE *__stream) throw () __attribute__ ((__warn_unused_result__)); | |
4420 | extern int ferror_unlocked (FILE *__stream) throw () __attribute__ ((__warn_unused_result__)); | |
4421 | ||
4422 | ||
4423 | ||
4424 | ||
4425 | ||
4426 | ||
4427 | ||
4428 | ||
4429 | extern void perror (const char *__s); | |
4430 | ||
4431 | ||
4432 | ||
4433 | ||
4434 | ||
4435 | ||
4436 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/sys_errlist.h" 1 3 4 | |
4437 | # 26 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/sys_errlist.h" 3 4 | |
4438 | extern int sys_nerr; | |
4439 | extern const char *const sys_errlist[]; | |
4440 | ||
4441 | ||
4442 | extern int _sys_nerr; | |
4443 | extern const char *const _sys_errlist[]; | |
4444 | # 854 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 2 3 4 | |
4445 | ||
4446 | ||
4447 | ||
4448 | ||
4449 | extern int fileno (FILE *__stream) throw () __attribute__ ((__warn_unused_result__)); | |
4450 | ||
4451 | ||
4452 | ||
4453 | ||
4454 | extern int fileno_unlocked (FILE *__stream) throw () __attribute__ ((__warn_unused_result__)); | |
4455 | # 872 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4 | |
4456 | extern FILE *popen (const char *__command, const char *__modes) __attribute__ ((__warn_unused_result__)); | |
4457 | ||
4458 | ||
4459 | ||
4460 | ||
4461 | ||
4462 | extern int pclose (FILE *__stream); | |
4463 | ||
4464 | ||
4465 | ||
4466 | ||
4467 | ||
4468 | extern char *ctermid (char *__s) throw (); | |
4469 | ||
4470 | ||
4471 | ||
4472 | ||
4473 | ||
4474 | extern char *cuserid (char *__s); | |
4475 | ||
4476 | ||
4477 | ||
4478 | ||
4479 | struct obstack; | |
4480 | ||
4481 | ||
4482 | extern int obstack_printf (struct obstack *__restrict __obstack, | |
4483 | const char *__restrict __format, ...) | |
4484 | throw () __attribute__ ((__format__ (__printf__, 2, 3))); | |
4485 | extern int obstack_vprintf (struct obstack *__restrict __obstack, | |
4486 | const char *__restrict __format, | |
4487 | __gnuc_va_list __args) | |
4488 | throw () __attribute__ ((__format__ (__printf__, 2, 0))); | |
4489 | ||
4490 | ||
4491 | ||
4492 | ||
4493 | ||
4494 | ||
4495 | ||
4496 | extern void flockfile (FILE *__stream) throw (); | |
4497 | ||
4498 | ||
4499 | ||
4500 | extern int ftrylockfile (FILE *__stream) throw () __attribute__ ((__warn_unused_result__)); | |
4501 | ||
4502 | ||
4503 | extern void funlockfile (FILE *__stream) throw (); | |
4504 | # 933 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4 | |
4505 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/stdio.h" 1 3 4 | |
4506 | # 43 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/stdio.h" 3 4 | |
4507 | extern __inline __attribute__ ((__gnu_inline__)) int | |
4508 | getchar (void) | |
4509 | { | |
4510 | return _IO_getc (stdin); | |
4511 | } | |
4512 | ||
4513 | ||
4514 | ||
4515 | ||
4516 | extern __inline __attribute__ ((__gnu_inline__)) int | |
4517 | fgetc_unlocked (FILE *__fp) | |
4518 | { | |
4519 | return (__builtin_expect (((__fp)->_IO_read_ptr >= (__fp)->_IO_read_end), 0) ? __uflow (__fp) : *(unsigned char *) (__fp)->_IO_read_ptr++); | |
4520 | } | |
4521 | ||
4522 | ||
4523 | ||
4524 | ||
4525 | ||
4526 | extern __inline __attribute__ ((__gnu_inline__)) int | |
4527 | getc_unlocked (FILE *__fp) | |
4528 | { | |
4529 | return (__builtin_expect (((__fp)->_IO_read_ptr >= (__fp)->_IO_read_end), 0) ? __uflow (__fp) : *(unsigned char *) (__fp)->_IO_read_ptr++); | |
4530 | } | |
4531 | ||
4532 | ||
4533 | extern __inline __attribute__ ((__gnu_inline__)) int | |
4534 | getchar_unlocked (void) | |
4535 | { | |
4536 | return (__builtin_expect (((stdin)->_IO_read_ptr >= (stdin)->_IO_read_end), 0) ? __uflow (stdin) : *(unsigned char *) (stdin)->_IO_read_ptr++); | |
4537 | } | |
4538 | ||
4539 | ||
4540 | ||
4541 | ||
4542 | extern __inline __attribute__ ((__gnu_inline__)) int | |
4543 | putchar (int __c) | |
4544 | { | |
4545 | return _IO_putc (__c, stdout); | |
4546 | } | |
4547 | ||
4548 | ||
4549 | ||
4550 | ||
4551 | extern __inline __attribute__ ((__gnu_inline__)) int | |
4552 | fputc_unlocked (int __c, FILE *__stream) | |
4553 | { | |
4554 | return (__builtin_expect (((__stream)->_IO_write_ptr >= (__stream)->_IO_write_end), 0) ? __overflow (__stream, (unsigned char) (__c)) : (unsigned char) (*(__stream)->_IO_write_ptr++ = (__c))); | |
4555 | } | |
4556 | ||
4557 | ||
4558 | ||
4559 | ||
4560 | ||
4561 | extern __inline __attribute__ ((__gnu_inline__)) int | |
4562 | putc_unlocked (int __c, FILE *__stream) | |
4563 | { | |
4564 | return (__builtin_expect (((__stream)->_IO_write_ptr >= (__stream)->_IO_write_end), 0) ? __overflow (__stream, (unsigned char) (__c)) : (unsigned char) (*(__stream)->_IO_write_ptr++ = (__c))); | |
4565 | } | |
4566 | ||
4567 | ||
4568 | extern __inline __attribute__ ((__gnu_inline__)) int | |
4569 | putchar_unlocked (int __c) | |
4570 | { | |
4571 | return (__builtin_expect (((stdout)->_IO_write_ptr >= (stdout)->_IO_write_end), 0) ? __overflow (stdout, (unsigned char) (__c)) : (unsigned char) (*(stdout)->_IO_write_ptr++ = (__c))); | |
4572 | } | |
4573 | ||
4574 | ||
4575 | ||
4576 | ||
4577 | ||
4578 | extern __inline __attribute__ ((__gnu_inline__)) __ssize_t | |
4579 | getline (char **__lineptr, size_t *__n, FILE *__stream) | |
4580 | { | |
4581 | return __getdelim (__lineptr, __n, '\n', __stream); | |
4582 | } | |
4583 | ||
4584 | ||
4585 | ||
4586 | ||
4587 | ||
4588 | extern __inline __attribute__ ((__gnu_inline__)) int | |
4589 | __attribute__ ((__leaf__)) feof_unlocked (FILE *__stream) throw () | |
4590 | { | |
4591 | return (((__stream)->_flags & 0x10) != 0); | |
4592 | } | |
4593 | ||
4594 | ||
4595 | extern __inline __attribute__ ((__gnu_inline__)) int | |
4596 | __attribute__ ((__leaf__)) ferror_unlocked (FILE *__stream) throw () | |
4597 | { | |
4598 | return (((__stream)->_flags & 0x20) != 0); | |
4599 | } | |
4600 | # 934 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 2 3 4 | |
4601 | ||
4602 | ||
4603 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/stdio2.h" 1 3 4 | |
4604 | # 23 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/stdio2.h" 3 4 | |
4605 | extern int __sprintf_chk (char *__restrict __s, int __flag, size_t __slen, | |
4606 | const char *__restrict __format, ...) throw (); | |
4607 | extern int __vsprintf_chk (char *__restrict __s, int __flag, size_t __slen, | |
4608 | const char *__restrict __format, | |
4609 | __gnuc_va_list __ap) throw (); | |
4610 | ||
4611 | ||
4612 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) int | |
4613 | __attribute__ ((__leaf__)) sprintf (char *__restrict __s, const char *__restrict __fmt, ...) throw () | |
4614 | { | |
4615 | return __builtin___sprintf_chk (__s, 2 - 1, | |
4616 | __builtin_object_size (__s, 2 > 1), __fmt, __builtin_va_arg_pack ()); | |
4617 | } | |
4618 | ||
4619 | ||
4620 | ||
4621 | ||
4622 | ||
4623 | ||
4624 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) int | |
4625 | __attribute__ ((__leaf__)) vsprintf (char *__restrict __s, const char *__restrict __fmt, __gnuc_va_list __ap) throw () | |
4626 | ||
4627 | { | |
4628 | return __builtin___vsprintf_chk (__s, 2 - 1, | |
4629 | __builtin_object_size (__s, 2 > 1), __fmt, __ap); | |
4630 | } | |
4631 | ||
4632 | ||
4633 | ||
4634 | extern int __snprintf_chk (char *__restrict __s, size_t __n, int __flag, | |
4635 | size_t __slen, const char *__restrict __format, | |
4636 | ...) throw (); | |
4637 | extern int __vsnprintf_chk (char *__restrict __s, size_t __n, int __flag, | |
4638 | size_t __slen, const char *__restrict __format, | |
4639 | __gnuc_va_list __ap) throw (); | |
4640 | ||
4641 | ||
4642 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) int | |
4643 | __attribute__ ((__leaf__)) snprintf (char *__restrict __s, size_t __n, const char *__restrict __fmt, ...) throw () | |
4644 | ||
4645 | { | |
4646 | return __builtin___snprintf_chk (__s, __n, 2 - 1, | |
4647 | __builtin_object_size (__s, 2 > 1), __fmt, __builtin_va_arg_pack ()); | |
4648 | } | |
4649 | ||
4650 | ||
4651 | ||
4652 | ||
4653 | ||
4654 | ||
4655 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) int | |
4656 | __attribute__ ((__leaf__)) vsnprintf (char *__restrict __s, size_t __n, const char *__restrict __fmt, __gnuc_va_list __ap) throw () | |
4657 | ||
4658 | { | |
4659 | return __builtin___vsnprintf_chk (__s, __n, 2 - 1, | |
4660 | __builtin_object_size (__s, 2 > 1), __fmt, __ap); | |
4661 | } | |
4662 | ||
4663 | ||
4664 | ||
4665 | ||
4666 | ||
4667 | extern int __fprintf_chk (FILE *__restrict __stream, int __flag, | |
4668 | const char *__restrict __format, ...); | |
4669 | extern int __printf_chk (int __flag, const char *__restrict __format, ...); | |
4670 | extern int __vfprintf_chk (FILE *__restrict __stream, int __flag, | |
4671 | const char *__restrict __format, __gnuc_va_list __ap); | |
4672 | extern int __vprintf_chk (int __flag, const char *__restrict __format, | |
4673 | __gnuc_va_list __ap); | |
4674 | ||
4675 | ||
4676 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) int | |
4677 | fprintf (FILE *__restrict __stream, const char *__restrict __fmt, ...) | |
4678 | { | |
4679 | return __fprintf_chk (__stream, 2 - 1, __fmt, | |
4680 | __builtin_va_arg_pack ()); | |
4681 | } | |
4682 | ||
4683 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) int | |
4684 | printf (const char *__restrict __fmt, ...) | |
4685 | { | |
4686 | return __printf_chk (2 - 1, __fmt, __builtin_va_arg_pack ()); | |
4687 | } | |
4688 | ||
4689 | ||
4690 | ||
4691 | ||
4692 | ||
4693 | ||
4694 | ||
4695 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) int | |
4696 | vprintf (const char *__restrict __fmt, __gnuc_va_list __ap) | |
4697 | { | |
4698 | ||
4699 | return __vfprintf_chk (stdout, 2 - 1, __fmt, __ap); | |
4700 | ||
4701 | ||
4702 | ||
4703 | } | |
4704 | ||
4705 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) int | |
4706 | vfprintf (FILE *__restrict __stream, | |
4707 | const char *__restrict __fmt, __gnuc_va_list __ap) | |
4708 | { | |
4709 | return __vfprintf_chk (__stream, 2 - 1, __fmt, __ap); | |
4710 | } | |
4711 | ||
4712 | ||
4713 | extern int __dprintf_chk (int __fd, int __flag, const char *__restrict __fmt, | |
4714 | ...) __attribute__ ((__format__ (__printf__, 3, 4))); | |
4715 | extern int __vdprintf_chk (int __fd, int __flag, | |
4716 | const char *__restrict __fmt, __gnuc_va_list __arg) | |
4717 | __attribute__ ((__format__ (__printf__, 3, 0))); | |
4718 | ||
4719 | ||
4720 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) int | |
4721 | dprintf (int __fd, const char *__restrict __fmt, ...) | |
4722 | { | |
4723 | return __dprintf_chk (__fd, 2 - 1, __fmt, | |
4724 | __builtin_va_arg_pack ()); | |
4725 | } | |
4726 | ||
4727 | ||
4728 | ||
4729 | ||
4730 | ||
4731 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) int | |
4732 | vdprintf (int __fd, const char *__restrict __fmt, __gnuc_va_list __ap) | |
4733 | { | |
4734 | return __vdprintf_chk (__fd, 2 - 1, __fmt, __ap); | |
4735 | } | |
4736 | ||
4737 | ||
4738 | ||
4739 | ||
4740 | extern int __asprintf_chk (char **__restrict __ptr, int __flag, | |
4741 | const char *__restrict __fmt, ...) | |
4742 | throw () __attribute__ ((__format__ (__printf__, 3, 4))) __attribute__ ((__warn_unused_result__)); | |
4743 | extern int __vasprintf_chk (char **__restrict __ptr, int __flag, | |
4744 | const char *__restrict __fmt, __gnuc_va_list __arg) | |
4745 | throw () __attribute__ ((__format__ (__printf__, 3, 0))) __attribute__ ((__warn_unused_result__)); | |
4746 | extern int __obstack_printf_chk (struct obstack *__restrict __obstack, | |
4747 | int __flag, const char *__restrict __format, | |
4748 | ...) | |
4749 | throw () __attribute__ ((__format__ (__printf__, 3, 4))); | |
4750 | extern int __obstack_vprintf_chk (struct obstack *__restrict __obstack, | |
4751 | int __flag, | |
4752 | const char *__restrict __format, | |
4753 | __gnuc_va_list __args) | |
4754 | throw () __attribute__ ((__format__ (__printf__, 3, 0))); | |
4755 | ||
4756 | ||
4757 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) int | |
4758 | __attribute__ ((__leaf__)) asprintf (char **__restrict __ptr, const char *__restrict __fmt, ...) throw () | |
4759 | { | |
4760 | return __asprintf_chk (__ptr, 2 - 1, __fmt, | |
4761 | __builtin_va_arg_pack ()); | |
4762 | } | |
4763 | ||
4764 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) int | |
4765 | __attribute__ ((__leaf__)) __asprintf (char **__restrict __ptr, const char *__restrict __fmt, ...) throw () | |
4766 | ||
4767 | { | |
4768 | return __asprintf_chk (__ptr, 2 - 1, __fmt, | |
4769 | __builtin_va_arg_pack ()); | |
4770 | } | |
4771 | ||
4772 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) int | |
4773 | __attribute__ ((__leaf__)) obstack_printf (struct obstack *__restrict __obstack, const char *__restrict __fmt, ...) throw () | |
4774 | ||
4775 | { | |
4776 | return __obstack_printf_chk (__obstack, 2 - 1, __fmt, | |
4777 | __builtin_va_arg_pack ()); | |
4778 | } | |
4779 | # 206 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/stdio2.h" 3 4 | |
4780 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) int | |
4781 | __attribute__ ((__leaf__)) vasprintf (char **__restrict __ptr, const char *__restrict __fmt, __gnuc_va_list __ap) throw () | |
4782 | ||
4783 | { | |
4784 | return __vasprintf_chk (__ptr, 2 - 1, __fmt, __ap); | |
4785 | } | |
4786 | ||
4787 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) int | |
4788 | __attribute__ ((__leaf__)) obstack_vprintf (struct obstack *__restrict __obstack, const char *__restrict __fmt, __gnuc_va_list __ap) throw () | |
4789 | ||
4790 | { | |
4791 | return __obstack_vprintf_chk (__obstack, 2 - 1, __fmt, | |
4792 | __ap); | |
4793 | } | |
4794 | # 241 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/stdio2.h" 3 4 | |
4795 | extern char *__fgets_chk (char *__restrict __s, size_t __size, int __n, | |
4796 | FILE *__restrict __stream) __attribute__ ((__warn_unused_result__)); | |
4797 | extern char *__fgets_alias (char *__restrict __s, int __n, FILE *__restrict __stream) __asm__ ("" "fgets") | |
4798 | ||
4799 | __attribute__ ((__warn_unused_result__)); | |
4800 | extern char *__fgets_chk_warn (char *__restrict __s, size_t __size, int __n, FILE *__restrict __stream) __asm__ ("" "__fgets_chk") | |
4801 | ||
4802 | ||
4803 | __attribute__ ((__warn_unused_result__)) __attribute__((__warning__ ("fgets called with bigger size than length " "of destination buffer"))) | |
4804 | ; | |
4805 | ||
4806 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) __attribute__ ((__warn_unused_result__)) char * | |
4807 | fgets (char *__restrict __s, int __n, FILE *__restrict __stream) | |
4808 | { | |
4809 | if (__builtin_object_size (__s, 2 > 1) != (size_t) -1) | |
4810 | { | |
4811 | if (!__builtin_constant_p (__n) || __n <= 0) | |
4812 | return __fgets_chk (__s, __builtin_object_size (__s, 2 > 1), __n, __stream); | |
4813 | ||
4814 | if ((size_t) __n > __builtin_object_size (__s, 2 > 1)) | |
4815 | return __fgets_chk_warn (__s, __builtin_object_size (__s, 2 > 1), __n, __stream); | |
4816 | } | |
4817 | return __fgets_alias (__s, __n, __stream); | |
4818 | } | |
4819 | ||
4820 | extern size_t __fread_chk (void *__restrict __ptr, size_t __ptrlen, | |
4821 | size_t __size, size_t __n, | |
4822 | FILE *__restrict __stream) __attribute__ ((__warn_unused_result__)); | |
4823 | extern size_t __fread_alias (void *__restrict __ptr, size_t __size, size_t __n, FILE *__restrict __stream) __asm__ ("" "fread") | |
4824 | ||
4825 | ||
4826 | __attribute__ ((__warn_unused_result__)); | |
4827 | extern size_t __fread_chk_warn (void *__restrict __ptr, size_t __ptrlen, size_t __size, size_t __n, FILE *__restrict __stream) __asm__ ("" "__fread_chk") | |
4828 | ||
4829 | ||
4830 | ||
4831 | ||
4832 | __attribute__ ((__warn_unused_result__)) __attribute__((__warning__ ("fread called with bigger size * nmemb than length " "of destination buffer"))) | |
4833 | ; | |
4834 | ||
4835 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) __attribute__ ((__warn_unused_result__)) size_t | |
4836 | fread (void *__restrict __ptr, size_t __size, size_t __n, | |
4837 | FILE *__restrict __stream) | |
4838 | { | |
4839 | if (__builtin_object_size (__ptr, 0) != (size_t) -1) | |
4840 | { | |
4841 | if (!__builtin_constant_p (__size) | |
4842 | || !__builtin_constant_p (__n) | |
4843 | || (__size | __n) >= (((size_t) 1) << (8 * sizeof (size_t) / 2))) | |
4844 | return __fread_chk (__ptr, __builtin_object_size (__ptr, 0), __size, __n, __stream); | |
4845 | ||
4846 | if (__size * __n > __builtin_object_size (__ptr, 0)) | |
4847 | return __fread_chk_warn (__ptr, __builtin_object_size (__ptr, 0), __size, __n, __stream); | |
4848 | } | |
4849 | return __fread_alias (__ptr, __size, __n, __stream); | |
4850 | } | |
4851 | ||
4852 | ||
4853 | extern char *__fgets_unlocked_chk (char *__restrict __s, size_t __size, | |
4854 | int __n, FILE *__restrict __stream) __attribute__ ((__warn_unused_result__)); | |
4855 | extern char *__fgets_unlocked_alias (char *__restrict __s, int __n, FILE *__restrict __stream) __asm__ ("" "fgets_unlocked") | |
4856 | ||
4857 | __attribute__ ((__warn_unused_result__)); | |
4858 | extern char *__fgets_unlocked_chk_warn (char *__restrict __s, size_t __size, int __n, FILE *__restrict __stream) __asm__ ("" "__fgets_unlocked_chk") | |
4859 | ||
4860 | ||
4861 | __attribute__ ((__warn_unused_result__)) __attribute__((__warning__ ("fgets_unlocked called with bigger size than length " "of destination buffer"))) | |
4862 | ; | |
4863 | ||
4864 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) __attribute__ ((__warn_unused_result__)) char * | |
4865 | fgets_unlocked (char *__restrict __s, int __n, FILE *__restrict __stream) | |
4866 | { | |
4867 | if (__builtin_object_size (__s, 2 > 1) != (size_t) -1) | |
4868 | { | |
4869 | if (!__builtin_constant_p (__n) || __n <= 0) | |
4870 | return __fgets_unlocked_chk (__s, __builtin_object_size (__s, 2 > 1), __n, __stream); | |
4871 | ||
4872 | if ((size_t) __n > __builtin_object_size (__s, 2 > 1)) | |
4873 | return __fgets_unlocked_chk_warn (__s, __builtin_object_size (__s, 2 > 1), __n, __stream); | |
4874 | } | |
4875 | return __fgets_unlocked_alias (__s, __n, __stream); | |
4876 | } | |
4877 | ||
4878 | ||
4879 | ||
4880 | ||
4881 | extern size_t __fread_unlocked_chk (void *__restrict __ptr, size_t __ptrlen, | |
4882 | size_t __size, size_t __n, | |
4883 | FILE *__restrict __stream) __attribute__ ((__warn_unused_result__)); | |
4884 | extern size_t __fread_unlocked_alias (void *__restrict __ptr, size_t __size, size_t __n, FILE *__restrict __stream) __asm__ ("" "fread_unlocked") | |
4885 | ||
4886 | ||
4887 | __attribute__ ((__warn_unused_result__)); | |
4888 | extern size_t __fread_unlocked_chk_warn (void *__restrict __ptr, size_t __ptrlen, size_t __size, size_t __n, FILE *__restrict __stream) __asm__ ("" "__fread_unlocked_chk") | |
4889 | ||
4890 | ||
4891 | ||
4892 | ||
4893 | __attribute__ ((__warn_unused_result__)) __attribute__((__warning__ ("fread_unlocked called with bigger size * nmemb than " "length of destination buffer"))) | |
4894 | ; | |
4895 | ||
4896 | extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) __attribute__ ((__warn_unused_result__)) size_t | |
4897 | fread_unlocked (void *__restrict __ptr, size_t __size, size_t __n, | |
4898 | FILE *__restrict __stream) | |
4899 | { | |
4900 | if (__builtin_object_size (__ptr, 0) != (size_t) -1) | |
4901 | { | |
4902 | if (!__builtin_constant_p (__size) | |
4903 | || !__builtin_constant_p (__n) | |
4904 | || (__size | __n) >= (((size_t) 1) << (8 * sizeof (size_t) / 2))) | |
4905 | return __fread_unlocked_chk (__ptr, __builtin_object_size (__ptr, 0), __size, __n, | |
4906 | __stream); | |
4907 | ||
4908 | if (__size * __n > __builtin_object_size (__ptr, 0)) | |
4909 | return __fread_unlocked_chk_warn (__ptr, __builtin_object_size (__ptr, 0), __size, __n, | |
4910 | __stream); | |
4911 | } | |
4912 | ||
4913 | ||
4914 | if (__builtin_constant_p (__size) | |
4915 | && __builtin_constant_p (__n) | |
4916 | && (__size | __n) < (((size_t) 1) << (8 * sizeof (size_t) / 2)) | |
4917 | && __size * __n <= 8) | |
4918 | { | |
4919 | size_t __cnt = __size * __n; | |
4920 | char *__cptr = (char *) __ptr; | |
4921 | if (__cnt == 0) | |
4922 | return 0; | |
4923 | ||
4924 | for (; __cnt > 0; --__cnt) | |
4925 | { | |
4926 | int __c = (__builtin_expect (((__stream)->_IO_read_ptr >= (__stream)->_IO_read_end), 0) ? __uflow (__stream) : *(unsigned char *) (__stream)->_IO_read_ptr++); | |
4927 | if (__c == (-1)) | |
4928 | break; | |
4929 | *__cptr++ = __c; | |
4930 | } | |
4931 | return (__cptr - (char *) __ptr) / __size; | |
4932 | } | |
4933 | ||
4934 | return __fread_unlocked_alias (__ptr, __size, __n, __stream); | |
4935 | } | |
4936 | # 937 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 2 3 4 | |
4937 | ||
4938 | ||
4939 | ||
4940 | ||
4941 | ||
4942 | } | |
4943 | # 62 "jsprf.h" 2 | |
4944 | # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stdarg.h" 1 3 4 | |
4945 | # 63 "jsprf.h" 2 | |
4946 | ||
4947 | extern "C" { | |
4948 | ||
4949 | ||
4950 | ||
4951 | ||
4952 | ||
4953 | ||
4954 | extern __attribute__((visibility ("default"))) JSUint32 JS_snprintf(char *out, JSUint32 outlen, const char *fmt, ...); | |
4955 | ||
4956 | ||
4957 | ||
4958 | ||
4959 | ||
4960 | ||
4961 | extern __attribute__((visibility ("default"))) char* JS_smprintf(const char *fmt, ...); | |
4962 | ||
4963 | ||
4964 | ||
4965 | ||
4966 | extern __attribute__((visibility ("default"))) void JS_smprintf_free(char *mem); | |
4967 | # 92 "jsprf.h" | |
4968 | extern __attribute__((visibility ("default"))) char* JS_sprintf_append(char *last, const char *fmt, ...); | |
4969 | # 101 "jsprf.h" | |
4970 | typedef JSIntn (*JSStuffFunc)(void *arg, const char *s, JSUint32 slen); | |
4971 | ||
4972 | extern __attribute__((visibility ("default"))) JSUint32 JS_sxprintf(JSStuffFunc f, void *arg, const char *fmt, ...); | |
4973 | ||
4974 | ||
4975 | ||
4976 | ||
4977 | extern __attribute__((visibility ("default"))) JSUint32 JS_vsnprintf(char *out, JSUint32 outlen, const char *fmt, va_list ap); | |
4978 | extern __attribute__((visibility ("default"))) char* JS_vsmprintf(const char *fmt, va_list ap); | |
4979 | extern __attribute__((visibility ("default"))) char* JS_vsprintf_append(char *last, const char *fmt, va_list ap); | |
4980 | extern __attribute__((visibility ("default"))) JSUint32 JS_vsxprintf(JSStuffFunc f, void *arg, const char *fmt, va_list ap); | |
4981 | # 146 "jsprf.h" | |
4982 | extern __attribute__((visibility ("default"))) JSInt32 JS_sscanf(const char *buf, const char *fmt, ...); | |
4983 | ||
4984 | } | |
4985 | # 51 "jsxml.cpp" 2 | |
4986 | ||
4987 | # 1 "jsapi.h" 1 | |
4988 | # 46 "jsapi.h" | |
4989 | # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stddef.h" 1 3 4 | |
4990 | # 47 "jsapi.h" 2 | |
4991 | ||
4992 | ||
4993 | # 1 "jspubtd.h" 1 | |
4994 | # 47 "jspubtd.h" | |
4995 | # 1 "jsval.h" 1 | |
4996 | # 50 "jsval.h" | |
4997 | extern "C" { | |
4998 | # 92 "jsval.h" | |
4999 | enum JSValueType | |
5000 | { | |
5001 | JSVAL_TYPE_DOUBLE = 0x00, | |
5002 | JSVAL_TYPE_INT32 = 0x01, | |
5003 | JSVAL_TYPE_UNDEFINED = 0x02, | |
5004 | JSVAL_TYPE_BOOLEAN = 0x03, | |
5005 | JSVAL_TYPE_MAGIC = 0x04, | |
5006 | JSVAL_TYPE_STRING = 0x05, | |
5007 | JSVAL_TYPE_NULL = 0x06, | |
5008 | JSVAL_TYPE_OBJECT = 0x07, | |
5009 | ||
5010 | ||
5011 | ||
5012 | JSVAL_TYPE_NONFUNOBJ = 0x57, | |
5013 | JSVAL_TYPE_FUNOBJ = 0x67, | |
5014 | ||
5015 | JSVAL_TYPE_STRORNULL = 0x97, | |
5016 | JSVAL_TYPE_OBJORNULL = 0x98, | |
5017 | ||
5018 | JSVAL_TYPE_BOXED = 0x99 | |
5019 | } __attribute__((packed)); | |
5020 | ||
5021 | typedef int js_static_assert0[(sizeof(JSValueType) == 1) ? 1 : -1]; | |
5022 | # 136 "jsval.h" | |
5023 | enum JSValueTag | |
5024 | { | |
5025 | JSVAL_TAG_MAX_DOUBLE = 0x1FFF0, | |
5026 | JSVAL_TAG_INT32 = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_INT32, | |
5027 | JSVAL_TAG_UNDEFINED = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_UNDEFINED, | |
5028 | JSVAL_TAG_STRING = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_STRING, | |
5029 | JSVAL_TAG_BOOLEAN = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_BOOLEAN, | |
5030 | JSVAL_TAG_MAGIC = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_MAGIC, | |
5031 | JSVAL_TAG_NULL = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_NULL, | |
5032 | JSVAL_TAG_OBJECT = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_OBJECT | |
5033 | } __attribute__((packed)); | |
5034 | ||
5035 | typedef int js_static_assert1[(sizeof(JSValueTag) == sizeof(uint32)) ? 1 : -1]; | |
5036 | ||
5037 | enum JSValueShiftedTag | |
5038 | { | |
5039 | JSVAL_SHIFTED_TAG_MAX_DOUBLE = ((((uint64)JSVAL_TAG_MAX_DOUBLE) << 47) | 0xFFFFFFFF), | |
5040 | JSVAL_SHIFTED_TAG_INT32 = (((uint64)JSVAL_TAG_INT32) << 47), | |
5041 | JSVAL_SHIFTED_TAG_UNDEFINED = (((uint64)JSVAL_TAG_UNDEFINED) << 47), | |
5042 | JSVAL_SHIFTED_TAG_STRING = (((uint64)JSVAL_TAG_STRING) << 47), | |
5043 | JSVAL_SHIFTED_TAG_BOOLEAN = (((uint64)JSVAL_TAG_BOOLEAN) << 47), | |
5044 | JSVAL_SHIFTED_TAG_MAGIC = (((uint64)JSVAL_TAG_MAGIC) << 47), | |
5045 | JSVAL_SHIFTED_TAG_NULL = (((uint64)JSVAL_TAG_NULL) << 47), | |
5046 | JSVAL_SHIFTED_TAG_OBJECT = (((uint64)JSVAL_TAG_OBJECT) << 47) | |
5047 | } __attribute__((packed)); | |
5048 | ||
5049 | typedef int js_static_assert2[(sizeof(JSValueShiftedTag) == sizeof(uint64)) ? 1 : -1]; | |
5050 | # 252 "jsval.h" | |
5051 | typedef enum JSWhyMagic | |
5052 | { | |
5053 | JS_ARRAY_HOLE, | |
5054 | JS_ARGS_HOLE, | |
5055 | JS_NATIVE_ENUMERATE, | |
5056 | ||
5057 | ||
5058 | JS_NO_ITER_VALUE, | |
5059 | JS_GENERATOR_CLOSING, | |
5060 | JS_NO_CONSTANT, | |
5061 | JS_THIS_POISON, | |
5062 | JS_ARG_POISON, | |
5063 | JS_SERIALIZE_NO_NODE, | |
5064 | JS_GENERIC_MAGIC | |
5065 | } JSWhyMagic; | |
5066 | ||
5067 | typedef struct JSString JSString; | |
5068 | typedef struct JSFlatString JSFlatString; | |
5069 | typedef struct JSObject JSObject; | |
5070 | # 294 "jsval.h" | |
5071 | typedef union jsval_layout | |
5072 | { | |
5073 | uint64 asBits; | |
5074 | ||
5075 | ||
5076 | struct { | |
5077 | uint64 payload47 : 47; | |
5078 | JSValueTag tag : 17; | |
5079 | } debugView; | |
5080 | ||
5081 | struct { | |
5082 | union { | |
5083 | int32 i32; | |
5084 | uint32 u32; | |
5085 | JSWhyMagic why; | |
5086 | jsuword word; | |
5087 | } payload; | |
5088 | } s; | |
5089 | double asDouble; | |
5090 | void *asPtr; | |
5091 | } jsval_layout; | |
5092 | # 564 "jsval.h" | |
5093 | static __attribute__((always_inline)) inline JSBool | |
5094 | JSVAL_IS_DOUBLE_IMPL(jsval_layout l) | |
5095 | { | |
5096 | return l.asBits <= JSVAL_SHIFTED_TAG_MAX_DOUBLE; | |
5097 | } | |
5098 | ||
5099 | static __attribute__((always_inline)) inline jsval_layout | |
5100 | DOUBLE_TO_JSVAL_IMPL(double d) | |
5101 | { | |
5102 | jsval_layout l; | |
5103 | l.asDouble = d; | |
5104 | ((void) 0); | |
5105 | return l; | |
5106 | } | |
5107 | ||
5108 | static __attribute__((always_inline)) inline JSBool | |
5109 | JSVAL_IS_INT32_IMPL(jsval_layout l) | |
5110 | { | |
5111 | return (uint32)(l.asBits >> 47) == JSVAL_TAG_INT32; | |
5112 | } | |
5113 | ||
5114 | static __attribute__((always_inline)) inline int32 | |
5115 | JSVAL_TO_INT32_IMPL(jsval_layout l) | |
5116 | { | |
5117 | return (int32)l.asBits; | |
5118 | } | |
5119 | ||
5120 | static __attribute__((always_inline)) inline jsval_layout | |
5121 | INT32_TO_JSVAL_IMPL(int32 i32) | |
5122 | { | |
5123 | jsval_layout l; | |
5124 | l.asBits = ((uint64)(uint32)i32) | JSVAL_SHIFTED_TAG_INT32; | |
5125 | return l; | |
5126 | } | |
5127 | ||
5128 | static __attribute__((always_inline)) inline JSBool | |
5129 | JSVAL_IS_NUMBER_IMPL(jsval_layout l) | |
5130 | { | |
5131 | return l.asBits < JSVAL_SHIFTED_TAG_UNDEFINED; | |
5132 | } | |
5133 | ||
5134 | static __attribute__((always_inline)) inline JSBool | |
5135 | JSVAL_IS_UNDEFINED_IMPL(jsval_layout l) | |
5136 | { | |
5137 | return l.asBits == JSVAL_SHIFTED_TAG_UNDEFINED; | |
5138 | } | |
5139 | ||
5140 | static __attribute__((always_inline)) inline JSBool | |
5141 | JSVAL_IS_STRING_IMPL(jsval_layout l) | |
5142 | { | |
5143 | return (uint32)(l.asBits >> 47) == JSVAL_TAG_STRING; | |
5144 | } | |
5145 | ||
5146 | static __attribute__((always_inline)) inline jsval_layout | |
5147 | STRING_TO_JSVAL_IMPL(JSString *str) | |
5148 | { | |
5149 | jsval_layout l; | |
5150 | uint64 strBits = (uint64)str; | |
5151 | ((void) 0); | |
5152 | ((void) 0); | |
5153 | l.asBits = strBits | JSVAL_SHIFTED_TAG_STRING; | |
5154 | return l; | |
5155 | } | |
5156 | ||
5157 | static __attribute__((always_inline)) inline JSString * | |
5158 | JSVAL_TO_STRING_IMPL(jsval_layout l) | |
5159 | { | |
5160 | return (JSString *)(l.asBits & 0x00007FFFFFFFFFFFLL); | |
5161 | } | |
5162 | ||
5163 | static __attribute__((always_inline)) inline JSBool | |
5164 | JSVAL_IS_BOOLEAN_IMPL(jsval_layout l) | |
5165 | { | |
5166 | return (uint32)(l.asBits >> 47) == JSVAL_TAG_BOOLEAN; | |
5167 | } | |
5168 | ||
5169 | static __attribute__((always_inline)) inline JSBool | |
5170 | JSVAL_TO_BOOLEAN_IMPL(jsval_layout l) | |
5171 | { | |
5172 | return (JSBool)l.asBits; | |
5173 | } | |
5174 | ||
5175 | static __attribute__((always_inline)) inline jsval_layout | |
5176 | BOOLEAN_TO_JSVAL_IMPL(JSBool b) | |
5177 | { | |
5178 | jsval_layout l; | |
5179 | l.asBits = ((uint64)(uint32)b) | JSVAL_SHIFTED_TAG_BOOLEAN; | |
5180 | return l; | |
5181 | } | |
5182 | ||
5183 | static __attribute__((always_inline)) inline JSBool | |
5184 | JSVAL_IS_MAGIC_IMPL(jsval_layout l) | |
5185 | { | |
5186 | return (l.asBits >> 47) == JSVAL_TAG_MAGIC; | |
5187 | } | |
5188 | ||
5189 | static __attribute__((always_inline)) inline JSObject * | |
5190 | MAGIC_JSVAL_TO_OBJECT_OR_NULL_IMPL(jsval_layout l) | |
5191 | { | |
5192 | uint64 ptrBits = l.asBits & 0x00007FFFFFFFFFFFLL; | |
5193 | ((void) 0); | |
5194 | ((void) 0); | |
5195 | return (JSObject *)ptrBits; | |
5196 | } | |
5197 | ||
5198 | static __attribute__((always_inline)) inline JSBool | |
5199 | JSVAL_IS_PRIMITIVE_IMPL(jsval_layout l) | |
5200 | { | |
5201 | return l.asBits < JSVAL_SHIFTED_TAG_OBJECT; | |
5202 | } | |
5203 | ||
5204 | static __attribute__((always_inline)) inline JSBool | |
5205 | JSVAL_IS_OBJECT_IMPL(jsval_layout l) | |
5206 | { | |
5207 | ((void) 0); | |
5208 | return l.asBits >= JSVAL_SHIFTED_TAG_OBJECT; | |
5209 | } | |
5210 | ||
5211 | static __attribute__((always_inline)) inline JSBool | |
5212 | JSVAL_IS_OBJECT_OR_NULL_IMPL(jsval_layout l) | |
5213 | { | |
5214 | ((void) 0); | |
5215 | return l.asBits >= JSVAL_SHIFTED_TAG_NULL; | |
5216 | } | |
5217 | ||
5218 | static __attribute__((always_inline)) inline JSObject * | |
5219 | JSVAL_TO_OBJECT_IMPL(jsval_layout l) | |
5220 | { | |
5221 | uint64 ptrBits = l.asBits & 0x00007FFFFFFFFFFFLL; | |
5222 | ((void) 0); | |
5223 | return (JSObject *)ptrBits; | |
5224 | } | |
5225 | ||
5226 | static __attribute__((always_inline)) inline jsval_layout | |
5227 | OBJECT_TO_JSVAL_IMPL(JSObject *obj) | |
5228 | { | |
5229 | jsval_layout l; | |
5230 | uint64 objBits = (uint64)obj; | |
5231 | ((void) 0); | |
5232 | ((void) 0); | |
5233 | l.asBits = objBits | JSVAL_SHIFTED_TAG_OBJECT; | |
5234 | return l; | |
5235 | } | |
5236 | ||
5237 | static __attribute__((always_inline)) inline JSBool | |
5238 | JSVAL_IS_NULL_IMPL(jsval_layout l) | |
5239 | { | |
5240 | return l.asBits == JSVAL_SHIFTED_TAG_NULL; | |
5241 | } | |
5242 | ||
5243 | static __attribute__((always_inline)) inline JSBool | |
5244 | JSVAL_IS_GCTHING_IMPL(jsval_layout l) | |
5245 | { | |
5246 | return l.asBits >= JSVAL_SHIFTED_TAG_STRING; | |
5247 | } | |
5248 | ||
5249 | static __attribute__((always_inline)) inline void * | |
5250 | JSVAL_TO_GCTHING_IMPL(jsval_layout l) | |
5251 | { | |
5252 | uint64 ptrBits = l.asBits & 0x00007FFFFFFFFFFFLL; | |
5253 | ((void) 0); | |
5254 | return (void *)ptrBits; | |
5255 | } | |
5256 | ||
5257 | static __attribute__((always_inline)) inline JSBool | |
5258 | JSVAL_IS_TRACEABLE_IMPL(jsval_layout l) | |
5259 | { | |
5260 | return JSVAL_IS_GCTHING_IMPL(l) && !JSVAL_IS_NULL_IMPL(l); | |
5261 | } | |
5262 | ||
5263 | static __attribute__((always_inline)) inline uint32 | |
5264 | JSVAL_TRACE_KIND_IMPL(jsval_layout l) | |
5265 | { | |
5266 | return (uint32)(JSBool)!(JSVAL_IS_OBJECT_IMPL(l)); | |
5267 | } | |
5268 | ||
5269 | static __attribute__((always_inline)) inline jsval_layout | |
5270 | PRIVATE_PTR_TO_JSVAL_IMPL(void *ptr) | |
5271 | { | |
5272 | jsval_layout l; | |
5273 | uint64 ptrBits = (uint64)ptr; | |
5274 | ((void) 0); | |
5275 | l.asBits = ptrBits >> 1; | |
5276 | ((void) 0); | |
5277 | return l; | |
5278 | } | |
5279 | ||
5280 | static __attribute__((always_inline)) inline void * | |
5281 | JSVAL_TO_PRIVATE_PTR_IMPL(jsval_layout l) | |
5282 | { | |
5283 | ((void) 0); | |
5284 | return (void *)(l.asBits << 1); | |
5285 | } | |
5286 | ||
5287 | ||
5288 | ||
5289 | static __attribute__((always_inline)) inline double | |
5290 | JS_CANONICALIZE_NAN(double d) | |
5291 | { | |
5292 | if ((__builtin_expect((d != d), 0))) { | |
5293 | jsval_layout l; | |
5294 | l.asBits = 0x7FF8000000000000LL; | |
5295 | return l.asDouble; | |
5296 | } | |
5297 | return d; | |
5298 | } | |
5299 | # 819 "jsval.h" | |
5300 | typedef __attribute__((aligned (8))) uint64 jsval; | |
5301 | typedef ptrdiff_t jsid; | |
5302 | # 830 "jsval.h" | |
5303 | } | |
5304 | # 48 "jspubtd.h" 2 | |
5305 | ||
5306 | extern "C" { | |
5307 | ||
5308 | ||
5309 | typedef JSInt32 jsint; | |
5310 | typedef JSUint32 jsuint; | |
5311 | typedef float64 jsdouble; | |
5312 | typedef JSInt32 jsrefcount; | |
5313 | ||
5314 | ||
5315 | ||
5316 | ||
5317 | typedef JSUint16 jschar; | |
5318 | # 69 "jspubtd.h" | |
5319 | typedef enum JSVersion { | |
5320 | JSVERSION_1_0 = 100, | |
5321 | JSVERSION_1_1 = 110, | |
5322 | JSVERSION_1_2 = 120, | |
5323 | JSVERSION_1_3 = 130, | |
5324 | JSVERSION_1_4 = 140, | |
5325 | JSVERSION_ECMA_3 = 148, | |
5326 | JSVERSION_1_5 = 150, | |
5327 | JSVERSION_1_6 = 160, | |
5328 | JSVERSION_1_7 = 170, | |
5329 | JSVERSION_1_8 = 180, | |
5330 | JSVERSION_ECMA_5 = 185, | |
5331 | JSVERSION_DEFAULT = 0, | |
5332 | JSVERSION_UNKNOWN = -1, | |
5333 | JSVERSION_LATEST = JSVERSION_ECMA_5 | |
5334 | } JSVersion; | |
5335 | ||
5336 | ||
5337 | ||
5338 | ||
5339 | ||
5340 | typedef enum JSType { | |
5341 | JSTYPE_VOID, | |
5342 | JSTYPE_OBJECT, | |
5343 | JSTYPE_FUNCTION, | |
5344 | JSTYPE_STRING, | |
5345 | JSTYPE_NUMBER, | |
5346 | JSTYPE_BOOLEAN, | |
5347 | JSTYPE_NULL, | |
5348 | JSTYPE_XML, | |
5349 | JSTYPE_LIMIT | |
5350 | } JSType; | |
5351 | ||
5352 | ||
5353 | typedef enum JSProtoKey { | |
5354 | ||
5355 | # 1 "jsproto.tbl" 1 | |
5356 | # 39 "jsproto.tbl" | |
5357 | # 1 "jsversion.h" 1 | |
5358 | # 40 "jsproto.tbl" 2 | |
5359 | # 64 "jsproto.tbl" | |
5360 | JSProto_Null = 0, | |
5361 | JSProto_Object = 1, | |
5362 | JSProto_Function = 2, | |
5363 | JSProto_Array = 3, | |
5364 | JSProto_Boolean = 4, | |
5365 | JSProto_JSON = 5, | |
5366 | JSProto_Date = 6, | |
5367 | JSProto_Math = 7, | |
5368 | JSProto_Number = 8, | |
5369 | JSProto_String = 9, | |
5370 | JSProto_RegExp = 10, | |
5371 | JSProto_XML = 11, | |
5372 | JSProto_Namespace = 12, | |
5373 | JSProto_QName = 13, | |
5374 | JSProto_Reflect = 14, | |
5375 | JSProto_ASTNode = 15, | |
5376 | JSProto_Error = 16, | |
5377 | JSProto_InternalError = 17, | |
5378 | JSProto_EvalError = 18, | |
5379 | JSProto_RangeError = 19, | |
5380 | JSProto_ReferenceError = 20, | |
5381 | JSProto_SyntaxError = 21, | |
5382 | JSProto_TypeError = 22, | |
5383 | JSProto_URIError = 23, | |
5384 | JSProto_Generator = 24, | |
5385 | JSProto_Iterator = 25, | |
5386 | JSProto_StopIteration = 26, | |
5387 | JSProto_ArrayBuffer = 27, | |
5388 | JSProto_Int8Array = 28, | |
5389 | JSProto_Uint8Array = 29, | |
5390 | JSProto_Int16Array = 30, | |
5391 | JSProto_Uint16Array = 31, | |
5392 | JSProto_Int32Array = 32, | |
5393 | JSProto_Uint32Array = 33, | |
5394 | JSProto_Float32Array = 34, | |
5395 | JSProto_Float64Array = 35, | |
5396 | JSProto_Uint8ClampedArray = 36, | |
5397 | JSProto_Proxy = 37, | |
5398 | JSProto_AnyName = 38, | |
5399 | # 106 "jspubtd.h" 2 | |
5400 | ||
5401 | JSProto_LIMIT | |
5402 | } JSProtoKey; | |
5403 | ||
5404 | ||
5405 | typedef enum JSAccessMode { | |
5406 | JSACC_PROTO = 0, | |
5407 | JSACC_PARENT = 1, | |
5408 | ||
5409 | ||
5410 | ||
5411 | ||
5412 | ||
5413 | ||
5414 | JSACC_WATCH = 3, | |
5415 | JSACC_READ = 4, | |
5416 | JSACC_WRITE = 8, | |
5417 | JSACC_LIMIT | |
5418 | } JSAccessMode; | |
5419 | ||
5420 | ||
5421 | ||
5422 | ||
5423 | ||
5424 | ||
5425 | ||
5426 | typedef enum JSIterateOp { | |
5427 | ||
5428 | JSENUMERATE_INIT, | |
5429 | ||
5430 | ||
5431 | JSENUMERATE_INIT_ALL, | |
5432 | ||
5433 | ||
5434 | JSENUMERATE_NEXT, | |
5435 | ||
5436 | ||
5437 | JSENUMERATE_DESTROY | |
5438 | } JSIterateOp; | |
5439 | ||
5440 | ||
5441 | typedef struct JSClass JSClass; | |
5442 | typedef struct JSConstDoubleSpec JSConstDoubleSpec; | |
5443 | typedef struct JSContext JSContext; | |
5444 | typedef struct JSErrorReport JSErrorReport; | |
5445 | typedef struct JSFunction JSFunction; | |
5446 | typedef struct JSFunctionSpec JSFunctionSpec; | |
5447 | typedef struct JSTracer JSTracer; | |
5448 | typedef struct JSIdArray JSIdArray; | |
5449 | typedef struct JSPropertyDescriptor JSPropertyDescriptor; | |
5450 | typedef struct JSPropertySpec JSPropertySpec; | |
5451 | typedef struct JSObjectMap JSObjectMap; | |
5452 | typedef struct JSRuntime JSRuntime; | |
5453 | typedef struct JSStackFrame JSStackFrame; | |
5454 | typedef struct JSXDRState JSXDRState; | |
5455 | typedef struct JSExceptionState JSExceptionState; | |
5456 | typedef struct JSLocaleCallbacks JSLocaleCallbacks; | |
5457 | typedef struct JSSecurityCallbacks JSSecurityCallbacks; | |
5458 | typedef struct JSONParser JSONParser; | |
5459 | typedef struct JSCompartment JSCompartment; | |
5460 | typedef struct JSCrossCompartmentCall JSCrossCompartmentCall; | |
5461 | typedef struct JSStructuredCloneWriter JSStructuredCloneWriter; | |
5462 | typedef struct JSStructuredCloneReader JSStructuredCloneReader; | |
5463 | typedef struct JSStructuredCloneCallbacks JSStructuredCloneCallbacks; | |
5464 | ||
5465 | ||
5466 | typedef class JSWrapper JSWrapper; | |
5467 | typedef class JSCrossCompartmentWrapper JSCrossCompartmentWrapper; | |
5468 | # 185 "jspubtd.h" | |
5469 | typedef JSBool | |
5470 | (* JSPropertyOp)(JSContext *cx, JSObject *obj, jsid id, jsval *vp); | |
5471 | # 195 "jspubtd.h" | |
5472 | typedef JSBool | |
5473 | (* JSStrictPropertyOp)(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp); | |
5474 | # 230 "jspubtd.h" | |
5475 | typedef JSBool | |
5476 | (* JSNewEnumerateOp)(JSContext *cx, JSObject *obj, JSIterateOp enum_op, | |
5477 | jsval *statep, jsid *idp); | |
5478 | ||
5479 | ||
5480 | ||
5481 | ||
5482 | ||
5483 | typedef JSBool | |
5484 | (* JSEnumerateOp)(JSContext *cx, JSObject *obj); | |
5485 | # 253 "jspubtd.h" | |
5486 | typedef JSBool | |
5487 | (* JSResolveOp)(JSContext *cx, JSObject *obj, jsid id); | |
5488 | # 285 "jspubtd.h" | |
5489 | typedef JSBool | |
5490 | (* JSNewResolveOp)(JSContext *cx, JSObject *obj, jsid id, uintN flags, | |
5491 | JSObject **objp); | |
5492 | ||
5493 | ||
5494 | ||
5495 | ||
5496 | ||
5497 | typedef JSBool | |
5498 | (* JSConvertOp)(JSContext *cx, JSObject *obj, JSType type, jsval *vp); | |
5499 | ||
5500 | ||
5501 | ||
5502 | ||
5503 | typedef JSType | |
5504 | (* JSTypeOfOp)(JSContext *cx, JSObject *obj); | |
5505 | ||
5506 | ||
5507 | ||
5508 | ||
5509 | ||
5510 | ||
5511 | typedef void | |
5512 | (* JSFinalizeOp)(JSContext *cx, JSObject *obj); | |
5513 | ||
5514 | ||
5515 | ||
5516 | ||
5517 | ||
5518 | typedef void | |
5519 | (* JSStringFinalizeOp)(JSContext *cx, JSString *str); | |
5520 | ||
5521 | ||
5522 | ||
5523 | ||
5524 | ||
5525 | ||
5526 | ||
5527 | typedef JSBool | |
5528 | (* JSCheckAccessOp)(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode, | |
5529 | jsval *vp); | |
5530 | ||
5531 | ||
5532 | ||
5533 | ||
5534 | ||
5535 | typedef JSBool | |
5536 | (* JSXDRObjectOp)(JSXDRState *xdr, JSObject **objp); | |
5537 | ||
5538 | ||
5539 | ||
5540 | ||
5541 | ||
5542 | ||
5543 | typedef JSBool | |
5544 | (* JSHasInstanceOp)(JSContext *cx, JSObject *obj, const jsval *v, JSBool *bp); | |
5545 | ||
5546 | ||
5547 | ||
5548 | ||
5549 | ||
5550 | ||
5551 | typedef uint32 | |
5552 | (* JSMarkOp)(JSContext *cx, JSObject *obj, void *arg); | |
5553 | # 372 "jspubtd.h" | |
5554 | typedef void | |
5555 | (* JSTraceOp)(JSTracer *trc, JSObject *obj); | |
5556 | # 399 "jspubtd.h" | |
5557 | typedef void | |
5558 | (* JSTraceCallback)(JSTracer *trc, void *thing, uint32 kind); | |
5559 | ||
5560 | ||
5561 | ||
5562 | ||
5563 | ||
5564 | typedef void | |
5565 | (* JSTraceNamePrinter)(JSTracer *trc, char *buf, size_t bufsize); | |
5566 | ||
5567 | typedef JSBool | |
5568 | (* JSEqualityOp)(JSContext *cx, JSObject *obj, const jsval *v, JSBool *bp); | |
5569 | ||
5570 | ||
5571 | ||
5572 | ||
5573 | ||
5574 | ||
5575 | ||
5576 | typedef JSBool | |
5577 | (* JSNative)(JSContext *cx, uintN argc, jsval *vp); | |
5578 | ||
5579 | ||
5580 | ||
5581 | typedef enum JSContextOp { | |
5582 | JSCONTEXT_NEW, | |
5583 | JSCONTEXT_DESTROY | |
5584 | } JSContextOp; | |
5585 | # 441 "jspubtd.h" | |
5586 | typedef JSBool | |
5587 | (* JSContextCallback)(JSContext *cx, uintN contextOp); | |
5588 | ||
5589 | ||
5590 | ||
5591 | ||
5592 | ||
5593 | ||
5594 | typedef enum JSGCStatus { | |
5595 | JSGC_BEGIN, | |
5596 | JSGC_END, | |
5597 | JSGC_MARK_END, | |
5598 | JSGC_FINALIZE_END | |
5599 | } JSGCStatus; | |
5600 | ||
5601 | typedef JSBool | |
5602 | (* JSGCCallback)(JSContext *cx, JSGCStatus status); | |
5603 | ||
5604 | ||
5605 | ||
5606 | ||
5607 | ||
5608 | typedef void | |
5609 | (* JSTraceDataOp)(JSTracer *trc, void *data); | |
5610 | ||
5611 | typedef JSBool | |
5612 | (* JSOperationCallback)(JSContext *cx); | |
5613 | ||
5614 | typedef void | |
5615 | (* JSErrorReporter)(JSContext *cx, const char *message, JSErrorReport *report); | |
5616 | ||
5617 | ||
5618 | ||
5619 | ||
5620 | ||
5621 | ||
5622 | typedef enum JSExnType { | |
5623 | JSEXN_NONE = -1, | |
5624 | JSEXN_ERR, | |
5625 | JSEXN_INTERNALERR, | |
5626 | JSEXN_EVALERR, | |
5627 | JSEXN_RANGEERR, | |
5628 | JSEXN_REFERENCEERR, | |
5629 | JSEXN_SYNTAXERR, | |
5630 | JSEXN_TYPEERR, | |
5631 | JSEXN_URIERR, | |
5632 | JSEXN_LIMIT | |
5633 | } JSExnType; | |
5634 | ||
5635 | typedef struct JSErrorFormatString { | |
5636 | ||
5637 | const char *format; | |
5638 | ||
5639 | ||
5640 | uint16 argCount; | |
5641 | ||
5642 | ||
5643 | int16 exnType; | |
5644 | } JSErrorFormatString; | |
5645 | ||
5646 | typedef const JSErrorFormatString * | |
5647 | (* JSErrorCallback)(void *userRef, const char *locale, | |
5648 | const uintN errorNumber); | |
5649 | ||
5650 | ||
5651 | ||
5652 | ||
5653 | typedef JSBool | |
5654 | (* JSArgumentFormatter)(JSContext *cx, const char *format, JSBool fromJS, | |
5655 | jsval **vpp, va_list *app); | |
5656 | ||
5657 | ||
5658 | typedef JSBool | |
5659 | (* JSLocaleToUpperCase)(JSContext *cx, JSString *src, jsval *rval); | |
5660 | ||
5661 | typedef JSBool | |
5662 | (* JSLocaleToLowerCase)(JSContext *cx, JSString *src, jsval *rval); | |
5663 | ||
5664 | typedef JSBool | |
5665 | (* JSLocaleCompare)(JSContext *cx, JSString *src1, JSString *src2, | |
5666 | jsval *rval); | |
5667 | ||
5668 | typedef JSBool | |
5669 | (* JSLocaleToUnicode)(JSContext *cx, const char *src, jsval *rval); | |
5670 | ||
5671 | ||
5672 | ||
5673 | ||
5674 | typedef struct JSPrincipals JSPrincipals; | |
5675 | # 538 "jspubtd.h" | |
5676 | typedef JSBool | |
5677 | (* JSPrincipalsTranscoder)(JSXDRState *xdr, JSPrincipals **principalsp); | |
5678 | # 549 "jspubtd.h" | |
5679 | typedef JSPrincipals * | |
5680 | (* JSObjectPrincipalsFinder)(JSContext *cx, JSObject *obj); | |
5681 | ||
5682 | ||
5683 | ||
5684 | ||
5685 | ||
5686 | typedef JSBool | |
5687 | (* JSCSPEvalChecker)(JSContext *cx); | |
5688 | ||
5689 | ||
5690 | ||
5691 | ||
5692 | ||
5693 | ||
5694 | typedef JSObject * | |
5695 | (* JSWrapObjectCallback)(JSContext *cx, JSObject *obj, JSObject *proto, JSObject *parent, | |
5696 | uintN flags); | |
5697 | ||
5698 | ||
5699 | ||
5700 | ||
5701 | ||
5702 | ||
5703 | typedef JSObject * | |
5704 | (* JSPreWrapCallback)(JSContext *cx, JSObject *scope, JSObject *obj, uintN flags); | |
5705 | ||
5706 | typedef enum { | |
5707 | JSCOMPARTMENT_NEW, | |
5708 | JSCOMPARTMENT_DESTROY | |
5709 | } JSCompartmentOp; | |
5710 | ||
5711 | typedef JSBool | |
5712 | (* JSCompartmentCallback)(JSContext *cx, JSCompartment *compartment, uintN compartmentOp); | |
5713 | # 593 "jspubtd.h" | |
5714 | typedef JSObject *(*ReadStructuredCloneOp)(JSContext *cx, JSStructuredCloneReader *r, | |
5715 | uint32 tag, uint32 data, void *closure); | |
5716 | # 607 "jspubtd.h" | |
5717 | typedef JSBool (*WriteStructuredCloneOp)(JSContext *cx, JSStructuredCloneWriter *w, | |
5718 | JSObject *obj, void *closure); | |
5719 | ||
5720 | ||
5721 | ||
5722 | ||
5723 | ||
5724 | ||
5725 | typedef void (*StructuredCloneErrorOp)(JSContext *cx, uint32 errorid); | |
5726 | ||
5727 | } | |
5728 | # 50 "jsapi.h" 2 | |
5729 | ||
5730 | ||
5731 | extern "C" { | |
5732 | # 93 "jsapi.h" | |
5733 | static __attribute__((always_inline)) inline JSBool | |
5734 | JSVAL_IS_NULL(jsval v) | |
5735 | { | |
5736 | jsval_layout l; | |
5737 | l.asBits = (v); | |
5738 | return JSVAL_IS_NULL_IMPL(l); | |
5739 | } | |
5740 | ||
5741 | static __attribute__((always_inline)) inline JSBool | |
5742 | JSVAL_IS_VOID(jsval v) | |
5743 | { | |
5744 | jsval_layout l; | |
5745 | l.asBits = (v); | |
5746 | return JSVAL_IS_UNDEFINED_IMPL(l); | |
5747 | } | |
5748 | ||
5749 | static __attribute__((always_inline)) inline JSBool | |
5750 | JSVAL_IS_INT(jsval v) | |
5751 | { | |
5752 | jsval_layout l; | |
5753 | l.asBits = (v); | |
5754 | return JSVAL_IS_INT32_IMPL(l); | |
5755 | } | |
5756 | ||
5757 | static __attribute__((always_inline)) inline jsint | |
5758 | JSVAL_TO_INT(jsval v) | |
5759 | { | |
5760 | jsval_layout l; | |
5761 | ((void) 0); | |
5762 | l.asBits = (v); | |
5763 | return JSVAL_TO_INT32_IMPL(l); | |
5764 | } | |
5765 | ||
5766 | ||
5767 | ||
5768 | ||
5769 | ||
5770 | static __attribute__((always_inline)) inline jsval | |
5771 | INT_TO_JSVAL(int32 i) | |
5772 | { | |
5773 | return ((INT32_TO_JSVAL_IMPL(i)).asBits); | |
5774 | } | |
5775 | ||
5776 | static __attribute__((always_inline)) inline JSBool | |
5777 | JSVAL_IS_DOUBLE(jsval v) | |
5778 | { | |
5779 | jsval_layout l; | |
5780 | l.asBits = (v); | |
5781 | return JSVAL_IS_DOUBLE_IMPL(l); | |
5782 | } | |
5783 | ||
5784 | static __attribute__((always_inline)) inline jsdouble | |
5785 | JSVAL_TO_DOUBLE(jsval v) | |
5786 | { | |
5787 | jsval_layout l; | |
5788 | ((void) 0); | |
5789 | l.asBits = (v); | |
5790 | return l.asDouble; | |
5791 | } | |
5792 | ||
5793 | static __attribute__((always_inline)) inline jsval | |
5794 | DOUBLE_TO_JSVAL(jsdouble d) | |
5795 | { | |
5796 | d = JS_CANONICALIZE_NAN(d); | |
5797 | return ((DOUBLE_TO_JSVAL_IMPL(d)).asBits); | |
5798 | } | |
5799 | ||
5800 | static __attribute__((always_inline)) inline jsval | |
5801 | UINT_TO_JSVAL(uint32 i) | |
5802 | { | |
5803 | if (i <= ((jsint)0x7fffffff)) | |
5804 | return INT_TO_JSVAL((int32)i); | |
5805 | return DOUBLE_TO_JSVAL((jsdouble)i); | |
5806 | } | |
5807 | ||
5808 | static __attribute__((always_inline)) inline JSBool | |
5809 | JSVAL_IS_NUMBER(jsval v) | |
5810 | { | |
5811 | jsval_layout l; | |
5812 | l.asBits = (v); | |
5813 | return JSVAL_IS_NUMBER_IMPL(l); | |
5814 | } | |
5815 | ||
5816 | static __attribute__((always_inline)) inline JSBool | |
5817 | JSVAL_IS_STRING(jsval v) | |
5818 | { | |
5819 | jsval_layout l; | |
5820 | l.asBits = (v); | |
5821 | return JSVAL_IS_STRING_IMPL(l); | |
5822 | } | |
5823 | ||
5824 | static __attribute__((always_inline)) inline JSString * | |
5825 | JSVAL_TO_STRING(jsval v) | |
5826 | { | |
5827 | jsval_layout l; | |
5828 | ((void) 0); | |
5829 | l.asBits = (v); | |
5830 | return JSVAL_TO_STRING_IMPL(l); | |
5831 | } | |
5832 | ||
5833 | static __attribute__((always_inline)) inline jsval | |
5834 | STRING_TO_JSVAL(JSString *str) | |
5835 | { | |
5836 | return ((STRING_TO_JSVAL_IMPL(str)).asBits); | |
5837 | } | |
5838 | ||
5839 | static __attribute__((always_inline)) inline JSBool | |
5840 | JSVAL_IS_OBJECT(jsval v) | |
5841 | { | |
5842 | jsval_layout l; | |
5843 | l.asBits = (v); | |
5844 | return JSVAL_IS_OBJECT_OR_NULL_IMPL(l); | |
5845 | } | |
5846 | ||
5847 | static __attribute__((always_inline)) inline JSObject * | |
5848 | JSVAL_TO_OBJECT(jsval v) | |
5849 | { | |
5850 | jsval_layout l; | |
5851 | ((void) 0); | |
5852 | l.asBits = (v); | |
5853 | return JSVAL_TO_OBJECT_IMPL(l); | |
5854 | } | |
5855 | ||
5856 | static __attribute__((always_inline)) inline jsval | |
5857 | OBJECT_TO_JSVAL(JSObject *obj) | |
5858 | { | |
5859 | if (obj) | |
5860 | return ((OBJECT_TO_JSVAL_IMPL(obj)).asBits); | |
5861 | return ((((uint64)(uint32)(JSVAL_TAG_NULL)) << 47) | (0)); | |
5862 | } | |
5863 | ||
5864 | static __attribute__((always_inline)) inline JSBool | |
5865 | JSVAL_IS_BOOLEAN(jsval v) | |
5866 | { | |
5867 | jsval_layout l; | |
5868 | l.asBits = (v); | |
5869 | return JSVAL_IS_BOOLEAN_IMPL(l); | |
5870 | } | |
5871 | ||
5872 | static __attribute__((always_inline)) inline JSBool | |
5873 | JSVAL_TO_BOOLEAN(jsval v) | |
5874 | { | |
5875 | jsval_layout l; | |
5876 | ((void) 0); | |
5877 | l.asBits = (v); | |
5878 | return JSVAL_TO_BOOLEAN_IMPL(l); | |
5879 | } | |
5880 | ||
5881 | static __attribute__((always_inline)) inline jsval | |
5882 | BOOLEAN_TO_JSVAL(JSBool b) | |
5883 | { | |
5884 | return ((BOOLEAN_TO_JSVAL_IMPL(b)).asBits); | |
5885 | } | |
5886 | ||
5887 | static __attribute__((always_inline)) inline JSBool | |
5888 | JSVAL_IS_PRIMITIVE(jsval v) | |
5889 | { | |
5890 | jsval_layout l; | |
5891 | l.asBits = (v); | |
5892 | return JSVAL_IS_PRIMITIVE_IMPL(l); | |
5893 | } | |
5894 | ||
5895 | static __attribute__((always_inline)) inline JSBool | |
5896 | JSVAL_IS_GCTHING(jsval v) | |
5897 | { | |
5898 | jsval_layout l; | |
5899 | l.asBits = (v); | |
5900 | return JSVAL_IS_GCTHING_IMPL(l); | |
5901 | } | |
5902 | ||
5903 | static __attribute__((always_inline)) inline void * | |
5904 | JSVAL_TO_GCTHING(jsval v) | |
5905 | { | |
5906 | jsval_layout l; | |
5907 | ((void) 0); | |
5908 | l.asBits = (v); | |
5909 | return JSVAL_TO_GCTHING_IMPL(l); | |
5910 | } | |
5911 | ||
5912 | ||
5913 | ||
5914 | static __attribute__((always_inline)) inline jsval | |
5915 | PRIVATE_TO_JSVAL(void *ptr) | |
5916 | { | |
5917 | return ((PRIVATE_PTR_TO_JSVAL_IMPL(ptr)).asBits); | |
5918 | } | |
5919 | ||
5920 | static __attribute__((always_inline)) inline void * | |
5921 | JSVAL_TO_PRIVATE(jsval v) | |
5922 | { | |
5923 | jsval_layout l; | |
5924 | ((void) 0); | |
5925 | l.asBits = (v); | |
5926 | return JSVAL_TO_PRIVATE_PTR_IMPL(l); | |
5927 | } | |
5928 | # 316 "jsapi.h" | |
5929 | static __attribute__((always_inline)) inline JSBool | |
5930 | JSID_IS_STRING(jsid iden) | |
5931 | { | |
5932 | return ((iden) & 0x7) == 0; | |
5933 | } | |
5934 | ||
5935 | static __attribute__((always_inline)) inline JSString * | |
5936 | JSID_TO_STRING(jsid iden) | |
5937 | { | |
5938 | ((void) 0); | |
5939 | return (JSString *)((iden)); | |
5940 | } | |
5941 | ||
5942 | static __attribute__((always_inline)) inline JSBool | |
5943 | JSID_IS_ZERO(jsid iden) | |
5944 | { | |
5945 | return (iden) == 0; | |
5946 | } | |
5947 | ||
5948 | __attribute__((visibility ("default"))) JSBool | |
5949 | JS_StringHasBeenInterned(JSString *str); | |
5950 | ||
5951 | ||
5952 | static __attribute__((always_inline)) inline jsid | |
5953 | INTERNED_STRING_TO_JSID(JSString *str) | |
5954 | { | |
5955 | jsid iden; | |
5956 | ((void) 0); | |
5957 | ((void) 0); | |
5958 | ((void) 0); | |
5959 | (iden) = (size_t)str; | |
5960 | return iden; | |
5961 | } | |
5962 | ||
5963 | static __attribute__((always_inline)) inline JSBool | |
5964 | JSID_IS_INT(jsid iden) | |
5965 | { | |
5966 | return !!((iden) & 0x1); | |
5967 | } | |
5968 | ||
5969 | static __attribute__((always_inline)) inline int32 | |
5970 | JSID_TO_INT(jsid iden) | |
5971 | { | |
5972 | ((void) 0); | |
5973 | return ((int32)(iden)) >> 1; | |
5974 | } | |
5975 | # 370 "jsapi.h" | |
5976 | static __attribute__((always_inline)) inline JSBool | |
5977 | INT_FITS_IN_JSID(int32 i) | |
5978 | { | |
5979 | return ((jsuint)(i) - (jsuint)(-(1 << 30)) <= | |
5980 | (jsuint)(((1 << 30) - 1) - (-(1 << 30)))); | |
5981 | } | |
5982 | ||
5983 | static __attribute__((always_inline)) inline jsid | |
5984 | INT_TO_JSID(int32 i) | |
5985 | { | |
5986 | jsid iden; | |
5987 | ((void) 0); | |
5988 | (iden) = ((i << 1) | 0x1); | |
5989 | return iden; | |
5990 | } | |
5991 | ||
5992 | static __attribute__((always_inline)) inline JSBool | |
5993 | JSID_IS_OBJECT(jsid iden) | |
5994 | { | |
5995 | return ((iden) & 0x7) == 0x4 && | |
5996 | (size_t)(iden) != 0x4; | |
5997 | } | |
5998 | ||
5999 | static __attribute__((always_inline)) inline JSObject * | |
6000 | JSID_TO_OBJECT(jsid iden) | |
6001 | { | |
6002 | ((void) 0); | |
6003 | return (JSObject *)((iden) & ~(size_t)0x7); | |
6004 | } | |
6005 | ||
6006 | static __attribute__((always_inline)) inline jsid | |
6007 | OBJECT_TO_JSID(JSObject *obj) | |
6008 | { | |
6009 | jsid iden; | |
6010 | ((void) 0); | |
6011 | ((void) 0); | |
6012 | (iden) = ((size_t)obj | 0x4); | |
6013 | return iden; | |
6014 | } | |
6015 | ||
6016 | static __attribute__((always_inline)) inline JSBool | |
6017 | JSID_IS_GCTHING(jsid iden) | |
6018 | { | |
6019 | return JSID_IS_STRING(iden) || JSID_IS_OBJECT(iden); | |
6020 | } | |
6021 | ||
6022 | static __attribute__((always_inline)) inline void * | |
6023 | JSID_TO_GCTHING(jsid iden) | |
6024 | { | |
6025 | return (void *)((iden) & ~(size_t)0x7); | |
6026 | } | |
6027 | ||
6028 | ||
6029 | ||
6030 | ||
6031 | ||
6032 | ||
6033 | static __attribute__((always_inline)) inline JSBool | |
6034 | JSID_IS_DEFAULT_XML_NAMESPACE(jsid iden) | |
6035 | { | |
6036 | ((void) 0) | |
6037 | ; | |
6038 | return ((size_t)(iden) == 0x6); | |
6039 | } | |
6040 | # 448 "jsapi.h" | |
6041 | static __attribute__((always_inline)) inline JSBool | |
6042 | JSID_IS_VOID(jsid iden) | |
6043 | { | |
6044 | ((void) 0) | |
6045 | ; | |
6046 | return ((size_t)(iden) == 0x2); | |
6047 | } | |
6048 | ||
6049 | static __attribute__((always_inline)) inline JSBool | |
6050 | JSID_IS_EMPTY(jsid iden) | |
6051 | { | |
6052 | return ((size_t)(iden) == 0x4); | |
6053 | } | |
6054 | # 532 "jsapi.h" | |
6055 | extern __attribute__((visibility ("default"))) int64 | |
6056 | JS_Now(void); | |
6057 | ||
6058 | ||
6059 | extern __attribute__((visibility ("default"))) jsval | |
6060 | JS_GetNaNValue(JSContext *cx); | |
6061 | ||
6062 | extern __attribute__((visibility ("default"))) jsval | |
6063 | JS_GetNegativeInfinityValue(JSContext *cx); | |
6064 | ||
6065 | extern __attribute__((visibility ("default"))) jsval | |
6066 | JS_GetPositiveInfinityValue(JSContext *cx); | |
6067 | ||
6068 | extern __attribute__((visibility ("default"))) jsval | |
6069 | JS_GetEmptyStringValue(JSContext *cx); | |
6070 | ||
6071 | extern __attribute__((visibility ("default"))) JSString * | |
6072 | JS_GetEmptyString(JSRuntime *rt); | |
6073 | # 583 "jsapi.h" | |
6074 | extern __attribute__((visibility ("default"))) JSBool | |
6075 | JS_ConvertArguments(JSContext *cx, uintN argc, jsval *argv, const char *format, | |
6076 | ...); | |
6077 | ||
6078 | ||
6079 | extern __attribute__((visibility ("default"))) JSBool | |
6080 | JS_ConvertArgumentsVA(JSContext *cx, uintN argc, jsval *argv, | |
6081 | const char *format, va_list ap); | |
6082 | # 634 "jsapi.h" | |
6083 | extern __attribute__((visibility ("default"))) JSBool | |
6084 | JS_AddArgumentFormatter(JSContext *cx, const char *format, | |
6085 | JSArgumentFormatter formatter); | |
6086 | ||
6087 | extern __attribute__((visibility ("default"))) void | |
6088 | JS_RemoveArgumentFormatter(JSContext *cx, const char *format); | |
6089 | ||
6090 | ||
6091 | ||
6092 | extern __attribute__((visibility ("default"))) JSBool | |
6093 | JS_ConvertValue(JSContext *cx, jsval v, JSType type, jsval *vp); | |
6094 | ||
6095 | extern __attribute__((visibility ("default"))) JSBool | |
6096 | JS_ValueToObject(JSContext *cx, jsval v, JSObject **objp); | |
6097 | ||
6098 | extern __attribute__((visibility ("default"))) JSFunction * | |
6099 | JS_ValueToFunction(JSContext *cx, jsval v); | |
6100 | ||
6101 | extern __attribute__((visibility ("default"))) JSFunction * | |
6102 | JS_ValueToConstructor(JSContext *cx, jsval v); | |
6103 | ||
6104 | extern __attribute__((visibility ("default"))) JSString * | |
6105 | JS_ValueToString(JSContext *cx, jsval v); | |
6106 | ||
6107 | extern __attribute__((visibility ("default"))) JSString * | |
6108 | JS_ValueToSource(JSContext *cx, jsval v); | |
6109 | ||
6110 | extern __attribute__((visibility ("default"))) JSBool | |
6111 | JS_ValueToNumber(JSContext *cx, jsval v, jsdouble *dp); | |
6112 | ||
6113 | extern __attribute__((visibility ("default"))) JSBool | |
6114 | JS_DoubleIsInt32(jsdouble d, jsint *ip); | |
6115 | ||
6116 | ||
6117 | ||
6118 | ||
6119 | ||
6120 | extern __attribute__((visibility ("default"))) JSBool | |
6121 | JS_ValueToECMAInt32(JSContext *cx, jsval v, int32 *ip); | |
6122 | ||
6123 | ||
6124 | ||
6125 | ||
6126 | ||
6127 | extern __attribute__((visibility ("default"))) JSBool | |
6128 | JS_ValueToECMAUint32(JSContext *cx, jsval v, uint32 *ip); | |
6129 | ||
6130 | ||
6131 | ||
6132 | ||
6133 | ||
6134 | ||
6135 | extern __attribute__((visibility ("default"))) JSBool | |
6136 | JS_ValueToInt32(JSContext *cx, jsval v, int32 *ip); | |
6137 | ||
6138 | ||
6139 | ||
6140 | ||
6141 | extern __attribute__((visibility ("default"))) JSBool | |
6142 | JS_ValueToUint16(JSContext *cx, jsval v, uint16 *ip); | |
6143 | ||
6144 | extern __attribute__((visibility ("default"))) JSBool | |
6145 | JS_ValueToBoolean(JSContext *cx, jsval v, JSBool *bp); | |
6146 | ||
6147 | extern __attribute__((visibility ("default"))) JSType | |
6148 | JS_TypeOfValue(JSContext *cx, jsval v); | |
6149 | ||
6150 | extern __attribute__((visibility ("default"))) const char * | |
6151 | JS_GetTypeName(JSContext *cx, JSType type); | |
6152 | ||
6153 | extern __attribute__((visibility ("default"))) JSBool | |
6154 | JS_StrictlyEqual(JSContext *cx, jsval v1, jsval v2, JSBool *equal); | |
6155 | ||
6156 | extern __attribute__((visibility ("default"))) JSBool | |
6157 | JS_SameValue(JSContext *cx, jsval v1, jsval v2, JSBool *same); | |
6158 | # 724 "jsapi.h" | |
6159 | extern __attribute__((visibility ("default"))) JSRuntime * | |
6160 | JS_Init(uint32 maxbytes); | |
6161 | ||
6162 | ||
6163 | ||
6164 | ||
6165 | extern __attribute__((visibility ("default"))) void | |
6166 | JS_Finish(JSRuntime *rt); | |
6167 | ||
6168 | extern __attribute__((visibility ("default"))) void | |
6169 | JS_ShutDown(void); | |
6170 | ||
6171 | __attribute__((visibility ("default"))) void * | |
6172 | JS_GetRuntimePrivate(JSRuntime *rt); | |
6173 | ||
6174 | __attribute__((visibility ("default"))) void | |
6175 | JS_SetRuntimePrivate(JSRuntime *rt, void *data); | |
6176 | ||
6177 | extern __attribute__((visibility ("default"))) void | |
6178 | JS_BeginRequest(JSContext *cx); | |
6179 | ||
6180 | extern __attribute__((visibility ("default"))) void | |
6181 | JS_EndRequest(JSContext *cx); | |
6182 | ||
6183 | ||
6184 | extern __attribute__((visibility ("default"))) void | |
6185 | JS_YieldRequest(JSContext *cx); | |
6186 | ||
6187 | extern __attribute__((visibility ("default"))) jsrefcount | |
6188 | JS_SuspendRequest(JSContext *cx); | |
6189 | ||
6190 | extern __attribute__((visibility ("default"))) void | |
6191 | JS_ResumeRequest(JSContext *cx, jsrefcount saveDepth); | |
6192 | ||
6193 | extern __attribute__((visibility ("default"))) JSBool | |
6194 | JS_IsInRequest(JSContext *cx); | |
6195 | ||
6196 | ||
6197 | } | |
6198 | ||
6199 | class JSAutoRequest { | |
6200 | public: | |
6201 | JSAutoRequest(JSContext *cx ) | |
6202 | : mContext(cx), mSaveDepth(0) { | |
6203 | do { } while (0); | |
6204 | JS_BeginRequest(mContext); | |
6205 | } | |
6206 | ~JSAutoRequest() { | |
6207 | JS_EndRequest(mContext); | |
6208 | } | |
6209 | ||
6210 | void suspend() { | |
6211 | mSaveDepth = JS_SuspendRequest(mContext); | |
6212 | } | |
6213 | void resume() { | |
6214 | JS_ResumeRequest(mContext, mSaveDepth); | |
6215 | } | |
6216 | ||
6217 | protected: | |
6218 | JSContext *mContext; | |
6219 | jsrefcount mSaveDepth; | |
6220 | ||
6221 | ||
6222 | ||
6223 | ||
6224 | ||
6225 | ||
6226 | ||
6227 | }; | |
6228 | ||
6229 | class JSAutoSuspendRequest { | |
6230 | public: | |
6231 | JSAutoSuspendRequest(JSContext *cx ) | |
6232 | : mContext(cx), mSaveDepth(0) { | |
6233 | do { } while (0); | |
6234 | if (mContext) { | |
6235 | mSaveDepth = JS_SuspendRequest(mContext); | |
6236 | } | |
6237 | } | |
6238 | ~JSAutoSuspendRequest() { | |
6239 | resume(); | |
6240 | } | |
6241 | ||
6242 | void resume() { | |
6243 | if (mContext) { | |
6244 | JS_ResumeRequest(mContext, mSaveDepth); | |
6245 | mContext = 0; | |
6246 | } | |
6247 | } | |
6248 | ||
6249 | protected: | |
6250 | JSContext *mContext; | |
6251 | jsrefcount mSaveDepth; | |
6252 | ||
6253 | ||
6254 | ||
6255 | ||
6256 | ||
6257 | ||
6258 | ||
6259 | }; | |
6260 | ||
6261 | class JSAutoCheckRequest { | |
6262 | public: | |
6263 | JSAutoCheckRequest(JSContext *cx ) { | |
6264 | ||
6265 | ||
6266 | ||
6267 | ||
6268 | do { } while (0); | |
6269 | } | |
6270 | ||
6271 | ~JSAutoCheckRequest() { | |
6272 | ||
6273 | ||
6274 | ||
6275 | } | |
6276 | ||
6277 | ||
6278 | private: | |
6279 | ||
6280 | ||
6281 | ||
6282 | ||
6283 | }; | |
6284 | ||
6285 | extern "C" { | |
6286 | ||
6287 | ||
6288 | extern __attribute__((visibility ("default"))) void | |
6289 | JS_Lock(JSRuntime *rt); | |
6290 | ||
6291 | extern __attribute__((visibility ("default"))) void | |
6292 | JS_Unlock(JSRuntime *rt); | |
6293 | ||
6294 | extern __attribute__((visibility ("default"))) JSContextCallback | |
6295 | JS_SetContextCallback(JSRuntime *rt, JSContextCallback cxCallback); | |
6296 | ||
6297 | extern __attribute__((visibility ("default"))) JSContext * | |
6298 | JS_NewContext(JSRuntime *rt, size_t stackChunkSize); | |
6299 | ||
6300 | extern __attribute__((visibility ("default"))) void | |
6301 | JS_DestroyContext(JSContext *cx); | |
6302 | ||
6303 | extern __attribute__((visibility ("default"))) void | |
6304 | JS_DestroyContextNoGC(JSContext *cx); | |
6305 | ||
6306 | extern __attribute__((visibility ("default"))) void | |
6307 | JS_DestroyContextMaybeGC(JSContext *cx); | |
6308 | ||
6309 | extern __attribute__((visibility ("default"))) void * | |
6310 | JS_GetContextPrivate(JSContext *cx); | |
6311 | ||
6312 | extern __attribute__((visibility ("default"))) void | |
6313 | JS_SetContextPrivate(JSContext *cx, void *data); | |
6314 | ||
6315 | extern __attribute__((visibility ("default"))) JSRuntime * | |
6316 | JS_GetRuntime(JSContext *cx); | |
6317 | ||
6318 | extern __attribute__((visibility ("default"))) JSContext * | |
6319 | JS_ContextIterator(JSRuntime *rt, JSContext **iterp); | |
6320 | ||
6321 | extern __attribute__((visibility ("default"))) JSVersion | |
6322 | JS_GetVersion(JSContext *cx); | |
6323 | ||
6324 | extern __attribute__((visibility ("default"))) JSVersion | |
6325 | JS_SetVersion(JSContext *cx, JSVersion version); | |
6326 | ||
6327 | extern __attribute__((visibility ("default"))) const char * | |
6328 | JS_VersionToString(JSVersion version); | |
6329 | ||
6330 | extern __attribute__((visibility ("default"))) JSVersion | |
6331 | JS_StringToVersion(const char *string); | |
6332 | # 968 "jsapi.h" | |
6333 | extern __attribute__((visibility ("default"))) uint32 | |
6334 | JS_GetOptions(JSContext *cx); | |
6335 | ||
6336 | extern __attribute__((visibility ("default"))) uint32 | |
6337 | JS_SetOptions(JSContext *cx, uint32 options); | |
6338 | ||
6339 | extern __attribute__((visibility ("default"))) uint32 | |
6340 | JS_ToggleOptions(JSContext *cx, uint32 options); | |
6341 | ||
6342 | extern __attribute__((visibility ("default"))) const char * | |
6343 | JS_GetImplementationVersion(void); | |
6344 | ||
6345 | extern __attribute__((visibility ("default"))) JSCompartmentCallback | |
6346 | JS_SetCompartmentCallback(JSRuntime *rt, JSCompartmentCallback callback); | |
6347 | ||
6348 | extern __attribute__((visibility ("default"))) JSWrapObjectCallback | |
6349 | JS_SetWrapObjectCallbacks(JSRuntime *rt, | |
6350 | JSWrapObjectCallback callback, | |
6351 | JSPreWrapCallback precallback); | |
6352 | ||
6353 | extern __attribute__((visibility ("default"))) JSCrossCompartmentCall * | |
6354 | JS_EnterCrossCompartmentCall(JSContext *cx, JSObject *target); | |
6355 | ||
6356 | extern __attribute__((visibility ("default"))) void | |
6357 | JS_LeaveCrossCompartmentCall(JSCrossCompartmentCall *call); | |
6358 | ||
6359 | extern __attribute__((visibility ("default"))) void * | |
6360 | JS_SetCompartmentPrivate(JSContext *cx, JSCompartment *compartment, void *data); | |
6361 | ||
6362 | extern __attribute__((visibility ("default"))) void * | |
6363 | JS_GetCompartmentPrivate(JSContext *cx, JSCompartment *compartment); | |
6364 | ||
6365 | extern __attribute__((visibility ("default"))) JSBool | |
6366 | JS_WrapObject(JSContext *cx, JSObject **objp); | |
6367 | ||
6368 | extern __attribute__((visibility ("default"))) JSBool | |
6369 | JS_WrapValue(JSContext *cx, jsval *vp); | |
6370 | ||
6371 | extern __attribute__((visibility ("default"))) JSObject * | |
6372 | JS_TransplantObject(JSContext *cx, JSObject *origobj, JSObject *target); | |
6373 | ||
6374 | extern __attribute__((visibility ("default"))) JSObject * | |
6375 | js_TransplantObjectWithWrapper(JSContext *cx, | |
6376 | JSObject *origobj, | |
6377 | JSObject *origwrapper, | |
6378 | JSObject *targetobj, | |
6379 | JSObject *targetwrapper); | |
6380 | ||
6381 | extern __attribute__((visibility ("default"))) JSObject * | |
6382 | js_TransplantObjectWithWrapper(JSContext *cx, | |
6383 | JSObject *origobj, | |
6384 | JSObject *origwrapper, | |
6385 | JSObject *targetobj, | |
6386 | JSObject *targetwrapper); | |
6387 | ||
6388 | ||
6389 | } | |
6390 | ||
6391 | class __attribute__((visibility ("default"))) JSAutoEnterCompartment | |
6392 | { | |
6393 | JSCrossCompartmentCall *call; | |
6394 | ||
6395 | public: | |
6396 | JSAutoEnterCompartment() : call(__null) {} | |
6397 | ||
6398 | bool enter(JSContext *cx, JSObject *target); | |
6399 | ||
6400 | void enterAndIgnoreErrors(JSContext *cx, JSObject *target); | |
6401 | ||
6402 | bool entered() const { return call != __null; } | |
6403 | ||
6404 | ~JSAutoEnterCompartment() { | |
6405 | if (call && call != reinterpret_cast<JSCrossCompartmentCall*>(1)) | |
6406 | JS_LeaveCrossCompartmentCall(call); | |
6407 | } | |
6408 | ||
6409 | void swap(JSAutoEnterCompartment &other) { | |
6410 | JSCrossCompartmentCall *tmp = call; | |
6411 | call = other.call; | |
6412 | other.call = tmp; | |
6413 | } | |
6414 | }; | |
6415 | ||
6416 | extern "C" { | |
6417 | ||
6418 | ||
6419 | extern __attribute__((visibility ("default"))) JSObject * | |
6420 | JS_GetGlobalObject(JSContext *cx); | |
6421 | ||
6422 | extern __attribute__((visibility ("default"))) void | |
6423 | JS_SetGlobalObject(JSContext *cx, JSObject *obj); | |
6424 | # 1067 "jsapi.h" | |
6425 | extern __attribute__((visibility ("default"))) JSBool | |
6426 | JS_InitStandardClasses(JSContext *cx, JSObject *obj); | |
6427 | # 1083 "jsapi.h" | |
6428 | extern __attribute__((visibility ("default"))) JSBool | |
6429 | JS_ResolveStandardClass(JSContext *cx, JSObject *obj, jsid id, | |
6430 | JSBool *resolved); | |
6431 | ||
6432 | extern __attribute__((visibility ("default"))) JSBool | |
6433 | JS_EnumerateStandardClasses(JSContext *cx, JSObject *obj); | |
6434 | ||
6435 | ||
6436 | ||
6437 | ||
6438 | ||
6439 | ||
6440 | extern __attribute__((visibility ("default"))) JSIdArray * | |
6441 | JS_EnumerateResolvedStandardClasses(JSContext *cx, JSObject *obj, | |
6442 | JSIdArray *ida); | |
6443 | ||
6444 | extern __attribute__((visibility ("default"))) JSBool | |
6445 | JS_GetClassObject(JSContext *cx, JSObject *obj, JSProtoKey key, | |
6446 | JSObject **objp); | |
6447 | ||
6448 | extern __attribute__((visibility ("default"))) JSObject * | |
6449 | JS_GetScopeChain(JSContext *cx); | |
6450 | ||
6451 | extern __attribute__((visibility ("default"))) JSObject * | |
6452 | JS_GetGlobalForObject(JSContext *cx, JSObject *obj); | |
6453 | ||
6454 | extern __attribute__((visibility ("default"))) JSObject * | |
6455 | JS_GetGlobalForScopeChain(JSContext *cx); | |
6456 | # 1184 "jsapi.h" | |
6457 | extern __attribute__((visibility ("default"))) jsval | |
6458 | JS_ComputeThis(JSContext *cx, jsval *vp); | |
6459 | ||
6460 | ||
6461 | ||
6462 | static inline jsval | |
6463 | JS_THIS(JSContext *cx, jsval *vp) | |
6464 | { | |
6465 | return JSVAL_IS_PRIMITIVE(vp[1]) ? JS_ComputeThis(cx, vp) : vp[1]; | |
6466 | } | |
6467 | # 1210 "jsapi.h" | |
6468 | extern __attribute__((visibility ("default"))) void * | |
6469 | JS_malloc(JSContext *cx, size_t nbytes); | |
6470 | ||
6471 | extern __attribute__((visibility ("default"))) void * | |
6472 | JS_realloc(JSContext *cx, void *p, size_t nbytes); | |
6473 | ||
6474 | extern __attribute__((visibility ("default"))) void | |
6475 | JS_free(JSContext *cx, void *p); | |
6476 | ||
6477 | extern __attribute__((visibility ("default"))) void | |
6478 | JS_updateMallocCounter(JSContext *cx, size_t nbytes); | |
6479 | ||
6480 | extern __attribute__((visibility ("default"))) char * | |
6481 | JS_strdup(JSContext *cx, const char *s); | |
6482 | ||
6483 | extern __attribute__((visibility ("default"))) JSBool | |
6484 | JS_NewNumberValue(JSContext *cx, jsdouble d, jsval *rval); | |
6485 | # 1253 "jsapi.h" | |
6486 | extern __attribute__((visibility ("default"))) JSBool | |
6487 | JS_AddValueRoot(JSContext *cx, jsval *vp); | |
6488 | ||
6489 | extern __attribute__((visibility ("default"))) JSBool | |
6490 | JS_AddStringRoot(JSContext *cx, JSString **rp); | |
6491 | ||
6492 | extern __attribute__((visibility ("default"))) JSBool | |
6493 | JS_AddObjectRoot(JSContext *cx, JSObject **rp); | |
6494 | ||
6495 | extern __attribute__((visibility ("default"))) JSBool | |
6496 | JS_AddGCThingRoot(JSContext *cx, void **rp); | |
6497 | # 1274 "jsapi.h" | |
6498 | extern __attribute__((visibility ("default"))) JSBool | |
6499 | JS_AddNamedValueRoot(JSContext *cx, jsval *vp, const char *name); | |
6500 | ||
6501 | extern __attribute__((visibility ("default"))) JSBool | |
6502 | JS_AddNamedStringRoot(JSContext *cx, JSString **rp, const char *name); | |
6503 | ||
6504 | extern __attribute__((visibility ("default"))) JSBool | |
6505 | JS_AddNamedObjectRoot(JSContext *cx, JSObject **rp, const char *name); | |
6506 | ||
6507 | extern __attribute__((visibility ("default"))) JSBool | |
6508 | JS_AddNamedGCThingRoot(JSContext *cx, void **rp, const char *name); | |
6509 | ||
6510 | extern __attribute__((visibility ("default"))) JSBool | |
6511 | JS_RemoveValueRoot(JSContext *cx, jsval *vp); | |
6512 | ||
6513 | extern __attribute__((visibility ("default"))) JSBool | |
6514 | JS_RemoveStringRoot(JSContext *cx, JSString **rp); | |
6515 | ||
6516 | extern __attribute__((visibility ("default"))) JSBool | |
6517 | JS_RemoveObjectRoot(JSContext *cx, JSObject **rp); | |
6518 | ||
6519 | extern __attribute__((visibility ("default"))) JSBool | |
6520 | JS_RemoveGCThingRoot(JSContext *cx, void **rp); | |
6521 | ||
6522 | ||
6523 | ||
6524 | extern __attribute__((visibility ("default"))) JSBool | |
6525 | js_AddRootRT(JSRuntime *rt, jsval *vp, const char *name); | |
6526 | ||
6527 | extern __attribute__((visibility ("default"))) JSBool | |
6528 | js_AddGCThingRootRT(JSRuntime *rt, void **rp, const char *name); | |
6529 | ||
6530 | extern __attribute__((visibility ("default"))) JSBool | |
6531 | js_RemoveRoot(JSRuntime *rt, void *rp); | |
6532 | ||
6533 | ||
6534 | } | |
6535 | ||
6536 | namespace JS { | |
6537 | # 1374 "jsapi.h" | |
6538 | template<typename T> class AnchorPermitted; | |
6539 | template<> class AnchorPermitted<JSObject *> { }; | |
6540 | template<> class AnchorPermitted<const JSObject *> { }; | |
6541 | template<> class AnchorPermitted<JSFunction *> { }; | |
6542 | template<> class AnchorPermitted<const JSFunction *> { }; | |
6543 | template<> class AnchorPermitted<JSString *> { }; | |
6544 | template<> class AnchorPermitted<const JSString *> { }; | |
6545 | template<> class AnchorPermitted<jsval> { }; | |
6546 | ||
6547 | template<typename T> | |
6548 | class Anchor: AnchorPermitted<T> { | |
6549 | public: | |
6550 | Anchor() { } | |
6551 | explicit Anchor(T t) { hold = t; } | |
6552 | inline ~Anchor(); | |
6553 | T &get() { return hold; } | |
6554 | void set(const T &t) { hold = t; } | |
6555 | void clear() { hold = 0; } | |
6556 | private: | |
6557 | T hold; | |
6558 | ||
6559 | Anchor(const Anchor &); | |
6560 | const Anchor &operator=(const Anchor &); | |
6561 | }; | |
6562 | ||
6563 | ||
6564 | template<typename T> | |
6565 | inline Anchor<T>::~Anchor() { | |
6566 | # 1413 "jsapi.h" | |
6567 | asm volatile("":: "g" (hold) : "memory"); | |
6568 | } | |
6569 | # 1465 "jsapi.h" | |
6570 | } | |
6571 | ||
6572 | extern "C" { | |
6573 | ||
6574 | ||
6575 | ||
6576 | ||
6577 | ||
6578 | ||
6579 | extern __attribute__((noinline)) __attribute__((visibility ("default"))) void | |
6580 | JS_AnchorPtr(void *p); | |
6581 | # 1490 "jsapi.h" | |
6582 | typedef enum JSGCRootType { | |
6583 | JS_GC_ROOT_VALUE_PTR, | |
6584 | JS_GC_ROOT_GCTHING_PTR | |
6585 | } JSGCRootType; | |
6586 | # 1528 "jsapi.h" | |
6587 | typedef intN | |
6588 | (* JSGCRootMapFun)(void *rp, JSGCRootType type, const char *name, void *data); | |
6589 | ||
6590 | extern __attribute__((visibility ("default"))) uint32 | |
6591 | JS_MapGCRoots(JSRuntime *rt, JSGCRootMapFun map, void *data); | |
6592 | ||
6593 | extern __attribute__((visibility ("default"))) JSBool | |
6594 | JS_LockGCThing(JSContext *cx, void *thing); | |
6595 | ||
6596 | extern __attribute__((visibility ("default"))) JSBool | |
6597 | JS_LockGCThingRT(JSRuntime *rt, void *thing); | |
6598 | ||
6599 | extern __attribute__((visibility ("default"))) JSBool | |
6600 | JS_UnlockGCThing(JSContext *cx, void *thing); | |
6601 | ||
6602 | extern __attribute__((visibility ("default"))) JSBool | |
6603 | JS_UnlockGCThingRT(JSRuntime *rt, void *thing); | |
6604 | # 1553 "jsapi.h" | |
6605 | extern __attribute__((visibility ("default"))) void | |
6606 | JS_SetExtraGCRoots(JSRuntime *rt, JSTraceDataOp traceOp, void *data); | |
6607 | ||
6608 | ||
6609 | ||
6610 | ||
6611 | ||
6612 | extern __attribute__((visibility ("default"))) void | |
6613 | JS_MarkGCThing(JSContext *cx, jsval v, const char *name, void *arg); | |
6614 | # 1583 "jsapi.h" | |
6615 | static __attribute__((always_inline)) inline JSBool | |
6616 | JSVAL_IS_TRACEABLE(jsval v) | |
6617 | { | |
6618 | jsval_layout l; | |
6619 | l.asBits = (v); | |
6620 | return JSVAL_IS_TRACEABLE_IMPL(l); | |
6621 | } | |
6622 | ||
6623 | static __attribute__((always_inline)) inline void * | |
6624 | JSVAL_TO_TRACEABLE(jsval v) | |
6625 | { | |
6626 | return JSVAL_TO_GCTHING(v); | |
6627 | } | |
6628 | ||
6629 | static __attribute__((always_inline)) inline uint32 | |
6630 | JSVAL_TRACE_KIND(jsval v) | |
6631 | { | |
6632 | jsval_layout l; | |
6633 | ((void) 0); | |
6634 | l.asBits = (v); | |
6635 | return JSVAL_TRACE_KIND_IMPL(l); | |
6636 | } | |
6637 | ||
6638 | struct JSTracer { | |
6639 | JSContext *context; | |
6640 | JSTraceCallback callback; | |
6641 | JSTraceNamePrinter debugPrinter; | |
6642 | const void *debugPrintArg; | |
6643 | size_t debugPrintIndex; | |
6644 | }; | |
6645 | ||
6646 | ||
6647 | ||
6648 | ||
6649 | ||
6650 | ||
6651 | ||
6652 | extern __attribute__((visibility ("default"))) void | |
6653 | JS_CallTracer(JSTracer *trc, void *thing, uint32 kind); | |
6654 | # 1713 "jsapi.h" | |
6655 | extern __attribute__((visibility ("default"))) void | |
6656 | JS_TraceChildren(JSTracer *trc, void *thing, uint32 kind); | |
6657 | ||
6658 | extern __attribute__((visibility ("default"))) void | |
6659 | JS_TraceRuntime(JSTracer *trc); | |
6660 | # 1749 "jsapi.h" | |
6661 | extern __attribute__((visibility ("default"))) void | |
6662 | JS_GC(JSContext *cx); | |
6663 | ||
6664 | extern __attribute__((visibility ("default"))) void | |
6665 | JS_MaybeGC(JSContext *cx); | |
6666 | ||
6667 | extern __attribute__((visibility ("default"))) JSGCCallback | |
6668 | JS_SetGCCallback(JSContext *cx, JSGCCallback cb); | |
6669 | ||
6670 | extern __attribute__((visibility ("default"))) JSGCCallback | |
6671 | JS_SetGCCallbackRT(JSRuntime *rt, JSGCCallback cb); | |
6672 | ||
6673 | extern __attribute__((visibility ("default"))) JSBool | |
6674 | JS_IsGCMarkingTracer(JSTracer *trc); | |
6675 | ||
6676 | extern __attribute__((visibility ("default"))) JSBool | |
6677 | JS_IsAboutToBeFinalized(JSContext *cx, void *thing); | |
6678 | ||
6679 | typedef enum JSGCParamKey { | |
6680 | ||
6681 | JSGC_MAX_BYTES = 0, | |
6682 | ||
6683 | ||
6684 | JSGC_MAX_MALLOC_BYTES = 1, | |
6685 | ||
6686 | ||
6687 | JSGC_STACKPOOL_LIFESPAN = 2, | |
6688 | # 1785 "jsapi.h" | |
6689 | JSGC_TRIGGER_FACTOR = 3, | |
6690 | ||
6691 | ||
6692 | JSGC_BYTES = 4, | |
6693 | ||
6694 | ||
6695 | JSGC_NUMBER = 5, | |
6696 | ||
6697 | ||
6698 | JSGC_MAX_CODE_CACHE_BYTES = 6, | |
6699 | ||
6700 | ||
6701 | JSGC_MODE = 7, | |
6702 | ||
6703 | ||
6704 | JSGC_UNUSED_CHUNKS = 8 | |
6705 | } JSGCParamKey; | |
6706 | ||
6707 | typedef enum JSGCMode { | |
6708 | ||
6709 | JSGC_MODE_GLOBAL = 0, | |
6710 | ||
6711 | ||
6712 | JSGC_MODE_COMPARTMENT = 1 | |
6713 | } JSGCMode; | |
6714 | ||
6715 | extern __attribute__((visibility ("default"))) void | |
6716 | JS_SetGCParameter(JSRuntime *rt, JSGCParamKey key, uint32 value); | |
6717 | ||
6718 | extern __attribute__((visibility ("default"))) uint32 | |
6719 | JS_GetGCParameter(JSRuntime *rt, JSGCParamKey key); | |
6720 | ||
6721 | extern __attribute__((visibility ("default"))) void | |
6722 | JS_SetGCParameterForThread(JSContext *cx, JSGCParamKey key, uint32 value); | |
6723 | ||
6724 | extern __attribute__((visibility ("default"))) uint32 | |
6725 | JS_GetGCParameterForThread(JSContext *cx, JSGCParamKey key); | |
6726 | ||
6727 | ||
6728 | ||
6729 | ||
6730 | ||
6731 | ||
6732 | ||
6733 | extern __attribute__((visibility ("default"))) void | |
6734 | JS_FlushCaches(JSContext *cx); | |
6735 | # 1844 "jsapi.h" | |
6736 | extern __attribute__((visibility ("default"))) intN | |
6737 | JS_AddExternalStringFinalizer(JSStringFinalizeOp finalizer); | |
6738 | # 1860 "jsapi.h" | |
6739 | extern __attribute__((visibility ("default"))) intN | |
6740 | JS_RemoveExternalStringFinalizer(JSStringFinalizeOp finalizer); | |
6741 | ||
6742 | ||
6743 | ||
6744 | ||
6745 | ||
6746 | ||
6747 | extern __attribute__((visibility ("default"))) JSString * | |
6748 | JS_NewExternalString(JSContext *cx, jschar *chars, size_t length, intN type); | |
6749 | ||
6750 | ||
6751 | ||
6752 | ||
6753 | ||
6754 | extern __attribute__((visibility ("default"))) intN | |
6755 | JS_GetExternalStringGCType(JSRuntime *rt, JSString *str); | |
6756 | ||
6757 | ||
6758 | ||
6759 | ||
6760 | extern __attribute__((visibility ("default"))) void | |
6761 | JS_SetThreadStackLimit(JSContext *cx, jsuword limitAddr); | |
6762 | ||
6763 | ||
6764 | ||
6765 | ||
6766 | ||
6767 | extern __attribute__((visibility ("default"))) void | |
6768 | JS_SetNativeStackQuota(JSContext *cx, size_t stackSize); | |
6769 | # 1902 "jsapi.h" | |
6770 | extern __attribute__((visibility ("default"))) void | |
6771 | JS_SetScriptStackQuota(JSContext *cx, size_t quota); | |
6772 | # 1912 "jsapi.h" | |
6773 | typedef void (*JSClassInternal)(); | |
6774 | ||
6775 | ||
6776 | struct JSClass { | |
6777 | const char *name; | |
6778 | uint32 flags; | |
6779 | ||
6780 | ||
6781 | JSPropertyOp addProperty; | |
6782 | JSPropertyOp delProperty; | |
6783 | JSPropertyOp getProperty; | |
6784 | JSStrictPropertyOp setProperty; | |
6785 | JSEnumerateOp enumerate; | |
6786 | JSResolveOp resolve; | |
6787 | JSConvertOp convert; | |
6788 | JSFinalizeOp finalize; | |
6789 | ||
6790 | ||
6791 | JSClassInternal reserved0; | |
6792 | JSCheckAccessOp checkAccess; | |
6793 | JSNative call; | |
6794 | JSNative construct; | |
6795 | JSXDRObjectOp xdrObject; | |
6796 | JSHasInstanceOp hasInstance; | |
6797 | JSMarkOp mark; | |
6798 | ||
6799 | JSClassInternal reserved1; | |
6800 | void *reserved[19]; | |
6801 | }; | |
6802 | # 2024 "jsapi.h" | |
6803 | struct JSIdArray { | |
6804 | jsint length; | |
6805 | jsid vector[1]; | |
6806 | }; | |
6807 | ||
6808 | extern __attribute__((visibility ("default"))) void | |
6809 | JS_DestroyIdArray(JSContext *cx, JSIdArray *ida); | |
6810 | ||
6811 | extern __attribute__((visibility ("default"))) JSBool | |
6812 | JS_ValueToId(JSContext *cx, jsval v, jsid *idp); | |
6813 | ||
6814 | extern __attribute__((visibility ("default"))) JSBool | |
6815 | JS_IdToValue(JSContext *cx, jsid id, jsval *vp); | |
6816 | # 2048 "jsapi.h" | |
6817 | extern __attribute__((visibility ("default"))) JSBool | |
6818 | JS_PropertyStub(JSContext *cx, JSObject *obj, jsid id, jsval *vp); | |
6819 | ||
6820 | extern __attribute__((visibility ("default"))) JSBool | |
6821 | JS_StrictPropertyStub(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp); | |
6822 | ||
6823 | extern __attribute__((visibility ("default"))) JSBool | |
6824 | JS_EnumerateStub(JSContext *cx, JSObject *obj); | |
6825 | ||
6826 | extern __attribute__((visibility ("default"))) JSBool | |
6827 | JS_ResolveStub(JSContext *cx, JSObject *obj, jsid id); | |
6828 | ||
6829 | extern __attribute__((visibility ("default"))) JSBool | |
6830 | JS_ConvertStub(JSContext *cx, JSObject *obj, JSType type, jsval *vp); | |
6831 | ||
6832 | extern __attribute__((visibility ("default"))) void | |
6833 | JS_FinalizeStub(JSContext *cx, JSObject *obj); | |
6834 | ||
6835 | struct JSConstDoubleSpec { | |
6836 | jsdouble dval; | |
6837 | const char *name; | |
6838 | uint8 flags; | |
6839 | uint8 spare[3]; | |
6840 | }; | |
6841 | ||
6842 | ||
6843 | ||
6844 | ||
6845 | ||
6846 | ||
6847 | struct JSPropertySpec { | |
6848 | const char *name; | |
6849 | int8 tinyid; | |
6850 | uint8 flags; | |
6851 | JSPropertyOp getter; | |
6852 | JSStrictPropertyOp setter; | |
6853 | }; | |
6854 | ||
6855 | struct JSFunctionSpec { | |
6856 | const char *name; | |
6857 | JSNative call; | |
6858 | uint16 nargs; | |
6859 | uint16 flags; | |
6860 | }; | |
6861 | # 2109 "jsapi.h" | |
6862 | extern __attribute__((visibility ("default"))) JSObject * | |
6863 | JS_InitClass(JSContext *cx, JSObject *obj, JSObject *parent_proto, | |
6864 | JSClass *clasp, JSNative constructor, uintN nargs, | |
6865 | JSPropertySpec *ps, JSFunctionSpec *fs, | |
6866 | JSPropertySpec *static_ps, JSFunctionSpec *static_fs); | |
6867 | ||
6868 | ||
6869 | extern __attribute__((visibility ("default"))) JSClass * | |
6870 | JS_GetClass(JSContext *cx, JSObject *obj); | |
6871 | # 2127 "jsapi.h" | |
6872 | extern __attribute__((visibility ("default"))) JSBool | |
6873 | JS_InstanceOf(JSContext *cx, JSObject *obj, JSClass *clasp, jsval *argv); | |
6874 | ||
6875 | extern __attribute__((visibility ("default"))) JSBool | |
6876 | JS_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp); | |
6877 | ||
6878 | extern __attribute__((visibility ("default"))) void * | |
6879 | JS_GetPrivate(JSContext *cx, JSObject *obj); | |
6880 | ||
6881 | extern __attribute__((visibility ("default"))) JSBool | |
6882 | JS_SetPrivate(JSContext *cx, JSObject *obj, void *data); | |
6883 | ||
6884 | extern __attribute__((visibility ("default"))) void * | |
6885 | JS_GetInstancePrivate(JSContext *cx, JSObject *obj, JSClass *clasp, | |
6886 | jsval *argv); | |
6887 | ||
6888 | extern __attribute__((visibility ("default"))) JSObject * | |
6889 | JS_GetPrototype(JSContext *cx, JSObject *obj); | |
6890 | ||
6891 | extern __attribute__((visibility ("default"))) JSBool | |
6892 | JS_SetPrototype(JSContext *cx, JSObject *obj, JSObject *proto); | |
6893 | ||
6894 | extern __attribute__((visibility ("default"))) JSObject * | |
6895 | JS_GetParent(JSContext *cx, JSObject *obj); | |
6896 | ||
6897 | extern __attribute__((visibility ("default"))) JSBool | |
6898 | JS_SetParent(JSContext *cx, JSObject *obj, JSObject *parent); | |
6899 | ||
6900 | extern __attribute__((visibility ("default"))) JSObject * | |
6901 | JS_GetConstructor(JSContext *cx, JSObject *proto); | |
6902 | ||
6903 | ||
6904 | ||
6905 | ||
6906 | ||
6907 | ||
6908 | extern __attribute__((visibility ("default"))) JSBool | |
6909 | JS_GetObjectId(JSContext *cx, JSObject *obj, jsid *idp); | |
6910 | ||
6911 | extern __attribute__((visibility ("default"))) JSObject * | |
6912 | JS_NewGlobalObject(JSContext *cx, JSClass *clasp); | |
6913 | ||
6914 | extern __attribute__((visibility ("default"))) JSObject * | |
6915 | JS_NewCompartmentAndGlobalObject(JSContext *cx, JSClass *clasp, JSPrincipals *principals); | |
6916 | ||
6917 | extern __attribute__((visibility ("default"))) JSObject * | |
6918 | JS_NewObject(JSContext *cx, JSClass *clasp, JSObject *proto, JSObject *parent); | |
6919 | ||
6920 | ||
6921 | extern __attribute__((visibility ("default"))) JSBool | |
6922 | JS_IsExtensible(JSObject *obj); | |
6923 | ||
6924 | ||
6925 | ||
6926 | ||
6927 | ||
6928 | extern __attribute__((visibility ("default"))) JSObject * | |
6929 | JS_NewObjectWithGivenProto(JSContext *cx, JSClass *clasp, JSObject *proto, | |
6930 | JSObject *parent); | |
6931 | ||
6932 | ||
6933 | ||
6934 | ||
6935 | ||
6936 | ||
6937 | extern __attribute__((visibility ("default"))) JSBool | |
6938 | JS_DeepFreezeObject(JSContext *cx, JSObject *obj); | |
6939 | ||
6940 | ||
6941 | ||
6942 | ||
6943 | extern __attribute__((visibility ("default"))) JSBool | |
6944 | JS_FreezeObject(JSContext *cx, JSObject *obj); | |
6945 | ||
6946 | extern __attribute__((visibility ("default"))) JSObject * | |
6947 | JS_ConstructObject(JSContext *cx, JSClass *clasp, JSObject *proto, | |
6948 | JSObject *parent); | |
6949 | ||
6950 | extern __attribute__((visibility ("default"))) JSObject * | |
6951 | JS_ConstructObjectWithArguments(JSContext *cx, JSClass *clasp, JSObject *proto, | |
6952 | JSObject *parent, uintN argc, jsval *argv); | |
6953 | ||
6954 | extern __attribute__((visibility ("default"))) JSObject * | |
6955 | JS_New(JSContext *cx, JSObject *ctor, uintN argc, jsval *argv); | |
6956 | ||
6957 | extern __attribute__((visibility ("default"))) JSObject * | |
6958 | JS_DefineObject(JSContext *cx, JSObject *obj, const char *name, JSClass *clasp, | |
6959 | JSObject *proto, uintN attrs); | |
6960 | ||
6961 | extern __attribute__((visibility ("default"))) JSBool | |
6962 | JS_DefineConstDoubles(JSContext *cx, JSObject *obj, JSConstDoubleSpec *cds); | |
6963 | ||
6964 | extern __attribute__((visibility ("default"))) JSBool | |
6965 | JS_DefineProperties(JSContext *cx, JSObject *obj, JSPropertySpec *ps); | |
6966 | ||
6967 | extern __attribute__((visibility ("default"))) JSBool | |
6968 | JS_DefineProperty(JSContext *cx, JSObject *obj, const char *name, jsval value, | |
6969 | JSPropertyOp getter, JSStrictPropertyOp setter, uintN attrs); | |
6970 | ||
6971 | extern __attribute__((visibility ("default"))) JSBool | |
6972 | JS_DefinePropertyById(JSContext *cx, JSObject *obj, jsid id, jsval value, | |
6973 | JSPropertyOp getter, JSStrictPropertyOp setter, uintN attrs); | |
6974 | ||
6975 | extern __attribute__((visibility ("default"))) JSBool | |
6976 | JS_DefineOwnProperty(JSContext *cx, JSObject *obj, jsid id, jsval descriptor, JSBool *bp); | |
6977 | ||
6978 | ||
6979 | ||
6980 | ||
6981 | ||
6982 | ||
6983 | ||
6984 | extern __attribute__((visibility ("default"))) JSBool | |
6985 | JS_GetPropertyAttributes(JSContext *cx, JSObject *obj, const char *name, | |
6986 | uintN *attrsp, JSBool *foundp); | |
6987 | ||
6988 | ||
6989 | ||
6990 | ||
6991 | ||
6992 | ||
6993 | extern __attribute__((visibility ("default"))) JSBool | |
6994 | JS_GetPropertyAttrsGetterAndSetter(JSContext *cx, JSObject *obj, | |
6995 | const char *name, | |
6996 | uintN *attrsp, JSBool *foundp, | |
6997 | JSPropertyOp *getterp, | |
6998 | JSStrictPropertyOp *setterp); | |
6999 | ||
7000 | extern __attribute__((visibility ("default"))) JSBool | |
7001 | JS_GetPropertyAttrsGetterAndSetterById(JSContext *cx, JSObject *obj, | |
7002 | jsid id, | |
7003 | uintN *attrsp, JSBool *foundp, | |
7004 | JSPropertyOp *getterp, | |
7005 | JSStrictPropertyOp *setterp); | |
7006 | ||
7007 | ||
7008 | ||
7009 | ||
7010 | ||
7011 | ||
7012 | ||
7013 | extern __attribute__((visibility ("default"))) JSBool | |
7014 | JS_SetPropertyAttributes(JSContext *cx, JSObject *obj, const char *name, | |
7015 | uintN attrs, JSBool *foundp); | |
7016 | ||
7017 | extern __attribute__((visibility ("default"))) JSBool | |
7018 | JS_DefinePropertyWithTinyId(JSContext *cx, JSObject *obj, const char *name, | |
7019 | int8 tinyid, jsval value, | |
7020 | JSPropertyOp getter, JSStrictPropertyOp setter, | |
7021 | uintN attrs); | |
7022 | ||
7023 | extern __attribute__((visibility ("default"))) JSBool | |
7024 | JS_AliasProperty(JSContext *cx, JSObject *obj, const char *name, | |
7025 | const char *alias); | |
7026 | ||
7027 | extern __attribute__((visibility ("default"))) JSBool | |
7028 | JS_AlreadyHasOwnProperty(JSContext *cx, JSObject *obj, const char *name, | |
7029 | JSBool *foundp); | |
7030 | ||
7031 | extern __attribute__((visibility ("default"))) JSBool | |
7032 | JS_AlreadyHasOwnPropertyById(JSContext *cx, JSObject *obj, jsid id, | |
7033 | JSBool *foundp); | |
7034 | ||
7035 | extern __attribute__((visibility ("default"))) JSBool | |
7036 | JS_HasProperty(JSContext *cx, JSObject *obj, const char *name, JSBool *foundp); | |
7037 | ||
7038 | extern __attribute__((visibility ("default"))) JSBool | |
7039 | JS_HasPropertyById(JSContext *cx, JSObject *obj, jsid id, JSBool *foundp); | |
7040 | ||
7041 | extern __attribute__((visibility ("default"))) JSBool | |
7042 | JS_LookupProperty(JSContext *cx, JSObject *obj, const char *name, jsval *vp); | |
7043 | ||
7044 | extern __attribute__((visibility ("default"))) JSBool | |
7045 | JS_LookupPropertyById(JSContext *cx, JSObject *obj, jsid id, jsval *vp); | |
7046 | ||
7047 | extern __attribute__((visibility ("default"))) JSBool | |
7048 | JS_LookupPropertyWithFlags(JSContext *cx, JSObject *obj, const char *name, | |
7049 | uintN flags, jsval *vp); | |
7050 | ||
7051 | extern __attribute__((visibility ("default"))) JSBool | |
7052 | JS_LookupPropertyWithFlagsById(JSContext *cx, JSObject *obj, jsid id, | |
7053 | uintN flags, JSObject **objp, jsval *vp); | |
7054 | ||
7055 | struct JSPropertyDescriptor { | |
7056 | JSObject *obj; | |
7057 | uintN attrs; | |
7058 | JSPropertyOp getter; | |
7059 | JSStrictPropertyOp setter; | |
7060 | jsval value; | |
7061 | uintN shortid; | |
7062 | }; | |
7063 | ||
7064 | ||
7065 | ||
7066 | ||
7067 | ||
7068 | ||
7069 | extern __attribute__((visibility ("default"))) JSBool | |
7070 | JS_GetPropertyDescriptorById(JSContext *cx, JSObject *obj, jsid id, uintN flags, | |
7071 | JSPropertyDescriptor *desc); | |
7072 | ||
7073 | extern __attribute__((visibility ("default"))) JSBool | |
7074 | JS_GetOwnPropertyDescriptor(JSContext *cx, JSObject *obj, jsid id, jsval *vp); | |
7075 | ||
7076 | extern __attribute__((visibility ("default"))) JSBool | |
7077 | JS_GetProperty(JSContext *cx, JSObject *obj, const char *name, jsval *vp); | |
7078 | ||
7079 | extern __attribute__((visibility ("default"))) JSBool | |
7080 | JS_GetPropertyDefault(JSContext *cx, JSObject *obj, const char *name, jsval def, jsval *vp); | |
7081 | ||
7082 | extern __attribute__((visibility ("default"))) JSBool | |
7083 | JS_GetPropertyById(JSContext *cx, JSObject *obj, jsid id, jsval *vp); | |
7084 | ||
7085 | extern __attribute__((visibility ("default"))) JSBool | |
7086 | JS_GetPropertyByIdDefault(JSContext *cx, JSObject *obj, jsid id, jsval def, jsval *vp); | |
7087 | ||
7088 | extern __attribute__((visibility ("default"))) JSBool | |
7089 | JS_GetMethodById(JSContext *cx, JSObject *obj, jsid id, JSObject **objp, | |
7090 | jsval *vp); | |
7091 | ||
7092 | extern __attribute__((visibility ("default"))) JSBool | |
7093 | JS_GetMethod(JSContext *cx, JSObject *obj, const char *name, JSObject **objp, | |
7094 | jsval *vp); | |
7095 | ||
7096 | extern __attribute__((visibility ("default"))) JSBool | |
7097 | JS_SetProperty(JSContext *cx, JSObject *obj, const char *name, jsval *vp); | |
7098 | ||
7099 | extern __attribute__((visibility ("default"))) JSBool | |
7100 | JS_SetPropertyById(JSContext *cx, JSObject *obj, jsid id, jsval *vp); | |
7101 | ||
7102 | extern __attribute__((visibility ("default"))) JSBool | |
7103 | JS_DeleteProperty(JSContext *cx, JSObject *obj, const char *name); | |
7104 | ||
7105 | extern __attribute__((visibility ("default"))) JSBool | |
7106 | JS_DeleteProperty2(JSContext *cx, JSObject *obj, const char *name, | |
7107 | jsval *rval); | |
7108 | ||
7109 | extern __attribute__((visibility ("default"))) JSBool | |
7110 | JS_DeletePropertyById(JSContext *cx, JSObject *obj, jsid id); | |
7111 | ||
7112 | extern __attribute__((visibility ("default"))) JSBool | |
7113 | JS_DeletePropertyById2(JSContext *cx, JSObject *obj, jsid id, jsval *rval); | |
7114 | ||
7115 | extern __attribute__((visibility ("default"))) JSBool | |
7116 | JS_DefineUCProperty(JSContext *cx, JSObject *obj, | |
7117 | const jschar *name, size_t namelen, jsval value, | |
7118 | JSPropertyOp getter, JSStrictPropertyOp setter, | |
7119 | uintN attrs); | |
7120 | ||
7121 | ||
7122 | ||
7123 | ||
7124 | ||
7125 | ||
7126 | ||
7127 | extern __attribute__((visibility ("default"))) JSBool | |
7128 | JS_GetUCPropertyAttributes(JSContext *cx, JSObject *obj, | |
7129 | const jschar *name, size_t namelen, | |
7130 | uintN *attrsp, JSBool *foundp); | |
7131 | ||
7132 | ||
7133 | ||
7134 | ||
7135 | ||
7136 | ||
7137 | extern __attribute__((visibility ("default"))) JSBool | |
7138 | JS_GetUCPropertyAttrsGetterAndSetter(JSContext *cx, JSObject *obj, | |
7139 | const jschar *name, size_t namelen, | |
7140 | uintN *attrsp, JSBool *foundp, | |
7141 | JSPropertyOp *getterp, | |
7142 | JSStrictPropertyOp *setterp); | |
7143 | ||
7144 | ||
7145 | ||
7146 | ||
7147 | ||
7148 | ||
7149 | ||
7150 | extern __attribute__((visibility ("default"))) JSBool | |
7151 | JS_SetUCPropertyAttributes(JSContext *cx, JSObject *obj, | |
7152 | const jschar *name, size_t namelen, | |
7153 | uintN attrs, JSBool *foundp); | |
7154 | ||
7155 | ||
7156 | extern __attribute__((visibility ("default"))) JSBool | |
7157 | JS_DefineUCPropertyWithTinyId(JSContext *cx, JSObject *obj, | |
7158 | const jschar *name, size_t namelen, | |
7159 | int8 tinyid, jsval value, | |
7160 | JSPropertyOp getter, JSStrictPropertyOp setter, | |
7161 | uintN attrs); | |
7162 | ||
7163 | extern __attribute__((visibility ("default"))) JSBool | |
7164 | JS_AlreadyHasOwnUCProperty(JSContext *cx, JSObject *obj, const jschar *name, | |
7165 | size_t namelen, JSBool *foundp); | |
7166 | ||
7167 | extern __attribute__((visibility ("default"))) JSBool | |
7168 | JS_HasUCProperty(JSContext *cx, JSObject *obj, | |
7169 | const jschar *name, size_t namelen, | |
7170 | JSBool *vp); | |
7171 | ||
7172 | extern __attribute__((visibility ("default"))) JSBool | |
7173 | JS_LookupUCProperty(JSContext *cx, JSObject *obj, | |
7174 | const jschar *name, size_t namelen, | |
7175 | jsval *vp); | |
7176 | ||
7177 | extern __attribute__((visibility ("default"))) JSBool | |
7178 | JS_GetUCProperty(JSContext *cx, JSObject *obj, | |
7179 | const jschar *name, size_t namelen, | |
7180 | jsval *vp); | |
7181 | ||
7182 | extern __attribute__((visibility ("default"))) JSBool | |
7183 | JS_SetUCProperty(JSContext *cx, JSObject *obj, | |
7184 | const jschar *name, size_t namelen, | |
7185 | jsval *vp); | |
7186 | ||
7187 | extern __attribute__((visibility ("default"))) JSBool | |
7188 | JS_DeleteUCProperty2(JSContext *cx, JSObject *obj, | |
7189 | const jschar *name, size_t namelen, | |
7190 | jsval *rval); | |
7191 | ||
7192 | extern __attribute__((visibility ("default"))) JSObject * | |
7193 | JS_NewArrayObject(JSContext *cx, jsint length, jsval *vector); | |
7194 | ||
7195 | extern __attribute__((visibility ("default"))) JSBool | |
7196 | JS_IsArrayObject(JSContext *cx, JSObject *obj); | |
7197 | ||
7198 | extern __attribute__((visibility ("default"))) JSBool | |
7199 | JS_GetArrayLength(JSContext *cx, JSObject *obj, jsuint *lengthp); | |
7200 | ||
7201 | extern __attribute__((visibility ("default"))) JSBool | |
7202 | JS_SetArrayLength(JSContext *cx, JSObject *obj, jsuint length); | |
7203 | ||
7204 | extern __attribute__((visibility ("default"))) JSBool | |
7205 | JS_HasArrayLength(JSContext *cx, JSObject *obj, jsuint *lengthp); | |
7206 | ||
7207 | extern __attribute__((visibility ("default"))) JSBool | |
7208 | JS_DefineElement(JSContext *cx, JSObject *obj, jsint index, jsval value, | |
7209 | JSPropertyOp getter, JSStrictPropertyOp setter, uintN attrs); | |
7210 | ||
7211 | extern __attribute__((visibility ("default"))) JSBool | |
7212 | JS_AliasElement(JSContext *cx, JSObject *obj, const char *name, jsint alias); | |
7213 | ||
7214 | extern __attribute__((visibility ("default"))) JSBool | |
7215 | JS_AlreadyHasOwnElement(JSContext *cx, JSObject *obj, jsint index, | |
7216 | JSBool *foundp); | |
7217 | ||
7218 | extern __attribute__((visibility ("default"))) JSBool | |
7219 | JS_HasElement(JSContext *cx, JSObject *obj, jsint index, JSBool *foundp); | |
7220 | ||
7221 | extern __attribute__((visibility ("default"))) JSBool | |
7222 | JS_LookupElement(JSContext *cx, JSObject *obj, jsint index, jsval *vp); | |
7223 | ||
7224 | extern __attribute__((visibility ("default"))) JSBool | |
7225 | JS_GetElement(JSContext *cx, JSObject *obj, jsint index, jsval *vp); | |
7226 | ||
7227 | extern __attribute__((visibility ("default"))) JSBool | |
7228 | JS_SetElement(JSContext *cx, JSObject *obj, jsint index, jsval *vp); | |
7229 | ||
7230 | extern __attribute__((visibility ("default"))) JSBool | |
7231 | JS_DeleteElement(JSContext *cx, JSObject *obj, jsint index); | |
7232 | ||
7233 | extern __attribute__((visibility ("default"))) JSBool | |
7234 | JS_DeleteElement2(JSContext *cx, JSObject *obj, jsint index, jsval *rval); | |
7235 | ||
7236 | extern __attribute__((visibility ("default"))) void | |
7237 | JS_ClearScope(JSContext *cx, JSObject *obj); | |
7238 | ||
7239 | extern __attribute__((visibility ("default"))) JSIdArray * | |
7240 | JS_Enumerate(JSContext *cx, JSObject *obj); | |
7241 | ||
7242 | ||
7243 | ||
7244 | ||
7245 | ||
7246 | ||
7247 | extern __attribute__((visibility ("default"))) JSObject * | |
7248 | JS_NewPropertyIterator(JSContext *cx, JSObject *obj); | |
7249 | ||
7250 | ||
7251 | ||
7252 | ||
7253 | ||
7254 | ||
7255 | extern __attribute__((visibility ("default"))) JSBool | |
7256 | JS_NextProperty(JSContext *cx, JSObject *iterobj, jsid *idp); | |
7257 | ||
7258 | extern __attribute__((visibility ("default"))) JSBool | |
7259 | JS_CheckAccess(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode, | |
7260 | jsval *vp, uintN *attrsp); | |
7261 | ||
7262 | extern __attribute__((visibility ("default"))) JSBool | |
7263 | JS_GetReservedSlot(JSContext *cx, JSObject *obj, uint32 index, jsval *vp); | |
7264 | ||
7265 | extern __attribute__((visibility ("default"))) JSBool | |
7266 | JS_SetReservedSlot(JSContext *cx, JSObject *obj, uint32 index, jsval v); | |
7267 | ||
7268 | ||
7269 | ||
7270 | ||
7271 | ||
7272 | ||
7273 | struct JSPrincipals { | |
7274 | char *codebase; | |
7275 | ||
7276 | ||
7277 | void * (* getPrincipalArray)(JSContext *cx, JSPrincipals *); | |
7278 | JSBool (* globalPrivilegesEnabled)(JSContext *cx, JSPrincipals *); | |
7279 | ||
7280 | ||
7281 | jsrefcount refcount; | |
7282 | ||
7283 | void (* destroy)(JSContext *cx, JSPrincipals *); | |
7284 | JSBool (* subsume)(JSPrincipals *, JSPrincipals *); | |
7285 | }; | |
7286 | ||
7287 | ||
7288 | ||
7289 | ||
7290 | ||
7291 | extern __attribute__((visibility ("default"))) jsrefcount | |
7292 | JS_HoldPrincipals(JSContext *cx, JSPrincipals *principals); | |
7293 | ||
7294 | extern __attribute__((visibility ("default"))) jsrefcount | |
7295 | JS_DropPrincipals(JSContext *cx, JSPrincipals *principals); | |
7296 | # 2561 "jsapi.h" | |
7297 | struct JSSecurityCallbacks { | |
7298 | JSCheckAccessOp checkObjectAccess; | |
7299 | JSPrincipalsTranscoder principalsTranscoder; | |
7300 | JSObjectPrincipalsFinder findObjectPrincipals; | |
7301 | JSCSPEvalChecker contentSecurityPolicyAllows; | |
7302 | }; | |
7303 | ||
7304 | extern __attribute__((visibility ("default"))) JSSecurityCallbacks * | |
7305 | JS_SetRuntimeSecurityCallbacks(JSRuntime *rt, JSSecurityCallbacks *callbacks); | |
7306 | ||
7307 | extern __attribute__((visibility ("default"))) JSSecurityCallbacks * | |
7308 | JS_GetRuntimeSecurityCallbacks(JSRuntime *rt); | |
7309 | ||
7310 | extern __attribute__((visibility ("default"))) JSSecurityCallbacks * | |
7311 | JS_SetContextSecurityCallbacks(JSContext *cx, JSSecurityCallbacks *callbacks); | |
7312 | ||
7313 | extern __attribute__((visibility ("default"))) JSSecurityCallbacks * | |
7314 | JS_GetSecurityCallbacks(JSContext *cx); | |
7315 | ||
7316 | ||
7317 | ||
7318 | ||
7319 | ||
7320 | ||
7321 | extern __attribute__((visibility ("default"))) JSFunction * | |
7322 | JS_NewFunction(JSContext *cx, JSNative call, uintN nargs, uintN flags, | |
7323 | JSObject *parent, const char *name); | |
7324 | ||
7325 | ||
7326 | ||
7327 | ||
7328 | ||
7329 | extern __attribute__((visibility ("default"))) JSFunction * | |
7330 | JS_NewFunctionById(JSContext *cx, JSNative call, uintN nargs, uintN flags, | |
7331 | JSObject *parent, jsid id); | |
7332 | ||
7333 | extern __attribute__((visibility ("default"))) JSObject * | |
7334 | JS_GetFunctionObject(JSFunction *fun); | |
7335 | ||
7336 | ||
7337 | ||
7338 | ||
7339 | ||
7340 | ||
7341 | ||
7342 | extern __attribute__((visibility ("default"))) JSString * | |
7343 | JS_GetFunctionId(JSFunction *fun); | |
7344 | ||
7345 | ||
7346 | ||
7347 | ||
7348 | extern __attribute__((visibility ("default"))) uintN | |
7349 | JS_GetFunctionFlags(JSFunction *fun); | |
7350 | ||
7351 | ||
7352 | ||
7353 | ||
7354 | extern __attribute__((visibility ("default"))) uint16 | |
7355 | JS_GetFunctionArity(JSFunction *fun); | |
7356 | ||
7357 | ||
7358 | ||
7359 | ||
7360 | ||
7361 | ||
7362 | ||
7363 | extern __attribute__((visibility ("default"))) JSBool | |
7364 | JS_ObjectIsFunction(JSContext *cx, JSObject *obj); | |
7365 | ||
7366 | extern __attribute__((visibility ("default"))) JSBool | |
7367 | JS_ObjectIsCallable(JSContext *cx, JSObject *obj); | |
7368 | ||
7369 | extern __attribute__((visibility ("default"))) JSBool | |
7370 | JS_DefineFunctions(JSContext *cx, JSObject *obj, JSFunctionSpec *fs); | |
7371 | ||
7372 | extern __attribute__((visibility ("default"))) JSFunction * | |
7373 | JS_DefineFunction(JSContext *cx, JSObject *obj, const char *name, JSNative call, | |
7374 | uintN nargs, uintN attrs); | |
7375 | ||
7376 | extern __attribute__((visibility ("default"))) JSFunction * | |
7377 | JS_DefineUCFunction(JSContext *cx, JSObject *obj, | |
7378 | const jschar *name, size_t namelen, JSNative call, | |
7379 | uintN nargs, uintN attrs); | |
7380 | ||
7381 | extern __attribute__((visibility ("default"))) JSFunction * | |
7382 | JS_DefineFunctionById(JSContext *cx, JSObject *obj, jsid id, JSNative call, | |
7383 | uintN nargs, uintN attrs); | |
7384 | ||
7385 | extern __attribute__((visibility ("default"))) JSObject * | |
7386 | JS_CloneFunctionObject(JSContext *cx, JSObject *funobj, JSObject *parent); | |
7387 | # 2659 "jsapi.h" | |
7388 | extern __attribute__((visibility ("default"))) JSBool | |
7389 | JS_BufferIsCompilableUnit(JSContext *cx, JSObject *obj, | |
7390 | const char *bytes, size_t length); | |
7391 | ||
7392 | extern __attribute__((visibility ("default"))) JSObject * | |
7393 | JS_CompileScript(JSContext *cx, JSObject *obj, | |
7394 | const char *bytes, size_t length, | |
7395 | const char *filename, uintN lineno); | |
7396 | ||
7397 | extern __attribute__((visibility ("default"))) JSObject * | |
7398 | JS_CompileScriptForPrincipals(JSContext *cx, JSObject *obj, | |
7399 | JSPrincipals *principals, | |
7400 | const char *bytes, size_t length, | |
7401 | const char *filename, uintN lineno); | |
7402 | ||
7403 | extern __attribute__((visibility ("default"))) JSObject * | |
7404 | JS_CompileScriptForPrincipalsVersion(JSContext *cx, JSObject *obj, | |
7405 | JSPrincipals *principals, | |
7406 | const char *bytes, size_t length, | |
7407 | const char *filename, uintN lineno, | |
7408 | JSVersion version); | |
7409 | ||
7410 | extern __attribute__((visibility ("default"))) JSObject * | |
7411 | JS_CompileUCScript(JSContext *cx, JSObject *obj, | |
7412 | const jschar *chars, size_t length, | |
7413 | const char *filename, uintN lineno); | |
7414 | ||
7415 | extern __attribute__((visibility ("default"))) JSObject * | |
7416 | JS_CompileUCScriptForPrincipals(JSContext *cx, JSObject *obj, | |
7417 | JSPrincipals *principals, | |
7418 | const jschar *chars, size_t length, | |
7419 | const char *filename, uintN lineno); | |
7420 | ||
7421 | extern __attribute__((visibility ("default"))) JSObject * | |
7422 | JS_CompileUCScriptForPrincipalsVersion(JSContext *cx, JSObject *obj, | |
7423 | JSPrincipals *principals, | |
7424 | const jschar *chars, size_t length, | |
7425 | const char *filename, uintN lineno, | |
7426 | JSVersion version); | |
7427 | ||
7428 | extern __attribute__((visibility ("default"))) JSObject * | |
7429 | JS_CompileFile(JSContext *cx, JSObject *obj, const char *filename); | |
7430 | ||
7431 | extern __attribute__((visibility ("default"))) JSObject * | |
7432 | JS_CompileFileHandle(JSContext *cx, JSObject *obj, const char *filename, | |
7433 | FILE *fh); | |
7434 | ||
7435 | extern __attribute__((visibility ("default"))) JSObject * | |
7436 | JS_CompileFileHandleForPrincipals(JSContext *cx, JSObject *obj, | |
7437 | const char *filename, FILE *fh, | |
7438 | JSPrincipals *principals); | |
7439 | ||
7440 | extern __attribute__((visibility ("default"))) JSObject * | |
7441 | JS_CompileFileHandleForPrincipalsVersion(JSContext *cx, JSObject *obj, | |
7442 | const char *filename, FILE *fh, | |
7443 | JSPrincipals *principals, | |
7444 | JSVersion version); | |
7445 | ||
7446 | extern __attribute__((visibility ("default"))) JSFunction * | |
7447 | JS_CompileFunction(JSContext *cx, JSObject *obj, const char *name, | |
7448 | uintN nargs, const char **argnames, | |
7449 | const char *bytes, size_t length, | |
7450 | const char *filename, uintN lineno); | |
7451 | ||
7452 | extern __attribute__((visibility ("default"))) JSFunction * | |
7453 | JS_CompileFunctionForPrincipals(JSContext *cx, JSObject *obj, | |
7454 | JSPrincipals *principals, const char *name, | |
7455 | uintN nargs, const char **argnames, | |
7456 | const char *bytes, size_t length, | |
7457 | const char *filename, uintN lineno); | |
7458 | ||
7459 | extern __attribute__((visibility ("default"))) JSFunction * | |
7460 | JS_CompileUCFunction(JSContext *cx, JSObject *obj, const char *name, | |
7461 | uintN nargs, const char **argnames, | |
7462 | const jschar *chars, size_t length, | |
7463 | const char *filename, uintN lineno); | |
7464 | ||
7465 | extern __attribute__((visibility ("default"))) JSFunction * | |
7466 | JS_CompileUCFunctionForPrincipals(JSContext *cx, JSObject *obj, | |
7467 | JSPrincipals *principals, const char *name, | |
7468 | uintN nargs, const char **argnames, | |
7469 | const jschar *chars, size_t length, | |
7470 | const char *filename, uintN lineno); | |
7471 | ||
7472 | extern __attribute__((visibility ("default"))) JSFunction * | |
7473 | JS_CompileUCFunctionForPrincipalsVersion(JSContext *cx, JSObject *obj, | |
7474 | JSPrincipals *principals, const char *name, | |
7475 | uintN nargs, const char **argnames, | |
7476 | const jschar *chars, size_t length, | |
7477 | const char *filename, uintN lineno, | |
7478 | JSVersion version); | |
7479 | ||
7480 | extern __attribute__((visibility ("default"))) JSString * | |
7481 | JS_DecompileScriptObject(JSContext *cx, JSObject *scriptObj, const char *name, uintN indent); | |
7482 | ||
7483 | ||
7484 | ||
7485 | ||
7486 | ||
7487 | ||
7488 | ||
7489 | extern __attribute__((visibility ("default"))) JSString * | |
7490 | JS_DecompileFunction(JSContext *cx, JSFunction *fun, uintN indent); | |
7491 | ||
7492 | extern __attribute__((visibility ("default"))) JSString * | |
7493 | JS_DecompileFunctionBody(JSContext *cx, JSFunction *fun, uintN indent); | |
7494 | # 2801 "jsapi.h" | |
7495 | extern __attribute__((visibility ("default"))) JSBool | |
7496 | JS_ExecuteScript(JSContext *cx, JSObject *obj, JSObject *scriptObj, jsval *rval); | |
7497 | ||
7498 | extern __attribute__((visibility ("default"))) JSBool | |
7499 | JS_ExecuteScriptVersion(JSContext *cx, JSObject *obj, JSObject *scriptObj, jsval *rval, | |
7500 | JSVersion version); | |
7501 | ||
7502 | ||
7503 | ||
7504 | ||
7505 | ||
7506 | typedef enum JSExecPart { JSEXEC_PROLOG, JSEXEC_MAIN } JSExecPart; | |
7507 | ||
7508 | extern __attribute__((visibility ("default"))) JSBool | |
7509 | JS_EvaluateScript(JSContext *cx, JSObject *obj, | |
7510 | const char *bytes, uintN length, | |
7511 | const char *filename, uintN lineno, | |
7512 | jsval *rval); | |
7513 | ||
7514 | extern __attribute__((visibility ("default"))) JSBool | |
7515 | JS_EvaluateScriptForPrincipals(JSContext *cx, JSObject *obj, | |
7516 | JSPrincipals *principals, | |
7517 | const char *bytes, uintN length, | |
7518 | const char *filename, uintN lineno, | |
7519 | jsval *rval); | |
7520 | ||
7521 | extern __attribute__((visibility ("default"))) JSBool | |
7522 | JS_EvaluateScriptForPrincipalsVersion(JSContext *cx, JSObject *obj, | |
7523 | JSPrincipals *principals, | |
7524 | const char *bytes, uintN length, | |
7525 | const char *filename, uintN lineno, | |
7526 | jsval *rval, JSVersion version); | |
7527 | ||
7528 | extern __attribute__((visibility ("default"))) JSBool | |
7529 | JS_EvaluateUCScript(JSContext *cx, JSObject *obj, | |
7530 | const jschar *chars, uintN length, | |
7531 | const char *filename, uintN lineno, | |
7532 | jsval *rval); | |
7533 | ||
7534 | extern __attribute__((visibility ("default"))) JSBool | |
7535 | JS_EvaluateUCScriptForPrincipalsVersion(JSContext *cx, JSObject *obj, | |
7536 | JSPrincipals *principals, | |
7537 | const jschar *chars, uintN length, | |
7538 | const char *filename, uintN lineno, | |
7539 | jsval *rval, JSVersion version); | |
7540 | ||
7541 | extern __attribute__((visibility ("default"))) JSBool | |
7542 | JS_EvaluateUCScriptForPrincipals(JSContext *cx, JSObject *obj, | |
7543 | JSPrincipals *principals, | |
7544 | const jschar *chars, uintN length, | |
7545 | const char *filename, uintN lineno, | |
7546 | jsval *rval); | |
7547 | ||
7548 | extern __attribute__((visibility ("default"))) JSBool | |
7549 | JS_CallFunction(JSContext *cx, JSObject *obj, JSFunction *fun, uintN argc, | |
7550 | jsval *argv, jsval *rval); | |
7551 | ||
7552 | extern __attribute__((visibility ("default"))) JSBool | |
7553 | JS_CallFunctionName(JSContext *cx, JSObject *obj, const char *name, uintN argc, | |
7554 | jsval *argv, jsval *rval); | |
7555 | ||
7556 | extern __attribute__((visibility ("default"))) JSBool | |
7557 | JS_CallFunctionValue(JSContext *cx, JSObject *obj, jsval fval, uintN argc, | |
7558 | jsval *argv, jsval *rval); | |
7559 | ||
7560 | ||
7561 | } | |
7562 | ||
7563 | namespace JS { | |
7564 | ||
7565 | static inline | |
7566 | ||
7567 | # 2871 "jsapi.h" | |
7568 | bool | |
7569 | Call(JSContext *cx, JSObject *thisObj, JSFunction *fun, uintN argc, jsval *argv, jsval *rval) { | |
7570 | return !!JS_CallFunction(cx, thisObj, fun, argc, argv, rval); | |
7571 | } | |
7572 | ||
7573 | static inline | |
7574 | ||
7575 | # 2876 "jsapi.h" | |
7576 | bool | |
7577 | Call(JSContext *cx, JSObject *thisObj, const char *name, uintN argc, jsval *argv, jsval *rval) { | |
7578 | return !!JS_CallFunctionName(cx, thisObj, name, argc, argv, rval); | |
7579 | } | |
7580 | ||
7581 | static inline | |
7582 | ||
7583 | # 2881 "jsapi.h" | |
7584 | bool | |
7585 | Call(JSContext *cx, JSObject *thisObj, jsval fun, uintN argc, jsval *argv, jsval *rval) { | |
7586 | return !!JS_CallFunctionValue(cx, thisObj, fun, argc, argv, rval); | |
7587 | } | |
7588 | ||
7589 | extern __attribute__((visibility ("default"))) bool | |
7590 | Call(JSContext *cx, jsval thisv, jsval fun, uintN argc, jsval *argv, jsval *rval); | |
7591 | ||
7592 | static inline | |
7593 | ||
7594 | # 2889 "jsapi.h" | |
7595 | bool | |
7596 | Call(JSContext *cx, jsval thisv, JSObject *funObj, uintN argc, jsval *argv, jsval *rval) { | |
7597 | return Call(cx, thisv, OBJECT_TO_JSVAL(funObj), argc, argv, rval); | |
7598 | } | |
7599 | ||
7600 | } | |
7601 | ||
7602 | extern "C" { | |
7603 | # 2916 "jsapi.h" | |
7604 | extern __attribute__((visibility ("default"))) JSOperationCallback | |
7605 | JS_SetOperationCallback(JSContext *cx, JSOperationCallback callback); | |
7606 | ||
7607 | extern __attribute__((visibility ("default"))) JSOperationCallback | |
7608 | JS_GetOperationCallback(JSContext *cx); | |
7609 | ||
7610 | extern __attribute__((visibility ("default"))) void | |
7611 | JS_TriggerOperationCallback(JSContext *cx); | |
7612 | ||
7613 | extern __attribute__((visibility ("default"))) void | |
7614 | JS_TriggerAllOperationCallbacks(JSRuntime *rt); | |
7615 | ||
7616 | extern __attribute__((visibility ("default"))) JSBool | |
7617 | JS_IsRunning(JSContext *cx); | |
7618 | # 2944 "jsapi.h" | |
7619 | extern __attribute__((visibility ("default"))) JSStackFrame * | |
7620 | JS_SaveFrameChain(JSContext *cx); | |
7621 | ||
7622 | extern __attribute__((visibility ("default"))) void | |
7623 | JS_RestoreFrameChain(JSContext *cx, JSStackFrame *fp); | |
7624 | # 2961 "jsapi.h" | |
7625 | extern __attribute__((visibility ("default"))) JSString * | |
7626 | JS_NewStringCopyN(JSContext *cx, const char *s, size_t n); | |
7627 | ||
7628 | extern __attribute__((visibility ("default"))) JSString * | |
7629 | JS_NewStringCopyZ(JSContext *cx, const char *s); | |
7630 | ||
7631 | extern __attribute__((visibility ("default"))) JSString * | |
7632 | JS_InternJSString(JSContext *cx, JSString *str); | |
7633 | ||
7634 | extern __attribute__((visibility ("default"))) JSString * | |
7635 | JS_InternString(JSContext *cx, const char *s); | |
7636 | ||
7637 | extern __attribute__((visibility ("default"))) JSString * | |
7638 | JS_NewUCString(JSContext *cx, jschar *chars, size_t length); | |
7639 | ||
7640 | extern __attribute__((visibility ("default"))) JSString * | |
7641 | JS_NewUCStringCopyN(JSContext *cx, const jschar *s, size_t n); | |
7642 | ||
7643 | extern __attribute__((visibility ("default"))) JSString * | |
7644 | JS_NewUCStringCopyZ(JSContext *cx, const jschar *s); | |
7645 | ||
7646 | extern __attribute__((visibility ("default"))) JSString * | |
7647 | JS_InternUCStringN(JSContext *cx, const jschar *s, size_t length); | |
7648 | ||
7649 | extern __attribute__((visibility ("default"))) JSString * | |
7650 | JS_InternUCString(JSContext *cx, const jschar *s); | |
7651 | ||
7652 | extern __attribute__((visibility ("default"))) JSBool | |
7653 | JS_CompareStrings(JSContext *cx, JSString *str1, JSString *str2, int32 *result); | |
7654 | ||
7655 | extern __attribute__((visibility ("default"))) JSBool | |
7656 | JS_StringEqualsAscii(JSContext *cx, JSString *str, const char *asciiBytes, JSBool *match); | |
7657 | ||
7658 | extern __attribute__((visibility ("default"))) size_t | |
7659 | JS_PutEscapedString(JSContext *cx, char *buffer, size_t size, JSString *str, char quote); | |
7660 | ||
7661 | extern __attribute__((visibility ("default"))) JSBool | |
7662 | JS_FileEscapedString(FILE *fp, JSString *str, char quote); | |
7663 | # 3035 "jsapi.h" | |
7664 | extern __attribute__((visibility ("default"))) size_t | |
7665 | JS_GetStringLength(JSString *str); | |
7666 | ||
7667 | extern __attribute__((visibility ("default"))) const jschar * | |
7668 | JS_GetStringCharsAndLength(JSContext *cx, JSString *str, size_t *length); | |
7669 | ||
7670 | extern __attribute__((visibility ("default"))) const jschar * | |
7671 | JS_GetInternedStringChars(JSString *str); | |
7672 | ||
7673 | extern __attribute__((visibility ("default"))) const jschar * | |
7674 | JS_GetInternedStringCharsAndLength(JSString *str, size_t *length); | |
7675 | ||
7676 | extern __attribute__((visibility ("default"))) const jschar * | |
7677 | JS_GetStringCharsZ(JSContext *cx, JSString *str); | |
7678 | ||
7679 | extern __attribute__((visibility ("default"))) const jschar * | |
7680 | JS_GetStringCharsZAndLength(JSContext *cx, JSString *str, size_t *length); | |
7681 | ||
7682 | extern __attribute__((visibility ("default"))) JSFlatString * | |
7683 | JS_FlattenString(JSContext *cx, JSString *str); | |
7684 | ||
7685 | extern __attribute__((visibility ("default"))) const jschar * | |
7686 | JS_GetFlatStringChars(JSFlatString *str); | |
7687 | ||
7688 | static __attribute__((always_inline)) inline JSFlatString * | |
7689 | JSID_TO_FLAT_STRING(jsid id) | |
7690 | { | |
7691 | ((void) 0); | |
7692 | return (JSFlatString *)((id)); | |
7693 | } | |
7694 | ||
7695 | static __attribute__((always_inline)) inline JSFlatString * | |
7696 | JS_ASSERT_STRING_IS_FLAT(JSString *str) | |
7697 | { | |
7698 | ((void) 0); | |
7699 | return (JSFlatString *)str; | |
7700 | } | |
7701 | ||
7702 | static __attribute__((always_inline)) inline JSString * | |
7703 | JS_FORGET_STRING_FLATNESS(JSFlatString *fstr) | |
7704 | { | |
7705 | return (JSString *)fstr; | |
7706 | } | |
7707 | ||
7708 | ||
7709 | ||
7710 | ||
7711 | ||
7712 | extern __attribute__((visibility ("default"))) JSBool | |
7713 | JS_FlatStringEqualsAscii(JSFlatString *str, const char *asciiBytes); | |
7714 | ||
7715 | extern __attribute__((visibility ("default"))) size_t | |
7716 | JS_PutEscapedFlatString(char *buffer, size_t size, JSFlatString *str, char quote); | |
7717 | ||
7718 | ||
7719 | ||
7720 | ||
7721 | ||
7722 | extern __attribute__((visibility ("default"))) JSString * | |
7723 | JS_NewGrowableString(JSContext *cx, jschar *chars, size_t length); | |
7724 | # 3122 "jsapi.h" | |
7725 | extern __attribute__((visibility ("default"))) JSString * | |
7726 | JS_NewDependentString(JSContext *cx, JSString *str, size_t start, | |
7727 | size_t length); | |
7728 | ||
7729 | ||
7730 | ||
7731 | ||
7732 | ||
7733 | extern __attribute__((visibility ("default"))) JSString * | |
7734 | JS_ConcatStrings(JSContext *cx, JSString *left, JSString *right); | |
7735 | ||
7736 | ||
7737 | ||
7738 | ||
7739 | ||
7740 | extern __attribute__((visibility ("default"))) const jschar * | |
7741 | JS_UndependString(JSContext *cx, JSString *str); | |
7742 | ||
7743 | ||
7744 | ||
7745 | ||
7746 | ||
7747 | extern __attribute__((visibility ("default"))) JSBool | |
7748 | JS_MakeStringImmutable(JSContext *cx, JSString *str); | |
7749 | ||
7750 | ||
7751 | ||
7752 | ||
7753 | ||
7754 | __attribute__((visibility ("default"))) JSBool | |
7755 | JS_CStringsAreUTF8(void); | |
7756 | ||
7757 | ||
7758 | ||
7759 | ||
7760 | ||
7761 | ||
7762 | __attribute__((visibility ("default"))) void | |
7763 | JS_SetCStringsAreUTF8(void); | |
7764 | # 3183 "jsapi.h" | |
7765 | __attribute__((visibility ("default"))) JSBool | |
7766 | JS_EncodeCharacters(JSContext *cx, const jschar *src, size_t srclen, char *dst, | |
7767 | size_t *dstlenp); | |
7768 | ||
7769 | __attribute__((visibility ("default"))) JSBool | |
7770 | JS_DecodeBytes(JSContext *cx, const char *src, size_t srclen, jschar *dst, | |
7771 | size_t *dstlenp); | |
7772 | ||
7773 | ||
7774 | ||
7775 | ||
7776 | ||
7777 | __attribute__((visibility ("default"))) char * | |
7778 | JS_EncodeString(JSContext *cx, JSString *str); | |
7779 | ||
7780 | ||
7781 | ||
7782 | ||
7783 | ||
7784 | ||
7785 | __attribute__((visibility ("default"))) size_t | |
7786 | JS_GetStringEncodingLength(JSContext *cx, JSString *str); | |
7787 | # 3219 "jsapi.h" | |
7788 | __attribute__((visibility ("default"))) size_t | |
7789 | JS_EncodeStringToBuffer(JSString *str, char *buffer, size_t length); | |
7790 | ||
7791 | ||
7792 | ||
7793 | class JSAutoByteString { | |
7794 | public: | |
7795 | JSAutoByteString(JSContext *cx, JSString *str ) | |
7796 | : mBytes(JS_EncodeString(cx, str)) { | |
7797 | ((void) 0); | |
7798 | do { } while (0); | |
7799 | } | |
7800 | ||
7801 | JSAutoByteString() | |
7802 | : mBytes(__null) { | |
7803 | do { } while (0); | |
7804 | } | |
7805 | ||
7806 | ~JSAutoByteString() { | |
7807 | js_free(mBytes); | |
7808 | } | |
7809 | ||
7810 | ||
7811 | void initBytes(char *bytes) { | |
7812 | ((void) 0); | |
7813 | mBytes = bytes; | |
7814 | } | |
7815 | ||
7816 | char *encode(JSContext *cx, JSString *str) { | |
7817 | ((void) 0); | |
7818 | ((void) 0); | |
7819 | mBytes = JS_EncodeString(cx, str); | |
7820 | return mBytes; | |
7821 | } | |
7822 | ||
7823 | void clear() { | |
7824 | js_free(mBytes); | |
7825 | mBytes = __null; | |
7826 | } | |
7827 | ||
7828 | char *ptr() const { | |
7829 | return mBytes; | |
7830 | } | |
7831 | ||
7832 | bool operator!() const { | |
7833 | return !mBytes; | |
7834 | } | |
7835 | ||
7836 | private: | |
7837 | char *mBytes; | |
7838 | ||
7839 | ||
7840 | ||
7841 | JSAutoByteString(const JSAutoByteString &another); | |
7842 | JSAutoByteString &operator=(const JSAutoByteString &another); | |
7843 | }; | |
7844 | ||
7845 | ||
7846 | ||
7847 | ||
7848 | ||
7849 | ||
7850 | ||
7851 | typedef JSBool (* JSONWriteCallback)(const jschar *buf, uint32 len, void *data); | |
7852 | ||
7853 | ||
7854 | ||
7855 | ||
7856 | __attribute__((visibility ("default"))) JSBool | |
7857 | JS_Stringify(JSContext *cx, jsval *vp, JSObject *replacer, jsval space, | |
7858 | JSONWriteCallback callback, void *data); | |
7859 | ||
7860 | ||
7861 | ||
7862 | ||
7863 | __attribute__((visibility ("default"))) JSBool | |
7864 | JS_TryJSON(JSContext *cx, jsval *vp); | |
7865 | ||
7866 | ||
7867 | ||
7868 | ||
7869 | __attribute__((visibility ("default"))) JSONParser * | |
7870 | JS_BeginJSONParse(JSContext *cx, jsval *vp); | |
7871 | ||
7872 | __attribute__((visibility ("default"))) JSBool | |
7873 | JS_ConsumeJSONText(JSContext *cx, JSONParser *jp, const jschar *data, uint32 len); | |
7874 | ||
7875 | __attribute__((visibility ("default"))) JSBool | |
7876 | JS_FinishJSONParse(JSContext *cx, JSONParser *jp, jsval reviver); | |
7877 | # 3316 "jsapi.h" | |
7878 | struct JSStructuredCloneCallbacks { | |
7879 | ReadStructuredCloneOp read; | |
7880 | WriteStructuredCloneOp write; | |
7881 | StructuredCloneErrorOp reportError; | |
7882 | }; | |
7883 | ||
7884 | __attribute__((visibility ("default"))) JSBool | |
7885 | JS_ReadStructuredClone(JSContext *cx, const uint64 *data, size_t nbytes, | |
7886 | uint32 version, jsval *vp, | |
7887 | const JSStructuredCloneCallbacks *optionalCallbacks, | |
7888 | void *closure); | |
7889 | ||
7890 | ||
7891 | __attribute__((visibility ("default"))) JSBool | |
7892 | JS_WriteStructuredClone(JSContext *cx, jsval v, uint64 **datap, size_t *nbytesp, | |
7893 | const JSStructuredCloneCallbacks *optionalCallbacks, | |
7894 | void *closure); | |
7895 | ||
7896 | __attribute__((visibility ("default"))) JSBool | |
7897 | JS_StructuredClone(JSContext *cx, jsval v, jsval *vp, | |
7898 | const JSStructuredCloneCallbacks *optionalCallbacks, | |
7899 | void *closure); | |
7900 | ||
7901 | ||
7902 | ||
7903 | class JSAutoStructuredCloneBuffer { | |
7904 | JSContext *cx_; | |
7905 | uint64 *data_; | |
7906 | size_t nbytes_; | |
7907 | uint32 version_; | |
7908 | ||
7909 | public: | |
7910 | JSAutoStructuredCloneBuffer() | |
7911 | : cx_(__null), data_(__null), nbytes_(0), version_(1) {} | |
7912 | ||
7913 | ~JSAutoStructuredCloneBuffer() { clear(); } | |
7914 | ||
7915 | JSContext *cx() const { return cx_; } | |
7916 | uint64 *data() const { return data_; } | |
7917 | size_t nbytes() const { return nbytes_; } | |
7918 | ||
7919 | void clear(JSContext *cx=__null) { | |
7920 | if (data_) { | |
7921 | if (!cx) | |
7922 | cx = cx_; | |
7923 | ((void) 0); | |
7924 | JS_free(cx, data_); | |
7925 | cx_ = __null; | |
7926 | data_ = __null; | |
7927 | nbytes_ = 0; | |
7928 | version_ = 0; | |
7929 | } | |
7930 | } | |
7931 | ||
7932 | ||
7933 | ||
7934 | ||
7935 | ||
7936 | void adopt(JSContext *cx, uint64 *data, size_t nbytes, | |
7937 | uint32 version=1) { | |
7938 | clear(cx); | |
7939 | cx_ = cx; | |
7940 | data_ = data; | |
7941 | nbytes_ = nbytes; | |
7942 | version_ = version; | |
7943 | } | |
7944 | ||
7945 | ||
7946 | ||
7947 | ||
7948 | ||
7949 | void steal(uint64 **datap, size_t *nbytesp, JSContext **cxp=__null, | |
7950 | uint32 *versionp=__null) { | |
7951 | *datap = data_; | |
7952 | *nbytesp = nbytes_; | |
7953 | if (cxp) | |
7954 | *cxp = cx_; | |
7955 | if (versionp) | |
7956 | *versionp = version_; | |
7957 | ||
7958 | cx_ = __null; | |
7959 | data_ = __null; | |
7960 | nbytes_ = 0; | |
7961 | version_ = 0; | |
7962 | } | |
7963 | ||
7964 | bool read(jsval *vp, JSContext *cx=__null, | |
7965 | const JSStructuredCloneCallbacks *optionalCallbacks=__null, | |
7966 | void *closure=__null) const { | |
7967 | if (!cx) | |
7968 | cx = cx_; | |
7969 | ((void) 0); | |
7970 | ((void) 0); | |
7971 | return !!JS_ReadStructuredClone(cx, data_, nbytes_, version_, vp, | |
7972 | optionalCallbacks, closure); | |
7973 | } | |
7974 | ||
7975 | bool write(JSContext *cx, jsval v, | |
7976 | const JSStructuredCloneCallbacks *optionalCallbacks=__null, | |
7977 | void *closure=__null) { | |
7978 | clear(cx); | |
7979 | cx_ = cx; | |
7980 | bool ok = !!JS_WriteStructuredClone(cx, v, &data_, &nbytes_, | |
7981 | optionalCallbacks, closure); | |
7982 | if (!ok) { | |
7983 | data_ = __null; | |
7984 | nbytes_ = 0; | |
7985 | version_ = 1; | |
7986 | } | |
7987 | return ok; | |
7988 | } | |
7989 | ||
7990 | ||
7991 | ||
7992 | ||
7993 | void swap(JSAutoStructuredCloneBuffer &other) { | |
7994 | JSContext *cx = other.cx_; | |
7995 | uint64 *data = other.data_; | |
7996 | size_t nbytes = other.nbytes_; | |
7997 | uint32 version = other.version_; | |
7998 | ||
7999 | other.cx_ = this->cx_; | |
8000 | other.data_ = this->data_; | |
8001 | other.nbytes_ = this->nbytes_; | |
8002 | other.version_ = this->version_; | |
8003 | ||
8004 | this->cx_ = cx; | |
8005 | this->data_ = data; | |
8006 | this->nbytes_ = nbytes; | |
8007 | this->version_ = version; | |
8008 | } | |
8009 | ||
8010 | private: | |
8011 | ||
8012 | JSAutoStructuredCloneBuffer(const JSAutoStructuredCloneBuffer &other); | |
8013 | JSAutoStructuredCloneBuffer &operator=(const JSAutoStructuredCloneBuffer &other); | |
8014 | }; | |
8015 | # 3463 "jsapi.h" | |
8016 | __attribute__((visibility ("default"))) void | |
8017 | JS_SetStructuredCloneCallbacks(JSRuntime *rt, const JSStructuredCloneCallbacks *callbacks); | |
8018 | ||
8019 | __attribute__((visibility ("default"))) JSBool | |
8020 | JS_ReadUint32Pair(JSStructuredCloneReader *r, uint32 *p1, uint32 *p2); | |
8021 | ||
8022 | __attribute__((visibility ("default"))) JSBool | |
8023 | JS_ReadBytes(JSStructuredCloneReader *r, void *p, size_t len); | |
8024 | ||
8025 | __attribute__((visibility ("default"))) JSBool | |
8026 | JS_WriteUint32Pair(JSStructuredCloneWriter *w, uint32 tag, uint32 data); | |
8027 | ||
8028 | __attribute__((visibility ("default"))) JSBool | |
8029 | JS_WriteBytes(JSStructuredCloneWriter *w, const void *p, size_t len); | |
8030 | ||
8031 | ||
8032 | ||
8033 | ||
8034 | ||
8035 | ||
8036 | struct JSLocaleCallbacks { | |
8037 | JSLocaleToUpperCase localeToUpperCase; | |
8038 | JSLocaleToLowerCase localeToLowerCase; | |
8039 | JSLocaleCompare localeCompare; | |
8040 | JSLocaleToUnicode localeToUnicode; | |
8041 | JSErrorCallback localeGetErrorMessage; | |
8042 | }; | |
8043 | ||
8044 | ||
8045 | ||
8046 | ||
8047 | ||
8048 | extern __attribute__((visibility ("default"))) void | |
8049 | JS_SetLocaleCallbacks(JSContext *cx, JSLocaleCallbacks *callbacks); | |
8050 | ||
8051 | ||
8052 | ||
8053 | ||
8054 | ||
8055 | extern __attribute__((visibility ("default"))) JSLocaleCallbacks * | |
8056 | JS_GetLocaleCallbacks(JSContext *cx); | |
8057 | # 3517 "jsapi.h" | |
8058 | extern __attribute__((visibility ("default"))) void | |
8059 | JS_ReportError(JSContext *cx, const char *format, ...); | |
8060 | ||
8061 | ||
8062 | ||
8063 | ||
8064 | extern __attribute__((visibility ("default"))) void | |
8065 | JS_ReportErrorNumber(JSContext *cx, JSErrorCallback errorCallback, | |
8066 | void *userRef, const uintN errorNumber, ...); | |
8067 | ||
8068 | ||
8069 | ||
8070 | ||
8071 | extern __attribute__((visibility ("default"))) void | |
8072 | JS_ReportErrorNumberUC(JSContext *cx, JSErrorCallback errorCallback, | |
8073 | void *userRef, const uintN errorNumber, ...); | |
8074 | ||
8075 | ||
8076 | ||
8077 | ||
8078 | ||
8079 | ||
8080 | ||
8081 | extern __attribute__((visibility ("default"))) JSBool | |
8082 | JS_ReportWarning(JSContext *cx, const char *format, ...); | |
8083 | ||
8084 | extern __attribute__((visibility ("default"))) JSBool | |
8085 | JS_ReportErrorFlagsAndNumber(JSContext *cx, uintN flags, | |
8086 | JSErrorCallback errorCallback, void *userRef, | |
8087 | const uintN errorNumber, ...); | |
8088 | ||
8089 | extern __attribute__((visibility ("default"))) JSBool | |
8090 | JS_ReportErrorFlagsAndNumberUC(JSContext *cx, uintN flags, | |
8091 | JSErrorCallback errorCallback, void *userRef, | |
8092 | const uintN errorNumber, ...); | |
8093 | ||
8094 | ||
8095 | ||
8096 | ||
8097 | extern __attribute__((visibility ("default"))) void | |
8098 | JS_ReportOutOfMemory(JSContext *cx); | |
8099 | ||
8100 | ||
8101 | ||
8102 | ||
8103 | extern __attribute__((visibility ("default"))) void | |
8104 | JS_ReportAllocationOverflow(JSContext *cx); | |
8105 | ||
8106 | struct JSErrorReport { | |
8107 | const char *filename; | |
8108 | uintN lineno; | |
8109 | const char *linebuf; | |
8110 | const char *tokenptr; | |
8111 | const jschar *uclinebuf; | |
8112 | const jschar *uctokenptr; | |
8113 | uintN flags; | |
8114 | uintN errorNumber; | |
8115 | const jschar *ucmessage; | |
8116 | const jschar **messageArgs; | |
8117 | }; | |
8118 | # 3608 "jsapi.h" | |
8119 | extern __attribute__((visibility ("default"))) JSErrorReporter | |
8120 | JS_SetErrorReporter(JSContext *cx, JSErrorReporter er); | |
8121 | ||
8122 | ||
8123 | ||
8124 | ||
8125 | ||
8126 | ||
8127 | ||
8128 | extern __attribute__((visibility ("default"))) JSObject * | |
8129 | JS_NewDateObject(JSContext *cx, int year, int mon, int mday, int hour, int min, int sec); | |
8130 | ||
8131 | extern __attribute__((visibility ("default"))) JSObject * | |
8132 | JS_NewDateObjectMsec(JSContext *cx, jsdouble msec); | |
8133 | ||
8134 | ||
8135 | ||
8136 | ||
8137 | extern __attribute__((visibility ("default"))) JSBool | |
8138 | JS_ObjectIsDate(JSContext *cx, JSObject *obj); | |
8139 | # 3641 "jsapi.h" | |
8140 | extern __attribute__((visibility ("default"))) JSObject * | |
8141 | JS_NewRegExpObject(JSContext *cx, JSObject *obj, char *bytes, size_t length, uintN flags); | |
8142 | ||
8143 | extern __attribute__((visibility ("default"))) JSObject * | |
8144 | JS_NewUCRegExpObject(JSContext *cx, JSObject *obj, jschar *chars, size_t length, uintN flags); | |
8145 | ||
8146 | extern __attribute__((visibility ("default"))) void | |
8147 | JS_SetRegExpInput(JSContext *cx, JSObject *obj, JSString *input, JSBool multiline); | |
8148 | ||
8149 | extern __attribute__((visibility ("default"))) void | |
8150 | JS_ClearRegExpStatics(JSContext *cx, JSObject *obj); | |
8151 | ||
8152 | extern __attribute__((visibility ("default"))) JSBool | |
8153 | JS_ExecuteRegExp(JSContext *cx, JSObject *obj, JSObject *reobj, jschar *chars, size_t length, | |
8154 | size_t *indexp, JSBool test, jsval *rval); | |
8155 | ||
8156 | ||
8157 | ||
8158 | extern __attribute__((visibility ("default"))) JSObject * | |
8159 | JS_NewRegExpObjectNoStatics(JSContext *cx, char *bytes, size_t length, uintN flags); | |
8160 | ||
8161 | extern __attribute__((visibility ("default"))) JSObject * | |
8162 | JS_NewUCRegExpObjectNoStatics(JSContext *cx, jschar *chars, size_t length, uintN flags); | |
8163 | ||
8164 | extern __attribute__((visibility ("default"))) JSBool | |
8165 | JS_ExecuteRegExpNoStatics(JSContext *cx, JSObject *reobj, jschar *chars, size_t length, | |
8166 | size_t *indexp, JSBool test, jsval *rval); | |
8167 | ||
8168 | ||
8169 | ||
8170 | extern __attribute__((visibility ("default"))) JSBool | |
8171 | JS_IsExceptionPending(JSContext *cx); | |
8172 | ||
8173 | extern __attribute__((visibility ("default"))) JSBool | |
8174 | JS_GetPendingException(JSContext *cx, jsval *vp); | |
8175 | ||
8176 | extern __attribute__((visibility ("default"))) void | |
8177 | JS_SetPendingException(JSContext *cx, jsval v); | |
8178 | ||
8179 | extern __attribute__((visibility ("default"))) void | |
8180 | JS_ClearPendingException(JSContext *cx); | |
8181 | ||
8182 | extern __attribute__((visibility ("default"))) JSBool | |
8183 | JS_ReportPendingException(JSContext *cx); | |
8184 | # 3697 "jsapi.h" | |
8185 | extern __attribute__((visibility ("default"))) JSExceptionState * | |
8186 | JS_SaveExceptionState(JSContext *cx); | |
8187 | ||
8188 | extern __attribute__((visibility ("default"))) void | |
8189 | JS_RestoreExceptionState(JSContext *cx, JSExceptionState *state); | |
8190 | ||
8191 | extern __attribute__((visibility ("default"))) void | |
8192 | JS_DropExceptionState(JSContext *cx, JSExceptionState *state); | |
8193 | # 3713 "jsapi.h" | |
8194 | extern __attribute__((visibility ("default"))) JSErrorReport * | |
8195 | JS_ErrorFromException(JSContext *cx, jsval v); | |
8196 | ||
8197 | ||
8198 | ||
8199 | ||
8200 | ||
8201 | extern __attribute__((visibility ("default"))) JSBool | |
8202 | JS_ThrowReportedError(JSContext *cx, const char *message, | |
8203 | JSErrorReport *reportp); | |
8204 | ||
8205 | ||
8206 | ||
8207 | ||
8208 | extern __attribute__((visibility ("default"))) JSBool | |
8209 | JS_ThrowStopIteration(JSContext *cx); | |
8210 | # 3739 "jsapi.h" | |
8211 | extern __attribute__((visibility ("default"))) jsword | |
8212 | JS_GetContextThread(JSContext *cx); | |
8213 | ||
8214 | extern __attribute__((visibility ("default"))) jsword | |
8215 | JS_SetContextThread(JSContext *cx); | |
8216 | ||
8217 | extern __attribute__((visibility ("default"))) jsword | |
8218 | JS_ClearContextThread(JSContext *cx); | |
8219 | # 3757 "jsapi.h" | |
8220 | static __attribute__((always_inline)) inline JSBool | |
8221 | JS_IsConstructing(JSContext *cx, const jsval *vp) | |
8222 | { | |
8223 | jsval_layout l; | |
8224 | # 3772 "jsapi.h" | |
8225 | l.asBits = (vp[1]); | |
8226 | return JSVAL_IS_MAGIC_IMPL(l); | |
8227 | } | |
8228 | # 3797 "jsapi.h" | |
8229 | static __attribute__((always_inline)) inline JSBool | |
8230 | JS_IsConstructing_PossiblyWithGivenThisObject(JSContext *cx, const jsval *vp, | |
8231 | JSObject **maybeThis) | |
8232 | { | |
8233 | jsval_layout l; | |
8234 | JSBool isCtor; | |
8235 | # 3814 "jsapi.h" | |
8236 | l.asBits = (vp[1]); | |
8237 | isCtor = JSVAL_IS_MAGIC_IMPL(l); | |
8238 | if (isCtor) | |
8239 | *maybeThis = MAGIC_JSVAL_TO_OBJECT_OR_NULL_IMPL(l); | |
8240 | return isCtor; | |
8241 | } | |
8242 | ||
8243 | ||
8244 | ||
8245 | ||
8246 | ||
8247 | ||
8248 | extern __attribute__((visibility ("default"))) JSObject * | |
8249 | JS_NewObjectForConstructor(JSContext *cx, const jsval *vp); | |
8250 | # 3840 "jsapi.h" | |
8251 | } | |
8252 | # 53 "jsxml.cpp" 2 | |
8253 | # 1 "jsarray.h" 1 | |
8254 | # 45 "jsarray.h" | |
8255 | # 1 "jsprvtd.h" 1 | |
8256 | # 58 "jsprvtd.h" | |
8257 | # 1 "jsstaticcheck.h" 1 | |
8258 | # 59 "jsprvtd.h" 2 | |
8259 | ||
8260 | ||
8261 | extern "C" { | |
8262 | # 70 "jsprvtd.h" | |
8263 | static const uintN JS_GCTHING_ALIGN = 8; | |
8264 | static const uintN JS_GCTHING_ZEROBITS = 3; | |
8265 | ||
8266 | ||
8267 | typedef uint8 jsbytecode; | |
8268 | typedef uint8 jssrcnote; | |
8269 | typedef uint32 jsatomid; | |
8270 | ||
8271 | ||
8272 | typedef struct JSArgumentFormatMap JSArgumentFormatMap; | |
8273 | typedef struct JSCodeGenerator JSCodeGenerator; | |
8274 | typedef struct JSGCThing JSGCThing; | |
8275 | typedef struct JSGenerator JSGenerator; | |
8276 | typedef struct JSNativeEnumerator JSNativeEnumerator; | |
8277 | typedef struct JSFunctionBox JSFunctionBox; | |
8278 | typedef struct JSObjectBox JSObjectBox; | |
8279 | typedef struct JSParseNode JSParseNode; | |
8280 | typedef struct JSProperty JSProperty; | |
8281 | typedef struct JSScript JSScript; | |
8282 | typedef struct JSSharpObjectMap JSSharpObjectMap; | |
8283 | typedef struct JSThread JSThread; | |
8284 | typedef struct JSThreadData JSThreadData; | |
8285 | typedef struct JSTreeContext JSTreeContext; | |
8286 | typedef struct JSTryNote JSTryNote; | |
8287 | ||
8288 | ||
8289 | typedef struct JSLinearString JSLinearString; | |
8290 | typedef struct JSAtom JSAtom; | |
8291 | typedef struct JSAtomList JSAtomList; | |
8292 | typedef struct JSAtomListElement JSAtomListElement; | |
8293 | typedef struct JSAtomMap JSAtomMap; | |
8294 | typedef struct JSAtomState JSAtomState; | |
8295 | typedef struct JSCodeSpec JSCodeSpec; | |
8296 | typedef struct JSPrinter JSPrinter; | |
8297 | typedef struct JSRegExpStatics JSRegExpStatics; | |
8298 | typedef struct JSStackHeader JSStackHeader; | |
8299 | typedef struct JSSubString JSSubString; | |
8300 | typedef struct JSNativeTraceInfo JSNativeTraceInfo; | |
8301 | typedef struct JSSpecializedNative JSSpecializedNative; | |
8302 | typedef struct JSXML JSXML; | |
8303 | typedef struct JSXMLArray JSXMLArray; | |
8304 | typedef struct JSXMLArrayCursor JSXMLArrayCursor; | |
8305 | # 121 "jsprvtd.h" | |
8306 | extern "C++" { | |
8307 | ||
8308 | namespace js { | |
8309 | ||
8310 | struct ArgumentsData; | |
8311 | ||
8312 | class RegExp; | |
8313 | class RegExpStatics; | |
8314 | class AutoStringRooter; | |
8315 | class ExecuteArgsGuard; | |
8316 | class InvokeFrameGuard; | |
8317 | class InvokeArgsGuard; | |
8318 | class InvokeSessionGuard; | |
8319 | class TraceRecorder; | |
8320 | struct TraceMonitor; | |
8321 | class StackSpace; | |
8322 | class StackSegment; | |
8323 | class FrameRegsIter; | |
8324 | class StringBuffer; | |
8325 | ||
8326 | struct Compiler; | |
8327 | struct Parser; | |
8328 | class TokenStream; | |
8329 | struct Token; | |
8330 | struct TokenPos; | |
8331 | struct TokenPtr; | |
8332 | ||
8333 | class ContextAllocPolicy; | |
8334 | class SystemAllocPolicy; | |
8335 | ||
8336 | template <class T, | |
8337 | size_t MinInlineCapacity = 0, | |
8338 | class AllocPolicy = ContextAllocPolicy> | |
8339 | class Vector; | |
8340 | ||
8341 | template <class> | |
8342 | struct DefaultHasher; | |
8343 | ||
8344 | template <class Key, | |
8345 | class Value, | |
8346 | class HashPolicy = DefaultHasher<Key>, | |
8347 | class AllocPolicy = ContextAllocPolicy> | |
8348 | class HashMap; | |
8349 | ||
8350 | template <class T, | |
8351 | class HashPolicy = DefaultHasher<T>, | |
8352 | class AllocPolicy = ContextAllocPolicy> | |
8353 | class HashSet; | |
8354 | ||
8355 | class PropertyCache; | |
8356 | struct PropertyCacheEntry; | |
8357 | ||
8358 | struct Shape; | |
8359 | struct EmptyShape; | |
8360 | ||
8361 | } | |
8362 | ||
8363 | } | |
8364 | ||
8365 | ||
8366 | ||
8367 | typedef enum JSTrapStatus { | |
8368 | JSTRAP_ERROR, | |
8369 | JSTRAP_CONTINUE, | |
8370 | JSTRAP_RETURN, | |
8371 | JSTRAP_THROW, | |
8372 | JSTRAP_LIMIT | |
8373 | } JSTrapStatus; | |
8374 | ||
8375 | typedef JSTrapStatus | |
8376 | (* JSTrapHandler)(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval, | |
8377 | jsval closure); | |
8378 | ||
8379 | typedef JSTrapStatus | |
8380 | (* JSInterruptHook)(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval, | |
8381 | void *closure); | |
8382 | ||
8383 | typedef JSTrapStatus | |
8384 | (* JSDebuggerHandler)(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval, | |
8385 | void *closure); | |
8386 | ||
8387 | typedef JSTrapStatus | |
8388 | (* JSThrowHook)(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval, | |
8389 | void *closure); | |
8390 | ||
8391 | typedef JSBool | |
8392 | (* JSWatchPointHandler)(JSContext *cx, JSObject *obj, jsid id, jsval old, | |
8393 | jsval *newp, void *closure); | |
8394 | ||
8395 | ||
8396 | typedef void | |
8397 | (* JSNewScriptHook)(JSContext *cx, | |
8398 | const char *filename, | |
8399 | uintN lineno, | |
8400 | JSScript *script, | |
8401 | JSFunction *fun, | |
8402 | void *callerdata); | |
8403 | ||
8404 | ||
8405 | typedef void | |
8406 | (* JSDestroyScriptHook)(JSContext *cx, | |
8407 | JSScript *script, | |
8408 | void *callerdata); | |
8409 | ||
8410 | typedef void | |
8411 | (* JSSourceHandler)(const char *filename, uintN lineno, jschar *str, | |
8412 | size_t length, void **listenerTSData, void *closure); | |
8413 | # 254 "jsprvtd.h" | |
8414 | typedef void * | |
8415 | (* JSInterpreterHook)(JSContext *cx, JSStackFrame *fp, JSBool before, | |
8416 | JSBool *ok, void *closure); | |
8417 | ||
8418 | typedef JSBool | |
8419 | (* JSDebugErrorHook)(JSContext *cx, const char *message, JSErrorReport *report, | |
8420 | void *closure); | |
8421 | ||
8422 | typedef struct JSDebugHooks { | |
8423 | JSInterruptHook interruptHook; | |
8424 | void *interruptHookData; | |
8425 | JSNewScriptHook newScriptHook; | |
8426 | void *newScriptHookData; | |
8427 | JSDestroyScriptHook destroyScriptHook; | |
8428 | void *destroyScriptHookData; | |
8429 | JSDebuggerHandler debuggerHandler; | |
8430 | void *debuggerHandlerData; | |
8431 | JSSourceHandler sourceHandler; | |
8432 | void *sourceHandlerData; | |
8433 | JSInterpreterHook executeHook; | |
8434 | void *executeHookData; | |
8435 | JSInterpreterHook callHook; | |
8436 | void *callHookData; | |
8437 | JSThrowHook throwHook; | |
8438 | void *throwHookData; | |
8439 | JSDebugErrorHook debugErrorHook; | |
8440 | void *debugErrorHookData; | |
8441 | } JSDebugHooks; | |
8442 | # 301 "jsprvtd.h" | |
8443 | typedef JSBool | |
8444 | (* JSLookupPropOp)(JSContext *cx, JSObject *obj, jsid id, JSObject **objp, | |
8445 | JSProperty **propp); | |
8446 | ||
8447 | ||
8448 | ||
8449 | ||
8450 | ||
8451 | typedef JSBool | |
8452 | (* JSAttributesOp)(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp); | |
8453 | ||
8454 | ||
8455 | ||
8456 | ||
8457 | ||
8458 | typedef JSObject * | |
8459 | (* JSObjectOp)(JSContext *cx, JSObject *obj); | |
8460 | ||
8461 | ||
8462 | ||
8463 | ||
8464 | ||
8465 | typedef JSObject * | |
8466 | (* JSIteratorOp)(JSContext *cx, JSObject *obj, JSBool keysonly); | |
8467 | # 333 "jsprvtd.h" | |
8468 | extern JSBool js_CStringsAreUTF8; | |
8469 | ||
8470 | ||
8471 | ||
8472 | ||
8473 | ||
8474 | ||
8475 | extern __attribute__((visibility ("default"))) JSObject * | |
8476 | js_ObjectToOuterObject(JSContext *cx, JSObject *obj); | |
8477 | ||
8478 | } | |
8479 | # 46 "jsarray.h" 2 | |
8480 | ||
8481 | # 1 "jsatom.h" 1 | |
8482 | # 45 "jsatom.h" | |
8483 | # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stddef.h" 1 3 4 | |
8484 | # 46 "jsatom.h" 2 | |
8485 | # 1 "jsversion.h" 1 | |
8486 | # 47 "jsatom.h" 2 | |
8487 | ||
8488 | ||
8489 | # 1 "jshash.h" 1 | |
8490 | # 45 "jshash.h" | |
8491 | # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stddef.h" 1 3 4 | |
8492 | # 46 "jshash.h" 2 | |
8493 | ||
8494 | ||
8495 | ||
8496 | ||
8497 | extern "C" { | |
8498 | ||
8499 | typedef uint32 JSHashNumber; | |
8500 | typedef struct JSHashEntry JSHashEntry; | |
8501 | typedef struct JSHashTable JSHashTable; | |
8502 | ||
8503 | ||
8504 | ||
8505 | ||
8506 | typedef JSHashNumber (* JSHashFunction)(const void *key); | |
8507 | typedef intN (* JSHashComparator)(const void *v1, const void *v2); | |
8508 | typedef intN (* JSHashEnumerator)(JSHashEntry *he, intN i, void *arg); | |
8509 | ||
8510 | ||
8511 | ||
8512 | ||
8513 | ||
8514 | ||
8515 | typedef struct JSHashAllocOps { | |
8516 | void * (*allocTable)(void *pool, size_t size); | |
8517 | void (*freeTable)(void *pool, void *item, size_t size); | |
8518 | JSHashEntry * (*allocEntry)(void *pool, const void *key); | |
8519 | void (*freeEntry)(void *pool, JSHashEntry *he, uintN flag); | |
8520 | } JSHashAllocOps; | |
8521 | ||
8522 | ||
8523 | ||
8524 | ||
8525 | struct JSHashEntry { | |
8526 | JSHashEntry *next; | |
8527 | JSHashNumber keyHash; | |
8528 | const void *key; | |
8529 | void *value; | |
8530 | }; | |
8531 | ||
8532 | struct JSHashTable { | |
8533 | JSHashEntry **buckets; | |
8534 | uint32 nentries; | |
8535 | uint32 shift; | |
8536 | JSHashFunction keyHash; | |
8537 | JSHashComparator keyCompare; | |
8538 | JSHashComparator valueCompare; | |
8539 | JSHashAllocOps *allocOps; | |
8540 | void *allocPriv; | |
8541 | ||
8542 | ||
8543 | ||
8544 | ||
8545 | ||
8546 | ||
8547 | }; | |
8548 | ||
8549 | ||
8550 | ||
8551 | ||
8552 | ||
8553 | extern __attribute__((visibility ("default"))) JSHashTable * | |
8554 | JS_NewHashTable(uint32 n, JSHashFunction keyHash, | |
8555 | JSHashComparator keyCompare, JSHashComparator valueCompare, | |
8556 | JSHashAllocOps *allocOps, void *allocPriv); | |
8557 | ||
8558 | extern __attribute__((visibility ("default"))) void | |
8559 | JS_HashTableDestroy(JSHashTable *ht); | |
8560 | ||
8561 | ||
8562 | extern __attribute__((visibility ("default"))) JSHashEntry ** | |
8563 | JS_HashTableRawLookup(JSHashTable *ht, JSHashNumber keyHash, const void *key); | |
8564 | ||
8565 | ||
8566 | extern __attribute__((visibility ("default"))) JSHashEntry * | |
8567 | JS_HashTableRawAdd(JSHashTable *ht, JSHashEntry **&hep, JSHashNumber keyHash, | |
8568 | const void *key, void *value); | |
8569 | ||
8570 | ||
8571 | extern __attribute__((visibility ("default"))) void | |
8572 | JS_HashTableRawRemove(JSHashTable *ht, JSHashEntry **hep, JSHashEntry *he); | |
8573 | ||
8574 | ||
8575 | extern __attribute__((visibility ("default"))) JSHashEntry * | |
8576 | JS_HashTableAdd(JSHashTable *ht, const void *key, void *value); | |
8577 | ||
8578 | extern __attribute__((visibility ("default"))) JSBool | |
8579 | JS_HashTableRemove(JSHashTable *ht, const void *key); | |
8580 | ||
8581 | extern __attribute__((visibility ("default"))) intN | |
8582 | JS_HashTableEnumerateEntries(JSHashTable *ht, JSHashEnumerator f, void *arg); | |
8583 | ||
8584 | extern __attribute__((visibility ("default"))) void * | |
8585 | JS_HashTableLookup(JSHashTable *ht, const void *key); | |
8586 | ||
8587 | extern __attribute__((visibility ("default"))) intN | |
8588 | JS_HashTableDump(JSHashTable *ht, JSHashEnumerator dump, FILE *fp); | |
8589 | ||
8590 | ||
8591 | extern __attribute__((visibility ("default"))) JSHashNumber | |
8592 | JS_HashString(const void *key); | |
8593 | ||
8594 | ||
8595 | extern __attribute__((visibility ("default"))) intN | |
8596 | JS_CompareValues(const void *v1, const void *v2); | |
8597 | ||
8598 | } | |
8599 | # 50 "jsatom.h" 2 | |
8600 | # 1 "jshashtable.h" 1 | |
8601 | # 46 "jshashtable.h" | |
8602 | # 1 "jstl.h" 1 | |
8603 | # 46 "jstl.h" | |
8604 | # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/new" 1 3 | |
8605 | # 37 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/new" 3 | |
8606 | ||
8607 | # 38 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/new" 3 | |
8608 | ||
8609 | # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/powerpc64-unknown-linux-gnu/bits/c++config.h" 1 3 | |
8610 | # 186 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/powerpc64-unknown-linux-gnu/bits/c++config.h" 3 | |
8611 | namespace std | |
8612 | { | |
8613 | typedef long unsigned int size_t; | |
8614 | typedef long int ptrdiff_t; | |
8615 | ||
8616 | ||
8617 | ||
8618 | ||
8619 | } | |
8620 | # 350 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/powerpc64-unknown-linux-gnu/bits/c++config.h" 3 | |
8621 | namespace std | |
8622 | { | |
8623 | inline namespace __gnu_cxx_ldbl128 { } | |
8624 | } | |
8625 | # 430 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/powerpc64-unknown-linux-gnu/bits/c++config.h" 3 | |
8626 | # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/powerpc64-unknown-linux-gnu/bits/os_defines.h" 1 3 | |
8627 | # 431 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/powerpc64-unknown-linux-gnu/bits/c++config.h" 2 3 | |
8628 | ||
8629 | ||
8630 | # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/powerpc64-unknown-linux-gnu/bits/cpu_defines.h" 1 3 | |
8631 | # 434 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/powerpc64-unknown-linux-gnu/bits/c++config.h" 2 3 | |
8632 | # 40 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/new" 2 3 | |
8633 | # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/exception" 1 3 | |
8634 | # 33 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/exception" 3 | |
8635 | ||
8636 | # 34 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/exception" 3 | |
8637 | ||
8638 | #pragma GCC visibility push(default) | |
8639 | ||
8640 | ||
8641 | # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/bits/atomic_lockfree_defines.h" 1 3 | |
8642 | # 33 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/bits/atomic_lockfree_defines.h" 3 | |
8643 | ||
8644 | # 34 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/bits/atomic_lockfree_defines.h" 3 | |
8645 | # 39 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/exception" 2 3 | |
8646 | ||
8647 | extern "C++" { | |
8648 | ||
8649 | namespace std | |
8650 | { | |
8651 | # 60 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/exception" 3 | |
8652 | class exception | |
8653 | { | |
8654 | public: | |
8655 | exception() throw() { } | |
8656 | virtual ~exception() throw(); | |
8657 | ||
8658 | ||
8659 | ||
8660 | virtual const char* what() const throw(); | |
8661 | }; | |
8662 | ||
8663 | ||
8664 | ||
8665 | class bad_exception : public exception | |
8666 | { | |
8667 | public: | |
8668 | bad_exception() throw() { } | |
8669 | ||
8670 | ||
8671 | ||
8672 | virtual ~bad_exception() throw(); | |
8673 | ||
8674 | ||
8675 | virtual const char* what() const throw(); | |
8676 | }; | |
8677 | ||
8678 | ||
8679 | typedef void (*terminate_handler) (); | |
8680 | ||
8681 | ||
8682 | typedef void (*unexpected_handler) (); | |
8683 | ||
8684 | ||
8685 | terminate_handler set_terminate(terminate_handler) throw(); | |
8686 | # 102 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/exception" 3 | |
8687 | void terminate() throw() __attribute__ ((__noreturn__)); | |
8688 | ||
8689 | ||
8690 | unexpected_handler set_unexpected(unexpected_handler) throw(); | |
8691 | # 114 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/exception" 3 | |
8692 | void unexpected() __attribute__ ((__noreturn__)); | |
8693 | # 127 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/exception" 3 | |
8694 | bool uncaught_exception() throw() __attribute__ ((__pure__)); | |
8695 | ||
8696 | ||
8697 | } | |
8698 | ||
8699 | namespace __gnu_cxx | |
8700 | { | |
8701 | ||
8702 | # 152 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/exception" 3 | |
8703 | void __verbose_terminate_handler(); | |
8704 | ||
8705 | ||
8706 | } | |
8707 | ||
8708 | } | |
8709 | ||
8710 | #pragma GCC visibility pop | |
8711 | # 41 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/new" 2 3 | |
8712 | ||
8713 | #pragma GCC visibility push(default) | |
8714 | ||
8715 | extern "C++" { | |
8716 | ||
8717 | namespace std | |
8718 | { | |
8719 | ||
8720 | ||
8721 | ||
8722 | ||
8723 | ||
8724 | ||
8725 | class bad_alloc : public exception | |
8726 | { | |
8727 | public: | |
8728 | bad_alloc() throw() { } | |
8729 | ||
8730 | ||
8731 | ||
8732 | virtual ~bad_alloc() throw(); | |
8733 | ||
8734 | ||
8735 | virtual const char* what() const throw(); | |
8736 | }; | |
8737 | # 85 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/new" 3 | |
8738 | class bad_array_length : public bad_alloc | |
8739 | { | |
8740 | public: | |
8741 | bad_array_length() throw() { }; | |
8742 | ||
8743 | ||
8744 | ||
8745 | virtual ~bad_array_length() throw(); | |
8746 | ||
8747 | ||
8748 | virtual const char* what() const throw(); | |
8749 | }; | |
8750 | ||
8751 | ||
8752 | struct nothrow_t { }; | |
8753 | ||
8754 | extern const nothrow_t nothrow; | |
8755 | ||
8756 | ||
8757 | ||
8758 | typedef void (*new_handler)(); | |
8759 | ||
8760 | ||
8761 | ||
8762 | new_handler set_new_handler(new_handler) throw(); | |
8763 | ||
8764 | ||
8765 | ||
8766 | ||
8767 | ||
8768 | } | |
8769 | # 128 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/new" 3 | |
8770 | void* operator new(std::size_t) throw(std::bad_alloc) | |
8771 | __attribute__((__externally_visible__)); | |
8772 | void* operator new[](std::size_t) throw(std::bad_alloc) | |
8773 | __attribute__((__externally_visible__)); | |
8774 | void operator delete(void*) throw() | |
8775 | __attribute__((__externally_visible__)); | |
8776 | void operator delete[](void*) throw() | |
8777 | __attribute__((__externally_visible__)); | |
8778 | void* operator new(std::size_t, const std::nothrow_t&) throw() | |
8779 | __attribute__((__externally_visible__)); | |
8780 | void* operator new[](std::size_t, const std::nothrow_t&) throw() | |
8781 | __attribute__((__externally_visible__)); | |
8782 | void operator delete(void*, const std::nothrow_t&) throw() | |
8783 | __attribute__((__externally_visible__)); | |
8784 | void operator delete[](void*, const std::nothrow_t&) throw() | |
8785 | __attribute__((__externally_visible__)); | |
8786 | ||
8787 | ||
8788 | inline void* operator new(std::size_t, void* __p) throw() | |
8789 | { return __p; } | |
8790 | inline void* operator new[](std::size_t, void* __p) throw() | |
8791 | { return __p; } | |
8792 | ||
8793 | ||
8794 | inline void operator delete (void*, void*) throw() { } | |
8795 | inline void operator delete[](void*, void*) throw() { } | |
8796 | ||
8797 | } | |
8798 | ||
8799 | #pragma GCC visibility pop | |
8800 | # 47 "jstl.h" 2 | |
8801 | # 56 "jstl.h" | |
8802 | namespace js { | |
8803 | ||
8804 | ||
8805 | namespace tl { | |
8806 | ||
8807 | ||
8808 | template <size_t i, size_t j> struct Min { | |
8809 | static const size_t result = i < j ? i : j; | |
8810 | }; | |
8811 | template <size_t i, size_t j> struct Max { | |
8812 | static const size_t result = i > j ? i : j; | |
8813 | }; | |
8814 | template <size_t i, size_t min, size_t max> struct Clamp { | |
8815 | static const size_t result = i < min ? min : (i > max ? max : i); | |
8816 | }; | |
8817 | ||
8818 | ||
8819 | template <size_t x, size_t y> struct Pow { | |
8820 | static const size_t result = x * Pow<x, y - 1>::result; | |
8821 | }; | |
8822 | template <size_t x> struct Pow<x,0> { | |
8823 | static const size_t result = 1; | |
8824 | }; | |
8825 | ||
8826 | ||
8827 | template <size_t i> struct FloorLog2 { | |
8828 | static const size_t result = 1 + FloorLog2<i / 2>::result; | |
8829 | }; | |
8830 | template <> struct FloorLog2<0> { }; | |
8831 | template <> struct FloorLog2<1> { static const size_t result = 0; }; | |
8832 | ||
8833 | ||
8834 | template <size_t i> struct CeilingLog2 { | |
8835 | static const size_t result = FloorLog2<2 * i - 1>::result; | |
8836 | }; | |
8837 | ||
8838 | ||
8839 | template <size_t i> struct RoundUpPow2 { | |
8840 | static const size_t result = 1u << CeilingLog2<i>::result; | |
8841 | }; | |
8842 | template <> struct RoundUpPow2<0> { | |
8843 | static const size_t result = 1; | |
8844 | }; | |
8845 | ||
8846 | ||
8847 | template <class T> struct BitSize { | |
8848 | static const size_t result = sizeof(T) * 8; | |
8849 | }; | |
8850 | ||
8851 | ||
8852 | template <bool> struct StaticAssert {}; | |
8853 | template <> struct StaticAssert<true> { typedef int result; }; | |
8854 | ||
8855 | ||
8856 | template <class T, class U> struct IsSameType { | |
8857 | static const bool result = false; | |
8858 | }; | |
8859 | template <class T> struct IsSameType<T,T> { | |
8860 | static const bool result = true; | |
8861 | }; | |
8862 | ||
8863 | ||
8864 | ||
8865 | ||
8866 | ||
8867 | template <size_t N> struct NBitMask { | |
8868 | typedef typename StaticAssert<N < BitSize<size_t>::result>::result _; | |
8869 | static const size_t result = (size_t(1) << N) - 1; | |
8870 | }; | |
8871 | template <> struct NBitMask<BitSize<size_t>::result> { | |
8872 | static const size_t result = size_t(-1); | |
8873 | }; | |
8874 | ||
8875 | ||
8876 | ||
8877 | ||
8878 | ||
8879 | template <size_t N> struct MulOverflowMask { | |
8880 | static const size_t result = | |
8881 | ~NBitMask<BitSize<size_t>::result - CeilingLog2<N>::result>::result; | |
8882 | }; | |
8883 | template <> struct MulOverflowMask<0> { }; | |
8884 | template <> struct MulOverflowMask<1> { static const size_t result = 0; }; | |
8885 | ||
8886 | ||
8887 | ||
8888 | ||
8889 | ||
8890 | ||
8891 | template <class T> struct UnsafeRangeSizeMask { | |
8892 | ||
8893 | ||
8894 | ||
8895 | ||
8896 | static const size_t result = MulOverflowMask<2 * sizeof(T)>::result; | |
8897 | }; | |
8898 | ||
8899 | ||
8900 | template <class T> struct StripConst { typedef T result; }; | |
8901 | template <class T> struct StripConst<const T> { typedef T result; }; | |
8902 | ||
8903 | ||
8904 | ||
8905 | ||
8906 | ||
8907 | template <class T> struct IsPodType { static const bool result = false; }; | |
8908 | template <> struct IsPodType<char> { static const bool result = true; }; | |
8909 | template <> struct IsPodType<signed char> { static const bool result = true; }; | |
8910 | template <> struct IsPodType<unsigned char> { static const bool result = true; }; | |
8911 | template <> struct IsPodType<short> { static const bool result = true; }; | |
8912 | template <> struct IsPodType<unsigned short> { static const bool result = true; }; | |
8913 | template <> struct IsPodType<int> { static const bool result = true; }; | |
8914 | template <> struct IsPodType<unsigned int> { static const bool result = true; }; | |
8915 | template <> struct IsPodType<long> { static const bool result = true; }; | |
8916 | template <> struct IsPodType<unsigned long> { static const bool result = true; }; | |
8917 | template <> struct IsPodType<float> { static const bool result = true; }; | |
8918 | template <> struct IsPodType<double> { static const bool result = true; }; | |
8919 | ||
8920 | ||
8921 | template <class T, size_t N> inline T *ArraySize(T (&)[N]) { return N; } | |
8922 | template <class T, size_t N> inline T *ArrayEnd(T (&arr)[N]) { return arr + N; } | |
8923 | ||
8924 | } | |
8925 | ||
8926 | ||
8927 | class ReentrancyGuard | |
8928 | { | |
8929 | ||
8930 | ReentrancyGuard(const ReentrancyGuard &); | |
8931 | void operator=(const ReentrancyGuard &); | |
8932 | ||
8933 | ||
8934 | ||
8935 | ||
8936 | public: | |
8937 | template <class T> | |
8938 | ||
8939 | ||
8940 | ||
8941 | ||
8942 | ReentrancyGuard(T & ) | |
8943 | ||
8944 | { | |
8945 | ||
8946 | ||
8947 | ||
8948 | ||
8949 | } | |
8950 | ~ReentrancyGuard() | |
8951 | { | |
8952 | ||
8953 | ||
8954 | ||
8955 | } | |
8956 | }; | |
8957 | ||
8958 | ||
8959 | ||
8960 | ||
8961 | ||
8962 | ||
8963 | __attribute__((always_inline)) inline size_t | |
8964 | RoundUpPow2(size_t x) | |
8965 | { | |
8966 | size_t log2 = ((x) <= 1 ? 0 : 1 + (((void) 0), ((size_t)((8 * 8) - 1 - __builtin_clzll((x) - 1))))); | |
8967 | ((void) 0); | |
8968 | size_t result = size_t(1) << log2; | |
8969 | return result; | |
8970 | } | |
8971 | ||
8972 | ||
8973 | ||
8974 | ||
8975 | ||
8976 | ||
8977 | ||
8978 | template <class T> | |
8979 | __attribute__((always_inline)) inline size_t | |
8980 | PointerRangeSize(T *begin, T *end) | |
8981 | { | |
8982 | return (size_t(end) - size_t(begin)) / sizeof(T); | |
8983 | } | |
8984 | # 252 "jstl.h" | |
8985 | class SystemAllocPolicy | |
8986 | { | |
8987 | public: | |
8988 | void *malloc(size_t bytes) { return js_malloc(bytes); } | |
8989 | void *realloc(void *p, size_t bytes) { return js_realloc(p, bytes); } | |
8990 | void free(void *p) { js_free(p); } | |
8991 | void reportAllocOverflow() const {} | |
8992 | }; | |
8993 | # 271 "jstl.h" | |
8994 | template <size_t nbytes> | |
8995 | struct AlignedStorage | |
8996 | { | |
8997 | union U { | |
8998 | char bytes[nbytes]; | |
8999 | uint64 _; | |
9000 | } u; | |
9001 | ||
9002 | const void *addr() const { return u.bytes; } | |
9003 | void *addr() { return u.bytes; } | |
9004 | }; | |
9005 | ||
9006 | template <class T> | |
9007 | struct AlignedStorage2 | |
9008 | { | |
9009 | union U { | |
9010 | char bytes[sizeof(T)]; | |
9011 | uint64 _; | |
9012 | } u; | |
9013 | ||
9014 | const T *addr() const { return (const T *)u.bytes; } | |
9015 | T *addr() { return (T *)u.bytes; } | |
9016 | }; | |
9017 | # 306 "jstl.h" | |
9018 | template <class T> | |
9019 | class LazilyConstructed | |
9020 | { | |
9021 | AlignedStorage2<T> storage; | |
9022 | bool constructed; | |
9023 | ||
9024 | T &asT() { return *storage.addr(); } | |
9025 | ||
9026 | public: | |
9027 | LazilyConstructed() { constructed = false; } | |
9028 | ~LazilyConstructed() { if (constructed) asT().~T(); } | |
9029 | ||
9030 | bool empty() const { return !constructed; } | |
9031 | ||
9032 | void construct() { | |
9033 | ((void) 0); | |
9034 | new(storage.addr()) T(); | |
9035 | constructed = true; | |
9036 | } | |
9037 | ||
9038 | template <class T1> | |
9039 | void construct(const T1 &t1) { | |
9040 | ((void) 0); | |
9041 | new(storage.addr()) T(t1); | |
9042 | constructed = true; | |
9043 | } | |
9044 | ||
9045 | template <class T1, class T2> | |
9046 | void construct(const T1 &t1, const T2 &t2) { | |
9047 | ((void) 0); | |
9048 | new(storage.addr()) T(t1, t2); | |
9049 | constructed = true; | |
9050 | } | |
9051 | ||
9052 | template <class T1, class T2, class T3> | |
9053 | void construct(const T1 &t1, const T2 &t2, const T3 &t3) { | |
9054 | ((void) 0); | |
9055 | new(storage.addr()) T(t1, t2, t3); | |
9056 | constructed = true; | |
9057 | } | |
9058 | ||
9059 | template <class T1, class T2, class T3, class T4> | |
9060 | void construct(const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4) { | |
9061 | ((void) 0); | |
9062 | new(storage.addr()) T(t1, t2, t3, t4); | |
9063 | constructed = true; | |
9064 | } | |
9065 | ||
9066 | T *addr() { | |
9067 | ((void) 0); | |
9068 | return &asT(); | |
9069 | } | |
9070 | ||
9071 | T &ref() { | |
9072 | ((void) 0); | |
9073 | return asT(); | |
9074 | } | |
9075 | ||
9076 | void destroy() { | |
9077 | ref().~T(); | |
9078 | constructed = false; | |
9079 | } | |
9080 | }; | |
9081 | ||
9082 | ||
9083 | ||
9084 | ||
9085 | ||
9086 | ||
9087 | template <class T> | |
9088 | class Conditionally { | |
9089 | LazilyConstructed<T> t; | |
9090 | ||
9091 | public: | |
9092 | Conditionally(bool b) { if (b) t.construct(); } | |
9093 | ||
9094 | template <class T1> | |
9095 | Conditionally(bool b, const T1 &t1) { if (b) t.construct(t1); } | |
9096 | ||
9097 | template <class T1, class T2> | |
9098 | Conditionally(bool b, const T1 &t1, const T2 &t2) { if (b) t.construct(t1, t2); } | |
9099 | }; | |
9100 | ||
9101 | template <class T> | |
9102 | class AlignedPtrAndFlag | |
9103 | { | |
9104 | uintptr_t bits; | |
9105 | ||
9106 | public: | |
9107 | AlignedPtrAndFlag(T *t, bool flag) { | |
9108 | ((void) 0); | |
9109 | bits = uintptr_t(t) | uintptr_t(flag); | |
9110 | } | |
9111 | ||
9112 | T *ptr() const { | |
9113 | return (T *)(bits & ~uintptr_t(1)); | |
9114 | } | |
9115 | ||
9116 | bool flag() const { | |
9117 | return (bits & 1) != 0; | |
9118 | } | |
9119 | ||
9120 | void setPtr(T *t) { | |
9121 | ((void) 0); | |
9122 | bits = uintptr_t(t) | uintptr_t(flag()); | |
9123 | } | |
9124 | ||
9125 | void setFlag() { | |
9126 | bits |= 1; | |
9127 | } | |
9128 | ||
9129 | void unsetFlag() { | |
9130 | bits &= ~uintptr_t(1); | |
9131 | } | |
9132 | ||
9133 | void set(T *t, bool flag) { | |
9134 | ((void) 0); | |
9135 | bits = uintptr_t(t) | flag; | |
9136 | } | |
9137 | }; | |
9138 | ||
9139 | template <class T> | |
9140 | static inline void | |
9141 | Reverse(T *beg, T *end) | |
9142 | { | |
9143 | while (beg != end) { | |
9144 | if (--end == beg) | |
9145 | return; | |
9146 | T tmp = *beg; | |
9147 | *beg = *end; | |
9148 | *end = tmp; | |
9149 | ++beg; | |
9150 | } | |
9151 | } | |
9152 | ||
9153 | template <class T> | |
9154 | static inline T * | |
9155 | Find(T *beg, T *end, const T &v) | |
9156 | { | |
9157 | for (T *p = beg; p != end; ++p) { | |
9158 | if (*p == v) | |
9159 | return p; | |
9160 | } | |
9161 | return end; | |
9162 | } | |
9163 | ||
9164 | template <class Container> | |
9165 | static inline typename Container::ElementType * | |
9166 | Find(Container &c, const typename Container::ElementType &v) | |
9167 | { | |
9168 | return Find(c.begin(), c.end(), v); | |
9169 | } | |
9170 | ||
9171 | template <typename InputIterT, typename CallableT> | |
9172 | void | |
9173 | ForEach(InputIterT begin, InputIterT end, CallableT f) | |
9174 | { | |
9175 | for (; begin != end; ++begin) | |
9176 | f(*begin); | |
9177 | } | |
9178 | ||
9179 | template <class T> | |
9180 | static inline T | |
9181 | Min(T t1, T t2) | |
9182 | { | |
9183 | return t1 < t2 ? t1 : t2; | |
9184 | } | |
9185 | ||
9186 | template <class T> | |
9187 | static inline T | |
9188 | Max(T t1, T t2) | |
9189 | { | |
9190 | return t1 > t2 ? t1 : t2; | |
9191 | } | |
9192 | ||
9193 | ||
9194 | template <class T> | |
9195 | static T& | |
9196 | InitConst(const T &t) | |
9197 | { | |
9198 | return const_cast<T &>(t); | |
9199 | } | |
9200 | ||
9201 | } | |
9202 | # 47 "jshashtable.h" 2 | |
9203 | ||
9204 | namespace js { | |
9205 | ||
9206 | ||
9207 | typedef uint32 HashNumber; | |
9208 | ||
9209 | namespace detail { | |
9210 | ||
9211 | ||
9212 | template <class T, class HashPolicy, class AllocPolicy> | |
9213 | class HashTable : AllocPolicy | |
9214 | { | |
9215 | typedef typename tl::StripConst<T>::result NonConstT; | |
9216 | typedef typename HashPolicy::KeyType Key; | |
9217 | typedef typename HashPolicy::Lookup Lookup; | |
9218 | ||
9219 | ||
9220 | ||
9221 | ||
9222 | ||
9223 | ||
9224 | static void assignT(NonConstT &dst, const T &src) { dst = src; } | |
9225 | ||
9226 | public: | |
9227 | class Entry { | |
9228 | HashNumber keyHash; | |
9229 | ||
9230 | public: | |
9231 | Entry() : keyHash(0), t() {} | |
9232 | void operator=(const Entry &rhs) { keyHash = rhs.keyHash; assignT(t, rhs.t); } | |
9233 | ||
9234 | NonConstT t; | |
9235 | ||
9236 | bool isFree() const { return keyHash == sFreeKey; } | |
9237 | void setFree() { keyHash = sFreeKey; assignT(t, T()); } | |
9238 | bool isRemoved() const { return keyHash == sRemovedKey; } | |
9239 | void setRemoved() { keyHash = sRemovedKey; assignT(t, T()); } | |
9240 | bool isLive() const { return isLiveHash(keyHash); } | |
9241 | void setLive(HashNumber hn) { ((void) 0); keyHash = hn; } | |
9242 | ||
9243 | void setCollision() { ((void) 0); keyHash |= sCollisionBit; } | |
9244 | void setCollision(HashNumber collisionBit) { | |
9245 | ((void) 0); keyHash |= collisionBit; | |
9246 | } | |
9247 | void unsetCollision() { ((void) 0); keyHash &= ~sCollisionBit; } | |
9248 | bool hasCollision() const { ((void) 0); return keyHash & sCollisionBit; } | |
9249 | bool matchHash(HashNumber hn) { return (keyHash & ~sCollisionBit) == hn; } | |
9250 | HashNumber getKeyHash() const { ((void) 0); return keyHash; } | |
9251 | }; | |
9252 | ||
9253 | ||
9254 | ||
9255 | ||
9256 | ||
9257 | ||
9258 | ||
9259 | class Ptr | |
9260 | { | |
9261 | friend class HashTable; | |
9262 | typedef void (Ptr::* ConvertibleToBool)(); | |
9263 | void nonNull() {} | |
9264 | ||
9265 | Entry *entry; | |
9266 | ||
9267 | protected: | |
9268 | Ptr(Entry &entry) : entry(&entry) {} | |
9269 | ||
9270 | public: | |
9271 | bool found() const { return entry->isLive(); } | |
9272 | operator ConvertibleToBool() const { return found() ? &Ptr::nonNull : 0; } | |
9273 | bool operator==(const Ptr &rhs) const { ((void) 0); return entry == rhs.entry; } | |
9274 | bool operator!=(const Ptr &rhs) const { return !(*this == rhs); } | |
9275 | ||
9276 | T &operator*() const { return entry->t; } | |
9277 | T *operator->() const { return &entry->t; } | |
9278 | }; | |
9279 | ||
9280 | ||
9281 | class AddPtr : public Ptr | |
9282 | { | |
9283 | friend class HashTable; | |
9284 | HashNumber keyHash; | |
9285 | ||
9286 | ||
9287 | ||
9288 | ||
9289 | ||
9290 | ||
9291 | AddPtr(Entry &entry, HashNumber hn) : Ptr(entry), keyHash(hn) {} | |
9292 | ||
9293 | }; | |
9294 | ||
9295 | ||
9296 | ||
9297 | ||
9298 | ||
9299 | ||
9300 | ||
9301 | class Range | |
9302 | { | |
9303 | protected: | |
9304 | friend class HashTable; | |
9305 | ||
9306 | Range(Entry *c, Entry *e) : cur(c), end(e) { | |
9307 | while (cur != end && !cur->isLive()) | |
9308 | ++cur; | |
9309 | } | |
9310 | ||
9311 | Entry *cur, *end; | |
9312 | ||
9313 | public: | |
9314 | bool empty() const { | |
9315 | return cur == end; | |
9316 | } | |
9317 | ||
9318 | T &front() const { | |
9319 | ((void) 0); | |
9320 | return cur->t; | |
9321 | } | |
9322 | ||
9323 | void popFront() { | |
9324 | ((void) 0); | |
9325 | while (++cur != end && !cur->isLive()); | |
9326 | } | |
9327 | }; | |
9328 | # 182 "jshashtable.h" | |
9329 | class Enum : public Range | |
9330 | { | |
9331 | friend class HashTable; | |
9332 | ||
9333 | HashTable &table; | |
9334 | bool removed; | |
9335 | ||
9336 | ||
9337 | Enum(const Enum &); | |
9338 | void operator=(const Enum &); | |
9339 | ||
9340 | public: | |
9341 | template<class Map> explicit | |
9342 | Enum(Map &map) : Range(map.all()), table(map.impl), removed(false) {} | |
9343 | # 206 "jshashtable.h" | |
9344 | void removeFront() { | |
9345 | table.remove(*this->cur); | |
9346 | removed = true; | |
9347 | } | |
9348 | ||
9349 | ||
9350 | ~Enum() { | |
9351 | if (removed) | |
9352 | table.checkUnderloaded(); | |
9353 | } | |
9354 | ||
9355 | ||
9356 | void endEnumeration() { | |
9357 | if (removed) { | |
9358 | table.checkUnderloaded(); | |
9359 | removed = false; | |
9360 | } | |
9361 | } | |
9362 | }; | |
9363 | ||
9364 | private: | |
9365 | uint32 hashShift; | |
9366 | uint32 tableCapacity; | |
9367 | uint32 entryCount; | |
9368 | uint32 gen; | |
9369 | uint32 removedCount; | |
9370 | Entry *table; | |
9371 | ||
9372 | void setTableSizeLog2(unsigned sizeLog2) { | |
9373 | hashShift = sHashBits - sizeLog2; | |
9374 | tableCapacity = ((JSUint32)1 << (sizeLog2)); | |
9375 | } | |
9376 | # 263 "jshashtable.h" | |
9377 | static const unsigned sMinSizeLog2 = 4; | |
9378 | static const unsigned sMinSize = 1 << sMinSizeLog2; | |
9379 | static const unsigned sSizeLimit = ((JSUint32)1 << (24)); | |
9380 | static const unsigned sHashBits = tl::BitSize<HashNumber>::result; | |
9381 | static const uint8 sMinAlphaFrac = 64; | |
9382 | static const uint8 sMaxAlphaFrac = 192; | |
9383 | static const uint8 sInvMaxAlpha = 171; | |
9384 | static const HashNumber sGoldenRatio = 0x9E3779B9U; | |
9385 | static const HashNumber sCollisionBit = 1; | |
9386 | static const HashNumber sFreeKey = 0; | |
9387 | static const HashNumber sRemovedKey = 1; | |
9388 | ||
9389 | static bool isLiveHash(HashNumber hash) | |
9390 | { | |
9391 | return hash > sRemovedKey; | |
9392 | } | |
9393 | ||
9394 | static HashNumber prepareHash(const Lookup& l) | |
9395 | { | |
9396 | HashNumber keyHash = HashPolicy::hash(l); | |
9397 | ||
9398 | ||
9399 | keyHash *= sGoldenRatio; | |
9400 | ||
9401 | ||
9402 | if (!isLiveHash(keyHash)) | |
9403 | keyHash -= (sRemovedKey + 1); | |
9404 | return keyHash & ~sCollisionBit; | |
9405 | } | |
9406 | ||
9407 | static Entry *createTable(AllocPolicy &alloc, uint32 capacity) | |
9408 | { | |
9409 | Entry *newTable = (Entry *)alloc.malloc(capacity * sizeof(Entry)); | |
9410 | if (!newTable) | |
9411 | return __null; | |
9412 | for (Entry *e = newTable, *end = e + capacity; e != end; ++e) | |
9413 | new(e) Entry(); | |
9414 | return newTable; | |
9415 | } | |
9416 | ||
9417 | static void destroyTable(AllocPolicy &alloc, Entry *oldTable, uint32 capacity) | |
9418 | { | |
9419 | for (Entry *e = oldTable, *end = e + capacity; e != end; ++e) | |
9420 | e->~Entry(); | |
9421 | alloc.free(oldTable); | |
9422 | } | |
9423 | ||
9424 | public: | |
9425 | HashTable(AllocPolicy ap) | |
9426 | : AllocPolicy(ap), | |
9427 | entryCount(0), | |
9428 | gen(0), | |
9429 | removedCount(0), | |
9430 | table(__null) | |
9431 | ||
9432 | ||
9433 | ||
9434 | ||
9435 | {} | |
9436 | ||
9437 | bool init(uint32 length) | |
9438 | { | |
9439 | ||
9440 | ((void) 0); | |
9441 | ||
9442 | ||
9443 | ||
9444 | ||
9445 | ||
9446 | ((void) 0); | |
9447 | uint32 capacity = (length * sInvMaxAlpha) >> 7; | |
9448 | ||
9449 | if (capacity < sMinSize) | |
9450 | capacity = sMinSize; | |
9451 | ||
9452 | ||
9453 | uint32 roundUp = sMinSize, roundUpLog2 = sMinSizeLog2; | |
9454 | while (roundUp < capacity) { | |
9455 | roundUp <<= 1; | |
9456 | ++roundUpLog2; | |
9457 | } | |
9458 | ||
9459 | capacity = roundUp; | |
9460 | if (capacity >= sSizeLimit) { | |
9461 | this->reportAllocOverflow(); | |
9462 | return false; | |
9463 | } | |
9464 | ||
9465 | table = createTable(*this, capacity); | |
9466 | if (!table) | |
9467 | return false; | |
9468 | ||
9469 | setTableSizeLog2(roundUpLog2); | |
9470 | ; | |
9471 | return true; | |
9472 | } | |
9473 | ||
9474 | bool initialized() const | |
9475 | { | |
9476 | return !!table; | |
9477 | } | |
9478 | ||
9479 | ~HashTable() | |
9480 | { | |
9481 | if (table) | |
9482 | destroyTable(*this, table, tableCapacity); | |
9483 | } | |
9484 | ||
9485 | private: | |
9486 | static HashNumber hash1(HashNumber hash0, uint32 shift) { | |
9487 | return hash0 >> shift; | |
9488 | } | |
9489 | ||
9490 | static HashNumber hash2(HashNumber hash0, uint32 log2, uint32 shift) { | |
9491 | return ((hash0 << log2) >> shift) | 1; | |
9492 | } | |
9493 | ||
9494 | bool overloaded() { | |
9495 | return entryCount + removedCount >= ((sMaxAlphaFrac * tableCapacity) >> 8); | |
9496 | } | |
9497 | ||
9498 | bool underloaded() { | |
9499 | return tableCapacity > sMinSize && | |
9500 | entryCount <= ((sMinAlphaFrac * tableCapacity) >> 8); | |
9501 | } | |
9502 | ||
9503 | static bool match(Entry &e, const Lookup &l) { | |
9504 | return HashPolicy::match(HashPolicy::getKey(e.t), l); | |
9505 | } | |
9506 | ||
9507 | Entry &lookup(const Lookup &l, HashNumber keyHash, unsigned collisionBit) const | |
9508 | { | |
9509 | ((void) 0); | |
9510 | ((void) 0); | |
9511 | ((void) 0); | |
9512 | ((void) 0); | |
9513 | ; | |
9514 | ||
9515 | ||
9516 | HashNumber h1 = hash1(keyHash, hashShift); | |
9517 | Entry *entry = &table[h1]; | |
9518 | ||
9519 | ||
9520 | if (entry->isFree()) { | |
9521 | ; | |
9522 | return *entry; | |
9523 | } | |
9524 | ||
9525 | ||
9526 | if (entry->matchHash(keyHash) && match(*entry, l)) { | |
9527 | ; | |
9528 | return *entry; | |
9529 | } | |
9530 | ||
9531 | ||
9532 | unsigned sizeLog2 = sHashBits - hashShift; | |
9533 | HashNumber h2 = hash2(keyHash, sizeLog2, hashShift); | |
9534 | HashNumber sizeMask = (HashNumber(1) << sizeLog2) - 1; | |
9535 | ||
9536 | ||
9537 | Entry *firstRemoved = __null; | |
9538 | ||
9539 | while(true) { | |
9540 | if ((__builtin_expect((entry->isRemoved()), 0))) { | |
9541 | if (!firstRemoved) | |
9542 | firstRemoved = entry; | |
9543 | } else { | |
9544 | entry->setCollision(collisionBit); | |
9545 | } | |
9546 | ||
9547 | ; | |
9548 | h1 -= h2; | |
9549 | h1 &= sizeMask; | |
9550 | ||
9551 | entry = &table[h1]; | |
9552 | if (entry->isFree()) { | |
9553 | ; | |
9554 | return firstRemoved ? *firstRemoved : *entry; | |
9555 | } | |
9556 | ||
9557 | if (entry->matchHash(keyHash) && match(*entry, l)) { | |
9558 | ; | |
9559 | return *entry; | |
9560 | } | |
9561 | } | |
9562 | } | |
9563 | # 458 "jshashtable.h" | |
9564 | Entry &findFreeEntry(HashNumber keyHash) | |
9565 | { | |
9566 | ; | |
9567 | ((void) 0); | |
9568 | ||
9569 | ||
9570 | ||
9571 | ||
9572 | HashNumber h1 = hash1(keyHash, hashShift); | |
9573 | Entry *entry = &table[h1]; | |
9574 | ||
9575 | ||
9576 | if (entry->isFree()) { | |
9577 | ; | |
9578 | return *entry; | |
9579 | } | |
9580 | ||
9581 | ||
9582 | unsigned sizeLog2 = sHashBits - hashShift; | |
9583 | HashNumber h2 = hash2(keyHash, sizeLog2, hashShift); | |
9584 | HashNumber sizeMask = (HashNumber(1) << sizeLog2) - 1; | |
9585 | ||
9586 | while(true) { | |
9587 | ((void) 0); | |
9588 | entry->setCollision(); | |
9589 | ||
9590 | ; | |
9591 | h1 -= h2; | |
9592 | h1 &= sizeMask; | |
9593 | ||
9594 | entry = &table[h1]; | |
9595 | if (entry->isFree()) { | |
9596 | ; | |
9597 | return *entry; | |
9598 | } | |
9599 | } | |
9600 | } | |
9601 | ||
9602 | bool changeTableSize(int deltaLog2) | |
9603 | { | |
9604 | ||
9605 | Entry *oldTable = table; | |
9606 | uint32 oldCap = tableCapacity; | |
9607 | uint32 newLog2 = sHashBits - hashShift + deltaLog2; | |
9608 | uint32 newCapacity = ((JSUint32)1 << (newLog2)); | |
9609 | if (newCapacity >= sSizeLimit) { | |
9610 | this->reportAllocOverflow(); | |
9611 | return false; | |
9612 | } | |
9613 | ||
9614 | Entry *newTable = createTable(*this, newCapacity); | |
9615 | if (!newTable) | |
9616 | return false; | |
9617 | ||
9618 | ||
9619 | setTableSizeLog2(newLog2); | |
9620 | removedCount = 0; | |
9621 | gen++; | |
9622 | table = newTable; | |
9623 | ||
9624 | ||
9625 | for (Entry *src = oldTable, *end = src + oldCap; src != end; ++src) { | |
9626 | if (src->isLive()) { | |
9627 | src->unsetCollision(); | |
9628 | findFreeEntry(src->getKeyHash()) = *src; | |
9629 | } | |
9630 | } | |
9631 | ||
9632 | destroyTable(*this, oldTable, oldCap); | |
9633 | return true; | |
9634 | } | |
9635 | ||
9636 | void remove(Entry &e) | |
9637 | { | |
9638 | ; | |
9639 | if (e.hasCollision()) { | |
9640 | e.setRemoved(); | |
9641 | removedCount++; | |
9642 | } else { | |
9643 | ; | |
9644 | e.setFree(); | |
9645 | } | |
9646 | entryCount--; | |
9647 | ||
9648 | ||
9649 | ||
9650 | } | |
9651 | ||
9652 | void checkUnderloaded() | |
9653 | { | |
9654 | if (underloaded()) { | |
9655 | ; | |
9656 | (void) changeTableSize(-1); | |
9657 | } | |
9658 | } | |
9659 | ||
9660 | public: | |
9661 | void clear() | |
9662 | { | |
9663 | for (Entry *e = table, *end = table + tableCapacity; e != end; ++e) | |
9664 | *e = Entry(); | |
9665 | removedCount = 0; | |
9666 | entryCount = 0; | |
9667 | ||
9668 | ||
9669 | ||
9670 | } | |
9671 | ||
9672 | Range all() const { | |
9673 | return Range(table, table + tableCapacity); | |
9674 | } | |
9675 | ||
9676 | bool empty() const { | |
9677 | return !entryCount; | |
9678 | } | |
9679 | ||
9680 | uint32 count() const{ | |
9681 | return entryCount; | |
9682 | } | |
9683 | ||
9684 | uint32 generation() const { | |
9685 | return gen; | |
9686 | } | |
9687 | ||
9688 | Ptr lookup(const Lookup &l) const { | |
9689 | ReentrancyGuard g(*this); | |
9690 | HashNumber keyHash = prepareHash(l); | |
9691 | return Ptr(lookup(l, keyHash, 0)); | |
9692 | } | |
9693 | ||
9694 | AddPtr lookupForAdd(const Lookup &l) const { | |
9695 | ReentrancyGuard g(*this); | |
9696 | HashNumber keyHash = prepareHash(l); | |
9697 | Entry &entry = lookup(l, keyHash, sCollisionBit); | |
9698 | ||
9699 | ||
9700 | ||
9701 | return AddPtr(entry, keyHash); | |
9702 | ||
9703 | } | |
9704 | ||
9705 | bool add(AddPtr &p) | |
9706 | { | |
9707 | ReentrancyGuard g(*this); | |
9708 | ((void) 0); | |
9709 | ((void) 0); | |
9710 | ((void) 0); | |
9711 | ((void) 0); | |
9712 | ||
9713 | ||
9714 | ||
9715 | ||
9716 | ||
9717 | if (p.entry->isRemoved()) { | |
9718 | ; | |
9719 | removedCount--; | |
9720 | p.keyHash |= sCollisionBit; | |
9721 | } else { | |
9722 | ||
9723 | if (overloaded()) { | |
9724 | ||
9725 | int deltaLog2; | |
9726 | if (removedCount >= (tableCapacity >> 2)) { | |
9727 | ; | |
9728 | deltaLog2 = 0; | |
9729 | } else { | |
9730 | ; | |
9731 | deltaLog2 = 1; | |
9732 | } | |
9733 | ||
9734 | if (!changeTableSize(deltaLog2)) | |
9735 | return false; | |
9736 | ||
9737 | ||
9738 | p.entry = &findFreeEntry(p.keyHash); | |
9739 | } | |
9740 | } | |
9741 | ||
9742 | p.entry->setLive(p.keyHash); | |
9743 | entryCount++; | |
9744 | ||
9745 | ||
9746 | ||
9747 | return true; | |
9748 | } | |
9749 | ||
9750 | ||
9751 | ||
9752 | ||
9753 | ||
9754 | ||
9755 | bool add(AddPtr &p, T** pentry) | |
9756 | { | |
9757 | if (!add(p)) | |
9758 | return false; | |
9759 | *pentry = &p.entry->t; | |
9760 | return true; | |
9761 | } | |
9762 | ||
9763 | bool add(AddPtr &p, const T &t) | |
9764 | { | |
9765 | if (!add(p)) | |
9766 | return false; | |
9767 | p.entry->t = t; | |
9768 | return true; | |
9769 | } | |
9770 | ||
9771 | bool relookupOrAdd(AddPtr& p, const Lookup &l, const T& t) | |
9772 | { | |
9773 | ||
9774 | ||
9775 | ||
9776 | { | |
9777 | ReentrancyGuard g(*this); | |
9778 | p.entry = &lookup(l, p.keyHash, sCollisionBit); | |
9779 | } | |
9780 | return p.found() || add(p, t); | |
9781 | } | |
9782 | ||
9783 | void remove(Ptr p) | |
9784 | { | |
9785 | ReentrancyGuard g(*this); | |
9786 | ((void) 0); | |
9787 | remove(*p.entry); | |
9788 | checkUnderloaded(); | |
9789 | } | |
9790 | ||
9791 | }; | |
9792 | ||
9793 | } | |
9794 | # 717 "jshashtable.h" | |
9795 | template <class Key> | |
9796 | struct DefaultHasher | |
9797 | { | |
9798 | typedef Key Lookup; | |
9799 | static HashNumber hash(const Lookup &l) { | |
9800 | ||
9801 | return l; | |
9802 | } | |
9803 | static bool match(const Key &k, const Lookup &l) { | |
9804 | ||
9805 | return k == l; | |
9806 | } | |
9807 | }; | |
9808 | ||
9809 | ||
9810 | template <class T> | |
9811 | struct DefaultHasher<T *> | |
9812 | { | |
9813 | typedef T *Lookup; | |
9814 | static HashNumber hash(T *l) { | |
9815 | ||
9816 | ||
9817 | ||
9818 | ||
9819 | return HashNumber(reinterpret_cast<size_t>(l) >> | |
9820 | tl::FloorLog2<sizeof(void *)>::result); | |
9821 | } | |
9822 | static bool match(T *k, T *l) { | |
9823 | return k == l; | |
9824 | } | |
9825 | }; | |
9826 | # 765 "jshashtable.h" | |
9827 | template <class Key, class Value, class HashPolicy, class AllocPolicy> | |
9828 | class HashMap | |
9829 | { | |
9830 | public: | |
9831 | typedef typename HashPolicy::Lookup Lookup; | |
9832 | ||
9833 | class Entry | |
9834 | { | |
9835 | template <class, class, class> friend class detail::HashTable; | |
9836 | void operator=(const Entry &rhs) { | |
9837 | const_cast<Key &>(key) = rhs.key; | |
9838 | value = rhs.value; | |
9839 | } | |
9840 | ||
9841 | public: | |
9842 | Entry() : key(), value() {} | |
9843 | Entry(const Key &k, const Value &v) : key(k), value(v) {} | |
9844 | ||
9845 | const Key key; | |
9846 | Value value; | |
9847 | }; | |
9848 | ||
9849 | private: | |
9850 | ||
9851 | struct MapHashPolicy : HashPolicy | |
9852 | { | |
9853 | typedef Key KeyType; | |
9854 | static const Key &getKey(Entry &e) { return e.key; } | |
9855 | }; | |
9856 | typedef detail::HashTable<Entry, MapHashPolicy, AllocPolicy> Impl; | |
9857 | ||
9858 | friend class Impl::Enum; | |
9859 | ||
9860 | ||
9861 | HashMap(const HashMap &); | |
9862 | HashMap &operator=(const HashMap &); | |
9863 | ||
9864 | Impl impl; | |
9865 | ||
9866 | public: | |
9867 | ||
9868 | ||
9869 | ||
9870 | ||
9871 | HashMap(AllocPolicy a = AllocPolicy()) : impl(a) {} | |
9872 | bool init(uint32 len = 0) { return impl.init(len); } | |
9873 | bool initialized() const { return impl.initialized(); } | |
9874 | # 826 "jshashtable.h" | |
9875 | typedef typename Impl::Ptr Ptr; | |
9876 | Ptr lookup(const Lookup &l) const { return impl.lookup(l); } | |
9877 | ||
9878 | ||
9879 | void remove(Ptr p) { impl.remove(p); } | |
9880 | # 867 "jshashtable.h" | |
9881 | typedef typename Impl::AddPtr AddPtr; | |
9882 | AddPtr lookupForAdd(const Lookup &l) const { | |
9883 | return impl.lookupForAdd(l); | |
9884 | } | |
9885 | ||
9886 | bool add(AddPtr &p, const Key &k, const Value &v) { | |
9887 | Entry *pentry; | |
9888 | if (!impl.add(p, &pentry)) | |
9889 | return false; | |
9890 | const_cast<Key &>(pentry->key) = k; | |
9891 | pentry->value = v; | |
9892 | return true; | |
9893 | } | |
9894 | ||
9895 | bool add(AddPtr &p, const Key &k) { | |
9896 | Entry *pentry; | |
9897 | if (!impl.add(p, &pentry)) | |
9898 | return false; | |
9899 | const_cast<Key &>(pentry->key) = k; | |
9900 | return true; | |
9901 | } | |
9902 | ||
9903 | bool relookupOrAdd(AddPtr &p, const Key &k, const Value &v) { | |
9904 | return impl.relookupOrAdd(p, k, Entry(k, v)); | |
9905 | } | |
9906 | # 903 "jshashtable.h" | |
9907 | typedef typename Impl::Range Range; | |
9908 | Range all() const { return impl.all(); } | |
9909 | size_t count() const { return impl.count(); } | |
9910 | # 920 "jshashtable.h" | |
9911 | typedef typename Impl::Enum Enum; | |
9912 | ||
9913 | ||
9914 | void clear() { impl.clear(); } | |
9915 | ||
9916 | ||
9917 | bool empty() const { return impl.empty(); } | |
9918 | ||
9919 | ||
9920 | ||
9921 | ||
9922 | ||
9923 | unsigned generation() const { return impl.generation(); } | |
9924 | ||
9925 | ||
9926 | ||
9927 | bool has(const Lookup &l) const { | |
9928 | return impl.lookup(l) != __null; | |
9929 | } | |
9930 | ||
9931 | Entry *put(const Key &k, const Value &v) { | |
9932 | AddPtr p = lookupForAdd(k); | |
9933 | if (p) { | |
9934 | p->value = v; | |
9935 | return &*p; | |
9936 | } | |
9937 | return add(p, k, v) ? &*p : __null; | |
9938 | } | |
9939 | ||
9940 | void remove(const Lookup &l) { | |
9941 | if (Ptr p = lookup(l)) | |
9942 | remove(p); | |
9943 | } | |
9944 | }; | |
9945 | # 971 "jshashtable.h" | |
9946 | template <class T, class HashPolicy, class AllocPolicy> | |
9947 | class HashSet | |
9948 | { | |
9949 | typedef typename HashPolicy::Lookup Lookup; | |
9950 | ||
9951 | ||
9952 | struct SetOps : HashPolicy { | |
9953 | typedef T KeyType; | |
9954 | static const KeyType &getKey(const T &t) { return t; } | |
9955 | }; | |
9956 | typedef detail::HashTable<const T, SetOps, AllocPolicy> Impl; | |
9957 | ||
9958 | friend class Impl::Enum; | |
9959 | ||
9960 | ||
9961 | HashSet(const HashSet &); | |
9962 | HashSet &operator=(const HashSet &); | |
9963 | ||
9964 | Impl impl; | |
9965 | ||
9966 | public: | |
9967 | ||
9968 | ||
9969 | ||
9970 | ||
9971 | HashSet(AllocPolicy a = AllocPolicy()) : impl(a) {} | |
9972 | bool init(uint32 len = 0) { return impl.init(len); } | |
9973 | bool initialized() const { return impl.initialized(); } | |
9974 | # 1011 "jshashtable.h" | |
9975 | typedef typename Impl::Ptr Ptr; | |
9976 | Ptr lookup(const Lookup &l) const { return impl.lookup(l); } | |
9977 | ||
9978 | ||
9979 | void remove(Ptr p) { impl.remove(p); } | |
9980 | # 1051 "jshashtable.h" | |
9981 | typedef typename Impl::AddPtr AddPtr; | |
9982 | AddPtr lookupForAdd(const Lookup &l) const { | |
9983 | return impl.lookupForAdd(l); | |
9984 | } | |
9985 | ||
9986 | bool add(AddPtr &p, const T &t) { | |
9987 | return impl.add(p, t); | |
9988 | } | |
9989 | ||
9990 | bool relookupOrAdd(AddPtr &p, const Lookup &l, const T &t) { | |
9991 | return impl.relookupOrAdd(p, l, t); | |
9992 | } | |
9993 | # 1074 "jshashtable.h" | |
9994 | typedef typename Impl::Range Range; | |
9995 | Range all() const { return impl.all(); } | |
9996 | size_t count() const { return impl.count(); } | |
9997 | # 1091 "jshashtable.h" | |
9998 | typedef typename Impl::Enum Enum; | |
9999 | ||
10000 | ||
10001 | void clear() { impl.clear(); } | |
10002 | ||
10003 | ||
10004 | bool empty() const { return impl.empty(); } | |
10005 | ||
10006 | ||
10007 | ||
10008 | ||
10009 | ||
10010 | unsigned generation() const { return impl.generation(); } | |
10011 | ||
10012 | ||
10013 | ||
10014 | bool has(const Lookup &l) const { | |
10015 | return impl.lookup(l) != __null; | |
10016 | } | |
10017 | ||
10018 | const T *put(const T &t) { | |
10019 | AddPtr p = lookupForAdd(t); | |
10020 | return p ? &*p : (add(p, t) ? &*p : __null); | |
10021 | } | |
10022 | ||
10023 | void remove(const Lookup &l) { | |
10024 | if (Ptr p = lookup(l)) | |
10025 | remove(p); | |
10026 | } | |
10027 | }; | |
10028 | ||
10029 | } | |
10030 | # 51 "jsatom.h" 2 | |
10031 | ||
10032 | # 1 "jsstr.h" 1 | |
10033 | # 51 "jsstr.h" | |
10034 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/ctype.h" 1 3 4 | |
10035 | # 28 "/usr/powerpc64-unknown-linux-gnu/usr/include/ctype.h" 3 4 | |
10036 | extern "C" { | |
10037 | # 46 "/usr/powerpc64-unknown-linux-gnu/usr/include/ctype.h" 3 4 | |
10038 | enum | |
10039 | { | |
10040 | _ISupper = (1 << (0)), | |
10041 | _ISlower = (1 << (1)), | |
10042 | _ISalpha = (1 << (2)), | |
10043 | _ISdigit = (1 << (3)), | |
10044 | _ISxdigit = (1 << (4)), | |
10045 | _ISspace = (1 << (5)), | |
10046 | _ISprint = (1 << (6)), | |
10047 | _ISgraph = (1 << (7)), | |
10048 | _ISblank = (1 << (8)), | |
10049 | _IScntrl = (1 << (9)), | |
10050 | _ISpunct = (1 << (10)), | |
10051 | _ISalnum = (1 << (11)) | |
10052 | }; | |
10053 | # 79 "/usr/powerpc64-unknown-linux-gnu/usr/include/ctype.h" 3 4 | |
10054 | extern const unsigned short int **__ctype_b_loc (void) | |
10055 | throw () __attribute__ ((__const__)); | |
10056 | extern const __int32_t **__ctype_tolower_loc (void) | |
10057 | throw () __attribute__ ((__const__)); | |
10058 | extern const __int32_t **__ctype_toupper_loc (void) | |
10059 | throw () __attribute__ ((__const__)); | |
10060 | # 104 "/usr/powerpc64-unknown-linux-gnu/usr/include/ctype.h" 3 4 | |
10061 | ||
10062 | ||
10063 | ||
10064 | ||
10065 | ||
10066 | ||
10067 | extern int isalnum (int) throw (); | |
10068 | extern int isalpha (int) throw (); | |
10069 | extern int iscntrl (int) throw (); | |
10070 | extern int isdigit (int) throw (); | |
10071 | extern int islower (int) throw (); | |
10072 | extern int isgraph (int) throw (); | |
10073 | extern int isprint (int) throw (); | |
10074 | extern int ispunct (int) throw (); | |
10075 | extern int isspace (int) throw (); | |
10076 | extern int isupper (int) throw (); | |
10077 | extern int isxdigit (int) throw (); | |
10078 | ||
10079 | ||
10080 | ||
10081 | extern int tolower (int __c) throw (); | |
10082 | ||
10083 | ||
10084 | extern int toupper (int __c) throw (); | |
10085 | ||
10086 | ||
10087 | ||
10088 | ||
10089 | ||
10090 | ||
10091 | ||
10092 | ||
10093 | extern int isblank (int) throw (); | |
10094 | ||
10095 | ||
10096 | ||
10097 | ||
10098 | ||
10099 | ||
10100 | extern int isctype (int __c, int __mask) throw (); | |
10101 | ||
10102 | ||
10103 | ||
10104 | ||
10105 | ||
10106 | ||
10107 | extern int isascii (int __c) throw (); | |
10108 | ||
10109 | ||
10110 | ||
10111 | extern int toascii (int __c) throw (); | |
10112 | ||
10113 | ||
10114 | ||
10115 | extern int _toupper (int) throw (); | |
10116 | extern int _tolower (int) throw (); | |
10117 | # 271 "/usr/powerpc64-unknown-linux-gnu/usr/include/ctype.h" 3 4 | |
10118 | extern int isalnum_l (int, __locale_t) throw (); | |
10119 | extern int isalpha_l (int, __locale_t) throw (); | |
10120 | extern int iscntrl_l (int, __locale_t) throw (); | |
10121 | extern int isdigit_l (int, __locale_t) throw (); | |
10122 | extern int islower_l (int, __locale_t) throw (); | |
10123 | extern int isgraph_l (int, __locale_t) throw (); | |
10124 | extern int isprint_l (int, __locale_t) throw (); | |
10125 | extern int ispunct_l (int, __locale_t) throw (); | |
10126 | extern int isspace_l (int, __locale_t) throw (); | |
10127 | extern int isupper_l (int, __locale_t) throw (); | |
10128 | extern int isxdigit_l (int, __locale_t) throw (); | |
10129 | ||
10130 | extern int isblank_l (int, __locale_t) throw (); | |
10131 | ||
10132 | ||
10133 | ||
10134 | extern int __tolower_l (int __c, __locale_t __l) throw (); | |
10135 | extern int tolower_l (int __c, __locale_t __l) throw (); | |
10136 | ||
10137 | ||
10138 | extern int __toupper_l (int __c, __locale_t __l) throw (); | |
10139 | extern int toupper_l (int __c, __locale_t __l) throw (); | |
10140 | # 347 "/usr/powerpc64-unknown-linux-gnu/usr/include/ctype.h" 3 4 | |
10141 | } | |
10142 | # 52 "jsstr.h" 2 | |
10143 | ||
10144 | ||
10145 | ||
10146 | # 1 "jslock.h" 1 | |
10147 | # 47 "jslock.h" | |
10148 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/pratom.h" 1 | |
10149 | # 14 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/pratom.h" | |
10150 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prtypes.h" 1 | |
10151 | # 26 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prtypes.h" | |
10152 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prcpucfg.h" 1 | |
10153 | # 27 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prtypes.h" 2 | |
10154 | ||
10155 | ||
10156 | # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stddef.h" 1 3 4 | |
10157 | # 30 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prtypes.h" 2 | |
10158 | # 206 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prtypes.h" | |
10159 | extern "C" { | |
10160 | # 246 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prtypes.h" | |
10161 | typedef unsigned char PRUint8; | |
10162 | # 260 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prtypes.h" | |
10163 | typedef signed char PRInt8; | |
10164 | # 285 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prtypes.h" | |
10165 | typedef unsigned short PRUint16; | |
10166 | typedef short PRInt16; | |
10167 | # 310 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prtypes.h" | |
10168 | typedef unsigned int PRUint32; | |
10169 | typedef int PRInt32; | |
10170 | # 365 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prtypes.h" | |
10171 | typedef long PRInt64; | |
10172 | typedef unsigned long PRUint64; | |
10173 | # 410 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prtypes.h" | |
10174 | typedef int PRIntn; | |
10175 | typedef unsigned int PRUintn; | |
10176 | # 421 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prtypes.h" | |
10177 | typedef double PRFloat64; | |
10178 | ||
10179 | ||
10180 | ||
10181 | ||
10182 | ||
10183 | ||
10184 | typedef size_t PRSize; | |
10185 | ||
10186 | ||
10187 | ||
10188 | ||
10189 | ||
10190 | ||
10191 | ||
10192 | typedef PRInt32 PROffset32; | |
10193 | typedef PRInt64 PROffset64; | |
10194 | ||
10195 | ||
10196 | ||
10197 | ||
10198 | ||
10199 | ||
10200 | ||
10201 | typedef ptrdiff_t PRPtrdiff; | |
10202 | # 456 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prtypes.h" | |
10203 | typedef unsigned long PRUptrdiff; | |
10204 | # 467 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prtypes.h" | |
10205 | typedef PRIntn PRBool; | |
10206 | # 477 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prtypes.h" | |
10207 | typedef PRUint8 PRPackedBool; | |
10208 | ||
10209 | ||
10210 | ||
10211 | ||
10212 | ||
10213 | typedef enum { PR_FAILURE = -1, PR_SUCCESS = 0 } PRStatus; | |
10214 | ||
10215 | ||
10216 | ||
10217 | ||
10218 | ||
10219 | ||
10220 | typedef PRUint16 PRUnichar; | |
10221 | # 509 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prtypes.h" | |
10222 | typedef long PRWord; | |
10223 | typedef unsigned long PRUword; | |
10224 | # 574 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prtypes.h" | |
10225 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/obsolete/protypes.h" 1 | |
10226 | # 575 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prtypes.h" 2 | |
10227 | # 587 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prtypes.h" | |
10228 | } | |
10229 | # 15 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/pratom.h" 2 | |
10230 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prlock.h" 1 | |
10231 | # 21 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prlock.h" | |
10232 | extern "C" { | |
10233 | # 34 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prlock.h" | |
10234 | typedef struct PRLock PRLock; | |
10235 | # 51 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prlock.h" | |
10236 | extern __attribute__((visibility("default"))) PRLock* PR_NewLock(void); | |
10237 | # 62 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prlock.h" | |
10238 | extern __attribute__((visibility("default"))) void PR_DestroyLock(PRLock *lock); | |
10239 | # 73 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prlock.h" | |
10240 | extern __attribute__((visibility("default"))) void PR_Lock(PRLock *lock); | |
10241 | # 85 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prlock.h" | |
10242 | extern __attribute__((visibility("default"))) PRStatus PR_Unlock(PRLock *lock); | |
10243 | # 105 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prlock.h" | |
10244 | extern __attribute__((visibility("default"))) void PR_AssertCurrentThreadOwnsLock(PRLock *lock); | |
10245 | ||
10246 | } | |
10247 | # 16 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/pratom.h" 2 | |
10248 | ||
10249 | extern "C" { | |
10250 | # 28 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/pratom.h" | |
10251 | extern __attribute__((visibility("default"))) PRInt32 PR_AtomicIncrement(PRInt32 *val); | |
10252 | # 39 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/pratom.h" | |
10253 | extern __attribute__((visibility("default"))) PRInt32 PR_AtomicDecrement(PRInt32 *val); | |
10254 | # 51 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/pratom.h" | |
10255 | extern __attribute__((visibility("default"))) PRInt32 PR_AtomicSet(PRInt32 *val, PRInt32 newval); | |
10256 | # 63 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/pratom.h" | |
10257 | extern __attribute__((visibility("default"))) PRInt32 PR_AtomicAdd(PRInt32 *ptr, PRInt32 val); | |
10258 | # 137 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/pratom.h" | |
10259 | typedef struct PRStackElemStr PRStackElem; | |
10260 | ||
10261 | struct PRStackElemStr { | |
10262 | PRStackElem *prstk_elem_next; | |
10263 | ||
10264 | }; | |
10265 | ||
10266 | typedef struct PRStackStr PRStack; | |
10267 | # 155 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/pratom.h" | |
10268 | extern __attribute__((visibility("default"))) PRStack * PR_CreateStack(const char *stack_name); | |
10269 | # 167 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/pratom.h" | |
10270 | extern __attribute__((visibility("default"))) void PR_StackPush(PRStack *stack, PRStackElem *stack_elem); | |
10271 | # 180 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/pratom.h" | |
10272 | extern __attribute__((visibility("default"))) PRStackElem * PR_StackPop(PRStack *stack); | |
10273 | # 194 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/pratom.h" | |
10274 | extern __attribute__((visibility("default"))) PRStatus PR_DestroyStack(PRStack *stack); | |
10275 | ||
10276 | } | |
10277 | # 48 "jslock.h" 2 | |
10278 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prlock.h" 1 | |
10279 | # 49 "jslock.h" 2 | |
10280 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prcvar.h" 1 | |
10281 | # 10 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prcvar.h" | |
10282 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prinrval.h" 1 | |
10283 | # 23 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prinrval.h" | |
10284 | extern "C" { | |
10285 | ||
10286 | ||
10287 | ||
10288 | ||
10289 | ||
10290 | typedef PRUint32 PRIntervalTime; | |
10291 | # 79 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prinrval.h" | |
10292 | extern __attribute__((visibility("default"))) PRIntervalTime PR_IntervalNow(void); | |
10293 | # 97 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prinrval.h" | |
10294 | extern __attribute__((visibility("default"))) PRUint32 PR_TicksPerSecond(void); | |
10295 | # 116 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prinrval.h" | |
10296 | extern __attribute__((visibility("default"))) PRIntervalTime PR_SecondsToInterval(PRUint32 seconds); | |
10297 | extern __attribute__((visibility("default"))) PRIntervalTime PR_MillisecondsToInterval(PRUint32 milli); | |
10298 | extern __attribute__((visibility("default"))) PRIntervalTime PR_MicrosecondsToInterval(PRUint32 micro); | |
10299 | # 137 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prinrval.h" | |
10300 | extern __attribute__((visibility("default"))) PRUint32 PR_IntervalToSeconds(PRIntervalTime ticks); | |
10301 | extern __attribute__((visibility("default"))) PRUint32 PR_IntervalToMilliseconds(PRIntervalTime ticks); | |
10302 | extern __attribute__((visibility("default"))) PRUint32 PR_IntervalToMicroseconds(PRIntervalTime ticks); | |
10303 | ||
10304 | } | |
10305 | # 11 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prcvar.h" 2 | |
10306 | ||
10307 | extern "C" { | |
10308 | ||
10309 | typedef struct PRCondVar PRCondVar; | |
10310 | # 27 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prcvar.h" | |
10311 | extern __attribute__((visibility("default"))) PRCondVar* PR_NewCondVar(PRLock *lock); | |
10312 | ||
10313 | ||
10314 | ||
10315 | ||
10316 | ||
10317 | ||
10318 | ||
10319 | extern __attribute__((visibility("default"))) void PR_DestroyCondVar(PRCondVar *cvar); | |
10320 | # 65 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prcvar.h" | |
10321 | extern __attribute__((visibility("default"))) PRStatus PR_WaitCondVar(PRCondVar *cvar, PRIntervalTime timeout); | |
10322 | # 80 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prcvar.h" | |
10323 | extern __attribute__((visibility("default"))) PRStatus PR_NotifyCondVar(PRCondVar *cvar); | |
10324 | # 90 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prcvar.h" | |
10325 | extern __attribute__((visibility("default"))) PRStatus PR_NotifyAllCondVar(PRCondVar *cvar); | |
10326 | ||
10327 | } | |
10328 | # 50 "jslock.h" 2 | |
10329 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prthread.h" 1 | |
10330 | # 49 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prthread.h" | |
10331 | extern "C" { | |
10332 | ||
10333 | typedef struct PRThread PRThread; | |
10334 | typedef struct PRThreadStack PRThreadStack; | |
10335 | ||
10336 | typedef enum PRThreadType { | |
10337 | PR_USER_THREAD, | |
10338 | PR_SYSTEM_THREAD | |
10339 | } PRThreadType; | |
10340 | ||
10341 | typedef enum PRThreadScope { | |
10342 | PR_LOCAL_THREAD, | |
10343 | PR_GLOBAL_THREAD, | |
10344 | PR_GLOBAL_BOUND_THREAD | |
10345 | } PRThreadScope; | |
10346 | ||
10347 | typedef enum PRThreadState { | |
10348 | PR_JOINABLE_THREAD, | |
10349 | PR_UNJOINABLE_THREAD | |
10350 | } PRThreadState; | |
10351 | ||
10352 | typedef enum PRThreadPriority | |
10353 | { | |
10354 | PR_PRIORITY_FIRST = 0, | |
10355 | PR_PRIORITY_LOW = 0, | |
10356 | PR_PRIORITY_NORMAL = 1, | |
10357 | PR_PRIORITY_HIGH = 2, | |
10358 | PR_PRIORITY_URGENT = 3, | |
10359 | PR_PRIORITY_LAST = 3 | |
10360 | } PRThreadPriority; | |
10361 | # 105 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prthread.h" | |
10362 | extern __attribute__((visibility("default"))) PRThread* PR_CreateThread(PRThreadType type, | |
10363 | void ( *start)(void *arg), | |
10364 | void *arg, | |
10365 | PRThreadPriority priority, | |
10366 | PRThreadScope scope, | |
10367 | PRThreadState state, | |
10368 | PRUint32 stackSize); | |
10369 | # 126 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prthread.h" | |
10370 | extern __attribute__((visibility("default"))) PRStatus PR_JoinThread(PRThread *thread); | |
10371 | ||
10372 | ||
10373 | ||
10374 | ||
10375 | ||
10376 | extern __attribute__((visibility("default"))) PRThread* PR_GetCurrentThread(void); | |
10377 | ||
10378 | ||
10379 | ||
10380 | ||
10381 | ||
10382 | ||
10383 | ||
10384 | extern __attribute__((visibility("default"))) PRThreadPriority PR_GetThreadPriority(const PRThread *thread); | |
10385 | # 152 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prthread.h" | |
10386 | extern __attribute__((visibility("default"))) void PR_SetThreadPriority(PRThread *thread, PRThreadPriority priority); | |
10387 | ||
10388 | ||
10389 | ||
10390 | ||
10391 | ||
10392 | extern __attribute__((visibility("default"))) PRStatus PR_SetCurrentThreadName(const char *name); | |
10393 | ||
10394 | ||
10395 | ||
10396 | ||
10397 | extern __attribute__((visibility("default"))) const char * PR_GetThreadName(const PRThread *thread); | |
10398 | # 189 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prthread.h" | |
10399 | typedef void ( *PRThreadPrivateDTOR)(void *priv); | |
10400 | ||
10401 | extern __attribute__((visibility("default"))) PRStatus PR_NewThreadPrivateIndex( | |
10402 | PRUintn *newIndex, PRThreadPrivateDTOR destructor); | |
10403 | # 205 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prthread.h" | |
10404 | extern __attribute__((visibility("default"))) PRStatus PR_SetThreadPrivate(PRUintn tpdIndex, void *priv); | |
10405 | # 216 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prthread.h" | |
10406 | extern __attribute__((visibility("default"))) void* PR_GetThreadPrivate(PRUintn tpdIndex); | |
10407 | # 228 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prthread.h" | |
10408 | extern __attribute__((visibility("default"))) PRStatus PR_Interrupt(PRThread *thread); | |
10409 | ||
10410 | ||
10411 | ||
10412 | ||
10413 | ||
10414 | extern __attribute__((visibility("default"))) void PR_ClearInterrupt(void); | |
10415 | ||
10416 | ||
10417 | ||
10418 | ||
10419 | extern __attribute__((visibility("default"))) void PR_BlockInterrupt(void); | |
10420 | ||
10421 | ||
10422 | ||
10423 | ||
10424 | extern __attribute__((visibility("default"))) void PR_UnblockInterrupt(void); | |
10425 | # 253 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prthread.h" | |
10426 | extern __attribute__((visibility("default"))) PRStatus PR_Sleep(PRIntervalTime ticks); | |
10427 | ||
10428 | ||
10429 | ||
10430 | ||
10431 | extern __attribute__((visibility("default"))) PRThreadScope PR_GetThreadScope(const PRThread *thread); | |
10432 | ||
10433 | ||
10434 | ||
10435 | ||
10436 | extern __attribute__((visibility("default"))) PRThreadType PR_GetThreadType(const PRThread *thread); | |
10437 | ||
10438 | ||
10439 | ||
10440 | ||
10441 | extern __attribute__((visibility("default"))) PRThreadState PR_GetThreadState(const PRThread *thread); | |
10442 | ||
10443 | } | |
10444 | # 51 "jslock.h" 2 | |
10445 | ||
10446 | ||
10447 | extern "C" { | |
10448 | # 79 "jslock.h" | |
10449 | typedef struct JSFatLock JSFatLock; | |
10450 | ||
10451 | typedef struct JSThinLock { | |
10452 | jsword owner; | |
10453 | JSFatLock *fat; | |
10454 | } JSThinLock; | |
10455 | ||
10456 | ||
10457 | ||
10458 | ||
10459 | typedef PRLock JSLock; | |
10460 | # 119 "jslock.h" | |
10461 | extern void js_Lock(JSContext *cx, JSThinLock *tl); | |
10462 | extern void js_Unlock(JSContext *cx, JSThinLock *tl); | |
10463 | extern void js_LockRuntime(JSRuntime *rt); | |
10464 | extern void js_UnlockRuntime(JSRuntime *rt); | |
10465 | extern int js_SetupLocks(int,int); | |
10466 | extern void js_CleanupLocks(); | |
10467 | extern void js_InitLock(JSThinLock *); | |
10468 | extern void js_FinishLock(JSThinLock *); | |
10469 | # 192 "jslock.h" | |
10470 | extern JSBool | |
10471 | js_CompareAndSwap(volatile jsword *w, jsword ov, jsword nv); | |
10472 | ||
10473 | ||
10474 | extern void | |
10475 | js_AtomicSetMask(volatile jsword *w, jsword mask); | |
10476 | ||
10477 | ||
10478 | ||
10479 | ||
10480 | ||
10481 | extern void | |
10482 | js_AtomicClearMask(volatile jsword *w, jsword mask); | |
10483 | # 222 "jslock.h" | |
10484 | } | |
10485 | ||
10486 | ||
10487 | namespace js { | |
10488 | ||
10489 | class AutoLock { | |
10490 | private: | |
10491 | JSLock *lock; | |
10492 | ||
10493 | public: | |
10494 | AutoLock(JSLock *lock) : lock(lock) { PR_Lock(lock); } | |
10495 | ~AutoLock() { PR_Unlock(lock); } | |
10496 | }; | |
10497 | ||
10498 | } | |
10499 | # 56 "jsstr.h" 2 | |
10500 | # 1 "jsobj.h" 1 | |
10501 | # 64 "jsobj.h" | |
10502 | # 1 "jsvalue.h" 1 | |
10503 | # 100 "jsvalue.h" | |
10504 | static inline int | |
10505 | JSDOUBLE_IS_NEGZERO(jsdouble d) | |
10506 | { | |
10507 | ||
10508 | ||
10509 | ||
10510 | ||
10511 | ||
10512 | return (d == 0 && (sizeof (d) == sizeof (float) ? __signbitf (d) : sizeof (d) == sizeof (double) ? __signbit (d) : __signbitl (d))); | |
10513 | ||
10514 | } | |
10515 | ||
10516 | static inline | |
10517 | ||
10518 | # 112 "jsvalue.h" | |
10519 | bool | |
10520 | JSDOUBLE_IS_INT32(jsdouble d, int32_t* pi) | |
10521 | { | |
10522 | if (JSDOUBLE_IS_NEGZERO(d)) | |
10523 | return false; | |
10524 | return d == (*pi = int32_t(d)); | |
10525 | } | |
10526 | # 225 "jsvalue.h" | |
10527 | static __attribute__((always_inline)) inline JSBool | |
10528 | JSVAL_IS_SPECIFIC_INT32_IMPL(jsval_layout l, int32 i32) | |
10529 | { | |
10530 | return l.asBits == (((uint64)(uint32)i32) | JSVAL_SHIFTED_TAG_INT32); | |
10531 | } | |
10532 | ||
10533 | static __attribute__((always_inline)) inline JSBool | |
10534 | JSVAL_IS_SPECIFIC_BOOLEAN(jsval_layout l, JSBool b) | |
10535 | { | |
10536 | return l.asBits == (((uint64)(uint32)b) | JSVAL_SHIFTED_TAG_BOOLEAN); | |
10537 | } | |
10538 | ||
10539 | static __attribute__((always_inline)) inline jsval_layout | |
10540 | MAGIC_TO_JSVAL_IMPL(JSWhyMagic why) | |
10541 | { | |
10542 | jsval_layout l; | |
10543 | l.asBits = ((uint64)(uint32)why) | JSVAL_SHIFTED_TAG_MAGIC; | |
10544 | return l; | |
10545 | } | |
10546 | ||
10547 | static __attribute__((always_inline)) inline jsval_layout | |
10548 | MAGIC_TO_JSVAL_IMPL(JSObject *obj) | |
10549 | { | |
10550 | jsval_layout l; | |
10551 | l.asBits = ((uint64)obj) | JSVAL_SHIFTED_TAG_MAGIC; | |
10552 | return l; | |
10553 | } | |
10554 | ||
10555 | static __attribute__((always_inline)) inline JSBool | |
10556 | JSVAL_SAME_TYPE_IMPL(jsval_layout lhs, jsval_layout rhs) | |
10557 | { | |
10558 | uint64 lbits = lhs.asBits, rbits = rhs.asBits; | |
10559 | return (lbits <= JSVAL_TAG_MAX_DOUBLE && rbits <= JSVAL_TAG_MAX_DOUBLE) || | |
10560 | (((lbits ^ rbits) & 0xFFFF800000000000LL) == 0); | |
10561 | } | |
10562 | ||
10563 | static __attribute__((always_inline)) inline jsval_layout | |
10564 | PRIVATE_UINT32_TO_JSVAL_IMPL(uint32 ui) | |
10565 | { | |
10566 | jsval_layout l; | |
10567 | l.asBits = (uint64)ui; | |
10568 | ((void) 0); | |
10569 | return l; | |
10570 | } | |
10571 | ||
10572 | static __attribute__((always_inline)) inline uint32 | |
10573 | JSVAL_TO_PRIVATE_UINT32_IMPL(jsval_layout l) | |
10574 | { | |
10575 | ((void) 0); | |
10576 | return (uint32)l.asBits; | |
10577 | } | |
10578 | ||
10579 | static __attribute__((always_inline)) inline JSValueType | |
10580 | JSVAL_EXTRACT_NON_DOUBLE_TYPE_IMPL(jsval_layout l) | |
10581 | { | |
10582 | uint64 type = (l.asBits >> 47) & 0xF; | |
10583 | ((void) 0); | |
10584 | return (JSValueType)type; | |
10585 | } | |
10586 | ||
10587 | static __attribute__((always_inline)) inline JSValueTag | |
10588 | JSVAL_EXTRACT_NON_DOUBLE_TAG_IMPL(jsval_layout l) | |
10589 | { | |
10590 | uint64 tag = l.asBits >> 47; | |
10591 | ((void) 0); | |
10592 | return (JSValueTag)tag; | |
10593 | } | |
10594 | ||
10595 | ||
10596 | typedef int js_static_assert3[(__builtin_offsetof (jsval_layout, s.payload) == 0) ? 1 : -1]; | |
10597 | typedef int js_static_assert4[((JSVAL_TYPE_NONFUNOBJ & 0xF) == JSVAL_TYPE_OBJECT) ? 1 : -1]; | |
10598 | typedef int js_static_assert5[((JSVAL_TYPE_FUNOBJ & 0xF) == JSVAL_TYPE_OBJECT) ? 1 : -1]; | |
10599 | ||
10600 | ||
10601 | static __attribute__((always_inline)) inline jsval_layout | |
10602 | BOX_NON_DOUBLE_JSVAL(JSValueType type, uint64 *slot) | |
10603 | { | |
10604 | ||
10605 | jsval_layout l; | |
10606 | ((void) 0); | |
10607 | uint32 isI32 = (uint32)(type < JSVAL_TYPE_MAGIC); | |
10608 | uint32 shift = isI32 * 32; | |
10609 | uint64 mask = ((uint64)-1) >> shift; | |
10610 | uint64 payload = *slot & mask; | |
10611 | ((void) 0) | |
10612 | ||
10613 | ||
10614 | ||
10615 | ; | |
10616 | l.asBits = payload | (((uint64)((JSValueTag)(JSVAL_TAG_MAX_DOUBLE | (type & 0xF)))) << 47); | |
10617 | return l; | |
10618 | } | |
10619 | ||
10620 | static __attribute__((always_inline)) inline void | |
10621 | UNBOX_NON_DOUBLE_JSVAL(jsval_layout l, uint64 *out) | |
10622 | { | |
10623 | ((void) 0); | |
10624 | *out = (l.asBits & 0x00007FFFFFFFFFFFLL); | |
10625 | } | |
10626 | ||
10627 | ||
10628 | ||
10629 | ||
10630 | ||
10631 | namespace js { | |
10632 | ||
10633 | class Value | |
10634 | { | |
10635 | public: | |
10636 | ||
10637 | ||
10638 | ||
10639 | ||
10640 | ||
10641 | ||
10642 | ||
10643 | __attribute__((always_inline)) inline | |
10644 | void setNull() { | |
10645 | data.asBits = (((((uint64)(uint32)(JSVAL_TAG_NULL)) << 47) | (0))); | |
10646 | } | |
10647 | ||
10648 | __attribute__((always_inline)) inline | |
10649 | void setUndefined() { | |
10650 | data.asBits = (((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0))); | |
10651 | } | |
10652 | ||
10653 | __attribute__((always_inline)) inline | |
10654 | void setInt32(int32 i) { | |
10655 | data = INT32_TO_JSVAL_IMPL(i); | |
10656 | } | |
10657 | ||
10658 | __attribute__((always_inline)) inline | |
10659 | int32 &getInt32Ref() { | |
10660 | ((void) 0); | |
10661 | return data.s.payload.i32; | |
10662 | } | |
10663 | ||
10664 | __attribute__((always_inline)) inline | |
10665 | void setDouble(double d) { | |
10666 | data = DOUBLE_TO_JSVAL_IMPL(d); | |
10667 | } | |
10668 | ||
10669 | __attribute__((always_inline)) inline | |
10670 | double &getDoubleRef() { | |
10671 | ((void) 0); | |
10672 | return data.asDouble; | |
10673 | } | |
10674 | ||
10675 | __attribute__((always_inline)) inline | |
10676 | void setString(JSString *str) { | |
10677 | data = STRING_TO_JSVAL_IMPL(str); | |
10678 | } | |
10679 | ||
10680 | __attribute__((always_inline)) inline | |
10681 | void setObject(JSObject &obj) { | |
10682 | data = OBJECT_TO_JSVAL_IMPL(&obj); | |
10683 | } | |
10684 | ||
10685 | __attribute__((always_inline)) inline | |
10686 | void setBoolean(bool b) { | |
10687 | data = BOOLEAN_TO_JSVAL_IMPL(b); | |
10688 | } | |
10689 | ||
10690 | __attribute__((always_inline)) inline | |
10691 | void setMagic(JSWhyMagic why) { | |
10692 | data = MAGIC_TO_JSVAL_IMPL(why); | |
10693 | } | |
10694 | ||
10695 | __attribute__((always_inline)) inline | |
10696 | void setMagicWithObjectOrNullPayload(JSObject *obj) { | |
10697 | data = MAGIC_TO_JSVAL_IMPL(obj); | |
10698 | } | |
10699 | ||
10700 | __attribute__((always_inline)) inline | |
10701 | JSObject *getMagicObjectOrNullPayload() const { | |
10702 | return MAGIC_JSVAL_TO_OBJECT_OR_NULL_IMPL(data); | |
10703 | } | |
10704 | ||
10705 | __attribute__((always_inline)) inline | |
10706 | void setNumber(uint32 ui) { | |
10707 | if (ui > ((jsint)0x7fffffff)) | |
10708 | setDouble((double)ui); | |
10709 | else | |
10710 | setInt32((int32)ui); | |
10711 | } | |
10712 | ||
10713 | __attribute__((always_inline)) inline | |
10714 | void setNumber(double d) { | |
10715 | int32_t i; | |
10716 | if (JSDOUBLE_IS_INT32(d, &i)) | |
10717 | setInt32(i); | |
10718 | else | |
10719 | setDouble(d); | |
10720 | } | |
10721 | ||
10722 | __attribute__((always_inline)) inline | |
10723 | void setObjectOrNull(JSObject *arg) { | |
10724 | if (arg) | |
10725 | setObject(*arg); | |
10726 | else | |
10727 | setNull(); | |
10728 | } | |
10729 | ||
10730 | __attribute__((always_inline)) inline | |
10731 | void setObjectOrUndefined(JSObject *arg) { | |
10732 | if (arg) | |
10733 | setObject(*arg); | |
10734 | else | |
10735 | setUndefined(); | |
10736 | } | |
10737 | ||
10738 | __attribute__((always_inline)) inline | |
10739 | void swap(Value &rhs) { | |
10740 | uint64 tmp = rhs.data.asBits; | |
10741 | rhs.data.asBits = data.asBits; | |
10742 | data.asBits = tmp; | |
10743 | } | |
10744 | ||
10745 | ||
10746 | ||
10747 | __attribute__((always_inline)) inline | |
10748 | bool isUndefined() const { | |
10749 | return JSVAL_IS_UNDEFINED_IMPL(data); | |
10750 | } | |
10751 | ||
10752 | __attribute__((always_inline)) inline | |
10753 | bool isNull() const { | |
10754 | return JSVAL_IS_NULL_IMPL(data); | |
10755 | } | |
10756 | ||
10757 | __attribute__((always_inline)) inline | |
10758 | bool isNullOrUndefined() const { | |
10759 | return isNull() || isUndefined(); | |
10760 | } | |
10761 | ||
10762 | __attribute__((always_inline)) inline | |
10763 | bool isInt32() const { | |
10764 | return JSVAL_IS_INT32_IMPL(data); | |
10765 | } | |
10766 | ||
10767 | __attribute__((always_inline)) inline | |
10768 | bool isInt32(int32 i32) const { | |
10769 | return JSVAL_IS_SPECIFIC_INT32_IMPL(data, i32); | |
10770 | } | |
10771 | ||
10772 | __attribute__((always_inline)) inline | |
10773 | bool isDouble() const { | |
10774 | return JSVAL_IS_DOUBLE_IMPL(data); | |
10775 | } | |
10776 | ||
10777 | __attribute__((always_inline)) inline | |
10778 | bool isNumber() const { | |
10779 | return JSVAL_IS_NUMBER_IMPL(data); | |
10780 | } | |
10781 | ||
10782 | __attribute__((always_inline)) inline | |
10783 | bool isString() const { | |
10784 | return JSVAL_IS_STRING_IMPL(data); | |
10785 | } | |
10786 | ||
10787 | __attribute__((always_inline)) inline | |
10788 | bool isObject() const { | |
10789 | return JSVAL_IS_OBJECT_IMPL(data); | |
10790 | } | |
10791 | ||
10792 | __attribute__((always_inline)) inline | |
10793 | bool isPrimitive() const { | |
10794 | return JSVAL_IS_PRIMITIVE_IMPL(data); | |
10795 | } | |
10796 | ||
10797 | __attribute__((always_inline)) inline | |
10798 | bool isObjectOrNull() const { | |
10799 | return JSVAL_IS_OBJECT_OR_NULL_IMPL(data); | |
10800 | } | |
10801 | ||
10802 | __attribute__((always_inline)) inline | |
10803 | bool isGCThing() const { | |
10804 | return JSVAL_IS_GCTHING_IMPL(data); | |
10805 | } | |
10806 | ||
10807 | __attribute__((always_inline)) inline | |
10808 | bool isBoolean() const { | |
10809 | return JSVAL_IS_BOOLEAN_IMPL(data); | |
10810 | } | |
10811 | ||
10812 | __attribute__((always_inline)) inline | |
10813 | bool isTrue() const { | |
10814 | return JSVAL_IS_SPECIFIC_BOOLEAN(data, true); | |
10815 | } | |
10816 | ||
10817 | __attribute__((always_inline)) inline | |
10818 | bool isFalse() const { | |
10819 | return JSVAL_IS_SPECIFIC_BOOLEAN(data, false); | |
10820 | } | |
10821 | ||
10822 | __attribute__((always_inline)) inline | |
10823 | bool isMagic() const { | |
10824 | return JSVAL_IS_MAGIC_IMPL(data); | |
10825 | } | |
10826 | ||
10827 | __attribute__((always_inline)) inline | |
10828 | bool isMagic(JSWhyMagic why) const { | |
10829 | ((void) 0); | |
10830 | return JSVAL_IS_MAGIC_IMPL(data); | |
10831 | } | |
10832 | ||
10833 | ||
10834 | __attribute__((always_inline)) inline | |
10835 | bool hasPtrPayload() const { | |
10836 | return data.asBits >= JSVAL_SHIFTED_TAG_MAGIC; | |
10837 | } | |
10838 | ||
10839 | ||
10840 | __attribute__((always_inline)) inline | |
10841 | bool isMarkable() const { | |
10842 | return JSVAL_IS_TRACEABLE_IMPL(data); | |
10843 | } | |
10844 | ||
10845 | __attribute__((always_inline)) inline | |
10846 | int32 gcKind() const { | |
10847 | ((void) 0); | |
10848 | return JSVAL_TRACE_KIND_IMPL(data); | |
10849 | } | |
10850 | # 559 "jsvalue.h" | |
10851 | __attribute__((always_inline)) inline | |
10852 | bool operator==(const Value &rhs) const { | |
10853 | return data.asBits == rhs.data.asBits; | |
10854 | } | |
10855 | ||
10856 | __attribute__((always_inline)) inline | |
10857 | bool operator!=(const Value &rhs) const { | |
10858 | return data.asBits != rhs.data.asBits; | |
10859 | } | |
10860 | ||
10861 | ||
10862 | ||
10863 | ||
10864 | friend bool SameType(const Value &lhs, const Value &rhs); | |
10865 | ||
10866 | ||
10867 | ||
10868 | __attribute__((always_inline)) inline | |
10869 | int32 toInt32() const { | |
10870 | ((void) 0); | |
10871 | return JSVAL_TO_INT32_IMPL(data); | |
10872 | } | |
10873 | ||
10874 | __attribute__((always_inline)) inline | |
10875 | double toDouble() const { | |
10876 | ((void) 0); | |
10877 | return data.asDouble; | |
10878 | } | |
10879 | ||
10880 | __attribute__((always_inline)) inline | |
10881 | double toNumber() const { | |
10882 | ((void) 0); | |
10883 | return isDouble() ? toDouble() : double(toInt32()); | |
10884 | } | |
10885 | ||
10886 | __attribute__((always_inline)) inline | |
10887 | JSString *toString() const { | |
10888 | ((void) 0); | |
10889 | return JSVAL_TO_STRING_IMPL(data); | |
10890 | } | |
10891 | ||
10892 | __attribute__((always_inline)) inline | |
10893 | JSObject &toObject() const { | |
10894 | ((void) 0); | |
10895 | return *JSVAL_TO_OBJECT_IMPL(data); | |
10896 | } | |
10897 | ||
10898 | __attribute__((always_inline)) inline | |
10899 | JSObject *toObjectOrNull() const { | |
10900 | ((void) 0); | |
10901 | return JSVAL_TO_OBJECT_IMPL(data); | |
10902 | } | |
10903 | ||
10904 | __attribute__((always_inline)) inline | |
10905 | void *toGCThing() const { | |
10906 | ((void) 0); | |
10907 | return JSVAL_TO_GCTHING_IMPL(data); | |
10908 | } | |
10909 | ||
10910 | __attribute__((always_inline)) inline | |
10911 | bool toBoolean() const { | |
10912 | ((void) 0); | |
10913 | return JSVAL_TO_BOOLEAN_IMPL(data); | |
10914 | } | |
10915 | ||
10916 | __attribute__((always_inline)) inline | |
10917 | uint32 payloadAsRawUint32() const { | |
10918 | ((void) 0); | |
10919 | return data.s.payload.u32; | |
10920 | } | |
10921 | ||
10922 | __attribute__((always_inline)) inline | |
10923 | uint64 asRawBits() const { | |
10924 | return data.asBits; | |
10925 | } | |
10926 | ||
10927 | ||
10928 | ||
10929 | ||
10930 | ||
10931 | ||
10932 | ||
10933 | __attribute__((always_inline)) inline | |
10934 | JSValueType extractNonDoubleType() const { | |
10935 | return JSVAL_EXTRACT_NON_DOUBLE_TYPE_IMPL(data); | |
10936 | } | |
10937 | ||
10938 | __attribute__((always_inline)) inline | |
10939 | JSValueTag extractNonDoubleTag() const { | |
10940 | return JSVAL_EXTRACT_NON_DOUBLE_TAG_IMPL(data); | |
10941 | } | |
10942 | ||
10943 | __attribute__((always_inline)) inline | |
10944 | void unboxNonDoubleTo(uint64 *out) const { | |
10945 | UNBOX_NON_DOUBLE_JSVAL(data, out); | |
10946 | } | |
10947 | ||
10948 | __attribute__((always_inline)) inline | |
10949 | void boxNonDoubleFrom(JSValueType type, uint64 *out) { | |
10950 | data = BOX_NON_DOUBLE_JSVAL(type, out); | |
10951 | } | |
10952 | ||
10953 | ||
10954 | ||
10955 | ||
10956 | ||
10957 | ||
10958 | __attribute__((always_inline)) inline | |
10959 | JSValueType extractNonDoubleObjectTraceType() const { | |
10960 | ((void) 0); | |
10961 | return JSVAL_EXTRACT_NON_DOUBLE_TYPE_IMPL(data); | |
10962 | } | |
10963 | ||
10964 | __attribute__((always_inline)) inline | |
10965 | JSValueTag extractNonDoubleObjectTraceTag() const { | |
10966 | ((void) 0); | |
10967 | return JSVAL_EXTRACT_NON_DOUBLE_TAG_IMPL(data); | |
10968 | } | |
10969 | # 687 "jsvalue.h" | |
10970 | __attribute__((always_inline)) inline | |
10971 | void setPrivate(void *ptr) { | |
10972 | data = PRIVATE_PTR_TO_JSVAL_IMPL(ptr); | |
10973 | } | |
10974 | ||
10975 | __attribute__((always_inline)) inline | |
10976 | void *toPrivate() const { | |
10977 | ((void) 0); | |
10978 | return JSVAL_TO_PRIVATE_PTR_IMPL(data); | |
10979 | } | |
10980 | ||
10981 | __attribute__((always_inline)) inline | |
10982 | void setPrivateUint32(uint32 ui) { | |
10983 | data = PRIVATE_UINT32_TO_JSVAL_IMPL(ui); | |
10984 | } | |
10985 | ||
10986 | __attribute__((always_inline)) inline | |
10987 | uint32 toPrivateUint32() const { | |
10988 | ((void) 0); | |
10989 | return JSVAL_TO_PRIVATE_UINT32_IMPL(data); | |
10990 | } | |
10991 | ||
10992 | __attribute__((always_inline)) inline | |
10993 | uint32 &getPrivateUint32Ref() { | |
10994 | ((void) 0); | |
10995 | return data.s.payload.u32; | |
10996 | } | |
10997 | ||
10998 | ||
10999 | ||
11000 | ||
11001 | ||
11002 | ||
11003 | ||
11004 | __attribute__((always_inline)) inline | |
11005 | void setUnmarkedPtr(void *ptr) { | |
11006 | data.asPtr = ptr; | |
11007 | } | |
11008 | ||
11009 | __attribute__((always_inline)) inline | |
11010 | void *toUnmarkedPtr() const { | |
11011 | return data.asPtr; | |
11012 | } | |
11013 | ||
11014 | const jsuword *payloadWord() const { | |
11015 | return &data.s.payload.word; | |
11016 | } | |
11017 | ||
11018 | private: | |
11019 | void staticAssertions() { | |
11020 | typedef int js_static_assert6[(sizeof(JSValueType) == 1) ? 1 : -1]; | |
11021 | typedef int js_static_assert7[(sizeof(JSValueTag) == 4) ? 1 : -1]; | |
11022 | typedef int js_static_assert8[(sizeof(JSBool) == 4) ? 1 : -1]; | |
11023 | typedef int js_static_assert9[(sizeof(JSWhyMagic) <= 4) ? 1 : -1]; | |
11024 | typedef int js_static_assert10[(sizeof(jsval) == 8) ? 1 : -1]; | |
11025 | } | |
11026 | ||
11027 | jsval_layout data; | |
11028 | } __attribute__((aligned (8))); | |
11029 | ||
11030 | __attribute__((always_inline)) inline | |
11031 | ||
11032 | # 747 "jsvalue.h" | |
11033 | bool | |
11034 | SameType(const Value &lhs, const Value &rhs) | |
11035 | { | |
11036 | return JSVAL_SAME_TYPE_IMPL(lhs.data, rhs.data); | |
11037 | } | |
11038 | ||
11039 | static __attribute__((always_inline)) inline Value | |
11040 | NullValue() | |
11041 | { | |
11042 | Value v; | |
11043 | v.setNull(); | |
11044 | return v; | |
11045 | } | |
11046 | ||
11047 | static __attribute__((always_inline)) inline Value | |
11048 | UndefinedValue() | |
11049 | { | |
11050 | Value v; | |
11051 | v.setUndefined(); | |
11052 | return v; | |
11053 | } | |
11054 | ||
11055 | static __attribute__((always_inline)) inline Value | |
11056 | Int32Value(int32 i32) | |
11057 | { | |
11058 | Value v; | |
11059 | v.setInt32(i32); | |
11060 | return v; | |
11061 | } | |
11062 | ||
11063 | static __attribute__((always_inline)) inline Value | |
11064 | DoubleValue(double dbl) | |
11065 | { | |
11066 | Value v; | |
11067 | v.setDouble(dbl); | |
11068 | return v; | |
11069 | } | |
11070 | ||
11071 | static __attribute__((always_inline)) inline Value | |
11072 | StringValue(JSString *str) | |
11073 | { | |
11074 | Value v; | |
11075 | v.setString(str); | |
11076 | return v; | |
11077 | } | |
11078 | ||
11079 | static __attribute__((always_inline)) inline Value | |
11080 | BooleanValue(bool boo) | |
11081 | { | |
11082 | Value v; | |
11083 | v.setBoolean(boo); | |
11084 | return v; | |
11085 | } | |
11086 | ||
11087 | static __attribute__((always_inline)) inline Value | |
11088 | ObjectValue(JSObject &obj) | |
11089 | { | |
11090 | Value v; | |
11091 | v.setObject(obj); | |
11092 | return v; | |
11093 | } | |
11094 | ||
11095 | static __attribute__((always_inline)) inline Value | |
11096 | MagicValue(JSWhyMagic why) | |
11097 | { | |
11098 | Value v; | |
11099 | v.setMagic(why); | |
11100 | return v; | |
11101 | } | |
11102 | ||
11103 | static __attribute__((always_inline)) inline Value | |
11104 | NumberValue(double dbl) | |
11105 | { | |
11106 | Value v; | |
11107 | v.setNumber(dbl); | |
11108 | return v; | |
11109 | } | |
11110 | ||
11111 | static __attribute__((always_inline)) inline Value | |
11112 | ObjectOrNullValue(JSObject *obj) | |
11113 | { | |
11114 | Value v; | |
11115 | v.setObjectOrNull(obj); | |
11116 | return v; | |
11117 | } | |
11118 | ||
11119 | static __attribute__((always_inline)) inline Value | |
11120 | PrivateValue(void *ptr) | |
11121 | { | |
11122 | Value v; | |
11123 | v.setPrivate(ptr); | |
11124 | return v; | |
11125 | } | |
11126 | ||
11127 | static __attribute__((always_inline)) inline void | |
11128 | ClearValueRange(Value *vec, uintN len, bool useHoles) | |
11129 | { | |
11130 | if (useHoles) { | |
11131 | for (uintN i = 0; i < len; i++) | |
11132 | vec[i].setMagic(JS_ARRAY_HOLE); | |
11133 | } else { | |
11134 | for (uintN i = 0; i < len; i++) | |
11135 | vec[i].setUndefined(); | |
11136 | } | |
11137 | } | |
11138 | # 879 "jsvalue.h" | |
11139 | static inline jsval * Jsvalify(Value *v) { return (jsval *)v; } | |
11140 | static inline const jsval * Jsvalify(const Value *v) { return (const jsval *)v; } | |
11141 | static inline jsval & Jsvalify(Value &v) { return (jsval &)v; } | |
11142 | static inline const jsval & Jsvalify(const Value &v) { return (const jsval &)v; } | |
11143 | static inline Value * Valueify(jsval *v) { return (Value *)v; } | |
11144 | static inline const Value * Valueify(const jsval *v) { return (const Value *)v; } | |
11145 | static inline Value ** Valueify(jsval **v) { return (Value **)v; } | |
11146 | static inline Value & Valueify(jsval &v) { return (Value &)v; } | |
11147 | static inline const Value & Valueify(const jsval &v) { return (const Value &)v; } | |
11148 | ||
11149 | struct Class; | |
11150 | ||
11151 | typedef JSBool | |
11152 | (* Native)(JSContext *cx, uintN argc, Value *vp); | |
11153 | typedef JSBool | |
11154 | (* PropertyOp)(JSContext *cx, JSObject *obj, jsid id, Value *vp); | |
11155 | typedef JSBool | |
11156 | (* StrictPropertyOp)(JSContext *cx, JSObject *obj, jsid id, JSBool strict, Value *vp); | |
11157 | typedef JSBool | |
11158 | (* ConvertOp)(JSContext *cx, JSObject *obj, JSType type, Value *vp); | |
11159 | typedef JSBool | |
11160 | (* NewEnumerateOp)(JSContext *cx, JSObject *obj, JSIterateOp enum_op, | |
11161 | Value *statep, jsid *idp); | |
11162 | typedef JSBool | |
11163 | (* HasInstanceOp)(JSContext *cx, JSObject *obj, const Value *v, JSBool *bp); | |
11164 | typedef JSBool | |
11165 | (* CheckAccessOp)(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode, | |
11166 | Value *vp); | |
11167 | typedef JSBool | |
11168 | (* EqualityOp)(JSContext *cx, JSObject *obj, const Value *v, JSBool *bp); | |
11169 | typedef JSBool | |
11170 | (* DefinePropOp)(JSContext *cx, JSObject *obj, jsid id, const Value *value, | |
11171 | PropertyOp getter, StrictPropertyOp setter, uintN attrs); | |
11172 | typedef JSBool | |
11173 | (* PropertyIdOp)(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, Value *vp); | |
11174 | typedef JSBool | |
11175 | (* StrictPropertyIdOp)(JSContext *cx, JSObject *obj, jsid id, Value *vp, JSBool strict); | |
11176 | typedef JSBool | |
11177 | (* DeleteIdOp)(JSContext *cx, JSObject *obj, jsid id, Value *vp, JSBool strict); | |
11178 | typedef JSBool | |
11179 | (* CallOp)(JSContext *cx, uintN argc, Value *vp); | |
11180 | typedef JSBool | |
11181 | (* LookupPropOp)(JSContext *cx, JSObject *obj, jsid id, JSObject **objp, | |
11182 | JSProperty **propp); | |
11183 | typedef JSBool | |
11184 | (* AttributesOp)(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp); | |
11185 | typedef JSType | |
11186 | (* TypeOfOp)(JSContext *cx, JSObject *obj); | |
11187 | typedef void | |
11188 | (* TraceOp)(JSTracer *trc, JSObject *obj); | |
11189 | typedef JSObject * | |
11190 | (* ObjectOp)(JSContext *cx, JSObject *obj); | |
11191 | typedef void | |
11192 | (* FinalizeOp)(JSContext *cx, JSObject *obj); | |
11193 | ||
11194 | class AutoIdVector; | |
11195 | # 943 "jsvalue.h" | |
11196 | typedef JSBool | |
11197 | (* FixOp)(JSContext *cx, JSObject *obj, bool *fixed, AutoIdVector *props); | |
11198 | ||
11199 | static inline Native Valueify(JSNative f) { return (Native)f; } | |
11200 | static inline JSNative Jsvalify(Native f) { return (JSNative)f; } | |
11201 | static inline PropertyOp Valueify(JSPropertyOp f) { return (PropertyOp)f; } | |
11202 | static inline JSPropertyOp Jsvalify(PropertyOp f) { return (JSPropertyOp)f; } | |
11203 | static inline StrictPropertyOp Valueify(JSStrictPropertyOp f) { return (StrictPropertyOp)f; } | |
11204 | static inline JSStrictPropertyOp Jsvalify(StrictPropertyOp f) { return (JSStrictPropertyOp)f; } | |
11205 | static inline ConvertOp Valueify(JSConvertOp f) { return (ConvertOp)f; } | |
11206 | static inline JSConvertOp Jsvalify(ConvertOp f) { return (JSConvertOp)f; } | |
11207 | static inline NewEnumerateOp Valueify(JSNewEnumerateOp f) { return (NewEnumerateOp)f; } | |
11208 | static inline JSNewEnumerateOp Jsvalify(NewEnumerateOp f) { return (JSNewEnumerateOp)f; } | |
11209 | static inline HasInstanceOp Valueify(JSHasInstanceOp f) { return (HasInstanceOp)f; } | |
11210 | static inline JSHasInstanceOp Jsvalify(HasInstanceOp f) { return (JSHasInstanceOp)f; } | |
11211 | static inline CheckAccessOp Valueify(JSCheckAccessOp f) { return (CheckAccessOp)f; } | |
11212 | static inline JSCheckAccessOp Jsvalify(CheckAccessOp f) { return (JSCheckAccessOp)f; } | |
11213 | static inline EqualityOp Valueify(JSEqualityOp f); | |
11214 | static inline JSEqualityOp Jsvalify(EqualityOp f); | |
11215 | ||
11216 | static const PropertyOp PropertyStub = (PropertyOp)JS_PropertyStub; | |
11217 | static const StrictPropertyOp StrictPropertyStub = (StrictPropertyOp)JS_StrictPropertyStub; | |
11218 | static const JSEnumerateOp EnumerateStub = JS_EnumerateStub; | |
11219 | static const JSResolveOp ResolveStub = JS_ResolveStub; | |
11220 | static const ConvertOp ConvertStub = (ConvertOp)JS_ConvertStub; | |
11221 | static const JSFinalizeOp FinalizeStub = JS_FinalizeStub; | |
11222 | # 998 "jsvalue.h" | |
11223 | struct ClassSizeMeasurement { | |
11224 | const char *name; uint32 flags; PropertyOp addProperty; PropertyOp delProperty; PropertyOp getProperty; StrictPropertyOp setProperty; JSEnumerateOp enumerate; JSResolveOp resolve; ConvertOp convert; JSFinalizeOp finalize; JSClassInternal reserved0; CheckAccessOp checkAccess; Native call; Native construct; JSXDRObjectOp xdrObject; HasInstanceOp hasInstance; JSMarkOp mark; | |
11225 | }; | |
11226 | ||
11227 | struct ClassExtension { | |
11228 | EqualityOp equality; | |
11229 | JSObjectOp outerObject; | |
11230 | JSObjectOp innerObject; | |
11231 | JSIteratorOp iteratorObject; | |
11232 | void *unused; | |
11233 | }; | |
11234 | ||
11235 | ||
11236 | ||
11237 | struct ObjectOps { | |
11238 | js::LookupPropOp lookupProperty; | |
11239 | js::DefinePropOp defineProperty; | |
11240 | js::PropertyIdOp getProperty; | |
11241 | js::StrictPropertyIdOp setProperty; | |
11242 | js::AttributesOp getAttributes; | |
11243 | js::AttributesOp setAttributes; | |
11244 | js::DeleteIdOp deleteProperty; | |
11245 | js::NewEnumerateOp enumerate; | |
11246 | js::TypeOfOp typeOf; | |
11247 | js::TraceOp trace; | |
11248 | js::FixOp fix; | |
11249 | js::ObjectOp thisObject; | |
11250 | js::FinalizeOp clear; | |
11251 | }; | |
11252 | ||
11253 | ||
11254 | ||
11255 | struct Class { | |
11256 | const char *name; uint32 flags; PropertyOp addProperty; PropertyOp delProperty; PropertyOp getProperty; StrictPropertyOp setProperty; JSEnumerateOp enumerate; JSResolveOp resolve; ConvertOp convert; JSFinalizeOp finalize; JSClassInternal reserved0; CheckAccessOp checkAccess; Native call; Native construct; JSXDRObjectOp xdrObject; HasInstanceOp hasInstance; JSMarkOp mark; | |
11257 | ClassExtension ext; | |
11258 | ObjectOps ops; | |
11259 | uint8 pad[sizeof(JSClass) - sizeof(ClassSizeMeasurement) - | |
11260 | sizeof(ClassExtension) - sizeof(ObjectOps)]; | |
11261 | ||
11262 | ||
11263 | static const uint32 NON_NATIVE = (1<<((8 + 8)+4)); | |
11264 | ||
11265 | bool isNative() const { | |
11266 | return !(flags & NON_NATIVE); | |
11267 | } | |
11268 | }; | |
11269 | ||
11270 | typedef int js_static_assert11[(__builtin_offsetof (JSClass, name) == __builtin_offsetof (Class, name)) ? 1 : -1]; | |
11271 | typedef int js_static_assert12[(__builtin_offsetof (JSClass, flags) == __builtin_offsetof (Class, flags)) ? 1 : -1]; | |
11272 | typedef int js_static_assert13[(__builtin_offsetof (JSClass, addProperty) == __builtin_offsetof (Class, addProperty)) ? 1 : -1]; | |
11273 | typedef int js_static_assert14[(__builtin_offsetof (JSClass, delProperty) == __builtin_offsetof (Class, delProperty)) ? 1 : -1]; | |
11274 | typedef int js_static_assert15[(__builtin_offsetof (JSClass, getProperty) == __builtin_offsetof (Class, getProperty)) ? 1 : -1]; | |
11275 | typedef int js_static_assert16[(__builtin_offsetof (JSClass, setProperty) == __builtin_offsetof (Class, setProperty)) ? 1 : -1]; | |
11276 | typedef int js_static_assert17[(__builtin_offsetof (JSClass, enumerate) == __builtin_offsetof (Class, enumerate)) ? 1 : -1]; | |
11277 | typedef int js_static_assert18[(__builtin_offsetof (JSClass, resolve) == __builtin_offsetof (Class, resolve)) ? 1 : -1]; | |
11278 | typedef int js_static_assert19[(__builtin_offsetof (JSClass, convert) == __builtin_offsetof (Class, convert)) ? 1 : -1]; | |
11279 | typedef int js_static_assert20[(__builtin_offsetof (JSClass, finalize) == __builtin_offsetof (Class, finalize)) ? 1 : -1]; | |
11280 | typedef int js_static_assert21[(__builtin_offsetof (JSClass, reserved0) == __builtin_offsetof (Class, reserved0)) ? 1 : -1]; | |
11281 | typedef int js_static_assert22[(__builtin_offsetof (JSClass, checkAccess) == __builtin_offsetof (Class, checkAccess)) ? 1 : -1]; | |
11282 | typedef int js_static_assert23[(__builtin_offsetof (JSClass, call) == __builtin_offsetof (Class, call)) ? 1 : -1]; | |
11283 | typedef int js_static_assert24[(__builtin_offsetof (JSClass, construct) == __builtin_offsetof (Class, construct)) ? 1 : -1]; | |
11284 | typedef int js_static_assert25[(__builtin_offsetof (JSClass, xdrObject) == __builtin_offsetof (Class, xdrObject)) ? 1 : -1]; | |
11285 | typedef int js_static_assert26[(__builtin_offsetof (JSClass, hasInstance) == __builtin_offsetof (Class, hasInstance)) ? 1 : -1]; | |
11286 | typedef int js_static_assert27[(__builtin_offsetof (JSClass, mark) == __builtin_offsetof (Class, mark)) ? 1 : -1]; | |
11287 | typedef int js_static_assert28[(sizeof(JSClass) == sizeof(Class)) ? 1 : -1]; | |
11288 | ||
11289 | struct PropertyDescriptor { | |
11290 | JSObject *obj; | |
11291 | uintN attrs; | |
11292 | PropertyOp getter; | |
11293 | StrictPropertyOp setter; | |
11294 | Value value; | |
11295 | uintN shortid; | |
11296 | }; | |
11297 | typedef int js_static_assert29[(__builtin_offsetof (JSPropertyDescriptor, obj) == __builtin_offsetof (PropertyDescriptor, obj)) ? 1 : -1]; | |
11298 | typedef int js_static_assert30[(__builtin_offsetof (JSPropertyDescriptor, attrs) == __builtin_offsetof (PropertyDescriptor, attrs)) ? 1 : -1]; | |
11299 | typedef int js_static_assert31[(__builtin_offsetof (JSPropertyDescriptor, getter) == __builtin_offsetof (PropertyDescriptor, getter)) ? 1 : -1]; | |
11300 | typedef int js_static_assert32[(__builtin_offsetof (JSPropertyDescriptor, setter) == __builtin_offsetof (PropertyDescriptor, setter)) ? 1 : -1]; | |
11301 | typedef int js_static_assert33[(__builtin_offsetof (JSPropertyDescriptor, value) == __builtin_offsetof (PropertyDescriptor, value)) ? 1 : -1]; | |
11302 | typedef int js_static_assert34[(__builtin_offsetof (JSPropertyDescriptor, shortid) == __builtin_offsetof (PropertyDescriptor, shortid)) ? 1 : -1]; | |
11303 | typedef int js_static_assert35[(sizeof(JSPropertyDescriptor) == sizeof(PropertyDescriptor)) ? 1 : -1]; | |
11304 | ||
11305 | static __attribute__((always_inline)) inline JSClass * Jsvalify(Class *c) { return (JSClass *)c; } | |
11306 | static __attribute__((always_inline)) inline Class * Valueify(JSClass *c) { return (Class *)c; } | |
11307 | static __attribute__((always_inline)) inline JSPropertyDescriptor * Jsvalify(PropertyDescriptor *p) { return (JSPropertyDescriptor *) p; } | |
11308 | static __attribute__((always_inline)) inline PropertyDescriptor * Valueify(JSPropertyDescriptor *p) { return (PropertyDescriptor *) p; } | |
11309 | # 1141 "jsvalue.h" | |
11310 | typedef js::Value ValueArgType; | |
11311 | ||
11312 | static __attribute__((always_inline)) inline const Value & | |
11313 | ValueArgToConstRef(const Value &v) | |
11314 | { | |
11315 | return v; | |
11316 | } | |
11317 | ||
11318 | ||
11319 | ||
11320 | ||
11321 | static __attribute__((always_inline)) inline void | |
11322 | MakeRangeGCSafe(Value *vec, size_t len) | |
11323 | { | |
11324 | PodZero(vec, len); | |
11325 | } | |
11326 | ||
11327 | static __attribute__((always_inline)) inline void | |
11328 | MakeRangeGCSafe(Value *beg, Value *end) | |
11329 | { | |
11330 | PodZero(beg, end - beg); | |
11331 | } | |
11332 | ||
11333 | static __attribute__((always_inline)) inline void | |
11334 | MakeRangeGCSafe(jsid *beg, jsid *end) | |
11335 | { | |
11336 | for (jsid *id = beg; id != end; ++id) | |
11337 | *id = INT_TO_JSID(0); | |
11338 | } | |
11339 | ||
11340 | static __attribute__((always_inline)) inline void | |
11341 | MakeRangeGCSafe(jsid *vec, size_t len) | |
11342 | { | |
11343 | MakeRangeGCSafe(vec, vec + len); | |
11344 | } | |
11345 | ||
11346 | static __attribute__((always_inline)) inline void | |
11347 | MakeRangeGCSafe(const Shape **beg, const Shape **end) | |
11348 | { | |
11349 | PodZero(beg, end - beg); | |
11350 | } | |
11351 | ||
11352 | static __attribute__((always_inline)) inline void | |
11353 | MakeRangeGCSafe(const Shape **vec, size_t len) | |
11354 | { | |
11355 | PodZero(vec, len); | |
11356 | } | |
11357 | ||
11358 | static __attribute__((always_inline)) inline void | |
11359 | SetValueRangeToUndefined(Value *beg, Value *end) | |
11360 | { | |
11361 | for (Value *v = beg; v != end; ++v) | |
11362 | v->setUndefined(); | |
11363 | } | |
11364 | ||
11365 | static __attribute__((always_inline)) inline void | |
11366 | SetValueRangeToUndefined(Value *vec, size_t len) | |
11367 | { | |
11368 | SetValueRangeToUndefined(vec, vec + len); | |
11369 | } | |
11370 | ||
11371 | static __attribute__((always_inline)) inline void | |
11372 | SetValueRangeToNull(Value *beg, Value *end) | |
11373 | { | |
11374 | for (Value *v = beg; v != end; ++v) | |
11375 | v->setNull(); | |
11376 | } | |
11377 | ||
11378 | static __attribute__((always_inline)) inline void | |
11379 | SetValueRangeToNull(Value *vec, size_t len) | |
11380 | { | |
11381 | SetValueRangeToNull(vec, vec + len); | |
11382 | } | |
11383 | ||
11384 | ||
11385 | ||
11386 | ||
11387 | ||
11388 | ||
11389 | ||
11390 | static __attribute__((always_inline)) inline void | |
11391 | Debug_SetValueRangeToCrashOnTouch(Value *beg, Value *end) | |
11392 | { | |
11393 | ||
11394 | ||
11395 | ||
11396 | ||
11397 | } | |
11398 | ||
11399 | static __attribute__((always_inline)) inline void | |
11400 | Debug_SetValueRangeToCrashOnTouch(Value *vec, size_t len) | |
11401 | { | |
11402 | ||
11403 | ||
11404 | ||
11405 | } | |
11406 | ||
11407 | } | |
11408 | # 65 "jsobj.h" 2 | |
11409 | # 1 "jsvector.h" 1 | |
11410 | # 59 "jsvector.h" | |
11411 | namespace js { | |
11412 | ||
11413 | ||
11414 | ||
11415 | ||
11416 | ||
11417 | template <class T, size_t N, class AP, bool IsPod> | |
11418 | struct VectorImpl | |
11419 | { | |
11420 | ||
11421 | static inline void destroy(T *begin, T *end) { | |
11422 | for (T *p = begin; p != end; ++p) | |
11423 | p->~T(); | |
11424 | } | |
11425 | ||
11426 | ||
11427 | static inline void initialize(T *begin, T *end) { | |
11428 | for (T *p = begin; p != end; ++p) | |
11429 | new(p) T(); | |
11430 | } | |
11431 | ||
11432 | ||
11433 | ||
11434 | ||
11435 | ||
11436 | template <class U> | |
11437 | static inline void copyConstruct(T *dst, const U *srcbeg, const U *srcend) { | |
11438 | for (const U *p = srcbeg; p != srcend; ++p, ++dst) | |
11439 | new(dst) T(*p); | |
11440 | } | |
11441 | ||
11442 | ||
11443 | ||
11444 | ||
11445 | ||
11446 | template <class U> | |
11447 | static inline void copyConstructN(T *dst, size_t n, const U &u) { | |
11448 | for (T *end = dst + n; dst != end; ++dst) | |
11449 | new(dst) T(u); | |
11450 | } | |
11451 | ||
11452 | ||
11453 | ||
11454 | ||
11455 | ||
11456 | ||
11457 | ||
11458 | static inline bool growTo(Vector<T,N,AP> &v, size_t newcap) { | |
11459 | ((void) 0); | |
11460 | T *newbuf = reinterpret_cast<T *>(v.malloc(newcap * sizeof(T))); | |
11461 | if (!newbuf) | |
11462 | return false; | |
11463 | for (T *dst = newbuf, *src = v.beginNoCheck(); src != v.endNoCheck(); ++dst, ++src) | |
11464 | new(dst) T(*src); | |
11465 | VectorImpl::destroy(v.beginNoCheck(), v.endNoCheck()); | |
11466 | v.free(v.mBegin); | |
11467 | v.mBegin = newbuf; | |
11468 | ||
11469 | v.mCapacity = newcap; | |
11470 | return true; | |
11471 | } | |
11472 | }; | |
11473 | ||
11474 | ||
11475 | ||
11476 | ||
11477 | ||
11478 | ||
11479 | template <class T, size_t N, class AP> | |
11480 | struct VectorImpl<T, N, AP, true> | |
11481 | { | |
11482 | static inline void destroy(T *, T *) {} | |
11483 | ||
11484 | static inline void initialize(T *begin, T *end) { | |
11485 | # 141 "jsvector.h" | |
11486 | for (T *p = begin; p != end; ++p) | |
11487 | new(p) T(); | |
11488 | } | |
11489 | ||
11490 | template <class U> | |
11491 | static inline void copyConstruct(T *dst, const U *srcbeg, const U *srcend) { | |
11492 | ||
11493 | ||
11494 | ||
11495 | ||
11496 | ||
11497 | ||
11498 | ||
11499 | for (const U *p = srcbeg; p != srcend; ++p, ++dst) | |
11500 | *dst = *p; | |
11501 | } | |
11502 | ||
11503 | static inline void copyConstructN(T *dst, size_t n, const T &t) { | |
11504 | for (T *p = dst, *end = dst + n; p != end; ++p) | |
11505 | *p = t; | |
11506 | } | |
11507 | ||
11508 | static inline bool growTo(Vector<T,N,AP> &v, size_t newcap) { | |
11509 | ((void) 0); | |
11510 | size_t bytes = sizeof(T) * newcap; | |
11511 | T *newbuf = reinterpret_cast<T *>(v.realloc(v.mBegin, bytes)); | |
11512 | if (!newbuf) | |
11513 | return false; | |
11514 | v.mBegin = newbuf; | |
11515 | ||
11516 | v.mCapacity = newcap; | |
11517 | return true; | |
11518 | } | |
11519 | }; | |
11520 | # 194 "jsvector.h" | |
11521 | template <class T, size_t N, class AllocPolicy> | |
11522 | class Vector : AllocPolicy | |
11523 | { | |
11524 | ||
11525 | ||
11526 | static const bool sElemIsPod = tl::IsPodType<T>::result; | |
11527 | typedef VectorImpl<T, N, AllocPolicy, sElemIsPod> Impl; | |
11528 | friend struct VectorImpl<T, N, AllocPolicy, sElemIsPod>; | |
11529 | ||
11530 | bool calculateNewCapacity(size_t curLength, size_t lengthInc, size_t &newCap); | |
11531 | bool growStorageBy(size_t lengthInc); | |
11532 | bool growHeapStorageBy(size_t lengthInc); | |
11533 | bool convertToHeapStorage(size_t lengthInc); | |
11534 | ||
11535 | template <bool InitNewElems> inline bool growByImpl(size_t inc); | |
11536 | ||
11537 | ||
11538 | ||
11539 | static const int sMaxInlineBytes = 1024; | |
11540 | ||
11541 | ||
11542 | ||
11543 | static const size_t sInlineCapacity = | |
11544 | tl::Min<N, sMaxInlineBytes / sizeof(T)>::result; | |
11545 | ||
11546 | ||
11547 | static const size_t sInlineBytes = | |
11548 | tl::Max<1, sInlineCapacity * sizeof(T)>::result; | |
11549 | # 230 "jsvector.h" | |
11550 | T *mBegin; | |
11551 | size_t mLength; | |
11552 | size_t mCapacity; | |
11553 | ||
11554 | AlignedStorage<sInlineBytes> storage; | |
11555 | ||
11556 | ||
11557 | ||
11558 | ||
11559 | ||
11560 | ||
11561 | Vector(const Vector &); | |
11562 | Vector &operator=(const Vector &); | |
11563 | ||
11564 | ||
11565 | ||
11566 | bool usingInlineStorage() const { | |
11567 | return mBegin == (T *)storage.addr(); | |
11568 | } | |
11569 | ||
11570 | T *beginNoCheck() const { | |
11571 | return mBegin; | |
11572 | } | |
11573 | ||
11574 | T *endNoCheck() { | |
11575 | return mBegin + mLength; | |
11576 | } | |
11577 | ||
11578 | const T *endNoCheck() const { | |
11579 | return mBegin + mLength; | |
11580 | } | |
11581 | ||
11582 | public: | |
11583 | typedef T ElementType; | |
11584 | ||
11585 | Vector(AllocPolicy = AllocPolicy()); | |
11586 | ~Vector(); | |
11587 | ||
11588 | ||
11589 | ||
11590 | const AllocPolicy &allocPolicy() const { | |
11591 | return *this; | |
11592 | } | |
11593 | ||
11594 | enum { InlineLength = N }; | |
11595 | ||
11596 | size_t length() const { | |
11597 | return mLength; | |
11598 | } | |
11599 | ||
11600 | bool empty() const { | |
11601 | return mLength == 0; | |
11602 | } | |
11603 | ||
11604 | size_t capacity() const { | |
11605 | return mCapacity; | |
11606 | } | |
11607 | ||
11608 | T *begin() const { | |
11609 | ((void) 0); | |
11610 | return mBegin; | |
11611 | } | |
11612 | ||
11613 | T *end() { | |
11614 | ((void) 0); | |
11615 | return mBegin + mLength; | |
11616 | } | |
11617 | ||
11618 | const T *end() const { | |
11619 | ((void) 0); | |
11620 | return mBegin + mLength; | |
11621 | } | |
11622 | ||
11623 | T &operator[](size_t i) { | |
11624 | ((void) 0); | |
11625 | return begin()[i]; | |
11626 | } | |
11627 | ||
11628 | const T &operator[](size_t i) const { | |
11629 | ((void) 0); | |
11630 | return begin()[i]; | |
11631 | } | |
11632 | ||
11633 | T &back() { | |
11634 | ((void) 0); | |
11635 | return *(end() - 1); | |
11636 | } | |
11637 | ||
11638 | const T &back() const { | |
11639 | ((void) 0); | |
11640 | return *(end() - 1); | |
11641 | } | |
11642 | ||
11643 | ||
11644 | ||
11645 | ||
11646 | bool reserve(size_t capacity); | |
11647 | ||
11648 | ||
11649 | void shrinkBy(size_t incr); | |
11650 | ||
11651 | ||
11652 | bool growBy(size_t incr); | |
11653 | ||
11654 | ||
11655 | bool resize(size_t newLength); | |
11656 | ||
11657 | ||
11658 | bool growByUninitialized(size_t incr); | |
11659 | bool resizeUninitialized(size_t newLength); | |
11660 | ||
11661 | void clear(); | |
11662 | ||
11663 | bool append(const T &t); | |
11664 | bool appendN(const T &t, size_t n); | |
11665 | template <class U> bool append(const U *begin, const U *end); | |
11666 | template <class U> bool append(const U *begin, size_t length); | |
11667 | template <class U, size_t O, class BP> bool append(const Vector<U,O,BP> &other); | |
11668 | ||
11669 | void popBack(); | |
11670 | ||
11671 | T popCopy(); | |
11672 | # 361 "jsvector.h" | |
11673 | T *extractRawBuffer(); | |
11674 | ||
11675 | ||
11676 | ||
11677 | ||
11678 | ||
11679 | ||
11680 | void replaceRawBuffer(T *p, size_t length); | |
11681 | ||
11682 | ||
11683 | ||
11684 | ||
11685 | ||
11686 | bool insert(T *p, const T &val); | |
11687 | ||
11688 | ||
11689 | ||
11690 | ||
11691 | ||
11692 | void erase(T *t); | |
11693 | }; | |
11694 | # 391 "jsvector.h" | |
11695 | template <class T, size_t N, class AllocPolicy> | |
11696 | __attribute__((always_inline)) inline | |
11697 | Vector<T,N,AllocPolicy>::Vector(AllocPolicy ap) | |
11698 | : AllocPolicy(ap), mBegin((T *)storage.addr()), mLength(0), | |
11699 | mCapacity(sInlineCapacity) | |
11700 | ||
11701 | ||
11702 | ||
11703 | {} | |
11704 | ||
11705 | template <class T, size_t N, class AP> | |
11706 | __attribute__((always_inline)) inline | |
11707 | Vector<T,N,AP>::~Vector() | |
11708 | { | |
11709 | ReentrancyGuard g(*this); ((void) 0); ((void) 0); | |
11710 | Impl::destroy(beginNoCheck(), endNoCheck()); | |
11711 | if (!usingInlineStorage()) | |
11712 | this->free(beginNoCheck()); | |
11713 | } | |
11714 | ||
11715 | ||
11716 | ||
11717 | ||
11718 | ||
11719 | template <class T, size_t N, class AP> | |
11720 | ||
11721 | inline | |
11722 | ||
11723 | # 417 "jsvector.h" | |
11724 | bool | |
11725 | Vector<T,N,AP>::calculateNewCapacity(size_t curLength, size_t lengthInc, | |
11726 | size_t &newCap) | |
11727 | { | |
11728 | size_t newMinCap = curLength + lengthInc; | |
11729 | ||
11730 | ||
11731 | ||
11732 | ||
11733 | ||
11734 | if (newMinCap < curLength || | |
11735 | newMinCap & tl::MulOverflowMask<2 * sizeof(T)>::result) { | |
11736 | this->reportAllocOverflow(); | |
11737 | return false; | |
11738 | } | |
11739 | ||
11740 | ||
11741 | newCap = RoundUpPow2(newMinCap); | |
11742 | ||
11743 | ||
11744 | ||
11745 | ||
11746 | ||
11747 | if (newCap & tl::UnsafeRangeSizeMask<T>::result) { | |
11748 | this->reportAllocOverflow(); | |
11749 | return false; | |
11750 | } | |
11751 | return true; | |
11752 | } | |
11753 | ||
11754 | ||
11755 | ||
11756 | ||
11757 | ||
11758 | template <class T, size_t N, class AP> | |
11759 | __attribute__((always_inline)) inline | |
11760 | ||
11761 | # 452 "jsvector.h" | |
11762 | bool | |
11763 | Vector<T,N,AP>::growHeapStorageBy(size_t lengthInc) | |
11764 | { | |
11765 | ((void) 0); | |
11766 | size_t newCap; | |
11767 | return calculateNewCapacity(mLength, lengthInc, newCap) && | |
11768 | Impl::growTo(*this, newCap); | |
11769 | } | |
11770 | ||
11771 | ||
11772 | ||
11773 | ||
11774 | ||
11775 | ||
11776 | template <class T, size_t N, class AP> | |
11777 | inline | |
11778 | ||
11779 | # 467 "jsvector.h" | |
11780 | bool | |
11781 | Vector<T,N,AP>::convertToHeapStorage(size_t lengthInc) | |
11782 | { | |
11783 | ((void) 0); | |
11784 | size_t newCap; | |
11785 | if (!calculateNewCapacity(mLength, lengthInc, newCap)) | |
11786 | return false; | |
11787 | ||
11788 | ||
11789 | T *newBuf = reinterpret_cast<T *>(this->malloc(newCap * sizeof(T))); | |
11790 | if (!newBuf) | |
11791 | return false; | |
11792 | ||
11793 | ||
11794 | Impl::copyConstruct(newBuf, beginNoCheck(), endNoCheck()); | |
11795 | Impl::destroy(beginNoCheck(), endNoCheck()); | |
11796 | ||
11797 | ||
11798 | mBegin = newBuf; | |
11799 | ||
11800 | mCapacity = newCap; | |
11801 | return true; | |
11802 | } | |
11803 | ||
11804 | template <class T, size_t N, class AP> | |
11805 | __attribute__((noinline)) | |
11806 | ||
11807 | # 492 "jsvector.h" | |
11808 | bool | |
11809 | Vector<T,N,AP>::growStorageBy(size_t incr) | |
11810 | { | |
11811 | ((void) 0); | |
11812 | return usingInlineStorage() | |
11813 | ? convertToHeapStorage(incr) | |
11814 | : growHeapStorageBy(incr); | |
11815 | } | |
11816 | ||
11817 | template <class T, size_t N, class AP> | |
11818 | inline | |
11819 | ||
11820 | # 502 "jsvector.h" | |
11821 | bool | |
11822 | Vector<T,N,AP>::reserve(size_t request) | |
11823 | { | |
11824 | ReentrancyGuard g(*this); ((void) 0); ((void) 0); | |
11825 | if (request > mCapacity) | |
11826 | return growStorageBy(request - mLength); | |
11827 | return true; | |
11828 | } | |
11829 | ||
11830 | template <class T, size_t N, class AP> | |
11831 | inline void | |
11832 | Vector<T,N,AP>::shrinkBy(size_t incr) | |
11833 | { | |
11834 | ReentrancyGuard g(*this); ((void) 0); ((void) 0); | |
11835 | ((void) 0); | |
11836 | Impl::destroy(endNoCheck() - incr, endNoCheck()); | |
11837 | mLength -= incr; | |
11838 | } | |
11839 | ||
11840 | template <class T, size_t N, class AP> | |
11841 | template <bool InitNewElems> | |
11842 | __attribute__((always_inline)) inline | |
11843 | ||
11844 | # 523 "jsvector.h" | |
11845 | bool | |
11846 | Vector<T,N,AP>::growByImpl(size_t incr) | |
11847 | { | |
11848 | ReentrancyGuard g(*this); ((void) 0); ((void) 0); | |
11849 | if (incr > mCapacity - mLength && !growStorageBy(incr)) | |
11850 | return false; | |
11851 | ||
11852 | ((void) 0); | |
11853 | T *newend = endNoCheck() + incr; | |
11854 | if (InitNewElems) | |
11855 | Impl::initialize(endNoCheck(), newend); | |
11856 | mLength += incr; | |
11857 | return true; | |
11858 | } | |
11859 | ||
11860 | template <class T, size_t N, class AP> | |
11861 | __attribute__((always_inline)) inline | |
11862 | ||
11863 | # 539 "jsvector.h" | |
11864 | bool | |
11865 | Vector<T,N,AP>::growBy(size_t incr) | |
11866 | { | |
11867 | return growByImpl<true>(incr); | |
11868 | } | |
11869 | ||
11870 | template <class T, size_t N, class AP> | |
11871 | __attribute__((always_inline)) inline | |
11872 | ||
11873 | # 546 "jsvector.h" | |
11874 | bool | |
11875 | Vector<T,N,AP>::growByUninitialized(size_t incr) | |
11876 | { | |
11877 | return growByImpl<false>(incr); | |
11878 | } | |
11879 | ||
11880 | template <class T, size_t N, class AP> | |
11881 | ||
11882 | inline | |
11883 | ||
11884 | # 554 "jsvector.h" | |
11885 | bool | |
11886 | Vector<T,N,AP>::resize(size_t newLength) | |
11887 | { | |
11888 | size_t curLength = mLength; | |
11889 | if (newLength > curLength) | |
11890 | return growBy(newLength - curLength); | |
11891 | shrinkBy(curLength - newLength); | |
11892 | return true; | |
11893 | } | |
11894 | ||
11895 | template <class T, size_t N, class AP> | |
11896 | __attribute__((always_inline)) inline | |
11897 | ||
11898 | # 565 "jsvector.h" | |
11899 | bool | |
11900 | Vector<T,N,AP>::resizeUninitialized(size_t newLength) | |
11901 | { | |
11902 | size_t curLength = mLength; | |
11903 | if (newLength > curLength) | |
11904 | return growByUninitialized(newLength - curLength); | |
11905 | shrinkBy(curLength - newLength); | |
11906 | return true; | |
11907 | } | |
11908 | ||
11909 | template <class T, size_t N, class AP> | |
11910 | inline void | |
11911 | Vector<T,N,AP>::clear() | |
11912 | { | |
11913 | ReentrancyGuard g(*this); ((void) 0); ((void) 0); | |
11914 | Impl::destroy(beginNoCheck(), endNoCheck()); | |
11915 | mLength = 0; | |
11916 | } | |
11917 | ||
11918 | template <class T, size_t N, class AP> | |
11919 | __attribute__((always_inline)) inline | |
11920 | ||
11921 | # 585 "jsvector.h" | |
11922 | bool | |
11923 | Vector<T,N,AP>::append(const T &t) | |
11924 | { | |
11925 | ReentrancyGuard g(*this); ((void) 0); ((void) 0); | |
11926 | if (mLength == mCapacity && !growStorageBy(1)) | |
11927 | return false; | |
11928 | ||
11929 | ((void) 0); | |
11930 | new(endNoCheck()) T(t); | |
11931 | ++mLength; | |
11932 | return true; | |
11933 | } | |
11934 | ||
11935 | template <class T, size_t N, class AP> | |
11936 | __attribute__((always_inline)) inline | |
11937 | ||
11938 | # 599 "jsvector.h" | |
11939 | bool | |
11940 | Vector<T,N,AP>::appendN(const T &t, size_t needed) | |
11941 | { | |
11942 | ReentrancyGuard g(*this); ((void) 0); ((void) 0); | |
11943 | if (mLength + needed > mCapacity && !growStorageBy(needed)) | |
11944 | return false; | |
11945 | ||
11946 | ((void) 0); | |
11947 | Impl::copyConstructN(endNoCheck(), needed, t); | |
11948 | mLength += needed; | |
11949 | return true; | |
11950 | } | |
11951 | ||
11952 | template <class T, size_t N, class AP> | |
11953 | inline | |
11954 | ||
11955 | # 613 "jsvector.h" | |
11956 | bool | |
11957 | Vector<T,N,AP>::insert(T *p, const T &val) | |
11958 | { | |
11959 | ((void) 0); | |
11960 | size_t pos = p - begin(); | |
11961 | ((void) 0); | |
11962 | size_t oldLength = mLength; | |
11963 | if (pos == oldLength) | |
11964 | return append(val); | |
11965 | { | |
11966 | T oldBack = back(); | |
11967 | if (!append(oldBack)) | |
11968 | return false; | |
11969 | } | |
11970 | for (size_t i = oldLength; i > pos; --i) | |
11971 | (*this)[i] = (*this)[i - 1]; | |
11972 | (*this)[pos] = val; | |
11973 | return true; | |
11974 | } | |
11975 | ||
11976 | template<typename T, size_t N, class AP> | |
11977 | inline void | |
11978 | Vector<T,N,AP>::erase(T *it) | |
11979 | { | |
11980 | ((void) 0); | |
11981 | while (it + 1 != end()) { | |
11982 | *it = *(it + 1); | |
11983 | ++it; | |
11984 | } | |
11985 | popBack(); | |
11986 | } | |
11987 | ||
11988 | template <class T, size_t N, class AP> | |
11989 | template <class U> | |
11990 | __attribute__((always_inline)) inline | |
11991 | ||
11992 | # 647 "jsvector.h" | |
11993 | bool | |
11994 | Vector<T,N,AP>::append(const U *insBegin, const U *insEnd) | |
11995 | { | |
11996 | ReentrancyGuard g(*this); ((void) 0); ((void) 0); | |
11997 | size_t needed = PointerRangeSize(insBegin, insEnd); | |
11998 | if (mLength + needed > mCapacity && !growStorageBy(needed)) | |
11999 | return false; | |
12000 | ||
12001 | ((void) 0); | |
12002 | Impl::copyConstruct(endNoCheck(), insBegin, insEnd); | |
12003 | mLength += needed; | |
12004 | return true; | |
12005 | } | |
12006 | ||
12007 | template <class T, size_t N, class AP> | |
12008 | template <class U, size_t O, class BP> | |
12009 | inline | |
12010 | ||
12011 | # 663 "jsvector.h" | |
12012 | bool | |
12013 | Vector<T,N,AP>::append(const Vector<U,O,BP> &other) | |
12014 | { | |
12015 | return append(other.begin(), other.end()); | |
12016 | } | |
12017 | ||
12018 | template <class T, size_t N, class AP> | |
12019 | template <class U> | |
12020 | __attribute__((always_inline)) inline | |
12021 | ||
12022 | # 671 "jsvector.h" | |
12023 | bool | |
12024 | Vector<T,N,AP>::append(const U *insBegin, size_t length) | |
12025 | { | |
12026 | return this->append(insBegin, insBegin + length); | |
12027 | } | |
12028 | ||
12029 | template <class T, size_t N, class AP> | |
12030 | __attribute__((always_inline)) inline void | |
12031 | Vector<T,N,AP>::popBack() | |
12032 | { | |
12033 | ReentrancyGuard g(*this); ((void) 0); ((void) 0); | |
12034 | ((void) 0); | |
12035 | --mLength; | |
12036 | endNoCheck()->~T(); | |
12037 | } | |
12038 | ||
12039 | template <class T, size_t N, class AP> | |
12040 | __attribute__((always_inline)) inline T | |
12041 | Vector<T,N,AP>::popCopy() | |
12042 | { | |
12043 | T ret = back(); | |
12044 | popBack(); | |
12045 | return ret; | |
12046 | } | |
12047 | ||
12048 | template <class T, size_t N, class AP> | |
12049 | inline T * | |
12050 | Vector<T,N,AP>::extractRawBuffer() | |
12051 | { | |
12052 | T *ret; | |
12053 | if (usingInlineStorage()) { | |
12054 | ret = reinterpret_cast<T *>(this->malloc(mLength * sizeof(T))); | |
12055 | if (!ret) | |
12056 | return __null; | |
12057 | Impl::copyConstruct(ret, beginNoCheck(), endNoCheck()); | |
12058 | Impl::destroy(beginNoCheck(), endNoCheck()); | |
12059 | ||
12060 | mLength = 0; | |
12061 | } else { | |
12062 | ret = mBegin; | |
12063 | mBegin = (T *)storage.addr(); | |
12064 | mLength = 0; | |
12065 | mCapacity = sInlineCapacity; | |
12066 | } | |
12067 | return ret; | |
12068 | } | |
12069 | ||
12070 | template <class T, size_t N, class AP> | |
12071 | inline void | |
12072 | Vector<T,N,AP>::replaceRawBuffer(T *p, size_t length) | |
12073 | { | |
12074 | ReentrancyGuard g(*this); ((void) 0); ((void) 0); | |
12075 | ||
12076 | ||
12077 | Impl::destroy(beginNoCheck(), endNoCheck()); | |
12078 | if (!usingInlineStorage()) | |
12079 | this->free(beginNoCheck()); | |
12080 | ||
12081 | ||
12082 | if (length <= sInlineCapacity) { | |
12083 | ||
12084 | ||
12085 | ||
12086 | ||
12087 | ||
12088 | mBegin = (T *)storage.addr(); | |
12089 | mLength = length; | |
12090 | mCapacity = sInlineCapacity; | |
12091 | Impl::copyConstruct(mBegin, p, p + length); | |
12092 | Impl::destroy(p, p + length); | |
12093 | this->free(p); | |
12094 | } else { | |
12095 | mBegin = p; | |
12096 | mLength = length; | |
12097 | mCapacity = length; | |
12098 | } | |
12099 | } | |
12100 | ||
12101 | } | |
12102 | # 66 "jsobj.h" 2 | |
12103 | # 1 "jscell.h" 1 | |
12104 | # 43 "jscell.h" | |
12105 | struct JSCompartment; | |
12106 | ||
12107 | namespace js { | |
12108 | namespace gc { | |
12109 | ||
12110 | template <typename T> struct Arena; | |
12111 | struct ArenaBitmap; | |
12112 | struct MarkingDelay; | |
12113 | struct Chunk; | |
12114 | struct FreeCell; | |
12115 | # 62 "jscell.h" | |
12116 | struct Cell { | |
12117 | static const size_t CellShift = 3; | |
12118 | static const size_t CellSize = size_t(1) << CellShift; | |
12119 | static const size_t CellMask = CellSize - 1; | |
12120 | ||
12121 | inline Arena<Cell> *arena() const; | |
12122 | inline Chunk *chunk() const; | |
12123 | inline ArenaBitmap *bitmap() const; | |
12124 | __attribute__((always_inline)) inline size_t cellIndex() const; | |
12125 | ||
12126 | __attribute__((always_inline)) inline bool isMarked(uint32 color) const; | |
12127 | __attribute__((always_inline)) inline bool markIfUnmarked(uint32 color) const; | |
12128 | __attribute__((always_inline)) inline void unmark(uint32 color) const; | |
12129 | ||
12130 | inline JSCompartment *compartment() const; | |
12131 | ||
12132 | ||
12133 | __attribute__((always_inline)) inline js::gc::Cell *asCell() { return this; } | |
12134 | ||
12135 | __attribute__((always_inline)) inline js::gc::FreeCell *asFreeCell() { | |
12136 | return reinterpret_cast<FreeCell *>(this); | |
12137 | } | |
12138 | }; | |
12139 | ||
12140 | ||
12141 | struct FreeCell : Cell { | |
12142 | union { | |
12143 | FreeCell *link; | |
12144 | double data; | |
12145 | }; | |
12146 | }; | |
12147 | ||
12148 | typedef int js_static_assert36[(sizeof(FreeCell) == 8) ? 1 : -1]; | |
12149 | ||
12150 | } | |
12151 | } | |
12152 | # 67 "jsobj.h" 2 | |
12153 | ||
12154 | namespace js { | |
12155 | ||
12156 | class JSProxyHandler; | |
12157 | class AutoPropDescArrayRooter; | |
12158 | ||
12159 | namespace mjit { | |
12160 | class Compiler; | |
12161 | } | |
12162 | ||
12163 | static inline PropertyOp | |
12164 | CastAsPropertyOp(JSObject *object) | |
12165 | { | |
12166 | return (__extension__ (PropertyOp) (size_t) (object)); | |
12167 | } | |
12168 | ||
12169 | static inline StrictPropertyOp | |
12170 | CastAsStrictPropertyOp(JSObject *object) | |
12171 | { | |
12172 | return (__extension__ (StrictPropertyOp) (size_t) (object)); | |
12173 | } | |
12174 | ||
12175 | static inline JSPropertyOp | |
12176 | CastAsJSPropertyOp(JSObject *object) | |
12177 | { | |
12178 | return (__extension__ (JSPropertyOp) (size_t) (object)); | |
12179 | } | |
12180 | ||
12181 | static inline JSStrictPropertyOp | |
12182 | CastAsJSStrictPropertyOp(JSObject *object) | |
12183 | { | |
12184 | return (__extension__ (JSStrictPropertyOp) (size_t) (object)); | |
12185 | } | |
12186 | ||
12187 | inline JSObject * | |
12188 | CastAsObject(PropertyOp op) | |
12189 | { | |
12190 | return (__extension__ (JSObject *) (size_t) (op)); | |
12191 | } | |
12192 | ||
12193 | inline JSObject * | |
12194 | CastAsObject(StrictPropertyOp op) | |
12195 | { | |
12196 | return (__extension__ (JSObject *) (size_t) (op)); | |
12197 | } | |
12198 | ||
12199 | inline Value | |
12200 | CastAsObjectJsval(PropertyOp op) | |
12201 | { | |
12202 | return ObjectOrNullValue(CastAsObject(op)); | |
12203 | } | |
12204 | ||
12205 | inline Value | |
12206 | CastAsObjectJsval(StrictPropertyOp op) | |
12207 | { | |
12208 | return ObjectOrNullValue(CastAsObject(op)); | |
12209 | } | |
12210 | ||
12211 | } | |
12212 | ||
12213 | ||
12214 | ||
12215 | ||
12216 | ||
12217 | struct PropDesc { | |
12218 | friend class js::AutoPropDescArrayRooter; | |
12219 | ||
12220 | PropDesc(); | |
12221 | ||
12222 | public: | |
12223 | ||
12224 | bool initialize(JSContext* cx, jsid id, const js::Value &v); | |
12225 | ||
12226 | ||
12227 | bool isAccessorDescriptor() const { | |
12228 | return hasGet || hasSet; | |
12229 | } | |
12230 | ||
12231 | ||
12232 | bool isDataDescriptor() const { | |
12233 | return hasValue || hasWritable; | |
12234 | } | |
12235 | ||
12236 | ||
12237 | bool isGenericDescriptor() const { | |
12238 | return !isAccessorDescriptor() && !isDataDescriptor(); | |
12239 | } | |
12240 | ||
12241 | bool configurable() const { | |
12242 | return (attrs & 0x04) == 0; | |
12243 | } | |
12244 | ||
12245 | bool enumerable() const { | |
12246 | return (attrs & 0x01) != 0; | |
12247 | } | |
12248 | ||
12249 | bool writable() const { | |
12250 | return (attrs & 0x02) == 0; | |
12251 | } | |
12252 | ||
12253 | JSObject* getterObject() const { | |
12254 | return get.isUndefined() ? __null : &get.toObject(); | |
12255 | } | |
12256 | JSObject* setterObject() const { | |
12257 | return set.isUndefined() ? __null : &set.toObject(); | |
12258 | } | |
12259 | ||
12260 | const js::Value &getterValue() const { | |
12261 | return get; | |
12262 | } | |
12263 | const js::Value &setterValue() const { | |
12264 | return set; | |
12265 | } | |
12266 | ||
12267 | js::PropertyOp getter() const { | |
12268 | return js::CastAsPropertyOp(getterObject()); | |
12269 | } | |
12270 | js::StrictPropertyOp setter() const { | |
12271 | return js::CastAsStrictPropertyOp(setterObject()); | |
12272 | } | |
12273 | ||
12274 | js::Value pd; | |
12275 | jsid id; | |
12276 | js::Value value, get, set; | |
12277 | ||
12278 | ||
12279 | uint8 attrs; | |
12280 | ||
12281 | ||
12282 | bool hasGet : 1; | |
12283 | bool hasSet : 1; | |
12284 | bool hasValue : 1; | |
12285 | bool hasWritable : 1; | |
12286 | bool hasEnumerable : 1; | |
12287 | bool hasConfigurable : 1; | |
12288 | }; | |
12289 | ||
12290 | namespace js { | |
12291 | ||
12292 | typedef Vector<PropDesc, 1> PropDescArray; | |
12293 | ||
12294 | } | |
12295 | ||
12296 | struct JSObjectMap { | |
12297 | uint32 shape; | |
12298 | uint32 slotSpan; | |
12299 | ||
12300 | static __attribute__((visibility ("default"))) const JSObjectMap sharedNonNative; | |
12301 | ||
12302 | explicit JSObjectMap(uint32 shape) : shape(shape), slotSpan(0) {} | |
12303 | JSObjectMap(uint32 shape, uint32 slotSpan) : shape(shape), slotSpan(slotSpan) {} | |
12304 | ||
12305 | enum { INVALID_SHAPE = 0x8fffffff, SHAPELESS = 0xffffffff }; | |
12306 | ||
12307 | bool isNative() const { return this != &sharedNonNative; } | |
12308 | ||
12309 | private: | |
12310 | ||
12311 | JSObjectMap(JSObjectMap &); | |
12312 | void operator=(JSObjectMap &); | |
12313 | }; | |
12314 | ||
12315 | ||
12316 | ||
12317 | ||
12318 | ||
12319 | ||
12320 | ||
12321 | extern __attribute__((visibility ("default"))) JSBool | |
12322 | js_LookupProperty(JSContext *cx, JSObject *obj, jsid id, JSObject **objp, | |
12323 | JSProperty **propp); | |
12324 | ||
12325 | extern JSBool | |
12326 | js_DefineProperty(JSContext *cx, JSObject *obj, jsid id, const js::Value *value, | |
12327 | js::PropertyOp getter, js::StrictPropertyOp setter, uintN attrs); | |
12328 | ||
12329 | extern JSBool | |
12330 | js_GetProperty(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, js::Value *vp); | |
12331 | ||
12332 | inline JSBool | |
12333 | js_GetProperty(JSContext *cx, JSObject *obj, jsid id, js::Value *vp) | |
12334 | { | |
12335 | return js_GetProperty(cx, obj, obj, id, vp); | |
12336 | } | |
12337 | ||
12338 | namespace js { | |
12339 | ||
12340 | extern JSBool | |
12341 | GetPropertyDefault(JSContext *cx, JSObject *obj, jsid id, const Value &def, Value *vp); | |
12342 | ||
12343 | } | |
12344 | ||
12345 | extern JSBool | |
12346 | js_SetProperty(JSContext *cx, JSObject *obj, jsid id, js::Value *vp, JSBool strict); | |
12347 | ||
12348 | extern JSBool | |
12349 | js_GetAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp); | |
12350 | ||
12351 | extern JSBool | |
12352 | js_SetAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp); | |
12353 | ||
12354 | extern JSBool | |
12355 | js_DeleteProperty(JSContext *cx, JSObject *obj, jsid id, js::Value *rval, JSBool strict); | |
12356 | ||
12357 | extern __attribute__((visibility ("default"))) JSBool | |
12358 | js_Enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op, | |
12359 | js::Value *statep, jsid *idp); | |
12360 | ||
12361 | extern JSType | |
12362 | js_TypeOf(JSContext *cx, JSObject *obj); | |
12363 | ||
12364 | namespace js { | |
12365 | ||
12366 | struct NativeIterator; | |
12367 | ||
12368 | } | |
12369 | ||
12370 | struct JSFunction; | |
12371 | ||
12372 | namespace nanojit { | |
12373 | class ValidateWriter; | |
12374 | } | |
12375 | # 326 "jsobj.h" | |
12376 | struct JSObject : js::gc::Cell { | |
12377 | ||
12378 | ||
12379 | ||
12380 | ||
12381 | ||
12382 | ||
12383 | friend class js::TraceRecorder; | |
12384 | friend class nanojit::ValidateWriter; | |
12385 | friend class GetPropCompiler; | |
12386 | # 352 "jsobj.h" | |
12387 | union { | |
12388 | js::Shape *lastProp; | |
12389 | JSObjectMap *map; | |
12390 | }; | |
12391 | ||
12392 | js::Class *clasp; | |
12393 | ||
12394 | private: | |
12395 | inline void setLastProperty(const js::Shape *shape); | |
12396 | inline void removeLastProperty(); | |
12397 | ||
12398 | ||
12399 | ||
12400 | ||
12401 | ||
12402 | public: | |
12403 | inline const js::Shape *lastProperty() const; | |
12404 | ||
12405 | inline js::Shape **nativeSearch(jsid id, bool adding = false); | |
12406 | inline const js::Shape *nativeLookup(jsid id); | |
12407 | ||
12408 | inline bool nativeContains(jsid id); | |
12409 | inline bool nativeContains(const js::Shape &shape); | |
12410 | ||
12411 | enum { | |
12412 | DELEGATE = 0x01, | |
12413 | SYSTEM = 0x02, | |
12414 | NOT_EXTENSIBLE = 0x04, | |
12415 | BRANDED = 0x08, | |
12416 | GENERIC = 0x10, | |
12417 | METHOD_BARRIER = 0x20, | |
12418 | INDEXED = 0x40, | |
12419 | OWN_SHAPE = 0x80, | |
12420 | BOUND_FUNCTION = 0x100, | |
12421 | HAS_EQUALITY = 0x200, | |
12422 | METHOD_THRASH_COUNT_MASK = 0xc00, | |
12423 | METHOD_THRASH_COUNT_SHIFT = 10, | |
12424 | METHOD_THRASH_COUNT_MAX = METHOD_THRASH_COUNT_MASK >> METHOD_THRASH_COUNT_SHIFT | |
12425 | }; | |
12426 | ||
12427 | ||
12428 | ||
12429 | ||
12430 | ||
12431 | enum { | |
12432 | NSLOTS_BITS = 29, | |
12433 | NSLOTS_LIMIT = ((JSUint32)1 << (NSLOTS_BITS)) | |
12434 | }; | |
12435 | ||
12436 | uint32 flags; | |
12437 | uint32 objShape; | |
12438 | ||
12439 | ||
12440 | js::EmptyShape **emptyShapes; | |
12441 | ||
12442 | JSObject *proto; | |
12443 | JSObject *parent; | |
12444 | void *privateData; | |
12445 | jsuword capacity; | |
12446 | js::Value *slots; | |
12447 | # 421 "jsobj.h" | |
12448 | inline bool canProvideEmptyShape(js::Class *clasp); | |
12449 | inline js::EmptyShape *getEmptyShape(JSContext *cx, js::Class *aclasp, | |
12450 | unsigned kind); | |
12451 | ||
12452 | bool isNative() const { return map->isNative(); } | |
12453 | ||
12454 | js::Class *getClass() const { return clasp; } | |
12455 | JSClass *getJSClass() const { return Jsvalify(clasp); } | |
12456 | ||
12457 | bool hasClass(const js::Class *c) const { | |
12458 | return c == clasp; | |
12459 | } | |
12460 | ||
12461 | const js::ObjectOps *getOps() const { | |
12462 | return &getClass()->ops; | |
12463 | } | |
12464 | ||
12465 | inline void trace(JSTracer *trc); | |
12466 | ||
12467 | uint32 shape() const { | |
12468 | ((void) 0); | |
12469 | return objShape; | |
12470 | } | |
12471 | ||
12472 | bool isDelegate() const { return !!(flags & DELEGATE); } | |
12473 | void setDelegate() { flags |= DELEGATE; } | |
12474 | void clearDelegate() { flags &= ~DELEGATE; } | |
12475 | ||
12476 | bool isBoundFunction() const { return !!(flags & BOUND_FUNCTION); } | |
12477 | ||
12478 | static void setDelegateNullSafe(JSObject *obj) { | |
12479 | if (obj) | |
12480 | obj->setDelegate(); | |
12481 | } | |
12482 | ||
12483 | bool isSystem() const { return !!(flags & SYSTEM); } | |
12484 | void setSystem() { flags |= SYSTEM; } | |
12485 | ||
12486 | ||
12487 | ||
12488 | ||
12489 | ||
12490 | ||
12491 | bool branded() { return !!(flags & BRANDED); } | |
12492 | ||
12493 | ||
12494 | ||
12495 | ||
12496 | ||
12497 | ||
12498 | bool brand(JSContext *cx); | |
12499 | bool unbrand(JSContext *cx); | |
12500 | ||
12501 | bool generic() { return !!(flags & GENERIC); } | |
12502 | void setGeneric() { flags |= GENERIC; } | |
12503 | ||
12504 | uintN getMethodThrashCount() const { | |
12505 | return (flags & METHOD_THRASH_COUNT_MASK) >> METHOD_THRASH_COUNT_SHIFT; | |
12506 | } | |
12507 | ||
12508 | void setMethodThrashCount(uintN count) { | |
12509 | ((void) 0); | |
12510 | flags = (flags & ~METHOD_THRASH_COUNT_MASK) | (count << METHOD_THRASH_COUNT_SHIFT); | |
12511 | } | |
12512 | ||
12513 | bool hasSpecialEquality() const { return !!(flags & HAS_EQUALITY); } | |
12514 | void assertSpecialEqualitySynced() const { | |
12515 | ((void) 0); | |
12516 | } | |
12517 | ||
12518 | ||
12519 | inline void syncSpecialEquality(); | |
12520 | ||
12521 | private: | |
12522 | void generateOwnShape(JSContext *cx); | |
12523 | ||
12524 | void setOwnShape(uint32 s) { flags |= OWN_SHAPE; objShape = s; } | |
12525 | void clearOwnShape() { flags &= ~OWN_SHAPE; objShape = map->shape; } | |
12526 | ||
12527 | public: | |
12528 | inline bool nativeEmpty() const; | |
12529 | ||
12530 | bool hasOwnShape() const { return !!(flags & OWN_SHAPE); } | |
12531 | ||
12532 | void setMap(const JSObjectMap *amap) { | |
12533 | ((void) 0); | |
12534 | map = const_cast<JSObjectMap *>(amap); | |
12535 | objShape = map->shape; | |
12536 | } | |
12537 | ||
12538 | void setSharedNonNativeMap() { | |
12539 | setMap(&JSObjectMap::sharedNonNative); | |
12540 | } | |
12541 | ||
12542 | void deletingShapeChange(JSContext *cx, const js::Shape &shape); | |
12543 | const js::Shape *methodShapeChange(JSContext *cx, const js::Shape &shape); | |
12544 | bool methodShapeChange(JSContext *cx, uint32 slot); | |
12545 | void protoShapeChange(JSContext *cx); | |
12546 | void shadowingShapeChange(JSContext *cx, const js::Shape &shape); | |
12547 | bool globalObjectOwnShapeChange(JSContext *cx); | |
12548 | void watchpointOwnShapeChange(JSContext *cx) { generateOwnShape(cx); } | |
12549 | ||
12550 | void extensibleShapeChange(JSContext *cx) { | |
12551 | ||
12552 | generateOwnShape(cx); | |
12553 | } | |
12554 | # 568 "jsobj.h" | |
12555 | bool hasMethodBarrier() { return !!(flags & METHOD_BARRIER); } | |
12556 | void setMethodBarrier() { flags |= METHOD_BARRIER; } | |
12557 | ||
12558 | ||
12559 | ||
12560 | ||
12561 | ||
12562 | ||
12563 | ||
12564 | bool brandedOrHasMethodBarrier() { return !!(flags & (BRANDED | METHOD_BARRIER)); } | |
12565 | ||
12566 | ||
12567 | ||
12568 | ||
12569 | ||
12570 | ||
12571 | const js::Shape *methodReadBarrier(JSContext *cx, const js::Shape &shape, js::Value *vp); | |
12572 | # 593 "jsobj.h" | |
12573 | const js::Shape *methodWriteBarrier(JSContext *cx, const js::Shape &shape, const js::Value &v); | |
12574 | bool methodWriteBarrier(JSContext *cx, uint32 slot, const js::Value &v); | |
12575 | ||
12576 | bool isIndexed() const { return !!(flags & INDEXED); } | |
12577 | void setIndexed() { flags |= INDEXED; } | |
12578 | ||
12579 | ||
12580 | ||
12581 | ||
12582 | ||
12583 | ||
12584 | inline bool inDictionaryMode() const; | |
12585 | ||
12586 | inline uint32 propertyCount() const; | |
12587 | ||
12588 | inline bool hasPropertyTable() const; | |
12589 | ||
12590 | unsigned finalizeKind() const; | |
12591 | ||
12592 | uint32 numSlots() const { return capacity; } | |
12593 | ||
12594 | size_t slotsAndStructSize(uint32 nslots) const; | |
12595 | size_t slotsAndStructSize() const { return slotsAndStructSize(numSlots()); } | |
12596 | ||
12597 | inline js::Value* fixedSlots() const; | |
12598 | inline size_t numFixedSlots() const; | |
12599 | ||
12600 | static inline size_t getFixedSlotOffset(size_t slot); | |
12601 | ||
12602 | public: | |
12603 | ||
12604 | static const uint32 SLOT_CAPACITY_MIN = 8; | |
12605 | ||
12606 | bool allocSlots(JSContext *cx, size_t nslots); | |
12607 | bool growSlots(JSContext *cx, size_t nslots); | |
12608 | void shrinkSlots(JSContext *cx, size_t nslots); | |
12609 | ||
12610 | bool ensureSlots(JSContext *cx, size_t nslots) { | |
12611 | if (numSlots() < nslots) | |
12612 | return growSlots(cx, nslots); | |
12613 | return true; | |
12614 | } | |
12615 | # 652 "jsobj.h" | |
12616 | bool ensureInstanceReservedSlots(JSContext *cx, size_t nreserved); | |
12617 | ||
12618 | ||
12619 | ||
12620 | ||
12621 | ||
12622 | js::Value *getSlots() const { | |
12623 | return slots; | |
12624 | } | |
12625 | ||
12626 | ||
12627 | ||
12628 | ||
12629 | ||
12630 | ||
12631 | bool ensureClassReservedSlotsForEmptyObject(JSContext *cx); | |
12632 | ||
12633 | inline bool ensureClassReservedSlots(JSContext *cx); | |
12634 | ||
12635 | uint32 slotSpan() const { return map->slotSpan; } | |
12636 | ||
12637 | bool containsSlot(uint32 slot) const { return slot < slotSpan(); } | |
12638 | ||
12639 | js::Value& getSlotRef(uintN slot) { | |
12640 | ((void) 0); | |
12641 | return slots[slot]; | |
12642 | } | |
12643 | ||
12644 | js::Value &nativeGetSlotRef(uintN slot) { | |
12645 | ((void) 0); | |
12646 | ((void) 0); | |
12647 | return getSlotRef(slot); | |
12648 | } | |
12649 | ||
12650 | const js::Value &getSlot(uintN slot) const { | |
12651 | ((void) 0); | |
12652 | return slots[slot]; | |
12653 | } | |
12654 | ||
12655 | const js::Value &nativeGetSlot(uintN slot) const { | |
12656 | ((void) 0); | |
12657 | ((void) 0); | |
12658 | return getSlot(slot); | |
12659 | } | |
12660 | ||
12661 | void setSlot(uintN slot, const js::Value &value) { | |
12662 | ((void) 0); | |
12663 | slots[slot] = value; | |
12664 | } | |
12665 | ||
12666 | void nativeSetSlot(uintN slot, const js::Value &value) { | |
12667 | ((void) 0); | |
12668 | ((void) 0); | |
12669 | return setSlot(slot, value); | |
12670 | } | |
12671 | ||
12672 | inline js::Value getReservedSlot(uintN index) const; | |
12673 | ||
12674 | ||
12675 | inline void updateShape(JSContext *cx); | |
12676 | inline void updateFlags(const js::Shape *shape, bool isDefinitelyAtom = false); | |
12677 | ||
12678 | ||
12679 | inline void extend(JSContext *cx, const js::Shape *shape, bool isDefinitelyAtom = false); | |
12680 | ||
12681 | JSObject *getProto() const { return proto; } | |
12682 | void clearProto() { proto = __null; } | |
12683 | ||
12684 | void setProto(JSObject *newProto) { | |
12685 | ||
12686 | ||
12687 | ||
12688 | ||
12689 | setDelegateNullSafe(newProto); | |
12690 | proto = newProto; | |
12691 | } | |
12692 | ||
12693 | JSObject *getParent() const { | |
12694 | return parent; | |
12695 | } | |
12696 | ||
12697 | void clearParent() { | |
12698 | parent = __null; | |
12699 | } | |
12700 | ||
12701 | void setParent(JSObject *newParent) { | |
12702 | ||
12703 | ||
12704 | ||
12705 | ||
12706 | setDelegateNullSafe(newParent); | |
12707 | parent = newParent; | |
12708 | } | |
12709 | ||
12710 | __attribute__((visibility ("default"))) JSObject * getGlobal() const; | |
12711 | ||
12712 | bool isGlobal() const { | |
12713 | return !!(getClass()->flags & (1<<((8 + 8)+2))); | |
12714 | } | |
12715 | ||
12716 | void *getPrivate() const { | |
12717 | ((void) 0); | |
12718 | return privateData; | |
12719 | } | |
12720 | ||
12721 | void setPrivate(void *data) { | |
12722 | ((void) 0); | |
12723 | privateData = data; | |
12724 | } | |
12725 | ||
12726 | ||
12727 | ||
12728 | ||
12729 | ||
12730 | ||
12731 | private: | |
12732 | enum ImmutabilityType { SEAL, FREEZE }; | |
12733 | ||
12734 | ||
12735 | ||
12736 | ||
12737 | ||
12738 | ||
12739 | ||
12740 | bool sealOrFreeze(JSContext *cx, ImmutabilityType it); | |
12741 | ||
12742 | public: | |
12743 | bool isExtensible() const { return !(flags & NOT_EXTENSIBLE); } | |
12744 | bool preventExtensions(JSContext *cx, js::AutoIdVector *props); | |
12745 | ||
12746 | ||
12747 | inline bool seal(JSContext *cx) { return sealOrFreeze(cx, SEAL); } | |
12748 | ||
12749 | bool freeze(JSContext *cx) { return sealOrFreeze(cx, FREEZE); } | |
12750 | ||
12751 | ||
12752 | ||
12753 | ||
12754 | ||
12755 | private: | |
12756 | static const uint32 JSSLOT_PRIMITIVE_THIS = 0; | |
12757 | ||
12758 | public: | |
12759 | inline const js::Value &getPrimitiveThis() const; | |
12760 | inline void setPrimitiveThis(const js::Value &pthis); | |
12761 | ||
12762 | ||
12763 | ||
12764 | ||
12765 | ||
12766 | inline uint32 getArrayLength() const; | |
12767 | inline void setArrayLength(uint32 length); | |
12768 | ||
12769 | inline uint32 getDenseArrayCapacity(); | |
12770 | inline js::Value* getDenseArrayElements(); | |
12771 | inline const js::Value &getDenseArrayElement(uintN idx); | |
12772 | inline js::Value* addressOfDenseArrayElement(uintN idx); | |
12773 | inline void setDenseArrayElement(uintN idx, const js::Value &val); | |
12774 | inline void shrinkDenseArrayElements(JSContext *cx, uintN cap); | |
12775 | # 819 "jsobj.h" | |
12776 | enum EnsureDenseResult { ED_OK, ED_FAILED, ED_SPARSE }; | |
12777 | inline EnsureDenseResult ensureDenseArrayElements(JSContext *cx, uintN index, uintN extra); | |
12778 | ||
12779 | ||
12780 | ||
12781 | ||
12782 | ||
12783 | bool willBeSparseDenseArray(uintN requiredCapacity, uintN newElementsHint); | |
12784 | ||
12785 | JSBool makeDenseArraySlow(JSContext *cx); | |
12786 | ||
12787 | ||
12788 | ||
12789 | ||
12790 | ||
12791 | private: | |
12792 | # 881 "jsobj.h" | |
12793 | static const uint32 JSSLOT_ARGS_DATA = 1; | |
12794 | ||
12795 | public: | |
12796 | ||
12797 | static const uint32 JSSLOT_ARGS_LENGTH = 0; | |
12798 | static const uint32 ARGS_CLASS_RESERVED_SLOTS = 2; | |
12799 | static const uint32 ARGS_FIRST_FREE_SLOT = ARGS_CLASS_RESERVED_SLOTS + 1; | |
12800 | ||
12801 | ||
12802 | static const uint32 ARGS_LENGTH_OVERRIDDEN_BIT = 0x1; | |
12803 | static const uint32 ARGS_PACKED_BITS_COUNT = 1; | |
12804 | ||
12805 | ||
12806 | ||
12807 | ||
12808 | inline void setArgsLength(uint32 argc); | |
12809 | ||
12810 | ||
12811 | ||
12812 | ||
12813 | ||
12814 | inline uint32 getArgsInitialLength() const; | |
12815 | ||
12816 | inline void setArgsLengthOverridden(); | |
12817 | inline bool isArgsLengthOverridden() const; | |
12818 | ||
12819 | inline js::ArgumentsData *getArgsData() const; | |
12820 | inline void setArgsData(js::ArgumentsData *data); | |
12821 | ||
12822 | inline const js::Value &getArgsCallee() const; | |
12823 | inline void setArgsCallee(const js::Value &callee); | |
12824 | ||
12825 | inline const js::Value &getArgsElement(uint32 i) const; | |
12826 | inline js::Value *getArgsElements() const; | |
12827 | inline js::Value *addressOfArgsElement(uint32 i); | |
12828 | inline void setArgsElement(uint32 i, const js::Value &v); | |
12829 | ||
12830 | private: | |
12831 | # 930 "jsobj.h" | |
12832 | static const uint32 JSSLOT_CALL_CALLEE = 0; | |
12833 | static const uint32 JSSLOT_CALL_ARGUMENTS = 1; | |
12834 | ||
12835 | public: | |
12836 | ||
12837 | static const uint32 CALL_RESERVED_SLOTS = 2; | |
12838 | ||
12839 | ||
12840 | inline bool callIsForEval() const; | |
12841 | ||
12842 | ||
12843 | inline JSStackFrame *maybeCallObjStackFrame() const; | |
12844 | ||
12845 | ||
12846 | ||
12847 | ||
12848 | ||
12849 | inline JSObject *getCallObjCallee() const; | |
12850 | inline JSFunction *getCallObjCalleeFunction() const; | |
12851 | inline void setCallObjCallee(JSObject *callee); | |
12852 | ||
12853 | inline const js::Value &getCallObjArguments() const; | |
12854 | inline void setCallObjArguments(const js::Value &v); | |
12855 | ||
12856 | ||
12857 | inline const js::Value &callObjArg(uintN i) const; | |
12858 | inline js::Value &callObjArg(uintN i); | |
12859 | ||
12860 | ||
12861 | inline const js::Value &callObjVar(uintN i) const; | |
12862 | inline js::Value &callObjVar(uintN i); | |
12863 | ||
12864 | ||
12865 | ||
12866 | ||
12867 | ||
12868 | static const uint32 JSSLOT_DATE_UTC_TIME = 0; | |
12869 | ||
12870 | ||
12871 | ||
12872 | ||
12873 | ||
12874 | ||
12875 | static const uint32 JSSLOT_DATE_COMPONENTS_START = 1; | |
12876 | ||
12877 | static const uint32 JSSLOT_DATE_LOCAL_TIME = 1; | |
12878 | static const uint32 JSSLOT_DATE_LOCAL_YEAR = 2; | |
12879 | static const uint32 JSSLOT_DATE_LOCAL_MONTH = 3; | |
12880 | static const uint32 JSSLOT_DATE_LOCAL_DATE = 4; | |
12881 | static const uint32 JSSLOT_DATE_LOCAL_DAY = 5; | |
12882 | static const uint32 JSSLOT_DATE_LOCAL_HOURS = 6; | |
12883 | static const uint32 JSSLOT_DATE_LOCAL_MINUTES = 7; | |
12884 | static const uint32 JSSLOT_DATE_LOCAL_SECONDS = 8; | |
12885 | ||
12886 | static const uint32 DATE_CLASS_RESERVED_SLOTS = 9; | |
12887 | ||
12888 | inline const js::Value &getDateUTCTime() const; | |
12889 | inline void setDateUTCTime(const js::Value &pthis); | |
12890 | ||
12891 | ||
12892 | ||
12893 | ||
12894 | ||
12895 | private: | |
12896 | friend struct JSFunction; | |
12897 | friend class js::mjit::Compiler; | |
12898 | ||
12899 | ||
12900 | ||
12901 | ||
12902 | ||
12903 | static const uint32 JSSLOT_FLAT_CLOSURE_UPVARS = 0; | |
12904 | ||
12905 | ||
12906 | ||
12907 | ||
12908 | ||
12909 | ||
12910 | static const uint32 JSSLOT_FUN_METHOD_ATOM = 0; | |
12911 | static const uint32 JSSLOT_FUN_METHOD_OBJ = 1; | |
12912 | ||
12913 | static const uint32 JSSLOT_BOUND_FUNCTION_THIS = 0; | |
12914 | static const uint32 JSSLOT_BOUND_FUNCTION_ARGS_COUNT = 1; | |
12915 | ||
12916 | public: | |
12917 | static const uint32 FUN_CLASS_RESERVED_SLOTS = 2; | |
12918 | ||
12919 | inline JSFunction *getFunctionPrivate() const; | |
12920 | ||
12921 | inline js::Value *getFlatClosureUpvars() const; | |
12922 | inline js::Value getFlatClosureUpvar(uint32 i) const; | |
12923 | inline js::Value &getFlatClosureUpvar(uint32 i); | |
12924 | inline void setFlatClosureUpvars(js::Value *upvars); | |
12925 | ||
12926 | inline bool hasMethodObj(const JSObject& obj) const; | |
12927 | inline void setMethodObj(JSObject& obj); | |
12928 | ||
12929 | inline bool initBoundFunction(JSContext *cx, const js::Value &thisArg, | |
12930 | const js::Value *args, uintN argslen); | |
12931 | ||
12932 | inline JSObject *getBoundFunctionTarget() const; | |
12933 | inline const js::Value &getBoundFunctionThis() const; | |
12934 | inline const js::Value *getBoundFunctionArguments(uintN &argslen) const; | |
12935 | ||
12936 | ||
12937 | ||
12938 | ||
12939 | ||
12940 | private: | |
12941 | static const uint32 JSSLOT_REGEXP_LAST_INDEX = 0; | |
12942 | ||
12943 | public: | |
12944 | static const uint32 REGEXP_CLASS_RESERVED_SLOTS = 1; | |
12945 | ||
12946 | inline const js::Value &getRegExpLastIndex() const; | |
12947 | inline void setRegExpLastIndex(const js::Value &v); | |
12948 | inline void setRegExpLastIndex(jsdouble d); | |
12949 | inline void zeroRegExpLastIndex(); | |
12950 | ||
12951 | ||
12952 | ||
12953 | ||
12954 | ||
12955 | inline js::NativeIterator *getNativeIterator() const; | |
12956 | inline void setNativeIterator(js::NativeIterator *); | |
12957 | ||
12958 | ||
12959 | ||
12960 | ||
12961 | ||
12962 | inline JSScript *getScript() const; | |
12963 | # 1073 "jsobj.h" | |
12964 | private: | |
12965 | static const uint32 JSSLOT_NAME_PREFIX = 0; | |
12966 | static const uint32 JSSLOT_NAME_URI = 1; | |
12967 | ||
12968 | static const uint32 JSSLOT_NAMESPACE_DECLARED = 2; | |
12969 | ||
12970 | static const uint32 JSSLOT_QNAME_LOCAL_NAME = 2; | |
12971 | ||
12972 | public: | |
12973 | static const uint32 NAMESPACE_CLASS_RESERVED_SLOTS = 3; | |
12974 | static const uint32 QNAME_CLASS_RESERVED_SLOTS = 3; | |
12975 | ||
12976 | inline JSLinearString *getNamePrefix() const; | |
12977 | inline jsval getNamePrefixVal() const; | |
12978 | inline void setNamePrefix(JSLinearString *prefix); | |
12979 | inline void clearNamePrefix(); | |
12980 | ||
12981 | inline JSLinearString *getNameURI() const; | |
12982 | inline jsval getNameURIVal() const; | |
12983 | inline void setNameURI(JSLinearString *uri); | |
12984 | ||
12985 | inline jsval getNamespaceDeclared() const; | |
12986 | inline void setNamespaceDeclared(jsval decl); | |
12987 | ||
12988 | inline JSLinearString *getQNameLocalName() const; | |
12989 | inline jsval getQNameLocalNameVal() const; | |
12990 | inline void setQNameLocalName(JSLinearString *name); | |
12991 | ||
12992 | ||
12993 | ||
12994 | ||
12995 | ||
12996 | inline js::JSProxyHandler *getProxyHandler() const; | |
12997 | inline const js::Value &getProxyPrivate() const; | |
12998 | inline void setProxyPrivate(const js::Value &priv); | |
12999 | inline const js::Value &getProxyExtra() const; | |
13000 | inline void setProxyExtra(const js::Value &extra); | |
13001 | ||
13002 | ||
13003 | ||
13004 | ||
13005 | inline JSObject *getWithThis() const; | |
13006 | inline void setWithThis(JSObject *thisp); | |
13007 | ||
13008 | ||
13009 | ||
13010 | ||
13011 | inline bool isCallable(); | |
13012 | ||
13013 | ||
13014 | void init(JSContext *cx, js::Class *aclasp, JSObject *proto, JSObject *parent, | |
13015 | void *priv, bool useHoles); | |
13016 | ||
13017 | inline void finish(JSContext *cx); | |
13018 | __attribute__((always_inline)) inline void finalize(JSContext *cx); | |
13019 | ||
13020 | ||
13021 | ||
13022 | ||
13023 | ||
13024 | inline bool initSharingEmptyShape(JSContext *cx, | |
13025 | js::Class *clasp, | |
13026 | JSObject *proto, | |
13027 | JSObject *parent, | |
13028 | void *priv, | |
13029 | unsigned kind); | |
13030 | ||
13031 | inline bool hasSlotsArray() const; | |
13032 | ||
13033 | ||
13034 | inline void freeSlotsArray(JSContext *cx); | |
13035 | ||
13036 | ||
13037 | inline void revertToFixedSlots(JSContext *cx); | |
13038 | ||
13039 | inline bool hasProperty(JSContext *cx, jsid id, bool *foundp, uintN flags = 0); | |
13040 | # 1159 "jsobj.h" | |
13041 | bool allocSlot(JSContext *cx, uint32 *slotp); | |
13042 | bool freeSlot(JSContext *cx, uint32 slot); | |
13043 | ||
13044 | public: | |
13045 | bool reportReadOnly(JSContext* cx, jsid id, uintN report = 0x0); | |
13046 | bool reportNotConfigurable(JSContext* cx, jsid id, uintN report = 0x0); | |
13047 | bool reportNotExtensible(JSContext *cx, uintN report = 0x0); | |
13048 | ||
13049 | private: | |
13050 | js::Shape *getChildProperty(JSContext *cx, js::Shape *parent, js::Shape &child); | |
13051 | # 1177 "jsobj.h" | |
13052 | const js::Shape *addPropertyInternal(JSContext *cx, jsid id, | |
13053 | js::PropertyOp getter, js::StrictPropertyOp setter, | |
13054 | uint32 slot, uintN attrs, | |
13055 | uintN flags, intN shortid, | |
13056 | js::Shape **spp); | |
13057 | ||
13058 | bool toDictionaryMode(JSContext *cx); | |
13059 | ||
13060 | public: | |
13061 | ||
13062 | const js::Shape *addProperty(JSContext *cx, jsid id, | |
13063 | js::PropertyOp getter, js::StrictPropertyOp setter, | |
13064 | uint32 slot, uintN attrs, | |
13065 | uintN flags, intN shortid); | |
13066 | ||
13067 | ||
13068 | const js::Shape *addDataProperty(JSContext *cx, jsid id, uint32 slot, uintN attrs) { | |
13069 | ((void) 0); | |
13070 | return addProperty(cx, id, __null, __null, slot, attrs, 0, 0); | |
13071 | } | |
13072 | ||
13073 | ||
13074 | const js::Shape *putProperty(JSContext *cx, jsid id, | |
13075 | js::PropertyOp getter, js::StrictPropertyOp setter, | |
13076 | uint32 slot, uintN attrs, | |
13077 | uintN flags, intN shortid); | |
13078 | ||
13079 | ||
13080 | const js::Shape *changeProperty(JSContext *cx, const js::Shape *shape, uintN attrs, uintN mask, | |
13081 | js::PropertyOp getter, js::StrictPropertyOp setter); | |
13082 | ||
13083 | ||
13084 | bool removeProperty(JSContext *cx, jsid id); | |
13085 | ||
13086 | ||
13087 | void clear(JSContext *cx); | |
13088 | ||
13089 | JSBool lookupProperty(JSContext *cx, jsid id, JSObject **objp, JSProperty **propp) { | |
13090 | js::LookupPropOp op = getOps()->lookupProperty; | |
13091 | return (op ? op : js_LookupProperty)(cx, this, id, objp, propp); | |
13092 | } | |
13093 | ||
13094 | JSBool defineProperty(JSContext *cx, jsid id, const js::Value &value, | |
13095 | js::PropertyOp getter = js::PropertyStub, | |
13096 | js::StrictPropertyOp setter = js::StrictPropertyStub, | |
13097 | uintN attrs = 0x01) { | |
13098 | js::DefinePropOp op = getOps()->defineProperty; | |
13099 | return (op ? op : js_DefineProperty)(cx, this, id, &value, getter, setter, attrs); | |
13100 | } | |
13101 | ||
13102 | JSBool getProperty(JSContext *cx, JSObject *receiver, jsid id, js::Value *vp) { | |
13103 | js::PropertyIdOp op = getOps()->getProperty; | |
13104 | return (op ? op : (js::PropertyIdOp)js_GetProperty)(cx, this, receiver, id, vp); | |
13105 | } | |
13106 | ||
13107 | JSBool getProperty(JSContext *cx, jsid id, js::Value *vp) { | |
13108 | return getProperty(cx, this, id, vp); | |
13109 | } | |
13110 | ||
13111 | JSBool setProperty(JSContext *cx, jsid id, js::Value *vp, JSBool strict) { | |
13112 | js::StrictPropertyIdOp op = getOps()->setProperty; | |
13113 | return (op ? op : js_SetProperty)(cx, this, id, vp, strict); | |
13114 | } | |
13115 | ||
13116 | JSBool getAttributes(JSContext *cx, jsid id, uintN *attrsp) { | |
13117 | js::AttributesOp op = getOps()->getAttributes; | |
13118 | return (op ? op : js_GetAttributes)(cx, this, id, attrsp); | |
13119 | } | |
13120 | ||
13121 | JSBool setAttributes(JSContext *cx, jsid id, uintN *attrsp) { | |
13122 | js::AttributesOp op = getOps()->setAttributes; | |
13123 | return (op ? op : js_SetAttributes)(cx, this, id, attrsp); | |
13124 | } | |
13125 | ||
13126 | JSBool deleteProperty(JSContext *cx, jsid id, js::Value *rval, JSBool strict) { | |
13127 | js::DeleteIdOp op = getOps()->deleteProperty; | |
13128 | return (op ? op : js_DeleteProperty)(cx, this, id, rval, strict); | |
13129 | } | |
13130 | ||
13131 | JSBool enumerate(JSContext *cx, JSIterateOp iterop, js::Value *statep, jsid *idp) { | |
13132 | js::NewEnumerateOp op = getOps()->enumerate; | |
13133 | return (op ? op : js_Enumerate)(cx, this, iterop, statep, idp); | |
13134 | } | |
13135 | ||
13136 | JSType typeOf(JSContext *cx) { | |
13137 | js::TypeOfOp op = getOps()->typeOf; | |
13138 | return (op ? op : js_TypeOf)(cx, this); | |
13139 | } | |
13140 | ||
13141 | ||
13142 | JSObject *thisObject(JSContext *cx) { | |
13143 | JSObjectOp op = getOps()->thisObject; | |
13144 | return op ? op(cx, this) : this; | |
13145 | } | |
13146 | ||
13147 | static bool thisObject(JSContext *cx, const js::Value &v, js::Value *vp); | |
13148 | ||
13149 | inline JSCompartment *getCompartment() const; | |
13150 | ||
13151 | inline JSObject *getThrowTypeError() const; | |
13152 | ||
13153 | __attribute__((visibility ("default"))) JSObject * clone(JSContext *cx, JSObject *proto, JSObject *parent); | |
13154 | __attribute__((visibility ("default"))) bool copyPropertiesFrom(JSContext *cx, JSObject *obj); | |
13155 | bool swap(JSContext *cx, JSObject *other); | |
13156 | ||
13157 | const js::Shape *defineBlockVariable(JSContext *cx, jsid id, intN index); | |
13158 | ||
13159 | inline bool canHaveMethodBarrier() const; | |
13160 | ||
13161 | inline bool isArguments() const; | |
13162 | inline bool isNormalArguments() const; | |
13163 | inline bool isStrictArguments() const; | |
13164 | inline bool isArray() const; | |
13165 | inline bool isDenseArray() const; | |
13166 | inline bool isSlowArray() const; | |
13167 | inline bool isNumber() const; | |
13168 | inline bool isBoolean() const; | |
13169 | inline bool isString() const; | |
13170 | inline bool isPrimitive() const; | |
13171 | inline bool isDate() const; | |
13172 | inline bool isFunction() const; | |
13173 | inline bool isObject() const; | |
13174 | inline bool isWith() const; | |
13175 | inline bool isBlock() const; | |
13176 | inline bool isStaticBlock() const; | |
13177 | inline bool isClonedBlock() const; | |
13178 | inline bool isCall() const; | |
13179 | inline bool isRegExp() const; | |
13180 | inline bool isScript() const; | |
13181 | inline bool isXML() const; | |
13182 | inline bool isXMLId() const; | |
13183 | inline bool isNamespace() const; | |
13184 | inline bool isQName() const; | |
13185 | ||
13186 | inline bool isProxy() const; | |
13187 | inline bool isObjectProxy() const; | |
13188 | inline bool isFunctionProxy() const; | |
13189 | ||
13190 | __attribute__((visibility ("default"))) bool isWrapper() const; | |
13191 | __attribute__((visibility ("default"))) JSObject * unwrap(uintN *flagsp = __null); | |
13192 | ||
13193 | inline void initArrayClass(); | |
13194 | }; | |
13195 | ||
13196 | ||
13197 | typedef int js_static_assert37[(sizeof(JSObject) % sizeof(js::Value) == 0) ? 1 : -1]; | |
13198 | ||
13199 | inline js::Value* | |
13200 | JSObject::fixedSlots() const { | |
13201 | return (js::Value*) (jsuword(this) + sizeof(JSObject)); | |
13202 | } | |
13203 | ||
13204 | inline | |
13205 | ||
13206 | # 1329 "jsobj.h" | |
13207 | bool | |
13208 | JSObject::hasSlotsArray() const { return this->slots != fixedSlots(); } | |
13209 | ||
13210 | inline size_t | |
13211 | JSObject::getFixedSlotOffset(size_t slot) { | |
13212 | return sizeof(JSObject) + (slot * sizeof(js::Value)); | |
13213 | } | |
13214 | ||
13215 | struct JSObject_Slots2 : JSObject { js::Value fslots[2]; }; | |
13216 | struct JSObject_Slots4 : JSObject { js::Value fslots[4]; }; | |
13217 | struct JSObject_Slots8 : JSObject { js::Value fslots[8]; }; | |
13218 | struct JSObject_Slots12 : JSObject { js::Value fslots[12]; }; | |
13219 | struct JSObject_Slots16 : JSObject { js::Value fslots[16]; }; | |
13220 | # 1360 "jsobj.h" | |
13221 | inline void | |
13222 | OBJ_TO_INNER_OBJECT(JSContext *cx, JSObject *&obj) | |
13223 | { | |
13224 | if (JSObjectOp op = obj->getClass()->ext.innerObject) | |
13225 | obj = op(cx, obj); | |
13226 | } | |
13227 | ||
13228 | inline void | |
13229 | OBJ_TO_OUTER_OBJECT(JSContext *cx, JSObject *&obj) | |
13230 | { | |
13231 | if (JSObjectOp op = obj->getClass()->ext.outerObject) | |
13232 | obj = op(cx, obj); | |
13233 | } | |
13234 | ||
13235 | class JSValueArray { | |
13236 | public: | |
13237 | jsval *array; | |
13238 | size_t length; | |
13239 | ||
13240 | JSValueArray(jsval *v, size_t c) : array(v), length(c) {} | |
13241 | }; | |
13242 | ||
13243 | class ValueArray { | |
13244 | public: | |
13245 | js::Value *array; | |
13246 | size_t length; | |
13247 | ||
13248 | ValueArray(js::Value *v, size_t c) : array(v), length(c) {} | |
13249 | }; | |
13250 | ||
13251 | extern js::Class js_ObjectClass; | |
13252 | extern js::Class js_WithClass; | |
13253 | extern js::Class js_BlockClass; | |
13254 | ||
13255 | inline bool JSObject::isObject() const { return getClass() == &js_ObjectClass; } | |
13256 | inline bool JSObject::isWith() const { return getClass() == &js_WithClass; } | |
13257 | inline bool JSObject::isBlock() const { return getClass() == &js_BlockClass; } | |
13258 | # 1413 "jsobj.h" | |
13259 | static const uint32 JSSLOT_BLOCK_DEPTH = 0; | |
13260 | static const uint32 JSSLOT_BLOCK_FIRST_FREE_SLOT = JSSLOT_BLOCK_DEPTH + 1; | |
13261 | ||
13262 | inline | |
13263 | ||
13264 | # 1416 "jsobj.h" | |
13265 | bool | |
13266 | JSObject::isStaticBlock() const | |
13267 | { | |
13268 | return isBlock() && !getProto(); | |
13269 | } | |
13270 | ||
13271 | inline | |
13272 | ||
13273 | # 1422 "jsobj.h" | |
13274 | bool | |
13275 | JSObject::isClonedBlock() const | |
13276 | { | |
13277 | return isBlock() && !!getProto(); | |
13278 | } | |
13279 | ||
13280 | static const uint32 JSSLOT_WITH_THIS = 1; | |
13281 | # 1445 "jsobj.h" | |
13282 | extern JSObject * | |
13283 | js_NewWithObject(JSContext *cx, JSObject *proto, JSObject *parent, jsint depth); | |
13284 | ||
13285 | inline JSObject * | |
13286 | js_UnwrapWithObject(JSContext *cx, JSObject *withobj) | |
13287 | { | |
13288 | ((void) 0); | |
13289 | return withobj->getProto(); | |
13290 | } | |
13291 | ||
13292 | ||
13293 | ||
13294 | ||
13295 | ||
13296 | ||
13297 | ||
13298 | extern JSObject * | |
13299 | js_NewBlockObject(JSContext *cx); | |
13300 | ||
13301 | extern JSObject * | |
13302 | js_CloneBlockObject(JSContext *cx, JSObject *proto, JSStackFrame *fp); | |
13303 | ||
13304 | extern JSBool | |
13305 | js_PutBlockObject(JSContext *cx, JSBool normalUnwind); | |
13306 | ||
13307 | JSBool | |
13308 | js_XDRBlockObject(JSXDRState *xdr, JSObject **objp); | |
13309 | ||
13310 | struct JSSharpObjectMap { | |
13311 | jsrefcount depth; | |
13312 | jsatomid sharpgen; | |
13313 | JSHashTable *table; | |
13314 | }; | |
13315 | # 1488 "jsobj.h" | |
13316 | extern JSHashEntry * | |
13317 | js_EnterSharpObject(JSContext *cx, JSObject *obj, JSIdArray **idap, | |
13318 | jschar **sp); | |
13319 | ||
13320 | extern void | |
13321 | js_LeaveSharpObject(JSContext *cx, JSIdArray **idap); | |
13322 | ||
13323 | ||
13324 | ||
13325 | ||
13326 | ||
13327 | extern void | |
13328 | js_TraceSharpMap(JSTracer *trc, JSSharpObjectMap *map); | |
13329 | ||
13330 | extern JSBool | |
13331 | js_HasOwnPropertyHelper(JSContext *cx, js::LookupPropOp lookup, uintN argc, | |
13332 | js::Value *vp); | |
13333 | ||
13334 | extern JSBool | |
13335 | js_HasOwnProperty(JSContext *cx, js::LookupPropOp lookup, JSObject *obj, jsid id, | |
13336 | JSObject **objp, JSProperty **propp); | |
13337 | ||
13338 | extern JSBool | |
13339 | js_NewPropertyDescriptorObject(JSContext *cx, jsid id, uintN attrs, | |
13340 | const js::Value &getter, const js::Value &setter, | |
13341 | const js::Value &value, js::Value *vp); | |
13342 | ||
13343 | extern JSBool | |
13344 | js_PropertyIsEnumerable(JSContext *cx, JSObject *obj, jsid id, js::Value *vp); | |
13345 | ||
13346 | ||
13347 | __attribute__((visibility ("default"))) JSBool js_obj_defineGetter(JSContext *cx, uintN argc, js::Value *vp); | |
13348 | __attribute__((visibility ("default"))) JSBool js_obj_defineSetter(JSContext *cx, uintN argc, js::Value *vp); | |
13349 | ||
13350 | ||
13351 | extern JSObject * | |
13352 | js_InitObjectClass(JSContext *cx, JSObject *obj); | |
13353 | ||
13354 | namespace js { | |
13355 | JSObject * | |
13356 | DefineConstructorAndPrototype(JSContext *cx, JSObject *obj, JSProtoKey key, JSAtom *atom, | |
13357 | JSObject *protoProto, Class *clasp, | |
13358 | Native constructor, uintN nargs, | |
13359 | JSPropertySpec *ps, JSFunctionSpec *fs, | |
13360 | JSPropertySpec *static_ps, JSFunctionSpec *static_fs); | |
13361 | } | |
13362 | ||
13363 | extern JSObject * | |
13364 | js_InitClass(JSContext *cx, JSObject *obj, JSObject *parent_proto, | |
13365 | js::Class *clasp, js::Native constructor, uintN nargs, | |
13366 | JSPropertySpec *ps, JSFunctionSpec *fs, | |
13367 | JSPropertySpec *static_ps, JSFunctionSpec *static_fs); | |
13368 | ||
13369 | ||
13370 | ||
13371 | ||
13372 | extern const char js_watch_str[]; | |
13373 | extern const char js_unwatch_str[]; | |
13374 | extern const char js_hasOwnProperty_str[]; | |
13375 | extern const char js_isPrototypeOf_str[]; | |
13376 | extern const char js_propertyIsEnumerable_str[]; | |
13377 | ||
13378 | ||
13379 | extern const char js_defineGetter_str[]; | |
13380 | extern const char js_defineSetter_str[]; | |
13381 | extern const char js_lookupGetter_str[]; | |
13382 | extern const char js_lookupSetter_str[]; | |
13383 | ||
13384 | ||
13385 | extern JSBool | |
13386 | js_PopulateObject(JSContext *cx, JSObject *newborn, JSObject *props); | |
13387 | ||
13388 | ||
13389 | ||
13390 | ||
13391 | extern JSBool | |
13392 | js_GetClassObject(JSContext *cx, JSObject *obj, JSProtoKey key, | |
13393 | JSObject **objp); | |
13394 | ||
13395 | extern JSBool | |
13396 | js_SetClassObject(JSContext *cx, JSObject *obj, JSProtoKey key, | |
13397 | JSObject *cobj, JSObject *prototype); | |
13398 | ||
13399 | ||
13400 | ||
13401 | ||
13402 | ||
13403 | extern JSBool | |
13404 | js_FindClassObject(JSContext *cx, JSObject *start, JSProtoKey key, | |
13405 | js::Value *vp, js::Class *clasp = __null); | |
13406 | ||
13407 | extern JSObject * | |
13408 | js_ConstructObject(JSContext *cx, js::Class *clasp, JSObject *proto, | |
13409 | JSObject *parent, uintN argc, js::Value *argv); | |
13410 | ||
13411 | ||
13412 | ||
13413 | extern JSObject * | |
13414 | js_CreateThisForFunctionWithProto(JSContext *cx, JSObject *callee, JSObject *proto); | |
13415 | ||
13416 | ||
13417 | extern JSObject * | |
13418 | js_CreateThisForFunction(JSContext *cx, JSObject *callee); | |
13419 | ||
13420 | ||
13421 | extern JSObject * | |
13422 | js_CreateThis(JSContext *cx, JSObject *callee); | |
13423 | ||
13424 | extern jsid | |
13425 | js_CheckForStringIndex(jsid id); | |
13426 | ||
13427 | ||
13428 | ||
13429 | ||
13430 | ||
13431 | ||
13432 | ||
13433 | extern void | |
13434 | js_PurgeScopeChainHelper(JSContext *cx, JSObject *obj, jsid id); | |
13435 | ||
13436 | inline void | |
13437 | js_PurgeScopeChain(JSContext *cx, JSObject *obj, jsid id) | |
13438 | { | |
13439 | if (obj->isDelegate()) | |
13440 | js_PurgeScopeChainHelper(cx, obj, id); | |
13441 | } | |
13442 | ||
13443 | ||
13444 | ||
13445 | ||
13446 | ||
13447 | extern const js::Shape * | |
13448 | js_AddNativeProperty(JSContext *cx, JSObject *obj, jsid id, | |
13449 | js::PropertyOp getter, js::StrictPropertyOp setter, uint32 slot, | |
13450 | uintN attrs, uintN flags, intN shortid); | |
13451 | ||
13452 | ||
13453 | ||
13454 | ||
13455 | ||
13456 | ||
13457 | extern const js::Shape * | |
13458 | js_ChangeNativePropertyAttrs(JSContext *cx, JSObject *obj, | |
13459 | const js::Shape *shape, uintN attrs, uintN mask, | |
13460 | js::PropertyOp getter, js::StrictPropertyOp setter); | |
13461 | ||
13462 | extern JSBool | |
13463 | js_DefineOwnProperty(JSContext *cx, JSObject *obj, jsid id, | |
13464 | const js::Value &descriptor, JSBool *bp); | |
13465 | ||
13466 | ||
13467 | ||
13468 | ||
13469 | const uintN JSDNP_CACHE_RESULT = 1; | |
13470 | const uintN JSDNP_DONT_PURGE = 2; | |
13471 | const uintN JSDNP_SET_METHOD = 4; | |
13472 | ||
13473 | ||
13474 | const uintN JSDNP_UNQUALIFIED = 8; | |
13475 | # 1655 "jsobj.h" | |
13476 | extern JSBool | |
13477 | js_DefineNativeProperty(JSContext *cx, JSObject *obj, jsid id, const js::Value &value, | |
13478 | js::PropertyOp getter, js::StrictPropertyOp setter, uintN attrs, | |
13479 | uintN flags, intN shortid, JSProperty **propp, | |
13480 | uintN defineHow = 0); | |
13481 | ||
13482 | ||
13483 | ||
13484 | ||
13485 | ||
13486 | ||
13487 | extern int | |
13488 | js_LookupPropertyWithFlags(JSContext *cx, JSObject *obj, jsid id, uintN flags, | |
13489 | JSObject **objp, JSProperty **propp); | |
13490 | ||
13491 | ||
13492 | extern __attribute__((visibility ("default"))) js::Class js_CallClass; | |
13493 | extern __attribute__((visibility ("default"))) js::Class js_DeclEnvClass; | |
13494 | ||
13495 | namespace js { | |
13496 | ||
13497 | ||
13498 | ||
13499 | ||
13500 | ||
13501 | ||
13502 | static inline | |
13503 | ||
13504 | # 1681 "jsobj.h" | |
13505 | bool | |
13506 | IsCacheableNonGlobalScope(JSObject *obj) | |
13507 | { | |
13508 | ((void) 0); | |
13509 | ||
13510 | js::Class *clasp = obj->getClass(); | |
13511 | bool cacheable = (clasp == &js_CallClass || | |
13512 | clasp == &js_BlockClass || | |
13513 | clasp == &js_DeclEnvClass); | |
13514 | ||
13515 | ((void) 0); | |
13516 | return cacheable; | |
13517 | } | |
13518 | ||
13519 | } | |
13520 | ||
13521 | ||
13522 | ||
13523 | ||
13524 | extern js::PropertyCacheEntry * | |
13525 | js_FindPropertyHelper(JSContext *cx, jsid id, JSBool cacheResult, | |
13526 | JSObject **objp, JSObject **pobjp, JSProperty **propp); | |
13527 | ||
13528 | ||
13529 | ||
13530 | ||
13531 | ||
13532 | extern __attribute__((visibility ("default"))) JSBool | |
13533 | js_FindProperty(JSContext *cx, jsid id, JSObject **objp, JSObject **pobjp, | |
13534 | JSProperty **propp); | |
13535 | ||
13536 | extern JSObject * | |
13537 | js_FindIdentifierBase(JSContext *cx, JSObject *scopeChain, jsid id); | |
13538 | ||
13539 | extern JSObject * | |
13540 | js_FindVariableScope(JSContext *cx, JSFunction **funp); | |
13541 | # 1731 "jsobj.h" | |
13542 | const uintN JSGET_CACHE_RESULT = 1; | |
13543 | const uintN JSGET_METHOD_BARRIER = 0; | |
13544 | const uintN JSGET_NO_METHOD_BARRIER = 2; | |
13545 | ||
13546 | ||
13547 | ||
13548 | ||
13549 | ||
13550 | ||
13551 | ||
13552 | extern JSBool | |
13553 | js_NativeGet(JSContext *cx, JSObject *obj, JSObject *pobj, const js::Shape *shape, uintN getHow, | |
13554 | js::Value *vp); | |
13555 | ||
13556 | extern JSBool | |
13557 | js_NativeSet(JSContext *cx, JSObject *obj, const js::Shape *shape, bool added, | |
13558 | bool strict, js::Value *vp); | |
13559 | ||
13560 | extern JSBool | |
13561 | js_GetPropertyHelper(JSContext *cx, JSObject *obj, jsid id, uint32 getHow, js::Value *vp); | |
13562 | ||
13563 | extern | |
13564 | ||
13565 | # 1752 "jsobj.h" | |
13566 | bool | |
13567 | js_GetPropertyHelperWithShape(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, | |
13568 | uint32 getHow, js::Value *vp, | |
13569 | const js::Shape **shapeOut, JSObject **holderOut); | |
13570 | ||
13571 | extern JSBool | |
13572 | js_GetOwnPropertyDescriptor(JSContext *cx, JSObject *obj, jsid id, js::Value *vp); | |
13573 | ||
13574 | extern JSBool | |
13575 | js_GetMethod(JSContext *cx, JSObject *obj, jsid id, uintN getHow, js::Value *vp); | |
13576 | ||
13577 | ||
13578 | ||
13579 | ||
13580 | ||
13581 | ||
13582 | ||
13583 | extern __attribute__((visibility ("default"))) bool | |
13584 | js_CheckUndeclaredVarAssignment(JSContext *cx, JSString *propname); | |
13585 | ||
13586 | extern JSBool | |
13587 | js_SetPropertyHelper(JSContext *cx, JSObject *obj, jsid id, uintN defineHow, | |
13588 | js::Value *vp, JSBool strict); | |
13589 | ||
13590 | ||
13591 | ||
13592 | ||
13593 | ||
13594 | extern JSBool | |
13595 | js_SetNativeAttributes(JSContext *cx, JSObject *obj, js::Shape *shape, | |
13596 | uintN attrs); | |
13597 | ||
13598 | namespace js { | |
13599 | ||
13600 | ||
13601 | ||
13602 | ||
13603 | ||
13604 | extern JSObject * | |
13605 | HasNativeMethod(JSObject *obj, jsid methodid, Native native); | |
13606 | ||
13607 | extern | |
13608 | ||
13609 | # 1793 "jsobj.h" | |
13610 | bool | |
13611 | DefaultValue(JSContext *cx, JSObject *obj, JSType hint, Value *vp); | |
13612 | ||
13613 | extern JSBool | |
13614 | CheckAccess(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode, | |
13615 | js::Value *vp, uintN *attrsp); | |
13616 | ||
13617 | } | |
13618 | ||
13619 | extern | |
13620 | ||
13621 | # 1802 "jsobj.h" | |
13622 | bool | |
13623 | js_IsDelegate(JSContext *cx, JSObject *obj, const js::Value &v); | |
13624 | ||
13625 | ||
13626 | ||
13627 | ||
13628 | ||
13629 | extern __attribute__((visibility ("default"))) JSBool | |
13630 | js_GetClassPrototype(JSContext *cx, JSObject *scope, JSProtoKey protoKey, | |
13631 | JSObject **protop, js::Class *clasp = __null); | |
13632 | ||
13633 | extern JSBool | |
13634 | js_SetClassPrototype(JSContext *cx, JSObject *ctor, JSObject *proto, | |
13635 | uintN attrs); | |
13636 | ||
13637 | ||
13638 | ||
13639 | ||
13640 | ||
13641 | extern JSBool | |
13642 | js_PrimitiveToObject(JSContext *cx, js::Value *vp); | |
13643 | ||
13644 | ||
13645 | ||
13646 | ||
13647 | ||
13648 | extern JSBool | |
13649 | js_ValueToObjectOrNull(JSContext *cx, const js::Value &v, JSObject **objp); | |
13650 | ||
13651 | namespace js { | |
13652 | ||
13653 | ||
13654 | ||
13655 | ||
13656 | ||
13657 | extern JSObject * | |
13658 | ToObjectSlow(JSContext *cx, js::Value *vp); | |
13659 | ||
13660 | __attribute__((always_inline)) inline JSObject * | |
13661 | ToObject(JSContext *cx, js::Value *vp) | |
13662 | { | |
13663 | if (vp->isObject()) | |
13664 | return &vp->toObject(); | |
13665 | return ToObjectSlow(cx, vp); | |
13666 | } | |
13667 | ||
13668 | } | |
13669 | ||
13670 | ||
13671 | ||
13672 | ||
13673 | ||
13674 | extern JSObject * | |
13675 | js_ValueToNonNullObject(JSContext *cx, const js::Value &v); | |
13676 | ||
13677 | extern JSBool | |
13678 | js_TryValueOf(JSContext *cx, JSObject *obj, JSType type, js::Value *rval); | |
13679 | ||
13680 | extern JSBool | |
13681 | js_TryMethod(JSContext *cx, JSObject *obj, JSAtom *atom, | |
13682 | uintN argc, js::Value *argv, js::Value *rval); | |
13683 | ||
13684 | extern JSBool | |
13685 | js_XDRObject(JSXDRState *xdr, JSObject **objp); | |
13686 | ||
13687 | extern void | |
13688 | js_TraceObject(JSTracer *trc, JSObject *obj); | |
13689 | ||
13690 | extern void | |
13691 | js_PrintObjectSlotName(JSTracer *trc, char *buf, size_t bufsize); | |
13692 | ||
13693 | extern void | |
13694 | js_ClearNative(JSContext *cx, JSObject *obj); | |
13695 | ||
13696 | extern | |
13697 | ||
13698 | # 1876 "jsobj.h" | |
13699 | bool | |
13700 | js_GetReservedSlot(JSContext *cx, JSObject *obj, uint32 index, js::Value *vp); | |
13701 | ||
13702 | extern | |
13703 | ||
13704 | # 1879 "jsobj.h" | |
13705 | bool | |
13706 | js_SetReservedSlot(JSContext *cx, JSObject *obj, uint32 index, const js::Value &v); | |
13707 | ||
13708 | extern JSBool | |
13709 | js_CheckPrincipalsAccess(JSContext *cx, JSObject *scopeobj, | |
13710 | JSPrincipals *principals, JSAtom *caller); | |
13711 | ||
13712 | ||
13713 | extern JSBool | |
13714 | js_CheckContentSecurityPolicy(JSContext *cx, JSObject *scopeObj); | |
13715 | ||
13716 | ||
13717 | extern const char * | |
13718 | js_ComputeFilename(JSContext *cx, JSStackFrame *caller, | |
13719 | JSPrincipals *principals, uintN *linenop); | |
13720 | ||
13721 | extern JSBool | |
13722 | js_ReportGetterOnlyAssignment(JSContext *cx); | |
13723 | ||
13724 | extern __attribute__((visibility ("default"))) JSBool | |
13725 | js_GetterOnlyPropertyStub(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp); | |
13726 | # 1911 "jsobj.h" | |
13727 | extern uintN | |
13728 | js_InferFlags(JSContext *cx, uintN defaultFlags); | |
13729 | ||
13730 | ||
13731 | JSBool | |
13732 | js_Object(JSContext *cx, uintN argc, js::Value *vp); | |
13733 | ||
13734 | ||
13735 | namespace js { | |
13736 | ||
13737 | extern | |
13738 | ||
13739 | # 1921 "jsobj.h" | |
13740 | bool | |
13741 | SetProto(JSContext *cx, JSObject *obj, JSObject *proto, bool checkForCycles); | |
13742 | ||
13743 | extern JSString * | |
13744 | obj_toStringHelper(JSContext *cx, JSObject *obj); | |
13745 | ||
13746 | enum EvalType { INDIRECT_EVAL, DIRECT_EVAL }; | |
13747 | # 1939 "jsobj.h" | |
13748 | extern | |
13749 | ||
13750 | # 1939 "jsobj.h" | |
13751 | bool | |
13752 | EvalKernel(JSContext *cx, uintN argc, js::Value *vp, EvalType evalType, JSStackFrame *caller, | |
13753 | JSObject *scopeobj); | |
13754 | ||
13755 | extern __attribute__((visibility ("default"))) bool | |
13756 | IsBuiltinEvalFunction(JSFunction *fun); | |
13757 | ||
13758 | } | |
13759 | # 57 "jsstr.h" 2 | |
13760 | # 69 "jsstr.h" | |
13761 | enum { | |
13762 | UNIT_STRING_LIMIT = 256U, | |
13763 | SMALL_CHAR_LIMIT = 128U, | |
13764 | NUM_SMALL_CHARS = 64U, | |
13765 | INT_STRING_LIMIT = 256U, | |
13766 | NUM_HUNDRED_STRINGS = 156U | |
13767 | }; | |
13768 | ||
13769 | ||
13770 | extern jschar * | |
13771 | js_GetDependentStringChars(JSString *str); | |
13772 | ||
13773 | extern JSString * | |
13774 | js_ConcatStrings(JSContext *cx, JSString *left, JSString *right); | |
13775 | ||
13776 | typedef int js_static_assert38[((8 * 8) >= 32) ? 1 : -1]; | |
13777 | ||
13778 | struct JSRopeBufferInfo { | |
13779 | ||
13780 | size_t capacity; | |
13781 | }; | |
13782 | ||
13783 | ||
13784 | namespace js { namespace mjit { | |
13785 | class Compiler; | |
13786 | }} | |
13787 | ||
13788 | struct JSLinearString; | |
13789 | # 130 "jsstr.h" | |
13790 | struct JSString | |
13791 | { | |
13792 | friend class js::TraceRecorder; | |
13793 | friend class js::mjit::Compiler; | |
13794 | ||
13795 | friend JSAtom *js_AtomizeString(JSContext *cx, JSString *str, uintN flags); | |
13796 | ||
13797 | ||
13798 | ||
13799 | ||
13800 | ||
13801 | size_t lengthAndFlags; | |
13802 | union { | |
13803 | const jschar *chars; | |
13804 | JSString *left; | |
13805 | } u; | |
13806 | union { | |
13807 | jschar inlineStorage[4]; | |
13808 | struct { | |
13809 | union { | |
13810 | JSString *right; | |
13811 | JSString *base; | |
13812 | size_t capacity; | |
13813 | }; | |
13814 | union { | |
13815 | JSString *parent; | |
13816 | size_t reserved; | |
13817 | }; | |
13818 | } s; | |
13819 | size_t externalStringType; | |
13820 | }; | |
13821 | # 174 "jsstr.h" | |
13822 | static const size_t TYPE_FLAGS_MASK = (((JSUint32)1 << (4)) - 1); | |
13823 | static const size_t LENGTH_SHIFT = 4; | |
13824 | ||
13825 | static const size_t TYPE_MASK = (((JSUint32)1 << (2)) - 1); | |
13826 | static const size_t FLAT = 0x0; | |
13827 | static const size_t DEPENDENT = 0x1; | |
13828 | static const size_t ROPE = 0x2; | |
13829 | ||
13830 | ||
13831 | static const size_t DEPENDENT_BIT = ((JSUint32)1 << (0)); | |
13832 | static const size_t ROPE_BIT = ((JSUint32)1 << (1)); | |
13833 | ||
13834 | static const size_t ATOMIZED = ((JSUint32)1 << (2)); | |
13835 | static const size_t EXTENSIBLE = ((JSUint32)1 << (3)); | |
13836 | ||
13837 | ||
13838 | size_t buildLengthAndFlags(size_t length, size_t flags) { | |
13839 | return (length << LENGTH_SHIFT) | flags; | |
13840 | } | |
13841 | ||
13842 | inline js::gc::Cell *asCell() { | |
13843 | return reinterpret_cast<js::gc::Cell *>(this); | |
13844 | } | |
13845 | ||
13846 | inline js::gc::FreeCell *asFreeCell() { | |
13847 | return reinterpret_cast<js::gc::FreeCell *>(this); | |
13848 | } | |
13849 | ||
13850 | ||
13851 | ||
13852 | ||
13853 | ||
13854 | static const size_t MAX_LENGTH = (1 << 28) - 1; | |
13855 | ||
13856 | __attribute__((always_inline)) inline bool isDependent() const { | |
13857 | return lengthAndFlags & DEPENDENT_BIT; | |
13858 | } | |
13859 | ||
13860 | __attribute__((always_inline)) inline bool isFlat() const { | |
13861 | return (lengthAndFlags & TYPE_MASK) == FLAT; | |
13862 | } | |
13863 | ||
13864 | __attribute__((always_inline)) inline bool isExtensible() const { | |
13865 | ((void) 0); | |
13866 | return lengthAndFlags & EXTENSIBLE; | |
13867 | } | |
13868 | ||
13869 | __attribute__((always_inline)) inline bool isAtomized() const { | |
13870 | ((void) 0); | |
13871 | return lengthAndFlags & ATOMIZED; | |
13872 | } | |
13873 | ||
13874 | __attribute__((always_inline)) inline bool isRope() const { | |
13875 | return lengthAndFlags & ROPE_BIT; | |
13876 | } | |
13877 | ||
13878 | __attribute__((always_inline)) inline size_t length() const { | |
13879 | return lengthAndFlags >> LENGTH_SHIFT; | |
13880 | } | |
13881 | ||
13882 | __attribute__((always_inline)) inline bool empty() const { | |
13883 | return lengthAndFlags <= TYPE_FLAGS_MASK; | |
13884 | } | |
13885 | ||
13886 | ||
13887 | __attribute__((always_inline)) inline const jschar *getChars(JSContext *cx) { | |
13888 | if (isRope()) | |
13889 | return flatten(cx); | |
13890 | return nonRopeChars(); | |
13891 | } | |
13892 | ||
13893 | ||
13894 | __attribute__((always_inline)) inline const jschar *getCharsZ(JSContext *cx) { | |
13895 | if (!isFlat()) | |
13896 | return undepend(cx); | |
13897 | return flatChars(); | |
13898 | } | |
13899 | ||
13900 | __attribute__((always_inline)) inline void initFlatNotTerminated(jschar *chars, size_t length) { | |
13901 | ((void) 0); | |
13902 | ((void) 0); | |
13903 | lengthAndFlags = buildLengthAndFlags(length, FLAT); | |
13904 | u.chars = chars; | |
13905 | } | |
13906 | ||
13907 | ||
13908 | __attribute__((always_inline)) inline void initFlat(jschar *chars, size_t length) { | |
13909 | initFlatNotTerminated(chars, length); | |
13910 | ((void) 0); | |
13911 | } | |
13912 | ||
13913 | __attribute__((always_inline)) inline void initShortString(const jschar *chars, size_t length) { | |
13914 | ((void) 0); | |
13915 | ((void) 0); | |
13916 | ((void) 0); | |
13917 | lengthAndFlags = buildLengthAndFlags(length, FLAT); | |
13918 | u.chars = chars; | |
13919 | } | |
13920 | ||
13921 | __attribute__((always_inline)) inline void initFlatExtensible(jschar *chars, size_t length, size_t cap) { | |
13922 | ((void) 0); | |
13923 | ((void) 0); | |
13924 | ((void) 0); | |
13925 | lengthAndFlags = buildLengthAndFlags(length, FLAT | EXTENSIBLE); | |
13926 | u.chars = chars; | |
13927 | s.capacity = cap; | |
13928 | } | |
13929 | ||
13930 | __attribute__((always_inline)) inline JSFlatString *assertIsFlat() { | |
13931 | ((void) 0); | |
13932 | return reinterpret_cast<JSFlatString *>(this); | |
13933 | } | |
13934 | ||
13935 | __attribute__((always_inline)) inline const jschar *flatChars() const { | |
13936 | ((void) 0); | |
13937 | return u.chars; | |
13938 | } | |
13939 | ||
13940 | __attribute__((always_inline)) inline size_t flatLength() const { | |
13941 | ((void) 0); | |
13942 | return length(); | |
13943 | } | |
13944 | ||
13945 | inline void flatSetAtomized() { | |
13946 | ((void) 0); | |
13947 | ((void) 0); | |
13948 | lengthAndFlags |= ATOMIZED; | |
13949 | } | |
13950 | ||
13951 | inline void flatClearExtensible() { | |
13952 | ||
13953 | ||
13954 | ||
13955 | ||
13956 | ((void) 0); | |
13957 | if (lengthAndFlags & EXTENSIBLE) | |
13958 | lengthAndFlags &= ~EXTENSIBLE; | |
13959 | } | |
13960 | ||
13961 | ||
13962 | ||
13963 | ||
13964 | ||
13965 | inline void initDependent(JSString *base, const jschar *chars, size_t length) { | |
13966 | ((void) 0); | |
13967 | ((void) 0); | |
13968 | ((void) 0); | |
13969 | ((void) 0); | |
13970 | lengthAndFlags = buildLengthAndFlags(length, DEPENDENT); | |
13971 | u.chars = chars; | |
13972 | s.base = base; | |
13973 | } | |
13974 | ||
13975 | inline JSLinearString *dependentBase() const { | |
13976 | ((void) 0); | |
13977 | return s.base->assertIsLinear(); | |
13978 | } | |
13979 | ||
13980 | __attribute__((always_inline)) inline const jschar *dependentChars() { | |
13981 | ((void) 0); | |
13982 | return u.chars; | |
13983 | } | |
13984 | ||
13985 | inline size_t dependentLength() const { | |
13986 | ((void) 0); | |
13987 | return length(); | |
13988 | } | |
13989 | ||
13990 | const jschar *undepend(JSContext *cx); | |
13991 | ||
13992 | const jschar *nonRopeChars() const { | |
13993 | ((void) 0); | |
13994 | return u.chars; | |
13995 | } | |
13996 | ||
13997 | ||
13998 | inline void initRopeNode(JSString *left, JSString *right, size_t length) { | |
13999 | ((void) 0); | |
14000 | lengthAndFlags = buildLengthAndFlags(length, ROPE); | |
14001 | u.left = left; | |
14002 | s.right = right; | |
14003 | } | |
14004 | ||
14005 | inline JSString *ropeLeft() const { | |
14006 | ((void) 0); | |
14007 | return u.left; | |
14008 | } | |
14009 | ||
14010 | inline JSString *ropeRight() const { | |
14011 | ((void) 0); | |
14012 | return s.right; | |
14013 | } | |
14014 | ||
14015 | inline void finishTraversalConversion(JSString *base, const jschar *baseBegin, const jschar *end) { | |
14016 | ((void) 0); | |
14017 | lengthAndFlags = buildLengthAndFlags(end - u.chars, DEPENDENT); | |
14018 | s.base = base; | |
14019 | } | |
14020 | ||
14021 | const jschar *flatten(JSContext *maybecx); | |
14022 | ||
14023 | JSLinearString *ensureLinear(JSContext *cx) { | |
14024 | if (isRope() && !flatten(cx)) | |
14025 | return __null; | |
14026 | return reinterpret_cast<JSLinearString *>(this); | |
14027 | } | |
14028 | ||
14029 | bool isLinear() const { | |
14030 | return !isRope(); | |
14031 | } | |
14032 | ||
14033 | JSLinearString *assertIsLinear() { | |
14034 | ((void) 0); | |
14035 | return reinterpret_cast<JSLinearString *>(this); | |
14036 | } | |
14037 | ||
14038 | typedef uint8 SmallChar; | |
14039 | ||
14040 | static inline bool fitsInSmallChar(jschar c) { | |
14041 | ||
14042 | return c < SMALL_CHAR_LIMIT && toSmallChar[c] != INVALID_SMALL_CHAR; | |
14043 | ||
14044 | ||
14045 | ||
14046 | } | |
14047 | ||
14048 | static inline bool isUnitString(void *ptr) { | |
14049 | ||
14050 | jsuword delta = reinterpret_cast<jsuword>(ptr) - | |
14051 | reinterpret_cast<jsuword>(unitStringTable); | |
14052 | if (delta >= UNIT_STRING_LIMIT * sizeof(JSString)) | |
14053 | return false; | |
14054 | ||
14055 | ||
14056 | ((void) 0); | |
14057 | return true; | |
14058 | ||
14059 | ||
14060 | ||
14061 | } | |
14062 | ||
14063 | static inline bool isLength2String(void *ptr) { | |
14064 | ||
14065 | jsuword delta = reinterpret_cast<jsuword>(ptr) - | |
14066 | reinterpret_cast<jsuword>(length2StringTable); | |
14067 | if (delta >= NUM_SMALL_CHARS * NUM_SMALL_CHARS * sizeof(JSString)) | |
14068 | return false; | |
14069 | ||
14070 | ||
14071 | ((void) 0); | |
14072 | return true; | |
14073 | ||
14074 | ||
14075 | ||
14076 | } | |
14077 | ||
14078 | static inline bool isHundredString(void *ptr) { | |
14079 | ||
14080 | jsuword delta = reinterpret_cast<jsuword>(ptr) - | |
14081 | reinterpret_cast<jsuword>(hundredStringTable); | |
14082 | if (delta >= NUM_HUNDRED_STRINGS * sizeof(JSString)) | |
14083 | return false; | |
14084 | ||
14085 | ||
14086 | ((void) 0); | |
14087 | return true; | |
14088 | ||
14089 | ||
14090 | ||
14091 | } | |
14092 | ||
14093 | static inline bool isStatic(void *ptr) { | |
14094 | return isUnitString(ptr) || isLength2String(ptr) || isHundredString(ptr); | |
14095 | } | |
14096 | ||
14097 | ||
14098 | ||
14099 | ||
14100 | ||
14101 | ||
14102 | static const SmallChar INVALID_SMALL_CHAR = -1; | |
14103 | ||
14104 | static const jschar fromSmallChar[]; | |
14105 | static const SmallChar toSmallChar[]; | |
14106 | static const JSString unitStringTable[]; | |
14107 | static const JSString length2StringTable[]; | |
14108 | static const JSString hundredStringTable[]; | |
14109 | ||
14110 | ||
14111 | ||
14112 | ||
14113 | static const JSString *const intStringTable[]; | |
14114 | ||
14115 | ||
14116 | static JSFlatString *unitString(jschar c); | |
14117 | static JSLinearString *getUnitString(JSContext *cx, JSString *str, size_t index); | |
14118 | static JSFlatString *length2String(jschar c1, jschar c2); | |
14119 | static JSFlatString *length2String(uint32 i); | |
14120 | static JSFlatString *intString(jsint i); | |
14121 | ||
14122 | static JSFlatString *lookupStaticString(const jschar *chars, size_t length); | |
14123 | ||
14124 | __attribute__((always_inline)) inline void finalize(JSContext *cx); | |
14125 | ||
14126 | static size_t offsetOfLengthAndFlags() { | |
14127 | return __builtin_offsetof (JSString, lengthAndFlags); | |
14128 | } | |
14129 | ||
14130 | static size_t offsetOfChars() { | |
14131 | return __builtin_offsetof (JSString, u.chars); | |
14132 | } | |
14133 | ||
14134 | static void staticAsserts() { | |
14135 | typedef int js_static_assert39[(((JSString::MAX_LENGTH << JSString::LENGTH_SHIFT) >> JSString::LENGTH_SHIFT) == JSString::MAX_LENGTH) ? 1 : -1] | |
14136 | ; | |
14137 | } | |
14138 | }; | |
14139 | ||
14140 | ||
14141 | ||
14142 | ||
14143 | ||
14144 | ||
14145 | struct JSLinearString : JSString | |
14146 | { | |
14147 | const jschar *chars() const { return JSString::nonRopeChars(); } | |
14148 | }; | |
14149 | ||
14150 | typedef int js_static_assert40[(sizeof(JSLinearString) == sizeof(JSString)) ? 1 : -1]; | |
14151 | ||
14152 | ||
14153 | ||
14154 | ||
14155 | ||
14156 | struct JSFlatString : JSLinearString | |
14157 | { | |
14158 | const jschar *charsZ() const { return chars(); } | |
14159 | }; | |
14160 | ||
14161 | typedef int js_static_assert41[(sizeof(JSFlatString) == sizeof(JSString)) ? 1 : -1]; | |
14162 | ||
14163 | ||
14164 | ||
14165 | ||
14166 | ||
14167 | struct JSAtom : JSFlatString | |
14168 | { | |
14169 | }; | |
14170 | ||
14171 | struct JSExternalString : JSString | |
14172 | { | |
14173 | static const uintN TYPE_LIMIT = 8; | |
14174 | static JSStringFinalizeOp str_finalizers[TYPE_LIMIT]; | |
14175 | ||
14176 | static intN changeFinalizer(JSStringFinalizeOp oldop, | |
14177 | JSStringFinalizeOp newop) { | |
14178 | for (uintN i = 0; i != (sizeof (str_finalizers) / sizeof (str_finalizers)[0]); i++) { | |
14179 | if (str_finalizers[i] == oldop) { | |
14180 | str_finalizers[i] = newop; | |
14181 | return intN(i); | |
14182 | } | |
14183 | } | |
14184 | return -1; | |
14185 | } | |
14186 | ||
14187 | void finalize(JSContext *cx); | |
14188 | void finalize(); | |
14189 | }; | |
14190 | ||
14191 | typedef int js_static_assert42[(sizeof(JSString) == sizeof(JSExternalString)) ? 1 : -1]; | |
14192 | ||
14193 | ||
14194 | ||
14195 | ||
14196 | ||
14197 | ||
14198 | class JSShortString : public js::gc::Cell | |
14199 | { | |
14200 | JSString mHeader; | |
14201 | JSString mDummy; | |
14202 | ||
14203 | public: | |
14204 | ||
14205 | ||
14206 | ||
14207 | ||
14208 | ||
14209 | inline jschar *init(size_t length) { | |
14210 | ((void) 0); | |
14211 | mHeader.initShortString(mHeader.inlineStorage, length); | |
14212 | return mHeader.inlineStorage; | |
14213 | } | |
14214 | ||
14215 | inline jschar *getInlineStorageBeforeInit() { | |
14216 | return mHeader.inlineStorage; | |
14217 | } | |
14218 | ||
14219 | inline void initAtOffsetInBuffer(jschar *p, size_t length) { | |
14220 | ((void) 0); | |
14221 | mHeader.initShortString(p, length); | |
14222 | } | |
14223 | ||
14224 | inline void resetLength(size_t length) { | |
14225 | mHeader.initShortString(mHeader.flatChars(), length); | |
14226 | } | |
14227 | ||
14228 | inline JSString *header() { | |
14229 | return &mHeader; | |
14230 | } | |
14231 | ||
14232 | static const size_t FREE_STRING_WORDS = 2; | |
14233 | ||
14234 | static const size_t MAX_SHORT_STRING_LENGTH = | |
14235 | ((sizeof(JSString) + FREE_STRING_WORDS * sizeof(size_t)) / sizeof(jschar)) - 1; | |
14236 | ||
14237 | static inline bool fitsIntoShortString(size_t length) { | |
14238 | return length <= MAX_SHORT_STRING_LENGTH; | |
14239 | } | |
14240 | ||
14241 | __attribute__((always_inline)) inline void finalize(JSContext *cx); | |
14242 | ||
14243 | static void staticAsserts() { | |
14244 | typedef int js_static_assert43[(__builtin_offsetof (JSString, inlineStorage) == sizeof(JSString) - JSShortString::FREE_STRING_WORDS * sizeof(void *)) ? 1 : -1] | |
14245 | ; | |
14246 | typedef int js_static_assert44[(__builtin_offsetof (JSShortString, mDummy) == sizeof(JSString)) ? 1 : -1]; | |
14247 | typedef int js_static_assert45[(__builtin_offsetof (JSString, inlineStorage) + sizeof(jschar) * (JSShortString::MAX_SHORT_STRING_LENGTH + 1) == sizeof(JSShortString)) ? 1 : -1] | |
14248 | ||
14249 | ; | |
14250 | } | |
14251 | }; | |
14252 | ||
14253 | namespace js { | |
14254 | ||
14255 | class StringBuffer; | |
14256 | # 616 "jsstr.h" | |
14257 | class StringSegmentRange; | |
14258 | class MutatingRopeSegmentRange; | |
14259 | ||
14260 | ||
14261 | ||
14262 | ||
14263 | class RopeBuilder; | |
14264 | ||
14265 | } | |
14266 | ||
14267 | extern const jschar * | |
14268 | js_GetStringChars(JSContext *cx, JSString *str); | |
14269 | ||
14270 | extern const jschar * | |
14271 | js_UndependString(JSContext *cx, JSString *str); | |
14272 | ||
14273 | extern JSBool | |
14274 | js_MakeStringImmutable(JSContext *cx, JSString *str); | |
14275 | ||
14276 | extern JSString * | |
14277 | js_toLowerCase(JSContext *cx, JSString *str); | |
14278 | ||
14279 | extern JSString * | |
14280 | js_toUpperCase(JSContext *cx, JSString *str); | |
14281 | ||
14282 | struct JSSubString { | |
14283 | size_t length; | |
14284 | const jschar *chars; | |
14285 | }; | |
14286 | ||
14287 | extern jschar js_empty_ucstr[]; | |
14288 | extern JSSubString js_EmptySubString; | |
14289 | ||
14290 | ||
14291 | extern const uint8 js_X[]; | |
14292 | extern const uint8 js_Y[]; | |
14293 | extern const uint32 js_A[]; | |
14294 | ||
14295 | ||
14296 | typedef enum JSCharType { | |
14297 | JSCT_UNASSIGNED = 0, | |
14298 | JSCT_UPPERCASE_LETTER = 1, | |
14299 | JSCT_LOWERCASE_LETTER = 2, | |
14300 | JSCT_TITLECASE_LETTER = 3, | |
14301 | JSCT_MODIFIER_LETTER = 4, | |
14302 | JSCT_OTHER_LETTER = 5, | |
14303 | JSCT_NON_SPACING_MARK = 6, | |
14304 | JSCT_ENCLOSING_MARK = 7, | |
14305 | JSCT_COMBINING_SPACING_MARK = 8, | |
14306 | JSCT_DECIMAL_DIGIT_NUMBER = 9, | |
14307 | JSCT_LETTER_NUMBER = 10, | |
14308 | JSCT_OTHER_NUMBER = 11, | |
14309 | JSCT_SPACE_SEPARATOR = 12, | |
14310 | JSCT_LINE_SEPARATOR = 13, | |
14311 | JSCT_PARAGRAPH_SEPARATOR = 14, | |
14312 | JSCT_CONTROL = 15, | |
14313 | JSCT_FORMAT = 16, | |
14314 | JSCT_PRIVATE_USE = 18, | |
14315 | JSCT_SURROGATE = 19, | |
14316 | JSCT_DASH_PUNCTUATION = 20, | |
14317 | JSCT_START_PUNCTUATION = 21, | |
14318 | JSCT_END_PUNCTUATION = 22, | |
14319 | JSCT_CONNECTOR_PUNCTUATION = 23, | |
14320 | JSCT_OTHER_PUNCTUATION = 24, | |
14321 | JSCT_MATH_SYMBOL = 25, | |
14322 | JSCT_CURRENCY_SYMBOL = 26, | |
14323 | JSCT_MODIFIER_SYMBOL = 27, | |
14324 | JSCT_OTHER_SYMBOL = 28 | |
14325 | } JSCharType; | |
14326 | # 737 "jsstr.h" | |
14327 | extern const bool js_alnum[]; | |
14328 | # 760 "jsstr.h" | |
14329 | const jschar BYTE_ORDER_MARK = 0xFEFF; | |
14330 | const jschar NO_BREAK_SPACE = 0x00A0; | |
14331 | ||
14332 | static inline | |
14333 | ||
14334 | # 763 "jsstr.h" | |
14335 | bool | |
14336 | JS_ISSPACE(jschar c) | |
14337 | { | |
14338 | unsigned w = c; | |
14339 | ||
14340 | if (w < 256) | |
14341 | return (w <= ' ' && (w == ' ' || (9 <= w && w <= 0xD))) || w == NO_BREAK_SPACE; | |
14342 | ||
14343 | return w == BYTE_ORDER_MARK || ((js_A[js_Y[(js_X[(uint16)(w)>>6]<<6)|((w)&0x3F)]]) & 0x00070000) == 0x00040000; | |
14344 | } | |
14345 | # 797 "jsstr.h" | |
14346 | extern js::Class js_StringClass; | |
14347 | ||
14348 | inline | |
14349 | ||
14350 | # 799 "jsstr.h" | |
14351 | bool | |
14352 | JSObject::isString() const | |
14353 | { | |
14354 | return getClass() == &js_StringClass; | |
14355 | } | |
14356 | ||
14357 | extern JSObject * | |
14358 | js_InitStringClass(JSContext *cx, JSObject *obj); | |
14359 | ||
14360 | extern const char js_escape_str[]; | |
14361 | extern const char js_unescape_str[]; | |
14362 | extern const char js_uneval_str[]; | |
14363 | extern const char js_decodeURI_str[]; | |
14364 | extern const char js_encodeURI_str[]; | |
14365 | extern const char js_decodeURIComponent_str[]; | |
14366 | extern const char js_encodeURIComponent_str[]; | |
14367 | ||
14368 | ||
14369 | extern JSFlatString * | |
14370 | js_NewString(JSContext *cx, jschar *chars, size_t length); | |
14371 | ||
14372 | extern JSLinearString * | |
14373 | js_NewDependentString(JSContext *cx, JSString *base, size_t start, | |
14374 | size_t length); | |
14375 | ||
14376 | ||
14377 | extern JSFlatString * | |
14378 | js_NewStringCopyN(JSContext *cx, const jschar *s, size_t n); | |
14379 | ||
14380 | extern JSFlatString * | |
14381 | js_NewStringCopyN(JSContext *cx, const char *s, size_t n); | |
14382 | ||
14383 | ||
14384 | extern JSFlatString * | |
14385 | js_NewStringCopyZ(JSContext *cx, const jschar *s); | |
14386 | ||
14387 | extern JSFlatString * | |
14388 | js_NewStringCopyZ(JSContext *cx, const char *s); | |
14389 | ||
14390 | ||
14391 | ||
14392 | ||
14393 | extern const char * | |
14394 | js_ValueToPrintable(JSContext *cx, const js::Value &, | |
14395 | JSAutoByteString *bytes, bool asSource = false); | |
14396 | ||
14397 | ||
14398 | ||
14399 | ||
14400 | ||
14401 | extern JSString * | |
14402 | js_ValueToString(JSContext *cx, const js::Value &v); | |
14403 | ||
14404 | namespace js { | |
14405 | ||
14406 | ||
14407 | ||
14408 | ||
14409 | ||
14410 | ||
14411 | static __attribute__((always_inline)) inline JSString * | |
14412 | ValueToString_TestForStringInline(JSContext *cx, const Value &v) | |
14413 | { | |
14414 | if (v.isString()) | |
14415 | return v.toString(); | |
14416 | return js_ValueToString(cx, v); | |
14417 | } | |
14418 | ||
14419 | ||
14420 | ||
14421 | ||
14422 | ||
14423 | ||
14424 | extern | |
14425 | ||
14426 | # 872 "jsstr.h" | |
14427 | bool | |
14428 | ValueToStringBuffer(JSContext *cx, const Value &v, StringBuffer &sb); | |
14429 | ||
14430 | } | |
14431 | ||
14432 | ||
14433 | ||
14434 | ||
14435 | ||
14436 | extern __attribute__((visibility ("default"))) JSString * | |
14437 | js_ValueToSource(JSContext *cx, const js::Value &v); | |
14438 | ||
14439 | ||
14440 | ||
14441 | ||
14442 | ||
14443 | inline uint32 | |
14444 | js_HashString(JSLinearString *str) | |
14445 | { | |
14446 | const jschar *s = str->chars(); | |
14447 | size_t n = str->length(); | |
14448 | uint32 h; | |
14449 | for (h = 0; n; s++, n--) | |
14450 | h = (((h) << (4)) | ((h) >> (32 - (4)))) ^ *s; | |
14451 | return h; | |
14452 | } | |
14453 | ||
14454 | namespace js { | |
14455 | ||
14456 | ||
14457 | ||
14458 | ||
14459 | ||
14460 | extern | |
14461 | ||
14462 | # 905 "jsstr.h" | |
14463 | bool | |
14464 | EqualStrings(JSContext *cx, JSString *str1, JSString *str2, JSBool *result); | |
14465 | ||
14466 | ||
14467 | extern | |
14468 | ||
14469 | # 909 "jsstr.h" | |
14470 | bool | |
14471 | EqualStrings(JSLinearString *str1, JSLinearString *str2); | |
14472 | ||
14473 | ||
14474 | ||
14475 | ||
14476 | ||
14477 | extern | |
14478 | ||
14479 | # 916 "jsstr.h" | |
14480 | bool | |
14481 | CompareStrings(JSContext *cx, JSString *str1, JSString *str2, int32 *result); | |
14482 | ||
14483 | ||
14484 | ||
14485 | ||
14486 | extern | |
14487 | ||
14488 | # 922 "jsstr.h" | |
14489 | bool | |
14490 | StringEqualsAscii(JSLinearString *str, const char *asciiBytes); | |
14491 | ||
14492 | } | |
14493 | ||
14494 | ||
14495 | ||
14496 | ||
14497 | ||
14498 | ||
14499 | ||
14500 | static const jsuint sBMHCharSetSize = 256; | |
14501 | static const jsuint sBMHPatLenMax = 255; | |
14502 | static const jsint sBMHBadPattern = -2; | |
14503 | ||
14504 | extern jsint | |
14505 | js_BoyerMooreHorspool(const jschar *text, jsuint textlen, | |
14506 | const jschar *pat, jsuint patlen); | |
14507 | ||
14508 | extern size_t | |
14509 | js_strlen(const jschar *s); | |
14510 | ||
14511 | extern jschar * | |
14512 | js_strchr(const jschar *s, jschar c); | |
14513 | ||
14514 | extern jschar * | |
14515 | js_strchr_limit(const jschar *s, jschar c, const jschar *limit); | |
14516 | ||
14517 | ||
14518 | ||
14519 | inline void | |
14520 | js_short_strncpy(jschar *dest, const jschar *src, size_t num) | |
14521 | { | |
14522 | ||
14523 | ||
14524 | ||
14525 | ||
14526 | ((void) 0); | |
14527 | for (size_t i = 0; i < num; i++) | |
14528 | dest[i] = src[i]; | |
14529 | } | |
14530 | ||
14531 | ||
14532 | ||
14533 | ||
14534 | static inline const jschar * | |
14535 | js_SkipWhiteSpace(const jschar *s, const jschar *end) | |
14536 | { | |
14537 | ((void) 0); | |
14538 | while (s != end && JS_ISSPACE(*s)) | |
14539 | s++; | |
14540 | return s; | |
14541 | } | |
14542 | ||
14543 | ||
14544 | ||
14545 | ||
14546 | ||
14547 | ||
14548 | extern jschar * | |
14549 | js_InflateString(JSContext *cx, const char *bytes, size_t *length); | |
14550 | ||
14551 | extern char * | |
14552 | js_DeflateString(JSContext *cx, const jschar *chars, size_t length); | |
14553 | ||
14554 | ||
14555 | ||
14556 | ||
14557 | ||
14558 | ||
14559 | ||
14560 | extern JSBool | |
14561 | js_InflateStringToBuffer(JSContext *cx, const char *bytes, size_t length, | |
14562 | jschar *chars, size_t *charsLength); | |
14563 | ||
14564 | ||
14565 | ||
14566 | ||
14567 | extern JSBool | |
14568 | js_InflateUTF8StringToBuffer(JSContext *cx, const char *bytes, size_t length, | |
14569 | jschar *chars, size_t *charsLength); | |
14570 | ||
14571 | ||
14572 | ||
14573 | ||
14574 | ||
14575 | extern size_t | |
14576 | js_GetDeflatedStringLength(JSContext *cx, const jschar *chars, | |
14577 | size_t charsLength); | |
14578 | ||
14579 | ||
14580 | ||
14581 | ||
14582 | extern size_t | |
14583 | js_GetDeflatedUTF8StringLength(JSContext *cx, const jschar *chars, | |
14584 | size_t charsLength); | |
14585 | ||
14586 | ||
14587 | ||
14588 | ||
14589 | ||
14590 | ||
14591 | ||
14592 | extern JSBool | |
14593 | js_DeflateStringToBuffer(JSContext *cx, const jschar *chars, | |
14594 | size_t charsLength, char *bytes, size_t *length); | |
14595 | ||
14596 | ||
14597 | ||
14598 | ||
14599 | extern JSBool | |
14600 | js_DeflateStringToUTF8Buffer(JSContext *cx, const jschar *chars, | |
14601 | size_t charsLength, char *bytes, size_t *length); | |
14602 | ||
14603 | ||
14604 | extern JSBool | |
14605 | js_str_escape(JSContext *cx, uintN argc, js::Value *argv, js::Value *rval); | |
14606 | ||
14607 | ||
14608 | ||
14609 | ||
14610 | ||
14611 | namespace js { | |
14612 | extern JSBool | |
14613 | str_replace(JSContext *cx, uintN argc, js::Value *vp); | |
14614 | } | |
14615 | ||
14616 | extern JSBool | |
14617 | js_str_toString(JSContext *cx, uintN argc, js::Value *vp); | |
14618 | ||
14619 | extern JSBool | |
14620 | js_str_charAt(JSContext *cx, uintN argc, js::Value *vp); | |
14621 | ||
14622 | extern JSBool | |
14623 | js_str_charCodeAt(JSContext *cx, uintN argc, js::Value *vp); | |
14624 | ||
14625 | ||
14626 | ||
14627 | ||
14628 | ||
14629 | extern int | |
14630 | js_OneUcs4ToUtf8Char(uint8 *utf8Buffer, uint32 ucs4Char); | |
14631 | ||
14632 | namespace js { | |
14633 | ||
14634 | extern size_t | |
14635 | PutEscapedStringImpl(char *buffer, size_t size, FILE *fp, JSLinearString *str, uint32 quote); | |
14636 | # 1079 "jsstr.h" | |
14637 | inline size_t | |
14638 | PutEscapedString(char *buffer, size_t size, JSLinearString *str, uint32 quote) | |
14639 | { | |
14640 | size_t n = PutEscapedStringImpl(buffer, size, __null, str, quote); | |
14641 | ||
14642 | ||
14643 | ((void) 0); | |
14644 | return n; | |
14645 | } | |
14646 | ||
14647 | ||
14648 | ||
14649 | ||
14650 | ||
14651 | ||
14652 | inline | |
14653 | ||
14654 | # 1094 "jsstr.h" | |
14655 | bool | |
14656 | FileEscapedString(FILE *fp, JSLinearString *str, uint32 quote) | |
14657 | { | |
14658 | return PutEscapedStringImpl(__null, 0, fp, str, quote) != size_t(-1); | |
14659 | } | |
14660 | ||
14661 | } | |
14662 | ||
14663 | extern JSBool | |
14664 | js_String(JSContext *cx, uintN argc, js::Value *vp); | |
14665 | # 53 "jsatom.h" 2 | |
14666 | # 68 "jsatom.h" | |
14667 | static __attribute__((always_inline)) inline jsid | |
14668 | JSID_FROM_BITS(size_t bits) | |
14669 | { | |
14670 | jsid id; | |
14671 | (id) = bits; | |
14672 | return id; | |
14673 | } | |
14674 | ||
14675 | static __attribute__((always_inline)) inline jsid | |
14676 | ATOM_TO_JSID(JSAtom *atom) | |
14677 | { | |
14678 | ((void) 0); | |
14679 | return JSID_FROM_BITS((size_t)atom); | |
14680 | } | |
14681 | ||
14682 | ||
14683 | static __attribute__((always_inline)) inline JSBool | |
14684 | JSID_IS_ATOM(jsid id) | |
14685 | { | |
14686 | return JSID_IS_STRING(id); | |
14687 | } | |
14688 | ||
14689 | static __attribute__((always_inline)) inline JSBool | |
14690 | JSID_IS_ATOM(jsid id, JSAtom *atom) | |
14691 | { | |
14692 | return (id) == (ATOM_TO_JSID(atom)); | |
14693 | } | |
14694 | ||
14695 | static __attribute__((always_inline)) inline JSAtom * | |
14696 | JSID_TO_ATOM(jsid id) | |
14697 | { | |
14698 | return (JSAtom *)JSID_TO_STRING(id); | |
14699 | } | |
14700 | ||
14701 | namespace js { | |
14702 | ||
14703 | static __attribute__((always_inline)) inline Value | |
14704 | IdToValue(jsid id) | |
14705 | { | |
14706 | if (JSID_IS_STRING(id)) | |
14707 | return StringValue(JSID_TO_STRING(id)); | |
14708 | if ((__builtin_expect((JSID_IS_INT(id)), 1))) | |
14709 | return Int32Value(JSID_TO_INT(id)); | |
14710 | if ((__builtin_expect((JSID_IS_OBJECT(id)), 1))) | |
14711 | return ObjectValue(*JSID_TO_OBJECT(id)); | |
14712 | ((void) 0); | |
14713 | return UndefinedValue(); | |
14714 | } | |
14715 | ||
14716 | static __attribute__((always_inline)) inline jsval | |
14717 | IdToJsval(jsid id) | |
14718 | { | |
14719 | return Jsvalify(IdToValue(id)); | |
14720 | } | |
14721 | ||
14722 | } | |
14723 | # 138 "jsatom.h" | |
14724 | extern const char * | |
14725 | js_AtomToPrintableString(JSContext *cx, JSAtom *atom, JSAutoByteString *bytes); | |
14726 | ||
14727 | struct JSAtomListElement { | |
14728 | JSHashEntry entry; | |
14729 | }; | |
14730 | # 172 "jsatom.h" | |
14731 | struct JSAtomSet { | |
14732 | JSHashEntry *list; | |
14733 | JSHashTable *table; | |
14734 | jsuint count; | |
14735 | }; | |
14736 | ||
14737 | struct JSAtomList : public JSAtomSet | |
14738 | { | |
14739 | ||
14740 | ||
14741 | ||
14742 | ||
14743 | JSAtomList() { | |
14744 | list = __null; table = __null; count = 0; | |
14745 | ||
14746 | ||
14747 | ||
14748 | } | |
14749 | ||
14750 | JSAtomList(const JSAtomSet& as) { | |
14751 | list = as.list; table = as.table; count = as.count; | |
14752 | ||
14753 | ||
14754 | ||
14755 | } | |
14756 | ||
14757 | void clear() { ((void) 0); list = __null; table = __null; count = 0; } | |
14758 | ||
14759 | JSAtomListElement *lookup(JSAtom *atom) { | |
14760 | JSHashEntry **hep; | |
14761 | return rawLookup(atom, hep); | |
14762 | } | |
14763 | ||
14764 | JSAtomListElement *rawLookup(JSAtom *atom, JSHashEntry **&hep); | |
14765 | ||
14766 | enum AddHow { UNIQUE, SHADOW, HOIST }; | |
14767 | ||
14768 | JSAtomListElement *add(js::Parser *parser, JSAtom *atom, AddHow how = UNIQUE); | |
14769 | ||
14770 | void remove(js::Parser *parser, JSAtom *atom) { | |
14771 | JSHashEntry **hep; | |
14772 | JSAtomListElement *ale = rawLookup(atom, hep); | |
14773 | if (ale) | |
14774 | rawRemove(parser, ale, hep); | |
14775 | } | |
14776 | ||
14777 | void rawRemove(js::Parser *parser, JSAtomListElement *ale, JSHashEntry **hep); | |
14778 | }; | |
14779 | ||
14780 | ||
14781 | ||
14782 | ||
14783 | ||
14784 | struct JSAutoAtomList: public JSAtomList | |
14785 | { | |
14786 | JSAutoAtomList(js::Parser *p): parser(p) {} | |
14787 | ~JSAutoAtomList(); | |
14788 | private: | |
14789 | js::Parser *parser; | |
14790 | }; | |
14791 | ||
14792 | ||
14793 | ||
14794 | ||
14795 | ||
14796 | ||
14797 | ||
14798 | class JSAtomListIterator { | |
14799 | JSAtomList* list; | |
14800 | JSAtomListElement* next; | |
14801 | uint32 index; | |
14802 | ||
14803 | public: | |
14804 | JSAtomListIterator(JSAtomList* al) : list(al) { reset(); } | |
14805 | ||
14806 | void reset() { | |
14807 | next = (JSAtomListElement *) list->list; | |
14808 | index = 0; | |
14809 | } | |
14810 | ||
14811 | JSAtomListElement* operator ()(); | |
14812 | }; | |
14813 | ||
14814 | struct JSAtomMap { | |
14815 | JSAtom **vector; | |
14816 | jsatomid length; | |
14817 | }; | |
14818 | ||
14819 | namespace js { | |
14820 | ||
14821 | ||
14822 | ||
14823 | typedef int js_static_assert46[(((size_t)(0x1 | 0x2)) < JS_GCTHING_ALIGN) ? 1 : -1]; | |
14824 | ||
14825 | typedef uintptr_t AtomEntryType; | |
14826 | ||
14827 | static __attribute__((always_inline)) inline JSAtom * | |
14828 | AtomEntryToKey(AtomEntryType entry) | |
14829 | { | |
14830 | ((void) 0); | |
14831 | return (JSAtom *)(entry & ~((size_t)(0x1 | 0x2))); | |
14832 | } | |
14833 | ||
14834 | struct AtomHasher | |
14835 | { | |
14836 | typedef JSLinearString *Lookup; | |
14837 | ||
14838 | static HashNumber hash(JSLinearString *str) { | |
14839 | return js_HashString(str); | |
14840 | } | |
14841 | ||
14842 | static bool match(AtomEntryType entry, JSLinearString *lookup) { | |
14843 | return entry ? EqualStrings(AtomEntryToKey(entry), lookup) : false; | |
14844 | } | |
14845 | }; | |
14846 | ||
14847 | typedef HashSet<AtomEntryType, AtomHasher, SystemAllocPolicy> AtomSet; | |
14848 | ||
14849 | } | |
14850 | ||
14851 | struct JSAtomState | |
14852 | { | |
14853 | js::AtomSet atoms; | |
14854 | ||
14855 | ||
14856 | JSThinLock lock; | |
14857 | # 311 "jsatom.h" | |
14858 | JSAtom *emptyAtom; | |
14859 | ||
14860 | ||
14861 | ||
14862 | ||
14863 | ||
14864 | JSAtom *booleanAtoms[2]; | |
14865 | JSAtom *typeAtoms[JSTYPE_LIMIT]; | |
14866 | JSAtom *nullAtom; | |
14867 | ||
14868 | ||
14869 | JSAtom *classAtoms[JSProto_LIMIT]; | |
14870 | ||
14871 | ||
14872 | JSAtom *anonymousAtom; | |
14873 | JSAtom *applyAtom; | |
14874 | JSAtom *argumentsAtom; | |
14875 | JSAtom *arityAtom; | |
14876 | JSAtom *callAtom; | |
14877 | JSAtom *calleeAtom; | |
14878 | JSAtom *callerAtom; | |
14879 | JSAtom *classPrototypeAtom; | |
14880 | JSAtom *constructorAtom; | |
14881 | JSAtom *eachAtom; | |
14882 | JSAtom *evalAtom; | |
14883 | JSAtom *fileNameAtom; | |
14884 | JSAtom *getAtom; | |
14885 | JSAtom *globalAtom; | |
14886 | JSAtom *ignoreCaseAtom; | |
14887 | JSAtom *indexAtom; | |
14888 | JSAtom *inputAtom; | |
14889 | JSAtom *toISOStringAtom; | |
14890 | JSAtom *iteratorAtom; | |
14891 | JSAtom *joinAtom; | |
14892 | JSAtom *lastIndexAtom; | |
14893 | JSAtom *lengthAtom; | |
14894 | JSAtom *lineNumberAtom; | |
14895 | JSAtom *messageAtom; | |
14896 | JSAtom *multilineAtom; | |
14897 | JSAtom *nameAtom; | |
14898 | JSAtom *nextAtom; | |
14899 | JSAtom *noSuchMethodAtom; | |
14900 | JSAtom *objectNullAtom; | |
14901 | JSAtom *objectUndefinedAtom; | |
14902 | JSAtom *protoAtom; | |
14903 | JSAtom *setAtom; | |
14904 | JSAtom *sourceAtom; | |
14905 | JSAtom *stackAtom; | |
14906 | JSAtom *stickyAtom; | |
14907 | JSAtom *toGMTStringAtom; | |
14908 | JSAtom *toLocaleStringAtom; | |
14909 | JSAtom *toSourceAtom; | |
14910 | JSAtom *toStringAtom; | |
14911 | JSAtom *toUTCStringAtom; | |
14912 | JSAtom *valueOfAtom; | |
14913 | JSAtom *toJSONAtom; | |
14914 | JSAtom *void0Atom; | |
14915 | JSAtom *enumerableAtom; | |
14916 | JSAtom *configurableAtom; | |
14917 | JSAtom *writableAtom; | |
14918 | JSAtom *valueAtom; | |
14919 | JSAtom *testAtom; | |
14920 | JSAtom *useStrictAtom; | |
14921 | JSAtom *locAtom; | |
14922 | JSAtom *lineAtom; | |
14923 | JSAtom *InfinityAtom; | |
14924 | JSAtom *NaNAtom; | |
14925 | JSAtom *builderAtom; | |
14926 | ||
14927 | ||
14928 | JSAtom *etagoAtom; | |
14929 | JSAtom *namespaceAtom; | |
14930 | JSAtom *ptagcAtom; | |
14931 | JSAtom *qualifierAtom; | |
14932 | JSAtom *spaceAtom; | |
14933 | JSAtom *stagoAtom; | |
14934 | JSAtom *starAtom; | |
14935 | JSAtom *starQualifierAtom; | |
14936 | JSAtom *tagcAtom; | |
14937 | JSAtom *xmlAtom; | |
14938 | ||
14939 | ||
14940 | JSAtom *functionNamespaceURIAtom; | |
14941 | ||
14942 | ||
14943 | JSAtom *ProxyAtom; | |
14944 | ||
14945 | JSAtom *getOwnPropertyDescriptorAtom; | |
14946 | JSAtom *getPropertyDescriptorAtom; | |
14947 | JSAtom *definePropertyAtom; | |
14948 | JSAtom *deleteAtom; | |
14949 | JSAtom *getOwnPropertyNamesAtom; | |
14950 | JSAtom *enumerateAtom; | |
14951 | JSAtom *fixAtom; | |
14952 | ||
14953 | JSAtom *hasAtom; | |
14954 | JSAtom *hasOwnAtom; | |
14955 | JSAtom *keysAtom; | |
14956 | JSAtom *iterateAtom; | |
14957 | ||
14958 | ||
14959 | struct { | |
14960 | JSAtom *XMLListAtom; | |
14961 | JSAtom *decodeURIAtom; | |
14962 | JSAtom *decodeURIComponentAtom; | |
14963 | JSAtom *defineGetterAtom; | |
14964 | JSAtom *defineSetterAtom; | |
14965 | JSAtom *encodeURIAtom; | |
14966 | JSAtom *encodeURIComponentAtom; | |
14967 | JSAtom *escapeAtom; | |
14968 | JSAtom *hasOwnPropertyAtom; | |
14969 | JSAtom *isFiniteAtom; | |
14970 | JSAtom *isNaNAtom; | |
14971 | JSAtom *isPrototypeOfAtom; | |
14972 | JSAtom *isXMLNameAtom; | |
14973 | JSAtom *lookupGetterAtom; | |
14974 | JSAtom *lookupSetterAtom; | |
14975 | JSAtom *parseFloatAtom; | |
14976 | JSAtom *parseIntAtom; | |
14977 | JSAtom *propertyIsEnumerableAtom; | |
14978 | JSAtom *unescapeAtom; | |
14979 | JSAtom *unevalAtom; | |
14980 | JSAtom *unwatchAtom; | |
14981 | JSAtom *watchAtom; | |
14982 | } lazy; | |
14983 | }; | |
14984 | # 460 "jsatom.h" | |
14985 | extern const char *const js_common_atom_names[]; | |
14986 | extern const size_t js_common_atom_count; | |
14987 | # 471 "jsatom.h" | |
14988 | # 1 "jsproto.tbl" 1 | |
14989 | # 39 "jsproto.tbl" | |
14990 | # 1 "jsversion.h" 1 | |
14991 | # 40 "jsproto.tbl" 2 | |
14992 | # 64 "jsproto.tbl" | |
14993 | extern const char js_Null_str[]; | |
14994 | extern const char js_Object_str[]; | |
14995 | extern const char js_Function_str[]; | |
14996 | extern const char js_Array_str[]; | |
14997 | extern const char js_Boolean_str[]; | |
14998 | extern const char js_JSON_str[]; | |
14999 | extern const char js_Date_str[]; | |
15000 | extern const char js_Math_str[]; | |
15001 | extern const char js_Number_str[]; | |
15002 | extern const char js_String_str[]; | |
15003 | extern const char js_RegExp_str[]; | |
15004 | extern const char js_XML_str[]; | |
15005 | extern const char js_Namespace_str[]; | |
15006 | extern const char js_QName_str[]; | |
15007 | extern const char js_Reflect_str[]; | |
15008 | extern const char js_ASTNode_str[]; | |
15009 | extern const char js_Error_str[]; | |
15010 | extern const char js_InternalError_str[]; | |
15011 | extern const char js_EvalError_str[]; | |
15012 | extern const char js_RangeError_str[]; | |
15013 | extern const char js_ReferenceError_str[]; | |
15014 | extern const char js_SyntaxError_str[]; | |
15015 | extern const char js_TypeError_str[]; | |
15016 | extern const char js_URIError_str[]; | |
15017 | extern const char js_Generator_str[]; | |
15018 | extern const char js_Iterator_str[]; | |
15019 | extern const char js_StopIteration_str[]; | |
15020 | extern const char js_ArrayBuffer_str[]; | |
15021 | extern const char js_Int8Array_str[]; | |
15022 | extern const char js_Uint8Array_str[]; | |
15023 | extern const char js_Int16Array_str[]; | |
15024 | extern const char js_Uint16Array_str[]; | |
15025 | extern const char js_Int32Array_str[]; | |
15026 | extern const char js_Uint32Array_str[]; | |
15027 | extern const char js_Float32Array_str[]; | |
15028 | extern const char js_Float64Array_str[]; | |
15029 | extern const char js_Uint8ClampedArray_str[]; | |
15030 | extern const char js_Proxy_str[]; | |
15031 | extern const char js_AnyName_str[]; | |
15032 | # 472 "jsatom.h" 2 | |
15033 | ||
15034 | ||
15035 | extern const char js_anonymous_str[]; | |
15036 | extern const char js_apply_str[]; | |
15037 | extern const char js_arguments_str[]; | |
15038 | extern const char js_arity_str[]; | |
15039 | extern const char js_call_str[]; | |
15040 | extern const char js_callee_str[]; | |
15041 | extern const char js_caller_str[]; | |
15042 | extern const char js_class_prototype_str[]; | |
15043 | extern const char js_close_str[]; | |
15044 | extern const char js_constructor_str[]; | |
15045 | extern const char js_count_str[]; | |
15046 | extern const char js_etago_str[]; | |
15047 | extern const char js_each_str[]; | |
15048 | extern const char js_eval_str[]; | |
15049 | extern const char js_fileName_str[]; | |
15050 | extern const char js_get_str[]; | |
15051 | extern const char js_getter_str[]; | |
15052 | extern const char js_global_str[]; | |
15053 | extern const char js_ignoreCase_str[]; | |
15054 | extern const char js_index_str[]; | |
15055 | extern const char js_input_str[]; | |
15056 | extern const char js_iterator_str[]; | |
15057 | extern const char js_join_str[]; | |
15058 | extern const char js_lastIndex_str[]; | |
15059 | extern const char js_length_str[]; | |
15060 | extern const char js_lineNumber_str[]; | |
15061 | extern const char js_message_str[]; | |
15062 | extern const char js_multiline_str[]; | |
15063 | extern const char js_name_str[]; | |
15064 | extern const char js_namespace_str[]; | |
15065 | extern const char js_next_str[]; | |
15066 | extern const char js_noSuchMethod_str[]; | |
15067 | extern const char js_object_str[]; | |
15068 | extern const char js_proto_str[]; | |
15069 | extern const char js_ptagc_str[]; | |
15070 | extern const char js_qualifier_str[]; | |
15071 | extern const char js_send_str[]; | |
15072 | extern const char js_setter_str[]; | |
15073 | extern const char js_set_str[]; | |
15074 | extern const char js_source_str[]; | |
15075 | extern const char js_space_str[]; | |
15076 | extern const char js_stack_str[]; | |
15077 | extern const char js_sticky_str[]; | |
15078 | extern const char js_stago_str[]; | |
15079 | extern const char js_star_str[]; | |
15080 | extern const char js_starQualifier_str[]; | |
15081 | extern const char js_tagc_str[]; | |
15082 | extern const char js_toGMTString_str[]; | |
15083 | extern const char js_toLocaleString_str[]; | |
15084 | extern const char js_toSource_str[]; | |
15085 | extern const char js_toString_str[]; | |
15086 | extern const char js_toUTCString_str[]; | |
15087 | extern const char js_undefined_str[]; | |
15088 | extern const char js_valueOf_str[]; | |
15089 | extern const char js_toJSON_str[]; | |
15090 | extern const char js_xml_str[]; | |
15091 | extern const char js_enumerable_str[]; | |
15092 | extern const char js_configurable_str[]; | |
15093 | extern const char js_writable_str[]; | |
15094 | extern const char js_value_str[]; | |
15095 | extern const char js_test_str[]; | |
15096 | ||
15097 | ||
15098 | ||
15099 | ||
15100 | ||
15101 | ||
15102 | extern JSBool | |
15103 | js_InitAtomState(JSRuntime *rt); | |
15104 | ||
15105 | ||
15106 | ||
15107 | ||
15108 | ||
15109 | extern void | |
15110 | js_FinishAtomState(JSRuntime *rt); | |
15111 | ||
15112 | ||
15113 | ||
15114 | ||
15115 | ||
15116 | extern void | |
15117 | js_TraceAtomState(JSTracer *trc); | |
15118 | ||
15119 | extern void | |
15120 | js_SweepAtomState(JSContext *cx); | |
15121 | ||
15122 | extern JSBool | |
15123 | js_InitCommonAtoms(JSContext *cx); | |
15124 | ||
15125 | extern void | |
15126 | js_FinishCommonAtoms(JSContext *cx); | |
15127 | ||
15128 | ||
15129 | ||
15130 | ||
15131 | ||
15132 | extern JSAtom * | |
15133 | js_AtomizeString(JSContext *cx, JSString *str, uintN flags); | |
15134 | ||
15135 | extern JSAtom * | |
15136 | js_Atomize(JSContext *cx, const char *bytes, size_t length, uintN flags); | |
15137 | ||
15138 | extern JSAtom * | |
15139 | js_AtomizeChars(JSContext *cx, const jschar *chars, size_t length, uintN flags); | |
15140 | ||
15141 | ||
15142 | ||
15143 | ||
15144 | ||
15145 | extern JSAtom * | |
15146 | js_GetExistingStringAtom(JSContext *cx, const jschar *chars, size_t length); | |
15147 | # 594 "jsatom.h" | |
15148 | inline | |
15149 | ||
15150 | # 594 "jsatom.h" | |
15151 | bool | |
15152 | js_ValueToAtom(JSContext *cx, const js::Value &v, JSAtom **atomp); | |
15153 | ||
15154 | inline | |
15155 | ||
15156 | # 597 "jsatom.h" | |
15157 | bool | |
15158 | js_ValueToStringId(JSContext *cx, const js::Value &v, jsid *idp); | |
15159 | ||
15160 | inline | |
15161 | ||
15162 | # 600 "jsatom.h" | |
15163 | bool | |
15164 | js_InternNonIntElementId(JSContext *cx, JSObject *obj, const js::Value &idval, | |
15165 | jsid *idp); | |
15166 | inline | |
15167 | ||
15168 | # 603 "jsatom.h" | |
15169 | bool | |
15170 | js_InternNonIntElementId(JSContext *cx, JSObject *obj, const js::Value &idval, | |
15171 | jsid *idp, js::Value *vp); | |
15172 | ||
15173 | ||
15174 | ||
15175 | ||
15176 | ||
15177 | extern void | |
15178 | js_InitAtomMap(JSContext *cx, JSAtomMap *map, JSAtomList *al); | |
15179 | # 48 "jsarray.h" 2 | |
15180 | ||
15181 | ||
15182 | ||
15183 | ||
15184 | const uintN MIN_SPARSE_INDEX = 256; | |
15185 | ||
15186 | inline JSObject::EnsureDenseResult | |
15187 | JSObject::ensureDenseArrayElements(JSContext *cx, uintN index, uintN extra) | |
15188 | { | |
15189 | ((void) 0); | |
15190 | uintN currentCapacity = numSlots(); | |
15191 | ||
15192 | uintN requiredCapacity; | |
15193 | if (extra == 1) { | |
15194 | ||
15195 | if (index < currentCapacity) | |
15196 | return ED_OK; | |
15197 | requiredCapacity = index + 1; | |
15198 | if (requiredCapacity == 0) { | |
15199 | ||
15200 | return ED_SPARSE; | |
15201 | } | |
15202 | } else { | |
15203 | requiredCapacity = index + extra; | |
15204 | if (requiredCapacity < index) { | |
15205 | ||
15206 | return ED_SPARSE; | |
15207 | } | |
15208 | if (requiredCapacity <= currentCapacity) | |
15209 | return ED_OK; | |
15210 | } | |
15211 | ||
15212 | ||
15213 | ||
15214 | ||
15215 | ||
15216 | if (requiredCapacity > MIN_SPARSE_INDEX && | |
15217 | willBeSparseDenseArray(requiredCapacity, extra)) { | |
15218 | return ED_SPARSE; | |
15219 | } | |
15220 | return growSlots(cx, requiredCapacity) ? ED_OK : ED_FAILED; | |
15221 | } | |
15222 | ||
15223 | extern | |
15224 | ||
15225 | # 91 "jsarray.h" | |
15226 | bool | |
15227 | js_StringIsIndex(JSLinearString *str, jsuint *indexp); | |
15228 | ||
15229 | inline JSBool | |
15230 | js_IdIsIndex(jsid id, jsuint *indexp) | |
15231 | { | |
15232 | if (JSID_IS_INT(id)) { | |
15233 | jsint i; | |
15234 | i = JSID_TO_INT(id); | |
15235 | if (i < 0) | |
15236 | return (JSIntn)0; | |
15237 | *indexp = (jsuint)i; | |
15238 | return (JSIntn)1; | |
15239 | } | |
15240 | ||
15241 | if ((__builtin_expect((!JSID_IS_STRING(id)), 0))) | |
15242 | return (JSIntn)0; | |
15243 | ||
15244 | return js_StringIsIndex(JSID_TO_ATOM(id), indexp); | |
15245 | } | |
15246 | ||
15247 | ||
15248 | inline | |
15249 | ||
15250 | # 113 "jsarray.h" | |
15251 | bool | |
15252 | js_IdValIsIndex(JSContext *cx, jsval id, jsuint *indexp, bool *isIndex) | |
15253 | { | |
15254 | if (JSVAL_IS_INT(id)) { | |
15255 | jsint i; | |
15256 | i = JSVAL_TO_INT(id); | |
15257 | if (i < 0) { | |
15258 | *isIndex = false; | |
15259 | return true; | |
15260 | } | |
15261 | *indexp = (jsuint)i; | |
15262 | *isIndex = true; | |
15263 | return true; | |
15264 | } | |
15265 | ||
15266 | if (!JSVAL_IS_STRING(id)) { | |
15267 | *isIndex = false; | |
15268 | return true; | |
15269 | } | |
15270 | ||
15271 | JSLinearString *str = JSVAL_TO_STRING(id)->ensureLinear(cx); | |
15272 | if (!str) | |
15273 | return false; | |
15274 | ||
15275 | *isIndex = js_StringIsIndex(str, indexp); | |
15276 | return true; | |
15277 | } | |
15278 | ||
15279 | extern js::Class js_ArrayClass, js_SlowArrayClass; | |
15280 | ||
15281 | inline | |
15282 | ||
15283 | # 143 "jsarray.h" | |
15284 | bool | |
15285 | JSObject::isDenseArray() const | |
15286 | { | |
15287 | return getClass() == &js_ArrayClass; | |
15288 | } | |
15289 | ||
15290 | inline | |
15291 | ||
15292 | # 149 "jsarray.h" | |
15293 | bool | |
15294 | JSObject::isSlowArray() const | |
15295 | { | |
15296 | return getClass() == &js_SlowArrayClass; | |
15297 | } | |
15298 | ||
15299 | inline | |
15300 | ||
15301 | # 155 "jsarray.h" | |
15302 | bool | |
15303 | JSObject::isArray() const | |
15304 | { | |
15305 | return isDenseArray() || isSlowArray(); | |
15306 | } | |
15307 | # 180 "jsarray.h" | |
15308 | static inline JSObject * | |
15309 | js_GetProtoIfDenseArray(JSObject *obj) | |
15310 | { | |
15311 | return obj->isDenseArray() ? obj->getProto() : obj; | |
15312 | } | |
15313 | ||
15314 | extern JSObject * | |
15315 | js_InitArrayClass(JSContext *cx, JSObject *obj); | |
15316 | ||
15317 | extern | |
15318 | ||
15319 | # 189 "jsarray.h" | |
15320 | bool | |
15321 | js_InitContextBusyArrayTable(JSContext *cx); | |
15322 | ||
15323 | namespace js | |
15324 | { | |
15325 | ||
15326 | ||
15327 | extern JSObject * | |
15328 | NewDenseEmptyArray(JSContext *cx, JSObject *proto=__null); | |
15329 | ||
15330 | ||
15331 | extern JSObject * | |
15332 | NewDenseAllocatedArray(JSContext *cx, uint length, JSObject *proto=__null); | |
15333 | ||
15334 | ||
15335 | ||
15336 | ||
15337 | ||
15338 | extern JSObject * | |
15339 | NewDenseUnallocatedArray(JSContext *cx, uint length, JSObject *proto=__null); | |
15340 | ||
15341 | ||
15342 | extern JSObject * | |
15343 | NewDenseCopiedArray(JSContext *cx, uint length, Value *vp, JSObject *proto=__null); | |
15344 | ||
15345 | ||
15346 | extern JSObject * | |
15347 | NewSlowEmptyArray(JSContext *cx); | |
15348 | ||
15349 | } | |
15350 | ||
15351 | extern JSBool | |
15352 | js_GetLengthProperty(JSContext *cx, JSObject *obj, jsuint *lengthp); | |
15353 | ||
15354 | extern JSBool | |
15355 | js_SetLengthProperty(JSContext *cx, JSObject *obj, jsdouble length); | |
15356 | ||
15357 | extern JSBool | |
15358 | js_HasLengthProperty(JSContext *cx, JSObject *obj, jsuint *lengthp); | |
15359 | ||
15360 | extern JSBool | |
15361 | js_IndexToId(JSContext *cx, jsuint index, jsid *idp); | |
15362 | ||
15363 | namespace js { | |
15364 | ||
15365 | ||
15366 | ||
15367 | ||
15368 | ||
15369 | extern | |
15370 | ||
15371 | # 238 "jsarray.h" | |
15372 | bool | |
15373 | GetElements(JSContext *cx, JSObject *aobj, jsuint length, js::Value *vp); | |
15374 | ||
15375 | } | |
15376 | ||
15377 | ||
15378 | ||
15379 | ||
15380 | typedef JSBool (*JSComparator)(void *arg, const void *a, const void *b, | |
15381 | int *result); | |
15382 | ||
15383 | enum JSMergeSortElemType { | |
15384 | JS_SORTING_VALUES, | |
15385 | JS_SORTING_GENERIC | |
15386 | }; | |
15387 | # 264 "jsarray.h" | |
15388 | extern | |
15389 | ||
15390 | # 264 "jsarray.h" | |
15391 | bool | |
15392 | js_MergeSort(void *vec, size_t nel, size_t elsize, JSComparator cmp, | |
15393 | void *arg, void *tmp, JSMergeSortElemType elemType); | |
15394 | ||
15395 | ||
15396 | ||
15397 | ||
15398 | ||
15399 | namespace js { | |
15400 | extern JSBool | |
15401 | array_sort(JSContext *cx, uintN argc, js::Value *vp); | |
15402 | } | |
15403 | ||
15404 | ||
15405 | ||
15406 | ||
15407 | ||
15408 | ||
15409 | extern JSBool | |
15410 | js_ArrayCompPush(JSContext *cx, JSObject *obj, const js::Value &vp); | |
15411 | # 301 "jsarray.h" | |
15412 | __attribute__((visibility ("default"))) JSBool | |
15413 | js_CoerceArrayToCanvasImageData(JSObject *obj, jsuint offset, jsuint count, | |
15414 | JSUint8 *dest); | |
15415 | ||
15416 | JSBool | |
15417 | js_PrototypeHasIndexedProperties(JSContext *cx, JSObject *obj); | |
15418 | ||
15419 | ||
15420 | ||
15421 | ||
15422 | JSBool | |
15423 | js_GetDenseArrayElementValue(JSContext *cx, JSObject *obj, jsid id, | |
15424 | js::Value *vp); | |
15425 | ||
15426 | ||
15427 | JSBool | |
15428 | js_Array(JSContext *cx, uintN argc, js::Value *vp); | |
15429 | # 329 "jsarray.h" | |
15430 | __attribute__((visibility ("default"))) JSBool | |
15431 | js_CloneDensePrimitiveArray(JSContext *cx, JSObject *obj, JSObject **clone); | |
15432 | ||
15433 | ||
15434 | ||
15435 | ||
15436 | ||
15437 | __attribute__((visibility ("default"))) JSBool | |
15438 | js_IsDensePrimitiveArray(JSObject *obj); | |
15439 | ||
15440 | extern JSBool | |
15441 | js_EnsureDenseArrayCapacity(JSContext *cx, JSObject *obj, jsint i); | |
15442 | # 54 "jsxml.cpp" 2 | |
15443 | ||
15444 | # 1 "jsbool.h" 1 | |
15445 | # 50 "jsbool.h" | |
15446 | extern js::Class js_BooleanClass; | |
15447 | ||
15448 | inline | |
15449 | ||
15450 | # 52 "jsbool.h" | |
15451 | bool | |
15452 | JSObject::isBoolean() const | |
15453 | { | |
15454 | return getClass() == &js_BooleanClass; | |
15455 | } | |
15456 | ||
15457 | extern JSObject * | |
15458 | js_InitBooleanClass(JSContext *cx, JSObject *obj); | |
15459 | ||
15460 | extern JSString * | |
15461 | js_BooleanToString(JSContext *cx, JSBool b); | |
15462 | ||
15463 | namespace js { | |
15464 | ||
15465 | extern | |
15466 | ||
15467 | # 66 "jsbool.h" | |
15468 | bool | |
15469 | BooleanToStringBuffer(JSContext *cx, JSBool b, StringBuffer &sb); | |
15470 | ||
15471 | } | |
15472 | ||
15473 | extern JSBool | |
15474 | js_ValueToBoolean(const js::Value &v); | |
15475 | # 56 "jsxml.cpp" 2 | |
15476 | # 1 "jscntxt.h" 1 | |
15477 | # 56 "jscntxt.h" | |
15478 | # 1 "jsarena.h" 1 | |
15479 | # 53 "jsarena.h" | |
15480 | extern "C" { | |
15481 | ||
15482 | typedef struct JSArena JSArena; | |
15483 | typedef struct JSArenaPool JSArenaPool; | |
15484 | ||
15485 | struct JSArena { | |
15486 | JSArena *next; | |
15487 | jsuword base; | |
15488 | jsuword limit; | |
15489 | jsuword avail; | |
15490 | }; | |
15491 | # 86 "jsarena.h" | |
15492 | struct JSArenaPool { | |
15493 | JSArena first; | |
15494 | JSArena *current; | |
15495 | size_t arenasize; | |
15496 | jsuword mask; | |
15497 | size_t *quotap; | |
15498 | ||
15499 | ||
15500 | ||
15501 | ||
15502 | }; | |
15503 | # 212 "jsarena.h" | |
15504 | extern __attribute__((visibility ("default"))) void | |
15505 | JS_InitArenaPool(JSArenaPool *pool, const char *name, size_t size, | |
15506 | size_t align, size_t *quotap); | |
15507 | ||
15508 | ||
15509 | ||
15510 | ||
15511 | ||
15512 | ||
15513 | extern __attribute__((visibility ("default"))) void | |
15514 | JS_FreeArenaPool(JSArenaPool *pool); | |
15515 | ||
15516 | ||
15517 | ||
15518 | ||
15519 | extern __attribute__((visibility ("default"))) void | |
15520 | JS_FinishArenaPool(JSArenaPool *pool); | |
15521 | ||
15522 | ||
15523 | ||
15524 | ||
15525 | extern __attribute__((visibility ("default"))) void | |
15526 | JS_ArenaFinish(void); | |
15527 | ||
15528 | ||
15529 | ||
15530 | ||
15531 | extern __attribute__((visibility ("default"))) void | |
15532 | JS_ArenaShutDown(void); | |
15533 | ||
15534 | ||
15535 | ||
15536 | ||
15537 | extern __attribute__((visibility ("default"))) void * | |
15538 | JS_ArenaAllocate(JSArenaPool *pool, size_t nb); | |
15539 | ||
15540 | extern __attribute__((visibility ("default"))) void * | |
15541 | JS_ArenaRealloc(JSArenaPool *pool, void *p, size_t size, size_t incr); | |
15542 | ||
15543 | extern __attribute__((visibility ("default"))) void * | |
15544 | JS_ArenaGrow(JSArenaPool *pool, void *p, size_t size, size_t incr); | |
15545 | ||
15546 | extern __attribute__((visibility ("default"))) void | |
15547 | JS_ArenaRelease(JSArenaPool *pool, char *mark); | |
15548 | # 289 "jsarena.h" | |
15549 | } | |
15550 | # 57 "jscntxt.h" 2 | |
15551 | # 1 "jsclist.h" 1 | |
15552 | # 47 "jsclist.h" | |
15553 | typedef struct JSCListStr { | |
15554 | struct JSCListStr *next; | |
15555 | struct JSCListStr *prev; | |
15556 | } JSCList; | |
15557 | # 58 "jscntxt.h" 2 | |
15558 | ||
15559 | ||
15560 | # 1 "jsdhash.h" 1 | |
15561 | # 46 "jsdhash.h" | |
15562 | extern "C" { | |
15563 | # 79 "jsdhash.h" | |
15564 | typedef uint32 JSDHashNumber; | |
15565 | typedef struct JSDHashEntryHdr JSDHashEntryHdr; | |
15566 | typedef struct JSDHashEntryStub JSDHashEntryStub; | |
15567 | typedef struct JSDHashTable JSDHashTable; | |
15568 | typedef struct JSDHashTableOps JSDHashTableOps; | |
15569 | # 114 "jsdhash.h" | |
15570 | struct JSDHashEntryHdr { | |
15571 | JSDHashNumber keyHash; | |
15572 | }; | |
15573 | # 194 "jsdhash.h" | |
15574 | struct JSDHashTable { | |
15575 | const JSDHashTableOps *ops; | |
15576 | void *data; | |
15577 | int16 hashShift; | |
15578 | uint8 maxAlphaFrac; | |
15579 | uint8 minAlphaFrac; | |
15580 | uint32 entrySize; | |
15581 | uint32 entryCount; | |
15582 | uint32 removedCount; | |
15583 | uint32 generation; | |
15584 | char *entryStore; | |
15585 | # 226 "jsdhash.h" | |
15586 | }; | |
15587 | # 240 "jsdhash.h" | |
15588 | typedef void * | |
15589 | (* JSDHashAllocTable)(JSDHashTable *table, uint32 nbytes); | |
15590 | ||
15591 | typedef void | |
15592 | (* JSDHashFreeTable) (JSDHashTable *table, void *ptr); | |
15593 | ||
15594 | ||
15595 | ||
15596 | ||
15597 | ||
15598 | typedef JSDHashNumber | |
15599 | (* JSDHashHashKey) (JSDHashTable *table, const void *key); | |
15600 | ||
15601 | ||
15602 | ||
15603 | ||
15604 | ||
15605 | typedef JSBool | |
15606 | (* JSDHashMatchEntry)(JSDHashTable *table, const JSDHashEntryHdr *entry, | |
15607 | const void *key); | |
15608 | ||
15609 | ||
15610 | ||
15611 | ||
15612 | ||
15613 | ||
15614 | ||
15615 | typedef void | |
15616 | (* JSDHashMoveEntry)(JSDHashTable *table, const JSDHashEntryHdr *from, | |
15617 | JSDHashEntryHdr *to); | |
15618 | ||
15619 | ||
15620 | ||
15621 | ||
15622 | ||
15623 | ||
15624 | typedef void | |
15625 | (* JSDHashClearEntry)(JSDHashTable *table, JSDHashEntryHdr *entry); | |
15626 | ||
15627 | ||
15628 | ||
15629 | ||
15630 | ||
15631 | ||
15632 | typedef void | |
15633 | (* JSDHashFinalize) (JSDHashTable *table); | |
15634 | # 294 "jsdhash.h" | |
15635 | typedef JSBool | |
15636 | (* JSDHashInitEntry)(JSDHashTable *table, JSDHashEntryHdr *entry, | |
15637 | const void *key); | |
15638 | # 325 "jsdhash.h" | |
15639 | struct JSDHashTableOps { | |
15640 | ||
15641 | JSDHashAllocTable allocTable; | |
15642 | JSDHashFreeTable freeTable; | |
15643 | JSDHashHashKey hashKey; | |
15644 | JSDHashMatchEntry matchEntry; | |
15645 | JSDHashMoveEntry moveEntry; | |
15646 | JSDHashClearEntry clearEntry; | |
15647 | JSDHashFinalize finalize; | |
15648 | ||
15649 | ||
15650 | JSDHashInitEntry initEntry; | |
15651 | }; | |
15652 | ||
15653 | ||
15654 | ||
15655 | ||
15656 | extern __attribute__((visibility ("default"))) void * | |
15657 | JS_DHashAllocTable(JSDHashTable *table, uint32 nbytes); | |
15658 | ||
15659 | extern __attribute__((visibility ("default"))) void | |
15660 | JS_DHashFreeTable(JSDHashTable *table, void *ptr); | |
15661 | ||
15662 | extern __attribute__((visibility ("default"))) JSDHashNumber | |
15663 | JS_DHashStringKey(JSDHashTable *table, const void *key); | |
15664 | ||
15665 | ||
15666 | struct JSDHashEntryStub { | |
15667 | JSDHashEntryHdr hdr; | |
15668 | const void *key; | |
15669 | }; | |
15670 | ||
15671 | extern __attribute__((visibility ("default"))) JSDHashNumber | |
15672 | JS_DHashVoidPtrKeyStub(JSDHashTable *table, const void *key); | |
15673 | ||
15674 | extern __attribute__((visibility ("default"))) JSBool | |
15675 | JS_DHashMatchEntryStub(JSDHashTable *table, | |
15676 | const JSDHashEntryHdr *entry, | |
15677 | const void *key); | |
15678 | ||
15679 | extern __attribute__((visibility ("default"))) JSBool | |
15680 | JS_DHashMatchStringKey(JSDHashTable *table, | |
15681 | const JSDHashEntryHdr *entry, | |
15682 | const void *key); | |
15683 | ||
15684 | extern __attribute__((visibility ("default"))) void | |
15685 | JS_DHashMoveEntryStub(JSDHashTable *table, | |
15686 | const JSDHashEntryHdr *from, | |
15687 | JSDHashEntryHdr *to); | |
15688 | ||
15689 | extern __attribute__((visibility ("default"))) void | |
15690 | JS_DHashClearEntryStub(JSDHashTable *table, JSDHashEntryHdr *entry); | |
15691 | ||
15692 | extern __attribute__((visibility ("default"))) void | |
15693 | JS_DHashFreeStringKey(JSDHashTable *table, JSDHashEntryHdr *entry); | |
15694 | ||
15695 | extern __attribute__((visibility ("default"))) void | |
15696 | JS_DHashFinalizeStub(JSDHashTable *table); | |
15697 | ||
15698 | ||
15699 | ||
15700 | ||
15701 | ||
15702 | ||
15703 | extern __attribute__((visibility ("default"))) const JSDHashTableOps * | |
15704 | JS_DHashGetStubOps(void); | |
15705 | ||
15706 | ||
15707 | ||
15708 | ||
15709 | ||
15710 | ||
15711 | ||
15712 | extern __attribute__((visibility ("default"))) JSDHashTable * | |
15713 | JS_NewDHashTable(const JSDHashTableOps *ops, void *data, uint32 entrySize, | |
15714 | uint32 capacity); | |
15715 | ||
15716 | ||
15717 | ||
15718 | ||
15719 | ||
15720 | extern __attribute__((visibility ("default"))) void | |
15721 | JS_DHashTableDestroy(JSDHashTable *table); | |
15722 | ||
15723 | ||
15724 | ||
15725 | ||
15726 | ||
15727 | ||
15728 | ||
15729 | extern __attribute__((visibility ("default"))) JSBool | |
15730 | JS_DHashTableInit(JSDHashTable *table, const JSDHashTableOps *ops, void *data, | |
15731 | uint32 entrySize, uint32 capacity); | |
15732 | # 427 "jsdhash.h" | |
15733 | extern __attribute__((visibility ("default"))) void | |
15734 | JS_DHashTableSetAlphaBounds(JSDHashTable *table, | |
15735 | float maxAlpha, | |
15736 | float minAlpha); | |
15737 | # 471 "jsdhash.h" | |
15738 | extern __attribute__((visibility ("default"))) void | |
15739 | JS_DHashTableFinish(JSDHashTable *table); | |
15740 | ||
15741 | ||
15742 | ||
15743 | ||
15744 | ||
15745 | ||
15746 | ||
15747 | typedef enum JSDHashOperator { | |
15748 | JS_DHASH_LOOKUP = 0, | |
15749 | JS_DHASH_ADD = 1, | |
15750 | JS_DHASH_REMOVE = 2, | |
15751 | JS_DHASH_NEXT = 0, | |
15752 | JS_DHASH_STOP = 1 | |
15753 | } JSDHashOperator; | |
15754 | # 518 "jsdhash.h" | |
15755 | extern __attribute__((visibility ("default"))) JSDHashEntryHdr * | |
15756 | JS_DHashTableOperate(JSDHashTable *table, const void *key, JSDHashOperator op); | |
15757 | # 530 "jsdhash.h" | |
15758 | extern __attribute__((visibility ("default"))) void | |
15759 | JS_DHashTableRawRemove(JSDHashTable *table, JSDHashEntryHdr *entry); | |
15760 | # 572 "jsdhash.h" | |
15761 | typedef JSDHashOperator | |
15762 | (* JSDHashEnumerator)(JSDHashTable *table, JSDHashEntryHdr *hdr, uint32 number, | |
15763 | void *arg); | |
15764 | ||
15765 | extern __attribute__((visibility ("default"))) uint32 | |
15766 | JS_DHashTableEnumerate(JSDHashTable *table, JSDHashEnumerator etor, void *arg); | |
15767 | # 605 "jsdhash.h" | |
15768 | } | |
15769 | # 61 "jscntxt.h" 2 | |
15770 | # 1 "jsdtoa.h" 1 | |
15771 | # 49 "jsdtoa.h" | |
15772 | extern "C" { | |
15773 | ||
15774 | struct DtoaState; | |
15775 | ||
15776 | DtoaState * | |
15777 | js_NewDtoaState(); | |
15778 | ||
15779 | void | |
15780 | js_DestroyDtoaState(DtoaState *state); | |
15781 | # 73 "jsdtoa.h" | |
15782 | double | |
15783 | js_strtod_harder(DtoaState *state, const char *s00, char **se, int *err); | |
15784 | # 88 "jsdtoa.h" | |
15785 | typedef enum JSDToStrMode { | |
15786 | DTOSTR_STANDARD, | |
15787 | DTOSTR_STANDARD_EXPONENTIAL, | |
15788 | DTOSTR_FIXED, | |
15789 | DTOSTR_EXPONENTIAL, | |
15790 | DTOSTR_PRECISION | |
15791 | } JSDToStrMode; | |
15792 | # 121 "jsdtoa.h" | |
15793 | char * | |
15794 | js_dtostr(DtoaState *state, char *buffer, size_t bufferSize, JSDToStrMode mode, int precision, | |
15795 | double dval); | |
15796 | # 143 "jsdtoa.h" | |
15797 | char * | |
15798 | js_dtobasestr(DtoaState *state, int base, double d); | |
15799 | ||
15800 | } | |
15801 | # 62 "jscntxt.h" 2 | |
15802 | # 1 "jsfun.h" 1 | |
15803 | # 49 "jsfun.h" | |
15804 | # 1 "jsscript.h" 1 | |
15805 | # 48 "jsscript.h" | |
15806 | # 1 "jsdbgapi.h" 1 | |
15807 | # 47 "jsdbgapi.h" | |
15808 | # 1 "jsopcode.h" 1 | |
15809 | # 45 "jsopcode.h" | |
15810 | # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stddef.h" 1 3 4 | |
15811 | # 46 "jsopcode.h" 2 | |
15812 | # 54 "jsopcode.h" | |
15813 | extern "C" { | |
15814 | ||
15815 | ||
15816 | ||
15817 | ||
15818 | typedef enum JSOp { | |
15819 | ||
15820 | ||
15821 | # 1 "jsopcode.tbl" 1 | |
15822 | # 113 "jsopcode.tbl" | |
15823 | JSOP_NOP = 0, | |
15824 | ||
15825 | ||
15826 | JSOP_PUSH = 1, | |
15827 | JSOP_POPV = 2, | |
15828 | JSOP_ENTERWITH = 3, | |
15829 | JSOP_LEAVEWITH = 4, | |
15830 | JSOP_RETURN = 5, | |
15831 | JSOP_GOTO = 6, | |
15832 | JSOP_IFEQ = 7, | |
15833 | JSOP_IFNE = 8, | |
15834 | ||
15835 | ||
15836 | JSOP_ARGUMENTS = 9, | |
15837 | ||
15838 | ||
15839 | JSOP_FORARG = 10, | |
15840 | JSOP_FORLOCAL = 11, | |
15841 | ||
15842 | ||
15843 | JSOP_DUP = 12, | |
15844 | JSOP_DUP2 = 13, | |
15845 | JSOP_SETCONST = 14, | |
15846 | JSOP_BITOR = 15, | |
15847 | JSOP_BITXOR = 16, | |
15848 | JSOP_BITAND = 17, | |
15849 | JSOP_EQ = 18, | |
15850 | JSOP_NE = 19, | |
15851 | JSOP_LT = 20, | |
15852 | JSOP_LE = 21, | |
15853 | JSOP_GT = 22, | |
15854 | JSOP_GE = 23, | |
15855 | JSOP_LSH = 24, | |
15856 | JSOP_RSH = 25, | |
15857 | JSOP_URSH = 26, | |
15858 | JSOP_ADD = 27, | |
15859 | JSOP_SUB = 28, | |
15860 | JSOP_MUL = 29, | |
15861 | JSOP_DIV = 30, | |
15862 | JSOP_MOD = 31, | |
15863 | JSOP_NOT = 32, | |
15864 | JSOP_BITNOT = 33, | |
15865 | JSOP_NEG = 34, | |
15866 | JSOP_POS = 35, | |
15867 | JSOP_DELNAME = 36, | |
15868 | JSOP_DELPROP = 37, | |
15869 | JSOP_DELELEM = 38, | |
15870 | JSOP_TYPEOF = 39, | |
15871 | JSOP_VOID = 40, | |
15872 | ||
15873 | JSOP_INCNAME = 41, | |
15874 | JSOP_INCPROP = 42, | |
15875 | JSOP_INCELEM = 43, | |
15876 | JSOP_DECNAME = 44, | |
15877 | JSOP_DECPROP = 45, | |
15878 | JSOP_DECELEM = 46, | |
15879 | JSOP_NAMEINC = 47, | |
15880 | JSOP_PROPINC = 48, | |
15881 | JSOP_ELEMINC = 49, | |
15882 | JSOP_NAMEDEC = 50, | |
15883 | JSOP_PROPDEC = 51, | |
15884 | JSOP_ELEMDEC = 52, | |
15885 | ||
15886 | JSOP_GETPROP = 53, | |
15887 | JSOP_SETPROP = 54, | |
15888 | JSOP_GETELEM = 55, | |
15889 | JSOP_SETELEM = 56, | |
15890 | JSOP_CALLNAME = 57, | |
15891 | JSOP_CALL = 58, | |
15892 | JSOP_NAME = 59, | |
15893 | JSOP_DOUBLE = 60, | |
15894 | JSOP_STRING = 61, | |
15895 | JSOP_ZERO = 62, | |
15896 | JSOP_ONE = 63, | |
15897 | JSOP_NULL = 64, | |
15898 | JSOP_THIS = 65, | |
15899 | JSOP_FALSE = 66, | |
15900 | JSOP_TRUE = 67, | |
15901 | JSOP_OR = 68, | |
15902 | JSOP_AND = 69, | |
15903 | ||
15904 | ||
15905 | JSOP_TABLESWITCH = 70, | |
15906 | JSOP_LOOKUPSWITCH = 71, | |
15907 | ||
15908 | ||
15909 | JSOP_STRICTEQ = 72, | |
15910 | JSOP_STRICTNE = 73, | |
15911 | ||
15912 | ||
15913 | ||
15914 | ||
15915 | ||
15916 | JSOP_SETCALL = 74, | |
15917 | # 220 "jsopcode.tbl" | |
15918 | JSOP_ITER = 75, | |
15919 | JSOP_MOREITER = 76, | |
15920 | JSOP_ENDITER = 77, | |
15921 | ||
15922 | JSOP_FUNAPPLY = 78, | |
15923 | JSOP_SWAP = 79, | |
15924 | ||
15925 | ||
15926 | JSOP_OBJECT = 80, | |
15927 | ||
15928 | ||
15929 | JSOP_POP = 81, | |
15930 | ||
15931 | ||
15932 | JSOP_NEW = 82, | |
15933 | ||
15934 | ||
15935 | JSOP_TRAP = 83, | |
15936 | ||
15937 | ||
15938 | JSOP_GETARG = 84, | |
15939 | JSOP_SETARG = 85, | |
15940 | JSOP_GETLOCAL = 86, | |
15941 | JSOP_SETLOCAL = 87, | |
15942 | ||
15943 | ||
15944 | JSOP_UINT16 = 88, | |
15945 | # 256 "jsopcode.tbl" | |
15946 | JSOP_NEWINIT = 89, | |
15947 | JSOP_NEWARRAY = 90, | |
15948 | JSOP_NEWOBJECT = 91, | |
15949 | JSOP_ENDINIT = 92, | |
15950 | JSOP_INITPROP = 93, | |
15951 | JSOP_INITELEM = 94, | |
15952 | JSOP_DEFSHARP = 95, | |
15953 | JSOP_USESHARP = 96, | |
15954 | ||
15955 | ||
15956 | JSOP_INCARG = 97, | |
15957 | JSOP_DECARG = 98, | |
15958 | JSOP_ARGINC = 99, | |
15959 | JSOP_ARGDEC = 100, | |
15960 | ||
15961 | JSOP_INCLOCAL = 101, | |
15962 | JSOP_DECLOCAL = 102, | |
15963 | JSOP_LOCALINC = 103, | |
15964 | JSOP_LOCALDEC = 104, | |
15965 | ||
15966 | JSOP_IMACOP = 105, | |
15967 | ||
15968 | ||
15969 | JSOP_FORNAME = 106, | |
15970 | JSOP_FORPROP = 107, | |
15971 | JSOP_FORELEM = 108, | |
15972 | JSOP_POPN = 109, | |
15973 | ||
15974 | ||
15975 | JSOP_BINDNAME = 110, | |
15976 | JSOP_SETNAME = 111, | |
15977 | ||
15978 | ||
15979 | JSOP_THROW = 112, | |
15980 | ||
15981 | ||
15982 | JSOP_IN = 113, | |
15983 | JSOP_INSTANCEOF = 114, | |
15984 | ||
15985 | ||
15986 | JSOP_DEBUGGER = 115, | |
15987 | ||
15988 | ||
15989 | JSOP_GOSUB = 116, | |
15990 | JSOP_RETSUB = 117, | |
15991 | ||
15992 | ||
15993 | JSOP_EXCEPTION = 118, | |
15994 | ||
15995 | ||
15996 | JSOP_LINENO = 119, | |
15997 | ||
15998 | ||
15999 | ||
16000 | ||
16001 | ||
16002 | ||
16003 | JSOP_CONDSWITCH = 120, | |
16004 | JSOP_CASE = 121, | |
16005 | JSOP_DEFAULT = 122, | |
16006 | ||
16007 | ||
16008 | ||
16009 | ||
16010 | JSOP_EVAL = 123, | |
16011 | ||
16012 | ||
16013 | ||
16014 | ||
16015 | JSOP_ENUMELEM = 124, | |
16016 | ||
16017 | ||
16018 | ||
16019 | ||
16020 | ||
16021 | ||
16022 | JSOP_GETTER = 125, | |
16023 | JSOP_SETTER = 126, | |
16024 | ||
16025 | ||
16026 | ||
16027 | ||
16028 | JSOP_DEFFUN = 127, | |
16029 | JSOP_DEFCONST = 128, | |
16030 | JSOP_DEFVAR = 129, | |
16031 | ||
16032 | ||
16033 | JSOP_LAMBDA = 130, | |
16034 | ||
16035 | ||
16036 | JSOP_CALLEE = 131, | |
16037 | ||
16038 | ||
16039 | ||
16040 | ||
16041 | ||
16042 | JSOP_SETLOCALPOP = 132, | |
16043 | ||
16044 | ||
16045 | JSOP_PICK = 133, | |
16046 | ||
16047 | ||
16048 | ||
16049 | ||
16050 | ||
16051 | JSOP_TRY = 134, | |
16052 | JSOP_FINALLY = 135, | |
16053 | ||
16054 | ||
16055 | ||
16056 | ||
16057 | ||
16058 | ||
16059 | ||
16060 | JSOP_GETFCSLOT = 136, | |
16061 | JSOP_CALLFCSLOT = 137, | |
16062 | ||
16063 | ||
16064 | ||
16065 | ||
16066 | ||
16067 | ||
16068 | JSOP_ARGSUB = 138, | |
16069 | JSOP_ARGCNT = 139, | |
16070 | ||
16071 | ||
16072 | ||
16073 | ||
16074 | ||
16075 | ||
16076 | JSOP_DEFLOCALFUN = 140, | |
16077 | ||
16078 | ||
16079 | JSOP_GOTOX = 141, | |
16080 | JSOP_IFEQX = 142, | |
16081 | JSOP_IFNEX = 143, | |
16082 | JSOP_ORX = 144, | |
16083 | JSOP_ANDX = 145, | |
16084 | JSOP_GOSUBX = 146, | |
16085 | JSOP_CASEX = 147, | |
16086 | JSOP_DEFAULTX = 148, | |
16087 | JSOP_TABLESWITCHX = 149, | |
16088 | JSOP_LOOKUPSWITCHX = 150, | |
16089 | ||
16090 | ||
16091 | JSOP_BACKPATCH = 151, | |
16092 | JSOP_BACKPATCH_POP = 152, | |
16093 | ||
16094 | ||
16095 | JSOP_THROWING = 153, | |
16096 | ||
16097 | ||
16098 | JSOP_SETRVAL = 154, | |
16099 | JSOP_RETRVAL = 155, | |
16100 | ||
16101 | ||
16102 | JSOP_GETGNAME = 156, | |
16103 | JSOP_SETGNAME = 157, | |
16104 | JSOP_INCGNAME = 158, | |
16105 | JSOP_DECGNAME = 159, | |
16106 | JSOP_GNAMEINC = 160, | |
16107 | JSOP_GNAMEDEC = 161, | |
16108 | ||
16109 | ||
16110 | JSOP_REGEXP = 162, | |
16111 | ||
16112 | ||
16113 | JSOP_DEFXMLNS = 163, | |
16114 | JSOP_ANYNAME = 164, | |
16115 | JSOP_QNAMEPART = 165, | |
16116 | JSOP_QNAMECONST = 166, | |
16117 | JSOP_QNAME = 167, | |
16118 | JSOP_TOATTRNAME = 168, | |
16119 | JSOP_TOATTRVAL = 169, | |
16120 | JSOP_ADDATTRNAME = 170, | |
16121 | JSOP_ADDATTRVAL = 171, | |
16122 | JSOP_BINDXMLNAME = 172, | |
16123 | JSOP_SETXMLNAME = 173, | |
16124 | JSOP_XMLNAME = 174, | |
16125 | JSOP_DESCENDANTS = 175, | |
16126 | JSOP_FILTER = 176, | |
16127 | JSOP_ENDFILTER = 177, | |
16128 | JSOP_TOXML = 178, | |
16129 | JSOP_TOXMLLIST = 179, | |
16130 | JSOP_XMLTAGEXPR = 180, | |
16131 | JSOP_XMLELTEXPR = 181, | |
16132 | JSOP_NOTRACE = 182, | |
16133 | JSOP_XMLCDATA = 183, | |
16134 | JSOP_XMLCOMMENT = 184, | |
16135 | JSOP_XMLPI = 185, | |
16136 | JSOP_DELDESC = 186, | |
16137 | ||
16138 | JSOP_CALLPROP = 187, | |
16139 | # 457 "jsopcode.tbl" | |
16140 | JSOP_BLOCKCHAIN = 188, | |
16141 | JSOP_NULLBLOCKCHAIN = 189, | |
16142 | ||
16143 | ||
16144 | ||
16145 | ||
16146 | JSOP_UINT24 = 190, | |
16147 | ||
16148 | ||
16149 | ||
16150 | ||
16151 | ||
16152 | ||
16153 | ||
16154 | JSOP_INDEXBASE = 191, | |
16155 | JSOP_RESETBASE = 192, | |
16156 | JSOP_RESETBASE0 = 193, | |
16157 | ||
16158 | ||
16159 | ||
16160 | ||
16161 | JSOP_STARTXML = 194, | |
16162 | JSOP_STARTXMLEXPR = 195, | |
16163 | ||
16164 | JSOP_CALLELEM = 196, | |
16165 | ||
16166 | ||
16167 | ||
16168 | ||
16169 | ||
16170 | JSOP_STOP = 197, | |
16171 | ||
16172 | ||
16173 | ||
16174 | ||
16175 | ||
16176 | JSOP_GETXPROP = 198, | |
16177 | ||
16178 | JSOP_CALLXMLNAME = 199, | |
16179 | ||
16180 | ||
16181 | ||
16182 | ||
16183 | JSOP_TYPEOFEXPR = 200, | |
16184 | ||
16185 | ||
16186 | ||
16187 | ||
16188 | JSOP_ENTERBLOCK = 201, | |
16189 | JSOP_LEAVEBLOCK = 202, | |
16190 | ||
16191 | ||
16192 | JSOP_IFPRIMTOP = 203, | |
16193 | ||
16194 | ||
16195 | JSOP_PRIMTOP = 204, | |
16196 | ||
16197 | ||
16198 | ||
16199 | ||
16200 | JSOP_GENERATOR = 205, | |
16201 | JSOP_YIELD = 206, | |
16202 | JSOP_ARRAYPUSH = 207, | |
16203 | ||
16204 | ||
16205 | ||
16206 | ||
16207 | JSOP_GETFUNNS = 208, | |
16208 | ||
16209 | ||
16210 | ||
16211 | ||
16212 | JSOP_ENUMCONSTELEM = 209, | |
16213 | ||
16214 | ||
16215 | ||
16216 | ||
16217 | ||
16218 | JSOP_LEAVEBLOCKEXPR = 210, | |
16219 | ||
16220 | ||
16221 | ||
16222 | ||
16223 | JSOP_GETTHISPROP = 211, | |
16224 | JSOP_GETARGPROP = 212, | |
16225 | JSOP_GETLOCALPROP = 213, | |
16226 | ||
16227 | ||
16228 | ||
16229 | ||
16230 | ||
16231 | JSOP_INDEXBASE1 = 214, | |
16232 | JSOP_INDEXBASE2 = 215, | |
16233 | JSOP_INDEXBASE3 = 216, | |
16234 | ||
16235 | JSOP_CALLGNAME = 217, | |
16236 | JSOP_CALLLOCAL = 218, | |
16237 | JSOP_CALLARG = 219, | |
16238 | JSOP_BINDGNAME = 220, | |
16239 | ||
16240 | ||
16241 | ||
16242 | ||
16243 | JSOP_INT8 = 221, | |
16244 | JSOP_INT32 = 222, | |
16245 | ||
16246 | ||
16247 | ||
16248 | ||
16249 | JSOP_LENGTH = 223, | |
16250 | ||
16251 | ||
16252 | ||
16253 | ||
16254 | ||
16255 | ||
16256 | JSOP_HOLE = 224, | |
16257 | ||
16258 | ||
16259 | ||
16260 | ||
16261 | JSOP_DEFFUN_FC = 225, | |
16262 | JSOP_DEFLOCALFUN_FC = 226, | |
16263 | JSOP_LAMBDA_FC = 227, | |
16264 | ||
16265 | ||
16266 | ||
16267 | ||
16268 | ||
16269 | ||
16270 | JSOP_OBJTOP = 228, | |
16271 | ||
16272 | ||
16273 | JSOP_TRACE = 229, | |
16274 | ||
16275 | ||
16276 | ||
16277 | ||
16278 | JSOP_GETUPVAR_DBG = 230, | |
16279 | JSOP_CALLUPVAR_DBG = 231, | |
16280 | JSOP_DEFFUN_DBGFC = 232, | |
16281 | JSOP_DEFLOCALFUN_DBGFC = 233, | |
16282 | JSOP_LAMBDA_DBGFC = 234, | |
16283 | ||
16284 | ||
16285 | ||
16286 | ||
16287 | JSOP_SETMETHOD = 235, | |
16288 | JSOP_INITMETHOD = 236, | |
16289 | JSOP_UNBRAND = 237, | |
16290 | JSOP_UNBRANDTHIS = 238, | |
16291 | ||
16292 | JSOP_SHARPINIT = 239, | |
16293 | ||
16294 | ||
16295 | JSOP_GETGLOBAL = 240, | |
16296 | JSOP_CALLGLOBAL = 241, | |
16297 | ||
16298 | ||
16299 | JSOP_FUNCALL = 242, | |
16300 | ||
16301 | JSOP_FORGNAME = 243, | |
16302 | # 63 "jsopcode.h" 2 | |
16303 | ||
16304 | JSOP_LIMIT, | |
16305 | ||
16306 | ||
16307 | ||
16308 | ||
16309 | ||
16310 | ||
16311 | JSOP_GETPROP2 = JSOP_LIMIT, | |
16312 | JSOP_GETELEM2 = JSOP_LIMIT + 1, | |
16313 | JSOP_FAKE_LIMIT = JSOP_GETELEM2 | |
16314 | } JSOp; | |
16315 | # 268 "jsopcode.h" | |
16316 | struct JSCodeSpec { | |
16317 | int8 length; | |
16318 | int8 nuses; | |
16319 | int8 ndefs; | |
16320 | uint8 prec; | |
16321 | uint32 format; | |
16322 | ||
16323 | ||
16324 | uint32 type() const { return ((format) & 0x001f); } | |
16325 | ||
16326 | }; | |
16327 | ||
16328 | extern const JSCodeSpec js_CodeSpec[]; | |
16329 | extern uintN js_NumCodeSpecs; | |
16330 | extern const char *js_CodeName[]; | |
16331 | extern const char js_EscapeMap[]; | |
16332 | # 296 "jsopcode.h" | |
16333 | extern JSString * | |
16334 | js_QuoteString(JSContext *cx, JSString *str, jschar quote); | |
16335 | # 310 "jsopcode.h" | |
16336 | extern JSPrinter * | |
16337 | js_NewPrinter(JSContext *cx, const char *name, JSFunction *fun, | |
16338 | uintN indent, JSBool pretty, JSBool grouped, JSBool strict); | |
16339 | ||
16340 | extern void | |
16341 | js_DestroyPrinter(JSPrinter *jp); | |
16342 | ||
16343 | extern JSString * | |
16344 | js_GetPrinterOutput(JSPrinter *jp); | |
16345 | ||
16346 | extern int | |
16347 | js_printf(JSPrinter *jp, const char *format, ...); | |
16348 | ||
16349 | extern JSBool | |
16350 | js_puts(JSPrinter *jp, const char *s); | |
16351 | # 333 "jsopcode.h" | |
16352 | uintN | |
16353 | js_GetIndexFromBytecode(JSContext *cx, JSScript *script, jsbytecode *pc, | |
16354 | ptrdiff_t pcoff); | |
16355 | # 386 "jsopcode.h" | |
16356 | extern uintN | |
16357 | js_GetVariableBytecodeLength(jsbytecode *pc); | |
16358 | ||
16359 | ||
16360 | ||
16361 | ||
16362 | ||
16363 | extern uintN | |
16364 | js_GetVariableStackUses(JSOp op, jsbytecode *pc); | |
16365 | ||
16366 | ||
16367 | ||
16368 | ||
16369 | ||
16370 | extern uintN | |
16371 | js_GetEnterBlockStackDefs(JSContext *cx, JSScript *script, jsbytecode *pc); | |
16372 | ||
16373 | ||
16374 | static inline uintN | |
16375 | js_GetStackUses(const JSCodeSpec *cs, JSOp op, jsbytecode *pc) | |
16376 | { | |
16377 | ((void) 0); | |
16378 | if (cs->nuses >= 0) | |
16379 | return cs->nuses; | |
16380 | return js_GetVariableStackUses(op, pc); | |
16381 | } | |
16382 | ||
16383 | static inline uintN | |
16384 | js_GetStackDefs(JSContext *cx, const JSCodeSpec *cs, JSOp op, JSScript *script, | |
16385 | jsbytecode *pc) | |
16386 | { | |
16387 | ((void) 0); | |
16388 | if (cs->ndefs >= 0) | |
16389 | return cs->ndefs; | |
16390 | ||
16391 | ||
16392 | ((void) 0); | |
16393 | return js_GetEnterBlockStackDefs(cx, script, pc); | |
16394 | } | |
16395 | # 444 "jsopcode.h" | |
16396 | extern JSBool | |
16397 | js_DecompileScript(JSPrinter *jp, JSScript *script); | |
16398 | ||
16399 | extern JSBool | |
16400 | js_DecompileFunctionBody(JSPrinter *jp); | |
16401 | ||
16402 | extern JSBool | |
16403 | js_DecompileFunction(JSPrinter *jp); | |
16404 | # 460 "jsopcode.h" | |
16405 | typedef JSBool (* JSDecompilerPtr)(JSPrinter *); | |
16406 | ||
16407 | extern JSString * | |
16408 | js_DecompileToString(JSContext *cx, const char *name, JSFunction *fun, | |
16409 | uintN indent, JSBool pretty, JSBool grouped, JSBool strict, | |
16410 | JSDecompilerPtr decompiler); | |
16411 | # 479 "jsopcode.h" | |
16412 | extern char * | |
16413 | js_DecompileValueGenerator(JSContext *cx, intN spindex, jsval v, | |
16414 | JSString *fallback); | |
16415 | ||
16416 | ||
16417 | ||
16418 | ||
16419 | ||
16420 | namespace js { | |
16421 | ||
16422 | static inline char * | |
16423 | DecompileValueGenerator(JSContext *cx, intN spindex, const Value &v, | |
16424 | JSString *fallback) | |
16425 | { | |
16426 | return js_DecompileValueGenerator(cx, spindex, Jsvalify(v), fallback); | |
16427 | } | |
16428 | ||
16429 | } | |
16430 | ||
16431 | ||
16432 | ||
16433 | ||
16434 | ||
16435 | ||
16436 | extern uintN | |
16437 | js_ReconstructStackDepth(JSContext *cx, JSScript *script, jsbytecode *pc); | |
16438 | ||
16439 | ||
16440 | ||
16441 | ||
16442 | ||
16443 | } | |
16444 | # 48 "jsdbgapi.h" 2 | |
16445 | ||
16446 | ||
16447 | extern "C" { | |
16448 | ||
16449 | extern __attribute__((visibility ("default"))) JSCrossCompartmentCall * | |
16450 | JS_EnterCrossCompartmentCallScript(JSContext *cx, JSScript *target); | |
16451 | ||
16452 | ||
16453 | } | |
16454 | ||
16455 | namespace JS { | |
16456 | ||
16457 | class __attribute__((visibility ("default"))) AutoEnterScriptCompartment | |
16458 | { | |
16459 | JSCrossCompartmentCall *call; | |
16460 | ||
16461 | public: | |
16462 | AutoEnterScriptCompartment() : call(__null) {} | |
16463 | ||
16464 | bool enter(JSContext *cx, JSScript *target); | |
16465 | ||
16466 | bool entered() const { return call != __null; } | |
16467 | ||
16468 | ~AutoEnterScriptCompartment() { | |
16469 | if (call && call != reinterpret_cast<JSCrossCompartmentCall*>(1)) | |
16470 | JS_LeaveCrossCompartmentCall(call); | |
16471 | } | |
16472 | }; | |
16473 | ||
16474 | } | |
16475 | ||
16476 | extern "C" { | |
16477 | ||
16478 | ||
16479 | extern __attribute__((visibility ("default"))) JSScript * | |
16480 | JS_GetScriptFromObject(JSObject *scriptObject); | |
16481 | ||
16482 | extern __attribute__((visibility ("default"))) JSString * | |
16483 | JS_DecompileScript(JSContext *cx, JSScript *script, const char *name, uintN indent); | |
16484 | ||
16485 | ||
16486 | ||
16487 | ||
16488 | ||
16489 | extern __attribute__((visibility ("default"))) void | |
16490 | JS_SetRuntimeDebugMode(JSRuntime *rt, JSBool debug); | |
16491 | # 106 "jsdbgapi.h" | |
16492 | extern __attribute__((visibility ("default"))) JSBool | |
16493 | JS_GetDebugMode(JSContext *cx); | |
16494 | ||
16495 | ||
16496 | ||
16497 | ||
16498 | ||
16499 | ||
16500 | __attribute__((visibility ("default"))) JSBool | |
16501 | JS_SetDebugModeForCompartment(JSContext *cx, JSCompartment *comp, JSBool debug); | |
16502 | ||
16503 | ||
16504 | ||
16505 | ||
16506 | __attribute__((visibility ("default"))) JSBool | |
16507 | JS_SetDebugMode(JSContext *cx, JSBool debug); | |
16508 | ||
16509 | ||
16510 | extern __attribute__((visibility ("default"))) JSBool | |
16511 | js_SetSingleStepMode(JSContext *cx, JSScript *script, JSBool singleStep); | |
16512 | ||
16513 | ||
16514 | extern __attribute__((visibility ("default"))) JSBool | |
16515 | JS_SetSingleStepMode(JSContext *cx, JSScript *script, JSBool singleStep); | |
16516 | ||
16517 | ||
16518 | ||
16519 | ||
16520 | ||
16521 | ||
16522 | extern jsbytecode * | |
16523 | js_UntrapScriptCode(JSContext *cx, JSScript *script); | |
16524 | ||
16525 | ||
16526 | extern __attribute__((visibility ("default"))) JSBool | |
16527 | JS_SetTrap(JSContext *cx, JSScript *script, jsbytecode *pc, | |
16528 | JSTrapHandler handler, jsval closure); | |
16529 | ||
16530 | extern __attribute__((visibility ("default"))) JSOp | |
16531 | JS_GetTrapOpcode(JSContext *cx, JSScript *script, jsbytecode *pc); | |
16532 | ||
16533 | extern __attribute__((visibility ("default"))) void | |
16534 | JS_ClearTrap(JSContext *cx, JSScript *script, jsbytecode *pc, | |
16535 | JSTrapHandler *handlerp, jsval *closurep); | |
16536 | ||
16537 | extern __attribute__((visibility ("default"))) void | |
16538 | JS_ClearScriptTraps(JSContext *cx, JSScript *script); | |
16539 | ||
16540 | extern __attribute__((visibility ("default"))) void | |
16541 | JS_ClearAllTraps(JSContext *cx); | |
16542 | ||
16543 | extern __attribute__((visibility ("default"))) JSTrapStatus | |
16544 | JS_HandleTrap(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval); | |
16545 | ||
16546 | extern __attribute__((visibility ("default"))) JSBool | |
16547 | JS_SetInterrupt(JSRuntime *rt, JSInterruptHook handler, void *closure); | |
16548 | ||
16549 | extern __attribute__((visibility ("default"))) JSBool | |
16550 | JS_ClearInterrupt(JSRuntime *rt, JSInterruptHook *handlerp, void **closurep); | |
16551 | ||
16552 | ||
16553 | ||
16554 | extern __attribute__((visibility ("default"))) JSBool | |
16555 | JS_SetWatchPoint(JSContext *cx, JSObject *obj, jsid id, | |
16556 | JSWatchPointHandler handler, JSObject *closure); | |
16557 | ||
16558 | extern __attribute__((visibility ("default"))) JSBool | |
16559 | JS_ClearWatchPoint(JSContext *cx, JSObject *obj, jsid id, | |
16560 | JSWatchPointHandler *handlerp, JSObject **closurep); | |
16561 | ||
16562 | extern __attribute__((visibility ("default"))) JSBool | |
16563 | JS_ClearWatchPointsForObject(JSContext *cx, JSObject *obj); | |
16564 | ||
16565 | extern __attribute__((visibility ("default"))) JSBool | |
16566 | JS_ClearAllWatchPoints(JSContext *cx); | |
16567 | ||
16568 | ||
16569 | ||
16570 | ||
16571 | ||
16572 | ||
16573 | extern void | |
16574 | js_TraceWatchPoints(JSTracer *trc, JSObject *obj); | |
16575 | ||
16576 | extern void | |
16577 | js_SweepWatchPoints(JSContext *cx); | |
16578 | ||
16579 | ||
16580 | ||
16581 | extern JSBool | |
16582 | js_watch_set(JSContext *cx, JSObject *obj, jsid id, JSBool strict, js::Value *vp); | |
16583 | ||
16584 | namespace js { | |
16585 | ||
16586 | ||
16587 | bool | |
16588 | # 201 "jsdbgapi.h" | |
16589 | IsWatchedProperty(JSContext *cx, const Shape *shape); | |
16590 | ||
16591 | } | |
16592 | ||
16593 | ||
16594 | ||
16595 | ||
16596 | ||
16597 | ||
16598 | ||
16599 | extern __attribute__((visibility ("default"))) uintN | |
16600 | JS_PCToLineNumber(JSContext *cx, JSScript *script, jsbytecode *pc); | |
16601 | ||
16602 | extern __attribute__((visibility ("default"))) jsbytecode * | |
16603 | JS_LineNumberToPC(JSContext *cx, JSScript *script, uintN lineno); | |
16604 | ||
16605 | extern __attribute__((visibility ("default"))) jsbytecode * | |
16606 | JS_EndPC(JSContext *cx, JSScript *script); | |
16607 | ||
16608 | extern __attribute__((visibility ("default"))) uintN | |
16609 | JS_GetFunctionArgumentCount(JSContext *cx, JSFunction *fun); | |
16610 | ||
16611 | extern __attribute__((visibility ("default"))) JSBool | |
16612 | JS_FunctionHasLocalNames(JSContext *cx, JSFunction *fun); | |
16613 | ||
16614 | ||
16615 | ||
16616 | ||
16617 | ||
16618 | ||
16619 | extern __attribute__((visibility ("default"))) jsuword * | |
16620 | JS_GetFunctionLocalNameArray(JSContext *cx, JSFunction *fun, void **markp); | |
16621 | ||
16622 | extern __attribute__((visibility ("default"))) JSAtom * | |
16623 | JS_LocalNameToAtom(jsuword w); | |
16624 | ||
16625 | extern __attribute__((visibility ("default"))) JSString * | |
16626 | JS_AtomKey(JSAtom *atom); | |
16627 | ||
16628 | extern __attribute__((visibility ("default"))) void | |
16629 | JS_ReleaseFunctionLocalNameArray(JSContext *cx, void *mark); | |
16630 | ||
16631 | extern __attribute__((visibility ("default"))) JSScript * | |
16632 | JS_GetFunctionScript(JSContext *cx, JSFunction *fun); | |
16633 | ||
16634 | extern __attribute__((visibility ("default"))) JSNative | |
16635 | JS_GetFunctionNative(JSContext *cx, JSFunction *fun); | |
16636 | ||
16637 | extern __attribute__((visibility ("default"))) JSPrincipals * | |
16638 | JS_GetScriptPrincipals(JSContext *cx, JSScript *script); | |
16639 | # 259 "jsdbgapi.h" | |
16640 | extern __attribute__((visibility ("default"))) JSStackFrame * | |
16641 | JS_FrameIterator(JSContext *cx, JSStackFrame **iteratorp); | |
16642 | ||
16643 | extern __attribute__((visibility ("default"))) JSScript * | |
16644 | JS_GetFrameScript(JSContext *cx, JSStackFrame *fp); | |
16645 | ||
16646 | extern __attribute__((visibility ("default"))) jsbytecode * | |
16647 | JS_GetFramePC(JSContext *cx, JSStackFrame *fp); | |
16648 | ||
16649 | ||
16650 | ||
16651 | ||
16652 | extern __attribute__((visibility ("default"))) JSStackFrame * | |
16653 | JS_GetScriptedCaller(JSContext *cx, JSStackFrame *fp); | |
16654 | ||
16655 | ||
16656 | ||
16657 | ||
16658 | ||
16659 | extern JSPrincipals * | |
16660 | js_StackFramePrincipals(JSContext *cx, JSStackFrame *fp); | |
16661 | ||
16662 | JSPrincipals * | |
16663 | js_EvalFramePrincipals(JSContext *cx, JSObject *callee, JSStackFrame *caller); | |
16664 | ||
16665 | extern __attribute__((visibility ("default"))) void * | |
16666 | JS_GetFrameAnnotation(JSContext *cx, JSStackFrame *fp); | |
16667 | ||
16668 | extern __attribute__((visibility ("default"))) void | |
16669 | JS_SetFrameAnnotation(JSContext *cx, JSStackFrame *fp, void *annotation); | |
16670 | ||
16671 | extern __attribute__((visibility ("default"))) void * | |
16672 | JS_GetFramePrincipalArray(JSContext *cx, JSStackFrame *fp); | |
16673 | ||
16674 | extern __attribute__((visibility ("default"))) JSBool | |
16675 | JS_IsScriptFrame(JSContext *cx, JSStackFrame *fp); | |
16676 | ||
16677 | ||
16678 | extern __attribute__((visibility ("default"))) JSObject * | |
16679 | JS_GetFrameObject(JSContext *cx, JSStackFrame *fp); | |
16680 | ||
16681 | extern __attribute__((visibility ("default"))) JSObject * | |
16682 | JS_GetFrameScopeChain(JSContext *cx, JSStackFrame *fp); | |
16683 | ||
16684 | extern __attribute__((visibility ("default"))) JSObject * | |
16685 | JS_GetFrameCallObject(JSContext *cx, JSStackFrame *fp); | |
16686 | ||
16687 | extern __attribute__((visibility ("default"))) JSBool | |
16688 | JS_GetFrameThis(JSContext *cx, JSStackFrame *fp, jsval *thisv); | |
16689 | ||
16690 | extern __attribute__((visibility ("default"))) JSFunction * | |
16691 | JS_GetFrameFunction(JSContext *cx, JSStackFrame *fp); | |
16692 | ||
16693 | extern __attribute__((visibility ("default"))) JSObject * | |
16694 | JS_GetFrameFunctionObject(JSContext *cx, JSStackFrame *fp); | |
16695 | ||
16696 | ||
16697 | ||
16698 | extern __attribute__((visibility ("default"))) JSBool | |
16699 | JS_IsConstructorFrame(JSContext *cx, JSStackFrame *fp); | |
16700 | ||
16701 | extern __attribute__((visibility ("default"))) JSBool | |
16702 | JS_IsDebuggerFrame(JSContext *cx, JSStackFrame *fp); | |
16703 | ||
16704 | extern __attribute__((visibility ("default"))) jsval | |
16705 | JS_GetFrameReturnValue(JSContext *cx, JSStackFrame *fp); | |
16706 | ||
16707 | extern __attribute__((visibility ("default"))) void | |
16708 | JS_SetFrameReturnValue(JSContext *cx, JSStackFrame *fp, jsval rval); | |
16709 | # 355 "jsdbgapi.h" | |
16710 | extern __attribute__((visibility ("default"))) JSObject * | |
16711 | JS_GetFrameCalleeObject(JSContext *cx, JSStackFrame *fp); | |
16712 | ||
16713 | ||
16714 | ||
16715 | ||
16716 | ||
16717 | ||
16718 | extern __attribute__((visibility ("default"))) JSBool | |
16719 | JS_GetValidFrameCalleeObject(JSContext *cx, JSStackFrame *fp, jsval *vp); | |
16720 | ||
16721 | ||
16722 | ||
16723 | extern __attribute__((visibility ("default"))) const char * | |
16724 | JS_GetScriptFilename(JSContext *cx, JSScript *script); | |
16725 | ||
16726 | extern __attribute__((visibility ("default"))) uintN | |
16727 | JS_GetScriptBaseLineNumber(JSContext *cx, JSScript *script); | |
16728 | ||
16729 | extern __attribute__((visibility ("default"))) uintN | |
16730 | JS_GetScriptLineExtent(JSContext *cx, JSScript *script); | |
16731 | ||
16732 | extern __attribute__((visibility ("default"))) JSVersion | |
16733 | JS_GetScriptVersion(JSContext *cx, JSScript *script); | |
16734 | # 390 "jsdbgapi.h" | |
16735 | extern __attribute__((visibility ("default"))) void | |
16736 | JS_SetNewScriptHookProc(JSRuntime *rt, JSNewScriptHook hook, void *callerdata); | |
16737 | ||
16738 | extern __attribute__((visibility ("default"))) void | |
16739 | JS_SetDestroyScriptHookProc(JSRuntime *rt, JSDestroyScriptHook hook, | |
16740 | void *callerdata); | |
16741 | ||
16742 | ||
16743 | ||
16744 | extern __attribute__((visibility ("default"))) JSBool | |
16745 | JS_EvaluateUCInStackFrame(JSContext *cx, JSStackFrame *fp, | |
16746 | const jschar *chars, uintN length, | |
16747 | const char *filename, uintN lineno, | |
16748 | jsval *rval); | |
16749 | ||
16750 | extern __attribute__((visibility ("default"))) JSBool | |
16751 | JS_EvaluateInStackFrame(JSContext *cx, JSStackFrame *fp, | |
16752 | const char *bytes, uintN length, | |
16753 | const char *filename, uintN lineno, | |
16754 | jsval *rval); | |
16755 | ||
16756 | ||
16757 | ||
16758 | typedef struct JSPropertyDesc { | |
16759 | jsval id; | |
16760 | jsval value; | |
16761 | uint8 flags; | |
16762 | uint8 spare; | |
16763 | uint16 slot; | |
16764 | jsval alias; | |
16765 | } JSPropertyDesc; | |
16766 | # 433 "jsdbgapi.h" | |
16767 | typedef struct JSPropertyDescArray { | |
16768 | uint32 length; | |
16769 | JSPropertyDesc *array; | |
16770 | } JSPropertyDescArray; | |
16771 | ||
16772 | typedef struct JSScopeProperty JSScopeProperty; | |
16773 | ||
16774 | extern __attribute__((visibility ("default"))) JSScopeProperty * | |
16775 | JS_PropertyIterator(JSObject *obj, JSScopeProperty **iteratorp); | |
16776 | ||
16777 | extern __attribute__((visibility ("default"))) JSBool | |
16778 | JS_GetPropertyDesc(JSContext *cx, JSObject *obj, JSScopeProperty *shape, | |
16779 | JSPropertyDesc *pd); | |
16780 | ||
16781 | extern __attribute__((visibility ("default"))) JSBool | |
16782 | JS_GetPropertyDescArray(JSContext *cx, JSObject *obj, JSPropertyDescArray *pda); | |
16783 | ||
16784 | extern __attribute__((visibility ("default"))) void | |
16785 | JS_PutPropertyDescArray(JSContext *cx, JSPropertyDescArray *pda); | |
16786 | ||
16787 | ||
16788 | ||
16789 | extern __attribute__((visibility ("default"))) JSBool | |
16790 | JS_SetDebuggerHandler(JSRuntime *rt, JSDebuggerHandler hook, void *closure); | |
16791 | ||
16792 | extern __attribute__((visibility ("default"))) JSBool | |
16793 | JS_SetSourceHandler(JSRuntime *rt, JSSourceHandler handler, void *closure); | |
16794 | ||
16795 | extern __attribute__((visibility ("default"))) JSBool | |
16796 | JS_SetExecuteHook(JSRuntime *rt, JSInterpreterHook hook, void *closure); | |
16797 | ||
16798 | extern __attribute__((visibility ("default"))) JSBool | |
16799 | JS_SetCallHook(JSRuntime *rt, JSInterpreterHook hook, void *closure); | |
16800 | ||
16801 | extern __attribute__((visibility ("default"))) JSBool | |
16802 | JS_SetThrowHook(JSRuntime *rt, JSThrowHook hook, void *closure); | |
16803 | ||
16804 | extern __attribute__((visibility ("default"))) JSBool | |
16805 | JS_SetDebugErrorHook(JSRuntime *rt, JSDebugErrorHook hook, void *closure); | |
16806 | ||
16807 | ||
16808 | ||
16809 | extern __attribute__((visibility ("default"))) size_t | |
16810 | JS_GetObjectTotalSize(JSContext *cx, JSObject *obj); | |
16811 | ||
16812 | extern __attribute__((visibility ("default"))) size_t | |
16813 | JS_GetFunctionTotalSize(JSContext *cx, JSFunction *fun); | |
16814 | ||
16815 | extern __attribute__((visibility ("default"))) size_t | |
16816 | JS_GetScriptTotalSize(JSContext *cx, JSScript *script); | |
16817 | ||
16818 | ||
16819 | ||
16820 | ||
16821 | ||
16822 | ||
16823 | extern __attribute__((visibility ("default"))) uint32 | |
16824 | JS_GetTopScriptFilenameFlags(JSContext *cx, JSStackFrame *fp); | |
16825 | ||
16826 | ||
16827 | ||
16828 | ||
16829 | ||
16830 | extern __attribute__((visibility ("default"))) uint32 | |
16831 | JS_GetScriptFilenameFlags(JSScript *script); | |
16832 | # 511 "jsdbgapi.h" | |
16833 | extern __attribute__((visibility ("default"))) JSBool | |
16834 | JS_FlagScriptFilenamePrefix(JSRuntime *rt, const char *prefix, uint32 flags); | |
16835 | # 526 "jsdbgapi.h" | |
16836 | extern __attribute__((visibility ("default"))) JSBool | |
16837 | JS_IsSystemObject(JSContext *cx, JSObject *obj); | |
16838 | ||
16839 | ||
16840 | ||
16841 | ||
16842 | ||
16843 | ||
16844 | extern __attribute__((visibility ("default"))) JSBool | |
16845 | JS_MakeSystemObject(JSContext *cx, JSObject *obj); | |
16846 | ||
16847 | ||
16848 | ||
16849 | extern __attribute__((visibility ("default"))) JSObject * | |
16850 | JS_UnwrapObject(JSContext *cx, JSObject *obj); | |
16851 | ||
16852 | ||
16853 | ||
16854 | extern __attribute__((visibility ("default"))) void | |
16855 | js_RevertVersion(JSContext *cx); | |
16856 | ||
16857 | extern __attribute__((visibility ("default"))) const JSDebugHooks * | |
16858 | JS_GetGlobalDebugHooks(JSRuntime *rt); | |
16859 | ||
16860 | extern __attribute__((visibility ("default"))) JSDebugHooks * | |
16861 | JS_SetContextDebugHooks(JSContext *cx, const JSDebugHooks *hooks); | |
16862 | ||
16863 | ||
16864 | extern __attribute__((visibility ("default"))) JSDebugHooks * | |
16865 | JS_ClearContextDebugHooks(JSContext *cx); | |
16866 | ||
16867 | extern __attribute__((visibility ("default"))) JSBool | |
16868 | JS_StartProfiling(); | |
16869 | ||
16870 | extern __attribute__((visibility ("default"))) void | |
16871 | JS_StopProfiling(); | |
16872 | ||
16873 | extern __attribute__((visibility ("default"))) JSBool | |
16874 | JS_DefineProfilingFunctions(JSContext *cx, JSObject *obj); | |
16875 | # 624 "jsdbgapi.h" | |
16876 | } | |
16877 | # 49 "jsscript.h" 2 | |
16878 | ||
16879 | ||
16880 | ||
16881 | ||
16882 | ||
16883 | ||
16884 | typedef enum JSTryNoteKind { | |
16885 | JSTRY_CATCH, | |
16886 | JSTRY_FINALLY, | |
16887 | JSTRY_ITER | |
16888 | } JSTryNoteKind; | |
16889 | ||
16890 | namespace js { | |
16891 | # 76 "jsscript.h" | |
16892 | class UpvarCookie | |
16893 | { | |
16894 | uint32 value; | |
16895 | ||
16896 | static const uint32 FREE_VALUE = 0xfffffffful; | |
16897 | ||
16898 | void checkInvariants() { | |
16899 | typedef int js_static_assert47[(sizeof(UpvarCookie) == sizeof(uint32)) ? 1 : -1]; | |
16900 | typedef int js_static_assert48[(UPVAR_LEVEL_LIMIT < FREE_LEVEL) ? 1 : -1]; | |
16901 | } | |
16902 | ||
16903 | public: | |
16904 | ||
16905 | ||
16906 | ||
16907 | ||
16908 | static const uint16 FREE_LEVEL = 0x3fff; | |
16909 | ||
16910 | ||
16911 | ||
16912 | ||
16913 | ||
16914 | static const uint16 UPVAR_LEVEL_LIMIT = 16; | |
16915 | static const uint16 CALLEE_SLOT = 0xffff; | |
16916 | static bool isLevelReserved(uint16 level) { return level >= FREE_LEVEL; } | |
16917 | ||
16918 | bool isFree() const { return value == FREE_VALUE; } | |
16919 | uint32 asInteger() const { return value; } | |
16920 | ||
16921 | uint16 level() const { ((void) 0); return uint16(value >> 16); } | |
16922 | uint16 slot() const { ((void) 0); return uint16(value); } | |
16923 | ||
16924 | void set(const UpvarCookie &other) { set(other.level(), other.slot()); } | |
16925 | void set(uint16 newLevel, uint16 newSlot) { value = (uint32(newLevel) << 16) | newSlot; } | |
16926 | void makeFree() { set(0xffff, 0xffff); ((void) 0); } | |
16927 | void fromInteger(uint32 u32) { value = u32; } | |
16928 | }; | |
16929 | ||
16930 | } | |
16931 | ||
16932 | ||
16933 | ||
16934 | ||
16935 | struct JSTryNote { | |
16936 | uint8 kind; | |
16937 | uint8 padding; | |
16938 | uint16 stackDepth; | |
16939 | uint32 start; | |
16940 | ||
16941 | uint32 length; | |
16942 | }; | |
16943 | ||
16944 | typedef struct JSTryNoteArray { | |
16945 | JSTryNote *vector; | |
16946 | uint32 length; | |
16947 | } JSTryNoteArray; | |
16948 | ||
16949 | typedef struct JSObjectArray { | |
16950 | JSObject **vector; | |
16951 | uint32 length; | |
16952 | } JSObjectArray; | |
16953 | ||
16954 | typedef struct JSUpvarArray { | |
16955 | js::UpvarCookie *vector; | |
16956 | uint32 length; | |
16957 | } JSUpvarArray; | |
16958 | ||
16959 | typedef struct JSConstArray { | |
16960 | js::Value *vector; | |
16961 | uint32 length; | |
16962 | } JSConstArray; | |
16963 | ||
16964 | struct JSArenaPool; | |
16965 | ||
16966 | namespace js { | |
16967 | ||
16968 | struct GlobalSlotArray { | |
16969 | struct Entry { | |
16970 | uint32 atomIndex; | |
16971 | uint32 slot; | |
16972 | }; | |
16973 | Entry *vector; | |
16974 | uint32 length; | |
16975 | }; | |
16976 | ||
16977 | struct Shape; | |
16978 | ||
16979 | enum BindingKind { NONE, ARGUMENT, VARIABLE, CONSTANT, UPVAR }; | |
16980 | ||
16981 | ||
16982 | ||
16983 | ||
16984 | ||
16985 | ||
16986 | ||
16987 | class Bindings { | |
16988 | js::Shape *lastBinding; | |
16989 | uint16 nargs; | |
16990 | uint16 nvars; | |
16991 | uint16 nupvars; | |
16992 | ||
16993 | public: | |
16994 | inline Bindings(JSContext *cx); | |
16995 | ||
16996 | ||
16997 | ||
16998 | ||
16999 | ||
17000 | ||
17001 | inline void transfer(JSContext *cx, Bindings *bindings); | |
17002 | ||
17003 | ||
17004 | ||
17005 | ||
17006 | ||
17007 | ||
17008 | inline void clone(JSContext *cx, Bindings *bindings); | |
17009 | ||
17010 | uint16 countArgs() const { return nargs; } | |
17011 | uint16 countVars() const { return nvars; } | |
17012 | uint16 countUpvars() const { return nupvars; } | |
17013 | ||
17014 | uintN countArgsAndVars() const { return nargs + nvars; } | |
17015 | ||
17016 | uintN countLocalNames() const { return nargs + nvars + nupvars; } | |
17017 | ||
17018 | bool hasUpvars() const { return nupvars > 0; } | |
17019 | bool hasLocalNames() const { return countLocalNames() > 0; } | |
17020 | ||
17021 | ||
17022 | inline const js::Shape *lastShape() const; | |
17023 | ||
17024 | enum { | |
17025 | ||
17026 | ||
17027 | ||
17028 | ||
17029 | BINDING_COUNT_LIMIT = 0xFFFF | |
17030 | }; | |
17031 | # 232 "jsscript.h" | |
17032 | bool add(JSContext *cx, JSAtom *name, BindingKind kind); | |
17033 | ||
17034 | ||
17035 | bool addVariable(JSContext *cx, JSAtom *name) { | |
17036 | return add(cx, name, VARIABLE); | |
17037 | } | |
17038 | bool addConstant(JSContext *cx, JSAtom *name) { | |
17039 | return add(cx, name, CONSTANT); | |
17040 | } | |
17041 | bool addUpvar(JSContext *cx, JSAtom *name) { | |
17042 | return add(cx, name, UPVAR); | |
17043 | } | |
17044 | bool addArgument(JSContext *cx, JSAtom *name, uint16 *slotp) { | |
17045 | ((void) 0); | |
17046 | *slotp = nargs; | |
17047 | return add(cx, name, ARGUMENT); | |
17048 | } | |
17049 | bool addDestructuring(JSContext *cx, uint16 *slotp) { | |
17050 | *slotp = nargs; | |
17051 | return add(cx, __null, ARGUMENT); | |
17052 | } | |
17053 | ||
17054 | ||
17055 | ||
17056 | ||
17057 | ||
17058 | ||
17059 | ||
17060 | BindingKind lookup(JSContext *cx, JSAtom *name, uintN *indexp) const; | |
17061 | ||
17062 | ||
17063 | bool hasBinding(JSContext *cx, JSAtom *name) const { | |
17064 | return lookup(cx, name, __null) != NONE; | |
17065 | } | |
17066 | # 284 "jsscript.h" | |
17067 | jsuword * | |
17068 | getLocalNameArray(JSContext *cx, JSArenaPool *pool); | |
17069 | ||
17070 | ||
17071 | ||
17072 | ||
17073 | ||
17074 | int sharpSlotBase(JSContext *cx); | |
17075 | ||
17076 | ||
17077 | ||
17078 | ||
17079 | ||
17080 | ||
17081 | void makeImmutable(); | |
17082 | # 311 "jsscript.h" | |
17083 | const js::Shape *lastArgument() const; | |
17084 | const js::Shape *lastVariable() const; | |
17085 | const js::Shape *lastUpvar() const; | |
17086 | ||
17087 | void trace(JSTracer *trc); | |
17088 | }; | |
17089 | ||
17090 | } | |
17091 | # 349 "jsscript.h" | |
17092 | struct JSScript { | |
17093 | # 361 "jsscript.h" | |
17094 | static JSScript *NewScript(JSContext *cx, uint32 length, uint32 nsrcnotes, uint32 natoms, | |
17095 | uint32 nobjects, uint32 nupvars, uint32 nregexps, | |
17096 | uint32 ntrynotes, uint32 nconsts, uint32 nglobals, | |
17097 | uint16 nClosedArgs, uint16 nClosedVars, JSVersion version); | |
17098 | ||
17099 | static JSScript *NewScriptFromCG(JSContext *cx, JSCodeGenerator *cg); | |
17100 | ||
17101 | ||
17102 | JSCList links; | |
17103 | jsbytecode *code; | |
17104 | uint32 length; | |
17105 | ||
17106 | private: | |
17107 | uint16 version; | |
17108 | ||
17109 | size_t callCount_; | |
17110 | ||
17111 | public: | |
17112 | uint16 nfixed; | |
17113 | ||
17114 | ||
17115 | ||
17116 | ||
17117 | ||
17118 | ||
17119 | uint8 objectsOffset; | |
17120 | ||
17121 | ||
17122 | uint8 upvarsOffset; | |
17123 | ||
17124 | uint8 regexpsOffset; | |
17125 | ||
17126 | uint8 trynotesOffset; | |
17127 | uint8 globalsOffset; | |
17128 | uint8 constOffset; | |
17129 | ||
17130 | bool noScriptRval:1; | |
17131 | ||
17132 | bool savedCallerFun:1; | |
17133 | bool hasSharps:1; | |
17134 | bool strictModeCode:1; | |
17135 | bool compileAndGo:1; | |
17136 | bool usesEval:1; | |
17137 | bool usesArguments:1; | |
17138 | bool warnedAboutTwoArgumentEval:1; | |
17139 | ||
17140 | ||
17141 | bool hasSingletons:1; | |
17142 | ||
17143 | ||
17144 | ||
17145 | ||
17146 | ||
17147 | jsbytecode *main; | |
17148 | JSAtomMap atomMap; | |
17149 | JSCompartment *compartment; | |
17150 | const char *filename; | |
17151 | uint32 lineno; | |
17152 | uint16 nslots; | |
17153 | uint16 staticLevel; | |
17154 | uint16 nClosedArgs; | |
17155 | uint16 nClosedVars; | |
17156 | js::Bindings bindings; | |
17157 | ||
17158 | JSPrincipals *principals; | |
17159 | union { | |
17160 | # 443 "jsscript.h" | |
17161 | JSObject *object; | |
17162 | JSScript *nextToGC; | |
17163 | } u; | |
17164 | ||
17165 | ||
17166 | ||
17167 | ||
17168 | ||
17169 | uint32 *closedSlots; | |
17170 | ||
17171 | public: | |
17172 | # 492 "jsscript.h" | |
17173 | jssrcnote *notes() { return (jssrcnote *)(code + length); } | |
17174 | ||
17175 | static const uint8 INVALID_OFFSET = 0xFF; | |
17176 | static bool isValidOffset(uint8 offset) { return offset != INVALID_OFFSET; } | |
17177 | ||
17178 | JSObjectArray *objects() { | |
17179 | ((void) 0); | |
17180 | return (JSObjectArray *)((uint8 *) (this + 1) + objectsOffset); | |
17181 | } | |
17182 | ||
17183 | JSUpvarArray *upvars() { | |
17184 | ((void) 0); | |
17185 | return (JSUpvarArray *) ((uint8 *) (this + 1) + upvarsOffset); | |
17186 | } | |
17187 | ||
17188 | JSObjectArray *regexps() { | |
17189 | ((void) 0); | |
17190 | return (JSObjectArray *) ((uint8 *) (this + 1) + regexpsOffset); | |
17191 | } | |
17192 | ||
17193 | JSTryNoteArray *trynotes() { | |
17194 | ((void) 0); | |
17195 | return (JSTryNoteArray *) ((uint8 *) (this + 1) + trynotesOffset); | |
17196 | } | |
17197 | ||
17198 | js::GlobalSlotArray *globals() { | |
17199 | ((void) 0); | |
17200 | return (js::GlobalSlotArray *) ((uint8 *) (this + 1) + globalsOffset); | |
17201 | } | |
17202 | ||
17203 | JSConstArray *consts() { | |
17204 | ((void) 0); | |
17205 | return (JSConstArray *) ((uint8 *) (this + 1) + constOffset); | |
17206 | } | |
17207 | ||
17208 | JSAtom *getAtom(size_t index) { | |
17209 | ((void) 0); | |
17210 | return atomMap.vector[index]; | |
17211 | } | |
17212 | ||
17213 | JSObject *getObject(size_t index) { | |
17214 | JSObjectArray *arr = objects(); | |
17215 | ((void) 0); | |
17216 | return arr->vector[index]; | |
17217 | } | |
17218 | ||
17219 | uint32 getGlobalSlot(size_t index) { | |
17220 | js::GlobalSlotArray *arr = globals(); | |
17221 | ((void) 0); | |
17222 | return arr->vector[index].slot; | |
17223 | } | |
17224 | ||
17225 | JSAtom *getGlobalAtom(size_t index) { | |
17226 | js::GlobalSlotArray *arr = globals(); | |
17227 | ((void) 0); | |
17228 | return getAtom(arr->vector[index].atomIndex); | |
17229 | } | |
17230 | ||
17231 | JSVersion getVersion() const { | |
17232 | return JSVersion(version); | |
17233 | } | |
17234 | ||
17235 | inline JSFunction *getFunction(size_t index); | |
17236 | ||
17237 | inline JSObject *getRegExp(size_t index); | |
17238 | ||
17239 | const js::Value &getConst(size_t index) { | |
17240 | JSConstArray *arr = consts(); | |
17241 | ((void) 0); | |
17242 | return arr->vector[index]; | |
17243 | } | |
17244 | ||
17245 | ||
17246 | ||
17247 | ||
17248 | ||
17249 | ||
17250 | inline bool isEmpty() const; | |
17251 | ||
17252 | uint32 getClosedArg(uint32 index) { | |
17253 | ((void) 0); | |
17254 | return closedSlots[index]; | |
17255 | } | |
17256 | ||
17257 | uint32 getClosedVar(uint32 index) { | |
17258 | ((void) 0); | |
17259 | return closedSlots[nClosedArgs + index]; | |
17260 | } | |
17261 | ||
17262 | void copyClosedSlotsTo(JSScript *other); | |
17263 | }; | |
17264 | ||
17265 | ||
17266 | ||
17267 | ||
17268 | static inline uintN | |
17269 | StackDepth(JSScript *script) | |
17270 | { | |
17271 | return script->nslots - script->nfixed; | |
17272 | } | |
17273 | # 609 "jsscript.h" | |
17274 | extern __attribute__((visibility ("default"))) js::Class js_ScriptClass; | |
17275 | ||
17276 | extern JSObject * | |
17277 | js_InitScriptClass(JSContext *cx, JSObject *obj); | |
17278 | ||
17279 | ||
17280 | ||
17281 | ||
17282 | ||
17283 | extern JSBool | |
17284 | js_InitRuntimeScriptState(JSRuntime *rt); | |
17285 | ||
17286 | ||
17287 | ||
17288 | ||
17289 | ||
17290 | ||
17291 | ||
17292 | extern void | |
17293 | js_FreeRuntimeScriptState(JSRuntime *rt); | |
17294 | ||
17295 | extern const char * | |
17296 | js_SaveScriptFilename(JSContext *cx, const char *filename); | |
17297 | ||
17298 | extern const char * | |
17299 | js_SaveScriptFilenameRT(JSRuntime *rt, const char *filename, uint32 flags); | |
17300 | ||
17301 | extern uint32 | |
17302 | js_GetScriptFilenameFlags(const char *filename); | |
17303 | ||
17304 | extern void | |
17305 | js_MarkScriptFilename(const char *filename); | |
17306 | ||
17307 | extern void | |
17308 | js_MarkScriptFilenames(JSRuntime *rt); | |
17309 | ||
17310 | extern void | |
17311 | js_SweepScriptFilenames(JSRuntime *rt); | |
17312 | ||
17313 | ||
17314 | ||
17315 | ||
17316 | ||
17317 | ||
17318 | ||
17319 | extern __attribute__((visibility ("default"))) void | |
17320 | js_CallNewScriptHook(JSContext *cx, JSScript *script, JSFunction *fun); | |
17321 | ||
17322 | extern void | |
17323 | js_CallDestroyScriptHook(JSContext *cx, JSScript *script); | |
17324 | ||
17325 | ||
17326 | ||
17327 | ||
17328 | ||
17329 | extern void | |
17330 | js_DestroyScript(JSContext *cx, JSScript *script); | |
17331 | ||
17332 | extern void | |
17333 | js_DestroyScriptFromGC(JSContext *cx, JSScript *script); | |
17334 | ||
17335 | ||
17336 | ||
17337 | ||
17338 | ||
17339 | ||
17340 | ||
17341 | extern void | |
17342 | js_DestroyCachedScript(JSContext *cx, JSScript *script); | |
17343 | ||
17344 | extern void | |
17345 | js_TraceScript(JSTracer *trc, JSScript *script); | |
17346 | ||
17347 | extern JSObject * | |
17348 | js_NewScriptObject(JSContext *cx, JSScript *script); | |
17349 | # 692 "jsscript.h" | |
17350 | extern jssrcnote * | |
17351 | js_GetSrcNoteCached(JSContext *cx, JSScript *script, jsbytecode *pc); | |
17352 | ||
17353 | ||
17354 | ||
17355 | ||
17356 | ||
17357 | ||
17358 | extern uintN | |
17359 | js_FramePCToLineNumber(JSContext *cx, JSStackFrame *fp); | |
17360 | ||
17361 | extern uintN | |
17362 | js_PCToLineNumber(JSContext *cx, JSScript *script, jsbytecode *pc); | |
17363 | ||
17364 | extern jsbytecode * | |
17365 | js_LineNumberToPC(JSScript *script, uintN lineno); | |
17366 | ||
17367 | extern __attribute__((visibility ("default"))) uintN | |
17368 | js_GetScriptLineExtent(JSScript *script); | |
17369 | ||
17370 | static inline JSOp | |
17371 | js_GetOpcode(JSContext *cx, JSScript *script, jsbytecode *pc) | |
17372 | { | |
17373 | JSOp op = (JSOp) *pc; | |
17374 | if (op == JSOP_TRAP) | |
17375 | op = JS_GetTrapOpcode(cx, script, pc); | |
17376 | return op; | |
17377 | } | |
17378 | ||
17379 | extern JSScript * | |
17380 | js_CloneScript(JSContext *cx, JSScript *script); | |
17381 | # 734 "jsscript.h" | |
17382 | extern JSBool | |
17383 | js_XDRScript(JSXDRState *xdr, JSScript **scriptp, JSBool *hasMagic); | |
17384 | ||
17385 | inline | |
17386 | ||
17387 | # 737 "jsscript.h" | |
17388 | bool | |
17389 | JSObject::isScript() const | |
17390 | { | |
17391 | return getClass() == &js_ScriptClass; | |
17392 | } | |
17393 | ||
17394 | inline JSScript * | |
17395 | JSObject::getScript() const | |
17396 | { | |
17397 | ((void) 0); | |
17398 | return static_cast<JSScript *>(getPrivate()); | |
17399 | } | |
17400 | # 50 "jsfun.h" 2 | |
17401 | # 117 "jsfun.h" | |
17402 | struct JSFunction : public JSObject_Slots2 | |
17403 | { | |
17404 | ||
17405 | ||
17406 | uint16 nargs; | |
17407 | ||
17408 | uint16 flags; | |
17409 | union U { | |
17410 | struct { | |
17411 | js::Native native; | |
17412 | js::Class *clasp; | |
17413 | ||
17414 | JSNativeTraceInfo *trcinfo; | |
17415 | } n; | |
17416 | struct Scripted { | |
17417 | JSScript *script; | |
17418 | uint16 skipmin; | |
17419 | ||
17420 | ||
17421 | JSPackedBool wrapper; | |
17422 | ||
17423 | ||
17424 | ||
17425 | ||
17426 | ||
17427 | js::Shape *names; | |
17428 | } i; | |
17429 | void *nativeOrScript; | |
17430 | } u; | |
17431 | JSAtom *atom; | |
17432 | ||
17433 | bool optimizedClosure() const { return ((this)->flags & 0xc000) > 0x4000; } | |
17434 | bool needsWrapper() const { return (((this)->flags & 0xc000) == 0xc000) && u.i.skipmin != 0; } | |
17435 | bool isInterpreted() const { return (((this)->flags & 0xc000) >= 0x4000); } | |
17436 | bool isNative() const { return !(((this)->flags & 0xc000) >= 0x4000); } | |
17437 | bool isConstructor() const { return flags & 0x0200; } | |
17438 | bool isHeavyweight() const { return ((flags) & 0x80); } | |
17439 | bool isFlatClosure() const { return ((this)->flags & 0xc000) == 0x8000; } | |
17440 | ||
17441 | bool isFunctionPrototype() const { return flags & 0x0800; } | |
17442 | ||
17443 | ||
17444 | inline bool inStrictMode() const; | |
17445 | ||
17446 | void setArgCount(uint16 nargs) { | |
17447 | ((void) 0); | |
17448 | this->nargs = nargs; | |
17449 | } | |
17450 | ||
17451 | ||
17452 | enum { MAX_ARGS_AND_VARS = 2 * ((1U << 16) - 1) }; | |
17453 | ||
17454 | ||
17455 | ||
17456 | ||
17457 | bool mightEscape() const { | |
17458 | return isInterpreted() && (isFlatClosure() || !script()->bindings.hasUpvars()); | |
17459 | } | |
17460 | ||
17461 | bool joinable() const { | |
17462 | return flags & 0x0001; | |
17463 | } | |
17464 | ||
17465 | JSObject &compiledFunObj() { | |
17466 | return *this; | |
17467 | } | |
17468 | ||
17469 | private: | |
17470 | ||
17471 | ||
17472 | ||
17473 | ||
17474 | ||
17475 | ||
17476 | enum { | |
17477 | METHOD_ATOM_SLOT = JSSLOT_FUN_METHOD_ATOM | |
17478 | }; | |
17479 | ||
17480 | public: | |
17481 | void setJoinable() { | |
17482 | ((void) 0); | |
17483 | getSlotRef(METHOD_ATOM_SLOT).setNull(); | |
17484 | flags |= 0x0001; | |
17485 | } | |
17486 | ||
17487 | ||
17488 | ||
17489 | ||
17490 | ||
17491 | ||
17492 | JSAtom *methodAtom() const { | |
17493 | return (joinable() && getSlot(METHOD_ATOM_SLOT).isString()) | |
17494 | ? (((void) 0), (JSAtom *)getSlot(METHOD_ATOM_SLOT).toString()) | |
17495 | : __null; | |
17496 | } | |
17497 | ||
17498 | void setMethodAtom(JSAtom *atom) { | |
17499 | ((void) 0); | |
17500 | getSlotRef(METHOD_ATOM_SLOT).setString((atom)); | |
17501 | } | |
17502 | ||
17503 | js::Native maybeNative() const { | |
17504 | return isInterpreted() ? __null : u.n.native; | |
17505 | } | |
17506 | ||
17507 | JSScript *script() const { | |
17508 | ((void) 0); | |
17509 | return u.i.script; | |
17510 | } | |
17511 | ||
17512 | static uintN offsetOfNativeOrScript() { | |
17513 | typedef int js_static_assert49[(__builtin_offsetof (U, n.native) == __builtin_offsetof (U, i.script)) ? 1 : -1]; | |
17514 | typedef int js_static_assert50[(__builtin_offsetof (U, n.native) == __builtin_offsetof (U, nativeOrScript)) ? 1 : -1]; | |
17515 | return __builtin_offsetof (JSFunction, u.nativeOrScript); | |
17516 | } | |
17517 | ||
17518 | ||
17519 | static const uint32 CLASS_RESERVED_SLOTS = JSObject::FUN_CLASS_RESERVED_SLOTS; | |
17520 | }; | |
17521 | # 266 "jsfun.h" | |
17522 | extern js::Class js_ArgumentsClass; | |
17523 | ||
17524 | namespace js { | |
17525 | ||
17526 | extern Class StrictArgumentsClass; | |
17527 | ||
17528 | struct ArgumentsData { | |
17529 | js::Value callee; | |
17530 | js::Value slots[1]; | |
17531 | }; | |
17532 | ||
17533 | } | |
17534 | ||
17535 | inline | |
17536 | ||
17537 | # 279 "jsfun.h" | |
17538 | bool | |
17539 | JSObject::isNormalArguments() const | |
17540 | { | |
17541 | return getClass() == &js_ArgumentsClass; | |
17542 | } | |
17543 | ||
17544 | inline | |
17545 | ||
17546 | # 285 "jsfun.h" | |
17547 | bool | |
17548 | JSObject::isStrictArguments() const | |
17549 | { | |
17550 | return getClass() == &js::StrictArgumentsClass; | |
17551 | } | |
17552 | ||
17553 | inline | |
17554 | ||
17555 | # 291 "jsfun.h" | |
17556 | bool | |
17557 | JSObject::isArguments() const | |
17558 | { | |
17559 | return isNormalArguments() || isStrictArguments(); | |
17560 | } | |
17561 | ||
17562 | ||
17563 | ||
17564 | extern __attribute__((visibility ("default"))) js::Class js_CallClass; | |
17565 | extern __attribute__((visibility ("default"))) js::Class js_FunctionClass; | |
17566 | extern js::Class js_DeclEnvClass; | |
17567 | ||
17568 | inline | |
17569 | ||
17570 | # 303 "jsfun.h" | |
17571 | bool | |
17572 | JSObject::isCall() const | |
17573 | { | |
17574 | return getClass() == &js_CallClass; | |
17575 | } | |
17576 | ||
17577 | inline | |
17578 | ||
17579 | # 309 "jsfun.h" | |
17580 | bool | |
17581 | JSObject::isFunction() const | |
17582 | { | |
17583 | return getClass() == &js_FunctionClass; | |
17584 | } | |
17585 | ||
17586 | inline JSFunction * | |
17587 | JSObject::getFunctionPrivate() const | |
17588 | { | |
17589 | ((void) 0); | |
17590 | return reinterpret_cast<JSFunction *>(getPrivate()); | |
17591 | } | |
17592 | ||
17593 | namespace js { | |
17594 | ||
17595 | ||
17596 | ||
17597 | ||
17598 | ||
17599 | ||
17600 | ||
17601 | extern JSObject * | |
17602 | NewCallObject(JSContext *cx, js::Bindings *bindings, JSObject &scopeChain, JSObject *callee); | |
17603 | ||
17604 | ||
17605 | ||
17606 | ||
17607 | ||
17608 | ||
17609 | ||
17610 | static __attribute__((always_inline)) inline | |
17611 | ||
17612 | # 339 "jsfun.h" | |
17613 | bool | |
17614 | IsFunctionObject(const js::Value &v) | |
17615 | { | |
17616 | return v.isObject() && v.toObject().isFunction(); | |
17617 | } | |
17618 | ||
17619 | static __attribute__((always_inline)) inline | |
17620 | ||
17621 | # 345 "jsfun.h" | |
17622 | bool | |
17623 | IsFunctionObject(const js::Value &v, JSObject **funobj) | |
17624 | { | |
17625 | return v.isObject() && (*funobj = &v.toObject())->isFunction(); | |
17626 | } | |
17627 | ||
17628 | static __attribute__((always_inline)) inline | |
17629 | ||
17630 | # 351 "jsfun.h" | |
17631 | bool | |
17632 | IsFunctionObject(const js::Value &v, JSFunction **fun) | |
17633 | { | |
17634 | JSObject *funobj; | |
17635 | bool b = IsFunctionObject(v, &funobj); | |
17636 | if (b) | |
17637 | *fun = funobj->getFunctionPrivate(); | |
17638 | return b; | |
17639 | } | |
17640 | ||
17641 | extern __attribute__((always_inline)) inline | |
17642 | ||
17643 | # 361 "jsfun.h" | |
17644 | bool | |
17645 | SameTraceType(const Value &lhs, const Value &rhs) | |
17646 | { | |
17647 | return SameType(lhs, rhs) && | |
17648 | (lhs.isPrimitive() || | |
17649 | lhs.toObject().isFunction() == rhs.toObject().isFunction()); | |
17650 | } | |
17651 | # 382 "jsfun.h" | |
17652 | inline | |
17653 | ||
17654 | # 382 "jsfun.h" | |
17655 | bool | |
17656 | IsInternalFunctionObject(JSObject *funobj) | |
17657 | { | |
17658 | ((void) 0); | |
17659 | JSFunction *fun = (JSFunction *) funobj->getPrivate(); | |
17660 | return funobj == fun && (fun->flags & 0x08) && !funobj->getParent(); | |
17661 | } | |
17662 | ||
17663 | ||
17664 | static __attribute__((always_inline)) inline | |
17665 | ||
17666 | # 391 "jsfun.h" | |
17667 | bool | |
17668 | IsConstructing(const Value *vp) | |
17669 | { | |
17670 | # 403 "jsfun.h" | |
17671 | return vp[1].isMagic(); | |
17672 | } | |
17673 | ||
17674 | static __attribute__((always_inline)) inline | |
17675 | ||
17676 | # 406 "jsfun.h" | |
17677 | bool | |
17678 | IsConstructing_PossiblyWithGivenThisObject(const Value *vp, JSObject **ctorThis) | |
17679 | { | |
17680 | # 418 "jsfun.h" | |
17681 | bool isCtor = vp[1].isMagic(); | |
17682 | if (isCtor) | |
17683 | *ctorThis = vp[1].getMagicObjectOrNullPayload(); | |
17684 | return isCtor; | |
17685 | } | |
17686 | ||
17687 | inline const char * | |
17688 | GetFunctionNameBytes(JSContext *cx, JSFunction *fun, JSAutoByteString *bytes) | |
17689 | { | |
17690 | if (fun->atom) | |
17691 | return bytes->encode(cx, (fun->atom)); | |
17692 | return js_anonymous_str; | |
17693 | } | |
17694 | ||
17695 | extern __attribute__((visibility ("default"))) bool | |
17696 | IsBuiltinFunctionConstructor(JSFunction *fun); | |
17697 | # 447 "jsfun.h" | |
17698 | const Shape * | |
17699 | LookupInterpretedFunctionPrototype(JSContext *cx, JSObject *funobj); | |
17700 | ||
17701 | } | |
17702 | ||
17703 | extern JSString * | |
17704 | fun_toStringHelper(JSContext *cx, JSObject *obj, uintN indent); | |
17705 | ||
17706 | extern JSFunction * | |
17707 | js_NewFunction(JSContext *cx, JSObject *funobj, js::Native native, uintN nargs, | |
17708 | uintN flags, JSObject *parent, JSAtom *atom); | |
17709 | ||
17710 | extern JSObject * | |
17711 | js_InitFunctionClass(JSContext *cx, JSObject *obj); | |
17712 | ||
17713 | extern JSObject * | |
17714 | js_InitArgumentsClass(JSContext *cx, JSObject *obj); | |
17715 | ||
17716 | extern void | |
17717 | js_TraceFunction(JSTracer *trc, JSFunction *fun); | |
17718 | ||
17719 | extern void | |
17720 | js_FinalizeFunction(JSContext *cx, JSFunction *fun); | |
17721 | ||
17722 | extern JSObject * | |
17723 | js_CloneFunctionObject(JSContext *cx, JSFunction *fun, JSObject *parent, | |
17724 | JSObject *proto); | |
17725 | ||
17726 | inline JSObject * | |
17727 | CloneFunctionObject(JSContext *cx, JSFunction *fun, JSObject *parent) | |
17728 | { | |
17729 | ((void) 0); | |
17730 | JSObject *proto; | |
17731 | if (!js_GetClassPrototype(cx, parent, JSProto_Function, &proto)) | |
17732 | return __null; | |
17733 | return js_CloneFunctionObject(cx, fun, parent, proto); | |
17734 | } | |
17735 | ||
17736 | extern JSObject * | |
17737 | js_AllocFlatClosure(JSContext *cx, JSFunction *fun, JSObject *scopeChain); | |
17738 | ||
17739 | extern JSObject * | |
17740 | js_NewFlatClosure(JSContext *cx, JSFunction *fun, JSOp op, size_t oplen); | |
17741 | ||
17742 | extern JSObject * | |
17743 | js_NewDebuggableFlatClosure(JSContext *cx, JSFunction *fun); | |
17744 | ||
17745 | extern JSFunction * | |
17746 | js_DefineFunction(JSContext *cx, JSObject *obj, jsid id, js::Native native, | |
17747 | uintN nargs, uintN flags); | |
17748 | # 506 "jsfun.h" | |
17749 | extern JSFunction * | |
17750 | js_ValueToFunction(JSContext *cx, const js::Value *vp, uintN flags); | |
17751 | ||
17752 | extern JSObject * | |
17753 | js_ValueToFunctionObject(JSContext *cx, js::Value *vp, uintN flags); | |
17754 | ||
17755 | extern JSObject * | |
17756 | js_ValueToCallableObject(JSContext *cx, js::Value *vp, uintN flags); | |
17757 | ||
17758 | extern void | |
17759 | js_ReportIsNotFunction(JSContext *cx, const js::Value *vp, uintN flags); | |
17760 | ||
17761 | extern JSObject * | |
17762 | js_GetCallObject(JSContext *cx, JSStackFrame *fp); | |
17763 | ||
17764 | extern JSObject * | |
17765 | js_CreateCallObjectOnTrace(JSContext *cx, JSFunction *fun, JSObject *callee, JSObject *scopeChain); | |
17766 | ||
17767 | extern void | |
17768 | js_PutCallObject(JSContext *cx, JSStackFrame *fp); | |
17769 | ||
17770 | extern JSBool | |
17771 | js_PutCallObjectOnTrace(JSContext *cx, JSObject *scopeChain, uint32 nargs, | |
17772 | js::Value *argv, uint32 nvars, js::Value *slots); | |
17773 | ||
17774 | namespace js { | |
17775 | ||
17776 | extern JSBool | |
17777 | GetCallArg(JSContext *cx, JSObject *obj, jsid id, js::Value *vp); | |
17778 | ||
17779 | extern JSBool | |
17780 | GetCallVar(JSContext *cx, JSObject *obj, jsid id, js::Value *vp); | |
17781 | ||
17782 | ||
17783 | ||
17784 | ||
17785 | ||
17786 | extern JSBool | |
17787 | GetCallVarChecked(JSContext *cx, JSObject *obj, jsid id, js::Value *vp); | |
17788 | ||
17789 | extern JSBool | |
17790 | GetCallUpvar(JSContext *cx, JSObject *obj, jsid id, js::Value *vp); | |
17791 | ||
17792 | extern JSBool | |
17793 | SetCallArg(JSContext *cx, JSObject *obj, jsid id, JSBool strict, js::Value *vp); | |
17794 | ||
17795 | extern JSBool | |
17796 | SetCallVar(JSContext *cx, JSObject *obj, jsid id, JSBool strict, js::Value *vp); | |
17797 | ||
17798 | extern JSBool | |
17799 | SetCallUpvar(JSContext *cx, JSObject *obj, jsid id, JSBool strict, js::Value *vp); | |
17800 | ||
17801 | } | |
17802 | ||
17803 | extern JSBool | |
17804 | js_GetArgsValue(JSContext *cx, JSStackFrame *fp, js::Value *vp); | |
17805 | ||
17806 | extern JSBool | |
17807 | js_GetArgsProperty(JSContext *cx, JSStackFrame *fp, jsid id, js::Value *vp); | |
17808 | # 576 "jsfun.h" | |
17809 | extern JSObject * | |
17810 | js_GetArgsObject(JSContext *cx, JSStackFrame *fp); | |
17811 | ||
17812 | extern void | |
17813 | js_PutArgsObject(JSContext *cx, JSStackFrame *fp); | |
17814 | ||
17815 | inline | |
17816 | ||
17817 | # 582 "jsfun.h" | |
17818 | bool | |
17819 | js_IsNamedLambda(JSFunction *fun) { return (fun->flags & 0x08) && fun->atom; } | |
17820 | # 595 "jsfun.h" | |
17821 | const uint32 JS_ARGS_LENGTH_MAX = ((JSUint32)1 << (19)) - 1024; | |
17822 | ||
17823 | ||
17824 | ||
17825 | ||
17826 | ||
17827 | typedef int js_static_assert51[(JS_ARGS_LENGTH_MAX <= ((JSUint32)1 << (30))) ? 1 : -1]; | |
17828 | typedef int js_static_assert52[(((JS_ARGS_LENGTH_MAX << 1) | 1) <= ((jsint)0x7fffffff)) ? 1 : -1]; | |
17829 | ||
17830 | extern JSBool | |
17831 | js_XDRFunctionObject(JSXDRState *xdr, JSObject **objp); | |
17832 | ||
17833 | extern JSBool | |
17834 | js_fun_apply(JSContext *cx, uintN argc, js::Value *vp); | |
17835 | ||
17836 | extern JSBool | |
17837 | js_fun_call(JSContext *cx, uintN argc, js::Value *vp); | |
17838 | # 63 "jscntxt.h" 2 | |
17839 | # 1 "jsgc.h" 1 | |
17840 | # 53 "jsgc.h" | |
17841 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/setjmp.h" 1 3 4 | |
17842 | # 27 "/usr/powerpc64-unknown-linux-gnu/usr/include/setjmp.h" 3 4 | |
17843 | extern "C" { | |
17844 | ||
17845 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/setjmp.h" 1 3 4 | |
17846 | # 31 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/setjmp.h" 3 4 | |
17847 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/wordsize.h" 1 3 4 | |
17848 | # 32 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/setjmp.h" 2 3 4 | |
17849 | # 42 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/setjmp.h" 3 4 | |
17850 | typedef long int __jmp_buf[64] __attribute__ ((__aligned__ (16))); | |
17851 | # 30 "/usr/powerpc64-unknown-linux-gnu/usr/include/setjmp.h" 2 3 4 | |
17852 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/sigset.h" 1 3 4 | |
17853 | # 31 "/usr/powerpc64-unknown-linux-gnu/usr/include/setjmp.h" 2 3 4 | |
17854 | ||
17855 | ||
17856 | ||
17857 | struct __jmp_buf_tag | |
17858 | { | |
17859 | ||
17860 | ||
17861 | ||
17862 | ||
17863 | __jmp_buf __jmpbuf; | |
17864 | int __mask_was_saved; | |
17865 | __sigset_t __saved_mask; | |
17866 | }; | |
17867 | ||
17868 | ||
17869 | ||
17870 | ||
17871 | typedef struct __jmp_buf_tag jmp_buf[1]; | |
17872 | ||
17873 | ||
17874 | ||
17875 | extern int setjmp (jmp_buf __env) throw (); | |
17876 | ||
17877 | ||
17878 | ||
17879 | ||
17880 | ||
17881 | ||
17882 | extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask) throw (); | |
17883 | ||
17884 | ||
17885 | ||
17886 | extern int _setjmp (struct __jmp_buf_tag __env[1]) throw (); | |
17887 | ||
17888 | ||
17889 | ||
17890 | ||
17891 | ||
17892 | ||
17893 | ||
17894 | ||
17895 | ||
17896 | ||
17897 | extern void longjmp (struct __jmp_buf_tag __env[1], int __val) | |
17898 | throw () __attribute__ ((__noreturn__)); | |
17899 | ||
17900 | ||
17901 | ||
17902 | ||
17903 | ||
17904 | ||
17905 | ||
17906 | extern void _longjmp (struct __jmp_buf_tag __env[1], int __val) | |
17907 | throw () __attribute__ ((__noreturn__)); | |
17908 | ||
17909 | ||
17910 | ||
17911 | ||
17912 | ||
17913 | ||
17914 | ||
17915 | typedef struct __jmp_buf_tag sigjmp_buf[1]; | |
17916 | # 102 "/usr/powerpc64-unknown-linux-gnu/usr/include/setjmp.h" 3 4 | |
17917 | extern void siglongjmp (sigjmp_buf __env, int __val) | |
17918 | throw () __attribute__ ((__noreturn__)); | |
17919 | ||
17920 | ||
17921 | ||
17922 | ||
17923 | ||
17924 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/setjmp2.h" 1 3 4 | |
17925 | # 25 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/setjmp2.h" 3 4 | |
17926 | extern void longjmp (struct __jmp_buf_tag __env[1], int __val) throw () __asm__ ("" "__longjmp_chk") | |
17927 | ||
17928 | __attribute__ ((__noreturn__)); | |
17929 | extern void _longjmp (struct __jmp_buf_tag __env[1], int __val) throw () __asm__ ("" "__longjmp_chk") | |
17930 | ||
17931 | __attribute__ ((__noreturn__)); | |
17932 | extern void siglongjmp (struct __jmp_buf_tag __env[1], int __val) throw () __asm__ ("" "__longjmp_chk") | |
17933 | ||
17934 | __attribute__ ((__noreturn__)); | |
17935 | # 110 "/usr/powerpc64-unknown-linux-gnu/usr/include/setjmp.h" 2 3 4 | |
17936 | ||
17937 | ||
17938 | } | |
17939 | # 54 "jsgc.h" 2 | |
17940 | ||
17941 | ||
17942 | ||
17943 | ||
17944 | ||
17945 | ||
17946 | # 1 "jsgcchunk.h" 1 | |
17947 | # 46 "jsgcchunk.h" | |
17948 | namespace js { | |
17949 | ||
17950 | ||
17951 | ||
17952 | ||
17953 | const size_t GC_CHUNK_SHIFT = 20; | |
17954 | ||
17955 | ||
17956 | const size_t GC_CHUNK_SIZE = size_t(1) << GC_CHUNK_SHIFT; | |
17957 | const size_t GC_CHUNK_MASK = GC_CHUNK_SIZE - 1; | |
17958 | ||
17959 | __attribute__((visibility ("default"))) void * | |
17960 | AllocGCChunk(); | |
17961 | ||
17962 | __attribute__((visibility ("default"))) void | |
17963 | FreeGCChunk(void *p); | |
17964 | ||
17965 | class GCChunkAllocator { | |
17966 | public: | |
17967 | GCChunkAllocator() {} | |
17968 | ||
17969 | void *alloc() { | |
17970 | void *chunk = doAlloc(); | |
17971 | ((void) 0); | |
17972 | return chunk; | |
17973 | } | |
17974 | ||
17975 | void free(void *chunk) { | |
17976 | ((void) 0); | |
17977 | ((void) 0); | |
17978 | doFree(chunk); | |
17979 | } | |
17980 | ||
17981 | private: | |
17982 | virtual void *doAlloc() { | |
17983 | return AllocGCChunk(); | |
17984 | } | |
17985 | ||
17986 | virtual void doFree(void *chunk) { | |
17987 | FreeGCChunk(chunk); | |
17988 | } | |
17989 | ||
17990 | ||
17991 | GCChunkAllocator(const GCChunkAllocator &); | |
17992 | void operator=(const GCChunkAllocator &); | |
17993 | }; | |
17994 | ||
17995 | extern GCChunkAllocator defaultGCChunkAllocator; | |
17996 | ||
17997 | } | |
17998 | # 61 "jsgc.h" 2 | |
17999 | ||
18000 | ||
18001 | # 1 "jsversion.h" 1 | |
18002 | # 64 "jsgc.h" 2 | |
18003 | ||
18004 | ||
18005 | # 1 "jsgcstats.h" 1 | |
18006 | # 58 "jsgcstats.h" | |
18007 | namespace js { | |
18008 | namespace gc { | |
18009 | ||
18010 | ||
18011 | ||
18012 | ||
18013 | enum ConservativeGCTest { | |
18014 | CGCT_VALID, | |
18015 | CGCT_VALIDWITHOFFSET, | |
18016 | CGCT_LOWBITSET, | |
18017 | CGCT_NOTARENA, | |
18018 | CGCT_NOTCHUNK, | |
18019 | CGCT_FREEARENA, | |
18020 | CGCT_WRONGTAG, | |
18021 | CGCT_NOTLIVE, | |
18022 | CGCT_END | |
18023 | }; | |
18024 | ||
18025 | struct ConservativeGCStats { | |
18026 | uint32 counter[gc::CGCT_END]; | |
18027 | ||
18028 | ||
18029 | void add(const ConservativeGCStats &another) { | |
18030 | for (size_t i = 0; i != (sizeof (counter) / sizeof (counter)[0]); ++i) | |
18031 | counter[i] += another.counter[i]; | |
18032 | } | |
18033 | ||
18034 | void dump(FILE *fp); | |
18035 | }; | |
18036 | # 136 "jsgcstats.h" | |
18037 | } | |
18038 | # 175 "jsgcstats.h" | |
18039 | } | |
18040 | ||
18041 | extern __attribute__((visibility ("default"))) void | |
18042 | js_DumpGCStats(JSRuntime *rt, FILE *fp); | |
18043 | # 67 "jsgc.h" 2 | |
18044 | ||
18045 | ||
18046 | struct JSCompartment; | |
18047 | ||
18048 | extern "C" void | |
18049 | js_TraceXML(JSTracer *trc, JSXML* thing); | |
18050 | ||
18051 | ||
18052 | ||
18053 | ||
18054 | ||
18055 | ||
18056 | ||
18057 | namespace js { | |
18058 | ||
18059 | struct Shape; | |
18060 | ||
18061 | namespace gc { | |
18062 | ||
18063 | ||
18064 | ||
18065 | ||
18066 | ||
18067 | enum FinalizeKind { | |
18068 | FINALIZE_OBJECT0, | |
18069 | FINALIZE_OBJECT2, | |
18070 | FINALIZE_OBJECT4, | |
18071 | FINALIZE_OBJECT8, | |
18072 | FINALIZE_OBJECT12, | |
18073 | FINALIZE_OBJECT16, | |
18074 | FINALIZE_OBJECT_LAST = FINALIZE_OBJECT16, | |
18075 | FINALIZE_FUNCTION, | |
18076 | ||
18077 | FINALIZE_XML, | |
18078 | ||
18079 | FINALIZE_SHORT_STRING, | |
18080 | FINALIZE_STRING, | |
18081 | FINALIZE_EXTERNAL_STRING, | |
18082 | FINALIZE_LIMIT | |
18083 | }; | |
18084 | ||
18085 | const uintN JS_FINALIZE_OBJECT_LIMIT = 6; | |
18086 | ||
18087 | ||
18088 | struct ArenaHeader { | |
18089 | JSCompartment *compartment; | |
18090 | Arena<FreeCell> *next; | |
18091 | FreeCell *freeList; | |
18092 | unsigned thingKind; | |
18093 | bool isUsed; | |
18094 | size_t thingSize; | |
18095 | ||
18096 | ||
18097 | ||
18098 | }; | |
18099 | ||
18100 | template <typename T> | |
18101 | union ThingOrCell { | |
18102 | T t; | |
18103 | FreeCell cell; | |
18104 | }; | |
18105 | ||
18106 | template <typename T, size_t N, size_t R> | |
18107 | struct Things { | |
18108 | ThingOrCell<T> things[N]; | |
18109 | char filler[R]; | |
18110 | }; | |
18111 | ||
18112 | template <typename T, size_t N> | |
18113 | struct Things<T, N, 0> { | |
18114 | ThingOrCell<T> things[N]; | |
18115 | }; | |
18116 | ||
18117 | template <typename T> | |
18118 | struct Arena { | |
18119 | static const size_t ArenaSize = 4096; | |
18120 | ||
18121 | struct AlignedArenaHeader { | |
18122 | T align[(sizeof(ArenaHeader) + sizeof(T) - 1) / sizeof(T)]; | |
18123 | }; | |
18124 | ||
18125 | ||
18126 | union { | |
18127 | ArenaHeader aheader; | |
18128 | AlignedArenaHeader align; | |
18129 | }; | |
18130 | ||
18131 | static const size_t ThingsPerArena = (ArenaSize - sizeof(AlignedArenaHeader)) / sizeof(T); | |
18132 | static const size_t FillerSize = ArenaSize - sizeof(AlignedArenaHeader) - sizeof(T) * ThingsPerArena; | |
18133 | Things<T, ThingsPerArena, FillerSize> t; | |
18134 | ||
18135 | inline Chunk *chunk() const; | |
18136 | inline size_t arenaIndex() const; | |
18137 | ||
18138 | inline ArenaHeader *header() { return &aheader; }; | |
18139 | ||
18140 | inline MarkingDelay *getMarkingDelay() const; | |
18141 | inline ArenaBitmap *bitmap() const; | |
18142 | ||
18143 | inline ConservativeGCTest mark(T *thing, JSTracer *trc); | |
18144 | void markDelayedChildren(JSTracer *trc); | |
18145 | inline bool inFreeList(void *thing) const; | |
18146 | inline T *getAlignedThing(void *thing); | |
18147 | ||
18148 | ||
18149 | ||
18150 | ||
18151 | void init(JSCompartment *compartment, unsigned thingKind); | |
18152 | }; | |
18153 | typedef int js_static_assert53[(sizeof(Arena<FreeCell>) == 4096) ? 1 : -1]; | |
18154 | ||
18155 | ||
18156 | ||
18157 | ||
18158 | ||
18159 | static const uint32 BLACK = 0; | |
18160 | ||
18161 | ||
18162 | struct ArenaBitmap { | |
18163 | static const size_t BitCount = Arena<FreeCell>::ArenaSize / Cell::CellSize; | |
18164 | static const size_t BitWords = BitCount / (8 * 8); | |
18165 | ||
18166 | uintptr_t bitmap[BitWords]; | |
18167 | ||
18168 | __attribute__((always_inline)) inline bool isMarked(size_t bit, uint32 color) { | |
18169 | bit += color; | |
18170 | ((void) 0); | |
18171 | uintptr_t *word = &bitmap[bit / (8 * 8)]; | |
18172 | return *word & (uintptr_t(1) << (bit % (8 * 8))); | |
18173 | } | |
18174 | ||
18175 | __attribute__((always_inline)) inline bool markIfUnmarked(size_t bit, uint32 color) { | |
18176 | ((void) 0); | |
18177 | uintptr_t *word = &bitmap[bit / (8 * 8)]; | |
18178 | uintptr_t mask = (uintptr_t(1) << (bit % (8 * 8))); | |
18179 | if (*word & mask) | |
18180 | return false; | |
18181 | *word |= mask; | |
18182 | if (color != BLACK) { | |
18183 | bit += color; | |
18184 | word = &bitmap[bit / (8 * 8)]; | |
18185 | mask = (uintptr_t(1) << (bit % (8 * 8))); | |
18186 | if (*word & mask) | |
18187 | return false; | |
18188 | *word |= mask; | |
18189 | } | |
18190 | return true; | |
18191 | } | |
18192 | ||
18193 | __attribute__((always_inline)) inline void unmark(size_t bit, uint32 color) { | |
18194 | bit += color; | |
18195 | ((void) 0); | |
18196 | uintptr_t *word = &bitmap[bit / (8 * 8)]; | |
18197 | *word &= ~(uintptr_t(1) << (bit % (8 * 8))); | |
18198 | } | |
18199 | # 232 "jsgc.h" | |
18200 | }; | |
18201 | ||
18202 | ||
18203 | typedef int js_static_assert54[(Arena<FreeCell>::ArenaSize % Cell::CellSize == 0) ? 1 : -1]; | |
18204 | typedef int js_static_assert55[(ArenaBitmap::BitCount % (8 * 8) == 0) ? 1 : -1]; | |
18205 | ||
18206 | ||
18207 | struct MarkingDelay { | |
18208 | Arena<Cell> *link; | |
18209 | uintptr_t unmarkedChildren; | |
18210 | jsuword start; | |
18211 | ||
18212 | void init() | |
18213 | { | |
18214 | link = __null; | |
18215 | unmarkedChildren = 0; | |
18216 | } | |
18217 | }; | |
18218 | ||
18219 | struct EmptyArenaLists { | |
18220 | ||
18221 | Arena<FreeCell> *cellFreeList; | |
18222 | ||
18223 | ||
18224 | Arena<FreeCell> *freeLists[FINALIZE_LIMIT]; | |
18225 | ||
18226 | void init() { | |
18227 | PodZero(this); | |
18228 | } | |
18229 | ||
18230 | Arena<FreeCell> *getOtherArena() { | |
18231 | Arena<FreeCell> *arena = cellFreeList; | |
18232 | if (arena) { | |
18233 | cellFreeList = arena->header()->next; | |
18234 | return arena; | |
18235 | } | |
18236 | for (int i = 0; i < FINALIZE_LIMIT; i++) { | |
18237 | if ((arena = (Arena<FreeCell> *) freeLists[i])) { | |
18238 | freeLists[i] = freeLists[i]->header()->next; | |
18239 | return arena; | |
18240 | } | |
18241 | } | |
18242 | ; | |
18243 | return __null; | |
18244 | } | |
18245 | ||
18246 | template <typename T> | |
18247 | inline Arena<T> *getTypedFreeList(unsigned thingKind); | |
18248 | ||
18249 | template <typename T> | |
18250 | inline Arena<T> *getNext(JSCompartment *comp, unsigned thingKind); | |
18251 | ||
18252 | template <typename T> | |
18253 | inline void insert(Arena<T> *arena); | |
18254 | }; | |
18255 | ||
18256 | template <typename T> | |
18257 | inline Arena<T> * | |
18258 | EmptyArenaLists::getTypedFreeList(unsigned thingKind) { | |
18259 | ((void) 0); | |
18260 | Arena<T> *arena = (Arena<T>*) freeLists[thingKind]; | |
18261 | if (arena) { | |
18262 | freeLists[thingKind] = freeLists[thingKind]->header()->next; | |
18263 | return arena; | |
18264 | } | |
18265 | return __null; | |
18266 | } | |
18267 | ||
18268 | template<typename T> | |
18269 | inline Arena<T> * | |
18270 | EmptyArenaLists::getNext(JSCompartment *comp, unsigned thingKind) { | |
18271 | Arena<T> *arena = getTypedFreeList<T>(thingKind); | |
18272 | if (arena) { | |
18273 | ((void) 0); | |
18274 | ((void) 0); | |
18275 | arena->header()->isUsed = true; | |
18276 | arena->header()->thingKind = thingKind; | |
18277 | arena->header()->compartment = comp; | |
18278 | return arena; | |
18279 | } | |
18280 | arena = (Arena<T> *)getOtherArena(); | |
18281 | ((void) 0); | |
18282 | arena->init(comp, thingKind); | |
18283 | return arena; | |
18284 | } | |
18285 | ||
18286 | template <typename T> | |
18287 | inline void | |
18288 | EmptyArenaLists::insert(Arena<T> *arena) { | |
18289 | unsigned thingKind = arena->header()->thingKind; | |
18290 | ((void) 0); | |
18291 | arena->header()->next = freeLists[thingKind]; | |
18292 | freeLists[thingKind] = (Arena<FreeCell> *) arena; | |
18293 | } | |
18294 | ||
18295 | ||
18296 | struct ChunkInfo { | |
18297 | Chunk *link; | |
18298 | JSRuntime *runtime; | |
18299 | EmptyArenaLists emptyArenaLists; | |
18300 | size_t age; | |
18301 | size_t numFree; | |
18302 | }; | |
18303 | ||
18304 | ||
18305 | struct Chunk { | |
18306 | static const size_t BytesPerArena = sizeof(Arena<FreeCell>) + | |
18307 | sizeof(ArenaBitmap) + | |
18308 | sizeof(MarkingDelay); | |
18309 | ||
18310 | static const size_t ArenasPerChunk = (GC_CHUNK_SIZE - sizeof(ChunkInfo)) / BytesPerArena; | |
18311 | ||
18312 | Arena<FreeCell> arenas[ArenasPerChunk]; | |
18313 | ArenaBitmap bitmaps[ArenasPerChunk]; | |
18314 | MarkingDelay markingDelay[ArenasPerChunk]; | |
18315 | ||
18316 | ChunkInfo info; | |
18317 | ||
18318 | void clearMarkBitmap(); | |
18319 | void init(JSRuntime *rt); | |
18320 | ||
18321 | bool unused(); | |
18322 | bool hasAvailableArenas(); | |
18323 | bool withinArenasRange(Cell *cell); | |
18324 | ||
18325 | template <typename T> | |
18326 | Arena<T> *allocateArena(JSCompartment *comp, unsigned thingKind); | |
18327 | ||
18328 | template <typename T> | |
18329 | void releaseArena(Arena<T> *a); | |
18330 | ||
18331 | JSRuntime *getRuntime(); | |
18332 | }; | |
18333 | typedef int js_static_assert56[(sizeof(Chunk) <= GC_CHUNK_SIZE) ? 1 : -1]; | |
18334 | typedef int js_static_assert57[(sizeof(Chunk) + Chunk::BytesPerArena > GC_CHUNK_SIZE) ? 1 : -1]; | |
18335 | ||
18336 | Arena<Cell> * | |
18337 | Cell::arena() const | |
18338 | { | |
18339 | uintptr_t addr = uintptr_t(this); | |
18340 | ((void) 0); | |
18341 | addr &= ~(Arena<FreeCell>::ArenaSize - 1); | |
18342 | return reinterpret_cast<Arena<Cell> *>(addr); | |
18343 | } | |
18344 | ||
18345 | Chunk * | |
18346 | Cell::chunk() const | |
18347 | { | |
18348 | uintptr_t addr = uintptr_t(this); | |
18349 | ((void) 0); | |
18350 | addr &= ~(GC_CHUNK_SIZE - 1); | |
18351 | return reinterpret_cast<Chunk *>(addr); | |
18352 | } | |
18353 | ||
18354 | ArenaBitmap * | |
18355 | Cell::bitmap() const | |
18356 | { | |
18357 | return &chunk()->bitmaps[arena()->arenaIndex()]; | |
18358 | } | |
18359 | ||
18360 | ||
18361 | size_t | |
18362 | Cell::cellIndex() const | |
18363 | { | |
18364 | return reinterpret_cast<const FreeCell *>(this) - reinterpret_cast<FreeCell *>(&arena()->t); | |
18365 | } | |
18366 | ||
18367 | template <typename T> | |
18368 | Chunk * | |
18369 | Arena<T>::chunk() const | |
18370 | { | |
18371 | uintptr_t addr = uintptr_t(this); | |
18372 | ((void) 0); | |
18373 | addr &= ~(GC_CHUNK_SIZE - 1); | |
18374 | return reinterpret_cast<Chunk *>(addr); | |
18375 | } | |
18376 | ||
18377 | template <typename T> | |
18378 | size_t | |
18379 | Arena<T>::arenaIndex() const | |
18380 | { | |
18381 | return reinterpret_cast<const Arena<FreeCell> *>(this) - chunk()->arenas; | |
18382 | } | |
18383 | ||
18384 | template <typename T> | |
18385 | MarkingDelay * | |
18386 | Arena<T>::getMarkingDelay() const | |
18387 | { | |
18388 | return &chunk()->markingDelay[arenaIndex()]; | |
18389 | } | |
18390 | ||
18391 | template <typename T> | |
18392 | ArenaBitmap * | |
18393 | Arena<T>::bitmap() const | |
18394 | { | |
18395 | return &chunk()->bitmaps[arenaIndex()]; | |
18396 | } | |
18397 | ||
18398 | template <typename T> | |
18399 | inline T * | |
18400 | Arena<T>::getAlignedThing(void *thing) | |
18401 | { | |
18402 | jsuword start = reinterpret_cast<jsuword>(&t.things[0]); | |
18403 | jsuword offset = reinterpret_cast<jsuword>(thing) - start; | |
18404 | offset -= offset % aheader.thingSize; | |
18405 | return reinterpret_cast<T *>(start + offset); | |
18406 | } | |
18407 | # 449 "jsgc.h" | |
18408 | static void | |
18409 | AssertValidColor(const void *thing, uint32 color) | |
18410 | { | |
18411 | ((void) 0); | |
18412 | } | |
18413 | ||
18414 | inline | |
18415 | ||
18416 | # 455 "jsgc.h" | |
18417 | bool | |
18418 | Cell::isMarked(uint32 color = BLACK) const | |
18419 | { | |
18420 | AssertValidColor(this, color); | |
18421 | return bitmap()->isMarked(cellIndex(), color); | |
18422 | } | |
18423 | ||
18424 | ||
18425 | bool | |
18426 | # 463 "jsgc.h" | |
18427 | Cell::markIfUnmarked(uint32 color = BLACK) const | |
18428 | { | |
18429 | AssertValidColor(this, color); | |
18430 | return bitmap()->markIfUnmarked(cellIndex(), color); | |
18431 | } | |
18432 | ||
18433 | void | |
18434 | Cell::unmark(uint32 color) const | |
18435 | { | |
18436 | ((void) 0); | |
18437 | AssertValidColor(this, color); | |
18438 | bitmap()->unmark(cellIndex(), color); | |
18439 | } | |
18440 | ||
18441 | JSCompartment * | |
18442 | Cell::compartment() const | |
18443 | { | |
18444 | return arena()->header()->compartment; | |
18445 | } | |
18446 | ||
18447 | template <typename T> | |
18448 | static inline | |
18449 | Arena<T> * | |
18450 | GetArena(Cell *cell) | |
18451 | { | |
18452 | return reinterpret_cast<Arena<T> *>(cell->arena()); | |
18453 | } | |
18454 | # 501 "jsgc.h" | |
18455 | const size_t GC_ARENA_ALLOCATION_TRIGGER = 30 * js::GC_CHUNK_SIZE; | |
18456 | ||
18457 | ||
18458 | ||
18459 | ||
18460 | ||
18461 | ||
18462 | ||
18463 | const float GC_HEAP_GROWTH_FACTOR = 3.0f; | |
18464 | ||
18465 | static inline size_t | |
18466 | GetFinalizableTraceKind(size_t thingKind) | |
18467 | { | |
18468 | typedef int js_static_assert58[(JSExternalString::TYPE_LIMIT == 8) ? 1 : -1]; | |
18469 | ||
18470 | static const uint8 map[FINALIZE_LIMIT] = { | |
18471 | 0, | |
18472 | 0, | |
18473 | 0, | |
18474 | 0, | |
18475 | 0, | |
18476 | 0, | |
18477 | 0, | |
18478 | ||
18479 | 2, | |
18480 | ||
18481 | 1, | |
18482 | 1, | |
18483 | 1, | |
18484 | }; | |
18485 | ||
18486 | ((void) 0); | |
18487 | return map[thingKind]; | |
18488 | } | |
18489 | ||
18490 | static inline | |
18491 | ||
18492 | # 536 "jsgc.h" | |
18493 | bool | |
18494 | IsFinalizableStringKind(unsigned thingKind) | |
18495 | { | |
18496 | return unsigned(FINALIZE_SHORT_STRING) <= thingKind && | |
18497 | thingKind <= unsigned(FINALIZE_EXTERNAL_STRING); | |
18498 | } | |
18499 | ||
18500 | ||
18501 | ||
18502 | ||
18503 | ||
18504 | static inline intN | |
18505 | GetExternalStringGCType(JSExternalString *str) | |
18506 | { | |
18507 | typedef int js_static_assert59[(FINALIZE_STRING + 1 == FINALIZE_EXTERNAL_STRING) ? 1 : -1]; | |
18508 | ((void) 0); | |
18509 | ||
18510 | unsigned thingKind = str->externalStringType; | |
18511 | ((void) 0); | |
18512 | return intN(thingKind); | |
18513 | } | |
18514 | ||
18515 | static inline uint32 | |
18516 | GetGCThingTraceKind(void *thing) | |
18517 | { | |
18518 | ((void) 0); | |
18519 | if (JSString::isStatic(thing)) | |
18520 | return 1; | |
18521 | Cell *cell = reinterpret_cast<Cell *>(thing); | |
18522 | return GetFinalizableTraceKind(cell->arena()->header()->thingKind); | |
18523 | } | |
18524 | ||
18525 | static inline JSRuntime * | |
18526 | GetGCThingRuntime(void *thing) | |
18527 | { | |
18528 | return reinterpret_cast<FreeCell *>(thing)->chunk()->info.runtime; | |
18529 | } | |
18530 | ||
18531 | ||
18532 | ||
18533 | ||
18534 | ||
18535 | ||
18536 | ||
18537 | struct ArenaList { | |
18538 | Arena<FreeCell> *head; | |
18539 | Arena<FreeCell> *cursor; | |
18540 | ||
18541 | inline void init() { | |
18542 | head = __null; | |
18543 | cursor = __null; | |
18544 | } | |
18545 | ||
18546 | inline Arena<FreeCell> *getNextWithFreeList() { | |
18547 | Arena<FreeCell> *a; | |
18548 | while (cursor != __null) { | |
18549 | ArenaHeader *aheader = cursor->header(); | |
18550 | a = cursor; | |
18551 | cursor = aheader->next; | |
18552 | if (aheader->freeList) | |
18553 | return a; | |
18554 | } | |
18555 | return __null; | |
18556 | } | |
18557 | # 621 "jsgc.h" | |
18558 | inline void insert(Arena<FreeCell> *a) { | |
18559 | a->header()->next = head; | |
18560 | head = a; | |
18561 | } | |
18562 | ||
18563 | void releaseAll() { | |
18564 | while (head) { | |
18565 | Arena<FreeCell> *next = head->header()->next; | |
18566 | head->chunk()->releaseArena(head); | |
18567 | head = next; | |
18568 | } | |
18569 | head = __null; | |
18570 | cursor = __null; | |
18571 | } | |
18572 | ||
18573 | inline bool isEmpty() const { | |
18574 | return (head == __null); | |
18575 | } | |
18576 | }; | |
18577 | ||
18578 | struct FreeLists { | |
18579 | FreeCell **finalizables[FINALIZE_LIMIT]; | |
18580 | ||
18581 | void purge(); | |
18582 | ||
18583 | inline FreeCell *getNext(uint32 kind) { | |
18584 | FreeCell *top = __null; | |
18585 | if (finalizables[kind]) { | |
18586 | top = *finalizables[kind]; | |
18587 | if (top) { | |
18588 | *finalizables[kind] = top->link; | |
18589 | } else { | |
18590 | finalizables[kind] = __null; | |
18591 | } | |
18592 | ||
18593 | ||
18594 | ||
18595 | ||
18596 | } | |
18597 | return top; | |
18598 | } | |
18599 | ||
18600 | template <typename T> | |
18601 | inline void populate(Arena<T> *a, uint32 thingKind) { | |
18602 | finalizables[thingKind] = &a->header()->freeList; | |
18603 | } | |
18604 | # 677 "jsgc.h" | |
18605 | }; | |
18606 | } | |
18607 | ||
18608 | typedef Vector<gc::Chunk *, 32, SystemAllocPolicy> GCChunks; | |
18609 | ||
18610 | struct GCPtrHasher | |
18611 | { | |
18612 | typedef void *Lookup; | |
18613 | ||
18614 | static HashNumber hash(void *key) { | |
18615 | return HashNumber(uintptr_t(key) >> JS_GCTHING_ZEROBITS); | |
18616 | } | |
18617 | ||
18618 | static bool match(void *l, void *k) { return l == k; } | |
18619 | }; | |
18620 | ||
18621 | typedef HashMap<void *, uint32, GCPtrHasher, SystemAllocPolicy> GCLocks; | |
18622 | ||
18623 | struct RootInfo { | |
18624 | RootInfo() {} | |
18625 | RootInfo(const char *name, JSGCRootType type) : name(name), type(type) {} | |
18626 | const char *name; | |
18627 | JSGCRootType type; | |
18628 | }; | |
18629 | ||
18630 | typedef js::HashMap<void *, | |
18631 | RootInfo, | |
18632 | js::DefaultHasher<void *>, | |
18633 | js::SystemAllocPolicy> RootedValueMap; | |
18634 | ||
18635 | ||
18636 | typedef int js_static_assert60[(sizeof(HashNumber) == 4) ? 1 : -1]; | |
18637 | ||
18638 | struct WrapperHasher | |
18639 | { | |
18640 | typedef Value Lookup; | |
18641 | ||
18642 | static HashNumber hash(Value key) { | |
18643 | uint64 bits = (Jsvalify(key)); | |
18644 | return (uint32)bits ^ (uint32)(bits >> 32); | |
18645 | } | |
18646 | ||
18647 | static bool match(const Value &l, const Value &k) { return l == k; } | |
18648 | }; | |
18649 | ||
18650 | typedef HashMap<Value, Value, WrapperHasher, SystemAllocPolicy> WrapperMap; | |
18651 | ||
18652 | class AutoValueVector; | |
18653 | class AutoIdVector; | |
18654 | } | |
18655 | ||
18656 | static inline void | |
18657 | CheckGCFreeListLink(js::gc::FreeCell *cell) | |
18658 | { | |
18659 | ||
18660 | ||
18661 | ||
18662 | ||
18663 | ((void) 0) | |
18664 | ||
18665 | ; | |
18666 | ((void) 0); | |
18667 | } | |
18668 | ||
18669 | extern | |
18670 | ||
18671 | # 741 "jsgc.h" | |
18672 | bool | |
18673 | RefillFinalizableFreeList(JSContext *cx, unsigned thingKind); | |
18674 | # 753 "jsgc.h" | |
18675 | extern intN | |
18676 | js_GetExternalStringGCType(JSString *str); | |
18677 | ||
18678 | extern __attribute__((visibility ("default"))) uint32 | |
18679 | js_GetGCThingTraceKind(void *thing); | |
18680 | # 770 "jsgc.h" | |
18681 | extern JSBool | |
18682 | js_InitGC(JSRuntime *rt, uint32 maxbytes); | |
18683 | ||
18684 | extern void | |
18685 | js_FinishGC(JSRuntime *rt); | |
18686 | ||
18687 | extern JSBool | |
18688 | js_AddRoot(JSContext *cx, js::Value *vp, const char *name); | |
18689 | ||
18690 | extern JSBool | |
18691 | js_AddGCThingRoot(JSContext *cx, void **rp, const char *name); | |
18692 | # 789 "jsgc.h" | |
18693 | extern uint32 | |
18694 | js_MapGCRoots(JSRuntime *rt, JSGCRootMapFun map, void *data); | |
18695 | ||
18696 | ||
18697 | typedef struct JSPtrTable { | |
18698 | size_t count; | |
18699 | void **array; | |
18700 | } JSPtrTable; | |
18701 | ||
18702 | extern JSBool | |
18703 | js_RegisterCloseableIterator(JSContext *cx, JSObject *obj); | |
18704 | ||
18705 | ||
18706 | ||
18707 | ||
18708 | ||
18709 | ||
18710 | extern JSBool | |
18711 | js_LockGCThingRT(JSRuntime *rt, void *thing); | |
18712 | ||
18713 | extern void | |
18714 | js_UnlockGCThingRT(JSRuntime *rt, void *thing); | |
18715 | ||
18716 | extern __attribute__((visibility ("default"))) bool | |
18717 | IsAboutToBeFinalized(JSContext *cx, void *thing); | |
18718 | ||
18719 | extern __attribute__((visibility ("default"))) bool | |
18720 | js_GCThingIsMarked(void *thing, uintN color); | |
18721 | ||
18722 | extern void | |
18723 | js_TraceStackFrame(JSTracer *trc, JSStackFrame *fp); | |
18724 | ||
18725 | namespace js { | |
18726 | ||
18727 | extern void | |
18728 | MarkRuntime(JSTracer *trc); | |
18729 | ||
18730 | extern void | |
18731 | TraceRuntime(JSTracer *trc); | |
18732 | ||
18733 | extern __attribute__((visibility ("default"))) void | |
18734 | MarkContext(JSTracer *trc, JSContext *acx); | |
18735 | ||
18736 | ||
18737 | extern void | |
18738 | TriggerGC(JSRuntime *rt); | |
18739 | ||
18740 | ||
18741 | extern void | |
18742 | TriggerCompartmentGC(JSCompartment *comp); | |
18743 | ||
18744 | extern void | |
18745 | MaybeGC(JSContext *cx); | |
18746 | ||
18747 | } | |
18748 | ||
18749 | ||
18750 | ||
18751 | ||
18752 | typedef enum JSGCInvocationKind { | |
18753 | ||
18754 | GC_NORMAL = 0, | |
18755 | ||
18756 | ||
18757 | ||
18758 | ||
18759 | ||
18760 | GC_LAST_CONTEXT = 1 | |
18761 | } JSGCInvocationKind; | |
18762 | ||
18763 | ||
18764 | extern void | |
18765 | js_GC(JSContext *cx, JSCompartment *comp, JSGCInvocationKind gckind); | |
18766 | # 870 "jsgc.h" | |
18767 | extern void | |
18768 | js_WaitForGC(JSRuntime *rt); | |
18769 | ||
18770 | ||
18771 | ||
18772 | ||
18773 | ||
18774 | ||
18775 | ||
18776 | extern void | |
18777 | js_DestroyScriptsToGC(JSContext *cx, JSCompartment *comp); | |
18778 | ||
18779 | namespace js { | |
18780 | # 896 "jsgc.h" | |
18781 | class GCHelperThread { | |
18782 | static const size_t FREE_ARRAY_SIZE = size_t(1) << 16; | |
18783 | static const size_t FREE_ARRAY_LENGTH = FREE_ARRAY_SIZE / sizeof(void *); | |
18784 | ||
18785 | PRThread* thread; | |
18786 | PRCondVar* wakeup; | |
18787 | PRCondVar* sweepingDone; | |
18788 | bool shutdown; | |
18789 | bool sweeping; | |
18790 | ||
18791 | Vector<void **, 16, js::SystemAllocPolicy> freeVector; | |
18792 | void **freeCursor; | |
18793 | void **freeCursorEnd; | |
18794 | ||
18795 | __attribute__((visibility ("default"))) void | |
18796 | replenishAndFreeLater(void *ptr); | |
18797 | ||
18798 | static void freeElementsAndArray(void **array, void **end) { | |
18799 | ((void) 0); | |
18800 | for (void **p = array; p != end; ++p) | |
18801 | js_free(*p); | |
18802 | js_free(array); | |
18803 | } | |
18804 | ||
18805 | static void threadMain(void* arg); | |
18806 | ||
18807 | void threadLoop(JSRuntime *rt); | |
18808 | void doSweep(); | |
18809 | ||
18810 | public: | |
18811 | GCHelperThread() | |
18812 | : thread(__null), | |
18813 | wakeup(__null), | |
18814 | sweepingDone(__null), | |
18815 | shutdown(false), | |
18816 | sweeping(false), | |
18817 | freeCursor(__null), | |
18818 | freeCursorEnd(__null) { } | |
18819 | ||
18820 | bool init(JSRuntime *rt); | |
18821 | void finish(JSRuntime *rt); | |
18822 | ||
18823 | ||
18824 | void startBackgroundSweep(JSRuntime *rt); | |
18825 | ||
18826 | ||
18827 | void waitBackgroundSweepEnd(JSRuntime *rt); | |
18828 | ||
18829 | void freeLater(void *ptr) { | |
18830 | ((void) 0); | |
18831 | if (freeCursor != freeCursorEnd) | |
18832 | *freeCursor++ = ptr; | |
18833 | else | |
18834 | replenishAndFreeLater(ptr); | |
18835 | } | |
18836 | }; | |
18837 | ||
18838 | ||
18839 | ||
18840 | struct GCChunkHasher { | |
18841 | typedef gc::Chunk *Lookup; | |
18842 | ||
18843 | ||
18844 | ||
18845 | ||
18846 | ||
18847 | static HashNumber hash(gc::Chunk *chunk) { | |
18848 | ((void) 0); | |
18849 | return HashNumber(jsuword(chunk) >> GC_CHUNK_SHIFT); | |
18850 | } | |
18851 | ||
18852 | static bool match(gc::Chunk *k, gc::Chunk *l) { | |
18853 | ((void) 0); | |
18854 | ((void) 0); | |
18855 | return k == l; | |
18856 | } | |
18857 | }; | |
18858 | ||
18859 | typedef HashSet<js::gc::Chunk *, GCChunkHasher, SystemAllocPolicy> GCChunkSet; | |
18860 | ||
18861 | struct ConservativeGCThreadData { | |
18862 | ||
18863 | ||
18864 | ||
18865 | ||
18866 | ||
18867 | jsuword *nativeStackTop; | |
18868 | ||
18869 | union { | |
18870 | jmp_buf jmpbuf; | |
18871 | jsuword words[(((sizeof(jmp_buf))+(sizeof(jsuword))-1)/(sizeof(jsuword)))]; | |
18872 | } registerSnapshot; | |
18873 | ||
18874 | ||
18875 | ||
18876 | ||
18877 | ||
18878 | ||
18879 | unsigned requestThreshold; | |
18880 | ||
18881 | __attribute__((noinline)) void recordStackTop(); | |
18882 | ||
18883 | ||
18884 | void updateForRequestEnd(unsigned suspendCount) { | |
18885 | if (suspendCount) | |
18886 | recordStackTop(); | |
18887 | else | |
18888 | nativeStackTop = __null; | |
18889 | } | |
18890 | ||
18891 | ||
18892 | bool hasStackToScan() const { | |
18893 | return !!nativeStackTop; | |
18894 | } | |
18895 | }; | |
18896 | ||
18897 | struct GCMarker : public JSTracer { | |
18898 | private: | |
18899 | ||
18900 | uint32 color; | |
18901 | public: | |
18902 | jsuword stackLimit; | |
18903 | ||
18904 | js::gc::Arena<js::gc::Cell> *unmarkedArenaStackTop; | |
18905 | # 1036 "jsgc.h" | |
18906 | public: | |
18907 | explicit GCMarker(JSContext *cx); | |
18908 | ~GCMarker(); | |
18909 | ||
18910 | uint32 getMarkColor() const { | |
18911 | return color; | |
18912 | } | |
18913 | ||
18914 | void setMarkColor(uint32 newColor) { | |
18915 | ||
18916 | ||
18917 | ||
18918 | ||
18919 | markDelayedChildren(); | |
18920 | color = newColor; | |
18921 | } | |
18922 | ||
18923 | void delayMarkingChildren(void *thing); | |
18924 | ||
18925 | __attribute__((visibility ("default"))) void markDelayedChildren(); | |
18926 | }; | |
18927 | ||
18928 | void | |
18929 | MarkStackRangeConservatively(JSTracer *trc, Value *begin, Value *end); | |
18930 | ||
18931 | } | |
18932 | ||
18933 | extern void | |
18934 | js_FinalizeStringRT(JSRuntime *rt, JSString *str); | |
18935 | ||
18936 | ||
18937 | ||
18938 | ||
18939 | ||
18940 | extern void | |
18941 | js_MarkTraps(JSTracer *trc); | |
18942 | ||
18943 | namespace js { | |
18944 | namespace gc { | |
18945 | # 1095 "jsgc.h" | |
18946 | extern | |
18947 | ||
18948 | # 1095 "jsgc.h" | |
18949 | bool | |
18950 | SetProtoCheckingForCycles(JSContext *cx, JSObject *obj, JSObject *proto); | |
18951 | ||
18952 | JSCompartment * | |
18953 | NewCompartment(JSContext *cx, JSPrincipals *principals); | |
18954 | ||
18955 | } | |
18956 | } | |
18957 | ||
18958 | inline JSCompartment * | |
18959 | JSObject::getCompartment() const | |
18960 | { | |
18961 | return compartment(); | |
18962 | } | |
18963 | # 64 "jscntxt.h" 2 | |
18964 | ||
18965 | ||
18966 | # 1 "jsinterp.h" 1 | |
18967 | # 53 "jsinterp.h" | |
18968 | struct JSFrameRegs | |
18969 | { | |
18970 | ||
18971 | js::Value *sp; | |
18972 | jsbytecode *pc; | |
18973 | JSStackFrame *fp; | |
18974 | }; | |
18975 | ||
18976 | ||
18977 | enum JSInterpMode | |
18978 | { | |
18979 | JSINTERP_NORMAL = 0, | |
18980 | JSINTERP_RECORD = 1, | |
18981 | JSINTERP_SAFEPOINT = 2, | |
18982 | JSINTERP_PROFILE = 3 | |
18983 | }; | |
18984 | ||
18985 | ||
18986 | enum JSFrameFlags | |
18987 | { | |
18988 | ||
18989 | JSFRAME_GLOBAL = 0x1, | |
18990 | JSFRAME_FUNCTION = 0x2, | |
18991 | JSFRAME_DUMMY = 0x4, | |
18992 | ||
18993 | ||
18994 | JSFRAME_EVAL = 0x8, | |
18995 | JSFRAME_DEBUGGER = 0x10, | |
18996 | JSFRAME_GENERATOR = 0x20, | |
18997 | JSFRAME_FLOATING_GENERATOR = 0x40, | |
18998 | JSFRAME_CONSTRUCTING = 0x80, | |
18999 | ||
19000 | ||
19001 | JSFRAME_ASSIGNING = 0x100, | |
19002 | JSFRAME_YIELDING = 0x200, | |
19003 | JSFRAME_FINISHED_IN_INTERPRETER = 0x400, | |
19004 | ||
19005 | ||
19006 | JSFRAME_OVERRIDE_ARGS = 0x1000, | |
19007 | JSFRAME_OVERFLOW_ARGS = 0x2000, | |
19008 | JSFRAME_UNDERFLOW_ARGS = 0x4000, | |
19009 | ||
19010 | ||
19011 | JSFRAME_HAS_IMACRO_PC = 0x8000, | |
19012 | JSFRAME_HAS_CALL_OBJ = 0x10000, | |
19013 | JSFRAME_HAS_ARGS_OBJ = 0x20000, | |
19014 | JSFRAME_HAS_HOOK_DATA = 0x40000, | |
19015 | JSFRAME_HAS_ANNOTATION = 0x80000, | |
19016 | JSFRAME_HAS_RVAL = 0x100000, | |
19017 | JSFRAME_HAS_SCOPECHAIN = 0x200000, | |
19018 | JSFRAME_HAS_PREVPC = 0x400000 | |
19019 | }; | |
19020 | ||
19021 | namespace js { namespace mjit { struct JITScript; } } | |
19022 | ||
19023 | ||
19024 | ||
19025 | ||
19026 | ||
19027 | struct JSStackFrame | |
19028 | { | |
19029 | private: | |
19030 | mutable uint32 flags_; | |
19031 | union { | |
19032 | JSScript *script; | |
19033 | JSFunction *fun; | |
19034 | } exec; | |
19035 | union { | |
19036 | uintN nactual; | |
19037 | JSObject *obj; | |
19038 | JSScript *script; | |
19039 | } args; | |
19040 | mutable JSObject *scopeChain_; | |
19041 | JSStackFrame *prev_; | |
19042 | void *ncode_; | |
19043 | ||
19044 | ||
19045 | js::Value rval_; | |
19046 | jsbytecode *prevpc_; | |
19047 | jsbytecode *imacropc_; | |
19048 | void *hookData_; | |
19049 | void *annotation_; | |
19050 | ||
19051 | friend class js::StackSpace; | |
19052 | friend class js::FrameRegsIter; | |
19053 | friend struct JSContext; | |
19054 | ||
19055 | inline void initPrev(JSContext *cx); | |
19056 | ||
19057 | public: | |
19058 | # 159 "jsinterp.h" | |
19059 | bool isFunctionFrame() const { | |
19060 | return !!(flags_ & JSFRAME_FUNCTION); | |
19061 | } | |
19062 | ||
19063 | bool isGlobalFrame() const { | |
19064 | return !!(flags_ & JSFRAME_GLOBAL); | |
19065 | } | |
19066 | ||
19067 | bool isDummyFrame() const { | |
19068 | return !!(flags_ & JSFRAME_DUMMY); | |
19069 | } | |
19070 | ||
19071 | bool isScriptFrame() const { | |
19072 | return !!(flags_ & (JSFRAME_FUNCTION | JSFRAME_GLOBAL)); | |
19073 | } | |
19074 | ||
19075 | bool isEvalFrame() const { | |
19076 | ((void) 0); | |
19077 | return flags_ & JSFRAME_EVAL; | |
19078 | } | |
19079 | ||
19080 | bool isExecuteFrame() const { | |
19081 | return !!(flags_ & (JSFRAME_GLOBAL | JSFRAME_EVAL)); | |
19082 | } | |
19083 | # 195 "jsinterp.h" | |
19084 | inline void initCallFrame(JSContext *cx, JSObject &callee, JSFunction *fun, | |
19085 | uint32 nactual, uint32 flags); | |
19086 | ||
19087 | ||
19088 | inline void resetInvokeCallFrame(); | |
19089 | ||
19090 | ||
19091 | inline void initCallFrameCallerHalf(JSContext *cx, uint32 flags, void *ncode); | |
19092 | inline void initCallFrameEarlyPrologue(JSFunction *fun, uint32 nactual); | |
19093 | inline void initCallFrameLatePrologue(); | |
19094 | ||
19095 | ||
19096 | inline void initEvalFrame(JSContext *cx, JSScript *script, JSStackFrame *prev, | |
19097 | uint32 flags); | |
19098 | inline void initGlobalFrame(JSScript *script, JSObject &chain, uint32 flags); | |
19099 | ||
19100 | ||
19101 | inline void stealFrameAndSlots(js::Value *vp, JSStackFrame *otherfp, | |
19102 | js::Value *othervp, js::Value *othersp); | |
19103 | ||
19104 | ||
19105 | inline void initDummyFrame(JSContext *cx, JSObject &chain); | |
19106 | # 231 "jsinterp.h" | |
19107 | JSStackFrame *prev() const { | |
19108 | return prev_; | |
19109 | } | |
19110 | ||
19111 | inline void resetGeneratorPrev(JSContext *cx); | |
19112 | # 245 "jsinterp.h" | |
19113 | js::Value *slots() const { | |
19114 | return (js::Value *)(this + 1); | |
19115 | } | |
19116 | ||
19117 | js::Value *base() const { | |
19118 | return slots() + script()->nfixed; | |
19119 | } | |
19120 | ||
19121 | js::Value &varSlot(uintN i) { | |
19122 | ((void) 0); | |
19123 | ((void) 0); | |
19124 | return slots()[i]; | |
19125 | } | |
19126 | # 270 "jsinterp.h" | |
19127 | jsbytecode *pc(JSContext *cx, JSStackFrame *next = __null); | |
19128 | ||
19129 | jsbytecode *prevpc() { | |
19130 | ((void) 0); | |
19131 | return prevpc_; | |
19132 | } | |
19133 | ||
19134 | JSScript *script() const { | |
19135 | ((void) 0); | |
19136 | return isFunctionFrame() | |
19137 | ? isEvalFrame() ? args.script : fun()->script() | |
19138 | : exec.script; | |
19139 | } | |
19140 | ||
19141 | JSScript *functionScript() const { | |
19142 | ((void) 0); | |
19143 | return isEvalFrame() ? args.script : fun()->script(); | |
19144 | } | |
19145 | ||
19146 | JSScript *globalScript() const { | |
19147 | ((void) 0); | |
19148 | return exec.script; | |
19149 | } | |
19150 | ||
19151 | JSScript *maybeScript() const { | |
19152 | return isScriptFrame() ? script() : __null; | |
19153 | } | |
19154 | ||
19155 | size_t numFixed() const { | |
19156 | return script()->nfixed; | |
19157 | } | |
19158 | ||
19159 | size_t numSlots() const { | |
19160 | return script()->nslots; | |
19161 | } | |
19162 | ||
19163 | size_t numGlobalVars() const { | |
19164 | ((void) 0); | |
19165 | return exec.script->nfixed; | |
19166 | } | |
19167 | ||
19168 | ||
19169 | ||
19170 | ||
19171 | ||
19172 | ||
19173 | ||
19174 | JSFunction* fun() const { | |
19175 | ((void) 0); | |
19176 | return exec.fun; | |
19177 | } | |
19178 | ||
19179 | JSFunction* maybeFun() const { | |
19180 | return isFunctionFrame() ? fun() : __null; | |
19181 | } | |
19182 | # 346 "jsinterp.h" | |
19183 | bool hasArgs() const { | |
19184 | return isFunctionFrame() && !isEvalFrame(); | |
19185 | } | |
19186 | ||
19187 | uintN numFormalArgs() const { | |
19188 | ((void) 0); | |
19189 | return fun()->nargs; | |
19190 | } | |
19191 | ||
19192 | js::Value &formalArg(uintN i) const { | |
19193 | ((void) 0); | |
19194 | return formalArgs()[i]; | |
19195 | } | |
19196 | ||
19197 | js::Value *formalArgs() const { | |
19198 | ((void) 0); | |
19199 | return (js::Value *)this - numFormalArgs(); | |
19200 | } | |
19201 | ||
19202 | js::Value *formalArgsEnd() const { | |
19203 | ((void) 0); | |
19204 | return (js::Value *)this; | |
19205 | } | |
19206 | ||
19207 | js::Value *maybeFormalArgs() const { | |
19208 | return (flags_ & (JSFRAME_FUNCTION | JSFRAME_EVAL)) == JSFRAME_FUNCTION | |
19209 | ? formalArgs() | |
19210 | : __null; | |
19211 | } | |
19212 | ||
19213 | inline uintN numActualArgs() const; | |
19214 | inline js::Value *actualArgs() const; | |
19215 | inline js::Value *actualArgsEnd() const; | |
19216 | ||
19217 | inline js::Value &canonicalActualArg(uintN i) const; | |
19218 | template <class Op> inline void forEachCanonicalActualArg(Op op); | |
19219 | template <class Op> inline void forEachFormalArg(Op op); | |
19220 | ||
19221 | inline void clearMissingArgs(); | |
19222 | ||
19223 | bool hasArgsObj() const { | |
19224 | return !!(flags_ & JSFRAME_HAS_ARGS_OBJ); | |
19225 | } | |
19226 | ||
19227 | JSObject &argsObj() const { | |
19228 | ((void) 0); | |
19229 | ((void) 0); | |
19230 | return *args.obj; | |
19231 | } | |
19232 | ||
19233 | JSObject *maybeArgsObj() const { | |
19234 | return hasArgsObj() ? &argsObj() : __null; | |
19235 | } | |
19236 | ||
19237 | inline void setArgsObj(JSObject &obj); | |
19238 | inline void clearArgsObj(); | |
19239 | # 417 "jsinterp.h" | |
19240 | js::Value &functionThis() const { | |
19241 | ((void) 0); | |
19242 | if (isEvalFrame()) | |
19243 | return ((js::Value *)this)[-1]; | |
19244 | return formalArgs()[-1]; | |
19245 | } | |
19246 | ||
19247 | JSObject &constructorThis() const { | |
19248 | ((void) 0); | |
19249 | return formalArgs()[-1].toObject(); | |
19250 | } | |
19251 | ||
19252 | js::Value &globalThis() const { | |
19253 | ((void) 0); | |
19254 | return ((js::Value *)this)[-1]; | |
19255 | } | |
19256 | ||
19257 | js::Value &thisValue() const { | |
19258 | if (flags_ & (JSFRAME_EVAL | JSFRAME_GLOBAL)) | |
19259 | return ((js::Value *)this)[-1]; | |
19260 | return formalArgs()[-1]; | |
19261 | } | |
19262 | ||
19263 | inline bool computeThis(JSContext *cx); | |
19264 | # 449 "jsinterp.h" | |
19265 | js::Value &calleeValue() const { | |
19266 | ((void) 0); | |
19267 | if (isEvalFrame()) | |
19268 | return ((js::Value *)this)[-2]; | |
19269 | return formalArgs()[-2]; | |
19270 | } | |
19271 | ||
19272 | JSObject &callee() const { | |
19273 | ((void) 0); | |
19274 | return calleeValue().toObject(); | |
19275 | } | |
19276 | ||
19277 | JSObject *maybeCallee() const { | |
19278 | return isFunctionFrame() ? &callee() : __null; | |
19279 | } | |
19280 | ||
19281 | ||
19282 | ||
19283 | ||
19284 | ||
19285 | ||
19286 | ||
19287 | bool getValidCalleeObject(JSContext *cx, js::Value *vp); | |
19288 | # 491 "jsinterp.h" | |
19289 | JSObject &scopeChain() const { | |
19290 | ((void) 0); | |
19291 | if (!(flags_ & JSFRAME_HAS_SCOPECHAIN)) { | |
19292 | scopeChain_ = callee().getParent(); | |
19293 | flags_ |= JSFRAME_HAS_SCOPECHAIN; | |
19294 | } | |
19295 | return *scopeChain_; | |
19296 | } | |
19297 | ||
19298 | bool hasCallObj() const { | |
19299 | return !!(flags_ & JSFRAME_HAS_CALL_OBJ); | |
19300 | } | |
19301 | ||
19302 | inline JSObject &callObj() const; | |
19303 | inline JSObject *maybeCallObj() const; | |
19304 | inline void setScopeChainNoCallObj(JSObject &obj); | |
19305 | inline void setScopeChainAndCallObj(JSObject &obj); | |
19306 | inline void clearCallObj(); | |
19307 | # 518 "jsinterp.h" | |
19308 | bool hasImacropc() const { | |
19309 | return flags_ & JSFRAME_HAS_IMACRO_PC; | |
19310 | } | |
19311 | ||
19312 | jsbytecode *imacropc() const { | |
19313 | ((void) 0); | |
19314 | return imacropc_; | |
19315 | } | |
19316 | ||
19317 | jsbytecode *maybeImacropc() const { | |
19318 | return hasImacropc() ? imacropc() : __null; | |
19319 | } | |
19320 | ||
19321 | void clearImacropc() { | |
19322 | flags_ &= ~JSFRAME_HAS_IMACRO_PC; | |
19323 | } | |
19324 | ||
19325 | void setImacropc(jsbytecode *pc) { | |
19326 | ((void) 0); | |
19327 | ((void) 0); | |
19328 | imacropc_ = pc; | |
19329 | flags_ |= JSFRAME_HAS_IMACRO_PC; | |
19330 | } | |
19331 | ||
19332 | ||
19333 | ||
19334 | void* annotation() const { | |
19335 | return (flags_ & JSFRAME_HAS_ANNOTATION) ? annotation_ : __null; | |
19336 | } | |
19337 | ||
19338 | void setAnnotation(void *annot) { | |
19339 | flags_ |= JSFRAME_HAS_ANNOTATION; | |
19340 | annotation_ = annot; | |
19341 | } | |
19342 | ||
19343 | ||
19344 | ||
19345 | bool hasHookData() const { | |
19346 | return !!(flags_ & JSFRAME_HAS_HOOK_DATA); | |
19347 | } | |
19348 | ||
19349 | void* hookData() const { | |
19350 | ((void) 0); | |
19351 | return hookData_; | |
19352 | } | |
19353 | ||
19354 | void* maybeHookData() const { | |
19355 | return hasHookData() ? hookData_ : __null; | |
19356 | } | |
19357 | ||
19358 | void setHookData(void *v) { | |
19359 | hookData_ = v; | |
19360 | flags_ |= JSFRAME_HAS_HOOK_DATA; | |
19361 | } | |
19362 | ||
19363 | ||
19364 | ||
19365 | const js::Value &returnValue() { | |
19366 | if (!(flags_ & JSFRAME_HAS_RVAL)) | |
19367 | rval_.setUndefined(); | |
19368 | return rval_; | |
19369 | } | |
19370 | ||
19371 | void markReturnValue() { | |
19372 | flags_ |= JSFRAME_HAS_RVAL; | |
19373 | } | |
19374 | ||
19375 | void setReturnValue(const js::Value &v) { | |
19376 | rval_ = v; | |
19377 | markReturnValue(); | |
19378 | } | |
19379 | ||
19380 | void clearReturnValue() { | |
19381 | rval_.setUndefined(); | |
19382 | markReturnValue(); | |
19383 | } | |
19384 | ||
19385 | ||
19386 | ||
19387 | void *nativeReturnAddress() const { | |
19388 | return ncode_; | |
19389 | } | |
19390 | ||
19391 | void setNativeReturnAddress(void *addr) { | |
19392 | ncode_ = addr; | |
19393 | } | |
19394 | ||
19395 | void **addressOfNativeReturnAddress() { | |
19396 | return &ncode_; | |
19397 | } | |
19398 | # 617 "jsinterp.h" | |
19399 | bool isGeneratorFrame() const { | |
19400 | return !!(flags_ & JSFRAME_GENERATOR); | |
19401 | } | |
19402 | ||
19403 | bool isFloatingGenerator() const { | |
19404 | ((void) 0); | |
19405 | return !!(flags_ & JSFRAME_FLOATING_GENERATOR); | |
19406 | } | |
19407 | ||
19408 | void initFloatingGenerator() { | |
19409 | ((void) 0); | |
19410 | flags_ |= (JSFRAME_GENERATOR | JSFRAME_FLOATING_GENERATOR); | |
19411 | } | |
19412 | ||
19413 | void unsetFloatingGenerator() { | |
19414 | flags_ &= ~JSFRAME_FLOATING_GENERATOR; | |
19415 | } | |
19416 | ||
19417 | void setFloatingGenerator() { | |
19418 | flags_ |= JSFRAME_FLOATING_GENERATOR; | |
19419 | } | |
19420 | ||
19421 | ||
19422 | ||
19423 | ||
19424 | ||
19425 | bool isConstructing() const { | |
19426 | return !!(flags_ & JSFRAME_CONSTRUCTING); | |
19427 | } | |
19428 | ||
19429 | uint32 isConstructingFlag() const { | |
19430 | ((void) 0); | |
19431 | ((void) 0); | |
19432 | return flags_; | |
19433 | } | |
19434 | ||
19435 | bool isDebuggerFrame() const { | |
19436 | return !!(flags_ & JSFRAME_DEBUGGER); | |
19437 | } | |
19438 | ||
19439 | bool isEvalOrDebuggerFrame() const { | |
19440 | return !!(flags_ & (JSFRAME_EVAL | JSFRAME_DEBUGGER)); | |
19441 | } | |
19442 | ||
19443 | bool hasOverriddenArgs() const { | |
19444 | return !!(flags_ & JSFRAME_OVERRIDE_ARGS); | |
19445 | } | |
19446 | ||
19447 | bool hasOverflowArgs() const { | |
19448 | return !!(flags_ & JSFRAME_OVERFLOW_ARGS); | |
19449 | } | |
19450 | ||
19451 | void setOverriddenArgs() { | |
19452 | flags_ |= JSFRAME_OVERRIDE_ARGS; | |
19453 | } | |
19454 | ||
19455 | bool isAssigning() const { | |
19456 | return !!(flags_ & JSFRAME_ASSIGNING); | |
19457 | } | |
19458 | ||
19459 | void setAssigning() { | |
19460 | flags_ |= JSFRAME_ASSIGNING; | |
19461 | } | |
19462 | ||
19463 | void clearAssigning() { | |
19464 | flags_ &= ~JSFRAME_ASSIGNING; | |
19465 | } | |
19466 | ||
19467 | bool isYielding() { | |
19468 | return !!(flags_ & JSFRAME_YIELDING); | |
19469 | } | |
19470 | ||
19471 | void setYielding() { | |
19472 | flags_ |= JSFRAME_YIELDING; | |
19473 | } | |
19474 | ||
19475 | void clearYielding() { | |
19476 | flags_ &= ~JSFRAME_YIELDING; | |
19477 | } | |
19478 | ||
19479 | void setFinishedInInterpreter() { | |
19480 | flags_ |= JSFRAME_FINISHED_IN_INTERPRETER; | |
19481 | } | |
19482 | ||
19483 | bool finishedInInterpreter() const { | |
19484 | return !!(flags_ & JSFRAME_FINISHED_IN_INTERPRETER); | |
19485 | } | |
19486 | # 717 "jsinterp.h" | |
19487 | inline JSObject &varobj(js::StackSegment *seg) const; | |
19488 | inline JSObject &varobj(JSContext *cx) const; | |
19489 | ||
19490 | ||
19491 | ||
19492 | static size_t offsetOfFlags() { | |
19493 | return __builtin_offsetof (JSStackFrame, flags_); | |
19494 | } | |
19495 | ||
19496 | static size_t offsetOfExec() { | |
19497 | return __builtin_offsetof (JSStackFrame, exec); | |
19498 | } | |
19499 | ||
19500 | void *addressOfArgs() { | |
19501 | return &args; | |
19502 | } | |
19503 | ||
19504 | static size_t offsetOfScopeChain() { | |
19505 | return __builtin_offsetof (JSStackFrame, scopeChain_); | |
19506 | } | |
19507 | ||
19508 | JSObject **addressOfScopeChain() { | |
19509 | ((void) 0); | |
19510 | return &scopeChain_; | |
19511 | } | |
19512 | ||
19513 | static size_t offsetOfPrev() { | |
19514 | return __builtin_offsetof (JSStackFrame, prev_); | |
19515 | } | |
19516 | ||
19517 | static size_t offsetOfReturnValue() { | |
19518 | return __builtin_offsetof (JSStackFrame, rval_); | |
19519 | } | |
19520 | ||
19521 | static ptrdiff_t offsetOfncode() { | |
19522 | return __builtin_offsetof (JSStackFrame, ncode_); | |
19523 | } | |
19524 | ||
19525 | static ptrdiff_t offsetOfCallee(JSFunction *fun) { | |
19526 | ((void) 0); | |
19527 | return -(fun->nargs + 2) * sizeof(js::Value); | |
19528 | } | |
19529 | ||
19530 | static ptrdiff_t offsetOfThis(JSFunction *fun) { | |
19531 | return fun == __null | |
19532 | ? -1 * ptrdiff_t(sizeof(js::Value)) | |
19533 | : -(fun->nargs + 1) * ptrdiff_t(sizeof(js::Value)); | |
19534 | } | |
19535 | ||
19536 | static ptrdiff_t offsetOfFormalArg(JSFunction *fun, uintN i) { | |
19537 | ((void) 0); | |
19538 | return (-(int)fun->nargs + i) * sizeof(js::Value); | |
19539 | } | |
19540 | ||
19541 | static size_t offsetOfFixed(uintN i) { | |
19542 | return sizeof(JSStackFrame) + i * sizeof(js::Value); | |
19543 | } | |
19544 | ||
19545 | ||
19546 | ||
19547 | void staticAsserts() { | |
19548 | typedef int js_static_assert61[(__builtin_offsetof (JSStackFrame, rval_) % sizeof(js::Value) == 0) ? 1 : -1]; | |
19549 | typedef int js_static_assert62[(sizeof(JSStackFrame) % sizeof(js::Value) == 0) ? 1 : -1]; | |
19550 | } | |
19551 | ||
19552 | ||
19553 | ||
19554 | ||
19555 | ||
19556 | ||
19557 | ||
19558 | void methodjitStaticAsserts(); | |
19559 | ||
19560 | ||
19561 | ||
19562 | ||
19563 | ||
19564 | }; | |
19565 | ||
19566 | namespace js { | |
19567 | ||
19568 | static const size_t VALUES_PER_STACK_FRAME = sizeof(JSStackFrame) / sizeof(Value); | |
19569 | ||
19570 | extern JSObject * | |
19571 | GetBlockChain(JSContext *cx, JSStackFrame *fp); | |
19572 | ||
19573 | extern JSObject * | |
19574 | GetBlockChainFast(JSContext *cx, JSStackFrame *fp, JSOp op, size_t oplen); | |
19575 | ||
19576 | extern JSObject * | |
19577 | GetScopeChain(JSContext *cx); | |
19578 | # 816 "jsinterp.h" | |
19579 | extern JSObject * | |
19580 | GetScopeChain(JSContext *cx, JSStackFrame *fp); | |
19581 | ||
19582 | extern JSObject * | |
19583 | GetScopeChainFast(JSContext *cx, JSStackFrame *fp, JSOp op, size_t oplen); | |
19584 | ||
19585 | ||
19586 | ||
19587 | ||
19588 | ||
19589 | void | |
19590 | ReportIncompatibleMethod(JSContext *cx, Value *vp, Class *clasp); | |
19591 | # 837 "jsinterp.h" | |
19592 | template <typename T> | |
19593 | bool GetPrimitiveThis(JSContext *cx, Value *vp, T *v); | |
19594 | ||
19595 | inline void | |
19596 | PutActivationObjects(JSContext *cx, JSStackFrame *fp); | |
19597 | ||
19598 | inline void | |
19599 | PutOwnedActivationObjects(JSContext *cx, JSStackFrame *fp); | |
19600 | ||
19601 | ||
19602 | ||
19603 | ||
19604 | ||
19605 | ||
19606 | ||
19607 | extern | |
19608 | ||
19609 | # 852 "jsinterp.h" | |
19610 | bool | |
19611 | BoxThisForVp(JSContext *cx, js::Value *vp); | |
19612 | ||
19613 | ||
19614 | ||
19615 | ||
19616 | ||
19617 | struct CallArgs | |
19618 | { | |
19619 | Value *argv_; | |
19620 | uintN argc_; | |
19621 | protected: | |
19622 | CallArgs() {} | |
19623 | CallArgs(Value *argv, uintN argc) : argv_(argv), argc_(argc) {} | |
19624 | public: | |
19625 | Value *base() const { return argv_ - 2; } | |
19626 | Value &callee() const { return argv_[-2]; } | |
19627 | Value &thisv() const { return argv_[-1]; } | |
19628 | Value &operator[](unsigned i) const { ((void) 0); return argv_[i]; } | |
19629 | Value *argv() const { return argv_; } | |
19630 | uintN argc() const { return argc_; } | |
19631 | Value &rval() const { return argv_[-2]; } | |
19632 | }; | |
19633 | # 884 "jsinterp.h" | |
19634 | extern | |
19635 | ||
19636 | # 884 "jsinterp.h" | |
19637 | bool | |
19638 | Invoke(JSContext *cx, const CallArgs &args, uint32 flags); | |
19639 | # 911 "jsinterp.h" | |
19640 | class InvokeSessionGuard; | |
19641 | # 938 "jsinterp.h" | |
19642 | extern | |
19643 | ||
19644 | # 938 "jsinterp.h" | |
19645 | bool | |
19646 | ExternalInvoke(JSContext *cx, const Value &thisv, const Value &fval, | |
19647 | uintN argc, Value *argv, Value *rval); | |
19648 | ||
19649 | extern | |
19650 | ||
19651 | # 942 "jsinterp.h" | |
19652 | bool | |
19653 | ExternalGetOrSet(JSContext *cx, JSObject *obj, jsid id, const Value &fval, | |
19654 | JSAccessMode mode, uintN argc, Value *argv, Value *rval); | |
19655 | # 954 "jsinterp.h" | |
19656 | extern | |
19657 | ||
19658 | # 954 "jsinterp.h" | |
19659 | bool | |
19660 | InvokeConstructor(JSContext *cx, const CallArgs &args); | |
19661 | ||
19662 | extern | |
19663 | ||
19664 | # 957 "jsinterp.h" | |
19665 | bool | |
19666 | InvokeConstructorWithGivenThis(JSContext *cx, JSObject *thisobj, const Value &fval, | |
19667 | uintN argc, Value *argv, Value *rval); | |
19668 | ||
19669 | extern | |
19670 | ||
19671 | # 961 "jsinterp.h" | |
19672 | bool | |
19673 | ExternalInvokeConstructor(JSContext *cx, const Value &fval, uintN argc, Value *argv, | |
19674 | Value *rval); | |
19675 | # 972 "jsinterp.h" | |
19676 | extern | |
19677 | ||
19678 | # 972 "jsinterp.h" | |
19679 | bool | |
19680 | DirectEval(JSContext *cx, JSFunction *evalfun, uint32 argc, Value *vp); | |
19681 | # 982 "jsinterp.h" | |
19682 | extern | |
19683 | ||
19684 | # 982 "jsinterp.h" | |
19685 | bool | |
19686 | DirectEval(JSContext *cx, JSFunction *evalfun, uint32 argc, Value *vp); | |
19687 | ||
19688 | ||
19689 | ||
19690 | ||
19691 | ||
19692 | extern | |
19693 | ||
19694 | # 989 "jsinterp.h" | |
19695 | bool | |
19696 | Execute(JSContext *cx, JSObject *chain, JSScript *script, | |
19697 | JSStackFrame *prev, uintN flags, Value *result); | |
19698 | ||
19699 | ||
19700 | ||
19701 | ||
19702 | ||
19703 | extern __attribute__((noinline)) | |
19704 | ||
19705 | # 997 "jsinterp.h" | |
19706 | bool | |
19707 | Interpret(JSContext *cx, JSStackFrame *stopFp, uintN inlineCallCount = 0, JSInterpMode mode = JSINTERP_NORMAL); | |
19708 | ||
19709 | extern | |
19710 | ||
19711 | # 1000 "jsinterp.h" | |
19712 | bool | |
19713 | RunScript(JSContext *cx, JSScript *script, JSStackFrame *fp); | |
19714 | ||
19715 | extern | |
19716 | ||
19717 | # 1003 "jsinterp.h" | |
19718 | bool | |
19719 | CheckRedeclaration(JSContext *cx, JSObject *obj, jsid id, uintN attrs); | |
19720 | ||
19721 | extern | |
19722 | ||
19723 | # 1006 "jsinterp.h" | |
19724 | bool | |
19725 | StrictlyEqual(JSContext *cx, const Value &lval, const Value &rval, JSBool *equal); | |
19726 | ||
19727 | ||
19728 | extern | |
19729 | ||
19730 | # 1010 "jsinterp.h" | |
19731 | bool | |
19732 | SameValue(JSContext *cx, const Value &v1, const Value &v2, JSBool *same); | |
19733 | ||
19734 | extern JSType | |
19735 | TypeOfValue(JSContext *cx, const Value &v); | |
19736 | ||
19737 | inline | |
19738 | ||
19739 | # 1016 "jsinterp.h" | |
19740 | bool | |
19741 | InstanceOf(JSContext *cx, JSObject *obj, Class *clasp, Value *argv) | |
19742 | { | |
19743 | if (obj && obj->getClass() == clasp) | |
19744 | return true; | |
19745 | extern bool InstanceOfSlow(JSContext *, JSObject *, Class *, Value *); | |
19746 | return InstanceOfSlow(cx, obj, clasp, argv); | |
19747 | } | |
19748 | ||
19749 | extern JSBool | |
19750 | HasInstance(JSContext *cx, JSObject *obj, const js::Value *v, JSBool *bp); | |
19751 | ||
19752 | inline void * | |
19753 | GetInstancePrivate(JSContext *cx, JSObject *obj, Class *clasp, Value *argv) | |
19754 | { | |
19755 | if (!InstanceOf(cx, obj, clasp, argv)) | |
19756 | return __null; | |
19757 | return obj->getPrivate(); | |
19758 | } | |
19759 | ||
19760 | extern | |
19761 | ||
19762 | # 1036 "jsinterp.h" | |
19763 | bool | |
19764 | ValueToId(JSContext *cx, const Value &v, jsid *idp); | |
19765 | # 1046 "jsinterp.h" | |
19766 | extern const js::Value & | |
19767 | GetUpvar(JSContext *cx, uintN level, js::UpvarCookie cookie); | |
19768 | ||
19769 | } | |
19770 | # 1077 "jsinterp.h" | |
19771 | extern JSBool | |
19772 | js_EnterWith(JSContext *cx, jsint stackIndex, JSOp op, size_t oplen); | |
19773 | ||
19774 | extern void | |
19775 | js_LeaveWith(JSContext *cx); | |
19776 | ||
19777 | ||
19778 | ||
19779 | ||
19780 | ||
19781 | ||
19782 | ||
19783 | extern JSBool | |
19784 | js_DoIncDec(JSContext *cx, const JSCodeSpec *cs, js::Value *vp, js::Value *vp2); | |
19785 | ||
19786 | ||
19787 | ||
19788 | ||
19789 | ||
19790 | extern void | |
19791 | js_LogOpcode(JSContext *cx); | |
19792 | ||
19793 | ||
19794 | ||
19795 | ||
19796 | extern void | |
19797 | js_MeterOpcodePair(JSOp op1, JSOp op2); | |
19798 | ||
19799 | extern void | |
19800 | js_MeterSlotOpcode(JSOp op, uint32 slot); | |
19801 | ||
19802 | ||
19803 | ||
19804 | ||
19805 | ||
19806 | ||
19807 | extern JSBool | |
19808 | js_UnwindScope(JSContext *cx, jsint stackDepth, JSBool normalUnwind); | |
19809 | ||
19810 | extern JSBool | |
19811 | js_OnUnknownMethod(JSContext *cx, js::Value *vp); | |
19812 | ||
19813 | extern js::Class * | |
19814 | js_IsActiveWithOrBlock(JSContext *cx, JSObject *obj, int stackDepth); | |
19815 | # 67 "jscntxt.h" 2 | |
19816 | # 1 "jsmath.h" 1 | |
19817 | # 43 "jsmath.h" | |
19818 | namespace js { | |
19819 | ||
19820 | typedef double (*UnaryFunType)(double); | |
19821 | ||
19822 | class MathCache | |
19823 | { | |
19824 | static const unsigned SizeLog2 = 12; | |
19825 | static const unsigned Size = 1 << SizeLog2; | |
19826 | struct Entry { double in; UnaryFunType f; double out; }; | |
19827 | Entry table[Size]; | |
19828 | ||
19829 | public: | |
19830 | MathCache(); | |
19831 | ||
19832 | uintN hash(double x) { | |
19833 | union { double d; struct { uint32 one, two; } s; } u = { x }; | |
19834 | uint32 hash32 = u.s.one ^ u.s.two; | |
19835 | uint16 hash16 = (uint16)(hash32 ^ (hash32 >> 16)); | |
19836 | return (hash16 & (Size - 1)) ^ (hash16 >> (16 - SizeLog2)); | |
19837 | } | |
19838 | ||
19839 | ||
19840 | ||
19841 | ||
19842 | ||
19843 | double lookup(UnaryFunType f, double x) { | |
19844 | uintN index = hash(x); | |
19845 | Entry &e = table[index]; | |
19846 | if (e.in == x && e.f == f) | |
19847 | return e.out; | |
19848 | e.in = x; | |
19849 | e.f = f; | |
19850 | return (e.out = f(x)); | |
19851 | } | |
19852 | }; | |
19853 | ||
19854 | } | |
19855 | ||
19856 | ||
19857 | ||
19858 | ||
19859 | ||
19860 | extern js::Class js_MathClass; | |
19861 | ||
19862 | extern JSObject * | |
19863 | js_InitMathClass(JSContext *cx, JSObject *obj); | |
19864 | ||
19865 | extern | |
19866 | ||
19867 | # 90 "jsmath.h" | |
19868 | bool | |
19869 | js_IsMathFunction(JSNative native); | |
19870 | ||
19871 | extern void | |
19872 | js_InitRandom(JSContext *cx); | |
19873 | ||
19874 | extern JSBool | |
19875 | js_math_abs(JSContext *cx, uintN argc, js::Value *vp); | |
19876 | ||
19877 | extern JSBool | |
19878 | js_math_ceil(JSContext *cx, uintN argc, js::Value *vp); | |
19879 | ||
19880 | extern JSBool | |
19881 | js_math_floor(JSContext *cx, uintN argc, js::Value *vp); | |
19882 | ||
19883 | extern JSBool | |
19884 | js_math_max(JSContext *cx, uintN argc, js::Value *vp); | |
19885 | ||
19886 | extern JSBool | |
19887 | js_math_min(JSContext *cx, uintN argc, js::Value *vp); | |
19888 | ||
19889 | extern JSBool | |
19890 | js_math_round(JSContext *cx, uintN argc, js::Value *vp); | |
19891 | ||
19892 | extern jsdouble | |
19893 | js_math_ceil_impl(jsdouble x); | |
19894 | ||
19895 | extern jsdouble | |
19896 | js_math_floor_impl(jsdouble x); | |
19897 | ||
19898 | extern jsdouble | |
19899 | js_math_round_impl(jsdouble x); | |
19900 | # 68 "jscntxt.h" 2 | |
19901 | ||
19902 | # 1 "jspropertycache.h" 1 | |
19903 | # 48 "jspropertycache.h" | |
19904 | namespace js { | |
19905 | # 57 "jspropertycache.h" | |
19906 | enum { | |
19907 | PCVCAP_PROTOBITS = 4, | |
19908 | PCVCAP_PROTOSIZE = ((JSUint32)1 << (PCVCAP_PROTOBITS)), | |
19909 | PCVCAP_PROTOMASK = (((JSUint32)1 << (PCVCAP_PROTOBITS)) - 1), | |
19910 | ||
19911 | PCVCAP_SCOPEBITS = 4, | |
19912 | PCVCAP_SCOPESIZE = ((JSUint32)1 << (PCVCAP_SCOPEBITS)), | |
19913 | PCVCAP_SCOPEMASK = (((JSUint32)1 << (PCVCAP_SCOPEBITS)) - 1), | |
19914 | ||
19915 | PCVCAP_TAGBITS = PCVCAP_PROTOBITS + PCVCAP_SCOPEBITS, | |
19916 | PCVCAP_TAGMASK = (((JSUint32)1 << (PCVCAP_TAGBITS)) - 1) | |
19917 | }; | |
19918 | ||
19919 | const uint32 SHAPE_OVERFLOW_BIT = ((JSUint32)1 << (32 - PCVCAP_TAGBITS)); | |
19920 | # 81 "jspropertycache.h" | |
19921 | class PCVal | |
19922 | { | |
19923 | private: | |
19924 | enum { | |
19925 | OBJECT = 0, | |
19926 | SLOT = 1, | |
19927 | SHAPE = 2, | |
19928 | TAG = 3 | |
19929 | }; | |
19930 | ||
19931 | jsuword v; | |
19932 | ||
19933 | public: | |
19934 | bool isNull() const { return v == 0; } | |
19935 | void setNull() { v = 0; } | |
19936 | ||
19937 | bool isFunObj() const { return (v & TAG) == OBJECT; } | |
19938 | JSObject &toFunObj() const { | |
19939 | ((void) 0); | |
19940 | return *reinterpret_cast<JSObject *>(v); | |
19941 | } | |
19942 | void setFunObj(JSObject &obj) { | |
19943 | v = reinterpret_cast<jsuword>(&obj); | |
19944 | } | |
19945 | ||
19946 | bool isSlot() const { return v & SLOT; } | |
19947 | uint32 toSlot() const { ((void) 0); return uint32(v) >> 1; } | |
19948 | void setSlot(uint32 slot) { v = (jsuword(slot) << 1) | SLOT; } | |
19949 | ||
19950 | bool isShape() const { return (v & TAG) == SHAPE; } | |
19951 | const js::Shape *toShape() const { | |
19952 | ((void) 0); | |
19953 | return reinterpret_cast<js::Shape *>(v & ~TAG); | |
19954 | } | |
19955 | void setShape(const js::Shape *shape) { | |
19956 | ((void) 0); | |
19957 | v = reinterpret_cast<jsuword>(shape) | SHAPE; | |
19958 | } | |
19959 | }; | |
19960 | ||
19961 | struct PropertyCacheEntry | |
19962 | { | |
19963 | jsbytecode *kpc; | |
19964 | jsuword kshape; | |
19965 | jsuword vcap; | |
19966 | PCVal vword; | |
19967 | ||
19968 | bool adding() const { return vcapTag() == 0 && kshape != vshape(); } | |
19969 | bool directHit() const { return vcapTag() == 0 && kshape == vshape(); } | |
19970 | ||
19971 | jsuword vcapTag() const { return vcap & PCVCAP_TAGMASK; } | |
19972 | uint32 vshape() const { return uint32(vcap >> PCVCAP_TAGBITS); } | |
19973 | jsuword scopeIndex() const { return (vcap >> PCVCAP_PROTOBITS) & PCVCAP_SCOPEMASK; } | |
19974 | jsuword protoIndex() const { return vcap & PCVCAP_PROTOMASK; } | |
19975 | ||
19976 | void assign(jsbytecode *kpc, jsuword kshape, jsuword vshape, | |
19977 | uintN scopeIndex, uintN protoIndex, PCVal vword) { | |
19978 | ((void) 0); | |
19979 | ((void) 0); | |
19980 | ((void) 0); | |
19981 | ((void) 0); | |
19982 | ||
19983 | this->kpc = kpc; | |
19984 | this->kshape = kshape; | |
19985 | this->vcap = (vshape << PCVCAP_TAGBITS) | (scopeIndex << PCVCAP_PROTOBITS) | protoIndex; | |
19986 | this->vword = vword; | |
19987 | } | |
19988 | }; | |
19989 | # 160 "jspropertycache.h" | |
19990 | class PropertyCache | |
19991 | { | |
19992 | private: | |
19993 | enum { | |
19994 | SIZE_LOG2 = 12, | |
19995 | SIZE = ((JSUint32)1 << (SIZE_LOG2)), | |
19996 | MASK = (((JSUint32)1 << (SIZE_LOG2)) - 1) | |
19997 | }; | |
19998 | ||
19999 | PropertyCacheEntry table[SIZE]; | |
20000 | JSBool empty; | |
20001 | # 214 "jspropertycache.h" | |
20002 | static inline jsuword | |
20003 | hash(jsbytecode *pc, jsuword kshape) | |
20004 | { | |
20005 | return ((((jsuword(pc) >> SIZE_LOG2) ^ jsuword(pc)) + kshape) & MASK); | |
20006 | } | |
20007 | ||
20008 | static inline bool matchShape(JSContext *cx, JSObject *obj, uint32 shape); | |
20009 | ||
20010 | JSAtom *fullTest(JSContext *cx, jsbytecode *pc, JSObject **objp, | |
20011 | JSObject **pobjp, PropertyCacheEntry *entry); | |
20012 | ||
20013 | ||
20014 | ||
20015 | ||
20016 | inline void assertEmpty() {} | |
20017 | ||
20018 | ||
20019 | public: | |
20020 | __attribute__((always_inline)) inline void test(JSContext *cx, jsbytecode *pc, | |
20021 | JSObject *&obj, JSObject *&pobj, | |
20022 | PropertyCacheEntry *&entry, JSAtom *&atom); | |
20023 | # 243 "jspropertycache.h" | |
20024 | __attribute__((always_inline)) inline bool testForSet(JSContext *cx, jsbytecode *pc, JSObject *obj, | |
20025 | PropertyCacheEntry **entryp, JSObject **obj2p, | |
20026 | JSAtom **atomp); | |
20027 | # 256 "jspropertycache.h" | |
20028 | __attribute__((always_inline)) inline bool testForInit(JSRuntime *rt, jsbytecode *pc, JSObject *obj, | |
20029 | const js::Shape **shapep, PropertyCacheEntry **entryp); | |
20030 | # 267 "jspropertycache.h" | |
20031 | PropertyCacheEntry *fill(JSContext *cx, JSObject *obj, uintN scopeIndex, | |
20032 | uintN protoIndex, JSObject *pobj, | |
20033 | const js::Shape *shape, JSBool adding = false); | |
20034 | ||
20035 | void purge(JSContext *cx); | |
20036 | void purgeForScript(JSContext *cx, JSScript *script); | |
20037 | }; | |
20038 | ||
20039 | } | |
20040 | # 70 "jscntxt.h" 2 | |
20041 | # 1 "jspropertytree.h" 1 | |
20042 | # 47 "jspropertytree.h" | |
20043 | namespace js { | |
20044 | ||
20045 | struct ShapeHasher { | |
20046 | typedef js::Shape *Key; | |
20047 | typedef const js::Shape *Lookup; | |
20048 | ||
20049 | static inline HashNumber hash(const Lookup l); | |
20050 | static inline bool match(Key k, Lookup l); | |
20051 | }; | |
20052 | ||
20053 | typedef HashSet<js::Shape *, ShapeHasher, SystemAllocPolicy> KidsHash; | |
20054 | ||
20055 | class KidsPointer { | |
20056 | private: | |
20057 | enum { | |
20058 | SHAPE = 0, | |
20059 | HASH = 1, | |
20060 | TAG = 1 | |
20061 | }; | |
20062 | ||
20063 | jsuword w; | |
20064 | ||
20065 | public: | |
20066 | bool isNull() const { return !w; } | |
20067 | void setNull() { w = 0; } | |
20068 | ||
20069 | bool isShape() const { return (w & TAG) == SHAPE && !isNull(); } | |
20070 | js::Shape *toShape() const { | |
20071 | ((void) 0); | |
20072 | return reinterpret_cast<js::Shape *>(w & ~jsuword(TAG)); | |
20073 | } | |
20074 | void setShape(js::Shape *shape) { | |
20075 | ((void) 0); | |
20076 | ((void) 0); | |
20077 | w = reinterpret_cast<jsuword>(shape) | SHAPE; | |
20078 | } | |
20079 | ||
20080 | bool isHash() const { return (w & TAG) == HASH; } | |
20081 | KidsHash *toHash() const { | |
20082 | ((void) 0); | |
20083 | return reinterpret_cast<KidsHash *>(w & ~jsuword(TAG)); | |
20084 | } | |
20085 | void setHash(KidsHash *hash) { | |
20086 | ((void) 0); | |
20087 | ((void) 0); | |
20088 | w = reinterpret_cast<jsuword>(hash) | HASH; | |
20089 | } | |
20090 | ||
20091 | ||
20092 | ||
20093 | ||
20094 | }; | |
20095 | ||
20096 | class PropertyTree | |
20097 | { | |
20098 | friend struct ::JSFunction; | |
20099 | ||
20100 | JSCompartment *compartment; | |
20101 | JSArenaPool arenaPool; | |
20102 | js::Shape *freeList; | |
20103 | ||
20104 | bool insertChild(JSContext *cx, js::Shape *parent, js::Shape *child); | |
20105 | void removeChild(js::Shape *child); | |
20106 | ||
20107 | PropertyTree(); | |
20108 | ||
20109 | public: | |
20110 | enum { MAX_HEIGHT = 128 }; | |
20111 | ||
20112 | PropertyTree(JSCompartment *comp) | |
20113 | : compartment(comp), freeList(__null) | |
20114 | { | |
20115 | PodZero(&arenaPool); | |
20116 | } | |
20117 | ||
20118 | bool init(); | |
20119 | void finish(); | |
20120 | ||
20121 | js::Shape *newShapeUnchecked(); | |
20122 | js::Shape *newShape(JSContext *cx); | |
20123 | js::Shape *getChild(JSContext *cx, js::Shape *parent, const js::Shape &child); | |
20124 | ||
20125 | void orphanChildren(js::Shape *shape); | |
20126 | void sweepShapes(JSContext *cx); | |
20127 | void unmarkShapes(JSContext *cx); | |
20128 | ||
20129 | static void dumpShapes(JSContext *cx); | |
20130 | ||
20131 | ||
20132 | ||
20133 | }; | |
20134 | ||
20135 | } | |
20136 | # 71 "jscntxt.h" 2 | |
20137 | ||
20138 | ||
20139 | ||
20140 | ||
20141 | # 1 "prmjtime.h" 1 | |
20142 | # 46 "prmjtime.h" | |
20143 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/time.h" 1 3 4 | |
20144 | # 29 "/usr/powerpc64-unknown-linux-gnu/usr/include/time.h" 3 4 | |
20145 | extern "C" { | |
20146 | ||
20147 | ||
20148 | ||
20149 | ||
20150 | ||
20151 | ||
20152 | ||
20153 | # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stddef.h" 1 3 4 | |
20154 | # 38 "/usr/powerpc64-unknown-linux-gnu/usr/include/time.h" 2 3 4 | |
20155 | ||
20156 | ||
20157 | ||
20158 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/time.h" 1 3 4 | |
20159 | # 88 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/time.h" 3 4 | |
20160 | # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/timex.h" 1 3 4 | |
20161 | # 25 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/timex.h" 3 4 | |
20162 | struct timex | |
20163 | { | |
20164 | unsigned int modes; | |
20165 | __syscall_slong_t offset; | |
20166 | __syscall_slong_t freq; | |
20167 | __syscall_slong_t maxerror; | |
20168 | __syscall_slong_t esterror; | |
20169 | int status; | |
20170 | __syscall_slong_t constant; | |
20171 | __syscall_slong_t precision; | |
20172 | __syscall_slong_t tolerance; | |
20173 | struct timeval time; | |
20174 | __syscall_slong_t tick; | |
20175 | __syscall_slong_t ppsfreq; | |
20176 | __syscall_slong_t jitter; | |
20177 | int shift; | |
20178 | __syscall_slong_t stabil; | |
20179 | __syscall_slong_t jitcnt; | |
20180 | __syscall_slong_t calcnt; | |
20181 | __syscall_slong_t errcnt; | |
20182 | __syscall_slong_t stbcnt; | |
20183 | ||
20184 | int tai; | |
20185 | ||
20186 | ||
20187 | int :32; int :32; int :32; int :32; | |
20188 | int :32; int :32; int :32; int :32; | |
20189 | int :32; int :32; int :32; | |
20190 | }; | |
20191 | # 89 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/time.h" 2 3 4 | |
20192 | ||
20193 | extern "C" { | |
20194 | ||
20195 | ||
20196 | extern int clock_adjtime (__clockid_t __clock_id, struct timex *__utx) throw (); | |
20197 | ||
20198 | } | |
20199 | # 42 "/usr/powerpc64-unknown-linux-gnu/usr/include/time.h" 2 3 4 | |
20200 | # 131 "/usr/powerpc64-unknown-linux-gnu/usr/include/time.h" 3 4 | |
20201 | ||
20202 | ||
20203 | struct tm | |
20204 | { | |
20205 | int tm_sec; | |
20206 | int tm_min; | |
20207 | int tm_hour; | |
20208 | int tm_mday; | |
20209 | int tm_mon; | |
20210 | int tm_year; | |
20211 | int tm_wday; | |
20212 | int tm_yday; | |
20213 | int tm_isdst; | |
20214 | ||
20215 | ||
20216 | long int tm_gmtoff; | |
20217 | const char *tm_zone; | |
20218 | ||
20219 | ||
20220 | ||
20221 | ||
20222 | }; | |
20223 | ||
20224 | ||
20225 | ||
20226 | ||
20227 | ||
20228 | ||
20229 | ||
20230 | ||
20231 | struct itimerspec | |
20232 | { | |
20233 | struct timespec it_interval; | |
20234 | struct timespec it_value; | |
20235 | }; | |
20236 | ||
20237 | ||
20238 | struct sigevent; | |
20239 | # 186 "/usr/powerpc64-unknown-linux-gnu/usr/include/time.h" 3 4 | |
20240 | ||
20241 | ||
20242 | ||
20243 | extern clock_t clock (void) throw (); | |
20244 | ||
20245 | ||
20246 | extern time_t time (time_t *__timer) throw (); | |
20247 | ||
20248 | ||
20249 | extern double difftime (time_t __time1, time_t __time0) | |
20250 | throw () __attribute__ ((__const__)); | |
20251 | ||
20252 | ||
20253 | extern time_t mktime (struct tm *__tp) throw (); | |
20254 | ||
20255 | ||
20256 | ||
20257 | ||
20258 | ||
20259 | extern size_t strftime (char *__restrict __s, size_t __maxsize, | |
20260 | const char *__restrict __format, | |
20261 | const struct tm *__restrict __tp) throw (); | |
20262 | ||
20263 | ||
20264 | ||
20265 | ||
20266 | ||
20267 | extern char *strptime (const char *__restrict __s, | |
20268 | const char *__restrict __fmt, struct tm *__tp) | |
20269 | throw (); | |
20270 | ||
20271 | ||
20272 | ||
20273 | ||
20274 | ||
20275 | ||
20276 | ||
20277 | extern size_t strftime_l (char *__restrict __s, size_t __maxsize, | |
20278 | const char *__restrict __format, | |
20279 | const struct tm *__restrict __tp, | |
20280 | __locale_t __loc) throw (); | |
20281 | ||
20282 | ||
20283 | ||
20284 | extern char *strptime_l (const char *__restrict __s, | |
20285 | const char *__restrict __fmt, struct tm *__tp, | |
20286 | __locale_t __loc) throw (); | |
20287 | ||
20288 | ||
20289 | ||
20290 | ||
20291 | ||
20292 | ||
20293 | extern struct tm *gmtime (const time_t *__timer) throw (); | |
20294 | ||
20295 | ||
20296 | ||
20297 | extern struct tm *localtime (const time_t *__timer) throw (); | |
20298 | ||
20299 | ||
20300 | ||
20301 | ||
20302 | ||
20303 | extern struct tm *gmtime_r (const time_t *__restrict __timer, | |
20304 | struct tm *__restrict __tp) throw (); | |
20305 | ||
20306 | ||
20307 | ||
20308 | extern struct tm *localtime_r (const time_t *__restrict __timer, | |
20309 | struct tm *__restrict __tp) throw (); | |
20310 | ||
20311 | ||
20312 | ||
20313 | ||
20314 | ||
20315 | extern char *asctime (const struct tm *__tp) throw (); | |
20316 | ||
20317 | ||
20318 | extern char *ctime (const time_t *__timer) throw (); | |
20319 | ||
20320 | ||
20321 | ||
20322 | ||
20323 | ||
20324 | ||
20325 | ||
20326 | extern char *asctime_r (const struct tm *__restrict __tp, | |
20327 | char *__restrict __buf) throw (); | |
20328 | ||
20329 | ||
20330 | extern char *ctime_r (const time_t *__restrict __timer, | |
20331 | char *__restrict __buf) throw (); | |
20332 | ||
20333 | ||
20334 | ||
20335 | ||
20336 | extern char *__tzname[2]; | |
20337 | extern int __daylight; | |
20338 | extern long int __timezone; | |
20339 | ||
20340 | ||
20341 | ||
20342 | ||
20343 | extern char *tzname[2]; | |
20344 | ||
20345 | ||
20346 | ||
20347 | extern void tzset (void) throw (); | |
20348 | ||
20349 | ||
20350 | ||
20351 | extern int daylight; | |
20352 | extern long int timezone; | |
20353 | ||
20354 | ||
20355 | ||
20356 | ||
20357 | ||
20358 | extern int stime (const time_t *__when) throw (); | |
20359 | # 319 "/usr/powerpc64-unknown-linux-gnu/usr/include/time.h" 3 4 | |
20360 | extern time_t timegm (struct tm *__tp) throw (); | |
20361 | ||
20362 | ||
20363 | extern time_t timelocal (struct tm *__tp) throw (); | |
20364 | ||
20365 | ||
20366 | extern int dysize (int __year) throw () __attribute__ ((__const__)); | |
20367 | # 334 "/usr/powerpc64-unknown-linux-gnu/usr/include/time.h" 3 4 | |
20368 | extern int nanosleep (const struct timespec *__requested_time, | |
20369 | struct timespec *__remaining); | |
20370 | ||
20371 | ||
20372 | ||
20373 | extern int clock_getres (clockid_t __clock_id, struct timespec *__res) throw (); | |
20374 | ||
20375 | ||
20376 | extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp) throw (); | |
20377 | ||
20378 | ||
20379 | extern int clock_settime (clockid_t __clock_id, const struct timespec *__tp) | |
20380 | throw (); | |
20381 | ||
20382 | ||
20383 | ||
20384 | ||
20385 | ||
20386 | ||
20387 | extern int clock_nanosleep (clockid_t __clock_id, int __flags, | |
20388 | const struct timespec *__req, | |
20389 | struct timespec *__rem); | |
20390 | ||
20391 | ||
20392 | extern int clock_getcpuclockid (pid_t __pid, clockid_t *__clock_id) throw (); | |
20393 | ||
20394 | ||
20395 | ||
20396 | ||
20397 | extern int timer_create (clockid_t __clock_id, | |
20398 | struct sigevent *__restrict __evp, | |
20399 | timer_t *__restrict __timerid) throw (); | |
20400 | ||
20401 | ||
20402 | extern int timer_delete (timer_t __timerid) throw (); | |
20403 | ||
20404 | ||
20405 | extern int timer_settime (timer_t __timerid, int __flags, | |
20406 | const struct itimerspec *__restrict __value, | |
20407 | struct itimerspec *__restrict __ovalue) throw (); | |
20408 | ||
20409 | ||
20410 | extern int timer_gettime (timer_t __timerid, struct itimerspec *__value) | |
20411 | throw (); | |
20412 | ||
20413 | ||
20414 | extern int timer_getoverrun (timer_t __timerid) throw (); | |
20415 | ||
20416 | ||
20417 | ||
20418 | ||
20419 | ||
20420 | extern int timespec_get (struct timespec *__ts, int __base) | |
20421 | throw () __attribute__ ((__nonnull__ (1))); | |
20422 | # 403 "/usr/powerpc64-unknown-linux-gnu/usr/include/time.h" 3 4 | |
20423 | extern int getdate_err; | |
20424 | # 412 "/usr/powerpc64-unknown-linux-gnu/usr/include/time.h" 3 4 | |
20425 | extern struct tm *getdate (const char *__string); | |
20426 | # 426 "/usr/powerpc64-unknown-linux-gnu/usr/include/time.h" 3 4 | |
20427 | extern int getdate_r (const char *__restrict __string, | |
20428 | struct tm *__restrict __resbufp); | |
20429 | ||
20430 | ||
20431 | } | |
20432 | # 47 "prmjtime.h" 2 | |
20433 | ||
20434 | ||
20435 | ||
20436 | ||
20437 | ||
20438 | ||
20439 | struct JSContext; | |
20440 | # 99 "prmjtime.h" | |
20441 | class DSTOffsetCache { | |
20442 | public: | |
20443 | inline DSTOffsetCache(); | |
20444 | JSInt64 getDSTOffsetMilliseconds(int64 localTimeMilliseconds, JSContext *cx); | |
20445 | ||
20446 | inline void purge(); | |
20447 | ||
20448 | ||
20449 | ||
20450 | ||
20451 | private: | |
20452 | JSInt64 computeDSTOffsetMilliseconds(int64 localTimeSeconds); | |
20453 | ||
20454 | JSInt64 offsetMilliseconds; | |
20455 | JSInt64 rangeStartSeconds, rangeEndSeconds; | |
20456 | ||
20457 | JSInt64 oldOffsetMilliseconds; | |
20458 | JSInt64 oldRangeStartSeconds, oldRangeEndSeconds; | |
20459 | # 131 "prmjtime.h" | |
20460 | static const JSInt64 MAX_UNIX_TIMET = 2145859200; | |
20461 | static const JSInt64 MILLISECONDS_PER_SECOND = 1000; | |
20462 | static const JSInt64 SECONDS_PER_MINUTE = 60; | |
20463 | static const JSInt64 SECONDS_PER_HOUR = 60 * SECONDS_PER_MINUTE; | |
20464 | static const JSInt64 SECONDS_PER_DAY = 24 * SECONDS_PER_HOUR; | |
20465 | ||
20466 | static const JSInt64 RANGE_EXPANSION_AMOUNT = 30 * SECONDS_PER_DAY; | |
20467 | ||
20468 | private: | |
20469 | void sanityCheck(); | |
20470 | ||
20471 | ||
20472 | ||
20473 | ||
20474 | ||
20475 | ||
20476 | void noteOffsetCalculation() { | |
20477 | ((void)0); | |
20478 | } | |
20479 | void noteCacheHit() { | |
20480 | ((void)0); | |
20481 | } | |
20482 | void noteCacheMissIncrease() { | |
20483 | ((void)0); | |
20484 | } | |
20485 | void noteCacheMissDecrease() { | |
20486 | ((void)0); | |
20487 | } | |
20488 | void noteCacheMissIncreasingOffsetChangeUpper() { | |
20489 | ((void)0); | |
20490 | } | |
20491 | void noteCacheMissIncreasingOffsetChangeExpand() { | |
20492 | ((void)0); | |
20493 | } | |
20494 | void noteCacheMissLargeIncrease() { | |
20495 | ((void)0); | |
20496 | } | |
20497 | void noteCacheMissDecreasingOffsetChangeLower() { | |
20498 | ((void)0); | |
20499 | } | |
20500 | void noteCacheMissDecreasingOffsetChangeExpand() { | |
20501 | ((void)0); | |
20502 | } | |
20503 | void noteCacheMissLargeDecrease() { | |
20504 | ((void)0); | |
20505 | } | |
20506 | ||
20507 | }; | |
20508 | ||
20509 | extern "C" { | |
20510 | ||
20511 | typedef struct PRMJTime PRMJTime; | |
20512 | ||
20513 | ||
20514 | ||
20515 | ||
20516 | struct PRMJTime { | |
20517 | JSInt32 tm_usec; | |
20518 | JSInt8 tm_sec; | |
20519 | JSInt8 tm_min; | |
20520 | JSInt8 tm_hour; | |
20521 | JSInt8 tm_mday; | |
20522 | JSInt8 tm_mon; | |
20523 | JSInt8 tm_wday; | |
20524 | JSInt32 tm_year; | |
20525 | JSInt16 tm_yday; | |
20526 | JSInt8 tm_isdst; | |
20527 | }; | |
20528 | ||
20529 | ||
20530 | ||
20531 | ||
20532 | ||
20533 | ||
20534 | extern JSInt64 | |
20535 | PRMJ_Now(void); | |
20536 | # 217 "prmjtime.h" | |
20537 | extern JSInt32 | |
20538 | PRMJ_LocalGMTDifference(void); | |
20539 | ||
20540 | ||
20541 | extern size_t | |
20542 | PRMJ_FormatTime(char *buf, int buflen, const char *fmt, PRMJTime *tm); | |
20543 | ||
20544 | } | |
20545 | # 76 "jscntxt.h" 2 | |
20546 | # 90 "jscntxt.h" | |
20547 | typedef struct JSGSNCache { | |
20548 | jsbytecode *code; | |
20549 | JSDHashTable table; | |
20550 | # 102 "jscntxt.h" | |
20551 | } JSGSNCache; | |
20552 | ||
20553 | ||
20554 | ||
20555 | extern void | |
20556 | js_PurgeGSNCache(JSGSNCache *cache); | |
20557 | ||
20558 | ||
20559 | ||
20560 | ||
20561 | ||
20562 | ||
20563 | namespace nanojit { | |
20564 | ||
20565 | class Assembler; | |
20566 | class CodeAlloc; | |
20567 | class Fragment; | |
20568 | template<typename K> struct DefaultHash; | |
20569 | template<typename K, typename V, typename H> class HashMap; | |
20570 | template<typename T> class Seq; | |
20571 | ||
20572 | } | |
20573 | ||
20574 | namespace js { | |
20575 | ||
20576 | ||
20577 | static const size_t MONITOR_N_GLOBAL_STATES = 4; | |
20578 | static const size_t FRAGMENT_TABLE_SIZE = 512; | |
20579 | static const size_t MAX_NATIVE_STACK_SLOTS = 4096; | |
20580 | static const size_t MAX_CALL_STACK_ENTRIES = 500; | |
20581 | static const size_t MAX_GLOBAL_SLOTS = 4096; | |
20582 | static const size_t GLOBAL_SLOTS_BUFFER_SIZE = MAX_GLOBAL_SLOTS + 1; | |
20583 | static const size_t MAX_SLOW_NATIVE_EXTRA_SLOTS = 16; | |
20584 | ||
20585 | ||
20586 | class VMAllocator; | |
20587 | class FrameInfoCache; | |
20588 | struct FrameInfo; | |
20589 | struct VMSideExit; | |
20590 | struct TreeFragment; | |
20591 | struct TracerState; | |
20592 | template<typename T> class Queue; | |
20593 | typedef Queue<uint16> SlotList; | |
20594 | class TypeMap; | |
20595 | class LoopProfile; | |
20596 | ||
20597 | ||
20598 | ||
20599 | ||
20600 | ||
20601 | ||
20602 | namespace mjit { | |
20603 | class JaegerCompartment; | |
20604 | } | |
20605 | ||
20606 | ||
20607 | ||
20608 | ||
20609 | ||
20610 | ||
20611 | ||
20612 | class ContextAllocPolicy | |
20613 | { | |
20614 | JSContext *cx; | |
20615 | ||
20616 | public: | |
20617 | ContextAllocPolicy(JSContext *cx) : cx(cx) {} | |
20618 | JSContext *context() const { return cx; } | |
20619 | ||
20620 | ||
20621 | void *malloc(size_t bytes); | |
20622 | void free(void *p); | |
20623 | void *realloc(void *p, size_t bytes); | |
20624 | void reportAllocOverflow() const; | |
20625 | }; | |
20626 | # 225 "jscntxt.h" | |
20627 | class StackSegment | |
20628 | { | |
20629 | ||
20630 | JSContext *cx; | |
20631 | ||
20632 | ||
20633 | StackSegment *previousInContext; | |
20634 | ||
20635 | ||
20636 | StackSegment *previousInMemory; | |
20637 | ||
20638 | ||
20639 | JSStackFrame *initialFrame; | |
20640 | ||
20641 | ||
20642 | JSFrameRegs *suspendedRegs; | |
20643 | ||
20644 | ||
20645 | JSObject *initialVarObj; | |
20646 | ||
20647 | ||
20648 | bool saved; | |
20649 | # 259 "jscntxt.h" | |
20650 | public: | |
20651 | StackSegment() | |
20652 | : cx(__null), previousInContext(__null), previousInMemory(__null), | |
20653 | initialFrame(__null), suspendedRegs(((JSFrameRegs *)0x1)), | |
20654 | initialVarObj(__null), saved(false) | |
20655 | { | |
20656 | ((void) 0); | |
20657 | } | |
20658 | ||
20659 | ||
20660 | ||
20661 | Value *valueRangeBegin() const { | |
20662 | return (Value *)(this + 1); | |
20663 | } | |
20664 | # 285 "jscntxt.h" | |
20665 | bool inContext() const { | |
20666 | ((void) 0); | |
20667 | ((void) 0); | |
20668 | return cx; | |
20669 | } | |
20670 | ||
20671 | bool isActive() const { | |
20672 | ((void) 0); | |
20673 | ((void) 0); | |
20674 | return !suspendedRegs; | |
20675 | } | |
20676 | ||
20677 | bool isSuspended() const { | |
20678 | ((void) 0); | |
20679 | ((void) 0); | |
20680 | return cx && suspendedRegs; | |
20681 | } | |
20682 | ||
20683 | ||
20684 | ||
20685 | bool isSaved() const { | |
20686 | ((void) 0); | |
20687 | return saved; | |
20688 | } | |
20689 | ||
20690 | ||
20691 | ||
20692 | void joinContext(JSContext *cx, JSStackFrame *f) { | |
20693 | ((void) 0); | |
20694 | this->cx = cx; | |
20695 | initialFrame = f; | |
20696 | suspendedRegs = __null; | |
20697 | ((void) 0); | |
20698 | } | |
20699 | ||
20700 | void leaveContext() { | |
20701 | ((void) 0); | |
20702 | this->cx = __null; | |
20703 | initialFrame = __null; | |
20704 | suspendedRegs = ((JSFrameRegs *)0x1); | |
20705 | ((void) 0); | |
20706 | } | |
20707 | ||
20708 | JSContext *maybeContext() const { | |
20709 | return cx; | |
20710 | } | |
20711 | ||
20712 | ||
20713 | ||
20714 | ||
20715 | ||
20716 | void suspend(JSFrameRegs *regs) { | |
20717 | ((void) 0); | |
20718 | ((void) 0); | |
20719 | suspendedRegs = regs; | |
20720 | ((void) 0); | |
20721 | } | |
20722 | ||
20723 | void resume() { | |
20724 | ((void) 0); | |
20725 | suspendedRegs = __null; | |
20726 | ((void) 0); | |
20727 | } | |
20728 | ||
20729 | ||
20730 | ||
20731 | void save(JSFrameRegs *regs) { | |
20732 | ((void) 0); | |
20733 | suspend(regs); | |
20734 | saved = true; | |
20735 | ((void) 0); | |
20736 | } | |
20737 | ||
20738 | void restore() { | |
20739 | ((void) 0); | |
20740 | saved = false; | |
20741 | resume(); | |
20742 | ((void) 0); | |
20743 | } | |
20744 | ||
20745 | ||
20746 | ||
20747 | JSStackFrame *getInitialFrame() const { | |
20748 | ((void) 0); | |
20749 | return initialFrame; | |
20750 | } | |
20751 | ||
20752 | inline JSFrameRegs *getCurrentRegs() const; | |
20753 | inline JSStackFrame *getCurrentFrame() const; | |
20754 | ||
20755 | ||
20756 | ||
20757 | JSFrameRegs *getSuspendedRegs() const { | |
20758 | ((void) 0); | |
20759 | return suspendedRegs; | |
20760 | } | |
20761 | ||
20762 | JSStackFrame *getSuspendedFrame() const { | |
20763 | return suspendedRegs->fp; | |
20764 | } | |
20765 | ||
20766 | ||
20767 | ||
20768 | void setPreviousInContext(StackSegment *seg) { | |
20769 | previousInContext = seg; | |
20770 | } | |
20771 | ||
20772 | StackSegment *getPreviousInContext() const { | |
20773 | return previousInContext; | |
20774 | } | |
20775 | ||
20776 | void setPreviousInMemory(StackSegment *seg) { | |
20777 | previousInMemory = seg; | |
20778 | } | |
20779 | ||
20780 | StackSegment *getPreviousInMemory() const { | |
20781 | return previousInMemory; | |
20782 | } | |
20783 | ||
20784 | void setInitialVarObj(JSObject *obj) { | |
20785 | ((void) 0); | |
20786 | initialVarObj = obj; | |
20787 | } | |
20788 | ||
20789 | bool hasInitialVarObj() { | |
20790 | ((void) 0); | |
20791 | return initialVarObj != __null; | |
20792 | } | |
20793 | ||
20794 | JSObject &getInitialVarObj() const { | |
20795 | ((void) 0); | |
20796 | return *initialVarObj; | |
20797 | } | |
20798 | ||
20799 | ||
20800 | ||
20801 | ||
20802 | }; | |
20803 | ||
20804 | static const size_t VALUES_PER_STACK_SEGMENT = sizeof(StackSegment) / sizeof(Value); | |
20805 | typedef int js_static_assert63[(sizeof(StackSegment) % sizeof(Value) == 0) ? 1 : -1]; | |
20806 | ||
20807 | ||
20808 | class InvokeArgsGuard : public CallArgs | |
20809 | { | |
20810 | friend class StackSpace; | |
20811 | JSContext *cx; | |
20812 | StackSegment *seg; | |
20813 | Value *prevInvokeArgEnd; | |
20814 | ||
20815 | ||
20816 | ||
20817 | ||
20818 | public: | |
20819 | InvokeArgsGuard() : cx(__null), seg(__null) {} | |
20820 | ~InvokeArgsGuard(); | |
20821 | bool pushed() const { return cx != __null; } | |
20822 | }; | |
20823 | ||
20824 | ||
20825 | ||
20826 | ||
20827 | ||
20828 | struct InvokeArgsAlreadyOnTheStack : CallArgs | |
20829 | { | |
20830 | InvokeArgsAlreadyOnTheStack(Value *vp, uintN argc) : CallArgs(vp + 2, argc) {} | |
20831 | }; | |
20832 | ||
20833 | ||
20834 | class InvokeFrameGuard | |
20835 | { | |
20836 | friend class StackSpace; | |
20837 | JSContext *cx_; | |
20838 | JSFrameRegs regs_; | |
20839 | JSFrameRegs *prevRegs_; | |
20840 | public: | |
20841 | InvokeFrameGuard() : cx_(__null) {} | |
20842 | ~InvokeFrameGuard() { if (pushed()) pop(); } | |
20843 | bool pushed() const { return cx_ != __null; } | |
20844 | JSContext *pushedFrameContext() const { ((void) 0); return cx_; } | |
20845 | void pop(); | |
20846 | JSStackFrame *fp() const { return regs_.fp; } | |
20847 | }; | |
20848 | ||
20849 | ||
20850 | class FrameGuard | |
20851 | { | |
20852 | friend class StackSpace; | |
20853 | JSContext *cx_; | |
20854 | StackSegment *seg_; | |
20855 | Value *vp_; | |
20856 | JSStackFrame *fp_; | |
20857 | public: | |
20858 | FrameGuard() : cx_(__null), vp_(__null), fp_(__null) {} | |
20859 | ~FrameGuard(); | |
20860 | bool pushed() const { return cx_ != __null; } | |
20861 | StackSegment *segment() const { return seg_; } | |
20862 | Value *vp() const { return vp_; } | |
20863 | JSStackFrame *fp() const { return fp_; } | |
20864 | }; | |
20865 | ||
20866 | ||
20867 | class ExecuteFrameGuard : public FrameGuard | |
20868 | { | |
20869 | friend class StackSpace; | |
20870 | JSFrameRegs regs_; | |
20871 | }; | |
20872 | ||
20873 | ||
20874 | class DummyFrameGuard : public FrameGuard | |
20875 | { | |
20876 | friend class StackSpace; | |
20877 | JSFrameRegs regs_; | |
20878 | }; | |
20879 | ||
20880 | ||
20881 | class GeneratorFrameGuard : public FrameGuard | |
20882 | {}; | |
20883 | # 573 "jscntxt.h" | |
20884 | class StackSpace | |
20885 | { | |
20886 | Value *base; | |
20887 | ||
20888 | ||
20889 | ||
20890 | Value *end; | |
20891 | StackSegment *currentSegment; | |
20892 | # 590 "jscntxt.h" | |
20893 | Value *invokeArgEnd; | |
20894 | ||
20895 | friend class InvokeArgsGuard; | |
20896 | friend class InvokeFrameGuard; | |
20897 | friend class FrameGuard; | |
20898 | ||
20899 | bool pushSegmentForInvoke(JSContext *cx, uintN argc, InvokeArgsGuard *ag); | |
20900 | void popSegmentForInvoke(const InvokeArgsGuard &ag); | |
20901 | ||
20902 | bool pushInvokeFrameSlow(JSContext *cx, const InvokeArgsGuard &ag, | |
20903 | InvokeFrameGuard *fg); | |
20904 | void popInvokeFrameSlow(const CallArgs &args); | |
20905 | ||
20906 | bool getSegmentAndFrame(JSContext *cx, uintN vplen, uintN nslots, | |
20907 | FrameGuard *fg) const; | |
20908 | void pushSegmentAndFrame(JSContext *cx, JSFrameRegs *regs, FrameGuard *fg); | |
20909 | void popSegmentAndFrame(JSContext *cx); | |
20910 | ||
20911 | struct EnsureSpaceCheck { | |
20912 | inline bool operator()(const StackSpace &, JSContext *, Value *, uintN); | |
20913 | }; | |
20914 | ||
20915 | struct LimitCheck { | |
20916 | JSStackFrame *base; | |
20917 | Value **limit; | |
20918 | LimitCheck(JSStackFrame *base, Value **limit) : base(base), limit(limit) {} | |
20919 | inline bool operator()(const StackSpace &, JSContext *, Value *, uintN); | |
20920 | }; | |
20921 | ||
20922 | template <class Check> | |
20923 | inline JSStackFrame *getCallFrame(JSContext *cx, Value *sp, uintN nactual, | |
20924 | JSFunction *fun, JSScript *script, | |
20925 | uint32 *pflags, Check check) const; | |
20926 | ||
20927 | inline void popInvokeArgs(const InvokeArgsGuard &args); | |
20928 | inline void popInvokeFrame(const InvokeFrameGuard &ag); | |
20929 | ||
20930 | inline Value *firstUnused() const; | |
20931 | ||
20932 | inline bool isCurrentAndActive(JSContext *cx) const; | |
20933 | friend class AllFramesIter; | |
20934 | StackSegment *getCurrentSegment() const { return currentSegment; } | |
20935 | ||
20936 | ||
20937 | ||
20938 | ||
20939 | ||
20940 | ||
20941 | public: | |
20942 | static const size_t CAPACITY_VALS = 512 * 1024; | |
20943 | static const size_t CAPACITY_BYTES = CAPACITY_VALS * sizeof(Value); | |
20944 | static const size_t COMMIT_VALS = 16 * 1024; | |
20945 | static const size_t COMMIT_BYTES = COMMIT_VALS * sizeof(Value); | |
20946 | # 654 "jscntxt.h" | |
20947 | static const size_t STACK_QUOTA = (VALUES_PER_STACK_FRAME + 18) * | |
20948 | 3000; | |
20949 | ||
20950 | ||
20951 | bool init(); | |
20952 | void finish(); | |
20953 | # 676 "jscntxt.h" | |
20954 | inline bool ensureEnoughSpaceToEnterTrace(); | |
20955 | ||
20956 | ||
20957 | static const ptrdiff_t MAX_TRACE_SPACE_VALS = | |
20958 | MAX_NATIVE_STACK_SLOTS + MAX_CALL_STACK_ENTRIES * VALUES_PER_STACK_FRAME + | |
20959 | (VALUES_PER_STACK_SEGMENT + VALUES_PER_STACK_FRAME ); | |
20960 | ||
20961 | ||
20962 | void mark(JSTracer *trc); | |
20963 | # 708 "jscntxt.h" | |
20964 | bool pushInvokeArgs(JSContext *cx, uintN argc, InvokeArgsGuard *ag); | |
20965 | ||
20966 | ||
20967 | bool getInvokeFrame(JSContext *cx, const CallArgs &args, JSFunction *fun, | |
20968 | JSScript *script, uint32 *flags, InvokeFrameGuard *fg) const; | |
20969 | ||
20970 | void pushInvokeFrame(JSContext *cx, const CallArgs &args, InvokeFrameGuard *fg); | |
20971 | ||
20972 | ||
20973 | bool getExecuteFrame(JSContext *cx, JSScript *script, ExecuteFrameGuard *fg) const; | |
20974 | void pushExecuteFrame(JSContext *cx, JSObject *initialVarObj, ExecuteFrameGuard *fg); | |
20975 | ||
20976 | ||
20977 | ||
20978 | ||
20979 | ||
20980 | inline JSStackFrame *getInlineFrame(JSContext *cx, Value *sp, uintN nactual, | |
20981 | JSFunction *fun, JSScript *script, | |
20982 | uint32 *flags) const; | |
20983 | inline void pushInlineFrame(JSContext *cx, JSScript *script, JSStackFrame *fp, | |
20984 | JSFrameRegs *regs); | |
20985 | inline void popInlineFrame(JSContext *cx, JSStackFrame *prev, js::Value *newsp); | |
20986 | ||
20987 | ||
20988 | bool getGeneratorFrame(JSContext *cx, uintN vplen, uintN nslots, | |
20989 | GeneratorFrameGuard *fg); | |
20990 | void pushGeneratorFrame(JSContext *cx, JSFrameRegs *regs, GeneratorFrameGuard *fg); | |
20991 | ||
20992 | ||
20993 | bool pushDummyFrame(JSContext *cx, JSObject &scopeChain, DummyFrameGuard *fg); | |
20994 | ||
20995 | ||
20996 | inline JSStackFrame *getInlineFrameWithinLimit(JSContext *cx, Value *sp, uintN nactual, | |
20997 | JSFunction *fun, JSScript *script, uint32 *flags, | |
20998 | JSStackFrame *base, Value **limit) const; | |
20999 | ||
21000 | ||
21001 | ||
21002 | ||
21003 | ||
21004 | ||
21005 | inline Value *getStackLimit(JSContext *cx); | |
21006 | ||
21007 | ||
21008 | ||
21009 | ||
21010 | ||
21011 | bool bumpCommitAndLimit(JSStackFrame *base, Value *from, uintN nvals, Value **limit) const; | |
21012 | ||
21013 | ||
21014 | ||
21015 | ||
21016 | ||
21017 | inline bool ensureSpace(JSContext *maybecx, Value *from, ptrdiff_t nvals) const; | |
21018 | }; | |
21019 | ||
21020 | typedef int js_static_assert64[(StackSpace::CAPACITY_VALS % StackSpace::COMMIT_VALS == 0) ? 1 : -1]; | |
21021 | # 776 "jscntxt.h" | |
21022 | class FrameRegsIter | |
21023 | { | |
21024 | JSContext *cx; | |
21025 | StackSegment *curseg; | |
21026 | JSStackFrame *curfp; | |
21027 | Value *cursp; | |
21028 | jsbytecode *curpc; | |
21029 | ||
21030 | void initSlow(); | |
21031 | void incSlow(JSStackFrame *fp, JSStackFrame *prev); | |
21032 | ||
21033 | public: | |
21034 | inline FrameRegsIter(JSContext *cx); | |
21035 | ||
21036 | bool done() const { return curfp == __null; } | |
21037 | inline FrameRegsIter &operator++(); | |
21038 | ||
21039 | JSStackFrame *fp() const { return curfp; } | |
21040 | Value *sp() const { return cursp; } | |
21041 | jsbytecode *pc() const { return curpc; } | |
21042 | }; | |
21043 | ||
21044 | ||
21045 | ||
21046 | ||
21047 | class AllFramesIter | |
21048 | { | |
21049 | public: | |
21050 | AllFramesIter(JSContext *cx); | |
21051 | ||
21052 | bool done() const { return curfp == __null; } | |
21053 | AllFramesIter& operator++(); | |
21054 | ||
21055 | JSStackFrame *fp() const { return curfp; } | |
21056 | ||
21057 | private: | |
21058 | StackSegment *curcs; | |
21059 | JSStackFrame *curfp; | |
21060 | }; | |
21061 | ||
21062 | } | |
21063 | # 840 "jscntxt.h" | |
21064 | struct JSPendingProxyOperation { | |
21065 | JSPendingProxyOperation *next; | |
21066 | JSObject *object; | |
21067 | }; | |
21068 | ||
21069 | struct JSThreadData { | |
21070 | ||
21071 | ||
21072 | unsigned requestDepth; | |
21073 | # 870 "jscntxt.h" | |
21074 | volatile int32 interruptFlags; | |
21075 | ||
21076 | ||
21077 | js::StackSpace stackSpace; | |
21078 | ||
21079 | ||
21080 | ||
21081 | ||
21082 | ||
21083 | bool waiveGCQuota; | |
21084 | ||
21085 | ||
21086 | ||
21087 | ||
21088 | ||
21089 | JSGSNCache gsnCache; | |
21090 | ||
21091 | ||
21092 | js::PropertyCache propertyCache; | |
21093 | ||
21094 | ||
21095 | ||
21096 | ||
21097 | ||
21098 | ||
21099 | ||
21100 | DtoaState *dtoaState; | |
21101 | ||
21102 | ||
21103 | jsuword *nativeStackBase; | |
21104 | ||
21105 | ||
21106 | JSPendingProxyOperation *pendingProxyOperation; | |
21107 | ||
21108 | js::ConservativeGCThreadData conservativeGC; | |
21109 | ||
21110 | bool init(); | |
21111 | void finish(); | |
21112 | void mark(JSTracer *trc); | |
21113 | void purge(JSContext *cx); | |
21114 | ||
21115 | ||
21116 | inline void triggerOperationCallback(JSRuntime *rt); | |
21117 | }; | |
21118 | ||
21119 | ||
21120 | ||
21121 | ||
21122 | ||
21123 | ||
21124 | ||
21125 | struct JSThread { | |
21126 | typedef js::HashMap<void *, | |
21127 | JSThread *, | |
21128 | js::DefaultHasher<void *>, | |
21129 | js::SystemAllocPolicy> Map; | |
21130 | ||
21131 | ||
21132 | JSCList contextList; | |
21133 | ||
21134 | ||
21135 | void *id; | |
21136 | ||
21137 | ||
21138 | unsigned suspendCount; | |
21139 | ||
21140 | ||
21141 | ||
21142 | ||
21143 | ||
21144 | ||
21145 | JSThreadData data; | |
21146 | }; | |
21147 | ||
21148 | ||
21149 | ||
21150 | extern JSThread * | |
21151 | js_CurrentThread(JSRuntime *rt); | |
21152 | ||
21153 | ||
21154 | ||
21155 | ||
21156 | ||
21157 | ||
21158 | extern JSBool | |
21159 | js_InitContextThread(JSContext *cx); | |
21160 | ||
21161 | ||
21162 | ||
21163 | ||
21164 | extern void | |
21165 | js_ClearContextThread(JSContext *cx); | |
21166 | ||
21167 | ||
21168 | ||
21169 | typedef enum JSDestroyContextMode { | |
21170 | JSDCM_NO_GC, | |
21171 | JSDCM_MAYBE_GC, | |
21172 | JSDCM_FORCE_GC, | |
21173 | JSDCM_NEW_FAILED | |
21174 | } JSDestroyContextMode; | |
21175 | ||
21176 | typedef enum JSRuntimeState { | |
21177 | JSRTS_DOWN, | |
21178 | JSRTS_LAUNCHING, | |
21179 | JSRTS_UP, | |
21180 | JSRTS_LANDING | |
21181 | } JSRuntimeState; | |
21182 | ||
21183 | typedef struct JSPropertyTreeEntry { | |
21184 | JSDHashEntryHdr hdr; | |
21185 | js::Shape *child; | |
21186 | } JSPropertyTreeEntry; | |
21187 | ||
21188 | typedef void | |
21189 | (* JSActivityCallback)(void *arg, JSBool active); | |
21190 | ||
21191 | namespace js { | |
21192 | ||
21193 | typedef js::Vector<JSCompartment *, 0, js::SystemAllocPolicy> WrapperVector; | |
21194 | ||
21195 | } | |
21196 | ||
21197 | struct JSRuntime { | |
21198 | ||
21199 | JSCompartment *atomsCompartment; | |
21200 | ||
21201 | bool atomsCompartmentIsLocked; | |
21202 | ||
21203 | ||
21204 | ||
21205 | js::WrapperVector compartments; | |
21206 | ||
21207 | ||
21208 | JSRuntimeState state; | |
21209 | ||
21210 | ||
21211 | JSContextCallback cxCallback; | |
21212 | ||
21213 | ||
21214 | JSCompartmentCallback compartmentCallback; | |
21215 | ||
21216 | ||
21217 | ||
21218 | ||
21219 | ||
21220 | ||
21221 | ||
21222 | void setActivityCallback(JSActivityCallback cb, void *arg) { | |
21223 | activityCallback = cb; | |
21224 | activityCallbackArg = arg; | |
21225 | } | |
21226 | ||
21227 | JSActivityCallback activityCallback; | |
21228 | void *activityCallbackArg; | |
21229 | # 1038 "jscntxt.h" | |
21230 | uint32 protoHazardShape; | |
21231 | ||
21232 | ||
21233 | js::GCChunkSet gcChunkSet; | |
21234 | ||
21235 | js::RootedValueMap gcRootsHash; | |
21236 | js::GCLocks gcLocksHash; | |
21237 | jsrefcount gcKeepAtoms; | |
21238 | size_t gcBytes; | |
21239 | size_t gcTriggerBytes; | |
21240 | size_t gcLastBytes; | |
21241 | size_t gcMaxBytes; | |
21242 | size_t gcMaxMallocBytes; | |
21243 | size_t gcChunksWaitingToExpire; | |
21244 | uint32 gcEmptyArenaPoolLifespan; | |
21245 | uint32 gcNumber; | |
21246 | js::GCMarker *gcMarkingTracer; | |
21247 | uint32 gcTriggerFactor; | |
21248 | int64 gcJitReleaseTime; | |
21249 | JSGCMode gcMode; | |
21250 | volatile bool gcIsNeeded; | |
21251 | ||
21252 | ||
21253 | ||
21254 | ||
21255 | ||
21256 | JSCompartment *gcTriggerCompartment; | |
21257 | ||
21258 | ||
21259 | JSCompartment *gcCurrentCompartment; | |
21260 | ||
21261 | ||
21262 | ||
21263 | ||
21264 | ||
21265 | ||
21266 | ||
21267 | bool gcPoke; | |
21268 | bool gcMarkAndSweep; | |
21269 | bool gcRunning; | |
21270 | bool gcRegenShapes; | |
21271 | ||
21272 | ||
21273 | ||
21274 | ||
21275 | ||
21276 | JSGCCallback gcCallback; | |
21277 | ||
21278 | private: | |
21279 | ||
21280 | ||
21281 | ||
21282 | ||
21283 | volatile ptrdiff_t gcMallocBytes; | |
21284 | ||
21285 | public: | |
21286 | js::GCChunkAllocator *gcChunkAllocator; | |
21287 | ||
21288 | void setCustomGCChunkAllocator(js::GCChunkAllocator *allocator) { | |
21289 | ((void) 0); | |
21290 | ((void) 0); | |
21291 | gcChunkAllocator = allocator; | |
21292 | } | |
21293 | ||
21294 | ||
21295 | ||
21296 | ||
21297 | ||
21298 | JSTraceDataOp gcExtraRootsTraceOp; | |
21299 | void *gcExtraRootsData; | |
21300 | ||
21301 | ||
21302 | js::Value NaNValue; | |
21303 | js::Value negativeInfinityValue; | |
21304 | js::Value positiveInfinityValue; | |
21305 | ||
21306 | JSFlatString *emptyString; | |
21307 | ||
21308 | ||
21309 | JSCList contextList; | |
21310 | ||
21311 | ||
21312 | JSDebugHooks globalDebugHooks; | |
21313 | ||
21314 | ||
21315 | ||
21316 | ||
21317 | JSBool debugMode; | |
21318 | # 1136 "jscntxt.h" | |
21319 | JSCList trapList; | |
21320 | JSCList watchPointList; | |
21321 | ||
21322 | ||
21323 | void *data; | |
21324 | ||
21325 | ||
21326 | ||
21327 | PRLock *gcLock; | |
21328 | PRCondVar *gcDone; | |
21329 | PRCondVar *requestDone; | |
21330 | uint32 requestCount; | |
21331 | JSThread *gcThread; | |
21332 | ||
21333 | js::GCHelperThread gcHelperThread; | |
21334 | ||
21335 | ||
21336 | PRLock *rtLock; | |
21337 | ||
21338 | ||
21339 | ||
21340 | ||
21341 | ||
21342 | PRCondVar *stateChange; | |
21343 | ||
21344 | ||
21345 | ||
21346 | ||
21347 | ||
21348 | ||
21349 | ||
21350 | PRLock *debuggerLock; | |
21351 | ||
21352 | JSThread::Map threads; | |
21353 | ||
21354 | uint32 debuggerMutations; | |
21355 | ||
21356 | ||
21357 | ||
21358 | ||
21359 | ||
21360 | JSSecurityCallbacks *securityCallbacks; | |
21361 | ||
21362 | ||
21363 | const JSStructuredCloneCallbacks *structuredCloneCallbacks; | |
21364 | ||
21365 | ||
21366 | ||
21367 | ||
21368 | ||
21369 | ||
21370 | int32 propertyRemovals; | |
21371 | ||
21372 | ||
21373 | struct JSHashTable *scriptFilenameTable; | |
21374 | JSCList scriptFilenamePrefixes; | |
21375 | ||
21376 | PRLock *scriptFilenameTableLock; | |
21377 | ||
21378 | ||
21379 | ||
21380 | const char *thousandsSeparator; | |
21381 | const char *decimalSeparator; | |
21382 | const char *numGrouping; | |
21383 | # 1208 "jscntxt.h" | |
21384 | JSObject *anynameObject; | |
21385 | JSObject *functionNamespaceObject; | |
21386 | ||
21387 | ||
21388 | ||
21389 | volatile int32 interruptCounter; | |
21390 | # 1233 "jscntxt.h" | |
21391 | volatile uint32 shapeGen; | |
21392 | ||
21393 | ||
21394 | JSAtomState atomState; | |
21395 | # 1336 "jscntxt.h" | |
21396 | JSWrapObjectCallback wrapObjectCallback; | |
21397 | JSPreWrapCallback preWrapObjectCallback; | |
21398 | ||
21399 | ||
21400 | ||
21401 | ||
21402 | uint32 stringMemoryUsed; | |
21403 | ||
21404 | JSRuntime(); | |
21405 | ~JSRuntime(); | |
21406 | ||
21407 | bool init(uint32 maxbytes); | |
21408 | ||
21409 | void setGCTriggerFactor(uint32 factor); | |
21410 | void setGCLastBytes(size_t lastBytes); | |
21411 | ||
21412 | ||
21413 | ||
21414 | ||
21415 | ||
21416 | void* malloc(size_t bytes, JSContext *cx = __null) { | |
21417 | updateMallocCounter(bytes); | |
21418 | void *p = ::js_malloc(bytes); | |
21419 | return (__builtin_expect((!!p), 1)) ? p : onOutOfMemory(__null, bytes, cx); | |
21420 | } | |
21421 | ||
21422 | ||
21423 | ||
21424 | ||
21425 | ||
21426 | void* calloc(size_t bytes, JSContext *cx = __null) { | |
21427 | updateMallocCounter(bytes); | |
21428 | void *p = ::js_calloc(bytes); | |
21429 | return (__builtin_expect((!!p), 1)) ? p : onOutOfMemory(reinterpret_cast<void *>(1), bytes, cx); | |
21430 | } | |
21431 | ||
21432 | void* realloc(void* p, size_t oldBytes, size_t newBytes, JSContext *cx = __null) { | |
21433 | ((void) 0); | |
21434 | updateMallocCounter(newBytes - oldBytes); | |
21435 | void *p2 = ::js_realloc(p, newBytes); | |
21436 | return (__builtin_expect((!!p2), 1)) ? p2 : onOutOfMemory(p, newBytes, cx); | |
21437 | } | |
21438 | ||
21439 | void* realloc(void* p, size_t bytes, JSContext *cx = __null) { | |
21440 | ||
21441 | ||
21442 | ||
21443 | ||
21444 | if (!p) | |
21445 | updateMallocCounter(bytes); | |
21446 | void *p2 = ::js_realloc(p, bytes); | |
21447 | return (__builtin_expect((!!p2), 1)) ? p2 : onOutOfMemory(p, bytes, cx); | |
21448 | } | |
21449 | ||
21450 | void free(void* p) { ::js_free(p); } | |
21451 | ||
21452 | bool isGCMallocLimitReached() const { return gcMallocBytes <= 0; } | |
21453 | ||
21454 | void resetGCMallocBytes() { gcMallocBytes = ptrdiff_t(gcMaxMallocBytes); } | |
21455 | ||
21456 | void setGCMaxMallocBytes(size_t value) { | |
21457 | ||
21458 | ||
21459 | ||
21460 | ||
21461 | gcMaxMallocBytes = (ptrdiff_t(value) >= 0) ? value : size_t(-1) >> 1; | |
21462 | resetGCMallocBytes(); | |
21463 | } | |
21464 | # 1413 "jscntxt.h" | |
21465 | void updateMallocCounter(size_t nbytes) { | |
21466 | ||
21467 | ptrdiff_t newCount = gcMallocBytes - ptrdiff_t(nbytes); | |
21468 | gcMallocBytes = newCount; | |
21469 | if ((__builtin_expect((newCount <= 0), 0))) | |
21470 | onTooMuchMalloc(); | |
21471 | } | |
21472 | ||
21473 | private: | |
21474 | ||
21475 | ||
21476 | ||
21477 | __attribute__((visibility ("default"))) void onTooMuchMalloc(); | |
21478 | # 1435 "jscntxt.h" | |
21479 | __attribute__((visibility ("default"))) void * onOutOfMemory(void *p, size_t nbytes, JSContext *cx); | |
21480 | }; | |
21481 | # 1459 "jscntxt.h" | |
21482 | struct JSArgumentFormatMap { | |
21483 | const char *format; | |
21484 | size_t length; | |
21485 | JSArgumentFormatter formatter; | |
21486 | JSArgumentFormatMap *next; | |
21487 | }; | |
21488 | # 1473 "jscntxt.h" | |
21489 | typedef struct JSResolvingKey { | |
21490 | JSObject *obj; | |
21491 | jsid id; | |
21492 | } JSResolvingKey; | |
21493 | ||
21494 | typedef struct JSResolvingEntry { | |
21495 | JSDHashEntryHdr hdr; | |
21496 | JSResolvingKey key; | |
21497 | uint32 flags; | |
21498 | } JSResolvingEntry; | |
21499 | ||
21500 | ||
21501 | ||
21502 | ||
21503 | ||
21504 | extern const JSDebugHooks js_NullDebugHooks; | |
21505 | ||
21506 | namespace js { | |
21507 | ||
21508 | class AutoGCRooter; | |
21509 | ||
21510 | static inline | |
21511 | ||
21512 | # 1494 "jscntxt.h" | |
21513 | bool | |
21514 | OptionsHasXML(uint32 options) | |
21515 | { | |
21516 | return !!(options & ((JSUint32)1 << (6))); | |
21517 | } | |
21518 | ||
21519 | static inline | |
21520 | ||
21521 | # 1500 "jscntxt.h" | |
21522 | bool | |
21523 | OptionsHasAnonFunFix(uint32 options) | |
21524 | { | |
21525 | return !!(options & ((JSUint32)1 << (10))); | |
21526 | } | |
21527 | ||
21528 | static inline | |
21529 | ||
21530 | # 1506 "jscntxt.h" | |
21531 | bool | |
21532 | OptionsSameVersionFlags(uint32 self, uint32 other) | |
21533 | { | |
21534 | static const uint32 mask = ((JSUint32)1 << (6)) | ((JSUint32)1 << (10)); | |
21535 | return !((self & mask) ^ (other & mask)); | |
21536 | } | |
21537 | # 1521 "jscntxt.h" | |
21538 | namespace VersionFlags { | |
21539 | static const uintN MASK = 0x0FFF; | |
21540 | static const uintN HAS_XML = 0x1000; | |
21541 | static const uintN ANONFUNFIX = 0x2000; | |
21542 | static const uintN FULL_MASK = 0x3FFF; | |
21543 | } | |
21544 | ||
21545 | static inline JSVersion | |
21546 | VersionNumber(JSVersion version) | |
21547 | { | |
21548 | return JSVersion(uint32(version) & VersionFlags::MASK); | |
21549 | } | |
21550 | ||
21551 | static inline | |
21552 | ||
21553 | # 1534 "jscntxt.h" | |
21554 | bool | |
21555 | VersionHasXML(JSVersion version) | |
21556 | { | |
21557 | return !!(version & VersionFlags::HAS_XML); | |
21558 | } | |
21559 | ||
21560 | ||
21561 | static inline | |
21562 | ||
21563 | # 1541 "jscntxt.h" | |
21564 | bool | |
21565 | VersionShouldParseXML(JSVersion version) | |
21566 | { | |
21567 | return VersionHasXML(version) || VersionNumber(version) >= JSVERSION_1_6; | |
21568 | } | |
21569 | ||
21570 | static inline | |
21571 | ||
21572 | # 1547 "jscntxt.h" | |
21573 | bool | |
21574 | VersionHasAnonFunFix(JSVersion version) | |
21575 | { | |
21576 | return !!(version & VersionFlags::ANONFUNFIX); | |
21577 | } | |
21578 | ||
21579 | static inline void | |
21580 | VersionSetXML(JSVersion *version, bool enable) | |
21581 | { | |
21582 | if (enable) | |
21583 | *version = JSVersion(uint32(*version) | VersionFlags::HAS_XML); | |
21584 | else | |
21585 | *version = JSVersion(uint32(*version) & ~VersionFlags::HAS_XML); | |
21586 | } | |
21587 | ||
21588 | static inline void | |
21589 | VersionSetAnonFunFix(JSVersion *version, bool enable) | |
21590 | { | |
21591 | if (enable) | |
21592 | *version = JSVersion(uint32(*version) | VersionFlags::ANONFUNFIX); | |
21593 | else | |
21594 | *version = JSVersion(uint32(*version) & ~VersionFlags::ANONFUNFIX); | |
21595 | } | |
21596 | ||
21597 | static inline JSVersion | |
21598 | VersionExtractFlags(JSVersion version) | |
21599 | { | |
21600 | return JSVersion(uint32(version) & ~VersionFlags::MASK); | |
21601 | } | |
21602 | ||
21603 | static inline void | |
21604 | VersionCopyFlags(JSVersion *version, JSVersion from) | |
21605 | { | |
21606 | *version = JSVersion(VersionNumber(*version) | VersionExtractFlags(from)); | |
21607 | } | |
21608 | ||
21609 | static inline | |
21610 | ||
21611 | # 1583 "jscntxt.h" | |
21612 | bool | |
21613 | VersionHasFlags(JSVersion version) | |
21614 | { | |
21615 | return !!VersionExtractFlags(version); | |
21616 | } | |
21617 | ||
21618 | static inline uintN | |
21619 | VersionFlagsToOptions(JSVersion version) | |
21620 | { | |
21621 | uintN copts = (VersionHasXML(version) ? ((JSUint32)1 << (6)) : 0) | | |
21622 | (VersionHasAnonFunFix(version) ? ((JSUint32)1 << (10)) : 0); | |
21623 | ((void) 0); | |
21624 | return copts; | |
21625 | } | |
21626 | ||
21627 | static inline JSVersion | |
21628 | OptionFlagsToVersion(uintN options, JSVersion version) | |
21629 | { | |
21630 | VersionSetXML(&version, OptionsHasXML(options)); | |
21631 | VersionSetAnonFunFix(&version, OptionsHasAnonFunFix(options)); | |
21632 | return version; | |
21633 | } | |
21634 | ||
21635 | static inline | |
21636 | ||
21637 | # 1606 "jscntxt.h" | |
21638 | bool | |
21639 | VersionIsKnown(JSVersion version) | |
21640 | { | |
21641 | return VersionNumber(version) != JSVERSION_UNKNOWN; | |
21642 | } | |
21643 | ||
21644 | typedef js::HashSet<JSObject *, | |
21645 | js::DefaultHasher<JSObject *>, | |
21646 | js::SystemAllocPolicy> BusyArraysMap; | |
21647 | ||
21648 | } | |
21649 | ||
21650 | struct JSContext | |
21651 | { | |
21652 | explicit JSContext(JSRuntime *rt); | |
21653 | ||
21654 | ||
21655 | JSCList link; | |
21656 | ||
21657 | private: | |
21658 | ||
21659 | JSVersion defaultVersion; | |
21660 | JSVersion versionOverride; | |
21661 | bool hasVersionOverride; | |
21662 | ||
21663 | ||
21664 | JSBool throwing; | |
21665 | js::Value exception; | |
21666 | ||
21667 | ||
21668 | uintN runOptions; | |
21669 | ||
21670 | public: | |
21671 | ||
21672 | JSLocaleCallbacks *localeCallbacks; | |
21673 | ||
21674 | ||
21675 | ||
21676 | ||
21677 | ||
21678 | ||
21679 | ||
21680 | JSDHashTable *resolvingTable; | |
21681 | ||
21682 | ||
21683 | ||
21684 | ||
21685 | ||
21686 | JSPackedBool generatingError; | |
21687 | ||
21688 | ||
21689 | jsuword stackLimit; | |
21690 | ||
21691 | ||
21692 | size_t scriptStackQuota; | |
21693 | ||
21694 | ||
21695 | JSRuntime *const runtime; | |
21696 | ||
21697 | ||
21698 | JSCompartment *compartment; | |
21699 | ||
21700 | ||
21701 | ||
21702 | JSFrameRegs *regs; | |
21703 | ||
21704 | ||
21705 | ||
21706 | JSStackFrame* fp() { | |
21707 | ((void) 0); | |
21708 | return regs->fp; | |
21709 | } | |
21710 | ||
21711 | JSStackFrame* maybefp() { | |
21712 | ((void) 0); | |
21713 | return regs ? regs->fp : __null; | |
21714 | } | |
21715 | ||
21716 | bool hasfp() { | |
21717 | ((void) 0); | |
21718 | return !!regs; | |
21719 | } | |
21720 | ||
21721 | public: | |
21722 | friend class js::StackSpace; | |
21723 | friend bool js::Interpret(JSContext *, JSStackFrame *, uintN, JSInterpMode); | |
21724 | ||
21725 | void resetCompartment(); | |
21726 | void wrapPendingException(); | |
21727 | ||
21728 | ||
21729 | void setCurrentRegs(JSFrameRegs *regs) { | |
21730 | ((void) 0); | |
21731 | this->regs = regs; | |
21732 | } | |
21733 | ||
21734 | ||
21735 | JSArenaPool tempPool; | |
21736 | ||
21737 | ||
21738 | JSArenaPool regExpPool; | |
21739 | ||
21740 | ||
21741 | JSObject *globalObject; | |
21742 | ||
21743 | ||
21744 | JSSharpObjectMap sharpObjectMap; | |
21745 | js::BusyArraysMap busyArrays; | |
21746 | ||
21747 | ||
21748 | JSArgumentFormatMap *argumentFormatMap; | |
21749 | ||
21750 | ||
21751 | char *lastMessage; | |
21752 | ||
21753 | ||
21754 | ||
21755 | ||
21756 | ||
21757 | ||
21758 | JSErrorReporter errorReporter; | |
21759 | ||
21760 | ||
21761 | JSOperationCallback operationCallback; | |
21762 | ||
21763 | ||
21764 | uintN interpLevel; | |
21765 | ||
21766 | ||
21767 | void *data; | |
21768 | void *data2; | |
21769 | ||
21770 | private: | |
21771 | ||
21772 | js::StackSegment *currentSegment; | |
21773 | ||
21774 | public: | |
21775 | void assertSegmentsInSync() const { | |
21776 | # 1753 "jscntxt.h" | |
21777 | } | |
21778 | ||
21779 | ||
21780 | bool hasActiveSegment() const { | |
21781 | assertSegmentsInSync(); | |
21782 | return !!regs; | |
21783 | } | |
21784 | ||
21785 | ||
21786 | js::StackSegment *activeSegment() const { | |
21787 | ((void) 0); | |
21788 | return currentSegment; | |
21789 | } | |
21790 | ||
21791 | ||
21792 | js::StackSegment *getCurrentSegment() const { | |
21793 | assertSegmentsInSync(); | |
21794 | return currentSegment; | |
21795 | } | |
21796 | ||
21797 | inline js::RegExpStatics *regExpStatics(); | |
21798 | ||
21799 | ||
21800 | void pushSegmentAndFrame(js::StackSegment *newseg, JSFrameRegs ®s); | |
21801 | ||
21802 | ||
21803 | void popSegmentAndFrame(); | |
21804 | ||
21805 | ||
21806 | void saveActiveSegment(); | |
21807 | ||
21808 | ||
21809 | void restoreSegment(); | |
21810 | ||
21811 | ||
21812 | inline JSStackFrame *computeNextFrame(JSStackFrame *fp); | |
21813 | ||
21814 | ||
21815 | ||
21816 | ||
21817 | ||
21818 | js::StackSegment *containingSegment(const JSStackFrame *target); | |
21819 | ||
21820 | ||
21821 | JSStackFrame *findFrameAtLevel(uintN targetLevel) const { | |
21822 | JSStackFrame *fp = regs->fp; | |
21823 | while (true) { | |
21824 | ((void) 0); | |
21825 | if (fp->script()->staticLevel == targetLevel) | |
21826 | break; | |
21827 | fp = fp->prev(); | |
21828 | } | |
21829 | return fp; | |
21830 | } | |
21831 | ||
21832 | public: | |
21833 | ||
21834 | ||
21835 | ||
21836 | ||
21837 | bool canSetDefaultVersion() const { | |
21838 | return !regs && !hasVersionOverride; | |
21839 | } | |
21840 | ||
21841 | ||
21842 | void overrideVersion(JSVersion newVersion) { | |
21843 | ((void) 0); | |
21844 | versionOverride = newVersion; | |
21845 | hasVersionOverride = true; | |
21846 | } | |
21847 | ||
21848 | ||
21849 | void setDefaultVersion(JSVersion version) { | |
21850 | defaultVersion = version; | |
21851 | } | |
21852 | ||
21853 | void clearVersionOverride() { hasVersionOverride = false; } | |
21854 | JSVersion getDefaultVersion() const { return defaultVersion; } | |
21855 | bool isVersionOverridden() const { return hasVersionOverride; } | |
21856 | ||
21857 | JSVersion getVersionOverride() const { | |
21858 | ((void) 0); | |
21859 | return versionOverride; | |
21860 | } | |
21861 | ||
21862 | ||
21863 | ||
21864 | ||
21865 | ||
21866 | bool maybeOverrideVersion(JSVersion newVersion) { | |
21867 | if (canSetDefaultVersion()) { | |
21868 | setDefaultVersion(newVersion); | |
21869 | return false; | |
21870 | } | |
21871 | overrideVersion(newVersion); | |
21872 | return true; | |
21873 | } | |
21874 | ||
21875 | private: | |
21876 | # 1860 "jscntxt.h" | |
21877 | void maybeMigrateVersionOverride() { | |
21878 | if ((__builtin_expect((!isVersionOverridden() || currentSegment), 1))) | |
21879 | return; | |
21880 | defaultVersion = versionOverride; | |
21881 | clearVersionOverride(); | |
21882 | } | |
21883 | ||
21884 | public: | |
21885 | # 1876 "jscntxt.h" | |
21886 | JSVersion findVersion() const { | |
21887 | if (hasVersionOverride) | |
21888 | return versionOverride; | |
21889 | ||
21890 | if (regs) { | |
21891 | ||
21892 | JSStackFrame *fp = regs->fp; | |
21893 | while (fp && !fp->isScriptFrame()) | |
21894 | fp = fp->prev(); | |
21895 | if (fp) | |
21896 | return fp->script()->getVersion(); | |
21897 | } | |
21898 | ||
21899 | return defaultVersion; | |
21900 | } | |
21901 | ||
21902 | void setRunOptions(uintN ropts) { | |
21903 | ((void) 0); | |
21904 | runOptions = ropts; | |
21905 | } | |
21906 | ||
21907 | ||
21908 | void setCompileOptions(uintN newcopts) { | |
21909 | ((void) 0); | |
21910 | if ((__builtin_expect((getCompileOptions() == newcopts), 1))) | |
21911 | return; | |
21912 | JSVersion version = findVersion(); | |
21913 | JSVersion newVersion = js::OptionFlagsToVersion(newcopts, version); | |
21914 | maybeOverrideVersion(newVersion); | |
21915 | } | |
21916 | ||
21917 | uintN getRunOptions() const { return runOptions; } | |
21918 | uintN getCompileOptions() const { return js::VersionFlagsToOptions(findVersion()); } | |
21919 | uintN allOptions() const { return getRunOptions() | getCompileOptions(); } | |
21920 | ||
21921 | bool hasRunOption(uintN ropt) const { | |
21922 | ((void) 0); | |
21923 | return !!(runOptions & ropt); | |
21924 | } | |
21925 | ||
21926 | bool hasStrictOption() const { return hasRunOption(((JSUint32)1 << (0))); } | |
21927 | bool hasWErrorOption() const { return hasRunOption(((JSUint32)1 << (1))); } | |
21928 | bool hasAtLineOption() const { return hasRunOption(((JSUint32)1 << (5))); } | |
21929 | ||
21930 | ||
21931 | JSThread *thread; | |
21932 | unsigned outstandingRequests; | |
21933 | ||
21934 | ||
21935 | JSCList threadLinks; | |
21936 | ||
21937 | ||
21938 | ||
21939 | ||
21940 | ||
21941 | ||
21942 | js::AutoGCRooter *autoGCRooters; | |
21943 | ||
21944 | ||
21945 | const JSDebugHooks *debugHooks; | |
21946 | ||
21947 | ||
21948 | JSSecurityCallbacks *securityCallbacks; | |
21949 | ||
21950 | ||
21951 | uintN resolveFlags; | |
21952 | ||
21953 | ||
21954 | int64 rngSeed; | |
21955 | ||
21956 | ||
21957 | js::Value iterValue; | |
21958 | # 1969 "jscntxt.h" | |
21959 | void updateJITEnabled(); | |
21960 | # 1984 "jscntxt.h" | |
21961 | DSTOffsetCache dstOffsetCache; | |
21962 | ||
21963 | ||
21964 | JSObject *enumerators; | |
21965 | ||
21966 | private: | |
21967 | ||
21968 | ||
21969 | ||
21970 | ||
21971 | ||
21972 | ||
21973 | js::Vector<JSGenerator *, 2, js::SystemAllocPolicy> genStack; | |
21974 | ||
21975 | public: | |
21976 | ||
21977 | ||
21978 | ||
21979 | ||
21980 | ||
21981 | JSGenerator *generatorFor(JSStackFrame *fp) const; | |
21982 | ||
21983 | ||
21984 | inline bool ensureGeneratorStackSpace(); | |
21985 | ||
21986 | bool enterGenerator(JSGenerator *gen) { | |
21987 | return genStack.append(gen); | |
21988 | } | |
21989 | ||
21990 | void leaveGenerator(JSGenerator *gen) { | |
21991 | ((void) 0); | |
21992 | genStack.popBack(); | |
21993 | } | |
21994 | ||
21995 | ||
21996 | ||
21997 | ||
21998 | ||
21999 | ||
22000 | js::GCHelperThread *gcBackgroundFree; | |
22001 | ||
22002 | ||
22003 | inline void* malloc(size_t bytes) { | |
22004 | return runtime->malloc(bytes, this); | |
22005 | } | |
22006 | ||
22007 | inline void* mallocNoReport(size_t bytes) { | |
22008 | ((void) 0); | |
22009 | return runtime->malloc(bytes, __null); | |
22010 | } | |
22011 | ||
22012 | inline void* calloc(size_t bytes) { | |
22013 | ((void) 0); | |
22014 | return runtime->calloc(bytes, this); | |
22015 | } | |
22016 | ||
22017 | inline void* realloc(void* p, size_t bytes) { | |
22018 | return runtime->realloc(p, bytes, this); | |
22019 | } | |
22020 | ||
22021 | inline void* realloc(void* p, size_t oldBytes, size_t newBytes) { | |
22022 | return runtime->realloc(p, oldBytes, newBytes, this); | |
22023 | } | |
22024 | ||
22025 | inline void free(void* p) { | |
22026 | ||
22027 | if (gcBackgroundFree) { | |
22028 | gcBackgroundFree->freeLater(p); | |
22029 | return; | |
22030 | } | |
22031 | ||
22032 | runtime->free(p); | |
22033 | } | |
22034 | # 2069 "jscntxt.h" | |
22035 | template <class T> | |
22036 | __attribute__((always_inline)) inline T *create() { | |
22037 | void *memory = this->malloc(sizeof(T)); if (!memory) return __null; return new(memory) T (); | |
22038 | } | |
22039 | ||
22040 | template <class T, class P1> | |
22041 | __attribute__((always_inline)) inline T *create(const P1 &p1) { | |
22042 | void *memory = this->malloc(sizeof(T)); if (!memory) return __null; return new(memory) T (p1); | |
22043 | } | |
22044 | ||
22045 | template <class T, class P1, class P2> | |
22046 | __attribute__((always_inline)) inline T *create(const P1 &p1, const P2 &p2) { | |
22047 | void *memory = this->malloc(sizeof(T)); if (!memory) return __null; return new(memory) T (p1, p2); | |
22048 | } | |
22049 | ||
22050 | template <class T, class P1, class P2, class P3> | |
22051 | __attribute__((always_inline)) inline T *create(const P1 &p1, const P2 &p2, const P3 &p3) { | |
22052 | void *memory = this->malloc(sizeof(T)); if (!memory) return __null; return new(memory) T (p1, p2, p3); | |
22053 | } | |
22054 | ||
22055 | ||
22056 | template <class T> | |
22057 | __attribute__((always_inline)) inline void destroy(T *p) { | |
22058 | p->~T(); | |
22059 | this->free(p); | |
22060 | } | |
22061 | ||
22062 | void purge(); | |
22063 | ||
22064 | js::StackSpace &stack() const { | |
22065 | return (&(this)->thread->data)->stackSpace; | |
22066 | } | |
22067 | ||
22068 | ||
22069 | ||
22070 | ||
22071 | ||
22072 | ||
22073 | ||
22074 | void assertValidStackDepth(uintN ) {} | |
22075 | ||
22076 | ||
22077 | bool isExceptionPending() { | |
22078 | return throwing; | |
22079 | } | |
22080 | ||
22081 | js::Value getPendingException() { | |
22082 | ((void) 0); | |
22083 | return exception; | |
22084 | } | |
22085 | ||
22086 | void setPendingException(js::Value v); | |
22087 | ||
22088 | void clearPendingException() { | |
22089 | this->throwing = false; | |
22090 | this->exception.setUndefined(); | |
22091 | } | |
22092 | ||
22093 | private: | |
22094 | ||
22095 | ||
22096 | ||
22097 | ||
22098 | ||
22099 | ||
22100 | __attribute__((visibility ("default"))) void checkMallocGCPressure(void *p); | |
22101 | }; | |
22102 | # 2168 "jscntxt.h" | |
22103 | static inline uintN | |
22104 | FramePCOffset(JSContext *cx, JSStackFrame* fp) | |
22105 | { | |
22106 | jsbytecode *pc = fp->hasImacropc() ? fp->imacropc() : fp->pc(cx); | |
22107 | return uintN(pc - fp->script()->code); | |
22108 | } | |
22109 | ||
22110 | static inline JSAtom ** | |
22111 | FrameAtomBase(JSContext *cx, JSStackFrame *fp) | |
22112 | { | |
22113 | return fp->hasImacropc() | |
22114 | ? ((JSAtom **)((uint8 *)(&cx->runtime->atomState) + __builtin_offsetof (JSAtomState, emptyAtom))) | |
22115 | : fp->script()->atomMap.vector; | |
22116 | } | |
22117 | ||
22118 | namespace js { | |
22119 | ||
22120 | class AutoGCRooter { | |
22121 | public: | |
22122 | AutoGCRooter(JSContext *cx, ptrdiff_t tag) | |
22123 | : down(cx->autoGCRooters), tag(tag), context(cx) | |
22124 | { | |
22125 | ((void) 0); | |
22126 | ((void) 0); | |
22127 | cx->autoGCRooters = this; | |
22128 | } | |
22129 | ||
22130 | ~AutoGCRooter() { | |
22131 | ((void) 0); | |
22132 | ((void) 0); | |
22133 | context->autoGCRooters = down; | |
22134 | } | |
22135 | ||
22136 | ||
22137 | inline void trace(JSTracer *trc); | |
22138 | ||
22139 | ||
22140 | #pragma GCC visibility push(default) | |
22141 | ||
22142 | friend __attribute__((visibility ("default"))) void MarkContext(JSTracer *trc, JSContext *acx); | |
22143 | friend void MarkRuntime(JSTracer *trc); | |
22144 | ||
22145 | #pragma GCC visibility pop | |
22146 | ||
22147 | ||
22148 | protected: | |
22149 | AutoGCRooter * const down; | |
22150 | # 2223 "jscntxt.h" | |
22151 | ptrdiff_t tag; | |
22152 | ||
22153 | JSContext * const context; | |
22154 | ||
22155 | enum { | |
22156 | JSVAL = -1, | |
22157 | SHAPE = -2, | |
22158 | PARSER = -3, | |
22159 | SCRIPT = -4, | |
22160 | ENUMERATOR = -5, | |
22161 | IDARRAY = -6, | |
22162 | DESCRIPTORS = -7, | |
22163 | NAMESPACES = -8, | |
22164 | XML = -9, | |
22165 | OBJECT = -10, | |
22166 | ID = -11, | |
22167 | VALVECTOR = -12, | |
22168 | DESCRIPTOR = -13, | |
22169 | STRING = -14, | |
22170 | IDVECTOR = -15, | |
22171 | BINDINGS = -16, | |
22172 | SHAPEVECTOR = -17 | |
22173 | }; | |
22174 | ||
22175 | private: | |
22176 | ||
22177 | AutoGCRooter(AutoGCRooter &ida); | |
22178 | void operator=(AutoGCRooter &ida); | |
22179 | }; | |
22180 | ||
22181 | ||
22182 | class AutoValueRooter : private AutoGCRooter | |
22183 | { | |
22184 | public: | |
22185 | explicit AutoValueRooter(JSContext *cx | |
22186 | ) | |
22187 | : AutoGCRooter(cx, JSVAL), val(js::NullValue()) | |
22188 | { | |
22189 | do { } while (0); | |
22190 | } | |
22191 | ||
22192 | AutoValueRooter(JSContext *cx, const Value &v | |
22193 | ) | |
22194 | : AutoGCRooter(cx, JSVAL), val(v) | |
22195 | { | |
22196 | do { } while (0); | |
22197 | } | |
22198 | ||
22199 | AutoValueRooter(JSContext *cx, jsval v | |
22200 | ) | |
22201 | : AutoGCRooter(cx, JSVAL), val(js::Valueify(v)) | |
22202 | { | |
22203 | do { } while (0); | |
22204 | } | |
22205 | ||
22206 | ||
22207 | ||
22208 | ||
22209 | ||
22210 | ||
22211 | ||
22212 | void set(Value v) { | |
22213 | ((void) 0); | |
22214 | val = v; | |
22215 | } | |
22216 | ||
22217 | void set(jsval v) { | |
22218 | ((void) 0); | |
22219 | val = js::Valueify(v); | |
22220 | } | |
22221 | ||
22222 | const Value &value() const { | |
22223 | ((void) 0); | |
22224 | return val; | |
22225 | } | |
22226 | ||
22227 | Value *addr() { | |
22228 | ((void) 0); | |
22229 | return &val; | |
22230 | } | |
22231 | ||
22232 | const jsval &jsval_value() const { | |
22233 | ((void) 0); | |
22234 | return Jsvalify(val); | |
22235 | } | |
22236 | ||
22237 | jsval *jsval_addr() { | |
22238 | ((void) 0); | |
22239 | return Jsvalify(&val); | |
22240 | } | |
22241 | ||
22242 | friend void AutoGCRooter::trace(JSTracer *trc); | |
22243 | friend void MarkRuntime(JSTracer *trc); | |
22244 | ||
22245 | private: | |
22246 | Value val; | |
22247 | ||
22248 | }; | |
22249 | ||
22250 | class AutoObjectRooter : private AutoGCRooter { | |
22251 | public: | |
22252 | AutoObjectRooter(JSContext *cx, JSObject *obj = __null | |
22253 | ) | |
22254 | : AutoGCRooter(cx, OBJECT), obj(obj) | |
22255 | { | |
22256 | do { } while (0); | |
22257 | } | |
22258 | ||
22259 | void setObject(JSObject *obj) { | |
22260 | this->obj = obj; | |
22261 | } | |
22262 | ||
22263 | JSObject * object() const { | |
22264 | return obj; | |
22265 | } | |
22266 | ||
22267 | JSObject ** addr() { | |
22268 | return &obj; | |
22269 | } | |
22270 | ||
22271 | friend void AutoGCRooter::trace(JSTracer *trc); | |
22272 | friend void MarkRuntime(JSTracer *trc); | |
22273 | ||
22274 | private: | |
22275 | JSObject *obj; | |
22276 | ||
22277 | }; | |
22278 | ||
22279 | class AutoStringRooter : private AutoGCRooter { | |
22280 | public: | |
22281 | AutoStringRooter(JSContext *cx, JSString *str = __null | |
22282 | ) | |
22283 | : AutoGCRooter(cx, STRING), str(str) | |
22284 | { | |
22285 | do { } while (0); | |
22286 | } | |
22287 | ||
22288 | void setString(JSString *str) { | |
22289 | this->str = str; | |
22290 | } | |
22291 | ||
22292 | JSString * string() const { | |
22293 | return str; | |
22294 | } | |
22295 | ||
22296 | JSString ** addr() { | |
22297 | return &str; | |
22298 | } | |
22299 | ||
22300 | friend void AutoGCRooter::trace(JSTracer *trc); | |
22301 | ||
22302 | private: | |
22303 | JSString *str; | |
22304 | ||
22305 | }; | |
22306 | ||
22307 | class AutoArrayRooter : private AutoGCRooter { | |
22308 | public: | |
22309 | AutoArrayRooter(JSContext *cx, size_t len, Value *vec | |
22310 | ) | |
22311 | : AutoGCRooter(cx, len), array(vec) | |
22312 | { | |
22313 | do { } while (0); | |
22314 | ((void) 0); | |
22315 | } | |
22316 | ||
22317 | AutoArrayRooter(JSContext *cx, size_t len, jsval *vec | |
22318 | ) | |
22319 | : AutoGCRooter(cx, len), array(Valueify(vec)) | |
22320 | { | |
22321 | do { } while (0); | |
22322 | ((void) 0); | |
22323 | } | |
22324 | ||
22325 | void changeLength(size_t newLength) { | |
22326 | tag = ptrdiff_t(newLength); | |
22327 | ((void) 0); | |
22328 | } | |
22329 | ||
22330 | void changeArray(Value *newArray, size_t newLength) { | |
22331 | changeLength(newLength); | |
22332 | array = newArray; | |
22333 | } | |
22334 | ||
22335 | Value *array; | |
22336 | ||
22337 | friend void AutoGCRooter::trace(JSTracer *trc); | |
22338 | ||
22339 | private: | |
22340 | ||
22341 | }; | |
22342 | ||
22343 | class AutoShapeRooter : private AutoGCRooter { | |
22344 | public: | |
22345 | AutoShapeRooter(JSContext *cx, const js::Shape *shape | |
22346 | ) | |
22347 | : AutoGCRooter(cx, SHAPE), shape(shape) | |
22348 | { | |
22349 | do { } while (0); | |
22350 | } | |
22351 | ||
22352 | friend void AutoGCRooter::trace(JSTracer *trc); | |
22353 | friend void MarkRuntime(JSTracer *trc); | |
22354 | ||
22355 | private: | |
22356 | const js::Shape * const shape; | |
22357 | ||
22358 | }; | |
22359 | ||
22360 | class AutoScriptRooter : private AutoGCRooter { | |
22361 | public: | |
22362 | AutoScriptRooter(JSContext *cx, JSScript *script | |
22363 | ) | |
22364 | : AutoGCRooter(cx, SCRIPT), script(script) | |
22365 | { | |
22366 | do { } while (0); | |
22367 | } | |
22368 | ||
22369 | void setScript(JSScript *script) { | |
22370 | this->script = script; | |
22371 | } | |
22372 | ||
22373 | friend void AutoGCRooter::trace(JSTracer *trc); | |
22374 | ||
22375 | private: | |
22376 | JSScript *script; | |
22377 | ||
22378 | }; | |
22379 | ||
22380 | class AutoIdRooter : private AutoGCRooter | |
22381 | { | |
22382 | public: | |
22383 | explicit AutoIdRooter(JSContext *cx, jsid id = INT_TO_JSID(0) | |
22384 | ) | |
22385 | : AutoGCRooter(cx, ID), id_(id) | |
22386 | { | |
22387 | do { } while (0); | |
22388 | } | |
22389 | ||
22390 | jsid id() { | |
22391 | return id_; | |
22392 | } | |
22393 | ||
22394 | jsid * addr() { | |
22395 | return &id_; | |
22396 | } | |
22397 | ||
22398 | friend void AutoGCRooter::trace(JSTracer *trc); | |
22399 | friend void MarkRuntime(JSTracer *trc); | |
22400 | ||
22401 | private: | |
22402 | jsid id_; | |
22403 | ||
22404 | }; | |
22405 | ||
22406 | class AutoIdArray : private AutoGCRooter { | |
22407 | public: | |
22408 | AutoIdArray(JSContext *cx, JSIdArray *ida ) | |
22409 | : AutoGCRooter(cx, IDARRAY), idArray(ida) | |
22410 | { | |
22411 | do { } while (0); | |
22412 | } | |
22413 | ~AutoIdArray() { | |
22414 | if (idArray) | |
22415 | JS_DestroyIdArray(context, idArray); | |
22416 | } | |
22417 | bool operator!() { | |
22418 | return idArray == __null; | |
22419 | } | |
22420 | jsid operator[](size_t i) const { | |
22421 | ((void) 0); | |
22422 | ((void) 0); | |
22423 | return idArray->vector[i]; | |
22424 | } | |
22425 | size_t length() const { | |
22426 | return idArray->length; | |
22427 | } | |
22428 | ||
22429 | friend void AutoGCRooter::trace(JSTracer *trc); | |
22430 | ||
22431 | JSIdArray *steal() { | |
22432 | JSIdArray *copy = idArray; | |
22433 | idArray = __null; | |
22434 | return copy; | |
22435 | } | |
22436 | ||
22437 | protected: | |
22438 | inline void trace(JSTracer *trc); | |
22439 | ||
22440 | private: | |
22441 | JSIdArray * idArray; | |
22442 | ||
22443 | ||
22444 | ||
22445 | AutoIdArray(AutoIdArray &ida); | |
22446 | void operator=(AutoIdArray &ida); | |
22447 | }; | |
22448 | ||
22449 | ||
22450 | class AutoEnumStateRooter : private AutoGCRooter | |
22451 | { | |
22452 | public: | |
22453 | AutoEnumStateRooter(JSContext *cx, JSObject *obj | |
22454 | ) | |
22455 | : AutoGCRooter(cx, ENUMERATOR), obj(obj), stateValue() | |
22456 | { | |
22457 | do { } while (0); | |
22458 | ((void) 0); | |
22459 | } | |
22460 | ||
22461 | ~AutoEnumStateRooter() { | |
22462 | if (!stateValue.isNull()) { | |
22463 | ||
22464 | ||
22465 | ||
22466 | obj->enumerate(context, JSENUMERATE_DESTROY, &stateValue, 0); | |
22467 | ((void) 0); | |
22468 | } | |
22469 | } | |
22470 | ||
22471 | friend void AutoGCRooter::trace(JSTracer *trc); | |
22472 | ||
22473 | const Value &state() const { return stateValue; } | |
22474 | Value *addr() { return &stateValue; } | |
22475 | ||
22476 | protected: | |
22477 | void trace(JSTracer *trc); | |
22478 | ||
22479 | JSObject * const obj; | |
22480 | ||
22481 | private: | |
22482 | Value stateValue; | |
22483 | ||
22484 | }; | |
22485 | ||
22486 | ||
22487 | class AutoXMLRooter : private AutoGCRooter { | |
22488 | public: | |
22489 | AutoXMLRooter(JSContext *cx, JSXML *xml | |
22490 | ) | |
22491 | : AutoGCRooter(cx, XML), xml(xml) | |
22492 | { | |
22493 | do { } while (0); | |
22494 | ((void) 0); | |
22495 | } | |
22496 | ||
22497 | friend void AutoGCRooter::trace(JSTracer *trc); | |
22498 | friend void MarkRuntime(JSTracer *trc); | |
22499 | ||
22500 | private: | |
22501 | JSXML * const xml; | |
22502 | ||
22503 | }; | |
22504 | ||
22505 | ||
22506 | class AutoBindingsRooter : private AutoGCRooter { | |
22507 | public: | |
22508 | AutoBindingsRooter(JSContext *cx, Bindings &bindings | |
22509 | ) | |
22510 | : AutoGCRooter(cx, BINDINGS), bindings(bindings) | |
22511 | { | |
22512 | do { } while (0); | |
22513 | } | |
22514 | ||
22515 | friend void AutoGCRooter::trace(JSTracer *trc); | |
22516 | ||
22517 | private: | |
22518 | Bindings &bindings; | |
22519 | ||
22520 | }; | |
22521 | ||
22522 | class AutoLockGC { | |
22523 | public: | |
22524 | explicit AutoLockGC(JSRuntime *rt | |
22525 | ) | |
22526 | : rt(rt) | |
22527 | { | |
22528 | do { } while (0); | |
22529 | PR_Lock((rt)->gcLock); | |
22530 | } | |
22531 | ~AutoLockGC() { PR_Unlock((rt)->gcLock); } | |
22532 | ||
22533 | private: | |
22534 | JSRuntime *rt; | |
22535 | ||
22536 | }; | |
22537 | ||
22538 | class AutoUnlockGC { | |
22539 | private: | |
22540 | JSRuntime *rt; | |
22541 | ||
22542 | ||
22543 | public: | |
22544 | explicit AutoUnlockGC(JSRuntime *rt | |
22545 | ) | |
22546 | : rt(rt) | |
22547 | { | |
22548 | do { } while (0); | |
22549 | PR_Unlock((rt)->gcLock); | |
22550 | } | |
22551 | ~AutoUnlockGC() { PR_Lock((rt)->gcLock); } | |
22552 | }; | |
22553 | ||
22554 | class AutoLockAtomsCompartment { | |
22555 | private: | |
22556 | JSContext *cx; | |
22557 | ||
22558 | ||
22559 | public: | |
22560 | AutoLockAtomsCompartment(JSContext *cx | |
22561 | ) | |
22562 | : cx(cx) | |
22563 | { | |
22564 | do { } while (0); | |
22565 | js_Lock(cx, &cx->runtime->atomState.lock); | |
22566 | ||
22567 | cx->runtime->atomsCompartmentIsLocked = true; | |
22568 | ||
22569 | } | |
22570 | ~AutoLockAtomsCompartment() { | |
22571 | ||
22572 | cx->runtime->atomsCompartmentIsLocked = false; | |
22573 | ||
22574 | js_Unlock(cx, &cx->runtime->atomState.lock); | |
22575 | } | |
22576 | }; | |
22577 | ||
22578 | class AutoUnlockAtomsCompartment { | |
22579 | JSContext *cx; | |
22580 | ||
22581 | ||
22582 | public: | |
22583 | AutoUnlockAtomsCompartment(JSContext *cx | |
22584 | ) | |
22585 | : cx(cx) | |
22586 | { | |
22587 | do { } while (0); | |
22588 | ||
22589 | cx->runtime->atomsCompartmentIsLocked = false; | |
22590 | ||
22591 | js_Unlock(cx, &cx->runtime->atomState.lock); | |
22592 | } | |
22593 | ~AutoUnlockAtomsCompartment() { | |
22594 | js_Lock(cx, &cx->runtime->atomState.lock); | |
22595 | ||
22596 | cx->runtime->atomsCompartmentIsLocked = true; | |
22597 | ||
22598 | } | |
22599 | }; | |
22600 | ||
22601 | class AutoKeepAtoms { | |
22602 | JSRuntime *rt; | |
22603 | ||
22604 | ||
22605 | public: | |
22606 | explicit AutoKeepAtoms(JSRuntime *rt | |
22607 | ) | |
22608 | : rt(rt) | |
22609 | { | |
22610 | do { } while (0); | |
22611 | PR_AtomicIncrement((PRInt32 *)(&(rt)->gcKeepAtoms));; | |
22612 | } | |
22613 | ~AutoKeepAtoms() { PR_AtomicDecrement((PRInt32 *)(&(rt)->gcKeepAtoms));; } | |
22614 | }; | |
22615 | ||
22616 | class AutoArenaAllocator { | |
22617 | JSArenaPool *pool; | |
22618 | void *mark; | |
22619 | ||
22620 | ||
22621 | public: | |
22622 | explicit AutoArenaAllocator(JSArenaPool *pool | |
22623 | ) | |
22624 | : pool(pool), mark(((void *) (pool)->current->avail)) | |
22625 | { | |
22626 | do { } while (0); | |
22627 | } | |
22628 | ~AutoArenaAllocator() { do { char *_m = (char *)(mark); JSArena *_a = (pool)->current; if (_a != &(pool)->first && (((jsuword)(_m) - (jsuword)((_a)->base)) <= ((jsuword)((_a)->avail) - (jsuword)((_a)->base)))) { _a->avail = (jsuword)(((jsuword)(_m) + (pool)->mask) & ~(pool)->mask); ((void) 0); ; ; } else { JS_ArenaRelease(pool, _m); } ; } while (0); } | |
22629 | ||
22630 | template <typename T> | |
22631 | T *alloc(size_t elems) { | |
22632 | void *ptr; | |
22633 | do { JSArena *_a = (pool)->current; size_t _nb = (((jsuword)(elems * sizeof(T)) + (pool)->mask) & ~(pool)->mask); jsuword _p = _a->avail; if ((_nb > _a->limit) || _p > _a->limit - _nb) _p = (jsuword)JS_ArenaAllocate(pool, _nb); else _a->avail = _p + _nb; ptr = (void *) _p; do { } while (0) ; } while (0); | |
22634 | return static_cast<T *>(ptr); | |
22635 | } | |
22636 | }; | |
22637 | ||
22638 | class AutoReleasePtr { | |
22639 | JSContext *cx; | |
22640 | void *ptr; | |
22641 | ||
22642 | ||
22643 | AutoReleasePtr operator=(const AutoReleasePtr &other); | |
22644 | ||
22645 | public: | |
22646 | explicit AutoReleasePtr(JSContext *cx, void *ptr | |
22647 | ) | |
22648 | : cx(cx), ptr(ptr) | |
22649 | { | |
22650 | do { } while (0); | |
22651 | } | |
22652 | ~AutoReleasePtr() { cx->free(ptr); } | |
22653 | }; | |
22654 | ||
22655 | ||
22656 | ||
22657 | ||
22658 | class AutoReleaseNullablePtr { | |
22659 | JSContext *cx; | |
22660 | void *ptr; | |
22661 | ||
22662 | ||
22663 | AutoReleaseNullablePtr operator=(const AutoReleaseNullablePtr &other); | |
22664 | ||
22665 | public: | |
22666 | explicit AutoReleaseNullablePtr(JSContext *cx, void *ptr | |
22667 | ) | |
22668 | : cx(cx), ptr(ptr) | |
22669 | { | |
22670 | do { } while (0); | |
22671 | } | |
22672 | void reset(void *ptr2) { | |
22673 | if (ptr) | |
22674 | cx->free(ptr); | |
22675 | ptr = ptr2; | |
22676 | } | |
22677 | ~AutoReleaseNullablePtr() { if (ptr) cx->free(ptr); } | |
22678 | }; | |
22679 | ||
22680 | class AutoLocalNameArray { | |
22681 | public: | |
22682 | explicit AutoLocalNameArray(JSContext *cx, JSFunction *fun | |
22683 | ) | |
22684 | : context(cx), | |
22685 | mark(((void *) (&cx->tempPool)->current->avail)), | |
22686 | names(fun->script()->bindings.getLocalNameArray(cx, &cx->tempPool)), | |
22687 | count(fun->script()->bindings.countLocalNames()) | |
22688 | { | |
22689 | do { } while (0); | |
22690 | } | |
22691 | ||
22692 | ~AutoLocalNameArray() { | |
22693 | do { char *_m = (char *)(mark); JSArena *_a = (&context->tempPool)->current; if (_a != &(&context->tempPool)->first && (((jsuword)(_m) - (jsuword)((_a)->base)) <= ((jsuword)((_a)->avail) - (jsuword)((_a)->base)))) { _a->avail = (jsuword)(((jsuword)(_m) + (&context->tempPool)->mask) & ~(&context->tempPool)->mask); ((void) 0); ; ; } else { JS_ArenaRelease(&context->tempPool, _m); } ; } while (0); | |
22694 | } | |
22695 | ||
22696 | operator bool() const { return !!names; } | |
22697 | ||
22698 | uint32 length() const { return count; } | |
22699 | ||
22700 | const jsuword &operator [](unsigned i) const { return names[i]; } | |
22701 | ||
22702 | private: | |
22703 | JSContext *context; | |
22704 | void *mark; | |
22705 | jsuword *names; | |
22706 | uint32 count; | |
22707 | ||
22708 | ||
22709 | }; | |
22710 | ||
22711 | template <class RefCountable> | |
22712 | class AlreadyIncRefed | |
22713 | { | |
22714 | typedef RefCountable *****ConvertibleToBool; | |
22715 | ||
22716 | RefCountable *obj; | |
22717 | ||
22718 | public: | |
22719 | explicit AlreadyIncRefed(RefCountable *obj) : obj(obj) {} | |
22720 | ||
22721 | bool null() const { return obj == __null; } | |
22722 | operator ConvertibleToBool() const { return (ConvertibleToBool)obj; } | |
22723 | ||
22724 | RefCountable *operator->() const { ((void) 0); return obj; } | |
22725 | RefCountable &operator*() const { ((void) 0); return *obj; } | |
22726 | RefCountable *get() const { return obj; } | |
22727 | }; | |
22728 | ||
22729 | template <class RefCountable> | |
22730 | class NeedsIncRef | |
22731 | { | |
22732 | typedef RefCountable *****ConvertibleToBool; | |
22733 | ||
22734 | RefCountable *obj; | |
22735 | ||
22736 | public: | |
22737 | explicit NeedsIncRef(RefCountable *obj) : obj(obj) {} | |
22738 | ||
22739 | bool null() const { return obj == __null; } | |
22740 | operator ConvertibleToBool() const { return (ConvertibleToBool)obj; } | |
22741 | ||
22742 | RefCountable *operator->() const { ((void) 0); return obj; } | |
22743 | RefCountable &operator*() const { ((void) 0); return *obj; } | |
22744 | RefCountable *get() const { return obj; } | |
22745 | }; | |
22746 | ||
22747 | template <class RefCountable> | |
22748 | class AutoRefCount | |
22749 | { | |
22750 | typedef RefCountable *****ConvertibleToBool; | |
22751 | ||
22752 | JSContext *const cx; | |
22753 | RefCountable *obj; | |
22754 | ||
22755 | AutoRefCount(const AutoRefCount &); | |
22756 | void operator=(const AutoRefCount &); | |
22757 | ||
22758 | public: | |
22759 | explicit AutoRefCount(JSContext *cx) | |
22760 | : cx(cx), obj(__null) | |
22761 | {} | |
22762 | ||
22763 | AutoRefCount(JSContext *cx, NeedsIncRef<RefCountable> aobj) | |
22764 | : cx(cx), obj(aobj.get()) | |
22765 | { | |
22766 | if (obj) | |
22767 | obj->incref(cx); | |
22768 | } | |
22769 | ||
22770 | AutoRefCount(JSContext *cx, AlreadyIncRefed<RefCountable> aobj) | |
22771 | : cx(cx), obj(aobj.get()) | |
22772 | {} | |
22773 | ||
22774 | ~AutoRefCount() { | |
22775 | if (obj) | |
22776 | obj->decref(cx); | |
22777 | } | |
22778 | ||
22779 | void reset(NeedsIncRef<RefCountable> aobj) { | |
22780 | if (obj) | |
22781 | obj->decref(cx); | |
22782 | obj = aobj.get(); | |
22783 | if (obj) | |
22784 | obj->incref(cx); | |
22785 | } | |
22786 | ||
22787 | void reset(AlreadyIncRefed<RefCountable> aobj) { | |
22788 | if (obj) | |
22789 | obj->decref(cx); | |
22790 | obj = aobj.get(); | |
22791 | } | |
22792 | ||
22793 | bool null() const { return obj == __null; } | |
22794 | operator ConvertibleToBool() const { return (ConvertibleToBool)obj; } | |
22795 | ||
22796 | RefCountable *operator->() const { ((void) 0); return obj; } | |
22797 | RefCountable &operator*() const { ((void) 0); return *obj; } | |
22798 | RefCountable *get() const { return obj; } | |
22799 | }; | |
22800 | ||
22801 | } | |
22802 | ||
22803 | class JSAutoResolveFlags | |
22804 | { | |
22805 | public: | |
22806 | JSAutoResolveFlags(JSContext *cx, uintN flags | |
22807 | ) | |
22808 | : mContext(cx), mSaved(cx->resolveFlags) | |
22809 | { | |
22810 | do { } while (0); | |
22811 | cx->resolveFlags = flags; | |
22812 | } | |
22813 | ||
22814 | ~JSAutoResolveFlags() { mContext->resolveFlags = mSaved; } | |
22815 | ||
22816 | private: | |
22817 | JSContext *mContext; | |
22818 | uintN mSaved; | |
22819 | ||
22820 | }; | |
22821 | ||
22822 | extern JSThreadData * | |
22823 | js_CurrentThreadData(JSRuntime *rt); | |
22824 | ||
22825 | extern JSBool | |
22826 | js_InitThreads(JSRuntime *rt); | |
22827 | ||
22828 | extern void | |
22829 | js_FinishThreads(JSRuntime *rt); | |
22830 | ||
22831 | extern void | |
22832 | js_PurgeThreads(JSContext *cx); | |
22833 | ||
22834 | namespace js { | |
22835 | ||
22836 | ||
22837 | ||
22838 | ||
22839 | class ThreadDataIter : public JSThread::Map::Range | |
22840 | { | |
22841 | public: | |
22842 | ThreadDataIter(JSRuntime *rt) : JSThread::Map::Range(rt->threads.all()) {} | |
22843 | ||
22844 | JSThreadData *threadData() const { | |
22845 | return &front().value->data; | |
22846 | } | |
22847 | }; | |
22848 | # 2947 "jscntxt.h" | |
22849 | } | |
22850 | ||
22851 | ||
22852 | ||
22853 | ||
22854 | ||
22855 | extern JSContext * | |
22856 | js_NewContext(JSRuntime *rt, size_t stackChunkSize); | |
22857 | ||
22858 | extern void | |
22859 | js_DestroyContext(JSContext *cx, JSDestroyContextMode mode); | |
22860 | ||
22861 | static inline JSContext * | |
22862 | js_ContextFromLinkField(JSCList *link) | |
22863 | { | |
22864 | ((void) 0); | |
22865 | return (JSContext *) ((uint8 *) link - __builtin_offsetof (JSContext, link)); | |
22866 | } | |
22867 | ||
22868 | ||
22869 | ||
22870 | ||
22871 | ||
22872 | extern JSContext * | |
22873 | js_ContextIterator(JSRuntime *rt, JSBool unlocked, JSContext **iterp); | |
22874 | ||
22875 | ||
22876 | ||
22877 | ||
22878 | ||
22879 | ||
22880 | extern __attribute__((visibility ("default"))) JSContext * | |
22881 | js_NextActiveContext(JSRuntime *, JSContext *); | |
22882 | ||
22883 | ||
22884 | ||
22885 | ||
22886 | extern JSBool | |
22887 | js_StartResolving(JSContext *cx, JSResolvingKey *key, uint32 flag, | |
22888 | JSResolvingEntry **entryp); | |
22889 | ||
22890 | extern void | |
22891 | js_StopResolving(JSContext *cx, JSResolvingKey *key, uint32 flag, | |
22892 | JSResolvingEntry *entry, uint32 generation); | |
22893 | ||
22894 | ||
22895 | ||
22896 | ||
22897 | ||
22898 | typedef enum JSErrNum { | |
22899 | ||
22900 | ||
22901 | # 1 "js.msg" 1 | |
22902 | # 82 "js.msg" | |
22903 | JSMSG_NOT_AN_ERROR = 0, | |
22904 | JSMSG_NOT_DEFINED = 1, | |
22905 | JSMSG_INACTIVE = 2, | |
22906 | JSMSG_MORE_ARGS_NEEDED = 3, | |
22907 | JSMSG_BAD_CHAR = 4, | |
22908 | JSMSG_BAD_TYPE = 5, | |
22909 | JSMSG_ALLOC_OVERFLOW = 6, | |
22910 | JSMSG_MISSING_HEXDIGITS = 7, | |
22911 | JSMSG_INCOMPATIBLE_PROTO = 8, | |
22912 | JSMSG_NO_CONSTRUCTOR = 9, | |
22913 | JSMSG_CANT_ALIAS = 10, | |
22914 | JSMSG_NOT_SCRIPTED_FUNCTION = 11, | |
22915 | JSMSG_BAD_SORT_ARG = 12, | |
22916 | JSMSG_BAD_ATOMIC_NUMBER = 13, | |
22917 | JSMSG_TOO_MANY_LITERALS = 14, | |
22918 | JSMSG_CANT_WATCH = 15, | |
22919 | JSMSG_STACK_UNDERFLOW = 16, | |
22920 | JSMSG_NEED_DIET = 17, | |
22921 | JSMSG_TOO_MANY_LOCAL_ROOTS = 18, | |
22922 | JSMSG_READ_ONLY = 19, | |
22923 | JSMSG_BAD_FORMAL = 20, | |
22924 | JSMSG_CANT_DELETE = 21, | |
22925 | JSMSG_NOT_FUNCTION = 22, | |
22926 | JSMSG_NOT_CONSTRUCTOR = 23, | |
22927 | JSMSG_SCRIPT_STACK_QUOTA = 24, | |
22928 | JSMSG_TOO_DEEP = 25, | |
22929 | JSMSG_OVER_RECURSED = 26, | |
22930 | JSMSG_IN_NOT_OBJECT = 27, | |
22931 | JSMSG_BAD_NEW_RESULT = 28, | |
22932 | JSMSG_BAD_SHARP_DEF = 29, | |
22933 | JSMSG_BAD_SHARP_USE = 30, | |
22934 | JSMSG_BAD_INSTANCEOF_RHS = 31, | |
22935 | JSMSG_BAD_BYTECODE = 32, | |
22936 | JSMSG_BAD_RADIX = 33, | |
22937 | JSMSG_PAREN_BEFORE_LET = 34, | |
22938 | JSMSG_CANT_CONVERT = 35, | |
22939 | JSMSG_CYCLIC_VALUE = 36, | |
22940 | JSMSG_COMPILE_EXECED_SCRIPT = 37, | |
22941 | JSMSG_CANT_CONVERT_TO = 38, | |
22942 | JSMSG_NO_PROPERTIES = 39, | |
22943 | JSMSG_CANT_FIND_CLASS = 40, | |
22944 | JSMSG_CANT_XDR_CLASS = 41, | |
22945 | JSMSG_BYTECODE_TOO_BIG = 42, | |
22946 | JSMSG_UNKNOWN_FORMAT = 43, | |
22947 | JSMSG_TOO_MANY_CON_ARGS = 44, | |
22948 | JSMSG_TOO_MANY_FUN_ARGS = 45, | |
22949 | JSMSG_BAD_QUANTIFIER = 46, | |
22950 | JSMSG_MIN_TOO_BIG = 47, | |
22951 | JSMSG_MAX_TOO_BIG = 48, | |
22952 | JSMSG_OUT_OF_ORDER = 49, | |
22953 | JSMSG_BAD_DESTRUCT_DECL = 50, | |
22954 | JSMSG_BAD_DESTRUCT_ASS = 51, | |
22955 | JSMSG_PAREN_AFTER_LET = 52, | |
22956 | JSMSG_CURLY_AFTER_LET = 53, | |
22957 | JSMSG_MISSING_PAREN = 54, | |
22958 | JSMSG_UNTERM_CLASS = 55, | |
22959 | JSMSG_TRAILING_SLASH = 56, | |
22960 | JSMSG_BAD_CLASS_RANGE = 57, | |
22961 | JSMSG_BAD_REGEXP_FLAG = 58, | |
22962 | JSMSG_NO_INPUT = 59, | |
22963 | JSMSG_CANT_OPEN = 60, | |
22964 | JSMSG_BAD_STRING_MASK = 61, | |
22965 | JSMSG_UNMATCHED_RIGHT_PAREN = 62, | |
22966 | JSMSG_END_OF_DATA = 63, | |
22967 | JSMSG_SEEK_BEYOND_START = 64, | |
22968 | JSMSG_SEEK_BEYOND_END = 65, | |
22969 | JSMSG_END_SEEK = 66, | |
22970 | JSMSG_WHITHER_WHENCE = 67, | |
22971 | JSMSG_BAD_SCRIPT_MAGIC = 68, | |
22972 | JSMSG_PAREN_BEFORE_FORMAL = 69, | |
22973 | JSMSG_MISSING_FORMAL = 70, | |
22974 | JSMSG_PAREN_AFTER_FORMAL = 71, | |
22975 | JSMSG_CURLY_BEFORE_BODY = 72, | |
22976 | JSMSG_CURLY_AFTER_BODY = 73, | |
22977 | JSMSG_PAREN_BEFORE_COND = 74, | |
22978 | JSMSG_PAREN_AFTER_COND = 75, | |
22979 | JSMSG_DESTRUCT_DUP_ARG = 76, | |
22980 | JSMSG_NAME_AFTER_DOT = 77, | |
22981 | JSMSG_BRACKET_IN_INDEX = 78, | |
22982 | JSMSG_XML_WHOLE_PROGRAM = 79, | |
22983 | JSMSG_PAREN_BEFORE_SWITCH = 80, | |
22984 | JSMSG_PAREN_AFTER_SWITCH = 81, | |
22985 | JSMSG_CURLY_BEFORE_SWITCH = 82, | |
22986 | JSMSG_COLON_AFTER_CASE = 83, | |
22987 | JSMSG_WHILE_AFTER_DO = 84, | |
22988 | JSMSG_PAREN_AFTER_FOR = 85, | |
22989 | JSMSG_SEMI_AFTER_FOR_INIT = 86, | |
22990 | JSMSG_SEMI_AFTER_FOR_COND = 87, | |
22991 | JSMSG_PAREN_AFTER_FOR_CTRL = 88, | |
22992 | JSMSG_CURLY_BEFORE_TRY = 89, | |
22993 | JSMSG_CURLY_AFTER_TRY = 90, | |
22994 | JSMSG_PAREN_BEFORE_CATCH = 91, | |
22995 | JSMSG_CATCH_IDENTIFIER = 92, | |
22996 | JSMSG_PAREN_AFTER_CATCH = 93, | |
22997 | JSMSG_CURLY_BEFORE_CATCH = 94, | |
22998 | JSMSG_CURLY_AFTER_CATCH = 95, | |
22999 | JSMSG_CURLY_BEFORE_FINALLY = 96, | |
23000 | JSMSG_CURLY_AFTER_FINALLY = 97, | |
23001 | JSMSG_CATCH_OR_FINALLY = 98, | |
23002 | JSMSG_PAREN_BEFORE_WITH = 99, | |
23003 | JSMSG_PAREN_AFTER_WITH = 100, | |
23004 | JSMSG_CURLY_IN_COMPOUND = 101, | |
23005 | JSMSG_NO_VARIABLE_NAME = 102, | |
23006 | JSMSG_COLON_IN_COND = 103, | |
23007 | JSMSG_PAREN_AFTER_ARGS = 104, | |
23008 | JSMSG_BRACKET_AFTER_LIST = 105, | |
23009 | JSMSG_COLON_AFTER_ID = 106, | |
23010 | JSMSG_CURLY_AFTER_LIST = 107, | |
23011 | JSMSG_PAREN_IN_PAREN = 108, | |
23012 | JSMSG_SEMI_BEFORE_STMNT = 109, | |
23013 | JSMSG_NO_RETURN_VALUE = 110, | |
23014 | JSMSG_DUPLICATE_FORMAL = 111, | |
23015 | JSMSG_EQUAL_AS_ASSIGN = 112, | |
23016 | JSMSG_OPTIMIZED_CLOSURE_LEAK = 113, | |
23017 | JSMSG_TOO_MANY_DEFAULTS = 114, | |
23018 | JSMSG_TOO_MANY_CASES = 115, | |
23019 | JSMSG_BAD_SWITCH = 116, | |
23020 | JSMSG_BAD_FOR_LEFTSIDE = 117, | |
23021 | JSMSG_CATCH_AFTER_GENERAL = 118, | |
23022 | JSMSG_CATCH_WITHOUT_TRY = 119, | |
23023 | JSMSG_FINALLY_WITHOUT_TRY = 120, | |
23024 | JSMSG_LABEL_NOT_FOUND = 121, | |
23025 | JSMSG_TOUGH_BREAK = 122, | |
23026 | JSMSG_BAD_CONTINUE = 123, | |
23027 | JSMSG_BAD_RETURN_OR_YIELD = 124, | |
23028 | JSMSG_BAD_LABEL = 125, | |
23029 | JSMSG_DUPLICATE_LABEL = 126, | |
23030 | JSMSG_VAR_HIDES_ARG = 127, | |
23031 | JSMSG_BAD_VAR_INIT = 128, | |
23032 | JSMSG_BAD_LEFTSIDE_OF_ASS = 129, | |
23033 | JSMSG_BAD_OPERAND = 130, | |
23034 | JSMSG_BAD_PROP_ID = 131, | |
23035 | JSMSG_RESERVED_ID = 132, | |
23036 | JSMSG_SYNTAX_ERROR = 133, | |
23037 | JSMSG_BAD_SHARP_VAR_DEF = 134, | |
23038 | JSMSG_BAD_PROTOTYPE = 135, | |
23039 | JSMSG_MISSING_EXPONENT = 136, | |
23040 | JSMSG_OUT_OF_MEMORY = 137, | |
23041 | JSMSG_UNTERMINATED_STRING = 138, | |
23042 | JSMSG_TOO_MANY_PARENS = 139, | |
23043 | JSMSG_UNTERMINATED_COMMENT = 140, | |
23044 | JSMSG_UNTERMINATED_REGEXP = 141, | |
23045 | JSMSG_BAD_CLONE_FUNOBJ_SCOPE = 142, | |
23046 | JSMSG_SHARPVAR_TOO_BIG = 143, | |
23047 | JSMSG_ILLEGAL_CHARACTER = 144, | |
23048 | JSMSG_BAD_OCTAL = 145, | |
23049 | JSMSG_BAD_INDIRECT_CALL = 146, | |
23050 | JSMSG_UNCAUGHT_EXCEPTION = 147, | |
23051 | JSMSG_INVALID_BACKREF = 148, | |
23052 | JSMSG_BAD_BACKREF = 149, | |
23053 | JSMSG_PRECISION_RANGE = 150, | |
23054 | JSMSG_BAD_GETTER_OR_SETTER = 151, | |
23055 | JSMSG_BAD_ARRAY_LENGTH = 152, | |
23056 | JSMSG_CANT_DESCRIBE_PROPS = 153, | |
23057 | JSMSG_BAD_APPLY_ARGS = 154, | |
23058 | JSMSG_REDECLARED_VAR = 155, | |
23059 | JSMSG_UNDECLARED_VAR = 156, | |
23060 | JSMSG_ANON_NO_RETURN_VALUE = 157, | |
23061 | JSMSG_DEPRECATED_USAGE = 158, | |
23062 | JSMSG_BAD_URI = 159, | |
23063 | JSMSG_GETTER_ONLY = 160, | |
23064 | JSMSG_IDSTART_AFTER_NUMBER = 161, | |
23065 | JSMSG_UNDEFINED_PROP = 162, | |
23066 | JSMSG_USELESS_EXPR = 163, | |
23067 | JSMSG_REDECLARED_PARAM = 164, | |
23068 | JSMSG_NEWREGEXP_FLAGGED = 165, | |
23069 | JSMSG_RESERVED_SLOT_RANGE = 166, | |
23070 | JSMSG_CANT_DECODE_PRINCIPALS = 167, | |
23071 | JSMSG_CANT_SEAL_OBJECT = 168, | |
23072 | JSMSG_TOO_MANY_CATCH_VARS = 169, | |
23073 | JSMSG_BAD_XML_MARKUP = 170, | |
23074 | JSMSG_BAD_XML_CHARACTER = 171, | |
23075 | JSMSG_BAD_DEFAULT_XML_NAMESPACE = 172, | |
23076 | JSMSG_BAD_XML_NAME_SYNTAX = 173, | |
23077 | JSMSG_BRACKET_AFTER_ATTR_EXPR = 174, | |
23078 | JSMSG_NESTING_GENERATOR = 175, | |
23079 | JSMSG_CURLY_IN_XML_EXPR = 176, | |
23080 | JSMSG_BAD_XML_NAMESPACE = 177, | |
23081 | JSMSG_BAD_XML_ATTR_NAME = 178, | |
23082 | JSMSG_BAD_XML_NAME = 179, | |
23083 | JSMSG_BAD_XML_CONVERSION = 180, | |
23084 | JSMSG_BAD_XMLLIST_CONVERSION = 181, | |
23085 | JSMSG_BAD_GENERATOR_SEND = 182, | |
23086 | JSMSG_NO_ASSIGN_IN_XML_ATTR = 183, | |
23087 | JSMSG_BAD_XML_ATTR_VALUE = 184, | |
23088 | JSMSG_XML_TAG_NAME_MISMATCH = 185, | |
23089 | JSMSG_BAD_XML_TAG_SYNTAX = 186, | |
23090 | JSMSG_BAD_XML_LIST_SYNTAX = 187, | |
23091 | JSMSG_INCOMPATIBLE_METHOD = 188, | |
23092 | JSMSG_CANT_SET_XML_ATTRS = 189, | |
23093 | JSMSG_END_OF_XML_SOURCE = 190, | |
23094 | JSMSG_END_OF_XML_ENTITY = 191, | |
23095 | JSMSG_BAD_XML_QNAME = 192, | |
23096 | JSMSG_BAD_FOR_EACH_LOOP = 193, | |
23097 | JSMSG_BAD_XMLLIST_PUT = 194, | |
23098 | JSMSG_UNKNOWN_XML_ENTITY = 195, | |
23099 | JSMSG_BAD_XML_NCR = 196, | |
23100 | JSMSG_UNDEFINED_XML_NAME = 197, | |
23101 | JSMSG_DUPLICATE_XML_ATTR = 198, | |
23102 | JSMSG_TOO_MANY_LOCALS = 199, | |
23103 | JSMSG_ARRAY_INIT_TOO_BIG = 200, | |
23104 | JSMSG_REGEXP_TOO_COMPLEX = 201, | |
23105 | JSMSG_BUFFER_TOO_SMALL = 202, | |
23106 | JSMSG_BAD_SURROGATE_CHAR = 203, | |
23107 | JSMSG_UTF8_CHAR_TOO_LARGE = 204, | |
23108 | JSMSG_MALFORMED_UTF8_CHAR = 205, | |
23109 | JSMSG_USER_DEFINED_ERROR = 206, | |
23110 | JSMSG_WRONG_CONSTRUCTOR = 207, | |
23111 | JSMSG_BAD_GENERATOR_RETURN = 208, | |
23112 | JSMSG_BAD_ANON_GENERATOR_RETURN = 209, | |
23113 | JSMSG_NAME_AFTER_FOR_PAREN = 210, | |
23114 | JSMSG_IN_AFTER_FOR_NAME = 211, | |
23115 | JSMSG_BAD_TRAP_RETURN_VALUE = 212, | |
23116 | JSMSG_KEYWORD_NOT_NS = 213, | |
23117 | JSMSG_BAD_GENERATOR_YIELD = 214, | |
23118 | JSMSG_BAD_GENERATOR_SYNTAX = 215, | |
23119 | JSMSG_ARRAY_COMP_LEFTSIDE = 216, | |
23120 | JSMSG_NON_XML_FILTER = 217, | |
23121 | JSMSG_EMPTY_ARRAY_REDUCE = 218, | |
23122 | JSMSG_NON_LIST_XML_METHOD = 219, | |
23123 | JSMSG_BAD_DELETE_OPERAND = 220, | |
23124 | JSMSG_BAD_INCOP_OPERAND = 221, | |
23125 | JSMSG_UNEXPECTED_TYPE = 222, | |
23126 | JSMSG_LET_DECL_NOT_IN_BLOCK = 223, | |
23127 | JSMSG_BAD_OBJECT_INIT = 224, | |
23128 | JSMSG_CANT_SET_ARRAY_ATTRS = 225, | |
23129 | JSMSG_EVAL_ARITY = 226, | |
23130 | JSMSG_MISSING_FUN_ARG = 227, | |
23131 | JSMSG_JSON_BAD_PARSE = 228, | |
23132 | JSMSG_JSON_BAD_STRINGIFY = 229, | |
23133 | JSMSG_XDR_CLOSURE_WRAPPER = 230, | |
23134 | JSMSG_NOT_NONNULL_OBJECT = 231, | |
23135 | JSMSG_DEPRECATED_OCTAL = 232, | |
23136 | JSMSG_STRICT_CODE_WITH = 233, | |
23137 | JSMSG_DUPLICATE_PROPERTY = 234, | |
23138 | JSMSG_DEPRECATED_DELETE_OPERAND = 235, | |
23139 | JSMSG_DEPRECATED_ASSIGN = 236, | |
23140 | JSMSG_BAD_BINDING = 237, | |
23141 | JSMSG_INVALID_DESCRIPTOR = 238, | |
23142 | JSMSG_OBJECT_NOT_EXTENSIBLE = 239, | |
23143 | JSMSG_CANT_REDEFINE_PROP = 240, | |
23144 | JSMSG_CANT_APPEND_TO_ARRAY = 241, | |
23145 | JSMSG_CANT_DEFINE_ARRAY_LENGTH = 242, | |
23146 | JSMSG_CANT_DEFINE_ARRAY_INDEX = 243, | |
23147 | JSMSG_TYPED_ARRAY_BAD_INDEX = 244, | |
23148 | JSMSG_TYPED_ARRAY_NEGATIVE_ARG = 245, | |
23149 | JSMSG_TYPED_ARRAY_BAD_ARGS = 246, | |
23150 | JSMSG_CSP_BLOCKED_FUNCTION = 247, | |
23151 | JSMSG_BAD_GET_SET_FIELD = 248, | |
23152 | JSMSG_BAD_PROXY_FIX = 249, | |
23153 | JSMSG_INVALID_EVAL_SCOPE_ARG = 250, | |
23154 | JSMSG_ACCESSOR_WRONG_ARGS = 251, | |
23155 | JSMSG_THROW_TYPE_ERROR = 252, | |
23156 | JSMSG_BAD_TOISOSTRING_PROP = 253, | |
23157 | JSMSG_BAD_PARSE_NODE = 254, | |
23158 | JSMSG_NOT_EXPECTED_TYPE = 255, | |
23159 | JSMSG_CALLER_IS_STRICT = 256, | |
23160 | JSMSG_NEED_DEBUG_MODE = 257, | |
23161 | JSMSG_STRICT_CODE_LET_EXPR_STMT = 258, | |
23162 | JSMSG_CANT_CHANGE_EXTENSIBILITY = 259, | |
23163 | JSMSG_SC_BAD_SERIALIZED_DATA = 260, | |
23164 | JSMSG_SC_UNSUPPORTED_TYPE = 261, | |
23165 | JSMSG_SC_RECURSION = 262, | |
23166 | JSMSG_CANT_WRAP_XML_OBJECT = 263, | |
23167 | JSMSG_BAD_CLONE_VERSION = 264, | |
23168 | JSMSG_CANT_CLONE_OBJECT = 265, | |
23169 | JSMSG_NON_NATIVE_SCOPE = 266, | |
23170 | JSMSG_STRICT_FUNCTION_STATEMENT = 267, | |
23171 | JSMSG_INVALID_FOR_IN_INIT = 268, | |
23172 | JSMSG_CLEARED_SCOPE = 269, | |
23173 | # 3000 "jscntxt.h" 2 | |
23174 | ||
23175 | JSErr_Limit | |
23176 | } JSErrNum; | |
23177 | ||
23178 | extern __attribute__((visibility ("default"))) const JSErrorFormatString * | |
23179 | js_GetErrorMessage(void *userRef, const char *locale, const uintN errorNumber); | |
23180 | ||
23181 | ||
23182 | extern JSBool | |
23183 | js_ReportErrorVA(JSContext *cx, uintN flags, const char *format, va_list ap); | |
23184 | ||
23185 | extern JSBool | |
23186 | js_ReportErrorNumberVA(JSContext *cx, uintN flags, JSErrorCallback callback, | |
23187 | void *userRef, const uintN errorNumber, | |
23188 | JSBool charArgs, va_list ap); | |
23189 | ||
23190 | extern JSBool | |
23191 | js_ExpandErrorArguments(JSContext *cx, JSErrorCallback callback, | |
23192 | void *userRef, const uintN errorNumber, | |
23193 | char **message, JSErrorReport *reportp, | |
23194 | bool charArgs, va_list ap); | |
23195 | ||
23196 | ||
23197 | extern void | |
23198 | js_ReportOutOfMemory(JSContext *cx); | |
23199 | ||
23200 | ||
23201 | ||
23202 | ||
23203 | void | |
23204 | js_ReportOutOfScriptQuota(JSContext *cx); | |
23205 | ||
23206 | extern __attribute__((visibility ("default"))) void | |
23207 | js_ReportOverRecursed(JSContext *cx); | |
23208 | ||
23209 | extern __attribute__((visibility ("default"))) void | |
23210 | js_ReportAllocationOverflow(JSContext *cx); | |
23211 | # 3052 "jscntxt.h" | |
23212 | extern __attribute__((visibility ("default"))) void | |
23213 | js_ReportErrorAgain(JSContext *cx, const char *message, JSErrorReport *report); | |
23214 | ||
23215 | extern void | |
23216 | js_ReportIsNotDefined(JSContext *cx, const char *name); | |
23217 | ||
23218 | ||
23219 | ||
23220 | ||
23221 | extern JSBool | |
23222 | js_ReportIsNullOrUndefined(JSContext *cx, intN spindex, const js::Value &v, | |
23223 | JSString *fallback); | |
23224 | ||
23225 | extern void | |
23226 | js_ReportMissingArg(JSContext *cx, const js::Value &v, uintN arg); | |
23227 | ||
23228 | ||
23229 | ||
23230 | ||
23231 | ||
23232 | ||
23233 | extern JSBool | |
23234 | js_ReportValueErrorFlags(JSContext *cx, uintN flags, const uintN errorNumber, | |
23235 | intN spindex, const js::Value &v, JSString *fallback, | |
23236 | const char *arg1, const char *arg2); | |
23237 | # 3090 "jscntxt.h" | |
23238 | extern JSErrorFormatString js_ErrorFormatString[JSErr_Limit]; | |
23239 | # 3108 "jscntxt.h" | |
23240 | __attribute__((always_inline)) inline void | |
23241 | JSThreadData::triggerOperationCallback(JSRuntime *rt) | |
23242 | { | |
23243 | ||
23244 | ||
23245 | ||
23246 | ||
23247 | ||
23248 | ||
23249 | if (interruptFlags) | |
23250 | return; | |
23251 | PR_AtomicSet((PRInt32 *)(&interruptFlags), (PRInt32)(1)); | |
23252 | ||
23253 | ||
23254 | ||
23255 | if (requestDepth != 0) | |
23256 | PR_AtomicIncrement((PRInt32 *)(&rt->interruptCounter)); | |
23257 | ||
23258 | } | |
23259 | ||
23260 | ||
23261 | ||
23262 | ||
23263 | ||
23264 | extern JSBool | |
23265 | js_InvokeOperationCallback(JSContext *cx); | |
23266 | ||
23267 | extern JSBool | |
23268 | js_HandleExecutionInterrupt(JSContext *cx); | |
23269 | ||
23270 | namespace js { | |
23271 | ||
23272 | ||
23273 | ||
23274 | __attribute__((visibility ("default"))) void | |
23275 | TriggerOperationCallback(JSContext *cx); | |
23276 | ||
23277 | void | |
23278 | TriggerAllOperationCallbacks(JSRuntime *rt); | |
23279 | ||
23280 | } | |
23281 | ||
23282 | extern JSStackFrame * | |
23283 | js_GetScriptedCaller(JSContext *cx, JSStackFrame *fp); | |
23284 | ||
23285 | extern jsbytecode* | |
23286 | js_GetCurrentBytecodePC(JSContext* cx); | |
23287 | ||
23288 | extern | |
23289 | ||
23290 | # 3156 "jscntxt.h" | |
23291 | bool | |
23292 | js_CurrentPCIsInImacro(JSContext *cx); | |
23293 | ||
23294 | namespace js { | |
23295 | ||
23296 | class RegExpStatics; | |
23297 | ||
23298 | extern __attribute__((visibility ("default"))) void | |
23299 | LeaveTrace(JSContext *cx); | |
23300 | ||
23301 | } | |
23302 | ||
23303 | ||
23304 | ||
23305 | ||
23306 | ||
23307 | ||
23308 | ||
23309 | static inline JSStackFrame * | |
23310 | js_GetTopStackFrame(JSContext *cx) | |
23311 | { | |
23312 | js::LeaveTrace(cx); | |
23313 | return cx->maybefp(); | |
23314 | } | |
23315 | ||
23316 | static inline JSBool | |
23317 | js_IsPropertyCacheDisabled(JSContext *cx) | |
23318 | { | |
23319 | return cx->runtime->shapeGen >= js::SHAPE_OVERFLOW_BIT; | |
23320 | } | |
23321 | ||
23322 | static inline uint32 | |
23323 | js_RegenerateShapeForGC(JSRuntime *rt) | |
23324 | { | |
23325 | ((void) 0); | |
23326 | ((void) 0); | |
23327 | ||
23328 | ||
23329 | ||
23330 | ||
23331 | ||
23332 | ||
23333 | uint32 shape = rt->shapeGen; | |
23334 | shape = (shape + 1) | (shape & js::SHAPE_OVERFLOW_BIT); | |
23335 | rt->shapeGen = shape; | |
23336 | return shape; | |
23337 | } | |
23338 | ||
23339 | namespace js { | |
23340 | ||
23341 | inline void * | |
23342 | ContextAllocPolicy::malloc(size_t bytes) | |
23343 | { | |
23344 | return cx->malloc(bytes); | |
23345 | } | |
23346 | ||
23347 | inline void | |
23348 | ContextAllocPolicy::free(void *p) | |
23349 | { | |
23350 | cx->free(p); | |
23351 | } | |
23352 | ||
23353 | inline void * | |
23354 | ContextAllocPolicy::realloc(void *p, size_t bytes) | |
23355 | { | |
23356 | return cx->realloc(p, bytes); | |
23357 | } | |
23358 | ||
23359 | inline void | |
23360 | ContextAllocPolicy::reportAllocOverflow() const | |
23361 | { | |
23362 | js_ReportAllocationOverflow(cx); | |
23363 | } | |
23364 | ||
23365 | template<class T> | |
23366 | class AutoVectorRooter : protected AutoGCRooter | |
23367 | { | |
23368 | public: | |
23369 | explicit AutoVectorRooter(JSContext *cx, ptrdiff_t tag | |
23370 | ) | |
23371 | : AutoGCRooter(cx, tag), vector(cx) | |
23372 | { | |
23373 | do { } while (0); | |
23374 | } | |
23375 | ||
23376 | size_t length() const { return vector.length(); } | |
23377 | ||
23378 | bool append(const T &v) { return vector.append(v); } | |
23379 | ||
23380 | void popBack() { vector.popBack(); } | |
23381 | ||
23382 | bool growBy(size_t inc) { | |
23383 | size_t oldLength = vector.length(); | |
23384 | if (!vector.growByUninitialized(inc)) | |
23385 | return false; | |
23386 | MakeRangeGCSafe(vector.begin() + oldLength, vector.end()); | |
23387 | return true; | |
23388 | } | |
23389 | ||
23390 | bool resize(size_t newLength) { | |
23391 | size_t oldLength = vector.length(); | |
23392 | if (newLength <= oldLength) { | |
23393 | vector.shrinkBy(oldLength - newLength); | |
23394 | return true; | |
23395 | } | |
23396 | if (!vector.growByUninitialized(newLength - oldLength)) | |
23397 | return false; | |
23398 | MakeRangeGCSafe(vector.begin() + oldLength, vector.end()); | |
23399 | return true; | |
23400 | } | |
23401 | ||
23402 | bool reserve(size_t newLength) { | |
23403 | return vector.reserve(newLength); | |
23404 | } | |
23405 | ||
23406 | T &operator[](size_t i) { return vector[i]; } | |
23407 | const T &operator[](size_t i) const { return vector[i]; } | |
23408 | ||
23409 | const T *begin() const { return vector.begin(); } | |
23410 | T *begin() { return vector.begin(); } | |
23411 | ||
23412 | const T *end() const { return vector.end(); } | |
23413 | T *end() { return vector.end(); } | |
23414 | ||
23415 | const T &back() const { return vector.back(); } | |
23416 | ||
23417 | friend void AutoGCRooter::trace(JSTracer *trc); | |
23418 | ||
23419 | private: | |
23420 | Vector<T, 8> vector; | |
23421 | ||
23422 | }; | |
23423 | ||
23424 | class AutoValueVector : public AutoVectorRooter<Value> | |
23425 | { | |
23426 | public: | |
23427 | explicit AutoValueVector(JSContext *cx | |
23428 | ) | |
23429 | : AutoVectorRooter<Value>(cx, VALVECTOR) | |
23430 | { | |
23431 | do { } while (0); | |
23432 | } | |
23433 | ||
23434 | const jsval *jsval_begin() const { return Jsvalify(begin()); } | |
23435 | jsval *jsval_begin() { return Jsvalify(begin()); } | |
23436 | ||
23437 | const jsval *jsval_end() const { return Jsvalify(end()); } | |
23438 | jsval *jsval_end() { return Jsvalify(end()); } | |
23439 | ||
23440 | ||
23441 | }; | |
23442 | ||
23443 | class AutoIdVector : public AutoVectorRooter<jsid> | |
23444 | { | |
23445 | public: | |
23446 | explicit AutoIdVector(JSContext *cx | |
23447 | ) | |
23448 | : AutoVectorRooter<jsid>(cx, IDVECTOR) | |
23449 | { | |
23450 | do { } while (0); | |
23451 | } | |
23452 | ||
23453 | ||
23454 | }; | |
23455 | ||
23456 | class AutoShapeVector : public AutoVectorRooter<const Shape *> | |
23457 | { | |
23458 | public: | |
23459 | explicit AutoShapeVector(JSContext *cx | |
23460 | ) | |
23461 | : AutoVectorRooter<const Shape *>(cx, SHAPEVECTOR) | |
23462 | { | |
23463 | do { } while (0); | |
23464 | } | |
23465 | ||
23466 | ||
23467 | }; | |
23468 | ||
23469 | JSIdArray * | |
23470 | NewIdArray(JSContext *cx, jsint length); | |
23471 | ||
23472 | } | |
23473 | # 57 "jsxml.cpp" 2 | |
23474 | ||
23475 | ||
23476 | ||
23477 | ||
23478 | # 1 "jsnum.h" 1 | |
23479 | # 76 "jsnum.h" | |
23480 | typedef union jsdpun { | |
23481 | struct { | |
23482 | ||
23483 | ||
23484 | ||
23485 | uint32 hi, lo; | |
23486 | ||
23487 | } s; | |
23488 | uint64 u64; | |
23489 | jsdouble d; | |
23490 | } jsdpun; | |
23491 | ||
23492 | static inline int | |
23493 | JSDOUBLE_IS_NaN(jsdouble d) | |
23494 | { | |
23495 | ||
23496 | ||
23497 | ||
23498 | return (sizeof (d) == sizeof (float) ? __isnanf (d) : sizeof (d) == sizeof (double) ? __isnan (d) : __isnanl (d)); | |
23499 | ||
23500 | } | |
23501 | ||
23502 | static inline int | |
23503 | JSDOUBLE_IS_FINITE(jsdouble d) | |
23504 | { | |
23505 | ||
23506 | ||
23507 | ||
23508 | ||
23509 | ||
23510 | return finite(d); | |
23511 | ||
23512 | } | |
23513 | ||
23514 | static inline int | |
23515 | JSDOUBLE_IS_INFINITE(jsdouble d) | |
23516 | { | |
23517 | ||
23518 | ||
23519 | ||
23520 | ||
23521 | ||
23522 | ||
23523 | return (sizeof (d) == sizeof (float) ? __isinff (d) : sizeof (d) == sizeof (double) ? __isinf (d) : __isinfl (d)); | |
23524 | ||
23525 | } | |
23526 | ||
23527 | ||
23528 | ||
23529 | ||
23530 | ||
23531 | ||
23532 | ||
23533 | static inline | |
23534 | ||
23535 | # 129 "jsnum.h" | |
23536 | bool | |
23537 | JSDOUBLE_IS_NEG(jsdouble d) | |
23538 | { | |
23539 | ||
23540 | ||
23541 | ||
23542 | ||
23543 | ||
23544 | return (sizeof (d) == sizeof (float) ? __signbitf (d) : sizeof (d) == sizeof (double) ? __signbit (d) : __signbitl (d)); | |
23545 | ||
23546 | } | |
23547 | ||
23548 | static inline uint32 | |
23549 | JS_HASH_DOUBLE(jsdouble d) | |
23550 | { | |
23551 | jsdpun u; | |
23552 | u.d = d; | |
23553 | return u.s.lo ^ u.s.hi; | |
23554 | } | |
23555 | # 158 "jsnum.h" | |
23556 | extern jsdouble js_NaN; | |
23557 | extern jsdouble js_PositiveInfinity; | |
23558 | extern jsdouble js_NegativeInfinity; | |
23559 | ||
23560 | ||
23561 | extern JSBool | |
23562 | js_InitRuntimeNumberState(JSContext *cx); | |
23563 | ||
23564 | extern void | |
23565 | js_FinishRuntimeNumberState(JSContext *cx); | |
23566 | ||
23567 | ||
23568 | extern js::Class js_NumberClass; | |
23569 | ||
23570 | inline | |
23571 | ||
23572 | # 172 "jsnum.h" | |
23573 | bool | |
23574 | JSObject::isNumber() const | |
23575 | { | |
23576 | return getClass() == &js_NumberClass; | |
23577 | } | |
23578 | ||
23579 | extern JSObject * | |
23580 | js_InitNumberClass(JSContext *cx, JSObject *obj); | |
23581 | ||
23582 | ||
23583 | ||
23584 | ||
23585 | extern const char js_Infinity_str[]; | |
23586 | extern const char js_NaN_str[]; | |
23587 | extern const char js_isNaN_str[]; | |
23588 | extern const char js_isFinite_str[]; | |
23589 | extern const char js_parseFloat_str[]; | |
23590 | extern const char js_parseInt_str[]; | |
23591 | ||
23592 | extern JSString * | |
23593 | js_IntToString(JSContext *cx, jsint i); | |
23594 | ||
23595 | ||
23596 | ||
23597 | ||
23598 | ||
23599 | ||
23600 | extern JSString * | |
23601 | js_NumberToString(JSContext *cx, jsdouble d); | |
23602 | ||
23603 | namespace js { | |
23604 | ||
23605 | ||
23606 | ||
23607 | ||
23608 | ||
23609 | extern bool | |
23610 | NumberValueToStringBuffer(JSContext *cx, const Value &v, StringBuffer &sb); | |
23611 | ||
23612 | ||
23613 | extern JSFlatString * | |
23614 | NumberToString(JSContext *cx, jsdouble d); | |
23615 | ||
23616 | ||
23617 | ||
23618 | ||
23619 | ||
23620 | ||
23621 | struct ToCStringBuf | |
23622 | { | |
23623 | ||
23624 | ||
23625 | ||
23626 | ||
23627 | ||
23628 | static const size_t sbufSize = 34; | |
23629 | char sbuf[sbufSize]; | |
23630 | char *dbuf; | |
23631 | ||
23632 | ToCStringBuf(); | |
23633 | ~ToCStringBuf(); | |
23634 | }; | |
23635 | ||
23636 | ||
23637 | ||
23638 | ||
23639 | ||
23640 | ||
23641 | ||
23642 | extern char * | |
23643 | NumberToCString(JSContext *cx, ToCStringBuf *cbuf, jsdouble d, jsint base = 10); | |
23644 | ||
23645 | ||
23646 | ||
23647 | ||
23648 | ||
23649 | const double DOUBLE_INTEGRAL_PRECISION_LIMIT = uint64(1) << 53; | |
23650 | # 262 "jsnum.h" | |
23651 | extern | |
23652 | ||
23653 | # 262 "jsnum.h" | |
23654 | bool | |
23655 | GetPrefixInteger(JSContext *cx, const jschar *start, const jschar *end, int base, | |
23656 | const jschar **endp, jsdouble *dp); | |
23657 | ||
23658 | ||
23659 | ||
23660 | ||
23661 | ||
23662 | __attribute__((always_inline)) inline | |
23663 | ||
23664 | # 270 "jsnum.h" | |
23665 | bool | |
23666 | ValueToNumber(JSContext *cx, const js::Value &v, double *out) | |
23667 | { | |
23668 | if (v.isNumber()) { | |
23669 | *out = v.toNumber(); | |
23670 | return true; | |
23671 | } | |
23672 | extern bool ValueToNumberSlow(JSContext *, js::Value, double *); | |
23673 | return ValueToNumberSlow(cx, v, out); | |
23674 | } | |
23675 | ||
23676 | ||
23677 | __attribute__((always_inline)) inline | |
23678 | ||
23679 | # 282 "jsnum.h" | |
23680 | bool | |
23681 | ValueToNumber(JSContext *cx, js::Value *vp) | |
23682 | { | |
23683 | if (vp->isNumber()) | |
23684 | return true; | |
23685 | double d; | |
23686 | extern bool ValueToNumberSlow(JSContext *, js::Value, double *); | |
23687 | if (!ValueToNumberSlow(cx, *vp, &d)) | |
23688 | return false; | |
23689 | vp->setNumber(d); | |
23690 | return true; | |
23691 | } | |
23692 | ||
23693 | ||
23694 | ||
23695 | ||
23696 | ||
23697 | ||
23698 | __attribute__((always_inline)) inline | |
23699 | ||
23700 | # 300 "jsnum.h" | |
23701 | bool | |
23702 | ValueToECMAInt32(JSContext *cx, const js::Value &v, int32_t *out) | |
23703 | { | |
23704 | if (v.isInt32()) { | |
23705 | *out = v.toInt32(); | |
23706 | return true; | |
23707 | } | |
23708 | extern bool ValueToECMAInt32Slow(JSContext *, const js::Value &, int32_t *); | |
23709 | return ValueToECMAInt32Slow(cx, v, out); | |
23710 | } | |
23711 | ||
23712 | __attribute__((always_inline)) inline | |
23713 | ||
23714 | # 311 "jsnum.h" | |
23715 | bool | |
23716 | ValueToECMAUint32(JSContext *cx, const js::Value &v, uint32_t *out) | |
23717 | { | |
23718 | if (v.isInt32()) { | |
23719 | *out = (uint32_t)v.toInt32(); | |
23720 | return true; | |
23721 | } | |
23722 | extern bool ValueToECMAUint32Slow(JSContext *, const js::Value &, uint32_t *); | |
23723 | return ValueToECMAUint32Slow(cx, v, out); | |
23724 | } | |
23725 | ||
23726 | ||
23727 | ||
23728 | ||
23729 | ||
23730 | ||
23731 | __attribute__((always_inline)) inline | |
23732 | ||
23733 | # 327 "jsnum.h" | |
23734 | bool | |
23735 | ValueToInt32(JSContext *cx, const js::Value &v, int32_t *out) | |
23736 | { | |
23737 | if (v.isInt32()) { | |
23738 | *out = v.toInt32(); | |
23739 | return true; | |
23740 | } | |
23741 | extern bool ValueToInt32Slow(JSContext *, const js::Value &, int32_t *); | |
23742 | return ValueToInt32Slow(cx, v, out); | |
23743 | } | |
23744 | ||
23745 | ||
23746 | ||
23747 | ||
23748 | ||
23749 | ||
23750 | __attribute__((always_inline)) inline | |
23751 | ||
23752 | # 343 "jsnum.h" | |
23753 | bool | |
23754 | ValueToUint16(JSContext *cx, const js::Value &v, uint16_t *out) | |
23755 | { | |
23756 | if (v.isInt32()) { | |
23757 | *out = (uint16_t)v.toInt32(); | |
23758 | return true; | |
23759 | } | |
23760 | extern bool ValueToUint16Slow(JSContext *, const js::Value &, uint16_t *); | |
23761 | return ValueToUint16Slow(cx, v, out); | |
23762 | } | |
23763 | ||
23764 | } | |
23765 | # 369 "jsnum.h" | |
23766 | static inline int32 | |
23767 | js_DoubleToECMAInt32(jsdouble d) | |
23768 | { | |
23769 | # 567 "jsnum.h" | |
23770 | int32 i; | |
23771 | jsdouble two32, two31; | |
23772 | ||
23773 | if (!JSDOUBLE_IS_FINITE(d)) | |
23774 | return 0; | |
23775 | ||
23776 | i = (int32) d; | |
23777 | if ((jsdouble) i == d) | |
23778 | return i; | |
23779 | ||
23780 | two32 = 4294967296.0; | |
23781 | two31 = 2147483648.0; | |
23782 | d = fmod(d, two32); | |
23783 | d = (d >= 0) ? floor(d) : ceil(d) + two32; | |
23784 | return (int32) (d >= two31 ? d - two32 : d); | |
23785 | ||
23786 | } | |
23787 | ||
23788 | uint32 | |
23789 | js_DoubleToECMAUint32(jsdouble d); | |
23790 | ||
23791 | ||
23792 | ||
23793 | ||
23794 | ||
23795 | static inline jsdouble | |
23796 | js_DoubleToInteger(jsdouble d) | |
23797 | { | |
23798 | if (d == 0) | |
23799 | return d; | |
23800 | ||
23801 | if (!JSDOUBLE_IS_FINITE(d)) { | |
23802 | if (JSDOUBLE_IS_NaN(d)) | |
23803 | return 0; | |
23804 | return d; | |
23805 | } | |
23806 | ||
23807 | JSBool neg = (d < 0); | |
23808 | d = floor(neg ? -d : d); | |
23809 | ||
23810 | return neg ? -d : d; | |
23811 | } | |
23812 | # 620 "jsnum.h" | |
23813 | extern JSBool | |
23814 | js_strtod(JSContext *cx, const jschar *s, const jschar *send, | |
23815 | const jschar **ep, jsdouble *dp); | |
23816 | ||
23817 | extern JSBool | |
23818 | js_num_valueOf(JSContext *cx, uintN argc, js::Value *vp); | |
23819 | ||
23820 | namespace js { | |
23821 | ||
23822 | static __attribute__((always_inline)) inline | |
23823 | ||
23824 | # 629 "jsnum.h" | |
23825 | bool | |
23826 | ValueFitsInInt32(const Value &v, int32_t *pi) | |
23827 | { | |
23828 | if (v.isInt32()) { | |
23829 | *pi = v.toInt32(); | |
23830 | return true; | |
23831 | } | |
23832 | return v.isDouble() && JSDOUBLE_IS_INT32(v.toDouble(), pi); | |
23833 | } | |
23834 | ||
23835 | template<typename T> struct NumberTraits { }; | |
23836 | template<> struct NumberTraits<int32> { | |
23837 | static __attribute__((always_inline)) inline int32 NaN() { return 0; } | |
23838 | static __attribute__((always_inline)) inline int32 toSelfType(int32 i) { return i; } | |
23839 | static __attribute__((always_inline)) inline int32 toSelfType(jsdouble d) { return js_DoubleToECMAUint32(d); } | |
23840 | }; | |
23841 | template<> struct NumberTraits<jsdouble> { | |
23842 | static __attribute__((always_inline)) inline jsdouble NaN() { return js_NaN; } | |
23843 | static __attribute__((always_inline)) inline jsdouble toSelfType(int32 i) { return i; } | |
23844 | static __attribute__((always_inline)) inline jsdouble toSelfType(jsdouble d) { return d; } | |
23845 | }; | |
23846 | ||
23847 | template<typename T> | |
23848 | static __attribute__((always_inline)) inline | |
23849 | ||
23850 | # 652 "jsnum.h" | |
23851 | bool | |
23852 | StringToNumberType(JSContext *cx, JSString *str, T *result) | |
23853 | { | |
23854 | size_t length = str->length(); | |
23855 | const jschar *chars = str->getChars(__null); | |
23856 | if (!chars) | |
23857 | return false; | |
23858 | ||
23859 | if (length == 1) { | |
23860 | jschar c = chars[0]; | |
23861 | if ('0' <= c && c <= '9') { | |
23862 | *result = NumberTraits<T>::toSelfType(T(c - '0')); | |
23863 | return true; | |
23864 | } | |
23865 | if (JS_ISSPACE(c)) { | |
23866 | *result = NumberTraits<T>::toSelfType(T(0)); | |
23867 | return true; | |
23868 | } | |
23869 | *result = NumberTraits<T>::NaN(); | |
23870 | return true; | |
23871 | } | |
23872 | ||
23873 | const jschar *bp = chars; | |
23874 | const jschar *end = chars + length; | |
23875 | bp = js_SkipWhiteSpace(bp, end); | |
23876 | ||
23877 | ||
23878 | if (end - bp >= 2 && bp[0] == '0' && (bp[1] == 'x' || bp[1] == 'X')) { | |
23879 | ||
23880 | const jschar *endptr; | |
23881 | double d; | |
23882 | if (!GetPrefixInteger(cx, bp + 2, end, 16, &endptr, &d) || | |
23883 | js_SkipWhiteSpace(endptr, end) != end) { | |
23884 | *result = NumberTraits<T>::NaN(); | |
23885 | return true; | |
23886 | } | |
23887 | *result = NumberTraits<T>::toSelfType(d); | |
23888 | return true; | |
23889 | } | |
23890 | # 699 "jsnum.h" | |
23891 | const jschar *ep; | |
23892 | double d; | |
23893 | if (!js_strtod(cx, bp, end, &ep, &d) || js_SkipWhiteSpace(ep, end) != end) { | |
23894 | *result = NumberTraits<T>::NaN(); | |
23895 | return true; | |
23896 | } | |
23897 | *result = NumberTraits<T>::toSelfType(d); | |
23898 | return true; | |
23899 | } | |
23900 | } | |
23901 | # 62 "jsxml.cpp" 2 | |
23902 | ||
23903 | ||
23904 | # 1 "jsparse.h" 1 | |
23905 | # 46 "jsparse.h" | |
23906 | # 1 "jsversion.h" 1 | |
23907 | # 47 "jsparse.h" 2 | |
23908 | ||
23909 | ||
23910 | ||
23911 | # 1 "jsscan.h" 1 | |
23912 | # 45 "jsscan.h" | |
23913 | # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stddef.h" 1 3 4 | |
23914 | # 46 "jsscan.h" 2 | |
23915 | ||
23916 | ||
23917 | # 1 "jsversion.h" 1 | |
23918 | # 49 "jsscan.h" 2 | |
23919 | ||
23920 | ||
23921 | ||
23922 | ||
23923 | ||
23924 | ||
23925 | ||
23926 | # 1 "jskeyword.tbl" 1 | |
23927 | # 45 "jskeyword.tbl" | |
23928 | extern const char js_false_str[]; | |
23929 | extern const char js_true_str[]; | |
23930 | extern const char js_null_str[]; | |
23931 | ||
23932 | ||
23933 | extern const char js_break_str[]; | |
23934 | extern const char js_case_str[]; | |
23935 | extern const char js_catch_str[]; | |
23936 | extern const char js_continue_str[]; | |
23937 | extern const char js_debugger_str[]; | |
23938 | extern const char js_default_str[]; | |
23939 | extern const char js_delete_str[]; | |
23940 | extern const char js_do_str[]; | |
23941 | extern const char js_else_str[]; | |
23942 | extern const char js_finally_str[]; | |
23943 | extern const char js_for_str[]; | |
23944 | extern const char js_function_str[]; | |
23945 | extern const char js_if_str[]; | |
23946 | extern const char js_in_str[]; | |
23947 | extern const char js_instanceof_str[]; | |
23948 | extern const char js_new_str[]; | |
23949 | extern const char js_return_str[]; | |
23950 | extern const char js_switch_str[]; | |
23951 | extern const char js_this_str[]; | |
23952 | extern const char js_throw_str[]; | |
23953 | extern const char js_try_str[]; | |
23954 | extern const char js_typeof_str[]; | |
23955 | extern const char js_var_str[]; | |
23956 | extern const char js_void_str[]; | |
23957 | extern const char js_while_str[]; | |
23958 | extern const char js_with_str[]; | |
23959 | ||
23960 | ||
23961 | ||
23962 | ||
23963 | ||
23964 | extern const char js_class_str[]; | |
23965 | extern const char js_enum_str[]; | |
23966 | extern const char js_export_str[]; | |
23967 | extern const char js_extends_str[]; | |
23968 | extern const char js_import_str[]; | |
23969 | extern const char js_super_str[]; | |
23970 | ||
23971 | ||
23972 | ||
23973 | ||
23974 | ||
23975 | ||
23976 | extern const char js_const_str[]; | |
23977 | ||
23978 | ||
23979 | ||
23980 | ||
23981 | extern const char js_let_str[]; | |
23982 | ||
23983 | ||
23984 | ||
23985 | ||
23986 | extern const char js_yield_str[]; | |
23987 | ||
23988 | ||
23989 | ||
23990 | ||
23991 | ||
23992 | extern const char js_implements_str[]; | |
23993 | extern const char js_interface_str[]; | |
23994 | extern const char js_package_str[]; | |
23995 | extern const char js_private_str[]; | |
23996 | extern const char js_protected_str[]; | |
23997 | extern const char js_public_str[]; | |
23998 | extern const char js_static_str[]; | |
23999 | # 57 "jsscan.h" 2 | |
24000 | ||
24001 | ||
24002 | namespace js { | |
24003 | ||
24004 | enum TokenKind { | |
24005 | TOK_ERROR = -1, | |
24006 | TOK_EOF = 0, | |
24007 | TOK_EOL = 1, | |
24008 | TOK_SEMI = 2, | |
24009 | TOK_COMMA = 3, | |
24010 | TOK_ASSIGN = 4, | |
24011 | TOK_HOOK = 5, TOK_COLON = 6, | |
24012 | TOK_OR = 7, | |
24013 | TOK_AND = 8, | |
24014 | TOK_BITOR = 9, | |
24015 | TOK_BITXOR = 10, | |
24016 | TOK_BITAND = 11, | |
24017 | TOK_EQOP = 12, | |
24018 | TOK_RELOP = 13, | |
24019 | TOK_SHOP = 14, | |
24020 | TOK_PLUS = 15, | |
24021 | TOK_MINUS = 16, | |
24022 | TOK_STAR = 17, TOK_DIVOP = 18, | |
24023 | TOK_UNARYOP = 19, | |
24024 | TOK_INC = 20, TOK_DEC = 21, | |
24025 | TOK_DOT = 22, | |
24026 | TOK_LB = 23, TOK_RB = 24, | |
24027 | TOK_LC = 25, TOK_RC = 26, | |
24028 | TOK_LP = 27, TOK_RP = 28, | |
24029 | TOK_NAME = 29, | |
24030 | TOK_NUMBER = 30, | |
24031 | TOK_STRING = 31, | |
24032 | TOK_REGEXP = 32, | |
24033 | TOK_PRIMARY = 33, | |
24034 | TOK_FUNCTION = 34, | |
24035 | TOK_IF = 35, | |
24036 | TOK_ELSE = 36, | |
24037 | TOK_SWITCH = 37, | |
24038 | TOK_CASE = 38, | |
24039 | TOK_DEFAULT = 39, | |
24040 | TOK_WHILE = 40, | |
24041 | TOK_DO = 41, | |
24042 | TOK_FOR = 42, | |
24043 | TOK_BREAK = 43, | |
24044 | TOK_CONTINUE = 44, | |
24045 | TOK_IN = 45, | |
24046 | TOK_VAR = 46, | |
24047 | TOK_WITH = 47, | |
24048 | TOK_RETURN = 48, | |
24049 | TOK_NEW = 49, | |
24050 | TOK_DELETE = 50, | |
24051 | TOK_DEFSHARP = 51, | |
24052 | TOK_USESHARP = 52, | |
24053 | TOK_TRY = 53, | |
24054 | TOK_CATCH = 54, | |
24055 | TOK_FINALLY = 55, | |
24056 | TOK_THROW = 56, | |
24057 | TOK_INSTANCEOF = 57, | |
24058 | TOK_DEBUGGER = 58, | |
24059 | TOK_XMLSTAGO = 59, | |
24060 | TOK_XMLETAGO = 60, | |
24061 | TOK_XMLPTAGC = 61, | |
24062 | TOK_XMLTAGC = 62, | |
24063 | TOK_XMLNAME = 63, | |
24064 | TOK_XMLATTR = 64, | |
24065 | TOK_XMLSPACE = 65, | |
24066 | TOK_XMLTEXT = 66, | |
24067 | TOK_XMLCOMMENT = 67, | |
24068 | TOK_XMLCDATA = 68, | |
24069 | TOK_XMLPI = 69, | |
24070 | TOK_AT = 70, | |
24071 | TOK_DBLCOLON = 71, | |
24072 | TOK_ANYNAME = 72, | |
24073 | TOK_DBLDOT = 73, | |
24074 | TOK_FILTER = 74, | |
24075 | TOK_XMLELEM = 75, | |
24076 | TOK_XMLLIST = 76, | |
24077 | TOK_YIELD = 77, | |
24078 | TOK_ARRAYCOMP = 78, | |
24079 | TOK_ARRAYPUSH = 79, | |
24080 | TOK_LEXICALSCOPE = 80, | |
24081 | TOK_LET = 81, | |
24082 | TOK_SEQ = 82, | |
24083 | ||
24084 | TOK_FORHEAD = 83, | |
24085 | TOK_ARGSBODY = 84, | |
24086 | TOK_UPVARS = 85, | |
24087 | ||
24088 | ||
24089 | TOK_RESERVED, | |
24090 | TOK_STRICT_RESERVED, | |
24091 | TOK_LIMIT | |
24092 | }; | |
24093 | ||
24094 | static inline | |
24095 | ||
24096 | # 151 "jsscan.h" | |
24097 | bool | |
24098 | TokenKindIsXML(TokenKind tt) | |
24099 | { | |
24100 | return tt == TOK_AT || tt == TOK_DBLCOLON || tt == TOK_ANYNAME; | |
24101 | } | |
24102 | ||
24103 | static inline | |
24104 | ||
24105 | # 157 "jsscan.h" | |
24106 | bool | |
24107 | TreeTypeIsXML(TokenKind tt) | |
24108 | { | |
24109 | return tt == TOK_XMLCOMMENT || tt == TOK_XMLCDATA || tt == TOK_XMLPI || | |
24110 | tt == TOK_XMLELEM || tt == TOK_XMLLIST; | |
24111 | } | |
24112 | ||
24113 | static inline | |
24114 | ||
24115 | # 164 "jsscan.h" | |
24116 | bool | |
24117 | TokenKindIsDecl(TokenKind tt) | |
24118 | { | |
24119 | ||
24120 | return tt == TOK_VAR || tt == TOK_LET; | |
24121 | ||
24122 | ||
24123 | ||
24124 | } | |
24125 | ||
24126 | struct TokenPtr { | |
24127 | uint32 index; | |
24128 | uint32 lineno; | |
24129 | ||
24130 | bool operator==(const TokenPtr& bptr) { | |
24131 | return index == bptr.index && lineno == bptr.lineno; | |
24132 | } | |
24133 | ||
24134 | bool operator!=(const TokenPtr& bptr) { | |
24135 | return index != bptr.index || lineno != bptr.lineno; | |
24136 | } | |
24137 | ||
24138 | bool operator <(const TokenPtr& bptr) { | |
24139 | return lineno < bptr.lineno || | |
24140 | (lineno == bptr.lineno && index < bptr.index); | |
24141 | } | |
24142 | ||
24143 | bool operator <=(const TokenPtr& bptr) { | |
24144 | return lineno < bptr.lineno || | |
24145 | (lineno == bptr.lineno && index <= bptr.index); | |
24146 | } | |
24147 | ||
24148 | bool operator >(const TokenPtr& bptr) { | |
24149 | return !(*this <= bptr); | |
24150 | } | |
24151 | ||
24152 | bool operator >=(const TokenPtr& bptr) { | |
24153 | return !(*this < bptr); | |
24154 | } | |
24155 | }; | |
24156 | ||
24157 | struct TokenPos { | |
24158 | TokenPtr begin; | |
24159 | TokenPtr end; | |
24160 | ||
24161 | bool operator==(const TokenPos& bpos) { | |
24162 | return begin == bpos.begin && end == bpos.end; | |
24163 | } | |
24164 | ||
24165 | bool operator!=(const TokenPos& bpos) { | |
24166 | return begin != bpos.begin || end != bpos.end; | |
24167 | } | |
24168 | ||
24169 | bool operator <(const TokenPos& bpos) { | |
24170 | return begin < bpos.begin; | |
24171 | } | |
24172 | ||
24173 | bool operator <=(const TokenPos& bpos) { | |
24174 | return begin <= bpos.begin; | |
24175 | } | |
24176 | ||
24177 | bool operator >(const TokenPos& bpos) { | |
24178 | return !(*this <= bpos); | |
24179 | } | |
24180 | ||
24181 | bool operator >=(const TokenPos& bpos) { | |
24182 | return !(*this < bpos); | |
24183 | } | |
24184 | }; | |
24185 | ||
24186 | struct Token { | |
24187 | TokenKind type; | |
24188 | TokenPos pos; | |
24189 | jschar *ptr; | |
24190 | union { | |
24191 | struct { | |
24192 | JSOp op; | |
24193 | JSAtom *atom; | |
24194 | } s; | |
24195 | uintN reflags; | |
24196 | ||
24197 | struct { | |
24198 | JSAtom *atom2; | |
24199 | JSAtom *atom; | |
24200 | } p; | |
24201 | jsdouble dval; | |
24202 | } u; | |
24203 | }; | |
24204 | ||
24205 | enum TokenStreamFlags | |
24206 | { | |
24207 | TSF_ERROR = 0x01, | |
24208 | TSF_EOF = 0x02, | |
24209 | TSF_NEWLINES = 0x04, | |
24210 | TSF_OPERAND = 0x08, | |
24211 | TSF_UNEXPECTED_EOF = 0x10, | |
24212 | TSF_KEYWORD_IS_NAME = 0x20, | |
24213 | TSF_STRICT_MODE_CODE = 0x40, | |
24214 | TSF_DIRTYLINE = 0x80, | |
24215 | TSF_OWNFILENAME = 0x100, | |
24216 | TSF_XMLTAGMODE = 0x200, | |
24217 | TSF_XMLTEXTMODE = 0x400, | |
24218 | TSF_XMLONLYMODE = 0x800, | |
24219 | TSF_OCTAL_CHAR = 0x1000, | |
24220 | # 288 "jsscan.h" | |
24221 | TSF_IN_HTML_COMMENT = 0x2000 | |
24222 | }; | |
24223 | ||
24224 | ||
24225 | ||
24226 | ||
24227 | ||
24228 | ||
24229 | ||
24230 | class TokenStream | |
24231 | { | |
24232 | static const size_t ntokens = 4; | |
24233 | ||
24234 | static const uintN ntokensMask = ntokens - 1; | |
24235 | ||
24236 | public: | |
24237 | typedef Vector<jschar, 32> CharBuffer; | |
24238 | # 316 "jsscan.h" | |
24239 | TokenStream(JSContext *); | |
24240 | ||
24241 | ||
24242 | ||
24243 | ||
24244 | ||
24245 | bool init(const jschar *base, size_t length, const char *filename, uintN lineno, | |
24246 | JSVersion version); | |
24247 | void close(); | |
24248 | ~TokenStream() {} | |
24249 | ||
24250 | ||
24251 | JSContext *getContext() const { return cx; } | |
24252 | bool onCurrentLine(const TokenPos &pos) const { return lineno == pos.end.lineno; } | |
24253 | const Token ¤tToken() const { return tokens[cursor]; } | |
24254 | const CharBuffer &getTokenbuf() const { return tokenbuf; } | |
24255 | const char *getFilename() const { return filename; } | |
24256 | uintN getLineno() const { return lineno; } | |
24257 | ||
24258 | JSVersion versionNumber() const { return VersionNumber(version); } | |
24259 | JSVersion versionWithFlags() const { return version; } | |
24260 | bool hasAnonFunFix() const { return VersionHasAnonFunFix(version); } | |
24261 | bool hasXML() const { return xml || VersionShouldParseXML(versionNumber()); } | |
24262 | void setXML(bool enabled) { xml = enabled; } | |
24263 | ||
24264 | ||
24265 | void setStrictMode(bool enabled = true) { setFlag(enabled, TSF_STRICT_MODE_CODE); } | |
24266 | void setXMLTagMode(bool enabled = true) { setFlag(enabled, TSF_XMLTAGMODE); } | |
24267 | void setXMLOnlyMode(bool enabled = true) { setFlag(enabled, TSF_XMLONLYMODE); } | |
24268 | void setUnexpectedEOF(bool enabled = true) { setFlag(enabled, TSF_UNEXPECTED_EOF); } | |
24269 | void setOctalCharacterEscape(bool enabled = true) { setFlag(enabled, TSF_OCTAL_CHAR); } | |
24270 | ||
24271 | bool isStrictMode() { return !!(flags & TSF_STRICT_MODE_CODE); } | |
24272 | bool isXMLTagMode() { return !!(flags & TSF_XMLTAGMODE); } | |
24273 | bool isXMLOnlyMode() { return !!(flags & TSF_XMLONLYMODE); } | |
24274 | bool isUnexpectedEOF() { return !!(flags & TSF_UNEXPECTED_EOF); } | |
24275 | bool isEOF() const { return !!(flags & TSF_EOF); } | |
24276 | bool isError() const { return !!(flags & TSF_ERROR); } | |
24277 | bool hasOctalCharacterEscape() const { return flags & TSF_OCTAL_CHAR; } | |
24278 | ||
24279 | ||
24280 | bool reportCompileErrorNumberVA(JSParseNode *pn, uintN flags, uintN errorNumber, va_list ap); | |
24281 | void mungeCurrentToken(TokenKind newKind) { tokens[cursor].type = newKind; } | |
24282 | void mungeCurrentToken(JSOp newOp) { tokens[cursor].u.s.op = newOp; } | |
24283 | void mungeCurrentToken(TokenKind newKind, JSOp newOp) { | |
24284 | mungeCurrentToken(newKind); | |
24285 | mungeCurrentToken(newOp); | |
24286 | } | |
24287 | ||
24288 | private: | |
24289 | static JSAtom *atomize(JSContext *cx, CharBuffer &cb); | |
24290 | ||
24291 | ||
24292 | ||
24293 | ||
24294 | ||
24295 | class Flagger { | |
24296 | TokenStream * const parent; | |
24297 | uintN flags; | |
24298 | public: | |
24299 | Flagger(TokenStream *parent, uintN withFlags) : parent(parent), flags(withFlags) { | |
24300 | parent->flags |= flags; | |
24301 | } | |
24302 | ||
24303 | ~Flagger() { parent->flags &= ~flags; } | |
24304 | }; | |
24305 | friend class Flagger; | |
24306 | ||
24307 | void setFlag(bool enabled, TokenStreamFlags flag) { | |
24308 | if (enabled) | |
24309 | flags |= flag; | |
24310 | else | |
24311 | flags &= ~flag; | |
24312 | } | |
24313 | ||
24314 | public: | |
24315 | ||
24316 | ||
24317 | ||
24318 | ||
24319 | TokenKind getToken() { | |
24320 | ||
24321 | while (lookahead != 0) { | |
24322 | ((void) 0); | |
24323 | lookahead--; | |
24324 | cursor = (cursor + 1) & ntokensMask; | |
24325 | TokenKind tt = currentToken().type; | |
24326 | ((void) 0); | |
24327 | if (tt != TOK_EOL) | |
24328 | return tt; | |
24329 | } | |
24330 | ||
24331 | ||
24332 | if (flags & TSF_ERROR) | |
24333 | return TOK_ERROR; | |
24334 | ||
24335 | return getTokenInternal(); | |
24336 | } | |
24337 | ||
24338 | ||
24339 | TokenKind getToken(uintN withFlags) { | |
24340 | Flagger flagger(this, withFlags); | |
24341 | return getToken(); | |
24342 | } | |
24343 | ||
24344 | ||
24345 | ||
24346 | ||
24347 | void ungetToken() { | |
24348 | ((void) 0); | |
24349 | lookahead++; | |
24350 | cursor = (cursor - 1) & ntokensMask; | |
24351 | } | |
24352 | ||
24353 | TokenKind peekToken(uintN withFlags = 0) { | |
24354 | Flagger flagger(this, withFlags); | |
24355 | if (lookahead != 0) { | |
24356 | ((void) 0); | |
24357 | return tokens[(cursor + lookahead) & ntokensMask].type; | |
24358 | } | |
24359 | TokenKind tt = getToken(); | |
24360 | ungetToken(); | |
24361 | return tt; | |
24362 | } | |
24363 | ||
24364 | TokenKind peekTokenSameLine(uintN withFlags = 0) { | |
24365 | Flagger flagger(this, withFlags); | |
24366 | if (!onCurrentLine(currentToken().pos)) | |
24367 | return TOK_EOL; | |
24368 | TokenKind tt = peekToken(TSF_NEWLINES); | |
24369 | return tt; | |
24370 | } | |
24371 | ||
24372 | ||
24373 | ||
24374 | ||
24375 | JSBool matchToken(TokenKind tt, uintN withFlags = 0) { | |
24376 | Flagger flagger(this, withFlags); | |
24377 | if (getToken() == tt) | |
24378 | return (JSIntn)1; | |
24379 | ungetToken(); | |
24380 | return (JSIntn)0; | |
24381 | } | |
24382 | ||
24383 | private: | |
24384 | typedef struct TokenBuf { | |
24385 | jschar *base; | |
24386 | jschar *limit; | |
24387 | jschar *ptr; | |
24388 | } TokenBuf; | |
24389 | ||
24390 | TokenKind getTokenInternal(); | |
24391 | ||
24392 | int32 getChar(); | |
24393 | int32 getCharIgnoreEOL(); | |
24394 | void ungetChar(int32 c); | |
24395 | void ungetCharIgnoreEOL(int32 c); | |
24396 | Token *newToken(ptrdiff_t adjust); | |
24397 | bool peekUnicodeEscape(int32 *c); | |
24398 | bool matchUnicodeEscapeIdStart(int32 *c); | |
24399 | bool matchUnicodeEscapeIdent(int32 *c); | |
24400 | JSBool peekChars(intN n, jschar *cp); | |
24401 | JSBool getXMLEntity(); | |
24402 | jschar *findEOL(); | |
24403 | ||
24404 | JSBool matchChar(int32 expect) { | |
24405 | int32 c = getChar(); | |
24406 | if (c == expect) | |
24407 | return (JSIntn)1; | |
24408 | ungetChar(c); | |
24409 | return (JSIntn)0; | |
24410 | } | |
24411 | ||
24412 | int32 peekChar() { | |
24413 | int32 c = getChar(); | |
24414 | ungetChar(c); | |
24415 | return c; | |
24416 | } | |
24417 | ||
24418 | void skipChars(intN n) { | |
24419 | while (--n >= 0) | |
24420 | getChar(); | |
24421 | } | |
24422 | ||
24423 | JSContext * const cx; | |
24424 | Token tokens[ntokens]; | |
24425 | uintN cursor; | |
24426 | uintN lookahead; | |
24427 | uintN lineno; | |
24428 | uintN flags; | |
24429 | jschar *linebase; | |
24430 | jschar *prevLinebase; | |
24431 | TokenBuf userbuf; | |
24432 | const char *filename; | |
24433 | JSSourceHandler listener; | |
24434 | void *listenerData; | |
24435 | void *listenerTSData; | |
24436 | CharBuffer tokenbuf; | |
24437 | bool maybeEOL[256]; | |
24438 | bool maybeStrSpecial[256]; | |
24439 | JSVersion version; | |
24440 | bool xml; | |
24441 | }; | |
24442 | ||
24443 | } | |
24444 | ||
24445 | ||
24446 | ||
24447 | ||
24448 | ||
24449 | extern void | |
24450 | js_CloseTokenStream(JSContext *cx, js::TokenStream *ts); | |
24451 | ||
24452 | extern __attribute__((visibility ("default"))) int | |
24453 | js_fgets(char *buf, int size, FILE *file); | |
24454 | ||
24455 | namespace js { | |
24456 | ||
24457 | struct KeywordInfo { | |
24458 | const char *chars; | |
24459 | TokenKind tokentype; | |
24460 | JSOp op; | |
24461 | JSVersion version; | |
24462 | }; | |
24463 | ||
24464 | ||
24465 | ||
24466 | ||
24467 | ||
24468 | extern const KeywordInfo * | |
24469 | FindKeyword(const jschar *s, size_t length); | |
24470 | ||
24471 | } | |
24472 | ||
24473 | ||
24474 | ||
24475 | ||
24476 | ||
24477 | typedef void (*JSMapKeywordFun)(const char *); | |
24478 | ||
24479 | ||
24480 | ||
24481 | ||
24482 | ||
24483 | extern JSBool | |
24484 | js_IsIdentifier(JSLinearString *str); | |
24485 | ||
24486 | ||
24487 | ||
24488 | ||
24489 | ||
24490 | ||
24491 | ||
24492 | namespace js { | |
24493 | ||
24494 | ||
24495 | ||
24496 | ||
24497 | ||
24498 | ||
24499 | ||
24500 | bool | |
24501 | # 577 "jsscan.h" | |
24502 | ReportCompileErrorNumber(JSContext *cx, TokenStream *ts, JSParseNode *pn, uintN flags, | |
24503 | uintN errorNumber, ...); | |
24504 | # 597 "jsscan.h" | |
24505 | ||
24506 | bool | |
24507 | # 598 "jsscan.h" | |
24508 | ReportStrictModeError(JSContext *cx, TokenStream *ts, JSTreeContext *tc, JSParseNode *pn, | |
24509 | uintN errorNumber, ...); | |
24510 | ||
24511 | } | |
24512 | # 51 "jsparse.h" 2 | |
24513 | ||
24514 | extern "C" { | |
24515 | # 291 "jsparse.h" | |
24516 | typedef enum JSParseNodeArity { | |
24517 | PN_NULLARY, | |
24518 | PN_UNARY, | |
24519 | PN_BINARY, | |
24520 | PN_TERNARY, | |
24521 | PN_FUNC, | |
24522 | PN_LIST, | |
24523 | PN_NAME, | |
24524 | PN_NAMESET | |
24525 | } JSParseNodeArity; | |
24526 | ||
24527 | struct JSDefinition; | |
24528 | ||
24529 | namespace js { | |
24530 | ||
24531 | struct GlobalScope { | |
24532 | GlobalScope(JSContext *cx, JSObject *globalObj, JSCodeGenerator *cg) | |
24533 | : globalObj(globalObj), cg(cg), defs(ContextAllocPolicy(cx)) | |
24534 | { } | |
24535 | ||
24536 | struct GlobalDef { | |
24537 | JSAtom *atom; | |
24538 | JSFunctionBox *funbox; | |
24539 | ||
24540 | uint32 knownSlot; | |
24541 | ||
24542 | GlobalDef() { } | |
24543 | GlobalDef(uint32 knownSlot) | |
24544 | : atom(__null), knownSlot(knownSlot) | |
24545 | { } | |
24546 | GlobalDef(JSAtom *atom, JSFunctionBox *box) : | |
24547 | atom(atom), funbox(box) | |
24548 | { } | |
24549 | }; | |
24550 | ||
24551 | JSObject *globalObj; | |
24552 | JSCodeGenerator *cg; | |
24553 | # 337 "jsparse.h" | |
24554 | Vector<GlobalDef, 16, ContextAllocPolicy> defs; | |
24555 | JSAtomList names; | |
24556 | }; | |
24557 | ||
24558 | } | |
24559 | ||
24560 | struct JSParseNode { | |
24561 | uint32 pn_type:16, | |
24562 | pn_op:8, | |
24563 | pn_arity:5, | |
24564 | pn_parens:1, | |
24565 | pn_used:1, | |
24566 | pn_defn:1; | |
24567 | ||
24568 | ||
24569 | ||
24570 | ||
24571 | js::TokenPos pn_pos; | |
24572 | int32 pn_offset; | |
24573 | JSParseNode *pn_next; | |
24574 | JSParseNode *pn_link; | |
24575 | ||
24576 | ||
24577 | union { | |
24578 | struct { | |
24579 | JSParseNode *head; | |
24580 | JSParseNode **tail; | |
24581 | uint32 count; | |
24582 | uint32 xflags:12, | |
24583 | blockid:20; | |
24584 | } list; | |
24585 | struct { | |
24586 | JSParseNode *kid1; | |
24587 | JSParseNode *kid2; | |
24588 | JSParseNode *kid3; | |
24589 | } ternary; | |
24590 | struct { | |
24591 | JSParseNode *left; | |
24592 | JSParseNode *right; | |
24593 | js::Value *pval; | |
24594 | uintN iflags; | |
24595 | } binary; | |
24596 | struct { | |
24597 | JSParseNode *kid; | |
24598 | jsint num; | |
24599 | JSBool hidden; | |
24600 | ||
24601 | ||
24602 | } unary; | |
24603 | struct { | |
24604 | union { | |
24605 | JSAtom *atom; | |
24606 | JSFunctionBox *funbox; | |
24607 | JSObjectBox *objbox; | |
24608 | }; | |
24609 | union { | |
24610 | JSParseNode *expr; | |
24611 | ||
24612 | JSDefinition *lexdef; | |
24613 | }; | |
24614 | js::UpvarCookie cookie; | |
24615 | ||
24616 | ||
24617 | uint32 dflags:12, | |
24618 | blockid:20; | |
24619 | ||
24620 | } name; | |
24621 | struct { | |
24622 | JSAtomSet names; | |
24623 | JSParseNode *tree; | |
24624 | } nameset; | |
24625 | struct { | |
24626 | JSAtom *atom; | |
24627 | JSAtom *atom2; | |
24628 | } apair; | |
24629 | jsdouble dval; | |
24630 | } pn_u; | |
24631 | # 445 "jsparse.h" | |
24632 | protected: | |
24633 | void inline init(js::TokenKind type, JSOp op, JSParseNodeArity arity) { | |
24634 | pn_type = type; | |
24635 | pn_op = op; | |
24636 | pn_arity = arity; | |
24637 | pn_parens = false; | |
24638 | ((void) 0); | |
24639 | ((void) 0); | |
24640 | pn_next = pn_link = __null; | |
24641 | } | |
24642 | ||
24643 | static JSParseNode *create(JSParseNodeArity arity, JSTreeContext *tc); | |
24644 | ||
24645 | public: | |
24646 | static JSParseNode *newBinaryOrAppend(js::TokenKind tt, JSOp op, JSParseNode *left, | |
24647 | JSParseNode *right, JSTreeContext *tc); | |
24648 | ||
24649 | ||
24650 | ||
24651 | ||
24652 | ||
24653 | ||
24654 | ||
24655 | JSParseNode *expr() const { | |
24656 | ((void) 0); | |
24657 | ((void) 0); | |
24658 | return pn_u.name.expr; | |
24659 | } | |
24660 | ||
24661 | JSDefinition *lexdef() const { | |
24662 | ((void) 0); | |
24663 | ((void) 0); | |
24664 | return pn_u.name.lexdef; | |
24665 | } | |
24666 | ||
24667 | JSParseNode *maybeExpr() { return pn_used ? __null : expr(); } | |
24668 | JSDefinition *maybeLexDef() { return pn_used ? lexdef() : __null; } | |
24669 | # 524 "jsparse.h" | |
24670 | uintN frameLevel() const { | |
24671 | ((void) 0); | |
24672 | return pn_u.name.cookie.level(); | |
24673 | } | |
24674 | ||
24675 | uintN frameSlot() const { | |
24676 | ((void) 0); | |
24677 | return pn_u.name.cookie.slot(); | |
24678 | } | |
24679 | ||
24680 | inline bool test(uintN flag) const; | |
24681 | ||
24682 | bool isLet() const { return test(0x01); } | |
24683 | bool isConst() const { return test(0x02); } | |
24684 | bool isInitialized() const { return test(0x04); } | |
24685 | bool isBlockChild() const { return test(0x20); } | |
24686 | bool isPlaceholder() const { return test(0x80); } | |
24687 | bool isDeoptimized() const { return test(0x400); } | |
24688 | bool isAssigned() const { return test(0x08); } | |
24689 | bool isFunArg() const { return test(0x100); } | |
24690 | bool isClosed() const { return test(0x800); } | |
24691 | # 558 "jsparse.h" | |
24692 | bool isTopLevel() const { return test(0x10); } | |
24693 | ||
24694 | ||
24695 | void setFunArg(); | |
24696 | ||
24697 | void become(JSParseNode *pn2); | |
24698 | void clear(); | |
24699 | ||
24700 | ||
24701 | bool isLiteral() const { | |
24702 | return ((js::TokenKind)(this)->pn_type) == js::TOK_NUMBER || | |
24703 | ((js::TokenKind)(this)->pn_type) == js::TOK_STRING || | |
24704 | (((js::TokenKind)(this)->pn_type) == js::TOK_PRIMARY && ((JSOp)(this)->pn_op) != JSOP_THIS); | |
24705 | } | |
24706 | # 588 "jsparse.h" | |
24707 | bool isStringExprStatement() const { | |
24708 | if (((js::TokenKind)(this)->pn_type) == js::TOK_SEMI) { | |
24709 | ((void) 0); | |
24710 | JSParseNode *kid = pn_u.unary.kid; | |
24711 | return kid && ((js::TokenKind)(kid)->pn_type) == js::TOK_STRING && !kid->pn_parens; | |
24712 | } | |
24713 | return false; | |
24714 | } | |
24715 | ||
24716 | ||
24717 | ||
24718 | ||
24719 | ||
24720 | ||
24721 | bool isEscapeFreeStringLiteral() const { | |
24722 | ((void) 0); | |
24723 | JSString *str = (pn_u.name.atom); | |
24724 | ||
24725 | ||
24726 | ||
24727 | ||
24728 | ||
24729 | ||
24730 | return (pn_pos.begin.lineno == pn_pos.end.lineno && | |
24731 | pn_pos.begin.index + str->length() + 2 == pn_pos.end.index); | |
24732 | } | |
24733 | ||
24734 | ||
24735 | bool isDirectivePrologueMember() const { return pn_u.unary.hidden; } | |
24736 | ||
24737 | ||
24738 | ||
24739 | ||
24740 | ||
24741 | bool isGeneratorExpr() const { | |
24742 | if (((js::TokenKind)(this)->pn_type) == js::TOK_LP) { | |
24743 | JSParseNode *callee = this->pn_u.list.head; | |
24744 | if (((js::TokenKind)(callee)->pn_type) == js::TOK_FUNCTION) { | |
24745 | JSParseNode *body = (((js::TokenKind)(callee->pn_u.name.expr)->pn_type) == js::TOK_UPVARS) | |
24746 | ? callee->pn_u.name.expr->pn_u.nameset.tree | |
24747 | : callee->pn_u.name.expr; | |
24748 | if (((js::TokenKind)(body)->pn_type) == js::TOK_LEXICALSCOPE) | |
24749 | return true; | |
24750 | } | |
24751 | } | |
24752 | return false; | |
24753 | } | |
24754 | ||
24755 | JSParseNode *generatorExpr() const { | |
24756 | ((void) 0); | |
24757 | JSParseNode *callee = this->pn_u.list.head; | |
24758 | JSParseNode *body = ((js::TokenKind)(callee->pn_u.name.expr)->pn_type) == js::TOK_UPVARS | |
24759 | ? callee->pn_u.name.expr->pn_u.nameset.tree | |
24760 | : callee->pn_u.name.expr; | |
24761 | ((void) 0); | |
24762 | return body->pn_u.name.expr; | |
24763 | } | |
24764 | ||
24765 | ||
24766 | ||
24767 | ||
24768 | ||
24769 | ||
24770 | JSParseNode *last() const { | |
24771 | ((void) 0); | |
24772 | ((void) 0); | |
24773 | return (JSParseNode *)((char *)pn_u.list.tail - __builtin_offsetof (JSParseNode, pn_next)); | |
24774 | } | |
24775 | ||
24776 | void makeEmpty() { | |
24777 | ((void) 0); | |
24778 | pn_u.list.head = __null; | |
24779 | pn_u.list.tail = &pn_u.list.head; | |
24780 | pn_u.list.count = 0; | |
24781 | pn_u.list.xflags = 0; | |
24782 | pn_u.name.blockid = 0; | |
24783 | } | |
24784 | ||
24785 | void initList(JSParseNode *pn) { | |
24786 | ((void) 0); | |
24787 | pn_u.list.head = pn; | |
24788 | pn_u.list.tail = &pn->pn_next; | |
24789 | pn_u.list.count = 1; | |
24790 | pn_u.list.xflags = 0; | |
24791 | pn_u.name.blockid = 0; | |
24792 | } | |
24793 | ||
24794 | void append(JSParseNode *pn) { | |
24795 | ((void) 0); | |
24796 | *pn_u.list.tail = pn; | |
24797 | pn_u.list.tail = &pn->pn_next; | |
24798 | pn_u.list.count++; | |
24799 | } | |
24800 | ||
24801 | bool getConstantValue(JSContext *cx, bool strictChecks, js::Value *vp); | |
24802 | inline bool isConstant(); | |
24803 | }; | |
24804 | ||
24805 | namespace js { | |
24806 | ||
24807 | struct NullaryNode : public JSParseNode { | |
24808 | static inline NullaryNode *create(JSTreeContext *tc) { | |
24809 | return (NullaryNode *)JSParseNode::create(PN_NULLARY, tc); | |
24810 | } | |
24811 | }; | |
24812 | ||
24813 | struct UnaryNode : public JSParseNode { | |
24814 | static inline UnaryNode *create(JSTreeContext *tc) { | |
24815 | return (UnaryNode *)JSParseNode::create(PN_UNARY, tc); | |
24816 | } | |
24817 | }; | |
24818 | ||
24819 | struct BinaryNode : public JSParseNode { | |
24820 | static inline BinaryNode *create(JSTreeContext *tc) { | |
24821 | return (BinaryNode *)JSParseNode::create(PN_BINARY, tc); | |
24822 | } | |
24823 | }; | |
24824 | ||
24825 | struct TernaryNode : public JSParseNode { | |
24826 | static inline TernaryNode *create(JSTreeContext *tc) { | |
24827 | return (TernaryNode *)JSParseNode::create(PN_TERNARY, tc); | |
24828 | } | |
24829 | }; | |
24830 | ||
24831 | struct ListNode : public JSParseNode { | |
24832 | static inline ListNode *create(JSTreeContext *tc) { | |
24833 | return (ListNode *)JSParseNode::create(PN_LIST, tc); | |
24834 | } | |
24835 | }; | |
24836 | ||
24837 | struct FunctionNode : public JSParseNode { | |
24838 | static inline FunctionNode *create(JSTreeContext *tc) { | |
24839 | return (FunctionNode *)JSParseNode::create(PN_FUNC, tc); | |
24840 | } | |
24841 | }; | |
24842 | ||
24843 | struct NameNode : public JSParseNode { | |
24844 | static NameNode *create(JSAtom *atom, JSTreeContext *tc); | |
24845 | ||
24846 | void inline initCommon(JSTreeContext *tc); | |
24847 | }; | |
24848 | ||
24849 | struct NameSetNode : public JSParseNode { | |
24850 | static inline NameSetNode *create(JSTreeContext *tc) { | |
24851 | return (NameSetNode *)JSParseNode::create(PN_NAMESET, tc); | |
24852 | } | |
24853 | }; | |
24854 | ||
24855 | struct LexicalScopeNode : public JSParseNode { | |
24856 | static inline LexicalScopeNode *create(JSTreeContext *tc) { | |
24857 | return (LexicalScopeNode *)JSParseNode::create(PN_NAME, tc); | |
24858 | } | |
24859 | }; | |
24860 | ||
24861 | } | |
24862 | # 857 "jsparse.h" | |
24863 | struct JSDefinition : public JSParseNode | |
24864 | { | |
24865 | # 867 "jsparse.h" | |
24866 | JSDefinition *resolve() { | |
24867 | JSParseNode *pn = this; | |
24868 | while (!pn->pn_defn) { | |
24869 | if (pn->pn_type == js::TOK_ASSIGN) { | |
24870 | pn = pn->pn_u.binary.left; | |
24871 | continue; | |
24872 | } | |
24873 | pn = pn->lexdef(); | |
24874 | } | |
24875 | return (JSDefinition *) pn; | |
24876 | } | |
24877 | ||
24878 | bool isFreeVar() const { | |
24879 | ((void) 0); | |
24880 | return pn_u.name.cookie.isFree() || test(0x40); | |
24881 | } | |
24882 | ||
24883 | bool isGlobal() const { | |
24884 | ((void) 0); | |
24885 | return test(0x40); | |
24886 | } | |
24887 | ||
24888 | ||
24889 | ||
24890 | ||
24891 | ||
24892 | enum Kind { VAR, CONST, LET, FUNCTION, ARG, UNKNOWN }; | |
24893 | ||
24894 | bool isBindingForm() { return int(kind()) <= int(LET); } | |
24895 | ||
24896 | static const char *kindString(Kind kind); | |
24897 | ||
24898 | Kind kind() { | |
24899 | if (((js::TokenKind)(this)->pn_type) == js::TOK_FUNCTION) | |
24900 | return FUNCTION; | |
24901 | ((void) 0); | |
24902 | if (((JSOp)(this)->pn_op) == JSOP_NOP) | |
24903 | return UNKNOWN; | |
24904 | if (((JSOp)(this)->pn_op) == JSOP_GETARG) | |
24905 | return ARG; | |
24906 | if (isConst()) | |
24907 | return CONST; | |
24908 | if (isLet()) | |
24909 | return LET; | |
24910 | return VAR; | |
24911 | } | |
24912 | }; | |
24913 | ||
24914 | inline | |
24915 | ||
24916 | # 915 "jsparse.h" | |
24917 | bool | |
24918 | JSParseNode::test(uintN flag) const | |
24919 | { | |
24920 | ((void) 0); | |
24921 | # 927 "jsparse.h" | |
24922 | return !!(pn_u.name.dflags & flag); | |
24923 | } | |
24924 | ||
24925 | inline void | |
24926 | JSParseNode::setFunArg() | |
24927 | { | |
24928 | # 943 "jsparse.h" | |
24929 | ((void) 0); | |
24930 | if (pn_used) | |
24931 | pn_u.name.lexdef->pn_u.name.dflags |= 0x100; | |
24932 | pn_u.name.dflags |= 0x100; | |
24933 | } | |
24934 | ||
24935 | struct JSObjectBox { | |
24936 | JSObjectBox *traceLink; | |
24937 | JSObjectBox *emitLink; | |
24938 | JSObject *object; | |
24939 | JSObjectBox *parent; | |
24940 | uintN index; | |
24941 | bool isFunctionBox; | |
24942 | }; | |
24943 | ||
24944 | ||
24945 | ||
24946 | struct JSFunctionBox : public JSObjectBox | |
24947 | { | |
24948 | JSParseNode *node; | |
24949 | JSFunctionBox *siblings; | |
24950 | JSFunctionBox *kids; | |
24951 | JSFunctionBox *parent; | |
24952 | JSParseNode *methods; | |
24953 | ||
24954 | ||
24955 | ||
24956 | ||
24957 | js::Bindings bindings; | |
24958 | uint32 queued:1, | |
24959 | inLoop:1, | |
24960 | level:14; | |
24961 | uint32 tcflags; | |
24962 | ||
24963 | bool joinable() const; | |
24964 | ||
24965 | ||
24966 | ||
24967 | ||
24968 | ||
24969 | bool inAnyDynamicScope() const; | |
24970 | # 995 "jsparse.h" | |
24971 | bool shouldUnbrand(uintN methods, uintN slowMethods) const; | |
24972 | }; | |
24973 | ||
24974 | struct JSFunctionBoxQueue { | |
24975 | JSFunctionBox **vector; | |
24976 | size_t head, tail; | |
24977 | size_t lengthMask; | |
24978 | ||
24979 | size_t count() { return head - tail; } | |
24980 | size_t length() { return lengthMask + 1; } | |
24981 | ||
24982 | JSFunctionBoxQueue() | |
24983 | : vector(__null), head(0), tail(0), lengthMask(0) { } | |
24984 | ||
24985 | bool init(uint32 count) { | |
24986 | lengthMask = (((JSUint32)1 << (JS_CeilingLog2(count))) - 1); | |
24987 | vector = js_array_new<JSFunctionBox*>(length()); | |
24988 | return !!vector; | |
24989 | } | |
24990 | ||
24991 | ~JSFunctionBoxQueue() { js_array_delete(vector); } | |
24992 | ||
24993 | void push(JSFunctionBox *funbox) { | |
24994 | if (!funbox->queued) { | |
24995 | ((void) 0); | |
24996 | vector[head++ & lengthMask] = funbox; | |
24997 | funbox->queued = true; | |
24998 | } | |
24999 | } | |
25000 | ||
25001 | JSFunctionBox *pull() { | |
25002 | if (tail == head) | |
25003 | return __null; | |
25004 | ((void) 0); | |
25005 | JSFunctionBox *funbox = vector[tail++ & lengthMask]; | |
25006 | funbox->queued = false; | |
25007 | return funbox; | |
25008 | } | |
25009 | }; | |
25010 | ||
25011 | ||
25012 | ||
25013 | typedef struct BindData BindData; | |
25014 | ||
25015 | namespace js { | |
25016 | ||
25017 | struct Parser : private js::AutoGCRooter | |
25018 | { | |
25019 | JSContext * const context; | |
25020 | JSAtomListElement *aleFreeList; | |
25021 | void *tempFreeList[6U]; | |
25022 | TokenStream tokenStream; | |
25023 | void *tempPoolMark; | |
25024 | JSPrincipals *principals; | |
25025 | JSStackFrame *const callerFrame; | |
25026 | JSObject *const callerVarObj; | |
25027 | JSParseNode *nodeList; | |
25028 | uint32 functionCount; | |
25029 | JSObjectBox *traceListHead; | |
25030 | JSTreeContext *tc; | |
25031 | ||
25032 | ||
25033 | js::AutoKeepAtoms keepAtoms; | |
25034 | ||
25035 | Parser(JSContext *cx, JSPrincipals *prin = __null, JSStackFrame *cfp = __null); | |
25036 | ~Parser(); | |
25037 | ||
25038 | friend void js::AutoGCRooter::trace(JSTracer *trc); | |
25039 | friend struct ::JSTreeContext; | |
25040 | friend struct Compiler; | |
25041 | ||
25042 | ||
25043 | ||
25044 | ||
25045 | ||
25046 | ||
25047 | ||
25048 | bool init(const jschar *base, size_t length, const char *filename, uintN lineno, | |
25049 | JSVersion version); | |
25050 | ||
25051 | void setPrincipals(JSPrincipals *prin); | |
25052 | ||
25053 | const char *getFilename() const { return tokenStream.getFilename(); } | |
25054 | JSVersion versionWithFlags() const { return tokenStream.versionWithFlags(); } | |
25055 | JSVersion versionNumber() const { return tokenStream.versionNumber(); } | |
25056 | bool hasXML() const { return tokenStream.hasXML(); } | |
25057 | bool hasAnonFunFix() const { return tokenStream.hasAnonFunFix(); } | |
25058 | ||
25059 | ||
25060 | ||
25061 | ||
25062 | JSParseNode *parse(JSObject *chain); | |
25063 | ||
25064 | ||
25065 | JSParseNode *parseXMLText(JSObject *chain, bool allowList); | |
25066 | ||
25067 | ||
25068 | ||
25069 | ||
25070 | ||
25071 | JSObjectBox *newObjectBox(JSObject *obj); | |
25072 | ||
25073 | JSFunctionBox *newFunctionBox(JSObject *obj, JSParseNode *fn, JSTreeContext *tc); | |
25074 | ||
25075 | ||
25076 | ||
25077 | ||
25078 | ||
25079 | JSFunction *newFunction(JSTreeContext *tc, JSAtom *atom, uintN lambda); | |
25080 | ||
25081 | ||
25082 | ||
25083 | ||
25084 | ||
25085 | ||
25086 | bool analyzeFunctions(JSTreeContext *tc); | |
25087 | void cleanFunctionList(JSFunctionBox **funbox); | |
25088 | bool markFunArgs(JSFunctionBox *funbox); | |
25089 | void setFunctionKinds(JSFunctionBox *funbox, uint32 *tcflags); | |
25090 | ||
25091 | void trace(JSTracer *trc); | |
25092 | ||
25093 | ||
25094 | ||
25095 | ||
25096 | inline bool reportErrorNumber(JSParseNode *pn, uintN flags, uintN errorNumber, ...); | |
25097 | ||
25098 | private: | |
25099 | # 1131 "jsparse.h" | |
25100 | JSParseNode *functionStmt(); | |
25101 | JSParseNode *functionExpr(); | |
25102 | JSParseNode *statements(); | |
25103 | JSParseNode *statement(); | |
25104 | JSParseNode *switchStatement(); | |
25105 | JSParseNode *forStatement(); | |
25106 | JSParseNode *tryStatement(); | |
25107 | JSParseNode *withStatement(); | |
25108 | ||
25109 | JSParseNode *letStatement(); | |
25110 | ||
25111 | JSParseNode *expressionStatement(); | |
25112 | JSParseNode *variables(bool inLetHead); | |
25113 | JSParseNode *expr(); | |
25114 | JSParseNode *assignExpr(); | |
25115 | JSParseNode *condExpr(); | |
25116 | JSParseNode *orExpr(); | |
25117 | JSParseNode *andExpr(); | |
25118 | JSParseNode *bitOrExpr(); | |
25119 | JSParseNode *bitXorExpr(); | |
25120 | JSParseNode *bitAndExpr(); | |
25121 | JSParseNode *eqExpr(); | |
25122 | JSParseNode *relExpr(); | |
25123 | JSParseNode *shiftExpr(); | |
25124 | JSParseNode *addExpr(); | |
25125 | JSParseNode *mulExpr(); | |
25126 | JSParseNode *unaryExpr(); | |
25127 | JSParseNode *memberExpr(JSBool allowCallSyntax); | |
25128 | JSParseNode *primaryExpr(js::TokenKind tt, JSBool afterDot); | |
25129 | JSParseNode *parenExpr(JSBool *genexp = __null); | |
25130 | ||
25131 | ||
25132 | ||
25133 | ||
25134 | bool recognizeDirectivePrologue(JSParseNode *pn, bool *isDirectivePrologueMember); | |
25135 | ||
25136 | enum FunctionType { GETTER, SETTER, GENERAL }; | |
25137 | bool functionArguments(JSTreeContext &funtc, JSFunctionBox *funbox, JSParseNode **list); | |
25138 | JSParseNode *functionBody(); | |
25139 | JSParseNode *functionDef(JSAtom *name, FunctionType type, uintN lambda); | |
25140 | ||
25141 | JSParseNode *condition(); | |
25142 | JSParseNode *comprehensionTail(JSParseNode *kid, uintN blockid, | |
25143 | js::TokenKind type = js::TOK_SEMI, JSOp op = JSOP_NOP); | |
25144 | JSParseNode *generatorExpr(JSParseNode *kid); | |
25145 | JSBool argumentList(JSParseNode *listNode); | |
25146 | JSParseNode *bracketedExpr(); | |
25147 | JSParseNode *letBlock(JSBool statement); | |
25148 | JSParseNode *returnOrYield(bool useAssignExpr); | |
25149 | JSParseNode *destructuringExpr(BindData *data, js::TokenKind tt); | |
25150 | ||
25151 | ||
25152 | JSParseNode *endBracketedExpr(); | |
25153 | ||
25154 | JSParseNode *propertySelector(); | |
25155 | JSParseNode *qualifiedSuffix(JSParseNode *pn); | |
25156 | JSParseNode *qualifiedIdentifier(); | |
25157 | JSParseNode *attributeIdentifier(); | |
25158 | JSParseNode *xmlExpr(JSBool inTag); | |
25159 | JSParseNode *xmlAtomNode(); | |
25160 | JSParseNode *xmlNameExpr(); | |
25161 | JSParseNode *xmlTagContent(js::TokenKind tagtype, JSAtom **namep); | |
25162 | JSBool xmlElementContent(JSParseNode *pn); | |
25163 | JSParseNode *xmlElementOrList(JSBool allowList); | |
25164 | JSParseNode *xmlElementOrListRoot(JSBool allowList); | |
25165 | ||
25166 | }; | |
25167 | ||
25168 | inline | |
25169 | ||
25170 | # 1199 "jsparse.h" | |
25171 | bool | |
25172 | Parser::reportErrorNumber(JSParseNode *pn, uintN flags, uintN errorNumber, ...) | |
25173 | { | |
25174 | va_list args; | |
25175 | __builtin_va_start(args,errorNumber); | |
25176 | bool result = tokenStream.reportCompileErrorNumberVA(pn, flags, errorNumber, args); | |
25177 | __builtin_va_end(args); | |
25178 | return result; | |
25179 | } | |
25180 | ||
25181 | struct Compiler | |
25182 | { | |
25183 | Parser parser; | |
25184 | GlobalScope *globalScope; | |
25185 | ||
25186 | Compiler(JSContext *cx, JSPrincipals *prin = __null, JSStackFrame *cfp = __null); | |
25187 | ||
25188 | ||
25189 | ||
25190 | ||
25191 | inline | |
25192 | ||
25193 | # 1220 "jsparse.h" | |
25194 | ||
25195 | # 1219 "jsparse.h" | |
25196 | bool | |
25197 | init(const jschar *base, size_t length, const char *filename, uintN lineno, JSVersion version) | |
25198 | { | |
25199 | return parser.init(base, length, filename, lineno, version); | |
25200 | } | |
25201 | ||
25202 | static | |
25203 | ||
25204 | # 1226 "jsparse.h" | |
25205 | ||
25206 | # 1225 "jsparse.h" | |
25207 | bool | |
25208 | compileFunctionBody(JSContext *cx, JSFunction *fun, JSPrincipals *principals, | |
25209 | js::Bindings *bindings, const jschar *chars, size_t length, | |
25210 | const char *filename, uintN lineno, JSVersion version); | |
25211 | ||
25212 | static JSScript * | |
25213 | compileScript(JSContext *cx, JSObject *scopeChain, JSStackFrame *callerFrame, | |
25214 | JSPrincipals *principals, uint32 tcflags, | |
25215 | const jschar *chars, size_t length, | |
25216 | const char *filename, uintN lineno, JSVersion version, | |
25217 | JSString *source = __null, uintN staticLevel = 0); | |
25218 | ||
25219 | private: | |
25220 | static bool defineGlobals(JSContext *cx, GlobalScope &globalScope, JSScript *script); | |
25221 | }; | |
25222 | ||
25223 | } | |
25224 | ||
25225 | ||
25226 | ||
25227 | ||
25228 | ||
25229 | ||
25230 | extern JSBool | |
25231 | js_FoldConstants(JSContext *cx, JSParseNode *pn, JSTreeContext *tc, | |
25232 | bool inCond = false); | |
25233 | ||
25234 | } | |
25235 | # 65 "jsxml.cpp" 2 | |
25236 | ||
25237 | # 1 "jsscope.h" 1 | |
25238 | # 53 "jsscope.h" | |
25239 | # 1 "jscompartment.h" 1 | |
25240 | # 50 "jscompartment.h" | |
25241 | # 1 "jsxml.h" 1 | |
25242 | # 46 "jsxml.h" | |
25243 | extern const char js_AnyName_str[]; | |
25244 | extern const char js_AttributeName_str[]; | |
25245 | extern const char js_isXMLName_str[]; | |
25246 | extern const char js_XMLList_str[]; | |
25247 | ||
25248 | extern const char js_amp_entity_str[]; | |
25249 | extern const char js_gt_entity_str[]; | |
25250 | extern const char js_lt_entity_str[]; | |
25251 | extern const char js_quot_entity_str[]; | |
25252 | ||
25253 | typedef JSBool | |
25254 | (* JSIdentityOp)(const void *a, const void *b); | |
25255 | ||
25256 | struct JSXMLArray { | |
25257 | uint32 length; | |
25258 | uint32 capacity; | |
25259 | void **vector; | |
25260 | JSXMLArrayCursor *cursors; | |
25261 | ||
25262 | void init() { | |
25263 | length = capacity = 0; | |
25264 | vector = __null; | |
25265 | cursors = __null; | |
25266 | } | |
25267 | ||
25268 | void finish(JSContext *cx); | |
25269 | ||
25270 | bool setCapacity(JSContext *cx, uint32 capacity); | |
25271 | void trim(); | |
25272 | }; | |
25273 | ||
25274 | struct JSXMLArrayCursor | |
25275 | { | |
25276 | JSXMLArray *array; | |
25277 | uint32 index; | |
25278 | JSXMLArrayCursor *next; | |
25279 | JSXMLArrayCursor **prevp; | |
25280 | void *root; | |
25281 | ||
25282 | JSXMLArrayCursor(JSXMLArray *array) | |
25283 | : array(array), index(0), next(array->cursors), prevp(&array->cursors), | |
25284 | root(__null) | |
25285 | { | |
25286 | if (next) | |
25287 | next->prevp = &next; | |
25288 | array->cursors = this; | |
25289 | } | |
25290 | ||
25291 | ~JSXMLArrayCursor() { disconnect(); } | |
25292 | ||
25293 | void disconnect() { | |
25294 | if (!array) | |
25295 | return; | |
25296 | if (next) | |
25297 | next->prevp = prevp; | |
25298 | *prevp = next; | |
25299 | array = __null; | |
25300 | } | |
25301 | ||
25302 | void *getNext() { | |
25303 | if (!array || index >= array->length) | |
25304 | return __null; | |
25305 | return root = array->vector[index++]; | |
25306 | } | |
25307 | ||
25308 | void *getCurrent() { | |
25309 | if (!array || index >= array->length) | |
25310 | return __null; | |
25311 | return root = array->vector[index]; | |
25312 | } | |
25313 | ||
25314 | void trace(JSTracer *trc); | |
25315 | }; | |
25316 | # 128 "jsxml.h" | |
25317 | typedef enum JSXMLClass { | |
25318 | JSXML_CLASS_LIST, | |
25319 | JSXML_CLASS_ELEMENT, | |
25320 | JSXML_CLASS_ATTRIBUTE, | |
25321 | JSXML_CLASS_PROCESSING_INSTRUCTION, | |
25322 | JSXML_CLASS_TEXT, | |
25323 | JSXML_CLASS_COMMENT, | |
25324 | JSXML_CLASS_LIMIT | |
25325 | } JSXMLClass; | |
25326 | # 148 "jsxml.h" | |
25327 | typedef struct JSXMLListVar { | |
25328 | JSXMLArray kids; | |
25329 | JSXML *target; | |
25330 | JSObject *targetprop; | |
25331 | } JSXMLListVar; | |
25332 | ||
25333 | typedef struct JSXMLElemVar { | |
25334 | JSXMLArray kids; | |
25335 | JSXMLArray namespaces; | |
25336 | JSXMLArray attrs; | |
25337 | } JSXMLElemVar; | |
25338 | # 176 "jsxml.h" | |
25339 | struct JSXML : js::gc::Cell { | |
25340 | ||
25341 | ||
25342 | ||
25343 | ||
25344 | JSObject *object; | |
25345 | void *domnode; | |
25346 | JSXML *parent; | |
25347 | JSObject *name; | |
25348 | uint32 xml_class; | |
25349 | uint32 xml_flags; | |
25350 | union { | |
25351 | JSXMLListVar list; | |
25352 | JSXMLElemVar elem; | |
25353 | JSString *value; | |
25354 | } u; | |
25355 | ||
25356 | void finalize(JSContext *cx) { | |
25357 | if ((((this)->xml_class) < JSXML_CLASS_ATTRIBUTE)) { | |
25358 | u.list.kids.finish(cx); | |
25359 | if (xml_class == JSXML_CLASS_ELEMENT) { | |
25360 | u.elem.namespaces.finish(cx); | |
25361 | u.elem.attrs.finish(cx); | |
25362 | } | |
25363 | } | |
25364 | ||
25365 | ||
25366 | ||
25367 | } | |
25368 | }; | |
25369 | ||
25370 | ||
25371 | ||
25372 | ||
25373 | extern JSXML * | |
25374 | js_NewXML(JSContext *cx, JSXMLClass xml_class); | |
25375 | ||
25376 | extern void | |
25377 | js_TraceXML(JSTracer *trc, JSXML *xml); | |
25378 | ||
25379 | extern JSObject * | |
25380 | js_NewXMLObject(JSContext *cx, JSXMLClass xml_class); | |
25381 | ||
25382 | extern JSObject * | |
25383 | js_GetXMLObject(JSContext *cx, JSXML *xml); | |
25384 | ||
25385 | extern __attribute__((visibility ("default"))) js::Class js_XMLClass; | |
25386 | extern __attribute__((visibility ("default"))) js::Class js_NamespaceClass; | |
25387 | extern __attribute__((visibility ("default"))) js::Class js_QNameClass; | |
25388 | extern __attribute__((visibility ("default"))) js::Class js_AttributeNameClass; | |
25389 | extern __attribute__((visibility ("default"))) js::Class js_AnyNameClass; | |
25390 | extern js::Class js_XMLFilterClass; | |
25391 | ||
25392 | ||
25393 | ||
25394 | ||
25395 | inline | |
25396 | ||
25397 | # 232 "jsxml.h" | |
25398 | bool | |
25399 | JSObject::isXML() const | |
25400 | { | |
25401 | return getClass() == &js_XMLClass; | |
25402 | } | |
25403 | ||
25404 | inline | |
25405 | ||
25406 | # 238 "jsxml.h" | |
25407 | bool | |
25408 | JSObject::isXMLId() const | |
25409 | { | |
25410 | js::Class *clasp = getClass(); | |
25411 | return clasp == &js_QNameClass || | |
25412 | clasp == &js_AttributeNameClass || | |
25413 | clasp == &js_AnyNameClass; | |
25414 | } | |
25415 | ||
25416 | ||
25417 | ||
25418 | inline | |
25419 | ||
25420 | # 249 "jsxml.h" | |
25421 | bool | |
25422 | JSObject::isNamespace() const | |
25423 | { | |
25424 | return getClass() == &js_NamespaceClass; | |
25425 | } | |
25426 | ||
25427 | inline | |
25428 | ||
25429 | # 255 "jsxml.h" | |
25430 | bool | |
25431 | JSObject::isQName() const | |
25432 | { | |
25433 | js::Class* clasp = getClass(); | |
25434 | return clasp == &js_QNameClass || | |
25435 | clasp == &js_AttributeNameClass || | |
25436 | clasp == &js_AnyNameClass; | |
25437 | } | |
25438 | ||
25439 | static inline | |
25440 | ||
25441 | # 264 "jsxml.h" | |
25442 | bool | |
25443 | IsXML(const js::Value &v) | |
25444 | { | |
25445 | return v.isObject() && v.toObject().isXML(); | |
25446 | } | |
25447 | ||
25448 | extern JSObject * | |
25449 | js_InitNamespaceClass(JSContext *cx, JSObject *obj); | |
25450 | ||
25451 | extern JSObject * | |
25452 | js_InitQNameClass(JSContext *cx, JSObject *obj); | |
25453 | ||
25454 | extern JSObject * | |
25455 | js_InitXMLClass(JSContext *cx, JSObject *obj); | |
25456 | ||
25457 | extern JSObject * | |
25458 | js_InitXMLClasses(JSContext *cx, JSObject *obj); | |
25459 | ||
25460 | extern JSBool | |
25461 | js_GetFunctionNamespace(JSContext *cx, js::Value *vp); | |
25462 | ||
25463 | ||
25464 | ||
25465 | ||
25466 | ||
25467 | JSBool | |
25468 | js_IsFunctionQName(JSContext *cx, JSObject *obj, jsid *funidp); | |
25469 | ||
25470 | extern JSBool | |
25471 | js_GetDefaultXMLNamespace(JSContext *cx, jsval *vp); | |
25472 | ||
25473 | extern JSBool | |
25474 | js_SetDefaultXMLNamespace(JSContext *cx, const js::Value &v); | |
25475 | ||
25476 | ||
25477 | ||
25478 | ||
25479 | ||
25480 | ||
25481 | extern JSBool | |
25482 | js_IsXMLName(JSContext *cx, jsval v); | |
25483 | ||
25484 | extern JSBool | |
25485 | js_ToAttributeName(JSContext *cx, js::Value *vp); | |
25486 | ||
25487 | extern JSFlatString * | |
25488 | js_EscapeAttributeValue(JSContext *cx, JSString *str, JSBool quote); | |
25489 | ||
25490 | extern JSString * | |
25491 | js_AddAttributePart(JSContext *cx, JSBool isName, JSString *str, | |
25492 | JSString *str2); | |
25493 | ||
25494 | extern JSFlatString * | |
25495 | js_EscapeElementValue(JSContext *cx, JSString *str); | |
25496 | ||
25497 | extern JSString * | |
25498 | js_ValueToXMLString(JSContext *cx, const js::Value &v); | |
25499 | ||
25500 | extern JSObject * | |
25501 | js_ConstructXMLQNameObject(JSContext *cx, const js::Value & nsval, | |
25502 | const js::Value & lnval); | |
25503 | ||
25504 | extern JSBool | |
25505 | js_GetAnyName(JSContext *cx, jsid *idp); | |
25506 | ||
25507 | ||
25508 | ||
25509 | ||
25510 | extern JSBool | |
25511 | js_FindXMLProperty(JSContext *cx, const js::Value &nameval, JSObject **objp, jsid *idp); | |
25512 | ||
25513 | extern JSBool | |
25514 | js_GetXMLMethod(JSContext *cx, JSObject *obj, jsid id, js::Value *vp); | |
25515 | ||
25516 | extern JSBool | |
25517 | js_GetXMLDescendants(JSContext *cx, JSObject *obj, jsval id, jsval *vp); | |
25518 | ||
25519 | extern JSBool | |
25520 | js_DeleteXMLListElements(JSContext *cx, JSObject *listobj); | |
25521 | ||
25522 | extern JSBool | |
25523 | js_StepXMLListFilter(JSContext *cx, JSBool initialized); | |
25524 | ||
25525 | extern JSObject * | |
25526 | js_ValueToXMLObject(JSContext *cx, const js::Value &v); | |
25527 | ||
25528 | extern JSObject * | |
25529 | js_ValueToXMLListObject(JSContext *cx, const js::Value &v); | |
25530 | ||
25531 | extern JSObject * | |
25532 | js_NewXMLSpecialObject(JSContext *cx, JSXMLClass xml_class, JSString *name, | |
25533 | JSString *value); | |
25534 | ||
25535 | extern JSString * | |
25536 | js_MakeXMLCDATAString(JSContext *cx, JSString *str); | |
25537 | ||
25538 | extern JSString * | |
25539 | js_MakeXMLCommentString(JSContext *cx, JSString *str); | |
25540 | ||
25541 | extern JSString * | |
25542 | js_MakeXMLPIString(JSContext *cx, JSString *name, JSString *str); | |
25543 | ||
25544 | ||
25545 | extern JSBool | |
25546 | js_TestXMLEquality(JSContext *cx, const js::Value &v1, const js::Value &v2, | |
25547 | JSBool *bp); | |
25548 | ||
25549 | extern JSBool | |
25550 | js_ConcatenateXML(JSContext *cx, JSObject *obj1, JSObject *obj2, js::Value *vp); | |
25551 | # 51 "jscompartment.h" 2 | |
25552 | ||
25553 | ||
25554 | ||
25555 | ||
25556 | ||
25557 | ||
25558 | namespace JSC { | |
25559 | ||
25560 | class ExecutableAllocator; | |
25561 | ||
25562 | } | |
25563 | ||
25564 | namespace js { | |
25565 | ||
25566 | ||
25567 | typedef HashMap<jsbytecode*, | |
25568 | size_t, | |
25569 | DefaultHasher<jsbytecode*>, | |
25570 | SystemAllocPolicy> RecordAttemptMap; | |
25571 | ||
25572 | ||
25573 | typedef HashMap<jsbytecode*, | |
25574 | LoopProfile*, | |
25575 | DefaultHasher<jsbytecode*>, | |
25576 | SystemAllocPolicy> LoopProfileMap; | |
25577 | ||
25578 | class Oracle; | |
25579 | ||
25580 | typedef HashSet<JSScript *, | |
25581 | DefaultHasher<JSScript *>, | |
25582 | SystemAllocPolicy> TracedScriptSet; | |
25583 | ||
25584 | typedef HashMap<JSFunction *, | |
25585 | JSString *, | |
25586 | DefaultHasher<JSFunction *>, | |
25587 | SystemAllocPolicy> ToSourceCache; | |
25588 | ||
25589 | struct TraceMonitor; | |
25590 | ||
25591 | ||
25592 | struct TracerState | |
25593 | { | |
25594 | JSContext* cx; | |
25595 | TraceMonitor* traceMonitor; | |
25596 | double* stackBase; | |
25597 | double* sp; | |
25598 | double* eos; | |
25599 | FrameInfo** callstackBase; | |
25600 | void* sor; | |
25601 | FrameInfo** rp; | |
25602 | void* eor; | |
25603 | VMSideExit* lastTreeExitGuard; | |
25604 | VMSideExit* lastTreeCallGuard; | |
25605 | ||
25606 | void* rpAtLastTreeCall; | |
25607 | VMSideExit* outermostTreeExitGuard; | |
25608 | TreeFragment* outermostTree; | |
25609 | uintN* inlineCallCountp; | |
25610 | VMSideExit** innermostNestedGuardp; | |
25611 | VMSideExit* innermost; | |
25612 | uint64 startTime; | |
25613 | TracerState* prev; | |
25614 | ||
25615 | ||
25616 | ||
25617 | ||
25618 | uint32 builtinStatus; | |
25619 | ||
25620 | ||
25621 | double* deepBailSp; | |
25622 | ||
25623 | ||
25624 | uintN nativeVpLen; | |
25625 | js::Value* nativeVp; | |
25626 | ||
25627 | TracerState(JSContext *cx, TraceMonitor *tm, TreeFragment *ti, | |
25628 | uintN &inlineCallCountp, VMSideExit** innermostNestedGuardp); | |
25629 | ~TracerState(); | |
25630 | }; | |
25631 | ||
25632 | ||
25633 | ||
25634 | ||
25635 | ||
25636 | ||
25637 | ||
25638 | struct TraceNativeStorage | |
25639 | { | |
25640 | double stack_global_buf[MAX_NATIVE_STACK_SLOTS + GLOBAL_SLOTS_BUFFER_SIZE]; | |
25641 | FrameInfo *callstack_buf[MAX_CALL_STACK_ENTRIES]; | |
25642 | ||
25643 | double *stack() { return stack_global_buf; } | |
25644 | double *global() { return stack_global_buf + MAX_NATIVE_STACK_SLOTS; } | |
25645 | FrameInfo **callstack() { return callstack_buf; } | |
25646 | }; | |
25647 | ||
25648 | ||
25649 | struct GlobalState { | |
25650 | JSObject* globalObj; | |
25651 | uint32 globalShape; | |
25652 | SlotList* globalSlots; | |
25653 | }; | |
25654 | ||
25655 | ||
25656 | ||
25657 | ||
25658 | ||
25659 | ||
25660 | struct TraceMonitor { | |
25661 | # 170 "jscompartment.h" | |
25662 | JSContext *tracecx; | |
25663 | ||
25664 | ||
25665 | ||
25666 | ||
25667 | ||
25668 | ||
25669 | js::TracerState *tracerState; | |
25670 | js::VMSideExit *bailExit; | |
25671 | ||
25672 | ||
25673 | unsigned iterationCounter; | |
25674 | ||
25675 | ||
25676 | ||
25677 | ||
25678 | ||
25679 | ||
25680 | TraceNativeStorage *storage; | |
25681 | # 214 "jscompartment.h" | |
25682 | VMAllocator* dataAlloc; | |
25683 | VMAllocator* traceAlloc; | |
25684 | VMAllocator* tempAlloc; | |
25685 | nanojit::CodeAlloc* codeAlloc; | |
25686 | nanojit::Assembler* assembler; | |
25687 | FrameInfoCache* frameCache; | |
25688 | ||
25689 | ||
25690 | uintN flushEpoch; | |
25691 | ||
25692 | Oracle* oracle; | |
25693 | TraceRecorder* recorder; | |
25694 | ||
25695 | ||
25696 | LoopProfile* profile; | |
25697 | ||
25698 | GlobalState globalStates[MONITOR_N_GLOBAL_STATES]; | |
25699 | TreeFragment *vmfragments[FRAGMENT_TABLE_SIZE]; | |
25700 | RecordAttemptMap* recordAttempts; | |
25701 | ||
25702 | ||
25703 | LoopProfileMap* loopProfiles; | |
25704 | ||
25705 | ||
25706 | ||
25707 | ||
25708 | ||
25709 | uint32 maxCodeCacheBytes; | |
25710 | ||
25711 | ||
25712 | ||
25713 | ||
25714 | ||
25715 | ||
25716 | JSBool needFlush; | |
25717 | ||
25718 | ||
25719 | ||
25720 | ||
25721 | TypeMap* cachedTempTypeMap; | |
25722 | ||
25723 | ||
25724 | TracedScriptSet tracedScripts; | |
25725 | # 270 "jscompartment.h" | |
25726 | bool ontrace() const { | |
25727 | return !!tracecx; | |
25728 | } | |
25729 | ||
25730 | ||
25731 | void flush(); | |
25732 | ||
25733 | ||
25734 | void sweep(JSContext *cx); | |
25735 | ||
25736 | ||
25737 | void mark(JSTracer *trc); | |
25738 | ||
25739 | bool outOfMemory() const; | |
25740 | }; | |
25741 | ||
25742 | namespace mjit { | |
25743 | class JaegerCompartment; | |
25744 | } | |
25745 | } | |
25746 | # 308 "jscompartment.h" | |
25747 | namespace js { | |
25748 | ||
25749 | class NativeIterCache { | |
25750 | static const size_t SIZE = size_t(1) << 8; | |
25751 | ||
25752 | ||
25753 | JSObject *data[SIZE]; | |
25754 | ||
25755 | static size_t getIndex(uint32 key) { | |
25756 | return size_t(key) % SIZE; | |
25757 | } | |
25758 | ||
25759 | public: | |
25760 | ||
25761 | JSObject *last; | |
25762 | ||
25763 | NativeIterCache() | |
25764 | : last(__null) { | |
25765 | PodArrayZero(data); | |
25766 | } | |
25767 | ||
25768 | void purge() { | |
25769 | PodArrayZero(data); | |
25770 | last = __null; | |
25771 | } | |
25772 | ||
25773 | JSObject *get(uint32 key) const { | |
25774 | return data[getIndex(key)]; | |
25775 | } | |
25776 | ||
25777 | void set(uint32 key, JSObject *iterobj) { | |
25778 | data[getIndex(key)] = iterobj; | |
25779 | } | |
25780 | }; | |
25781 | # 350 "jscompartment.h" | |
25782 | class DtoaCache { | |
25783 | double d; | |
25784 | jsint base; | |
25785 | JSString *s; | |
25786 | public: | |
25787 | DtoaCache() : s(__null) {} | |
25788 | void purge() { s = __null; } | |
25789 | ||
25790 | JSString *lookup(jsint base, double d) { | |
25791 | return this->s && base == this->base && d == this->d ? this->s : __null; | |
25792 | } | |
25793 | ||
25794 | void cache(jsint base, double d, JSString *s) { | |
25795 | this->base = base; | |
25796 | this->d = d; | |
25797 | this->s = s; | |
25798 | } | |
25799 | ||
25800 | }; | |
25801 | ||
25802 | } | |
25803 | ||
25804 | struct __attribute__((visibility ("default"))) JSCompartment { | |
25805 | JSRuntime *rt; | |
25806 | JSPrincipals *principals; | |
25807 | js::gc::Chunk *chunk; | |
25808 | ||
25809 | js::gc::ArenaList arenas[js::gc::FINALIZE_LIMIT]; | |
25810 | js::gc::FreeLists freeLists; | |
25811 | ||
25812 | size_t gcBytes; | |
25813 | size_t gcTriggerBytes; | |
25814 | size_t gcLastBytes; | |
25815 | # 394 "jscompartment.h" | |
25816 | JSScript *scriptsToGC[((JSUint32)1 << (6))]; | |
25817 | ||
25818 | ||
25819 | ||
25820 | ||
25821 | ||
25822 | void *data; | |
25823 | bool active; | |
25824 | js::WrapperMap crossCompartmentWrappers; | |
25825 | # 411 "jscompartment.h" | |
25826 | js::PropertyTree propertyTree; | |
25827 | # 425 "jscompartment.h" | |
25828 | js::EmptyShape *emptyArgumentsShape; | |
25829 | js::EmptyShape *emptyBlockShape; | |
25830 | js::EmptyShape *emptyCallShape; | |
25831 | js::EmptyShape *emptyDeclEnvShape; | |
25832 | js::EmptyShape *emptyEnumeratorShape; | |
25833 | js::EmptyShape *emptyWithShape; | |
25834 | ||
25835 | typedef js::HashSet<js::EmptyShape *, | |
25836 | js::DefaultHasher<js::EmptyShape *>, | |
25837 | js::SystemAllocPolicy> EmptyShapeSet; | |
25838 | ||
25839 | EmptyShapeSet emptyShapes; | |
25840 | ||
25841 | bool debugMode; | |
25842 | JSCList scripts; | |
25843 | ||
25844 | JSC::ExecutableAllocator *regExpAllocator; | |
25845 | ||
25846 | js::NativeIterCache nativeIterCache; | |
25847 | ||
25848 | js::ToSourceCache toSourceCache; | |
25849 | ||
25850 | JSCompartment(JSRuntime *rt); | |
25851 | ~JSCompartment(); | |
25852 | ||
25853 | bool init(); | |
25854 | ||
25855 | ||
25856 | void markCrossCompartment(JSTracer *trc); | |
25857 | ||
25858 | ||
25859 | void mark(JSTracer *trc); | |
25860 | ||
25861 | bool wrap(JSContext *cx, js::Value *vp); | |
25862 | bool wrap(JSContext *cx, JSString **strp); | |
25863 | bool wrap(JSContext *cx, JSObject **objp); | |
25864 | bool wrapId(JSContext *cx, jsid *idp); | |
25865 | bool wrap(JSContext *cx, js::PropertyOp *op); | |
25866 | bool wrap(JSContext *cx, js::StrictPropertyOp *op); | |
25867 | bool wrap(JSContext *cx, js::PropertyDescriptor *desc); | |
25868 | bool wrap(JSContext *cx, js::AutoIdVector &props); | |
25869 | ||
25870 | void sweep(JSContext *cx, uint32 releaseInterval); | |
25871 | void purge(JSContext *cx); | |
25872 | void finishArenaLists(); | |
25873 | void finalizeObjectArenaLists(JSContext *cx); | |
25874 | void finalizeStringArenaLists(JSContext *cx); | |
25875 | bool arenaListsAreEmpty(); | |
25876 | ||
25877 | void setGCLastBytes(size_t lastBytes); | |
25878 | ||
25879 | js::DtoaCache dtoaCache; | |
25880 | ||
25881 | private: | |
25882 | js::MathCache *mathCache; | |
25883 | ||
25884 | js::MathCache *allocMathCache(JSContext *cx); | |
25885 | ||
25886 | bool marked; | |
25887 | ||
25888 | typedef js::HashMap<jsbytecode*, | |
25889 | size_t, | |
25890 | js::DefaultHasher<jsbytecode*>, | |
25891 | js::SystemAllocPolicy> BackEdgeMap; | |
25892 | ||
25893 | BackEdgeMap backEdgeTable; | |
25894 | ||
25895 | JSCompartment *thisForCtor() { return this; } | |
25896 | public: | |
25897 | js::MathCache *getMathCache(JSContext *cx) { | |
25898 | return mathCache ? mathCache : allocMathCache(cx); | |
25899 | } | |
25900 | ||
25901 | bool isMarked() { return marked; } | |
25902 | void clearMark() { marked = false; } | |
25903 | ||
25904 | size_t backEdgeCount(jsbytecode *pc) const; | |
25905 | size_t incBackEdgeCount(jsbytecode *pc); | |
25906 | }; | |
25907 | # 519 "jscompartment.h" | |
25908 | static inline | |
25909 | ||
25910 | # 519 "jscompartment.h" | |
25911 | bool | |
25912 | JS_ON_TRACE(JSContext *cx) | |
25913 | { | |
25914 | ||
25915 | ||
25916 | ||
25917 | ||
25918 | return false; | |
25919 | } | |
25920 | # 549 "jscompartment.h" | |
25921 | static inline js::TraceRecorder * | |
25922 | TRACE_RECORDER(JSContext *cx) | |
25923 | { | |
25924 | ||
25925 | ||
25926 | ||
25927 | ||
25928 | return __null; | |
25929 | } | |
25930 | ||
25931 | static inline js::LoopProfile * | |
25932 | TRACE_PROFILER(JSContext *cx) | |
25933 | { | |
25934 | ||
25935 | ||
25936 | ||
25937 | ||
25938 | return __null; | |
25939 | } | |
25940 | ||
25941 | namespace js { | |
25942 | static inline MathCache * | |
25943 | GetMathCache(JSContext *cx) | |
25944 | { | |
25945 | return cx->compartment->getMathCache(cx); | |
25946 | } | |
25947 | } | |
25948 | # 587 "jscompartment.h" | |
25949 | namespace js { | |
25950 | ||
25951 | class PreserveCompartment { | |
25952 | protected: | |
25953 | JSContext *cx; | |
25954 | private: | |
25955 | JSCompartment *oldCompartment; | |
25956 | ||
25957 | public: | |
25958 | PreserveCompartment(JSContext *cx ) : cx(cx) { | |
25959 | do { } while (0); | |
25960 | oldCompartment = cx->compartment; | |
25961 | } | |
25962 | ||
25963 | ~PreserveCompartment() { | |
25964 | cx->compartment = oldCompartment; | |
25965 | } | |
25966 | }; | |
25967 | ||
25968 | class SwitchToCompartment : public PreserveCompartment { | |
25969 | public: | |
25970 | SwitchToCompartment(JSContext *cx, JSCompartment *newCompartment) : PreserveCompartment(cx) { | |
25971 | cx->compartment = newCompartment; | |
25972 | } | |
25973 | ||
25974 | SwitchToCompartment(JSContext *cx, JSObject *target) : PreserveCompartment(cx) { | |
25975 | cx->compartment = target->getCompartment(); | |
25976 | } | |
25977 | }; | |
25978 | ||
25979 | class AssertCompartmentUnchanged { | |
25980 | protected: | |
25981 | JSContext * const cx; | |
25982 | JSCompartment * const oldCompartment; | |
25983 | ||
25984 | public: | |
25985 | AssertCompartmentUnchanged(JSContext *cx ) | |
25986 | : cx(cx), oldCompartment(cx->compartment) { | |
25987 | do { } while (0); | |
25988 | } | |
25989 | ||
25990 | ~AssertCompartmentUnchanged() { | |
25991 | ((void) 0); | |
25992 | } | |
25993 | }; | |
25994 | ||
25995 | } | |
25996 | # 54 "jsscope.h" 2 | |
25997 | ||
25998 | ||
25999 | ||
26000 | ||
26001 | ||
26002 | # 1 "jsstrinlines.h" 1 | |
26003 | # 44 "jsstrinlines.h" | |
26004 | # 1 "jscntxtinlines.h" 1 | |
26005 | # 49 "jscntxtinlines.h" | |
26006 | # 1 "jsregexp.h" 1 | |
26007 | # 45 "jsregexp.h" | |
26008 | # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stddef.h" 1 3 4 | |
26009 | # 46 "jsregexp.h" 2 | |
26010 | # 55 "jsregexp.h" | |
26011 | extern js::Class js_RegExpClass; | |
26012 | ||
26013 | namespace js { | |
26014 | ||
26015 | class RegExpStatics | |
26016 | { | |
26017 | typedef Vector<int, 20, SystemAllocPolicy> MatchPairs; | |
26018 | MatchPairs matchPairs; | |
26019 | ||
26020 | JSLinearString *matchPairsInput; | |
26021 | ||
26022 | JSString *pendingInput; | |
26023 | uintN flags; | |
26024 | RegExpStatics *bufferLink; | |
26025 | bool copied; | |
26026 | ||
26027 | bool createDependent(JSContext *cx, size_t start, size_t end, Value *out) const; | |
26028 | ||
26029 | void copyTo(RegExpStatics &dst) { | |
26030 | dst.matchPairs.clear(); | |
26031 | ||
26032 | ((void) (dst.matchPairs.append(matchPairs))); | |
26033 | dst.matchPairsInput = matchPairsInput; | |
26034 | dst.pendingInput = pendingInput; | |
26035 | dst.flags = flags; | |
26036 | } | |
26037 | ||
26038 | void aboutToWrite() { | |
26039 | if (bufferLink && !bufferLink->copied) { | |
26040 | copyTo(*bufferLink); | |
26041 | bufferLink->copied = true; | |
26042 | } | |
26043 | } | |
26044 | ||
26045 | bool save(JSContext *cx, RegExpStatics *buffer) { | |
26046 | ((void) 0); | |
26047 | buffer->bufferLink = bufferLink; | |
26048 | bufferLink = buffer; | |
26049 | if (!buffer->matchPairs.reserve(matchPairs.length())) { | |
26050 | js_ReportOutOfMemory(cx); | |
26051 | return false; | |
26052 | } | |
26053 | return true; | |
26054 | } | |
26055 | ||
26056 | void restore() { | |
26057 | if (bufferLink->copied) | |
26058 | bufferLink->copyTo(*this); | |
26059 | bufferLink = bufferLink->bufferLink; | |
26060 | } | |
26061 | ||
26062 | void checkInvariants() { | |
26063 | # 130 "jsregexp.h" | |
26064 | } | |
26065 | ||
26066 | ||
26067 | ||
26068 | ||
26069 | ||
26070 | void checkParenNum(size_t pairNum) const { | |
26071 | ((void) 0); | |
26072 | ((void) 0); | |
26073 | } | |
26074 | ||
26075 | bool pairIsPresent(size_t pairNum) const { | |
26076 | return get(pairNum, 0) >= 0; | |
26077 | } | |
26078 | ||
26079 | ||
26080 | size_t getParenLength(size_t pairNum) const { | |
26081 | checkParenNum(pairNum); | |
26082 | ((void) 0); | |
26083 | return get(pairNum, 1) - get(pairNum, 0); | |
26084 | } | |
26085 | ||
26086 | int get(size_t pairNum, bool which) const { | |
26087 | ((void) 0); | |
26088 | return matchPairs[2 * pairNum + which]; | |
26089 | } | |
26090 | ||
26091 | ||
26092 | ||
26093 | ||
26094 | ||
26095 | ||
26096 | bool makeMatch(JSContext *cx, size_t checkValidIndex, size_t pairNum, Value *out) const; | |
26097 | ||
26098 | static const uintN allFlags = 0x01 | 0x02 | 0x08 | 0x04; | |
26099 | ||
26100 | struct InitBuffer {}; | |
26101 | explicit RegExpStatics(InitBuffer) : bufferLink(__null), copied(false) {} | |
26102 | ||
26103 | friend class PreserveRegExpStatics; | |
26104 | ||
26105 | public: | |
26106 | RegExpStatics() : bufferLink(__null), copied(false) { clear(); } | |
26107 | ||
26108 | static RegExpStatics *extractFrom(JSObject *global); | |
26109 | ||
26110 | ||
26111 | ||
26112 | bool updateFromMatch(JSContext *cx, JSLinearString *input, int *buf, size_t matchItemCount) { | |
26113 | aboutToWrite(); | |
26114 | pendingInput = input; | |
26115 | ||
26116 | if (!matchPairs.resizeUninitialized(matchItemCount)) { | |
26117 | js_ReportOutOfMemory(cx); | |
26118 | return false; | |
26119 | } | |
26120 | ||
26121 | for (size_t i = 0; i < matchItemCount; ++i) | |
26122 | matchPairs[i] = buf[i]; | |
26123 | ||
26124 | matchPairsInput = input; | |
26125 | return true; | |
26126 | } | |
26127 | ||
26128 | void setMultiline(bool enabled) { | |
26129 | aboutToWrite(); | |
26130 | if (enabled) | |
26131 | flags = flags | 0x04; | |
26132 | else | |
26133 | flags = flags & ~0x04; | |
26134 | } | |
26135 | ||
26136 | void clear() { | |
26137 | aboutToWrite(); | |
26138 | flags = 0; | |
26139 | pendingInput = __null; | |
26140 | matchPairsInput = __null; | |
26141 | matchPairs.clear(); | |
26142 | } | |
26143 | ||
26144 | ||
26145 | void reset(JSString *newInput, bool newMultiline) { | |
26146 | aboutToWrite(); | |
26147 | clear(); | |
26148 | pendingInput = newInput; | |
26149 | setMultiline(newMultiline); | |
26150 | checkInvariants(); | |
26151 | } | |
26152 | ||
26153 | void setPendingInput(JSString *newInput) { | |
26154 | aboutToWrite(); | |
26155 | pendingInput = newInput; | |
26156 | } | |
26157 | # 233 "jsregexp.h" | |
26158 | private: | |
26159 | size_t pairCount() const { | |
26160 | ((void) 0); | |
26161 | return matchPairs.length() / 2; | |
26162 | } | |
26163 | ||
26164 | public: | |
26165 | size_t parenCount() const { | |
26166 | size_t pc = pairCount(); | |
26167 | ((void) 0); | |
26168 | return pc - 1; | |
26169 | } | |
26170 | ||
26171 | JSString *getPendingInput() const { return pendingInput; } | |
26172 | uintN getFlags() const { return flags; } | |
26173 | bool multiline() const { return flags & 0x04; } | |
26174 | ||
26175 | size_t matchStart() const { | |
26176 | int start = get(0, 0); | |
26177 | ((void) 0); | |
26178 | return size_t(start); | |
26179 | } | |
26180 | ||
26181 | size_t matchLimit() const { | |
26182 | int limit = get(0, 1); | |
26183 | ((void) 0); | |
26184 | return size_t(limit); | |
26185 | } | |
26186 | ||
26187 | ||
26188 | bool matched() const { | |
26189 | ((void) 0); | |
26190 | ((void) 0); | |
26191 | return get(0, 1) - get(0, 0) > 0; | |
26192 | } | |
26193 | ||
26194 | void mark(JSTracer *trc) const { | |
26195 | if (pendingInput) | |
26196 | do { JSString *str_ = (pendingInput); ((void) 0); do { do { } while (0); JS_CallTracer(((trc)), (str_), (1)); } while (0); } while (0); | |
26197 | if (matchPairsInput) | |
26198 | do { JSString *str_ = (matchPairsInput); ((void) 0); do { do { } while (0); JS_CallTracer(((trc)), (str_), (1)); } while (0); } while (0); | |
26199 | } | |
26200 | ||
26201 | ||
26202 | ||
26203 | bool createPendingInput(JSContext *cx, Value *out) const; | |
26204 | bool createLastMatch(JSContext *cx, Value *out) const { return makeMatch(cx, 0, 0, out); } | |
26205 | bool createLastParen(JSContext *cx, Value *out) const; | |
26206 | bool createLeftContext(JSContext *cx, Value *out) const; | |
26207 | bool createRightContext(JSContext *cx, Value *out) const; | |
26208 | ||
26209 | ||
26210 | bool createParen(JSContext *cx, size_t pairNum, Value *out) const { | |
26211 | ((void) 0); | |
26212 | if (pairNum >= pairCount()) { | |
26213 | out->setString(cx->runtime->emptyString); | |
26214 | return true; | |
26215 | } | |
26216 | return makeMatch(cx, pairNum * 2, pairNum, out); | |
26217 | } | |
26218 | ||
26219 | ||
26220 | ||
26221 | void getParen(size_t pairNum, JSSubString *out) const; | |
26222 | void getLastMatch(JSSubString *out) const; | |
26223 | void getLastParen(JSSubString *out) const; | |
26224 | void getLeftContext(JSSubString *out) const; | |
26225 | void getRightContext(JSSubString *out) const; | |
26226 | }; | |
26227 | ||
26228 | class PreserveRegExpStatics | |
26229 | { | |
26230 | RegExpStatics *const original; | |
26231 | RegExpStatics buffer; | |
26232 | ||
26233 | public: | |
26234 | explicit PreserveRegExpStatics(RegExpStatics *original) | |
26235 | : original(original), | |
26236 | buffer(RegExpStatics::InitBuffer()) | |
26237 | {} | |
26238 | ||
26239 | bool init(JSContext *cx) { | |
26240 | return original->save(cx, &buffer); | |
26241 | } | |
26242 | ||
26243 | ~PreserveRegExpStatics() { | |
26244 | original->restore(); | |
26245 | } | |
26246 | }; | |
26247 | ||
26248 | } | |
26249 | ||
26250 | static inline | |
26251 | ||
26252 | # 325 "jsregexp.h" | |
26253 | bool | |
26254 | VALUE_IS_REGEXP(JSContext *cx, js::Value v) | |
26255 | { | |
26256 | return !v.isPrimitive() && v.toObject().isRegExp(); | |
26257 | } | |
26258 | ||
26259 | inline const js::Value & | |
26260 | JSObject::getRegExpLastIndex() const | |
26261 | { | |
26262 | ((void) 0); | |
26263 | return getSlot(JSSLOT_REGEXP_LAST_INDEX); | |
26264 | } | |
26265 | ||
26266 | inline void | |
26267 | JSObject::setRegExpLastIndex(const js::Value &v) | |
26268 | { | |
26269 | ((void) 0); | |
26270 | setSlot(JSSLOT_REGEXP_LAST_INDEX, v); | |
26271 | } | |
26272 | ||
26273 | inline void | |
26274 | JSObject::setRegExpLastIndex(jsdouble d) | |
26275 | { | |
26276 | ((void) 0); | |
26277 | setSlot(JSSLOT_REGEXP_LAST_INDEX, js::NumberValue(d)); | |
26278 | } | |
26279 | ||
26280 | inline void | |
26281 | JSObject::zeroRegExpLastIndex() | |
26282 | { | |
26283 | ((void) 0); | |
26284 | getSlotRef(JSSLOT_REGEXP_LAST_INDEX).setInt32(0); | |
26285 | } | |
26286 | ||
26287 | namespace js { class AutoStringRooter; } | |
26288 | ||
26289 | inline | |
26290 | ||
26291 | # 361 "jsregexp.h" | |
26292 | bool | |
26293 | JSObject::isRegExp() const | |
26294 | { | |
26295 | return getClass() == &js_RegExpClass; | |
26296 | } | |
26297 | ||
26298 | extern __attribute__((visibility ("default"))) JSBool | |
26299 | js_ObjectIsRegExp(JSObject *obj); | |
26300 | ||
26301 | extern JSObject * | |
26302 | js_InitRegExpClass(JSContext *cx, JSObject *obj); | |
26303 | ||
26304 | ||
26305 | ||
26306 | ||
26307 | extern JSBool | |
26308 | js_regexp_toString(JSContext *cx, JSObject *obj, js::Value *vp); | |
26309 | ||
26310 | extern __attribute__((visibility ("default"))) JSObject * | |
26311 | js_CloneRegExpObject(JSContext *cx, JSObject *obj, JSObject *proto); | |
26312 | ||
26313 | ||
26314 | ||
26315 | ||
26316 | ||
26317 | extern __attribute__((visibility ("default"))) void | |
26318 | js_SaveAndClearRegExpStatics(JSContext *cx, js::RegExpStatics *res, js::AutoStringRooter *tvr); | |
26319 | ||
26320 | ||
26321 | extern __attribute__((visibility ("default"))) void | |
26322 | js_RestoreRegExpStatics(JSContext *cx, js::RegExpStatics *res); | |
26323 | ||
26324 | extern JSBool | |
26325 | js_XDRRegExpObject(JSXDRState *xdr, JSObject **objp); | |
26326 | ||
26327 | extern JSBool | |
26328 | js_regexp_exec(JSContext *cx, uintN argc, js::Value *vp); | |
26329 | extern JSBool | |
26330 | js_regexp_test(JSContext *cx, uintN argc, js::Value *vp); | |
26331 | # 50 "jscntxtinlines.h" 2 | |
26332 | ||
26333 | ||
26334 | namespace js { | |
26335 | ||
26336 | static inline JSObject * | |
26337 | GetGlobalForScopeChain(JSContext *cx) | |
26338 | { | |
26339 | # 65 "jscntxtinlines.h" | |
26340 | ((void) 0); | |
26341 | ||
26342 | if (cx->hasfp()) | |
26343 | return cx->fp()->scopeChain().getGlobal(); | |
26344 | ||
26345 | JSObject *scope = cx->globalObject; | |
26346 | if (!scope) { | |
26347 | JS_ReportErrorNumber(cx, js_GetErrorMessage, __null, JSMSG_INACTIVE); | |
26348 | return __null; | |
26349 | } | |
26350 | OBJ_TO_INNER_OBJECT(cx, scope); | |
26351 | return scope; | |
26352 | } | |
26353 | ||
26354 | } | |
26355 | # 88 "jscntxtinlines.h" | |
26356 | inline | |
26357 | ||
26358 | # 88 "jscntxtinlines.h" | |
26359 | bool | |
26360 | JSContext::ensureGeneratorStackSpace() | |
26361 | { | |
26362 | bool ok = genStack.reserve(genStack.length() + 1); | |
26363 | if (!ok) | |
26364 | js_ReportOutOfMemory(this); | |
26365 | return ok; | |
26366 | } | |
26367 | ||
26368 | JSStackFrame * | |
26369 | JSContext::computeNextFrame(JSStackFrame *fp) | |
26370 | { | |
26371 | JSStackFrame *next = __null; | |
26372 | for (js::StackSegment *ss = currentSegment; ; ss = ss->getPreviousInContext()) { | |
26373 | JSStackFrame *end = ss->getInitialFrame()->prev(); | |
26374 | for (JSStackFrame *f = ss->getCurrentFrame(); f != end; next = f, f = f->prev()) { | |
26375 | if (f == fp) | |
26376 | return next; | |
26377 | } | |
26378 | if (end != ss->getPreviousInContext()->getCurrentFrame()) | |
26379 | next = __null; | |
26380 | } | |
26381 | } | |
26382 | ||
26383 | inline js::RegExpStatics * | |
26384 | JSContext::regExpStatics() | |
26385 | { | |
26386 | return js::RegExpStatics::extractFrom(js::GetGlobalForScopeChain(this)); | |
26387 | } | |
26388 | ||
26389 | namespace js { | |
26390 | ||
26391 | __attribute__((always_inline)) inline JSFrameRegs * | |
26392 | StackSegment::getCurrentRegs() const | |
26393 | { | |
26394 | ((void) 0); | |
26395 | return isActive() ? cx->regs : getSuspendedRegs(); | |
26396 | } | |
26397 | ||
26398 | __attribute__((always_inline)) inline JSStackFrame * | |
26399 | StackSegment::getCurrentFrame() const | |
26400 | { | |
26401 | return getCurrentRegs()->fp; | |
26402 | } | |
26403 | ||
26404 | inline Value * | |
26405 | StackSpace::firstUnused() const | |
26406 | { | |
26407 | StackSegment *seg = currentSegment; | |
26408 | if (!seg) { | |
26409 | ((void) 0); | |
26410 | return base; | |
26411 | } | |
26412 | if (seg->inContext()) { | |
26413 | Value *sp = seg->getCurrentRegs()->sp; | |
26414 | if (invokeArgEnd > sp) { | |
26415 | ((void) 0); | |
26416 | ((void) 0) | |
26417 | ; | |
26418 | return invokeArgEnd; | |
26419 | } | |
26420 | return sp; | |
26421 | } | |
26422 | ((void) 0); | |
26423 | ((void) 0); | |
26424 | return invokeArgEnd; | |
26425 | } | |
26426 | ||
26427 | ||
26428 | ||
26429 | __attribute__((always_inline)) inline | |
26430 | ||
26431 | # 158 "jscntxtinlines.h" | |
26432 | bool | |
26433 | StackSpace::isCurrentAndActive(JSContext *cx) const | |
26434 | { | |
26435 | ||
26436 | ||
26437 | ||
26438 | ||
26439 | ||
26440 | return currentSegment && | |
26441 | currentSegment->isActive() && | |
26442 | currentSegment == cx->getCurrentSegment(); | |
26443 | } | |
26444 | ||
26445 | ||
26446 | __attribute__((always_inline)) inline | |
26447 | ||
26448 | # 172 "jscntxtinlines.h" | |
26449 | bool | |
26450 | StackSpace::ensureSpace(JSContext *maybecx, Value *from, ptrdiff_t nvals) const | |
26451 | { | |
26452 | ((void) 0); | |
26453 | # 192 "jscntxtinlines.h" | |
26454 | if (end - from < nvals) { | |
26455 | if (maybecx) | |
26456 | js_ReportOutOfScriptQuota(maybecx); | |
26457 | return false; | |
26458 | } | |
26459 | goto success; | |
26460 | ||
26461 | success: | |
26462 | ||
26463 | ||
26464 | ||
26465 | return true; | |
26466 | } | |
26467 | ||
26468 | __attribute__((always_inline)) inline | |
26469 | ||
26470 | # 206 "jscntxtinlines.h" | |
26471 | bool | |
26472 | StackSpace::ensureEnoughSpaceToEnterTrace() | |
26473 | { | |
26474 | ||
26475 | ||
26476 | ||
26477 | return end - firstUnused() > MAX_TRACE_SPACE_VALS; | |
26478 | } | |
26479 | ||
26480 | __attribute__((always_inline)) inline | |
26481 | ||
26482 | # 215 "jscntxtinlines.h" | |
26483 | bool | |
26484 | StackSpace::EnsureSpaceCheck::operator()(const StackSpace &stack, JSContext *cx, | |
26485 | Value *from, uintN nvals) | |
26486 | { | |
26487 | return stack.ensureSpace(cx, from, nvals); | |
26488 | } | |
26489 | ||
26490 | __attribute__((always_inline)) inline | |
26491 | ||
26492 | # 222 "jscntxtinlines.h" | |
26493 | bool | |
26494 | StackSpace::LimitCheck::operator()(const StackSpace &stack, JSContext *cx, | |
26495 | Value *from, uintN nvals) | |
26496 | { | |
26497 | ((void) 0); | |
26498 | ((void) 0); | |
26499 | if (*limit - from >= ptrdiff_t(nvals)) | |
26500 | return true; | |
26501 | if (stack.bumpCommitAndLimit(base, from, nvals, limit)) | |
26502 | return true; | |
26503 | js_ReportOverRecursed(cx); | |
26504 | return false; | |
26505 | } | |
26506 | ||
26507 | __attribute__((always_inline)) inline | |
26508 | ||
26509 | # 236 "jscntxtinlines.h" | |
26510 | bool | |
26511 | StackSpace::pushInvokeArgs(JSContext *cx, uintN argc, InvokeArgsGuard *ag) | |
26512 | { | |
26513 | if ((__builtin_expect((!isCurrentAndActive(cx)), 0))) | |
26514 | return pushSegmentForInvoke(cx, argc, ag); | |
26515 | ||
26516 | Value *sp = cx->regs->sp; | |
26517 | Value *start = invokeArgEnd > sp ? invokeArgEnd : sp; | |
26518 | ((void) 0); | |
26519 | uintN nvals = 2 + argc; | |
26520 | if (!ensureSpace(cx, start, nvals)) | |
26521 | return false; | |
26522 | ||
26523 | Value *vp = start; | |
26524 | Value *vpend = vp + nvals; | |
26525 | ||
26526 | ||
26527 | ||
26528 | ag->prevInvokeArgEnd = invokeArgEnd; | |
26529 | invokeArgEnd = vpend; | |
26530 | ||
26531 | ||
26532 | ||
26533 | ||
26534 | ||
26535 | ||
26536 | ||
26537 | ag->cx = cx; | |
26538 | ag->argv_ = vp + 2; | |
26539 | ag->argc_ = argc; | |
26540 | return true; | |
26541 | } | |
26542 | ||
26543 | __attribute__((always_inline)) inline void | |
26544 | StackSpace::popInvokeArgs(const InvokeArgsGuard &ag) | |
26545 | { | |
26546 | if ((__builtin_expect((ag.seg != __null), 0))) { | |
26547 | popSegmentForInvoke(ag); | |
26548 | return; | |
26549 | } | |
26550 | ||
26551 | ((void) 0); | |
26552 | ((void) 0); | |
26553 | ((void) 0); | |
26554 | ((void) 0); | |
26555 | ||
26556 | ||
26557 | ||
26558 | ||
26559 | ||
26560 | invokeArgEnd = ag.prevInvokeArgEnd; | |
26561 | } | |
26562 | ||
26563 | __attribute__((always_inline)) inline | |
26564 | InvokeArgsGuard::~InvokeArgsGuard() | |
26565 | { | |
26566 | if ((__builtin_expect((!pushed()), 0))) | |
26567 | return; | |
26568 | cx->stack().popInvokeArgs(*this); | |
26569 | } | |
26570 | ||
26571 | template <class Check> | |
26572 | __attribute__((always_inline)) inline JSStackFrame * | |
26573 | StackSpace::getCallFrame(JSContext *cx, Value *firstUnused, uintN nactual, | |
26574 | JSFunction *fun, JSScript *script, uint32 *flags, | |
26575 | Check check) const | |
26576 | { | |
26577 | ((void) 0); | |
26578 | ||
26579 | ||
26580 | uintN nvals = VALUES_PER_STACK_FRAME + script->nslots; | |
26581 | uintN nformal = fun->nargs; | |
26582 | ||
26583 | ||
26584 | ||
26585 | if (nactual == nformal) { | |
26586 | if ((__builtin_expect((!check(*this, cx, firstUnused, nvals)), 0))) | |
26587 | return __null; | |
26588 | return reinterpret_cast<JSStackFrame *>(firstUnused); | |
26589 | } | |
26590 | ||
26591 | if (nactual < nformal) { | |
26592 | *flags |= JSFRAME_UNDERFLOW_ARGS; | |
26593 | uintN nmissing = nformal - nactual; | |
26594 | if ((__builtin_expect((!check(*this, cx, firstUnused, nmissing + nvals)), 0))) | |
26595 | return __null; | |
26596 | SetValueRangeToUndefined(firstUnused, nmissing); | |
26597 | return reinterpret_cast<JSStackFrame *>(firstUnused + nmissing); | |
26598 | } | |
26599 | ||
26600 | *flags |= JSFRAME_OVERFLOW_ARGS; | |
26601 | uintN ncopy = 2 + nformal; | |
26602 | if ((__builtin_expect((!check(*this, cx, firstUnused, ncopy + nvals)), 0))) | |
26603 | return __null; | |
26604 | ||
26605 | Value *dst = firstUnused; | |
26606 | Value *src = firstUnused - (2 + nactual); | |
26607 | PodCopy(dst, src, ncopy); | |
26608 | Debug_SetValueRangeToCrashOnTouch(src, ncopy); | |
26609 | return reinterpret_cast<JSStackFrame *>(firstUnused + ncopy); | |
26610 | } | |
26611 | ||
26612 | __attribute__((always_inline)) inline | |
26613 | ||
26614 | # 338 "jscntxtinlines.h" | |
26615 | bool | |
26616 | StackSpace::getInvokeFrame(JSContext *cx, const CallArgs &args, | |
26617 | JSFunction *fun, JSScript *script, | |
26618 | uint32 *flags, InvokeFrameGuard *fg) const | |
26619 | { | |
26620 | ((void) 0); | |
26621 | ||
26622 | Value *firstUnused = args.argv() + args.argc(); | |
26623 | fg->regs_.fp = getCallFrame(cx, firstUnused, args.argc(), fun, script, flags, | |
26624 | EnsureSpaceCheck()); | |
26625 | fg->regs_.sp = fg->regs_.fp->slots() + script->nfixed; | |
26626 | fg->regs_.pc = script->code; | |
26627 | ||
26628 | return fg->regs_.fp != __null; | |
26629 | } | |
26630 | ||
26631 | __attribute__((always_inline)) inline void | |
26632 | StackSpace::pushInvokeFrame(JSContext *cx, const CallArgs &args, | |
26633 | InvokeFrameGuard *fg) | |
26634 | { | |
26635 | ((void) 0); | |
26636 | ||
26637 | if ((__builtin_expect((!currentSegment->inContext()), 0))) { | |
26638 | cx->pushSegmentAndFrame(currentSegment, fg->regs_); | |
26639 | } else { | |
26640 | fg->prevRegs_ = cx->regs; | |
26641 | cx->setCurrentRegs(&fg->regs_); | |
26642 | } | |
26643 | ||
26644 | fg->cx_ = cx; | |
26645 | ((void) 0); | |
26646 | } | |
26647 | ||
26648 | __attribute__((always_inline)) inline void | |
26649 | StackSpace::popInvokeFrame(const InvokeFrameGuard &fg) | |
26650 | { | |
26651 | JSContext *cx = fg.cx_; | |
26652 | JSStackFrame *fp = fg.regs_.fp; | |
26653 | ||
26654 | ((void) 0); | |
26655 | if ((__builtin_expect((currentSegment->getInitialFrame() == fp), 0))) { | |
26656 | cx->popSegmentAndFrame(); | |
26657 | } else { | |
26658 | ((void) 0); | |
26659 | ((void) 0); | |
26660 | ((void) 0); | |
26661 | cx->setCurrentRegs(fg.prevRegs_); | |
26662 | } | |
26663 | } | |
26664 | ||
26665 | __attribute__((always_inline)) inline void | |
26666 | InvokeFrameGuard::pop() | |
26667 | { | |
26668 | ((void) 0); | |
26669 | cx_->stack().popInvokeFrame(*this); | |
26670 | cx_ = __null; | |
26671 | } | |
26672 | ||
26673 | __attribute__((always_inline)) inline JSStackFrame * | |
26674 | StackSpace::getInlineFrame(JSContext *cx, Value *sp, uintN nactual, | |
26675 | JSFunction *fun, JSScript *script, uint32 *flags) const | |
26676 | { | |
26677 | ((void) 0); | |
26678 | ((void) 0); | |
26679 | ((void) 0); | |
26680 | ||
26681 | return getCallFrame(cx, sp, nactual, fun, script, flags, EnsureSpaceCheck()); | |
26682 | } | |
26683 | ||
26684 | __attribute__((always_inline)) inline JSStackFrame * | |
26685 | StackSpace::getInlineFrameWithinLimit(JSContext *cx, Value *sp, uintN nactual, | |
26686 | JSFunction *fun, JSScript *script, uint32 *flags, | |
26687 | JSStackFrame *base, Value **limit) const | |
26688 | { | |
26689 | ((void) 0); | |
26690 | ((void) 0); | |
26691 | ((void) 0); | |
26692 | ||
26693 | return getCallFrame(cx, sp, nactual, fun, script, flags, LimitCheck(base, limit)); | |
26694 | } | |
26695 | ||
26696 | __attribute__((always_inline)) inline void | |
26697 | StackSpace::pushInlineFrame(JSContext *cx, JSScript *script, JSStackFrame *fp, | |
26698 | JSFrameRegs *regs) | |
26699 | { | |
26700 | ((void) 0); | |
26701 | ((void) 0); | |
26702 | ||
26703 | regs->fp = fp; | |
26704 | regs->pc = script->code; | |
26705 | regs->sp = fp->slots() + script->nfixed; | |
26706 | } | |
26707 | ||
26708 | __attribute__((always_inline)) inline void | |
26709 | StackSpace::popInlineFrame(JSContext *cx, JSStackFrame *prev, Value *newsp) | |
26710 | { | |
26711 | ((void) 0); | |
26712 | ((void) 0); | |
26713 | ((void) 0); | |
26714 | ((void) 0); | |
26715 | ((void) 0); | |
26716 | ||
26717 | JSFrameRegs *regs = cx->regs; | |
26718 | regs->pc = prev->pc(cx, regs->fp); | |
26719 | regs->fp = prev; | |
26720 | regs->sp = newsp; | |
26721 | } | |
26722 | ||
26723 | __attribute__((always_inline)) inline Value * | |
26724 | StackSpace::getStackLimit(JSContext *cx) | |
26725 | { | |
26726 | Value *sp = cx->regs->sp; | |
26727 | ((void) 0); | |
26728 | Value *limit = sp + STACK_QUOTA; | |
26729 | # 466 "jscntxtinlines.h" | |
26730 | if ((__builtin_expect((limit <= end), 1))) | |
26731 | return limit; | |
26732 | uintN minimum = cx->fp()->numSlots() + VALUES_PER_STACK_FRAME; | |
26733 | return ensureSpace(cx, sp, minimum) ? sp + minimum : __null; | |
26734 | ||
26735 | } | |
26736 | ||
26737 | inline | |
26738 | FrameRegsIter::FrameRegsIter(JSContext *cx) | |
26739 | : cx(cx) | |
26740 | { | |
26741 | curseg = cx->getCurrentSegment(); | |
26742 | if ((__builtin_expect((!curseg || !curseg->isActive()), 0))) { | |
26743 | initSlow(); | |
26744 | return; | |
26745 | } | |
26746 | ((void) 0); | |
26747 | curfp = cx->regs->fp; | |
26748 | cursp = cx->regs->sp; | |
26749 | curpc = cx->regs->pc; | |
26750 | return; | |
26751 | } | |
26752 | ||
26753 | inline FrameRegsIter & | |
26754 | FrameRegsIter::operator++() | |
26755 | { | |
26756 | JSStackFrame *fp = curfp; | |
26757 | JSStackFrame *prev = curfp = curfp->prev(); | |
26758 | if (!prev) | |
26759 | return *this; | |
26760 | ||
26761 | curpc = curfp->pc(cx, fp); | |
26762 | ||
26763 | if ((__builtin_expect((fp == curseg->getInitialFrame()), 0))) { | |
26764 | incSlow(fp, prev); | |
26765 | return *this; | |
26766 | } | |
26767 | ||
26768 | cursp = fp->formalArgsEnd(); | |
26769 | return *this; | |
26770 | } | |
26771 | ||
26772 | class AutoNamespaceArray : protected AutoGCRooter { | |
26773 | public: | |
26774 | AutoNamespaceArray(JSContext *cx) : AutoGCRooter(cx, NAMESPACES) { | |
26775 | array.init(); | |
26776 | } | |
26777 | ||
26778 | ~AutoNamespaceArray() { | |
26779 | array.finish(context); | |
26780 | } | |
26781 | ||
26782 | uint32 length() const { return array.length; } | |
26783 | ||
26784 | public: | |
26785 | friend void AutoGCRooter::trace(JSTracer *trc); | |
26786 | ||
26787 | JSXMLArray array; | |
26788 | }; | |
26789 | # 636 "jscntxtinlines.h" | |
26790 | template <class T1> inline void | |
26791 | assertSameCompartment(JSContext *cx, T1 t1) | |
26792 | { | |
26793 | ||
26794 | ||
26795 | ||
26796 | ||
26797 | } | |
26798 | ||
26799 | template <class T1, class T2> inline void | |
26800 | assertSameCompartment(JSContext *cx, T1 t1, T2 t2) | |
26801 | { | |
26802 | ||
26803 | ||
26804 | ||
26805 | ||
26806 | ||
26807 | } | |
26808 | ||
26809 | template <class T1, class T2, class T3> inline void | |
26810 | assertSameCompartment(JSContext *cx, T1 t1, T2 t2, T3 t3) | |
26811 | { | |
26812 | ||
26813 | ||
26814 | ||
26815 | ||
26816 | ||
26817 | ||
26818 | } | |
26819 | ||
26820 | template <class T1, class T2, class T3, class T4> inline void | |
26821 | assertSameCompartment(JSContext *cx, T1 t1, T2 t2, T3 t3, T4 t4) | |
26822 | { | |
26823 | ||
26824 | ||
26825 | ||
26826 | ||
26827 | ||
26828 | ||
26829 | ||
26830 | } | |
26831 | ||
26832 | template <class T1, class T2, class T3, class T4, class T5> inline void | |
26833 | assertSameCompartment(JSContext *cx, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) | |
26834 | { | |
26835 | # 689 "jscntxtinlines.h" | |
26836 | } | |
26837 | ||
26838 | ||
26839 | ||
26840 | ||
26841 | __attribute__((always_inline)) inline | |
26842 | ||
26843 | # 694 "jscntxtinlines.h" | |
26844 | bool | |
26845 | CallJSNative(JSContext *cx, js::Native native, uintN argc, js::Value *vp) | |
26846 | { | |
26847 | ||
26848 | ||
26849 | ||
26850 | assertSameCompartment(cx, ValueArray(vp, argc + 2)); | |
26851 | JSBool ok = native(cx, argc, vp); | |
26852 | if (ok) { | |
26853 | assertSameCompartment(cx, vp[0]); | |
26854 | ((void) 0); | |
26855 | } | |
26856 | return ok; | |
26857 | } | |
26858 | ||
26859 | extern JSBool CallOrConstructBoundFunction(JSContext *, uintN, js::Value *); | |
26860 | ||
26861 | ||
26862 | __attribute__((always_inline)) inline | |
26863 | ||
26864 | # 712 "jscntxtinlines.h" | |
26865 | bool | |
26866 | CallJSNativeConstructor(JSContext *cx, js::Native native, uintN argc, js::Value *vp) | |
26867 | { | |
26868 | ||
26869 | ||
26870 | ||
26871 | ||
26872 | ((void) 0); | |
26873 | if (!CallJSNative(cx, native, argc, vp)) | |
26874 | return false; | |
26875 | # 738 "jscntxtinlines.h" | |
26876 | extern JSBool proxy_Construct(JSContext *, uintN, Value *); | |
26877 | ((void) 0) | |
26878 | ||
26879 | ; | |
26880 | ||
26881 | return true; | |
26882 | } | |
26883 | ||
26884 | __attribute__((always_inline)) inline | |
26885 | ||
26886 | # 746 "jscntxtinlines.h" | |
26887 | bool | |
26888 | CallJSPropertyOp(JSContext *cx, js::PropertyOp op, JSObject *obj, jsid id, js::Value *vp) | |
26889 | { | |
26890 | assertSameCompartment(cx, obj, id, *vp); | |
26891 | JSBool ok = op(cx, obj, id, vp); | |
26892 | if (ok) | |
26893 | assertSameCompartment(cx, obj, *vp); | |
26894 | return ok; | |
26895 | } | |
26896 | ||
26897 | __attribute__((always_inline)) inline | |
26898 | ||
26899 | # 756 "jscntxtinlines.h" | |
26900 | bool | |
26901 | CallJSPropertyOpSetter(JSContext *cx, js::StrictPropertyOp op, JSObject *obj, jsid id, | |
26902 | JSBool strict, js::Value *vp) | |
26903 | { | |
26904 | assertSameCompartment(cx, obj, id, *vp); | |
26905 | return op(cx, obj, id, strict, vp); | |
26906 | } | |
26907 | ||
26908 | inline | |
26909 | ||
26910 | # 764 "jscntxtinlines.h" | |
26911 | bool | |
26912 | CallSetter(JSContext *cx, JSObject *obj, jsid id, js::StrictPropertyOp op, uintN attrs, | |
26913 | uintN shortid, JSBool strict, js::Value *vp) | |
26914 | { | |
26915 | if (attrs & 0x20) | |
26916 | return ExternalGetOrSet(cx, obj, id, CastAsObjectJsval(op), JSACC_WRITE, 1, vp, vp); | |
26917 | ||
26918 | if (attrs & 0x10) | |
26919 | return js_ReportGetterOnlyAssignment(cx); | |
26920 | ||
26921 | if (attrs & 0x100) | |
26922 | id = INT_TO_JSID(shortid); | |
26923 | return CallJSPropertyOpSetter(cx, op, obj, id, strict, vp); | |
26924 | } | |
26925 | # 791 "jscntxtinlines.h" | |
26926 | static inline void | |
26927 | LeaveTraceIfGlobalObject(JSContext *cx, JSObject *obj) | |
26928 | { | |
26929 | if (!obj->parent) | |
26930 | LeaveTrace(cx); | |
26931 | } | |
26932 | ||
26933 | static inline void | |
26934 | LeaveTraceIfArgumentsObject(JSContext *cx, JSObject *obj) | |
26935 | { | |
26936 | if (obj->isArguments()) | |
26937 | LeaveTrace(cx); | |
26938 | } | |
26939 | ||
26940 | static inline JSBool | |
26941 | CanLeaveTrace(JSContext *cx) | |
26942 | { | |
26943 | ((void) 0); | |
26944 | ||
26945 | ||
26946 | ||
26947 | return (JSIntn)0; | |
26948 | ||
26949 | } | |
26950 | ||
26951 | } | |
26952 | ||
26953 | inline void | |
26954 | JSContext::setPendingException(js::Value v) { | |
26955 | this->throwing = true; | |
26956 | this->exception = v; | |
26957 | assertSameCompartment(this, v); | |
26958 | } | |
26959 | # 45 "jsstrinlines.h" 2 | |
26960 | ||
26961 | namespace js { | |
26962 | ||
26963 | static inline | |
26964 | ||
26965 | # 48 "jsstrinlines.h" | |
26966 | bool | |
26967 | CheckStringLength(JSContext *cx, size_t length) | |
26968 | { | |
26969 | if ((__builtin_expect((length > JSString::MAX_LENGTH), 0))) { | |
26970 | js_ReportAllocationOverflow(cx); | |
26971 | return false; | |
26972 | } | |
26973 | ||
26974 | return true; | |
26975 | } | |
26976 | # 67 "jsstrinlines.h" | |
26977 | class StringBuffer | |
26978 | { | |
26979 | typedef Vector<jschar, 32> CharBuffer; | |
26980 | CharBuffer cb; | |
26981 | ||
26982 | static inline bool checkLength(JSContext *cx, size_t length); | |
26983 | inline bool checkLength(size_t length); | |
26984 | JSContext *context() const { return cb.allocPolicy().context(); } | |
26985 | ||
26986 | public: | |
26987 | explicit inline StringBuffer(JSContext *cx); | |
26988 | bool reserve(size_t len); | |
26989 | bool resize(size_t len); | |
26990 | bool append(const jschar c); | |
26991 | bool append(const jschar *chars, size_t len); | |
26992 | bool append(const jschar *begin, const jschar *end); | |
26993 | bool append(JSString *str); | |
26994 | bool append(JSAtom *atom); | |
26995 | bool appendN(const jschar c, size_t n); | |
26996 | bool appendInflated(const char *cstr, size_t len); | |
26997 | JSAtom *atomize(uintN flags = 0); | |
26998 | static JSAtom *atomize(JSContext *cx, const CharBuffer &cb, uintN flags = 0); | |
26999 | static JSAtom *atomize(JSContext *cx, const jschar *begin, size_t length, uintN flags = 0); | |
27000 | ||
27001 | void replaceRawBuffer(jschar *chars, size_t len) { cb.replaceRawBuffer(chars, len); } | |
27002 | jschar *begin() { return cb.begin(); } | |
27003 | jschar *end() { return cb.end(); } | |
27004 | const jschar *begin() const { return cb.begin(); } | |
27005 | const jschar *end() const { return cb.end(); } | |
27006 | bool empty() const { return cb.empty(); } | |
27007 | inline jsint length() const; | |
27008 | ||
27009 | ||
27010 | ||
27011 | ||
27012 | ||
27013 | ||
27014 | JSFlatString *finishString(); | |
27015 | ||
27016 | template <size_t ArrayLength> | |
27017 | bool append(const char (&array)[ArrayLength]) { | |
27018 | return cb.append(array, array + ArrayLength - 1); | |
27019 | } | |
27020 | }; | |
27021 | ||
27022 | inline | |
27023 | StringBuffer::StringBuffer(JSContext *cx) | |
27024 | : cb(cx) | |
27025 | {} | |
27026 | ||
27027 | inline | |
27028 | ||
27029 | # 117 "jsstrinlines.h" | |
27030 | bool | |
27031 | StringBuffer::reserve(size_t len) | |
27032 | { | |
27033 | if (!checkLength(len)) | |
27034 | return false; | |
27035 | return cb.reserve(len); | |
27036 | } | |
27037 | ||
27038 | inline | |
27039 | ||
27040 | # 125 "jsstrinlines.h" | |
27041 | bool | |
27042 | StringBuffer::resize(size_t len) | |
27043 | { | |
27044 | if (!checkLength(len)) | |
27045 | return false; | |
27046 | return cb.resize(len); | |
27047 | } | |
27048 | ||
27049 | inline | |
27050 | ||
27051 | # 133 "jsstrinlines.h" | |
27052 | bool | |
27053 | StringBuffer::append(const jschar c) | |
27054 | { | |
27055 | if (!checkLength(cb.length() + 1)) | |
27056 | return false; | |
27057 | return cb.append(c); | |
27058 | } | |
27059 | ||
27060 | inline | |
27061 | ||
27062 | # 141 "jsstrinlines.h" | |
27063 | bool | |
27064 | StringBuffer::append(const jschar *chars, size_t len) | |
27065 | { | |
27066 | if (!checkLength(cb.length() + len)) | |
27067 | return false; | |
27068 | return cb.append(chars, len); | |
27069 | } | |
27070 | ||
27071 | inline | |
27072 | ||
27073 | # 149 "jsstrinlines.h" | |
27074 | bool | |
27075 | StringBuffer::append(const jschar *begin, const jschar *end) | |
27076 | { | |
27077 | if (!checkLength(cb.length() + (end - begin))) | |
27078 | return false; | |
27079 | return cb.append(begin, end); | |
27080 | } | |
27081 | ||
27082 | inline | |
27083 | ||
27084 | # 157 "jsstrinlines.h" | |
27085 | bool | |
27086 | StringBuffer::append(JSString *str) | |
27087 | { | |
27088 | JSLinearString *linear = str->ensureLinear(context()); | |
27089 | size_t strLen = linear->length(); | |
27090 | if (!checkLength(cb.length() + strLen)) | |
27091 | return false; | |
27092 | return cb.append(linear->chars(), strLen); | |
27093 | } | |
27094 | ||
27095 | inline | |
27096 | ||
27097 | # 167 "jsstrinlines.h" | |
27098 | bool | |
27099 | StringBuffer::append(JSAtom *atom) | |
27100 | { | |
27101 | size_t strLen = atom->length(); | |
27102 | if (!checkLength(cb.length() + strLen)) | |
27103 | return false; | |
27104 | return cb.append(atom->chars(), strLen); | |
27105 | } | |
27106 | ||
27107 | inline | |
27108 | ||
27109 | # 176 "jsstrinlines.h" | |
27110 | bool | |
27111 | StringBuffer::appendN(const jschar c, size_t n) | |
27112 | { | |
27113 | if (!checkLength(cb.length() + n)) | |
27114 | return false; | |
27115 | return cb.appendN(c, n); | |
27116 | } | |
27117 | ||
27118 | inline | |
27119 | ||
27120 | # 184 "jsstrinlines.h" | |
27121 | bool | |
27122 | StringBuffer::appendInflated(const char *cstr, size_t cstrlen) | |
27123 | { | |
27124 | size_t lengthBefore = length(); | |
27125 | if (!cb.growByUninitialized(cstrlen)) | |
27126 | return false; | |
27127 | ||
27128 | ||
27129 | ||
27130 | ||
27131 | js_InflateStringToBuffer(context(), cstr, cstrlen, begin() + lengthBefore, &cstrlen); | |
27132 | ((void) 0); | |
27133 | return true; | |
27134 | } | |
27135 | ||
27136 | inline jsint | |
27137 | StringBuffer::length() const | |
27138 | { | |
27139 | typedef int js_static_assert65[(jsint(JSString::MAX_LENGTH) == JSString::MAX_LENGTH) ? 1 : -1]; | |
27140 | ((void) 0); | |
27141 | return jsint(cb.length()); | |
27142 | } | |
27143 | ||
27144 | inline | |
27145 | ||
27146 | # 207 "jsstrinlines.h" | |
27147 | bool | |
27148 | StringBuffer::checkLength(size_t length) | |
27149 | { | |
27150 | return CheckStringLength(context(), length); | |
27151 | } | |
27152 | ||
27153 | } | |
27154 | ||
27155 | inline JSFlatString * | |
27156 | JSString::unitString(jschar c) | |
27157 | { | |
27158 | ||
27159 | ((void) 0); | |
27160 | return const_cast<JSString *>(&unitStringTable[c])->assertIsFlat(); | |
27161 | ||
27162 | ||
27163 | ||
27164 | ||
27165 | } | |
27166 | ||
27167 | inline JSLinearString * | |
27168 | JSString::getUnitString(JSContext *cx, JSString *str, size_t index) | |
27169 | { | |
27170 | ((void) 0); | |
27171 | ||
27172 | const jschar *chars = str->getChars(cx); | |
27173 | if (!chars) | |
27174 | return __null; | |
27175 | jschar c = chars[index]; | |
27176 | if (c < UNIT_STRING_LIMIT) | |
27177 | return unitString(c); | |
27178 | ||
27179 | return js_NewDependentString(cx, str, index, 1); | |
27180 | } | |
27181 | ||
27182 | inline JSFlatString * | |
27183 | JSString::length2String(jschar c1, jschar c2) | |
27184 | { | |
27185 | ||
27186 | ((void) 0); | |
27187 | ((void) 0); | |
27188 | return const_cast<JSString *> ( | |
27189 | &length2StringTable[(((size_t)toSmallChar[c1]) << 6) + toSmallChar[c2]] | |
27190 | )->assertIsFlat(); | |
27191 | ||
27192 | ||
27193 | ||
27194 | ||
27195 | } | |
27196 | ||
27197 | inline JSFlatString * | |
27198 | JSString::length2String(uint32 i) | |
27199 | { | |
27200 | ||
27201 | ((void) 0); | |
27202 | return length2String('0' + i / 10, '0' + i % 10); | |
27203 | ||
27204 | ||
27205 | ||
27206 | ||
27207 | } | |
27208 | ||
27209 | inline JSFlatString * | |
27210 | JSString::intString(jsint i) | |
27211 | { | |
27212 | ||
27213 | jsuint u = jsuint(i); | |
27214 | ((void) 0); | |
27215 | return const_cast<JSString *>(JSString::intStringTable[u])->assertIsFlat(); | |
27216 | ||
27217 | ||
27218 | ||
27219 | ||
27220 | } | |
27221 | ||
27222 | ||
27223 | inline JSFlatString * | |
27224 | JSString::lookupStaticString(const jschar *chars, size_t length) | |
27225 | { | |
27226 | ||
27227 | if (length == 1) { | |
27228 | if (chars[0] < UNIT_STRING_LIMIT) | |
27229 | return unitString(chars[0]); | |
27230 | } | |
27231 | ||
27232 | if (length == 2) { | |
27233 | if (fitsInSmallChar(chars[0]) && fitsInSmallChar(chars[1])) | |
27234 | return length2String(chars[0], chars[1]); | |
27235 | } | |
27236 | ||
27237 | ||
27238 | ||
27239 | ||
27240 | ||
27241 | ||
27242 | ||
27243 | typedef int js_static_assert66[(INT_STRING_LIMIT <= 999) ? 1 : -1]; | |
27244 | if (length == 3) { | |
27245 | if ('1' <= chars[0] && chars[0] <= '9' && | |
27246 | '0' <= chars[1] && chars[1] <= '9' && | |
27247 | '0' <= chars[2] && chars[2] <= '9') { | |
27248 | jsint i = (chars[0] - '0') * 100 + | |
27249 | (chars[1] - '0') * 10 + | |
27250 | (chars[2] - '0'); | |
27251 | ||
27252 | if (jsuint(i) < INT_STRING_LIMIT) | |
27253 | return intString(i); | |
27254 | } | |
27255 | } | |
27256 | ||
27257 | ||
27258 | return __null; | |
27259 | } | |
27260 | ||
27261 | inline void | |
27262 | JSString::finalize(JSContext *cx) { | |
27263 | ((void) 0); | |
27264 | ; | |
27265 | if (isDependent()) { | |
27266 | ; | |
27267 | } else if (isFlat()) { | |
27268 | ||
27269 | ||
27270 | ||
27271 | ||
27272 | cx->runtime->stringMemoryUsed -= length() * 2; | |
27273 | cx->free(const_cast<jschar *>(flatChars())); | |
27274 | } | |
27275 | } | |
27276 | ||
27277 | inline void | |
27278 | JSShortString::finalize(JSContext *cx) | |
27279 | { | |
27280 | ((void) 0); | |
27281 | ((void) 0); | |
27282 | ; | |
27283 | } | |
27284 | ||
27285 | inline void | |
27286 | JSExternalString::finalize(JSContext *cx) | |
27287 | { | |
27288 | ((void) 0); | |
27289 | ((void) 0); | |
27290 | ((void) 0); | |
27291 | ; | |
27292 | ||
27293 | ||
27294 | jschar *chars = const_cast<jschar *>(flatChars()); | |
27295 | if (!chars) | |
27296 | return; | |
27297 | JSStringFinalizeOp finalizer = str_finalizers[externalStringType]; | |
27298 | if (finalizer) | |
27299 | finalizer(cx, this); | |
27300 | } | |
27301 | ||
27302 | inline void | |
27303 | JSExternalString::finalize() | |
27304 | { | |
27305 | ((void) 0); | |
27306 | JSStringFinalizeOp finalizer = str_finalizers[externalStringType]; | |
27307 | if (finalizer) { | |
27308 | ||
27309 | ||
27310 | ||
27311 | ||
27312 | finalizer(__null, this); | |
27313 | } | |
27314 | } | |
27315 | ||
27316 | namespace js { | |
27317 | ||
27318 | class RopeBuilder { | |
27319 | JSContext *cx; | |
27320 | JSString *res; | |
27321 | ||
27322 | public: | |
27323 | RopeBuilder(JSContext *cx) | |
27324 | : cx(cx), res(cx->runtime->emptyString) | |
27325 | {} | |
27326 | ||
27327 | inline bool append(JSString *str) { | |
27328 | res = js_ConcatStrings(cx, res, str); | |
27329 | return !!res; | |
27330 | } | |
27331 | ||
27332 | inline JSString *result() { | |
27333 | return res; | |
27334 | } | |
27335 | }; | |
27336 | ||
27337 | class StringSegmentRange | |
27338 | { | |
27339 | ||
27340 | ||
27341 | ||
27342 | ||
27343 | Vector<JSString *, 32> stack; | |
27344 | JSString *cur; | |
27345 | ||
27346 | bool settle(JSString *str) { | |
27347 | while (str->isRope()) { | |
27348 | if (!stack.append(str->ropeRight())) | |
27349 | return false; | |
27350 | str = str->ropeLeft(); | |
27351 | } | |
27352 | cur = str; | |
27353 | return true; | |
27354 | } | |
27355 | ||
27356 | public: | |
27357 | StringSegmentRange(JSContext *cx) | |
27358 | : stack(cx), cur(__null) | |
27359 | {} | |
27360 | ||
27361 | __attribute__((warn_unused_result)) bool init(JSString *str) { | |
27362 | ((void) 0); | |
27363 | return settle(str); | |
27364 | } | |
27365 | ||
27366 | bool empty() const { | |
27367 | return cur == __null; | |
27368 | } | |
27369 | ||
27370 | JSString *front() const { | |
27371 | ((void) 0); | |
27372 | return cur; | |
27373 | } | |
27374 | ||
27375 | __attribute__((warn_unused_result)) bool popFront() { | |
27376 | ((void) 0); | |
27377 | if (stack.empty()) { | |
27378 | cur = __null; | |
27379 | return true; | |
27380 | } | |
27381 | return settle(stack.popCopy()); | |
27382 | } | |
27383 | }; | |
27384 | ||
27385 | } | |
27386 | # 60 "jsscope.h" 2 | |
27387 | # 213 "jsscope.h" | |
27388 | namespace js { | |
27389 | ||
27390 | ||
27391 | ||
27392 | ||
27393 | ||
27394 | ||
27395 | ||
27396 | struct PropertyTable { | |
27397 | static const uint32 MAX_LINEAR_SEARCHES = 7; | |
27398 | static const uint32 MIN_SIZE_LOG2 = 4; | |
27399 | static const uint32 MIN_SIZE = ((JSUint32)1 << (MIN_SIZE_LOG2)); | |
27400 | ||
27401 | int hashShift; | |
27402 | ||
27403 | uint32 entryCount; | |
27404 | uint32 removedCount; | |
27405 | uint32 freelist; | |
27406 | ||
27407 | ||
27408 | js::Shape **entries; | |
27409 | ||
27410 | PropertyTable(uint32 nentries) | |
27411 | : hashShift(32 - MIN_SIZE_LOG2), | |
27412 | entryCount(nentries), | |
27413 | removedCount(0), | |
27414 | freelist(0xffffffff) | |
27415 | { | |
27416 | ||
27417 | } | |
27418 | ||
27419 | ~PropertyTable() { | |
27420 | js_free(entries); | |
27421 | } | |
27422 | ||
27423 | ||
27424 | uint32 capacity() const { return ((JSUint32)1 << (32 - hashShift)); } | |
27425 | ||
27426 | ||
27427 | bool needsToGrow() const { | |
27428 | uint32 size = capacity(); | |
27429 | return entryCount + removedCount >= size - (size >> 2); | |
27430 | } | |
27431 | ||
27432 | ||
27433 | ||
27434 | ||
27435 | ||
27436 | ||
27437 | bool grow(JSContext *cx); | |
27438 | ||
27439 | ||
27440 | ||
27441 | ||
27442 | ||
27443 | ||
27444 | bool init(JSRuntime *rt, js::Shape *lastProp); | |
27445 | bool change(int log2Delta, JSContext *cx); | |
27446 | js::Shape **search(jsid id, bool adding); | |
27447 | }; | |
27448 | ||
27449 | } | |
27450 | ||
27451 | struct JSObject; | |
27452 | ||
27453 | namespace js { | |
27454 | ||
27455 | class PropertyTree; | |
27456 | ||
27457 | static inline PropertyOp | |
27458 | CastAsPropertyOp(js::Class *clasp) | |
27459 | { | |
27460 | return (__extension__ (PropertyOp) (size_t) (clasp)); | |
27461 | } | |
27462 | ||
27463 | ||
27464 | ||
27465 | ||
27466 | ||
27467 | ||
27468 | struct Shape : public JSObjectMap | |
27469 | { | |
27470 | friend struct ::JSObject; | |
27471 | friend struct ::JSFunction; | |
27472 | friend class js::PropertyTree; | |
27473 | friend class js::Bindings; | |
27474 | friend bool IsShapeAboutToBeFinalized(JSContext *cx, const js::Shape *shape); | |
27475 | # 309 "jsscope.h" | |
27476 | union { | |
27477 | mutable size_t numLinearSearches; | |
27478 | mutable js::PropertyTable *table; | |
27479 | }; | |
27480 | ||
27481 | public: | |
27482 | inline void freeTable(JSContext *cx); | |
27483 | ||
27484 | static bool initEmptyShapes(JSCompartment *comp); | |
27485 | static void finishEmptyShapes(JSCompartment *comp); | |
27486 | ||
27487 | jsid id; | |
27488 | ||
27489 | ||
27490 | ||
27491 | ||
27492 | ||
27493 | protected: | |
27494 | union { | |
27495 | js::PropertyOp rawGetter; | |
27496 | JSObject *getterObj; | |
27497 | ||
27498 | ||
27499 | ||
27500 | js::Class *clasp; | |
27501 | }; | |
27502 | ||
27503 | union { | |
27504 | js::StrictPropertyOp rawSetter; | |
27505 | ||
27506 | JSObject *setterObj; | |
27507 | ||
27508 | }; | |
27509 | ||
27510 | public: | |
27511 | uint32 slot; | |
27512 | private: | |
27513 | uint8 attrs; | |
27514 | mutable uint8 flags; | |
27515 | public: | |
27516 | int16 shortid; | |
27517 | ||
27518 | protected: | |
27519 | mutable js::Shape *parent; | |
27520 | union { | |
27521 | mutable js::KidsPointer kids; | |
27522 | ||
27523 | mutable js::Shape **listp; | |
27524 | ||
27525 | ||
27526 | ||
27527 | }; | |
27528 | ||
27529 | static inline js::Shape **search(JSRuntime *rt, js::Shape **startp, jsid id, | |
27530 | bool adding = false); | |
27531 | static js::Shape *newDictionaryShape(JSContext *cx, const js::Shape &child, js::Shape **listp); | |
27532 | static js::Shape *newDictionaryList(JSContext *cx, js::Shape **listp); | |
27533 | ||
27534 | inline void removeFromDictionary(JSObject *obj) const; | |
27535 | inline void insertIntoDictionary(js::Shape **dictp); | |
27536 | ||
27537 | js::Shape *getChild(JSContext *cx, const js::Shape &child, js::Shape **listp); | |
27538 | ||
27539 | bool hashify(JSRuntime *rt); | |
27540 | ||
27541 | bool hasTable() const { | |
27542 | ||
27543 | return numLinearSearches > PropertyTable::MAX_LINEAR_SEARCHES; | |
27544 | } | |
27545 | ||
27546 | js::PropertyTable *getTable() const { | |
27547 | ((void) 0); | |
27548 | return table; | |
27549 | } | |
27550 | ||
27551 | void setTable(js::PropertyTable *t) const { | |
27552 | ((void) 0); | |
27553 | table = t; | |
27554 | } | |
27555 | # 430 "jsscope.h" | |
27556 | void setParent(js::Shape *p) { | |
27557 | typedef int js_static_assert67[(uint32(0xffffffff) == ~uint32(0)) ? 1 : -1]; | |
27558 | if (p) | |
27559 | slotSpan = ((p->slotSpan)>(slot + 1)?(p->slotSpan):(slot + 1)); | |
27560 | ((void) 0); | |
27561 | parent = p; | |
27562 | } | |
27563 | ||
27564 | void insertFree(js::Shape **freep) { | |
27565 | ||
27566 | ||
27567 | ||
27568 | id = ((jsid)0x2); | |
27569 | parent = *freep; | |
27570 | if (parent) | |
27571 | parent->listp = &parent; | |
27572 | listp = freep; | |
27573 | *freep = this; | |
27574 | } | |
27575 | ||
27576 | void removeFree() { | |
27577 | ((void) 0); | |
27578 | *listp = parent; | |
27579 | if (parent) | |
27580 | parent->listp = listp; | |
27581 | } | |
27582 | ||
27583 | public: | |
27584 | const js::Shape *previous() const { | |
27585 | return parent; | |
27586 | } | |
27587 | ||
27588 | class Range { | |
27589 | protected: | |
27590 | friend struct Shape; | |
27591 | ||
27592 | const Shape *cursor; | |
27593 | const Shape *end; | |
27594 | ||
27595 | public: | |
27596 | Range(const Shape *shape) : cursor(shape) { } | |
27597 | ||
27598 | bool empty() const { | |
27599 | ((void) 0); | |
27600 | return !cursor->parent; | |
27601 | } | |
27602 | ||
27603 | const Shape &front() const { | |
27604 | ((void) 0); | |
27605 | return *cursor; | |
27606 | } | |
27607 | ||
27608 | void popFront() { | |
27609 | ((void) 0); | |
27610 | cursor = cursor->parent; | |
27611 | } | |
27612 | }; | |
27613 | ||
27614 | Range all() const { | |
27615 | return Range(this); | |
27616 | } | |
27617 | ||
27618 | protected: | |
27619 | ||
27620 | ||
27621 | ||
27622 | ||
27623 | ||
27624 | enum { | |
27625 | ||
27626 | MARK = 0x01, | |
27627 | ||
27628 | SHARED_EMPTY = 0x02, | |
27629 | ||
27630 | ||
27631 | ||
27632 | ||
27633 | ||
27634 | SHAPE_REGEN = 0x04, | |
27635 | ||
27636 | ||
27637 | IN_DICTIONARY = 0x08, | |
27638 | ||
27639 | ||
27640 | FROZEN = 0x10 | |
27641 | }; | |
27642 | ||
27643 | Shape(jsid id, js::PropertyOp getter, js::StrictPropertyOp setter, uint32 slot, uintN attrs, | |
27644 | uintN flags, intN shortid, uint32 shape = INVALID_SHAPE, uint32 slotSpan = 0); | |
27645 | ||
27646 | ||
27647 | Shape(JSCompartment *comp, Class *aclasp); | |
27648 | ||
27649 | bool marked() const { return (flags & MARK) != 0; } | |
27650 | void mark() const { flags |= MARK; } | |
27651 | void clearMark() { flags &= ~MARK; } | |
27652 | ||
27653 | bool hasRegenFlag() const { return (flags & SHAPE_REGEN) != 0; } | |
27654 | void setRegenFlag() { flags |= SHAPE_REGEN; } | |
27655 | void clearRegenFlag() { flags &= ~SHAPE_REGEN; } | |
27656 | ||
27657 | bool inDictionary() const { return (flags & IN_DICTIONARY) != 0; } | |
27658 | bool frozen() const { return (flags & FROZEN) != 0; } | |
27659 | void setFrozen() { flags |= FROZEN; } | |
27660 | ||
27661 | bool isEmptyShape() const { ((void) 0); return !parent; } | |
27662 | ||
27663 | public: | |
27664 | ||
27665 | enum { | |
27666 | ALIAS = 0x20, | |
27667 | HAS_SHORTID = 0x40, | |
27668 | METHOD = 0x80, | |
27669 | PUBLIC_FLAGS = ALIAS | HAS_SHORTID | METHOD | |
27670 | }; | |
27671 | ||
27672 | uintN getFlags() const { return flags & PUBLIC_FLAGS; } | |
27673 | bool isAlias() const { return (flags & ALIAS) != 0; } | |
27674 | bool hasShortID() const { return (flags & HAS_SHORTID) != 0; } | |
27675 | bool isMethod() const { return (flags & METHOD) != 0; } | |
27676 | ||
27677 | JSObject &methodObject() const { ((void) 0); return *getterObj; } | |
27678 | ||
27679 | js::PropertyOp getter() const { return rawGetter; } | |
27680 | bool hasDefaultGetter() const { return !rawGetter; } | |
27681 | js::PropertyOp getterOp() const { ((void) 0); return rawGetter; } | |
27682 | JSObject *getterObject() const { ((void) 0); return getterObj; } | |
27683 | ||
27684 | ||
27685 | js::Value getterValue() const { | |
27686 | ((void) 0); | |
27687 | return getterObj ? js::ObjectValue(*getterObj) : js::UndefinedValue(); | |
27688 | } | |
27689 | ||
27690 | js::Value getterOrUndefined() const { | |
27691 | return hasGetterValue() && getterObj ? js::ObjectValue(*getterObj) : js::UndefinedValue(); | |
27692 | } | |
27693 | ||
27694 | js::StrictPropertyOp setter() const { return rawSetter; } | |
27695 | bool hasDefaultSetter() const { return !rawSetter; } | |
27696 | js::StrictPropertyOp setterOp() const { ((void) 0); return rawSetter; } | |
27697 | JSObject *setterObject() const { ((void) 0); return setterObj; } | |
27698 | ||
27699 | ||
27700 | js::Value setterValue() const { | |
27701 | ((void) 0); | |
27702 | return setterObj ? js::ObjectValue(*setterObj) : js::UndefinedValue(); | |
27703 | } | |
27704 | ||
27705 | js::Value setterOrUndefined() const { | |
27706 | return hasSetterValue() && setterObj ? js::ObjectValue(*setterObj) : js::UndefinedValue(); | |
27707 | } | |
27708 | ||
27709 | inline JSDHashNumber hash() const; | |
27710 | inline bool matches(const js::Shape *p) const; | |
27711 | inline bool matchesParamsAfterId(js::PropertyOp agetter, js::StrictPropertyOp asetter, | |
27712 | uint32 aslot, uintN aattrs, uintN aflags, | |
27713 | intN ashortid) const; | |
27714 | ||
27715 | bool get(JSContext* cx, JSObject *receiver, JSObject *obj, JSObject *pobj, js::Value* vp) const; | |
27716 | bool set(JSContext* cx, JSObject *obj, bool strict, js::Value* vp) const; | |
27717 | ||
27718 | inline bool isSharedPermanent() const; | |
27719 | ||
27720 | void trace(JSTracer *trc) const; | |
27721 | ||
27722 | bool hasSlot() const { return (attrs & 0x40) == 0; } | |
27723 | ||
27724 | uint8 attributes() const { return attrs; } | |
27725 | bool configurable() const { return (attrs & 0x04) == 0; } | |
27726 | bool enumerable() const { return (attrs & 0x01) != 0; } | |
27727 | bool writable() const { | |
27728 | ||
27729 | return (attrs & 0x02) == 0; | |
27730 | } | |
27731 | bool hasGetterValue() const { return attrs & 0x10; } | |
27732 | bool hasSetterValue() const { return attrs & 0x20; } | |
27733 | ||
27734 | bool hasDefaultGetterOrIsMethod() const { | |
27735 | return hasDefaultGetter() || isMethod(); | |
27736 | } | |
27737 | ||
27738 | bool isDataDescriptor() const { | |
27739 | return (attrs & (0x20 | 0x10)) == 0; | |
27740 | } | |
27741 | bool isAccessorDescriptor() const { | |
27742 | return (attrs & (0x20 | 0x10)) != 0; | |
27743 | } | |
27744 | ||
27745 | ||
27746 | ||
27747 | ||
27748 | ||
27749 | ||
27750 | ||
27751 | bool shadowable() const { | |
27752 | ((void) 0); | |
27753 | return hasSlot() || (attrs & 0x80); | |
27754 | } | |
27755 | ||
27756 | uint32 entryCount() const { | |
27757 | if (hasTable()) | |
27758 | return getTable()->entryCount; | |
27759 | ||
27760 | const js::Shape *shape = this; | |
27761 | uint32 count = 0; | |
27762 | for (js::Shape::Range r = shape->all(); !r.empty(); r.popFront()) | |
27763 | ++count; | |
27764 | return count; | |
27765 | } | |
27766 | ||
27767 | ||
27768 | ||
27769 | ||
27770 | ||
27771 | }; | |
27772 | ||
27773 | struct EmptyShape : public js::Shape | |
27774 | { | |
27775 | EmptyShape(JSCompartment *comp, js::Class *aclasp); | |
27776 | ||
27777 | js::Class *getClass() const { return clasp; }; | |
27778 | ||
27779 | static EmptyShape *create(JSCompartment *comp, js::Class *clasp) { | |
27780 | js::Shape *eprop = comp->propertyTree.newShapeUnchecked(); | |
27781 | if (!eprop) | |
27782 | return __null; | |
27783 | return new (eprop) EmptyShape(comp, clasp); | |
27784 | } | |
27785 | ||
27786 | static EmptyShape *create(JSContext *cx, js::Class *clasp) { | |
27787 | js::Shape *eprop = ((cx)->compartment->propertyTree).newShape(cx); | |
27788 | if (!eprop) | |
27789 | return __null; | |
27790 | return new (eprop) EmptyShape(cx->compartment, clasp); | |
27791 | } | |
27792 | }; | |
27793 | ||
27794 | } | |
27795 | # 689 "jsscope.h" | |
27796 | inline js::Shape ** | |
27797 | JSObject::nativeSearch(jsid id, bool adding) | |
27798 | { | |
27799 | return js::Shape::search(compartment()->rt, &lastProp, id, adding); | |
27800 | } | |
27801 | ||
27802 | inline const js::Shape * | |
27803 | JSObject::nativeLookup(jsid id) | |
27804 | { | |
27805 | ((void) 0); | |
27806 | return ((js::Shape *) (jsuword(*(nativeSearch(id))) & ~(jsuword(1)))); | |
27807 | } | |
27808 | ||
27809 | inline | |
27810 | ||
27811 | # 702 "jsscope.h" | |
27812 | bool | |
27813 | JSObject::nativeContains(jsid id) | |
27814 | { | |
27815 | return nativeLookup(id) != __null; | |
27816 | } | |
27817 | ||
27818 | inline | |
27819 | ||
27820 | # 708 "jsscope.h" | |
27821 | bool | |
27822 | JSObject::nativeContains(const js::Shape &shape) | |
27823 | { | |
27824 | return nativeLookup(shape.id) == &shape; | |
27825 | } | |
27826 | ||
27827 | inline const js::Shape * | |
27828 | JSObject::lastProperty() const | |
27829 | { | |
27830 | ((void) 0); | |
27831 | ((void) 0); | |
27832 | return lastProp; | |
27833 | } | |
27834 | ||
27835 | inline | |
27836 | ||
27837 | # 722 "jsscope.h" | |
27838 | bool | |
27839 | JSObject::nativeEmpty() const | |
27840 | { | |
27841 | return lastProperty()->isEmptyShape(); | |
27842 | } | |
27843 | ||
27844 | inline | |
27845 | ||
27846 | # 728 "jsscope.h" | |
27847 | bool | |
27848 | JSObject::inDictionaryMode() const | |
27849 | { | |
27850 | return lastProperty()->inDictionary(); | |
27851 | } | |
27852 | ||
27853 | inline uint32 | |
27854 | JSObject::propertyCount() const | |
27855 | { | |
27856 | return lastProperty()->entryCount(); | |
27857 | } | |
27858 | ||
27859 | inline | |
27860 | ||
27861 | # 740 "jsscope.h" | |
27862 | bool | |
27863 | JSObject::hasPropertyTable() const | |
27864 | { | |
27865 | return lastProperty()->hasTable(); | |
27866 | } | |
27867 | ||
27868 | ||
27869 | ||
27870 | ||
27871 | inline void | |
27872 | JSObject::setLastProperty(const js::Shape *shape) | |
27873 | { | |
27874 | ((void) 0); | |
27875 | ((void) 0); | |
27876 | ((void) 0); | |
27877 | ((void) 0); | |
27878 | ||
27879 | lastProp = const_cast<js::Shape *>(shape); | |
27880 | } | |
27881 | ||
27882 | inline void | |
27883 | JSObject::removeLastProperty() | |
27884 | { | |
27885 | ((void) 0); | |
27886 | ((void) 0); | |
27887 | ||
27888 | lastProp = lastProp->parent; | |
27889 | } | |
27890 | ||
27891 | namespace js { | |
27892 | ||
27893 | inline void | |
27894 | Shape::removeFromDictionary(JSObject *obj) const | |
27895 | { | |
27896 | ((void) 0); | |
27897 | ((void) 0); | |
27898 | ((void) 0); | |
27899 | ((void) 0); | |
27900 | ((void) 0); | |
27901 | ||
27902 | ((void) 0); | |
27903 | ((void) 0); | |
27904 | ((void) 0); | |
27905 | ((void) 0); | |
27906 | ||
27907 | if (parent) | |
27908 | parent->listp = listp; | |
27909 | *listp = parent; | |
27910 | listp = __null; | |
27911 | } | |
27912 | ||
27913 | inline void | |
27914 | Shape::insertIntoDictionary(js::Shape **dictp) | |
27915 | { | |
27916 | ||
27917 | ||
27918 | ||
27919 | ||
27920 | ((void) 0); | |
27921 | ((void) 0); | |
27922 | ((void) 0); | |
27923 | ||
27924 | ((void) 0); | |
27925 | ((void) 0); | |
27926 | ((void) 0); | |
27927 | ((void) 0); | |
27928 | ||
27929 | setParent(*dictp); | |
27930 | if (parent) | |
27931 | parent->listp = &parent; | |
27932 | listp = dictp; | |
27933 | *dictp = this; | |
27934 | } | |
27935 | ||
27936 | } | |
27937 | # 824 "jsscope.h" | |
27938 | extern uint32 | |
27939 | js_GenerateShape(JSRuntime *rt); | |
27940 | ||
27941 | extern uint32 | |
27942 | js_GenerateShape(JSContext *cx); | |
27943 | # 869 "jsscope.h" | |
27944 | namespace js { | |
27945 | ||
27946 | __attribute__((always_inline)) inline js::Shape ** | |
27947 | Shape::search(JSRuntime *rt, js::Shape **startp, jsid id, bool adding) | |
27948 | { | |
27949 | js::Shape *start = *startp; | |
27950 | ; | |
27951 | ||
27952 | if (start->hasTable()) | |
27953 | return start->getTable()->search(id, adding); | |
27954 | ||
27955 | if (start->numLinearSearches == PropertyTable::MAX_LINEAR_SEARCHES) { | |
27956 | if (start->hashify(rt)) | |
27957 | return start->getTable()->search(id, adding); | |
27958 | ||
27959 | ((void) 0); | |
27960 | } else { | |
27961 | ((void) 0); | |
27962 | start->numLinearSearches++; | |
27963 | } | |
27964 | # 898 "jsscope.h" | |
27965 | js::Shape **spp; | |
27966 | for (spp = startp; js::Shape *shape = *spp; spp = &shape->parent) { | |
27967 | if (shape->id == id) { | |
27968 | ; | |
27969 | return spp; | |
27970 | } | |
27971 | } | |
27972 | ; | |
27973 | return spp; | |
27974 | } | |
27975 | ||
27976 | ||
27977 | ||
27978 | inline | |
27979 | ||
27980 | # 911 "jsscope.h" | |
27981 | bool | |
27982 | Shape::isSharedPermanent() const | |
27983 | { | |
27984 | return (~attrs & (0x40 | 0x04)) == 0; | |
27985 | } | |
27986 | ||
27987 | } | |
27988 | # 67 "jsxml.cpp" 2 | |
27989 | ||
27990 | ||
27991 | ||
27992 | ||
27993 | ||
27994 | ||
27995 | # 1 "jsatominlines.h" 1 | |
27996 | # 49 "jsatominlines.h" | |
27997 | inline | |
27998 | ||
27999 | # 49 "jsatominlines.h" | |
28000 | bool | |
28001 | js_ValueToAtom(JSContext *cx, const js::Value &v, JSAtom **atomp) | |
28002 | { | |
28003 | JSString *str; | |
28004 | JSAtom *atom; | |
28005 | # 62 "jsatominlines.h" | |
28006 | if (v.isString()) { | |
28007 | str = v.toString(); | |
28008 | if (str->isAtomized()) { | |
28009 | *atomp = (((void) 0), (JSAtom *)str); | |
28010 | return true; | |
28011 | } | |
28012 | } else { | |
28013 | str = js_ValueToString(cx, v); | |
28014 | if (!str) | |
28015 | return false; | |
28016 | } | |
28017 | atom = js_AtomizeString(cx, str, 0); | |
28018 | if (!atom) | |
28019 | return false; | |
28020 | *atomp = atom; | |
28021 | return true; | |
28022 | } | |
28023 | ||
28024 | inline | |
28025 | ||
28026 | # 80 "jsatominlines.h" | |
28027 | bool | |
28028 | js_ValueToStringId(JSContext *cx, const js::Value &v, jsid *idp) | |
28029 | { | |
28030 | JSAtom *atom; | |
28031 | if (js_ValueToAtom(cx, v, &atom)) { | |
28032 | *idp = ATOM_TO_JSID(atom); | |
28033 | return true; | |
28034 | } | |
28035 | return false; | |
28036 | } | |
28037 | ||
28038 | inline | |
28039 | ||
28040 | # 91 "jsatominlines.h" | |
28041 | bool | |
28042 | js_InternNonIntElementId(JSContext *cx, JSObject *obj, const js::Value &idval, | |
28043 | jsid *idp) | |
28044 | { | |
28045 | ((void) 0); | |
28046 | ||
28047 | ||
28048 | extern bool js_InternNonIntElementIdSlow(JSContext *, JSObject *, | |
28049 | const js::Value &, jsid *); | |
28050 | if (idval.isObject()) | |
28051 | return js_InternNonIntElementIdSlow(cx, obj, idval, idp); | |
28052 | ||
28053 | ||
28054 | return js_ValueToStringId(cx, idval, idp); | |
28055 | } | |
28056 | ||
28057 | inline | |
28058 | ||
28059 | # 107 "jsatominlines.h" | |
28060 | bool | |
28061 | js_InternNonIntElementId(JSContext *cx, JSObject *obj, const js::Value &idval, | |
28062 | jsid *idp, js::Value *vp) | |
28063 | { | |
28064 | ((void) 0); | |
28065 | ||
28066 | ||
28067 | extern bool js_InternNonIntElementIdSlow(JSContext *, JSObject *, | |
28068 | const js::Value &, | |
28069 | jsid *, js::Value *); | |
28070 | if (idval.isObject()) | |
28071 | return js_InternNonIntElementIdSlow(cx, obj, idval, idp, vp); | |
28072 | ||
28073 | ||
28074 | JSAtom *atom; | |
28075 | if (js_ValueToAtom(cx, idval, &atom)) { | |
28076 | *idp = ATOM_TO_JSID(atom); | |
28077 | vp->setString((atom)); | |
28078 | return true; | |
28079 | } | |
28080 | return false; | |
28081 | } | |
28082 | ||
28083 | inline | |
28084 | ||
28085 | # 130 "jsatominlines.h" | |
28086 | bool | |
28087 | js_Int32ToId(JSContext* cx, int32 index, jsid* id) | |
28088 | { | |
28089 | if (INT_FITS_IN_JSID(index)) { | |
28090 | *id = INT_TO_JSID(index); | |
28091 | return true; | |
28092 | } | |
28093 | ||
28094 | JSString* str = js_NumberToString(cx, index); | |
28095 | if (!str) | |
28096 | return false; | |
28097 | ||
28098 | return js_ValueToStringId(cx, js::StringValue(str), id); | |
28099 | } | |
28100 | # 74 "jsxml.cpp" 2 | |
28101 | ||
28102 | # 1 "jsinterpinlines.h" 1 | |
28103 | # 48 "jsinterpinlines.h" | |
28104 | # 1 "jsprobes.h" 1 | |
28105 | # 45 "jsprobes.h" | |
28106 | namespace js { | |
28107 | ||
28108 | class Probes { | |
28109 | static const char nullName[]; | |
28110 | ||
28111 | static const char *FunctionClassname(const JSFunction *fun); | |
28112 | static const char *ScriptFilename(JSScript *script); | |
28113 | static int FunctionLineNumber(JSContext *cx, const JSFunction *fun); | |
28114 | static const char *FunctionName(JSContext *cx, const JSFunction *fun, JSAutoByteString *bytes); | |
28115 | ||
28116 | static void enterJSFunImpl(JSContext *cx, JSFunction *fun, JSScript *script); | |
28117 | static void handleFunctionReturn(JSContext *cx, JSFunction *fun, JSScript *script); | |
28118 | static void finalizeObjectImpl(JSObject *obj); | |
28119 | public: | |
28120 | static bool callTrackingActive(JSContext *); | |
28121 | ||
28122 | static void enterJSFun(JSContext *, JSFunction *, JSScript *, int counter = 1); | |
28123 | static void exitJSFun(JSContext *, JSFunction *, JSScript *, int counter = 0); | |
28124 | ||
28125 | static void startExecution(JSContext *cx, JSScript *script); | |
28126 | static void stopExecution(JSContext *cx, JSScript *script); | |
28127 | ||
28128 | static void resizeHeap(JSCompartment *compartment, size_t oldSize, size_t newSize); | |
28129 | ||
28130 | ||
28131 | static void createObject(JSContext *cx, JSObject *obj); | |
28132 | ||
28133 | static void resizeObject(JSContext *cx, JSObject *obj, size_t oldSize, size_t newSize); | |
28134 | ||
28135 | ||
28136 | static void finalizeObject(JSObject *obj); | |
28137 | # 85 "jsprobes.h" | |
28138 | static void createString(JSContext *cx, JSString *string, size_t length); | |
28139 | ||
28140 | ||
28141 | ||
28142 | ||
28143 | static void finalizeString(JSString *string); | |
28144 | ||
28145 | static void compileScriptBegin(JSContext *cx, const char *filename, int lineno); | |
28146 | static void compileScriptEnd(JSContext *cx, JSScript *script, const char *filename, int lineno); | |
28147 | ||
28148 | static void calloutBegin(JSContext *cx, JSFunction *fun); | |
28149 | static void calloutEnd(JSContext *cx, JSFunction *fun); | |
28150 | ||
28151 | static void acquireMemory(JSContext *cx, void *address, size_t nbytes); | |
28152 | static void releaseMemory(JSContext *cx, void *address, size_t nbytes); | |
28153 | ||
28154 | static void GCStart(JSCompartment *compartment); | |
28155 | static void GCEnd(JSCompartment *compartment); | |
28156 | static void GCStartMarkPhase(JSCompartment *compartment); | |
28157 | ||
28158 | static void GCEndMarkPhase(JSCompartment *compartment); | |
28159 | static void GCStartSweepPhase(JSCompartment *compartment); | |
28160 | static void GCEndSweepPhase(JSCompartment *compartment); | |
28161 | ||
28162 | static bool CustomMark(JSString *string); | |
28163 | static bool CustomMark(const char *string); | |
28164 | static bool CustomMark(int marker); | |
28165 | ||
28166 | static bool startProfiling(); | |
28167 | static void stopProfiling(); | |
28168 | }; | |
28169 | ||
28170 | inline | |
28171 | ||
28172 | # 117 "jsprobes.h" | |
28173 | bool | |
28174 | Probes::callTrackingActive(JSContext *cx) | |
28175 | { | |
28176 | # 132 "jsprobes.h" | |
28177 | return false; | |
28178 | } | |
28179 | ||
28180 | inline void | |
28181 | Probes::enterJSFun(JSContext *cx, JSFunction *fun, JSScript *script, int counter) | |
28182 | { | |
28183 | ||
28184 | ||
28185 | ||
28186 | ||
28187 | ||
28188 | ||
28189 | ||
28190 | } | |
28191 | ||
28192 | inline void | |
28193 | Probes::exitJSFun(JSContext *cx, JSFunction *fun, JSScript *script, int counter) | |
28194 | { | |
28195 | # 159 "jsprobes.h" | |
28196 | } | |
28197 | ||
28198 | inline void | |
28199 | Probes::createObject(JSContext *cx, JSObject *obj) | |
28200 | { | |
28201 | ||
28202 | ||
28203 | ||
28204 | ||
28205 | ||
28206 | ||
28207 | } | |
28208 | ||
28209 | inline void | |
28210 | Probes::finalizeObject(JSObject *obj) | |
28211 | { | |
28212 | # 183 "jsprobes.h" | |
28213 | } | |
28214 | ||
28215 | inline void | |
28216 | Probes::startExecution(JSContext *cx, JSScript *script) | |
28217 | { | |
28218 | # 196 "jsprobes.h" | |
28219 | } | |
28220 | ||
28221 | inline void | |
28222 | Probes::stopExecution(JSContext *cx, JSScript *script) | |
28223 | { | |
28224 | # 209 "jsprobes.h" | |
28225 | } | |
28226 | ||
28227 | ||
28228 | ||
28229 | ||
28230 | ||
28231 | ||
28232 | inline void Probes::resizeHeap(JSCompartment *compartment, size_t oldSize, size_t newSize) {} | |
28233 | inline void Probes::resizeObject(JSContext *cx, JSObject *obj, size_t oldSize, size_t newSize) {} | |
28234 | inline void Probes::createString(JSContext *cx, JSString *string, size_t length) {} | |
28235 | inline void Probes::finalizeString(JSString *string) {} | |
28236 | inline void Probes::compileScriptBegin(JSContext *cx, const char *filename, int lineno) {} | |
28237 | inline void Probes::compileScriptEnd(JSContext *cx, JSScript *script, const char *filename, int lineno) {} | |
28238 | inline void Probes::calloutBegin(JSContext *cx, JSFunction *fun) {} | |
28239 | inline void Probes::calloutEnd(JSContext *cx, JSFunction *fun) {} | |
28240 | inline void Probes::acquireMemory(JSContext *cx, void *address, size_t nbytes) {} | |
28241 | inline void Probes::releaseMemory(JSContext *cx, void *address, size_t nbytes) {} | |
28242 | inline void Probes::GCStart(JSCompartment *compartment) {} | |
28243 | inline void Probes::GCEnd(JSCompartment *compartment) {} | |
28244 | inline void Probes::GCStartMarkPhase(JSCompartment *compartment) {} | |
28245 | inline void Probes::GCEndMarkPhase(JSCompartment *compartment) {} | |
28246 | inline void Probes::GCStartSweepPhase(JSCompartment *compartment) {} | |
28247 | inline void Probes::GCEndSweepPhase(JSCompartment *compartment) {} | |
28248 | inline bool Probes::CustomMark(JSString *string) { return (JSIntn)1; } | |
28249 | inline bool Probes::CustomMark(const char *string) { return (JSIntn)1; } | |
28250 | inline bool Probes::CustomMark(int marker) { return (JSIntn)1; } | |
28251 | ||
28252 | struct AutoFunctionCallProbe { | |
28253 | JSContext * const cx; | |
28254 | JSFunction *fun; | |
28255 | JSScript *script; | |
28256 | ||
28257 | ||
28258 | AutoFunctionCallProbe(JSContext *cx, JSFunction *fun, JSScript *script | |
28259 | ) | |
28260 | : cx(cx), fun(fun), script(script) | |
28261 | { | |
28262 | do { } while (0); | |
28263 | Probes::enterJSFun(cx, fun, script); | |
28264 | } | |
28265 | ||
28266 | ~AutoFunctionCallProbe() { | |
28267 | Probes::exitJSFun(cx, fun, script); | |
28268 | } | |
28269 | }; | |
28270 | ||
28271 | } | |
28272 | # 49 "jsinterpinlines.h" 2 | |
28273 | ||
28274 | # 1 "methodjit/MethodJIT.h" 1 | |
28275 | # 51 "jsinterpinlines.h" 2 | |
28276 | ||
28277 | # 1 "jsfuninlines.h" 1 | |
28278 | # 46 "jsfuninlines.h" | |
28279 | inline | |
28280 | ||
28281 | # 46 "jsfuninlines.h" | |
28282 | bool | |
28283 | JSFunction::inStrictMode() const | |
28284 | { | |
28285 | return script()->strictModeCode; | |
28286 | } | |
28287 | # 53 "jsinterpinlines.h" 2 | |
28288 | ||
28289 | inline void | |
28290 | JSStackFrame::initPrev(JSContext *cx) | |
28291 | { | |
28292 | ((void) 0); | |
28293 | if (JSFrameRegs *regs = cx->regs) { | |
28294 | prev_ = regs->fp; | |
28295 | prevpc_ = regs->pc; | |
28296 | ((void) 0) | |
28297 | ; | |
28298 | } else { | |
28299 | prev_ = __null; | |
28300 | ||
28301 | ||
28302 | ||
28303 | } | |
28304 | } | |
28305 | ||
28306 | inline void | |
28307 | JSStackFrame::resetGeneratorPrev(JSContext *cx) | |
28308 | { | |
28309 | flags_ |= JSFRAME_HAS_PREVPC; | |
28310 | initPrev(cx); | |
28311 | } | |
28312 | ||
28313 | inline void | |
28314 | JSStackFrame::initCallFrame(JSContext *cx, JSObject &callee, JSFunction *fun, | |
28315 | uint32 nactual, uint32 flagsArg) | |
28316 | { | |
28317 | ((void) 0) | |
28318 | ||
28319 | ; | |
28320 | ((void) 0); | |
28321 | ||
28322 | ||
28323 | flags_ = JSFRAME_FUNCTION | JSFRAME_HAS_PREVPC | JSFRAME_HAS_SCOPECHAIN | flagsArg; | |
28324 | exec.fun = fun; | |
28325 | args.nactual = nactual; | |
28326 | scopeChain_ = callee.getParent(); | |
28327 | initPrev(cx); | |
28328 | ((void) 0); | |
28329 | ((void) 0); | |
28330 | ((void) 0); | |
28331 | ||
28332 | ((void) 0); | |
28333 | } | |
28334 | ||
28335 | inline void | |
28336 | JSStackFrame::resetInvokeCallFrame() | |
28337 | { | |
28338 | ||
28339 | ||
28340 | ((void) 0) | |
28341 | ||
28342 | ||
28343 | ||
28344 | ||
28345 | ||
28346 | ||
28347 | ||
28348 | ; | |
28349 | flags_ &= JSFRAME_FUNCTION | | |
28350 | JSFRAME_OVERFLOW_ARGS | | |
28351 | JSFRAME_HAS_PREVPC | | |
28352 | JSFRAME_UNDERFLOW_ARGS; | |
28353 | ||
28354 | ((void) 0); | |
28355 | scopeChain_ = callee().getParent(); | |
28356 | } | |
28357 | ||
28358 | inline void | |
28359 | JSStackFrame::initCallFrameCallerHalf(JSContext *cx, uint32 flagsArg, | |
28360 | void *ncode) | |
28361 | { | |
28362 | ((void) 0) | |
28363 | ||
28364 | ||
28365 | ; | |
28366 | ||
28367 | flags_ = JSFRAME_FUNCTION | flagsArg; | |
28368 | prev_ = cx->regs->fp; | |
28369 | ncode_ = ncode; | |
28370 | } | |
28371 | ||
28372 | ||
28373 | ||
28374 | ||
28375 | ||
28376 | inline void | |
28377 | JSStackFrame::initCallFrameEarlyPrologue(JSFunction *fun, uint32 nactual) | |
28378 | { | |
28379 | exec.fun = fun; | |
28380 | if (flags_ & (JSFRAME_OVERFLOW_ARGS | JSFRAME_UNDERFLOW_ARGS)) | |
28381 | args.nactual = nactual; | |
28382 | } | |
28383 | ||
28384 | ||
28385 | ||
28386 | ||
28387 | ||
28388 | inline void | |
28389 | JSStackFrame::initCallFrameLatePrologue() | |
28390 | { | |
28391 | SetValueRangeToUndefined(slots(), script()->nfixed); | |
28392 | } | |
28393 | ||
28394 | inline void | |
28395 | JSStackFrame::initEvalFrame(JSContext *cx, JSScript *script, JSStackFrame *prev, uint32 flagsArg) | |
28396 | { | |
28397 | ((void) 0); | |
28398 | ((void) 0); | |
28399 | ((void) 0); | |
28400 | ||
28401 | ||
28402 | js::Value *dstvp = (js::Value *)this - 2; | |
28403 | js::Value *srcvp = prev->flags_ & (JSFRAME_GLOBAL | JSFRAME_EVAL) | |
28404 | ? (js::Value *)prev - 2 | |
28405 | : prev->formalArgs() - 2; | |
28406 | dstvp[0] = srcvp[0]; | |
28407 | dstvp[1] = srcvp[1]; | |
28408 | ((void) 0) | |
28409 | ; | |
28410 | ||
28411 | ||
28412 | flags_ = flagsArg | JSFRAME_HAS_PREVPC | JSFRAME_HAS_SCOPECHAIN | | |
28413 | (prev->flags_ & (JSFRAME_FUNCTION | JSFRAME_GLOBAL | JSFRAME_HAS_CALL_OBJ)); | |
28414 | if (isFunctionFrame()) { | |
28415 | exec = prev->exec; | |
28416 | args.script = script; | |
28417 | } else { | |
28418 | exec.script = script; | |
28419 | } | |
28420 | ||
28421 | scopeChain_ = &prev->scopeChain(); | |
28422 | ((void) 0); | |
28423 | ||
28424 | prev_ = prev; | |
28425 | prevpc_ = prev->pc(cx); | |
28426 | ((void) 0); | |
28427 | ((void) 0); | |
28428 | setAnnotation(prev->annotation()); | |
28429 | } | |
28430 | ||
28431 | inline void | |
28432 | JSStackFrame::initGlobalFrame(JSScript *script, JSObject &chain, uint32 flagsArg) | |
28433 | { | |
28434 | ((void) 0); | |
28435 | ||
28436 | ||
28437 | js::Value *vp = (js::Value *)this - 2; | |
28438 | vp[0].setUndefined(); | |
28439 | vp[1].setUndefined(); | |
28440 | ||
28441 | ||
28442 | flags_ = flagsArg | JSFRAME_GLOBAL | JSFRAME_HAS_PREVPC | JSFRAME_HAS_SCOPECHAIN; | |
28443 | exec.script = script; | |
28444 | args.script = (JSScript *)0xbad; | |
28445 | scopeChain_ = &chain; | |
28446 | prev_ = __null; | |
28447 | ((void) 0); | |
28448 | ((void) 0); | |
28449 | ((void) 0); | |
28450 | } | |
28451 | ||
28452 | inline void | |
28453 | JSStackFrame::initDummyFrame(JSContext *cx, JSObject &chain) | |
28454 | { | |
28455 | js::PodZero(this); | |
28456 | flags_ = JSFRAME_DUMMY | JSFRAME_HAS_PREVPC | JSFRAME_HAS_SCOPECHAIN; | |
28457 | initPrev(cx); | |
28458 | chain.isGlobal(); | |
28459 | setScopeChainNoCallObj(chain); | |
28460 | } | |
28461 | ||
28462 | inline void | |
28463 | JSStackFrame::stealFrameAndSlots(js::Value *vp, JSStackFrame *otherfp, | |
28464 | js::Value *othervp, js::Value *othersp) | |
28465 | { | |
28466 | ((void) 0); | |
28467 | ((void) 0); | |
28468 | ((void) 0); | |
28469 | ((void) 0); | |
28470 | ||
28471 | PodCopy(vp, othervp, othersp - othervp); | |
28472 | ((void) 0); | |
28473 | ||
28474 | ||
28475 | if (otherfp->hasOverflowArgs()) | |
28476 | Debug_SetValueRangeToCrashOnTouch(othervp, othervp + 2 + otherfp->numFormalArgs()); | |
28477 | ||
28478 | ||
28479 | ||
28480 | ||
28481 | ||
28482 | ||
28483 | ||
28484 | if (hasCallObj()) { | |
28485 | callObj().setPrivate(this); | |
28486 | otherfp->flags_ &= ~JSFRAME_HAS_CALL_OBJ; | |
28487 | if (js_IsNamedLambda(fun())) { | |
28488 | JSObject *env = callObj().getParent(); | |
28489 | ((void) 0); | |
28490 | env->setPrivate(this); | |
28491 | } | |
28492 | } | |
28493 | if (hasArgsObj()) { | |
28494 | JSObject &args = argsObj(); | |
28495 | ((void) 0); | |
28496 | if (args.isNormalArguments()) | |
28497 | args.setPrivate(this); | |
28498 | else | |
28499 | ((void) 0); | |
28500 | otherfp->flags_ &= ~JSFRAME_HAS_ARGS_OBJ; | |
28501 | } | |
28502 | } | |
28503 | ||
28504 | inline js::Value & | |
28505 | JSStackFrame::canonicalActualArg(uintN i) const | |
28506 | { | |
28507 | if (i < numFormalArgs()) | |
28508 | return formalArg(i); | |
28509 | ((void) 0); | |
28510 | return actualArgs()[i]; | |
28511 | } | |
28512 | ||
28513 | template <class Op> | |
28514 | inline void | |
28515 | JSStackFrame::forEachCanonicalActualArg(Op op) | |
28516 | { | |
28517 | uintN nformal = fun()->nargs; | |
28518 | js::Value *formals = formalArgsEnd() - nformal; | |
28519 | uintN nactual = numActualArgs(); | |
28520 | if (nactual <= nformal) { | |
28521 | uintN i = 0; | |
28522 | js::Value *actualsEnd = formals + nactual; | |
28523 | for (js::Value *p = formals; p != actualsEnd; ++p, ++i) | |
28524 | op(i, p); | |
28525 | } else { | |
28526 | uintN i = 0; | |
28527 | js::Value *formalsEnd = formalArgsEnd(); | |
28528 | for (js::Value *p = formals; p != formalsEnd; ++p, ++i) | |
28529 | op(i, p); | |
28530 | js::Value *actuals = formalsEnd - (nactual + 2); | |
28531 | js::Value *actualsEnd = formals - 2; | |
28532 | for (js::Value *p = actuals; p != actualsEnd; ++p, ++i) | |
28533 | op(i, p); | |
28534 | } | |
28535 | } | |
28536 | ||
28537 | template <class Op> | |
28538 | inline void | |
28539 | JSStackFrame::forEachFormalArg(Op op) | |
28540 | { | |
28541 | js::Value *formals = formalArgsEnd() - fun()->nargs; | |
28542 | js::Value *formalsEnd = formalArgsEnd(); | |
28543 | uintN i = 0; | |
28544 | for (js::Value *p = formals; p != formalsEnd; ++p, ++i) | |
28545 | op(i, p); | |
28546 | } | |
28547 | ||
28548 | namespace js { | |
28549 | ||
28550 | struct CopyNonHoleArgsTo | |
28551 | { | |
28552 | CopyNonHoleArgsTo(JSObject *aobj, Value *dst) : aobj(aobj), dst(dst) {} | |
28553 | JSObject *aobj; | |
28554 | Value *dst; | |
28555 | void operator()(uintN argi, Value *src) { | |
28556 | if (aobj->getArgsElement(argi).isMagic(JS_ARGS_HOLE)) | |
28557 | dst->setUndefined(); | |
28558 | else | |
28559 | *dst = *src; | |
28560 | ++dst; | |
28561 | } | |
28562 | }; | |
28563 | ||
28564 | struct CopyTo | |
28565 | { | |
28566 | Value *dst; | |
28567 | CopyTo(Value *dst) : dst(dst) {} | |
28568 | void operator()(uintN, Value *src) { | |
28569 | *dst++ = *src; | |
28570 | } | |
28571 | }; | |
28572 | ||
28573 | } | |
28574 | ||
28575 | __attribute__((always_inline)) inline void | |
28576 | JSStackFrame::clearMissingArgs() | |
28577 | { | |
28578 | if (flags_ & JSFRAME_UNDERFLOW_ARGS) | |
28579 | SetValueRangeToUndefined(formalArgs() + numActualArgs(), formalArgsEnd()); | |
28580 | } | |
28581 | ||
28582 | inline | |
28583 | ||
28584 | # 347 "jsinterpinlines.h" | |
28585 | bool | |
28586 | JSStackFrame::computeThis(JSContext *cx) | |
28587 | { | |
28588 | js::Value &thisv = thisValue(); | |
28589 | if (thisv.isObject()) | |
28590 | return true; | |
28591 | if (isFunctionFrame()) { | |
28592 | if (fun()->inStrictMode()) | |
28593 | return true; | |
28594 | ||
28595 | ||
28596 | ||
28597 | ||
28598 | ||
28599 | ||
28600 | ||
28601 | ((void) 0); | |
28602 | } | |
28603 | if (!js::BoxThisForVp(cx, &thisv - 1)) | |
28604 | return false; | |
28605 | return true; | |
28606 | } | |
28607 | ||
28608 | inline JSObject & | |
28609 | JSStackFrame::varobj(js::StackSegment *seg) const | |
28610 | { | |
28611 | ((void) 0); | |
28612 | return isFunctionFrame() ? callObj() : seg->getInitialVarObj(); | |
28613 | } | |
28614 | ||
28615 | inline JSObject & | |
28616 | JSStackFrame::varobj(JSContext *cx) const | |
28617 | { | |
28618 | ((void) 0); | |
28619 | return isFunctionFrame() ? callObj() : cx->activeSegment()->getInitialVarObj(); | |
28620 | } | |
28621 | ||
28622 | inline uintN | |
28623 | JSStackFrame::numActualArgs() const | |
28624 | { | |
28625 | ((void) 0); | |
28626 | if ((__builtin_expect((flags_ & (JSFRAME_OVERFLOW_ARGS | JSFRAME_UNDERFLOW_ARGS)), 0))) | |
28627 | return hasArgsObj() ? argsObj().getArgsInitialLength() : args.nactual; | |
28628 | return numFormalArgs(); | |
28629 | } | |
28630 | ||
28631 | inline js::Value * | |
28632 | JSStackFrame::actualArgs() const | |
28633 | { | |
28634 | ((void) 0); | |
28635 | js::Value *argv = formalArgs(); | |
28636 | if ((__builtin_expect((flags_ & JSFRAME_OVERFLOW_ARGS), 0))) { | |
28637 | uintN nactual = hasArgsObj() ? argsObj().getArgsInitialLength() : args.nactual; | |
28638 | return argv - (2 + nactual); | |
28639 | } | |
28640 | return argv; | |
28641 | } | |
28642 | ||
28643 | inline js::Value * | |
28644 | JSStackFrame::actualArgsEnd() const | |
28645 | { | |
28646 | ((void) 0); | |
28647 | if ((__builtin_expect((flags_ & JSFRAME_OVERFLOW_ARGS), 0))) | |
28648 | return formalArgs() - 2; | |
28649 | return formalArgs() + numActualArgs(); | |
28650 | } | |
28651 | ||
28652 | inline void | |
28653 | JSStackFrame::setArgsObj(JSObject &obj) | |
28654 | { | |
28655 | ((void) 0); | |
28656 | ((void) 0); | |
28657 | args.obj = &obj; | |
28658 | flags_ |= JSFRAME_HAS_ARGS_OBJ; | |
28659 | } | |
28660 | ||
28661 | inline void | |
28662 | JSStackFrame::clearArgsObj() | |
28663 | { | |
28664 | ((void) 0); | |
28665 | args.nactual = args.obj->getArgsInitialLength(); | |
28666 | flags_ ^= JSFRAME_HAS_ARGS_OBJ; | |
28667 | } | |
28668 | ||
28669 | inline void | |
28670 | JSStackFrame::setScopeChainNoCallObj(JSObject &obj) | |
28671 | { | |
28672 | # 442 "jsinterpinlines.h" | |
28673 | scopeChain_ = &obj; | |
28674 | flags_ |= JSFRAME_HAS_SCOPECHAIN; | |
28675 | ((void) 0); | |
28676 | } | |
28677 | ||
28678 | inline void | |
28679 | JSStackFrame::setScopeChainAndCallObj(JSObject &obj) | |
28680 | { | |
28681 | ((void) 0); | |
28682 | ((void) 0); | |
28683 | scopeChain_ = &obj; | |
28684 | flags_ |= JSFRAME_HAS_SCOPECHAIN | JSFRAME_HAS_CALL_OBJ; | |
28685 | } | |
28686 | ||
28687 | inline void | |
28688 | JSStackFrame::clearCallObj() | |
28689 | { | |
28690 | ((void) 0); | |
28691 | flags_ ^= JSFRAME_HAS_CALL_OBJ; | |
28692 | } | |
28693 | ||
28694 | inline JSObject & | |
28695 | JSStackFrame::callObj() const | |
28696 | { | |
28697 | ((void) 0); | |
28698 | JSObject *pobj = &scopeChain(); | |
28699 | while ((__builtin_expect((pobj->getClass() != &js_CallClass), 0))) { | |
28700 | ((void) 0); | |
28701 | pobj = pobj->getParent(); | |
28702 | } | |
28703 | return *pobj; | |
28704 | } | |
28705 | ||
28706 | inline JSObject * | |
28707 | JSStackFrame::maybeCallObj() const | |
28708 | { | |
28709 | return hasCallObj() ? &callObj() : __null; | |
28710 | } | |
28711 | ||
28712 | namespace js { | |
28713 | ||
28714 | class AutoPreserveEnumerators { | |
28715 | JSContext *cx; | |
28716 | JSObject *enumerators; | |
28717 | ||
28718 | public: | |
28719 | AutoPreserveEnumerators(JSContext *cx) : cx(cx), enumerators(cx->enumerators) | |
28720 | { | |
28721 | } | |
28722 | ||
28723 | ~AutoPreserveEnumerators() | |
28724 | { | |
28725 | cx->enumerators = enumerators; | |
28726 | } | |
28727 | }; | |
28728 | ||
28729 | struct AutoInterpPreparer { | |
28730 | JSContext *cx; | |
28731 | JSScript *script; | |
28732 | ||
28733 | AutoInterpPreparer(JSContext *cx, JSScript *script) | |
28734 | : cx(cx), script(script) | |
28735 | { | |
28736 | cx->interpLevel++; | |
28737 | } | |
28738 | ||
28739 | ~AutoInterpPreparer() | |
28740 | { | |
28741 | --cx->interpLevel; | |
28742 | } | |
28743 | }; | |
28744 | ||
28745 | inline void | |
28746 | PutActivationObjects(JSContext *cx, JSStackFrame *fp) | |
28747 | { | |
28748 | ((void) 0); | |
28749 | ((void) 0); | |
28750 | ||
28751 | ||
28752 | if (fp->hasCallObj()) { | |
28753 | js_PutCallObject(cx, fp); | |
28754 | } else if (fp->hasArgsObj()) { | |
28755 | js_PutArgsObject(cx, fp); | |
28756 | } | |
28757 | } | |
28758 | ||
28759 | ||
28760 | ||
28761 | ||
28762 | ||
28763 | ||
28764 | inline void | |
28765 | PutOwnedActivationObjects(JSContext *cx, JSStackFrame *fp) | |
28766 | { | |
28767 | ((void) 0); | |
28768 | if (!fp->isEvalFrame() || fp->script()->strictModeCode) | |
28769 | PutActivationObjects(cx, fp); | |
28770 | } | |
28771 | ||
28772 | class InvokeSessionGuard | |
28773 | { | |
28774 | InvokeArgsGuard args_; | |
28775 | InvokeFrameGuard frame_; | |
28776 | Value savedCallee_, savedThis_; | |
28777 | Value *formals_, *actuals_; | |
28778 | unsigned nformals_; | |
28779 | JSScript *script_; | |
28780 | Value *stackLimit_; | |
28781 | jsbytecode *stop_; | |
28782 | ||
28783 | bool optimized() const { return frame_.pushed(); } | |
28784 | ||
28785 | public: | |
28786 | InvokeSessionGuard() : args_(), frame_() {} | |
28787 | inline ~InvokeSessionGuard(); | |
28788 | ||
28789 | bool start(JSContext *cx, const Value &callee, const Value &thisv, uintN argc); | |
28790 | bool invoke(JSContext *cx) const; | |
28791 | ||
28792 | bool started() const { | |
28793 | return args_.pushed(); | |
28794 | } | |
28795 | ||
28796 | Value &operator[](unsigned i) const { | |
28797 | ((void) 0); | |
28798 | Value &arg = i < nformals_ ? formals_[i] : actuals_[i]; | |
28799 | ((void) 0); | |
28800 | ((void) 0); | |
28801 | return arg; | |
28802 | } | |
28803 | ||
28804 | uintN argc() const { | |
28805 | return args_.argc(); | |
28806 | } | |
28807 | ||
28808 | const Value &rval() const { | |
28809 | return optimized() ? frame_.fp()->returnValue() : args_.rval(); | |
28810 | } | |
28811 | }; | |
28812 | ||
28813 | inline | |
28814 | InvokeSessionGuard::~InvokeSessionGuard() | |
28815 | { | |
28816 | if (frame_.pushed()) | |
28817 | PutActivationObjects(frame_.pushedFrameContext(), frame_.fp()); | |
28818 | } | |
28819 | ||
28820 | inline | |
28821 | ||
28822 | # 589 "jsinterpinlines.h" | |
28823 | bool | |
28824 | InvokeSessionGuard::invoke(JSContext *cx) const | |
28825 | { | |
28826 | ||
28827 | ||
28828 | ||
28829 | formals_[-2] = savedCallee_; | |
28830 | formals_[-1] = savedThis_; | |
28831 | ||
28832 | ||
28833 | ||
28834 | ||
28835 | ||
28836 | if (!optimized()) | |
28837 | ||
28838 | return Invoke(cx, args_, 0); | |
28839 | ||
28840 | ||
28841 | JSStackFrame *fp = frame_.fp(); | |
28842 | fp->clearMissingArgs(); | |
28843 | PutActivationObjects(cx, frame_.fp()); | |
28844 | fp->resetInvokeCallFrame(); | |
28845 | SetValueRangeToUndefined(fp->slots(), script_->nfixed); | |
28846 | ||
28847 | JSBool ok; | |
28848 | { | |
28849 | AutoPreserveEnumerators preserve(cx); | |
28850 | Probes::enterJSFun(cx, fp->fun(), script_); | |
28851 | ||
28852 | ||
28853 | ||
28854 | ||
28855 | ||
28856 | cx->regs->pc = script_->code; | |
28857 | ok = Interpret(cx, cx->fp()); | |
28858 | ||
28859 | Probes::exitJSFun(cx, fp->fun(), script_); | |
28860 | } | |
28861 | ||
28862 | ||
28863 | return ok; | |
28864 | } | |
28865 | ||
28866 | namespace detail { | |
28867 | ||
28868 | template<typename T> class PrimitiveBehavior { }; | |
28869 | ||
28870 | template<> | |
28871 | class PrimitiveBehavior<JSString *> { | |
28872 | public: | |
28873 | static inline bool isType(const Value &v) { return v.isString(); } | |
28874 | static inline JSString *extract(const Value &v) { return v.toString(); } | |
28875 | static inline Class *getClass() { return &js_StringClass; } | |
28876 | }; | |
28877 | ||
28878 | template<> | |
28879 | class PrimitiveBehavior<bool> { | |
28880 | public: | |
28881 | static inline bool isType(const Value &v) { return v.isBoolean(); } | |
28882 | static inline bool extract(const Value &v) { return v.toBoolean(); } | |
28883 | static inline Class *getClass() { return &js_BooleanClass; } | |
28884 | }; | |
28885 | ||
28886 | template<> | |
28887 | class PrimitiveBehavior<double> { | |
28888 | public: | |
28889 | static inline bool isType(const Value &v) { return v.isNumber(); } | |
28890 | static inline double extract(const Value &v) { return v.toNumber(); } | |
28891 | static inline Class *getClass() { return &js_NumberClass; } | |
28892 | }; | |
28893 | ||
28894 | } | |
28895 | # 703 "jsinterpinlines.h" | |
28896 | inline | |
28897 | ||
28898 | # 703 "jsinterpinlines.h" | |
28899 | bool | |
28900 | ComputeImplicitThis(JSContext *cx, JSObject *obj, const Value &funval, Value *vp) | |
28901 | { | |
28902 | vp->setUndefined(); | |
28903 | ||
28904 | if (!funval.isObject()) | |
28905 | return true; | |
28906 | ||
28907 | if (!obj->isGlobal()) { | |
28908 | if (IsCacheableNonGlobalScope(obj)) | |
28909 | return true; | |
28910 | } else { | |
28911 | JSObject *callee = &funval.toObject(); | |
28912 | ||
28913 | if (callee->isProxy()) { | |
28914 | callee = callee->unwrap(); | |
28915 | if (!callee->isFunction()) | |
28916 | return true; | |
28917 | } | |
28918 | if (callee->isFunction()) { | |
28919 | JSFunction *fun = callee->getFunctionPrivate(); | |
28920 | if (fun->isInterpreted() && fun->inStrictMode()) | |
28921 | return true; | |
28922 | } | |
28923 | if (callee->getGlobal() == cx->fp()->scopeChain().getGlobal()) | |
28924 | return true;; | |
28925 | } | |
28926 | ||
28927 | obj = obj->thisObject(cx); | |
28928 | if (!obj) | |
28929 | return false; | |
28930 | ||
28931 | vp->setObject(*obj); | |
28932 | return true; | |
28933 | } | |
28934 | ||
28935 | template <typename T> | |
28936 | ||
28937 | bool | |
28938 | # 741 "jsinterpinlines.h" | |
28939 | GetPrimitiveThis(JSContext *cx, Value *vp, T *v) | |
28940 | { | |
28941 | typedef detail::PrimitiveBehavior<T> Behavior; | |
28942 | ||
28943 | const Value &thisv = vp[1]; | |
28944 | if (Behavior::isType(thisv)) { | |
28945 | *v = Behavior::extract(thisv); | |
28946 | return true; | |
28947 | } | |
28948 | ||
28949 | if (thisv.isObject() && thisv.toObject().getClass() == Behavior::getClass()) { | |
28950 | *v = Behavior::extract(thisv.toObject().getPrimitiveThis()); | |
28951 | return true; | |
28952 | } | |
28953 | ||
28954 | ReportIncompatibleMethod(cx, vp, Behavior::getClass()); | |
28955 | return false; | |
28956 | } | |
28957 | # 771 "jsinterpinlines.h" | |
28958 | __attribute__((always_inline)) inline JSObject * | |
28959 | ValuePropertyBearer(JSContext *cx, const Value &v, int spindex) | |
28960 | { | |
28961 | if (v.isObject()) | |
28962 | return &v.toObject(); | |
28963 | ||
28964 | JSProtoKey protoKey; | |
28965 | if (v.isString()) { | |
28966 | protoKey = JSProto_String; | |
28967 | } else if (v.isNumber()) { | |
28968 | protoKey = JSProto_Number; | |
28969 | } else if (v.isBoolean()) { | |
28970 | protoKey = JSProto_Boolean; | |
28971 | } else { | |
28972 | ((void) 0); | |
28973 | js_ReportIsNullOrUndefined(cx, spindex, v, __null); | |
28974 | return __null; | |
28975 | } | |
28976 | ||
28977 | JSObject *pobj; | |
28978 | if (!js_GetClassPrototype(cx, __null, protoKey, &pobj)) | |
28979 | return __null; | |
28980 | return pobj; | |
28981 | } | |
28982 | ||
28983 | static inline | |
28984 | ||
28985 | # 796 "jsinterpinlines.h" | |
28986 | bool | |
28987 | ScriptEpilogue(JSContext *cx, JSStackFrame *fp, JSBool ok) | |
28988 | { | |
28989 | if (!fp->isExecuteFrame()) | |
28990 | Probes::exitJSFun(cx, fp->maybeFun(), fp->maybeScript()); | |
28991 | ||
28992 | JSInterpreterHook hook = | |
28993 | fp->isExecuteFrame() ? cx->debugHooks->executeHook : cx->debugHooks->callHook; | |
28994 | ||
28995 | void* hookData; | |
28996 | if ((__builtin_expect((hook != __null), 0)) && (hookData = fp->maybeHookData())) | |
28997 | hook(cx, fp, (JSIntn)0, &ok, hookData); | |
28998 | ||
28999 | if (fp->isEvalFrame()) { | |
29000 | ||
29001 | ||
29002 | ||
29003 | ||
29004 | ||
29005 | ||
29006 | if (fp->script()->strictModeCode) { | |
29007 | ((void) 0); | |
29008 | ((void) 0); | |
29009 | ((void) 0); | |
29010 | ((void) 0); | |
29011 | js_PutCallObject(cx, fp); | |
29012 | } | |
29013 | } else { | |
29014 | ||
29015 | ||
29016 | ||
29017 | ||
29018 | ||
29019 | if (fp->isFunctionFrame() && !fp->isYielding()) { | |
29020 | ((void) 0); | |
29021 | PutActivationObjects(cx, fp); | |
29022 | } | |
29023 | } | |
29024 | ||
29025 | ||
29026 | ||
29027 | ||
29028 | ||
29029 | if (fp->isConstructing() && ok) { | |
29030 | if (fp->returnValue().isPrimitive()) | |
29031 | fp->setReturnValue(ObjectValue(fp->constructorThis())); | |
29032 | ; | |
29033 | } | |
29034 | ||
29035 | return ok; | |
29036 | } | |
29037 | ||
29038 | } | |
29039 | # 76 "jsxml.cpp" 2 | |
29040 | # 1 "jsobjinlines.h" 1 | |
29041 | # 45 "jsobjinlines.h" | |
29042 | # 1 "jsdate.h" 1 | |
29043 | # 49 "jsdate.h" | |
29044 | extern js::Class js_DateClass; | |
29045 | ||
29046 | inline | |
29047 | ||
29048 | # 51 "jsdate.h" | |
29049 | bool | |
29050 | JSObject::isDate() const | |
29051 | { | |
29052 | return getClass() == &js_DateClass; | |
29053 | } | |
29054 | ||
29055 | ||
29056 | ||
29057 | ||
29058 | ||
29059 | ||
29060 | ||
29061 | extern JSObject * | |
29062 | js_InitDateClass(JSContext *cx, JSObject *obj); | |
29063 | # 74 "jsdate.h" | |
29064 | extern __attribute__((visibility ("default"))) JSObject* | |
29065 | js_NewDateObjectMsec(JSContext* cx, jsdouble msec_time); | |
29066 | # 84 "jsdate.h" | |
29067 | extern __attribute__((visibility ("default"))) JSObject* | |
29068 | js_NewDateObject(JSContext* cx, int year, int mon, int mday, | |
29069 | int hour, int min, int sec); | |
29070 | ||
29071 | ||
29072 | ||
29073 | ||
29074 | ||
29075 | extern __attribute__((visibility ("default"))) JSBool | |
29076 | js_DateIsValid(JSContext *cx, JSObject* obj); | |
29077 | ||
29078 | extern __attribute__((visibility ("default"))) int | |
29079 | js_DateGetYear(JSContext *cx, JSObject* obj); | |
29080 | ||
29081 | extern __attribute__((visibility ("default"))) int | |
29082 | js_DateGetMonth(JSContext *cx, JSObject* obj); | |
29083 | ||
29084 | extern __attribute__((visibility ("default"))) int | |
29085 | js_DateGetDate(JSContext *cx, JSObject* obj); | |
29086 | ||
29087 | extern __attribute__((visibility ("default"))) int | |
29088 | js_DateGetHours(JSContext *cx, JSObject* obj); | |
29089 | ||
29090 | extern __attribute__((visibility ("default"))) int | |
29091 | js_DateGetMinutes(JSContext *cx, JSObject* obj); | |
29092 | ||
29093 | extern __attribute__((visibility ("default"))) int | |
29094 | js_DateGetSeconds(JSContext *cx, JSObject* obj); | |
29095 | ||
29096 | extern __attribute__((visibility ("default"))) jsdouble | |
29097 | js_DateGetMsecSinceEpoch(JSContext *cx, JSObject *obj); | |
29098 | ||
29099 | typedef uint32 JSIntervalTime; | |
29100 | ||
29101 | extern __attribute__((visibility ("default"))) JSIntervalTime | |
29102 | js_IntervalNow(); | |
29103 | ||
29104 | ||
29105 | JSBool | |
29106 | js_Date(JSContext *cx, uintN argc, js::Value *vp); | |
29107 | # 46 "jsobjinlines.h" 2 | |
29108 | ||
29109 | # 1 "jsiter.h" 1 | |
29110 | # 49 "jsiter.h" | |
29111 | # 1 "jsversion.h" 1 | |
29112 | # 50 "jsiter.h" 2 | |
29113 | # 69 "jsiter.h" | |
29114 | namespace js { | |
29115 | ||
29116 | struct NativeIterator { | |
29117 | JSObject *obj; | |
29118 | jsid *props_array; | |
29119 | jsid *props_cursor; | |
29120 | jsid *props_end; | |
29121 | uint32 *shapes_array; | |
29122 | uint32 shapes_length; | |
29123 | uint32 shapes_key; | |
29124 | uint32 flags; | |
29125 | JSObject *next; | |
29126 | ||
29127 | bool isKeyIter() const { return (flags & 0x2) == 0; } | |
29128 | ||
29129 | inline jsid *begin() const { | |
29130 | return props_array; | |
29131 | } | |
29132 | ||
29133 | inline jsid *end() const { | |
29134 | return props_end; | |
29135 | } | |
29136 | ||
29137 | size_t numKeys() const { | |
29138 | return end() - begin(); | |
29139 | } | |
29140 | ||
29141 | jsid *current() const { | |
29142 | ((void) 0); | |
29143 | return props_cursor; | |
29144 | } | |
29145 | ||
29146 | void incCursor() { | |
29147 | props_cursor = props_cursor + 1; | |
29148 | } | |
29149 | ||
29150 | static NativeIterator *allocateIterator(JSContext *cx, uint32 slength, | |
29151 | const js::AutoIdVector &props); | |
29152 | void init(JSObject *obj, uintN flags, uint32 slength, uint32 key); | |
29153 | ||
29154 | void mark(JSTracer *trc); | |
29155 | }; | |
29156 | ||
29157 | ||
29158 | bool | |
29159 | # 113 "jsiter.h" | |
29160 | VectorToIdArray(JSContext *cx, js::AutoIdVector &props, JSIdArray **idap); | |
29161 | ||
29162 | __attribute__((visibility ("default"))) bool | |
29163 | GetPropertyNames(JSContext *cx, JSObject *obj, uintN flags, js::AutoIdVector *props); | |
29164 | ||
29165 | ||
29166 | bool | |
29167 | # 119 "jsiter.h" | |
29168 | GetIterator(JSContext *cx, JSObject *obj, uintN flags, js::Value *vp); | |
29169 | ||
29170 | ||
29171 | bool | |
29172 | # 122 "jsiter.h" | |
29173 | VectorToKeyIterator(JSContext *cx, JSObject *obj, uintN flags, js::AutoIdVector &props, js::Value *vp); | |
29174 | ||
29175 | ||
29176 | bool | |
29177 | # 125 "jsiter.h" | |
29178 | VectorToValueIterator(JSContext *cx, JSObject *obj, uintN flags, js::AutoIdVector &props, js::Value *vp); | |
29179 | ||
29180 | ||
29181 | ||
29182 | ||
29183 | ||
29184 | ||
29185 | bool | |
29186 | # 132 "jsiter.h" | |
29187 | EnumeratedIdVectorToIterator(JSContext *cx, JSObject *obj, uintN flags, js::AutoIdVector &props, js::Value *vp); | |
29188 | ||
29189 | } | |
29190 | ||
29191 | ||
29192 | ||
29193 | ||
29194 | ||
29195 | ||
29196 | ||
29197 | extern __attribute__((visibility ("default"))) JSBool | |
29198 | js_ValueToIterator(JSContext *cx, uintN flags, js::Value *vp); | |
29199 | ||
29200 | extern __attribute__((visibility ("default"))) JSBool | |
29201 | js_CloseIterator(JSContext *cx, JSObject *iterObj); | |
29202 | ||
29203 | ||
29204 | bool | |
29205 | # 149 "jsiter.h" | |
29206 | js_SuppressDeletedProperty(JSContext *cx, JSObject *obj, jsid id); | |
29207 | ||
29208 | ||
29209 | bool | |
29210 | # 152 "jsiter.h" | |
29211 | js_SuppressDeletedIndexProperties(JSContext *cx, JSObject *obj, jsint begin, jsint end); | |
29212 | ||
29213 | ||
29214 | ||
29215 | ||
29216 | ||
29217 | ||
29218 | extern JSBool | |
29219 | js_IteratorMore(JSContext *cx, JSObject *iterobj, js::Value *rval); | |
29220 | ||
29221 | extern JSBool | |
29222 | js_IteratorNext(JSContext *cx, JSObject *iterobj, js::Value *rval); | |
29223 | ||
29224 | extern JSBool | |
29225 | js_ThrowStopIteration(JSContext *cx); | |
29226 | ||
29227 | ||
29228 | ||
29229 | ||
29230 | ||
29231 | ||
29232 | typedef enum JSGeneratorState { | |
29233 | JSGEN_NEWBORN, | |
29234 | JSGEN_OPEN, | |
29235 | JSGEN_RUNNING, | |
29236 | JSGEN_CLOSING, | |
29237 | JSGEN_CLOSED | |
29238 | } JSGeneratorState; | |
29239 | ||
29240 | struct JSGenerator { | |
29241 | JSObject *obj; | |
29242 | JSGeneratorState state; | |
29243 | JSFrameRegs regs; | |
29244 | JSObject *enumerators; | |
29245 | JSStackFrame *floating; | |
29246 | js::Value floatingStack[1]; | |
29247 | ||
29248 | JSStackFrame *floatingFrame() { | |
29249 | return floating; | |
29250 | } | |
29251 | ||
29252 | JSStackFrame *liveFrame() { | |
29253 | ((void) 0) | |
29254 | ; | |
29255 | return regs.fp; | |
29256 | } | |
29257 | }; | |
29258 | ||
29259 | extern JSObject * | |
29260 | js_NewGenerator(JSContext *cx); | |
29261 | # 214 "jsiter.h" | |
29262 | inline JSStackFrame * | |
29263 | js_FloatingFrameIfGenerator(JSContext *cx, JSStackFrame *fp) | |
29264 | { | |
29265 | ((void) 0); | |
29266 | if ((__builtin_expect((fp->isGeneratorFrame()), 0))) | |
29267 | return cx->generatorFor(fp)->floatingFrame(); | |
29268 | return fp; | |
29269 | } | |
29270 | ||
29271 | ||
29272 | extern JSGenerator * | |
29273 | js_FloatingFrameToGenerator(JSStackFrame *fp); | |
29274 | ||
29275 | inline JSStackFrame * | |
29276 | js_LiveFrameIfGenerator(JSStackFrame *fp) | |
29277 | { | |
29278 | return fp->isGeneratorFrame() ? js_FloatingFrameToGenerator(fp)->liveFrame() : fp; | |
29279 | } | |
29280 | ||
29281 | ||
29282 | ||
29283 | extern js::Class js_GeneratorClass; | |
29284 | extern js::Class js_IteratorClass; | |
29285 | extern js::Class js_StopIterationClass; | |
29286 | ||
29287 | static inline | |
29288 | ||
29289 | # 239 "jsiter.h" | |
29290 | bool | |
29291 | js_ValueIsStopIteration(const js::Value &v) | |
29292 | { | |
29293 | return v.isObject() && v.toObject().getClass() == &js_StopIterationClass; | |
29294 | } | |
29295 | ||
29296 | extern JSObject * | |
29297 | js_InitIteratorClasses(JSContext *cx, JSObject *obj); | |
29298 | # 48 "jsobjinlines.h" 2 | |
29299 | ||
29300 | ||
29301 | # 1 "jsprobes.h" 1 | |
29302 | # 51 "jsobjinlines.h" 2 | |
29303 | ||
29304 | # 1 "jsproxy.h" 1 | |
29305 | # 49 "jsproxy.h" | |
29306 | namespace js { | |
29307 | ||
29308 | ||
29309 | class __attribute__((visibility ("default"))) JSProxyHandler { | |
29310 | void *mFamily; | |
29311 | public: | |
29312 | explicit JSProxyHandler(void *family); | |
29313 | virtual ~JSProxyHandler(); | |
29314 | ||
29315 | ||
29316 | virtual bool getPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set, | |
29317 | PropertyDescriptor *desc) = 0; | |
29318 | virtual bool getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set, | |
29319 | PropertyDescriptor *desc) = 0; | |
29320 | virtual bool defineProperty(JSContext *cx, JSObject *proxy, jsid id, | |
29321 | PropertyDescriptor *desc) = 0; | |
29322 | virtual bool getOwnPropertyNames(JSContext *cx, JSObject *proxy, js::AutoIdVector &props) = 0; | |
29323 | virtual bool delete_(JSContext *cx, JSObject *proxy, jsid id, bool *bp) = 0; | |
29324 | virtual bool enumerate(JSContext *cx, JSObject *proxy, js::AutoIdVector &props) = 0; | |
29325 | virtual bool fix(JSContext *cx, JSObject *proxy, Value *vp) = 0; | |
29326 | ||
29327 | ||
29328 | virtual bool has(JSContext *cx, JSObject *proxy, jsid id, bool *bp); | |
29329 | virtual bool hasOwn(JSContext *cx, JSObject *proxy, jsid id, bool *bp); | |
29330 | virtual bool get(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, js::Value *vp); | |
29331 | virtual bool set(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, bool strict, | |
29332 | js::Value *vp); | |
29333 | virtual bool keys(JSContext *cx, JSObject *proxy, js::AutoIdVector &props); | |
29334 | virtual bool iterate(JSContext *cx, JSObject *proxy, uintN flags, js::Value *vp); | |
29335 | ||
29336 | ||
29337 | virtual bool call(JSContext *cx, JSObject *proxy, uintN argc, js::Value *vp); | |
29338 | virtual bool construct(JSContext *cx, JSObject *proxy, | |
29339 | uintN argc, js::Value *argv, js::Value *rval); | |
29340 | virtual bool hasInstance(JSContext *cx, JSObject *proxy, const js::Value *vp, bool *bp); | |
29341 | virtual JSType typeOf(JSContext *cx, JSObject *proxy); | |
29342 | virtual JSString *obj_toString(JSContext *cx, JSObject *proxy); | |
29343 | virtual JSString *fun_toString(JSContext *cx, JSObject *proxy, uintN indent); | |
29344 | virtual void finalize(JSContext *cx, JSObject *proxy); | |
29345 | virtual void trace(JSTracer *trc, JSObject *proxy); | |
29346 | ||
29347 | virtual bool isOuterWindow() { | |
29348 | return false; | |
29349 | } | |
29350 | ||
29351 | inline void *family() { | |
29352 | return mFamily; | |
29353 | } | |
29354 | }; | |
29355 | ||
29356 | ||
29357 | class JSProxy { | |
29358 | public: | |
29359 | ||
29360 | static bool getPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set, | |
29361 | PropertyDescriptor *desc); | |
29362 | static bool getPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set, Value *vp); | |
29363 | static bool getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set, | |
29364 | PropertyDescriptor *desc); | |
29365 | static bool getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set, | |
29366 | Value *vp); | |
29367 | static bool defineProperty(JSContext *cx, JSObject *proxy, jsid id, PropertyDescriptor *desc); | |
29368 | static bool defineProperty(JSContext *cx, JSObject *proxy, jsid id, const Value &v); | |
29369 | static bool getOwnPropertyNames(JSContext *cx, JSObject *proxy, js::AutoIdVector &props); | |
29370 | static bool delete_(JSContext *cx, JSObject *proxy, jsid id, bool *bp); | |
29371 | static bool enumerate(JSContext *cx, JSObject *proxy, js::AutoIdVector &props); | |
29372 | static bool fix(JSContext *cx, JSObject *proxy, Value *vp); | |
29373 | ||
29374 | ||
29375 | static bool has(JSContext *cx, JSObject *proxy, jsid id, bool *bp); | |
29376 | static bool hasOwn(JSContext *cx, JSObject *proxy, jsid id, bool *bp); | |
29377 | static bool get(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, Value *vp); | |
29378 | static bool set(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, bool strict, | |
29379 | Value *vp); | |
29380 | static bool keys(JSContext *cx, JSObject *proxy, js::AutoIdVector &props); | |
29381 | static bool iterate(JSContext *cx, JSObject *proxy, uintN flags, Value *vp); | |
29382 | ||
29383 | ||
29384 | static bool call(JSContext *cx, JSObject *proxy, uintN argc, js::Value *vp); | |
29385 | static bool construct(JSContext *cx, JSObject *proxy, uintN argc, js::Value *argv, js::Value *rval); | |
29386 | static bool hasInstance(JSContext *cx, JSObject *proxy, const js::Value *vp, bool *bp); | |
29387 | static JSType typeOf(JSContext *cx, JSObject *proxy); | |
29388 | static JSString *obj_toString(JSContext *cx, JSObject *proxy); | |
29389 | static JSString *fun_toString(JSContext *cx, JSObject *proxy, uintN indent); | |
29390 | }; | |
29391 | ||
29392 | ||
29393 | const uint32 JSSLOT_PROXY_HANDLER = 0; | |
29394 | const uint32 JSSLOT_PROXY_PRIVATE = 1; | |
29395 | const uint32 JSSLOT_PROXY_EXTRA = 2; | |
29396 | ||
29397 | const uint32 JSSLOT_PROXY_CALL = 3; | |
29398 | const uint32 JSSLOT_PROXY_CONSTRUCT = 4; | |
29399 | ||
29400 | extern __attribute__((visibility ("default"))) js::Class ObjectProxyClass; | |
29401 | extern __attribute__((visibility ("default"))) js::Class FunctionProxyClass; | |
29402 | extern __attribute__((visibility ("default"))) js::Class OuterWindowProxyClass; | |
29403 | extern js::Class CallableObjectClass; | |
29404 | ||
29405 | } | |
29406 | ||
29407 | inline | |
29408 | ||
29409 | # 150 "jsproxy.h" | |
29410 | bool | |
29411 | JSObject::isObjectProxy() const | |
29412 | { | |
29413 | return getClass() == &js::ObjectProxyClass || | |
29414 | getClass() == &js::OuterWindowProxyClass; | |
29415 | } | |
29416 | ||
29417 | inline | |
29418 | ||
29419 | # 157 "jsproxy.h" | |
29420 | bool | |
29421 | JSObject::isFunctionProxy() const | |
29422 | { | |
29423 | return getClass() == &js::FunctionProxyClass; | |
29424 | } | |
29425 | ||
29426 | inline | |
29427 | ||
29428 | # 163 "jsproxy.h" | |
29429 | bool | |
29430 | JSObject::isProxy() const | |
29431 | { | |
29432 | return isObjectProxy() || isFunctionProxy(); | |
29433 | } | |
29434 | ||
29435 | inline js::JSProxyHandler * | |
29436 | JSObject::getProxyHandler() const | |
29437 | { | |
29438 | ((void) 0); | |
29439 | return (js::JSProxyHandler *) getSlot(js::JSSLOT_PROXY_HANDLER).toPrivate(); | |
29440 | } | |
29441 | ||
29442 | inline const js::Value & | |
29443 | JSObject::getProxyPrivate() const | |
29444 | { | |
29445 | ((void) 0); | |
29446 | return getSlot(js::JSSLOT_PROXY_PRIVATE); | |
29447 | } | |
29448 | ||
29449 | inline void | |
29450 | JSObject::setProxyPrivate(const js::Value &priv) | |
29451 | { | |
29452 | ((void) 0); | |
29453 | setSlot(js::JSSLOT_PROXY_PRIVATE, priv); | |
29454 | } | |
29455 | ||
29456 | inline const js::Value & | |
29457 | JSObject::getProxyExtra() const | |
29458 | { | |
29459 | ((void) 0); | |
29460 | return getSlot(js::JSSLOT_PROXY_EXTRA); | |
29461 | } | |
29462 | ||
29463 | inline void | |
29464 | JSObject::setProxyExtra(const js::Value &extra) | |
29465 | { | |
29466 | ((void) 0); | |
29467 | setSlot(js::JSSLOT_PROXY_EXTRA, extra); | |
29468 | } | |
29469 | ||
29470 | namespace js { | |
29471 | ||
29472 | __attribute__((visibility ("default"))) JSObject * | |
29473 | NewProxyObject(JSContext *cx, JSProxyHandler *handler, const js::Value &priv, | |
29474 | JSObject *proto, JSObject *parent, | |
29475 | JSObject *call = __null, JSObject *construct = __null); | |
29476 | ||
29477 | __attribute__((visibility ("default"))) JSBool | |
29478 | FixProxy(JSContext *cx, JSObject *proxy, JSBool *bp); | |
29479 | ||
29480 | } | |
29481 | ||
29482 | extern "C" { | |
29483 | ||
29484 | extern js::Class js_ProxyClass; | |
29485 | ||
29486 | extern __attribute__((visibility ("default"))) JSObject * | |
29487 | js_InitProxyClass(JSContext *cx, JSObject *obj); | |
29488 | ||
29489 | } | |
29490 | # 53 "jsobjinlines.h" 2 | |
29491 | # 61 "jsobjinlines.h" | |
29492 | # 1 "jsscopeinlines.h" 1 | |
29493 | # 53 "jsscopeinlines.h" | |
29494 | inline void | |
29495 | js::Shape::freeTable(JSContext *cx) | |
29496 | { | |
29497 | if (hasTable()) { | |
29498 | cx->destroy(getTable()); | |
29499 | setTable(__null); | |
29500 | } | |
29501 | } | |
29502 | ||
29503 | inline js::EmptyShape * | |
29504 | JSObject::getEmptyShape(JSContext *cx, js::Class *aclasp, | |
29505 | unsigned kind) | |
29506 | { | |
29507 | ((void) 0); | |
29508 | int i = kind - js::gc::FINALIZE_OBJECT0; | |
29509 | ||
29510 | if (!emptyShapes) { | |
29511 | emptyShapes = (js::EmptyShape**) | |
29512 | cx->calloc(sizeof(js::EmptyShape*) * js::gc::JS_FINALIZE_OBJECT_LIMIT); | |
29513 | if (!emptyShapes) | |
29514 | return __null; | |
29515 | ||
29516 | ||
29517 | ||
29518 | ||
29519 | ||
29520 | emptyShapes[0] = js::EmptyShape::create(cx, aclasp); | |
29521 | if (!emptyShapes[0]) { | |
29522 | cx->free(emptyShapes); | |
29523 | emptyShapes = __null; | |
29524 | return __null; | |
29525 | } | |
29526 | } | |
29527 | ||
29528 | ((void) 0); | |
29529 | ||
29530 | if (!emptyShapes[i]) { | |
29531 | emptyShapes[i] = js::EmptyShape::create(cx, aclasp); | |
29532 | if (!emptyShapes[i]) | |
29533 | return __null; | |
29534 | } | |
29535 | ||
29536 | return emptyShapes[i]; | |
29537 | } | |
29538 | ||
29539 | inline | |
29540 | ||
29541 | # 98 "jsscopeinlines.h" | |
29542 | bool | |
29543 | JSObject::canProvideEmptyShape(js::Class *aclasp) | |
29544 | { | |
29545 | return !emptyShapes || emptyShapes[0]->getClass() == aclasp; | |
29546 | } | |
29547 | ||
29548 | inline void | |
29549 | JSObject::updateShape(JSContext *cx) | |
29550 | { | |
29551 | ((void) 0); | |
29552 | js::LeaveTraceIfGlobalObject(cx, this); | |
29553 | if (hasOwnShape()) | |
29554 | setOwnShape(js_GenerateShape(cx)); | |
29555 | else | |
29556 | objShape = lastProp->shape; | |
29557 | } | |
29558 | ||
29559 | inline void | |
29560 | JSObject::updateFlags(const js::Shape *shape, bool isDefinitelyAtom) | |
29561 | { | |
29562 | jsuint index; | |
29563 | if (!isDefinitelyAtom && js_IdIsIndex(shape->id, &index)) | |
29564 | setIndexed(); | |
29565 | ||
29566 | if (shape->isMethod()) | |
29567 | setMethodBarrier(); | |
29568 | } | |
29569 | ||
29570 | inline void | |
29571 | JSObject::extend(JSContext *cx, const js::Shape *shape, bool isDefinitelyAtom) | |
29572 | { | |
29573 | setLastProperty(shape); | |
29574 | updateFlags(shape, isDefinitelyAtom); | |
29575 | updateShape(cx); | |
29576 | } | |
29577 | ||
29578 | inline void | |
29579 | JSObject::trace(JSTracer *trc) | |
29580 | { | |
29581 | if (!isNative()) | |
29582 | return; | |
29583 | ||
29584 | JSContext *cx = trc->context; | |
29585 | js::Shape *shape = lastProp; | |
29586 | ||
29587 | if (((trc)->callback == __null) && cx->runtime->gcRegenShapes) { | |
29588 | ||
29589 | ||
29590 | ||
29591 | ||
29592 | if (!shape->hasRegenFlag()) { | |
29593 | shape->shape = js_RegenerateShapeForGC(cx->runtime); | |
29594 | shape->setRegenFlag(); | |
29595 | } | |
29596 | ||
29597 | uint32 newShape = shape->shape; | |
29598 | if (hasOwnShape()) { | |
29599 | newShape = js_RegenerateShapeForGC(cx->runtime); | |
29600 | ((void) 0); | |
29601 | } | |
29602 | objShape = newShape; | |
29603 | } | |
29604 | ||
29605 | ||
29606 | do { | |
29607 | shape->trace(trc); | |
29608 | } while ((shape = shape->parent) != __null); | |
29609 | } | |
29610 | ||
29611 | namespace js { | |
29612 | ||
29613 | inline | |
29614 | Shape::Shape(jsid id, js::PropertyOp getter, js::StrictPropertyOp setter, uint32 slot, uintN attrs, | |
29615 | uintN flags, intN shortid, uint32 shape, uint32 slotSpan) | |
29616 | : JSObjectMap(shape, slotSpan), | |
29617 | numLinearSearches(0), id(id), rawGetter(getter), rawSetter(setter), slot(slot), | |
29618 | attrs(uint8(attrs)), flags(uint8(flags)), shortid(int16(shortid)), parent(__null) | |
29619 | { | |
29620 | ((void) 0); | |
29621 | ((void) 0); | |
29622 | ((void) 0); | |
29623 | kids.setNull(); | |
29624 | } | |
29625 | ||
29626 | inline | |
29627 | Shape::Shape(JSCompartment *comp, Class *aclasp) | |
29628 | : JSObjectMap(js_GenerateShape(comp->rt), (((aclasp)->flags >> 8) & (((JSUint32)1 << (8)) - 1))), | |
29629 | numLinearSearches(0), | |
29630 | id(((jsid)0x4)), | |
29631 | clasp(aclasp), | |
29632 | rawSetter(__null), | |
29633 | slot(0xffffffff), | |
29634 | attrs(0), | |
29635 | flags(SHARED_EMPTY), | |
29636 | shortid(0), | |
29637 | parent(__null) | |
29638 | { | |
29639 | kids.setNull(); | |
29640 | } | |
29641 | ||
29642 | inline JSDHashNumber | |
29643 | Shape::hash() const | |
29644 | { | |
29645 | JSDHashNumber hash = 0; | |
29646 | ||
29647 | ||
29648 | ((void) 0); | |
29649 | if (rawGetter) | |
29650 | hash = (((hash) << (4)) | ((hash) >> (32 - (4)))) ^ jsuword(rawGetter); | |
29651 | if (rawSetter) | |
29652 | hash = (((hash) << (4)) | ((hash) >> (32 - (4)))) ^ jsuword(rawSetter); | |
29653 | hash = (((hash) << (4)) | ((hash) >> (32 - (4)))) ^ (flags & PUBLIC_FLAGS); | |
29654 | hash = (((hash) << (4)) | ((hash) >> (32 - (4)))) ^ attrs; | |
29655 | hash = (((hash) << (4)) | ((hash) >> (32 - (4)))) ^ shortid; | |
29656 | hash = (((hash) << (4)) | ((hash) >> (32 - (4)))) ^ slot; | |
29657 | hash = (((hash) << (4)) | ((hash) >> (32 - (4)))) ^ (id); | |
29658 | return hash; | |
29659 | } | |
29660 | ||
29661 | inline | |
29662 | ||
29663 | # 217 "jsscopeinlines.h" | |
29664 | bool | |
29665 | Shape::matches(const js::Shape *other) const | |
29666 | { | |
29667 | ((void) 0); | |
29668 | ((void) 0); | |
29669 | return id == other->id && | |
29670 | matchesParamsAfterId(other->rawGetter, other->rawSetter, other->slot, other->attrs, | |
29671 | other->flags, other->shortid); | |
29672 | } | |
29673 | ||
29674 | inline | |
29675 | ||
29676 | # 227 "jsscopeinlines.h" | |
29677 | bool | |
29678 | Shape::matchesParamsAfterId(js::PropertyOp agetter, js::StrictPropertyOp asetter, uint32 aslot, | |
29679 | uintN aattrs, uintN aflags, intN ashortid) const | |
29680 | { | |
29681 | ((void) 0); | |
29682 | return rawGetter == agetter && | |
29683 | rawSetter == asetter && | |
29684 | slot == aslot && | |
29685 | attrs == aattrs && | |
29686 | ((flags ^ aflags) & PUBLIC_FLAGS) == 0 && | |
29687 | shortid == ashortid; | |
29688 | } | |
29689 | ||
29690 | inline | |
29691 | ||
29692 | # 240 "jsscopeinlines.h" | |
29693 | bool | |
29694 | Shape::get(JSContext* cx, JSObject *receiver, JSObject* obj, JSObject *pobj, js::Value* vp) const | |
29695 | { | |
29696 | ((void) 0); | |
29697 | ((void) 0); | |
29698 | ||
29699 | if (hasGetterValue()) { | |
29700 | ((void) 0); | |
29701 | js::Value fval = getterValue(); | |
29702 | return js::ExternalGetOrSet(cx, receiver, id, fval, JSACC_READ, 0, 0, vp); | |
29703 | } | |
29704 | ||
29705 | if (isMethod()) { | |
29706 | vp->setObject(methodObject()); | |
29707 | return pobj->methodReadBarrier(cx, *this, vp); | |
29708 | } | |
29709 | ||
29710 | ||
29711 | ||
29712 | ||
29713 | ||
29714 | if (obj->getClass() == &js_WithClass) | |
29715 | obj = js_UnwrapWithObject(cx, obj); | |
29716 | return js::CallJSPropertyOp(cx, getterOp(), obj, ((this)->hasShortID() ? INT_TO_JSID((this)->shortid) : (this)->id), vp); | |
29717 | } | |
29718 | ||
29719 | inline | |
29720 | ||
29721 | # 266 "jsscopeinlines.h" | |
29722 | bool | |
29723 | Shape::set(JSContext* cx, JSObject* obj, bool strict, js::Value* vp) const | |
29724 | { | |
29725 | ((void) 0); | |
29726 | ||
29727 | if (attrs & 0x20) { | |
29728 | js::Value fval = setterValue(); | |
29729 | return js::ExternalGetOrSet(cx, obj, id, fval, JSACC_WRITE, 1, vp, vp); | |
29730 | } | |
29731 | ||
29732 | if (attrs & 0x10) | |
29733 | return js_ReportGetterOnlyAssignment(cx); | |
29734 | ||
29735 | ||
29736 | if (obj->getClass() == &js_WithClass) | |
29737 | obj = js_UnwrapWithObject(cx, obj); | |
29738 | return js::CallJSPropertyOpSetter(cx, setterOp(), obj, ((this)->hasShortID() ? INT_TO_JSID((this)->shortid) : (this)->id), strict, vp); | |
29739 | } | |
29740 | ||
29741 | inline | |
29742 | EmptyShape::EmptyShape(JSCompartment *comp, js::Class *aclasp) | |
29743 | : js::Shape(comp, aclasp) | |
29744 | { | |
29745 | ||
29746 | ||
29747 | ||
29748 | ||
29749 | } | |
29750 | ||
29751 | } | |
29752 | # 62 "jsobjinlines.h" 2 | |
29753 | ||
29754 | ||
29755 | ||
29756 | # 1 "jsgcinlines.h" 1 | |
29757 | # 58 "jsgcinlines.h" | |
29758 | namespace js { | |
29759 | namespace gc { | |
29760 | ||
29761 | ||
29762 | const size_t SLOTS_TO_THING_KIND_LIMIT = 17; | |
29763 | ||
29764 | ||
29765 | static inline FinalizeKind | |
29766 | GetGCObjectKind(size_t numSlots) | |
29767 | { | |
29768 | extern FinalizeKind slotsToThingKind[]; | |
29769 | ||
29770 | if (numSlots >= SLOTS_TO_THING_KIND_LIMIT) | |
29771 | return FINALIZE_OBJECT0; | |
29772 | return slotsToThingKind[numSlots]; | |
29773 | } | |
29774 | ||
29775 | ||
29776 | static inline size_t | |
29777 | GetGCKindSlots(FinalizeKind thingKind) | |
29778 | { | |
29779 | ||
29780 | switch (thingKind) { | |
29781 | case FINALIZE_OBJECT0: | |
29782 | return 0; | |
29783 | case FINALIZE_OBJECT2: | |
29784 | return 2; | |
29785 | case FINALIZE_OBJECT4: | |
29786 | return 4; | |
29787 | case FINALIZE_OBJECT8: | |
29788 | return 8; | |
29789 | case FINALIZE_OBJECT12: | |
29790 | return 12; | |
29791 | case FINALIZE_OBJECT16: | |
29792 | return 16; | |
29793 | default: | |
29794 | ; | |
29795 | return 0; | |
29796 | } | |
29797 | } | |
29798 | ||
29799 | } | |
29800 | } | |
29801 | # 109 "jsgcinlines.h" | |
29802 | template <typename T> | |
29803 | __attribute__((always_inline)) inline T * | |
29804 | NewFinalizableGCThing(JSContext *cx, unsigned thingKind) | |
29805 | { | |
29806 | ((void) 0); | |
29807 | ||
29808 | ((void) 0) | |
29809 | ||
29810 | ; | |
29811 | ||
29812 | ||
29813 | ((void) 0); | |
29814 | do { | |
29815 | js::gc::FreeCell *cell = cx->compartment->freeLists.getNext(thingKind); | |
29816 | if (cell) { | |
29817 | CheckGCFreeListLink(cell); | |
29818 | return (T *)cell; | |
29819 | } | |
29820 | if (!RefillFinalizableFreeList(cx, thingKind)) | |
29821 | return __null; | |
29822 | } while (true); | |
29823 | } | |
29824 | ||
29825 | ||
29826 | ||
29827 | ||
29828 | inline JSObject * | |
29829 | js_NewGCObject(JSContext *cx, js::gc::FinalizeKind kind) | |
29830 | { | |
29831 | ((void) 0); | |
29832 | JSObject *obj = NewFinalizableGCThing<JSObject>(cx, kind); | |
29833 | if (obj) | |
29834 | obj->capacity = js::gc::GetGCKindSlots(kind); | |
29835 | return obj; | |
29836 | } | |
29837 | ||
29838 | inline JSString * | |
29839 | js_NewGCString(JSContext *cx) | |
29840 | { | |
29841 | return NewFinalizableGCThing<JSString>(cx, js::gc::FINALIZE_STRING); | |
29842 | } | |
29843 | ||
29844 | inline JSShortString * | |
29845 | js_NewGCShortString(JSContext *cx) | |
29846 | { | |
29847 | return NewFinalizableGCThing<JSShortString>(cx, js::gc::FINALIZE_SHORT_STRING); | |
29848 | } | |
29849 | ||
29850 | inline JSExternalString * | |
29851 | js_NewGCExternalString(JSContext *cx, uintN type) | |
29852 | { | |
29853 | ((void) 0); | |
29854 | JSExternalString *str = NewFinalizableGCThing<JSExternalString>(cx, js::gc::FINALIZE_EXTERNAL_STRING); | |
29855 | return str; | |
29856 | } | |
29857 | ||
29858 | inline JSFunction* | |
29859 | js_NewGCFunction(JSContext *cx) | |
29860 | { | |
29861 | JSFunction *fun = NewFinalizableGCThing<JSFunction>(cx, js::gc::FINALIZE_FUNCTION); | |
29862 | if (fun) | |
29863 | fun->capacity = JSObject::FUN_CLASS_RESERVED_SLOTS; | |
29864 | return fun; | |
29865 | } | |
29866 | ||
29867 | ||
29868 | inline JSXML * | |
29869 | js_NewGCXML(JSContext *cx) | |
29870 | { | |
29871 | return NewFinalizableGCThing<JSXML>(cx, js::gc::FINALIZE_XML); | |
29872 | } | |
29873 | ||
29874 | ||
29875 | namespace js { | |
29876 | namespace gc { | |
29877 | ||
29878 | static __attribute__((always_inline)) inline void | |
29879 | TypedMarker(JSTracer *trc, JSXML *thing); | |
29880 | ||
29881 | static __attribute__((always_inline)) inline void | |
29882 | TypedMarker(JSTracer *trc, JSObject *thing); | |
29883 | ||
29884 | static __attribute__((always_inline)) inline void | |
29885 | TypedMarker(JSTracer *trc, JSFunction *thing); | |
29886 | ||
29887 | static __attribute__((always_inline)) inline void | |
29888 | TypedMarker(JSTracer *trc, JSShortString *thing); | |
29889 | ||
29890 | static __attribute__((always_inline)) inline void | |
29891 | TypedMarker(JSTracer *trc, JSString *thing); | |
29892 | ||
29893 | template<typename T> | |
29894 | static __attribute__((always_inline)) inline void | |
29895 | Mark(JSTracer *trc, T *thing) | |
29896 | { | |
29897 | ((void) 0); | |
29898 | ((void) 0); | |
29899 | ((void) 0); | |
29900 | ||
29901 | ||
29902 | ((void) 0); | |
29903 | ||
29904 | JSRuntime *rt = trc->context->runtime; | |
29905 | ||
29906 | if (rt->gcCurrentCompartment && thing->asCell()->compartment() != rt->gcCurrentCompartment) | |
29907 | goto out; | |
29908 | ||
29909 | if (!((trc)->callback == __null)) { | |
29910 | uint32 kind = GetGCThingTraceKind(thing); | |
29911 | trc->callback(trc, thing, kind); | |
29912 | goto out; | |
29913 | } | |
29914 | ||
29915 | TypedMarker(trc, thing); | |
29916 | ||
29917 | out: | |
29918 | ||
29919 | ||
29920 | ||
29921 | ||
29922 | return; | |
29923 | } | |
29924 | ||
29925 | static inline void | |
29926 | MarkString(JSTracer *trc, JSString *str) | |
29927 | { | |
29928 | ((void) 0); | |
29929 | if (JSString::isStatic(str)) | |
29930 | return; | |
29931 | ((void) 0); | |
29932 | Mark(trc, str); | |
29933 | } | |
29934 | ||
29935 | static inline void | |
29936 | MarkString(JSTracer *trc, JSString *str, const char *name) | |
29937 | { | |
29938 | ((void) 0); | |
29939 | do { } while (0); | |
29940 | MarkString(trc, str); | |
29941 | } | |
29942 | ||
29943 | static inline void | |
29944 | MarkObject(JSTracer *trc, JSObject &obj, const char *name) | |
29945 | { | |
29946 | ((void) 0); | |
29947 | ((void) 0); | |
29948 | do { } while (0); | |
29949 | ((void) 0) | |
29950 | ||
29951 | ||
29952 | ||
29953 | ||
29954 | ||
29955 | ; | |
29956 | Mark(trc, &obj); | |
29957 | } | |
29958 | ||
29959 | static inline void | |
29960 | MarkChildren(JSTracer *trc, JSObject *obj) | |
29961 | { | |
29962 | ||
29963 | if (!obj->map) | |
29964 | return; | |
29965 | ||
29966 | ||
29967 | if (JSObject *proto = obj->getProto()) | |
29968 | MarkObject(trc, *proto, "proto"); | |
29969 | if (JSObject *parent = obj->getParent()) | |
29970 | MarkObject(trc, *parent, "parent"); | |
29971 | ||
29972 | if (obj->emptyShapes) { | |
29973 | int count = FINALIZE_OBJECT_LAST - FINALIZE_OBJECT0 + 1; | |
29974 | for (int i = 0; i < count; i++) { | |
29975 | if (obj->emptyShapes[i]) | |
29976 | obj->emptyShapes[i]->trace(trc); | |
29977 | } | |
29978 | } | |
29979 | ||
29980 | ||
29981 | TraceOp op = obj->getOps()->trace; | |
29982 | (op ? op : js_TraceObject)(trc, obj); | |
29983 | } | |
29984 | ||
29985 | static inline void | |
29986 | MarkChildren(JSTracer *trc, JSString *str) | |
29987 | { | |
29988 | if (str->isDependent()) | |
29989 | MarkString(trc, str->dependentBase(), "base"); | |
29990 | else if (str->isRope()) { | |
29991 | MarkString(trc, str->ropeLeft(), "left child"); | |
29992 | MarkString(trc, str->ropeRight(), "right child"); | |
29993 | } | |
29994 | } | |
29995 | ||
29996 | ||
29997 | static inline void | |
29998 | MarkChildren(JSTracer *trc, JSXML *xml) | |
29999 | { | |
30000 | js_TraceXML(trc, xml); | |
30001 | } | |
30002 | ||
30003 | ||
30004 | static inline | |
30005 | ||
30006 | # 311 "jsgcinlines.h" | |
30007 | bool | |
30008 | RecursionTooDeep(GCMarker *gcmarker) { | |
30009 | ||
30010 | ||
30011 | ||
30012 | int stackDummy; | |
30013 | return !((jsuword)(&stackDummy) > gcmarker->stackLimit); | |
30014 | ||
30015 | } | |
30016 | ||
30017 | static __attribute__((always_inline)) inline void | |
30018 | TypedMarker(JSTracer *trc, JSXML *thing) | |
30019 | { | |
30020 | if (!reinterpret_cast<Cell *>(thing)->markIfUnmarked(reinterpret_cast<GCMarker *>(trc)->getMarkColor())) | |
30021 | return; | |
30022 | GCMarker *gcmarker = static_cast<GCMarker *>(trc); | |
30023 | if (RecursionTooDeep(gcmarker)) { | |
30024 | gcmarker->delayMarkingChildren(thing); | |
30025 | } else { | |
30026 | MarkChildren(trc, thing); | |
30027 | } | |
30028 | } | |
30029 | ||
30030 | static __attribute__((always_inline)) inline void | |
30031 | TypedMarker(JSTracer *trc, JSObject *thing) | |
30032 | { | |
30033 | ((void) 0); | |
30034 | ((void) 0); | |
30035 | ||
30036 | GCMarker *gcmarker = static_cast<GCMarker *>(trc); | |
30037 | if (!thing->markIfUnmarked(gcmarker->getMarkColor())) | |
30038 | return; | |
30039 | ||
30040 | if (RecursionTooDeep(gcmarker)) { | |
30041 | gcmarker->delayMarkingChildren(thing); | |
30042 | } else { | |
30043 | MarkChildren(trc, thing); | |
30044 | } | |
30045 | } | |
30046 | ||
30047 | static __attribute__((always_inline)) inline void | |
30048 | TypedMarker(JSTracer *trc, JSFunction *thing) | |
30049 | { | |
30050 | ((void) 0); | |
30051 | ((void) 0); | |
30052 | ||
30053 | GCMarker *gcmarker = static_cast<GCMarker *>(trc); | |
30054 | if (!thing->markIfUnmarked(gcmarker->getMarkColor())) | |
30055 | return; | |
30056 | ||
30057 | if (RecursionTooDeep(gcmarker)) { | |
30058 | gcmarker->delayMarkingChildren(thing); | |
30059 | } else { | |
30060 | MarkChildren(trc, static_cast<JSObject *>(thing)); | |
30061 | } | |
30062 | } | |
30063 | ||
30064 | static __attribute__((always_inline)) inline void | |
30065 | TypedMarker(JSTracer *trc, JSShortString *thing) | |
30066 | { | |
30067 | ||
30068 | ||
30069 | ||
30070 | ||
30071 | ||
30072 | (void) thing->asCell()->markIfUnmarked(); | |
30073 | } | |
30074 | ||
30075 | } | |
30076 | ||
30077 | namespace detail { | |
30078 | ||
30079 | static __attribute__((always_inline)) inline JSString * | |
30080 | Tag(JSString *str) | |
30081 | { | |
30082 | ((void) 0); | |
30083 | return (JSString *)(size_t(str) | 1); | |
30084 | } | |
30085 | ||
30086 | static __attribute__((always_inline)) inline | |
30087 | ||
30088 | # 390 "jsgcinlines.h" | |
30089 | bool | |
30090 | Tagged(JSString *str) | |
30091 | { | |
30092 | return (size_t(str) & 1) != 0; | |
30093 | } | |
30094 | ||
30095 | static __attribute__((always_inline)) inline JSString * | |
30096 | Untag(JSString *str) | |
30097 | { | |
30098 | ((void) 0); | |
30099 | return (JSString *)(size_t(str) & ~size_t(1)); | |
30100 | } | |
30101 | ||
30102 | static __attribute__((always_inline)) inline void | |
30103 | NonRopeTypedMarker(JSRuntime *rt, JSString *str) | |
30104 | { | |
30105 | ||
30106 | ((void) 0); | |
30107 | ||
30108 | if (rt->gcCurrentCompartment) { | |
30109 | for (;;) { | |
30110 | if (JSString::isStatic(str)) | |
30111 | break; | |
30112 | ||
30113 | ||
30114 | ||
30115 | ||
30116 | ||
30117 | if (str->asCell()->compartment() != rt->gcCurrentCompartment) { | |
30118 | ((void) 0); | |
30119 | break; | |
30120 | } | |
30121 | if (!str->asCell()->markIfUnmarked()) | |
30122 | break; | |
30123 | if (!str->isDependent()) | |
30124 | break; | |
30125 | str = str->dependentBase(); | |
30126 | } | |
30127 | } else { | |
30128 | while (!JSString::isStatic(str) && | |
30129 | str->asCell()->markIfUnmarked() && | |
30130 | str->isDependent()) { | |
30131 | str = str->dependentBase(); | |
30132 | } | |
30133 | } | |
30134 | } | |
30135 | ||
30136 | } | |
30137 | ||
30138 | namespace gc { | |
30139 | ||
30140 | static __attribute__((always_inline)) inline void | |
30141 | TypedMarker(JSTracer *trc, JSString *str) | |
30142 | { | |
30143 | using namespace detail; | |
30144 | JSRuntime *rt = trc->context->runtime; | |
30145 | ((void) 0); | |
30146 | ||
30147 | ||
30148 | ||
30149 | if (!str->isRope()) { | |
30150 | NonRopeTypedMarker(rt, str); | |
30151 | return; | |
30152 | } | |
30153 | ||
30154 | ||
30155 | ||
30156 | ||
30157 | ||
30158 | ||
30159 | ||
30160 | JSString *parent = __null; | |
30161 | first_visit_node: { | |
30162 | ((void) 0); | |
30163 | ((void) 0); | |
30164 | if (!str->asCell()->markIfUnmarked()) | |
30165 | goto finish_node; | |
30166 | JSString *left = str->ropeLeft(); | |
30167 | if (left->isRope()) { | |
30168 | ((void) 0); | |
30169 | str->u.left = Tag(parent); | |
30170 | parent = str; | |
30171 | str = left; | |
30172 | goto first_visit_node; | |
30173 | } | |
30174 | ((void) 0) | |
30175 | ||
30176 | ; | |
30177 | NonRopeTypedMarker(rt, left); | |
30178 | } | |
30179 | visit_right_child: { | |
30180 | JSString *right = str->ropeRight(); | |
30181 | if (right->isRope()) { | |
30182 | ((void) 0); | |
30183 | str->s.right = Tag(parent); | |
30184 | parent = str; | |
30185 | str = right; | |
30186 | goto first_visit_node; | |
30187 | } | |
30188 | ((void) 0) | |
30189 | ||
30190 | ; | |
30191 | NonRopeTypedMarker(rt, right); | |
30192 | } | |
30193 | finish_node: { | |
30194 | if (!parent) | |
30195 | return; | |
30196 | if (Tagged(parent->u.left)) { | |
30197 | ((void) 0); | |
30198 | JSString *nextParent = Untag(parent->u.left); | |
30199 | parent->u.left = str; | |
30200 | str = parent; | |
30201 | parent = nextParent; | |
30202 | goto visit_right_child; | |
30203 | } | |
30204 | ((void) 0); | |
30205 | JSString *nextParent = Untag(parent->s.right); | |
30206 | parent->s.right = str; | |
30207 | str = parent; | |
30208 | parent = nextParent; | |
30209 | goto finish_node; | |
30210 | } | |
30211 | } | |
30212 | ||
30213 | static inline void | |
30214 | MarkAtomRange(JSTracer *trc, size_t len, JSAtom **vec, const char *name) | |
30215 | { | |
30216 | for (uint32 i = 0; i < len; i++) { | |
30217 | if (JSAtom *atom = vec[i]) { | |
30218 | do { } while (0); | |
30219 | JSString *str = (atom); | |
30220 | if (!JSString::isStatic(str)) | |
30221 | Mark(trc, str); | |
30222 | } | |
30223 | } | |
30224 | } | |
30225 | ||
30226 | static inline void | |
30227 | MarkObjectRange(JSTracer *trc, size_t len, JSObject **vec, const char *name) | |
30228 | { | |
30229 | for (uint32 i = 0; i < len; i++) { | |
30230 | if (JSObject *obj = vec[i]) { | |
30231 | do { } while (0); | |
30232 | Mark(trc, obj); | |
30233 | } | |
30234 | } | |
30235 | } | |
30236 | ||
30237 | static inline void | |
30238 | MarkId(JSTracer *trc, jsid id) | |
30239 | { | |
30240 | if (JSID_IS_STRING(id)) { | |
30241 | JSString *str = JSID_TO_STRING(id); | |
30242 | if (!JSString::isStatic(str)) | |
30243 | Mark(trc, str); | |
30244 | } | |
30245 | else if ((__builtin_expect((JSID_IS_OBJECT(id)), 0))) | |
30246 | Mark(trc, JSID_TO_OBJECT(id)); | |
30247 | } | |
30248 | ||
30249 | static inline void | |
30250 | MarkId(JSTracer *trc, jsid id, const char *name) | |
30251 | { | |
30252 | do { } while (0); | |
30253 | MarkId(trc, id); | |
30254 | } | |
30255 | ||
30256 | static inline void | |
30257 | MarkIdRange(JSTracer *trc, jsid *beg, jsid *end, const char *name) | |
30258 | { | |
30259 | for (jsid *idp = beg; idp != end; ++idp) { | |
30260 | do { } while (0); | |
30261 | MarkId(trc, *idp); | |
30262 | } | |
30263 | } | |
30264 | ||
30265 | static inline void | |
30266 | MarkIdRange(JSTracer *trc, size_t len, jsid *vec, const char *name) | |
30267 | { | |
30268 | MarkIdRange(trc, vec, vec + len, name); | |
30269 | } | |
30270 | ||
30271 | static inline void | |
30272 | MarkKind(JSTracer *trc, void *thing, uint32 kind) | |
30273 | { | |
30274 | ((void) 0); | |
30275 | ((void) 0); | |
30276 | switch (kind) { | |
30277 | case 0: | |
30278 | Mark(trc, reinterpret_cast<JSObject *>(thing)); | |
30279 | break; | |
30280 | case 1: | |
30281 | MarkString(trc, reinterpret_cast<JSString *>(thing)); | |
30282 | break; | |
30283 | ||
30284 | case 2: | |
30285 | Mark(trc, reinterpret_cast<JSXML *>(thing)); | |
30286 | break; | |
30287 | ||
30288 | default: | |
30289 | ((void) 0); | |
30290 | } | |
30291 | } | |
30292 | ||
30293 | ||
30294 | static inline void | |
30295 | MarkValueRaw(JSTracer *trc, const js::Value &v) | |
30296 | { | |
30297 | if (v.isMarkable()) { | |
30298 | ((void) 0); | |
30299 | return MarkKind(trc, v.toGCThing(), v.gcKind()); | |
30300 | } | |
30301 | } | |
30302 | ||
30303 | static inline void | |
30304 | MarkValue(JSTracer *trc, const js::Value &v, const char *name) | |
30305 | { | |
30306 | do { } while (0); | |
30307 | MarkValueRaw(trc, v); | |
30308 | } | |
30309 | ||
30310 | static inline void | |
30311 | MarkValueRange(JSTracer *trc, Value *beg, Value *end, const char *name) | |
30312 | { | |
30313 | for (Value *vp = beg; vp < end; ++vp) { | |
30314 | do { } while (0); | |
30315 | MarkValueRaw(trc, *vp); | |
30316 | } | |
30317 | } | |
30318 | ||
30319 | static inline void | |
30320 | MarkValueRange(JSTracer *trc, size_t len, Value *vec, const char *name) | |
30321 | { | |
30322 | MarkValueRange(trc, vec, vec + len, name); | |
30323 | } | |
30324 | ||
30325 | static inline void | |
30326 | MarkShapeRange(JSTracer *trc, const Shape **beg, const Shape **end, const char *name) | |
30327 | { | |
30328 | for (const Shape **sp = beg; sp < end; ++sp) { | |
30329 | do { } while (0); | |
30330 | (*sp)->trace(trc); | |
30331 | } | |
30332 | } | |
30333 | ||
30334 | static inline void | |
30335 | MarkShapeRange(JSTracer *trc, size_t len, const Shape **vec, const char *name) | |
30336 | { | |
30337 | MarkShapeRange(trc, vec, vec + len, name); | |
30338 | } | |
30339 | ||
30340 | ||
30341 | static inline void | |
30342 | MarkGCThing(JSTracer *trc, void *thing, uint32 kind) | |
30343 | { | |
30344 | if (!thing) | |
30345 | return; | |
30346 | ||
30347 | MarkKind(trc, thing, kind); | |
30348 | } | |
30349 | ||
30350 | static inline void | |
30351 | MarkGCThing(JSTracer *trc, void *thing) | |
30352 | { | |
30353 | if (!thing) | |
30354 | return; | |
30355 | MarkKind(trc, thing, GetGCThingTraceKind(thing)); | |
30356 | } | |
30357 | ||
30358 | static inline void | |
30359 | MarkGCThing(JSTracer *trc, void *thing, const char *name) | |
30360 | { | |
30361 | do { } while (0); | |
30362 | MarkGCThing(trc, thing); | |
30363 | } | |
30364 | ||
30365 | static inline void | |
30366 | MarkGCThing(JSTracer *trc, void *thing, const char *name, size_t index) | |
30367 | { | |
30368 | do { } while (0); | |
30369 | MarkGCThing(trc, thing); | |
30370 | } | |
30371 | ||
30372 | static inline void | |
30373 | Mark(JSTracer *trc, void *thing, uint32 kind, const char *name) | |
30374 | { | |
30375 | ((void) 0); | |
30376 | do { } while (0); | |
30377 | MarkKind(trc, thing, kind); | |
30378 | } | |
30379 | ||
30380 | }} | |
30381 | # 66 "jsobjinlines.h" 2 | |
30382 | # 1 "jsprobes.h" 1 | |
30383 | # 67 "jsobjinlines.h" 2 | |
30384 | ||
30385 | inline | |
30386 | ||
30387 | # 68 "jsobjinlines.h" | |
30388 | bool | |
30389 | JSObject::preventExtensions(JSContext *cx, js::AutoIdVector *props) | |
30390 | { | |
30391 | ((void) 0); | |
30392 | ||
30393 | if (js::FixOp fix = getOps()->fix) { | |
30394 | bool success; | |
30395 | if (!fix(cx, this, &success, props)) | |
30396 | return false; | |
30397 | if (!success) { | |
30398 | JS_ReportErrorNumber(cx, js_GetErrorMessage, __null, JSMSG_CANT_CHANGE_EXTENSIBILITY); | |
30399 | return false; | |
30400 | } | |
30401 | } else { | |
30402 | if (!GetPropertyNames(cx, this, 0x10 | 0x8, props)) | |
30403 | return false; | |
30404 | } | |
30405 | ||
30406 | if (isNative()) | |
30407 | extensibleShapeChange(cx); | |
30408 | ||
30409 | flags |= NOT_EXTENSIBLE; | |
30410 | return true; | |
30411 | } | |
30412 | ||
30413 | inline | |
30414 | ||
30415 | # 93 "jsobjinlines.h" | |
30416 | bool | |
30417 | JSObject::brand(JSContext *cx) | |
30418 | { | |
30419 | ((void) 0); | |
30420 | ((void) 0); | |
30421 | ((void) 0); | |
30422 | generateOwnShape(cx); | |
30423 | if (js_IsPropertyCacheDisabled(cx)) | |
30424 | return false; | |
30425 | flags |= BRANDED; | |
30426 | return true; | |
30427 | } | |
30428 | ||
30429 | inline | |
30430 | ||
30431 | # 106 "jsobjinlines.h" | |
30432 | bool | |
30433 | JSObject::unbrand(JSContext *cx) | |
30434 | { | |
30435 | ((void) 0); | |
30436 | if (branded()) { | |
30437 | generateOwnShape(cx); | |
30438 | if (js_IsPropertyCacheDisabled(cx)) | |
30439 | return false; | |
30440 | flags &= ~BRANDED; | |
30441 | } | |
30442 | setGeneric(); | |
30443 | return true; | |
30444 | } | |
30445 | ||
30446 | inline void | |
30447 | JSObject::syncSpecialEquality() | |
30448 | { | |
30449 | if (clasp->ext.equality) | |
30450 | flags |= JSObject::HAS_EQUALITY; | |
30451 | } | |
30452 | ||
30453 | inline void | |
30454 | JSObject::finalize(JSContext *cx) | |
30455 | { | |
30456 | ||
30457 | if (!map) | |
30458 | return; | |
30459 | ||
30460 | ||
30461 | js::Class *clasp = getClass(); | |
30462 | if (clasp->finalize) | |
30463 | clasp->finalize(cx, this); | |
30464 | ||
30465 | js::Probes::finalizeObject(this); | |
30466 | ||
30467 | finish(cx); | |
30468 | } | |
30469 | ||
30470 | ||
30471 | ||
30472 | ||
30473 | ||
30474 | inline const js::Shape * | |
30475 | JSObject::methodReadBarrier(JSContext *cx, const js::Shape &shape, js::Value *vp) | |
30476 | { | |
30477 | ((void) 0); | |
30478 | ((void) 0); | |
30479 | ((void) 0); | |
30480 | ((void) 0); | |
30481 | ((void) 0); | |
30482 | ((void) 0); | |
30483 | ((void) 0); | |
30484 | ((void) 0); | |
30485 | ((void) 0); | |
30486 | ||
30487 | JSObject *funobj = &vp->toObject(); | |
30488 | JSFunction *fun = funobj->getFunctionPrivate(); | |
30489 | ((void) 0); | |
30490 | ((void) 0); | |
30491 | ||
30492 | funobj = CloneFunctionObject(cx, fun, funobj->getParent()); | |
30493 | if (!funobj) | |
30494 | return __null; | |
30495 | funobj->setMethodObj(*this); | |
30496 | ||
30497 | ||
30498 | ||
30499 | ||
30500 | ||
30501 | ||
30502 | uint32 slot = shape.slot; | |
30503 | const js::Shape *newshape = methodShapeChange(cx, shape); | |
30504 | if (!newshape) | |
30505 | return __null; | |
30506 | ((void) 0); | |
30507 | ((void) 0); | |
30508 | vp->setObject(*funobj); | |
30509 | nativeSetSlot(slot, *vp); | |
30510 | # 200 "jsobjinlines.h" | |
30511 | return newshape; | |
30512 | } | |
30513 | ||
30514 | static __attribute__((always_inline)) inline | |
30515 | ||
30516 | # 203 "jsobjinlines.h" | |
30517 | bool | |
30518 | ChangesMethodValue(const js::Value &prev, const js::Value &v) | |
30519 | { | |
30520 | JSObject *prevObj; | |
30521 | return prev.isObject() && (prevObj = &prev.toObject())->isFunction() && | |
30522 | (!v.isObject() || &v.toObject() != prevObj); | |
30523 | } | |
30524 | ||
30525 | inline const js::Shape * | |
30526 | JSObject::methodWriteBarrier(JSContext *cx, const js::Shape &shape, const js::Value &v) | |
30527 | { | |
30528 | if (brandedOrHasMethodBarrier() && shape.slot != 0xffffffff) { | |
30529 | const js::Value &prev = nativeGetSlot(shape.slot); | |
30530 | ||
30531 | if (ChangesMethodValue(prev, v)) { | |
30532 | ((void)0); | |
30533 | return methodShapeChange(cx, shape); | |
30534 | } | |
30535 | } | |
30536 | return &shape; | |
30537 | } | |
30538 | ||
30539 | inline | |
30540 | ||
30541 | # 225 "jsobjinlines.h" | |
30542 | bool | |
30543 | JSObject::methodWriteBarrier(JSContext *cx, uint32 slot, const js::Value &v) | |
30544 | { | |
30545 | if (brandedOrHasMethodBarrier()) { | |
30546 | const js::Value &prev = nativeGetSlot(slot); | |
30547 | ||
30548 | if (ChangesMethodValue(prev, v)) { | |
30549 | ((void)0); | |
30550 | return methodShapeChange(cx, slot); | |
30551 | } | |
30552 | } | |
30553 | return true; | |
30554 | } | |
30555 | ||
30556 | inline | |
30557 | ||
30558 | # 239 "jsobjinlines.h" | |
30559 | bool | |
30560 | JSObject::ensureClassReservedSlots(JSContext *cx) | |
30561 | { | |
30562 | return !nativeEmpty() || ensureClassReservedSlotsForEmptyObject(cx); | |
30563 | } | |
30564 | ||
30565 | inline js::Value | |
30566 | JSObject::getReservedSlot(uintN index) const | |
30567 | { | |
30568 | return (index < numSlots()) ? getSlot(index) : js::UndefinedValue(); | |
30569 | } | |
30570 | ||
30571 | inline | |
30572 | ||
30573 | # 251 "jsobjinlines.h" | |
30574 | bool | |
30575 | JSObject::canHaveMethodBarrier() const | |
30576 | { | |
30577 | return isObject() || isFunction() || isPrimitive() || isDate(); | |
30578 | } | |
30579 | ||
30580 | inline | |
30581 | ||
30582 | # 257 "jsobjinlines.h" | |
30583 | bool | |
30584 | JSObject::isPrimitive() const | |
30585 | { | |
30586 | return isNumber() || isString() || isBoolean(); | |
30587 | } | |
30588 | ||
30589 | inline const js::Value & | |
30590 | JSObject::getPrimitiveThis() const | |
30591 | { | |
30592 | ((void) 0); | |
30593 | return getSlot(JSSLOT_PRIMITIVE_THIS); | |
30594 | } | |
30595 | ||
30596 | inline void | |
30597 | JSObject::setPrimitiveThis(const js::Value &pthis) | |
30598 | { | |
30599 | ((void) 0); | |
30600 | setSlot(JSSLOT_PRIMITIVE_THIS, pthis); | |
30601 | } | |
30602 | ||
30603 | inline unsigned | |
30604 | JSObject::finalizeKind() const | |
30605 | { | |
30606 | return js::gc::FinalizeKind(arena()->header()->thingKind); | |
30607 | } | |
30608 | ||
30609 | inline size_t | |
30610 | JSObject::numFixedSlots() const | |
30611 | { | |
30612 | if (isFunction()) | |
30613 | return JSObject::FUN_CLASS_RESERVED_SLOTS; | |
30614 | if (!hasSlotsArray()) | |
30615 | return capacity; | |
30616 | return js::gc::GetGCKindSlots(js::gc::FinalizeKind(finalizeKind())); | |
30617 | } | |
30618 | ||
30619 | inline size_t | |
30620 | JSObject::slotsAndStructSize(uint32 nslots) const | |
30621 | { | |
30622 | bool isFun = isFunction() && this == (JSObject*) getPrivate(); | |
30623 | ||
30624 | int ndslots = hasSlotsArray() ? nslots : 0; | |
30625 | int nfslots = isFun ? 0 : numFixedSlots(); | |
30626 | ||
30627 | return sizeof(js::Value) * (ndslots + nfslots) | |
30628 | + isFun ? sizeof(JSFunction) : sizeof(JSObject); | |
30629 | } | |
30630 | ||
30631 | inline uint32 | |
30632 | JSObject::getArrayLength() const | |
30633 | { | |
30634 | ((void) 0); | |
30635 | return (uint32)(size_t) getPrivate(); | |
30636 | } | |
30637 | ||
30638 | inline void | |
30639 | JSObject::setArrayLength(uint32 length) | |
30640 | { | |
30641 | ((void) 0); | |
30642 | setPrivate((void*) length); | |
30643 | } | |
30644 | ||
30645 | inline uint32 | |
30646 | JSObject::getDenseArrayCapacity() | |
30647 | { | |
30648 | ((void) 0); | |
30649 | return numSlots(); | |
30650 | } | |
30651 | ||
30652 | inline js::Value* | |
30653 | JSObject::getDenseArrayElements() | |
30654 | { | |
30655 | ((void) 0); | |
30656 | return getSlots(); | |
30657 | } | |
30658 | ||
30659 | inline const js::Value & | |
30660 | JSObject::getDenseArrayElement(uintN idx) | |
30661 | { | |
30662 | ((void) 0); | |
30663 | return getSlot(idx); | |
30664 | } | |
30665 | ||
30666 | inline js::Value * | |
30667 | JSObject::addressOfDenseArrayElement(uintN idx) | |
30668 | { | |
30669 | ((void) 0); | |
30670 | return &getSlotRef(idx); | |
30671 | } | |
30672 | ||
30673 | inline void | |
30674 | JSObject::setDenseArrayElement(uintN idx, const js::Value &val) | |
30675 | { | |
30676 | ((void) 0); | |
30677 | setSlot(idx, val); | |
30678 | } | |
30679 | ||
30680 | inline void | |
30681 | JSObject::shrinkDenseArrayElements(JSContext *cx, uintN cap) | |
30682 | { | |
30683 | ((void) 0); | |
30684 | shrinkSlots(cx, cap); | |
30685 | } | |
30686 | ||
30687 | inline void | |
30688 | JSObject::setArgsLength(uint32 argc) | |
30689 | { | |
30690 | ((void) 0); | |
30691 | ((void) 0); | |
30692 | ((void) 0); | |
30693 | getSlotRef(JSSLOT_ARGS_LENGTH).setInt32(argc << ARGS_PACKED_BITS_COUNT); | |
30694 | ((void) 0); | |
30695 | } | |
30696 | ||
30697 | inline uint32 | |
30698 | JSObject::getArgsInitialLength() const | |
30699 | { | |
30700 | ((void) 0); | |
30701 | uint32 argc = uint32(getSlot(JSSLOT_ARGS_LENGTH).toInt32()) >> ARGS_PACKED_BITS_COUNT; | |
30702 | ((void) 0); | |
30703 | return argc; | |
30704 | } | |
30705 | ||
30706 | inline void | |
30707 | JSObject::setArgsLengthOverridden() | |
30708 | { | |
30709 | ((void) 0); | |
30710 | getSlotRef(JSSLOT_ARGS_LENGTH).getInt32Ref() |= ARGS_LENGTH_OVERRIDDEN_BIT; | |
30711 | } | |
30712 | ||
30713 | inline | |
30714 | ||
30715 | # 387 "jsobjinlines.h" | |
30716 | bool | |
30717 | JSObject::isArgsLengthOverridden() const | |
30718 | { | |
30719 | ((void) 0); | |
30720 | const js::Value &v = getSlot(JSSLOT_ARGS_LENGTH); | |
30721 | return v.toInt32() & ARGS_LENGTH_OVERRIDDEN_BIT; | |
30722 | } | |
30723 | ||
30724 | inline js::ArgumentsData * | |
30725 | JSObject::getArgsData() const | |
30726 | { | |
30727 | ((void) 0); | |
30728 | return (js::ArgumentsData *) getSlot(JSSLOT_ARGS_DATA).toPrivate(); | |
30729 | } | |
30730 | ||
30731 | inline void | |
30732 | JSObject::setArgsData(js::ArgumentsData *data) | |
30733 | { | |
30734 | ((void) 0); | |
30735 | getSlotRef(JSSLOT_ARGS_DATA).setPrivate(data); | |
30736 | } | |
30737 | ||
30738 | inline const js::Value & | |
30739 | JSObject::getArgsCallee() const | |
30740 | { | |
30741 | return getArgsData()->callee; | |
30742 | } | |
30743 | ||
30744 | inline void | |
30745 | JSObject::setArgsCallee(const js::Value &callee) | |
30746 | { | |
30747 | getArgsData()->callee = callee; | |
30748 | } | |
30749 | ||
30750 | inline const js::Value & | |
30751 | JSObject::getArgsElement(uint32 i) const | |
30752 | { | |
30753 | ((void) 0); | |
30754 | ((void) 0); | |
30755 | return getArgsData()->slots[i]; | |
30756 | } | |
30757 | ||
30758 | inline js::Value * | |
30759 | JSObject::getArgsElements() const | |
30760 | { | |
30761 | ((void) 0); | |
30762 | return getArgsData()->slots; | |
30763 | } | |
30764 | ||
30765 | inline js::Value * | |
30766 | JSObject::addressOfArgsElement(uint32 i) | |
30767 | { | |
30768 | ((void) 0); | |
30769 | ((void) 0); | |
30770 | return &getArgsData()->slots[i]; | |
30771 | } | |
30772 | ||
30773 | inline void | |
30774 | JSObject::setArgsElement(uint32 i, const js::Value &v) | |
30775 | { | |
30776 | ((void) 0); | |
30777 | ((void) 0); | |
30778 | getArgsData()->slots[i] = v; | |
30779 | } | |
30780 | ||
30781 | inline | |
30782 | ||
30783 | # 452 "jsobjinlines.h" | |
30784 | bool | |
30785 | JSObject::callIsForEval() const | |
30786 | { | |
30787 | ((void) 0); | |
30788 | ((void) 0); | |
30789 | ((void) 0) | |
30790 | ; | |
30791 | return getSlot(JSSLOT_CALL_CALLEE).isNull(); | |
30792 | } | |
30793 | ||
30794 | inline JSStackFrame * | |
30795 | JSObject::maybeCallObjStackFrame() const | |
30796 | { | |
30797 | ((void) 0); | |
30798 | return reinterpret_cast<JSStackFrame *>(getPrivate()); | |
30799 | } | |
30800 | ||
30801 | inline void | |
30802 | JSObject::setCallObjCallee(JSObject *callee) | |
30803 | { | |
30804 | ((void) 0); | |
30805 | ((void) 0); | |
30806 | return getSlotRef(JSSLOT_CALL_CALLEE).setObjectOrNull(callee); | |
30807 | } | |
30808 | ||
30809 | inline JSObject * | |
30810 | JSObject::getCallObjCallee() const | |
30811 | { | |
30812 | ((void) 0); | |
30813 | return getSlot(JSSLOT_CALL_CALLEE).toObjectOrNull(); | |
30814 | } | |
30815 | ||
30816 | inline JSFunction * | |
30817 | JSObject::getCallObjCalleeFunction() const | |
30818 | { | |
30819 | ((void) 0); | |
30820 | return getSlot(JSSLOT_CALL_CALLEE).toObject().getFunctionPrivate(); | |
30821 | } | |
30822 | ||
30823 | inline const js::Value & | |
30824 | JSObject::getCallObjArguments() const | |
30825 | { | |
30826 | ((void) 0); | |
30827 | ((void) 0); | |
30828 | return getSlot(JSSLOT_CALL_ARGUMENTS); | |
30829 | } | |
30830 | ||
30831 | inline void | |
30832 | JSObject::setCallObjArguments(const js::Value &v) | |
30833 | { | |
30834 | ((void) 0); | |
30835 | ((void) 0); | |
30836 | setSlot(JSSLOT_CALL_ARGUMENTS, v); | |
30837 | } | |
30838 | ||
30839 | inline const js::Value & | |
30840 | JSObject::callObjArg(uintN i) const | |
30841 | { | |
30842 | ((void) 0); | |
30843 | ((void) 0); | |
30844 | return getSlot(JSObject::CALL_RESERVED_SLOTS + i); | |
30845 | } | |
30846 | ||
30847 | inline js::Value & | |
30848 | JSObject::callObjArg(uintN i) | |
30849 | { | |
30850 | ((void) 0); | |
30851 | ((void) 0); | |
30852 | return getSlotRef(JSObject::CALL_RESERVED_SLOTS + i); | |
30853 | } | |
30854 | ||
30855 | inline const js::Value & | |
30856 | JSObject::callObjVar(uintN i) const | |
30857 | { | |
30858 | JSFunction *fun = getCallObjCalleeFunction(); | |
30859 | ((void) 0); | |
30860 | ((void) 0); | |
30861 | return getSlot(JSObject::CALL_RESERVED_SLOTS + fun->nargs + i); | |
30862 | } | |
30863 | ||
30864 | inline js::Value & | |
30865 | JSObject::callObjVar(uintN i) | |
30866 | { | |
30867 | JSFunction *fun = getCallObjCalleeFunction(); | |
30868 | ((void) 0); | |
30869 | ((void) 0); | |
30870 | return getSlotRef(JSObject::CALL_RESERVED_SLOTS + fun->nargs + i); | |
30871 | } | |
30872 | ||
30873 | inline const js::Value & | |
30874 | JSObject::getDateUTCTime() const | |
30875 | { | |
30876 | ((void) 0); | |
30877 | return getSlot(JSSLOT_DATE_UTC_TIME); | |
30878 | } | |
30879 | ||
30880 | inline void | |
30881 | JSObject::setDateUTCTime(const js::Value &time) | |
30882 | { | |
30883 | ((void) 0); | |
30884 | setSlot(JSSLOT_DATE_UTC_TIME, time); | |
30885 | } | |
30886 | ||
30887 | inline js::Value * | |
30888 | JSObject::getFlatClosureUpvars() const | |
30889 | { | |
30890 | ||
30891 | ||
30892 | ||
30893 | ||
30894 | ||
30895 | return (js::Value *) getSlot(JSSLOT_FLAT_CLOSURE_UPVARS).toPrivate(); | |
30896 | } | |
30897 | ||
30898 | inline js::Value | |
30899 | JSObject::getFlatClosureUpvar(uint32 i) const | |
30900 | { | |
30901 | ((void) 0); | |
30902 | return getFlatClosureUpvars()[i]; | |
30903 | } | |
30904 | ||
30905 | inline js::Value & | |
30906 | JSObject::getFlatClosureUpvar(uint32 i) | |
30907 | { | |
30908 | ((void) 0); | |
30909 | return getFlatClosureUpvars()[i]; | |
30910 | } | |
30911 | ||
30912 | inline void | |
30913 | JSObject::setFlatClosureUpvars(js::Value *upvars) | |
30914 | { | |
30915 | ((void) 0); | |
30916 | ((void) 0); | |
30917 | getSlotRef(JSSLOT_FLAT_CLOSURE_UPVARS).setPrivate(upvars); | |
30918 | } | |
30919 | ||
30920 | inline | |
30921 | ||
30922 | # 588 "jsobjinlines.h" | |
30923 | bool | |
30924 | JSObject::hasMethodObj(const JSObject& obj) const | |
30925 | { | |
30926 | return JSSLOT_FUN_METHOD_OBJ < numSlots() && | |
30927 | getSlot(JSSLOT_FUN_METHOD_OBJ).isObject() && | |
30928 | &getSlot(JSSLOT_FUN_METHOD_OBJ).toObject() == &obj; | |
30929 | } | |
30930 | ||
30931 | inline void | |
30932 | JSObject::setMethodObj(JSObject& obj) | |
30933 | { | |
30934 | getSlotRef(JSSLOT_FUN_METHOD_OBJ).setObject(obj); | |
30935 | } | |
30936 | ||
30937 | inline js::NativeIterator * | |
30938 | JSObject::getNativeIterator() const | |
30939 | { | |
30940 | return (js::NativeIterator *) getPrivate(); | |
30941 | } | |
30942 | ||
30943 | inline void | |
30944 | JSObject::setNativeIterator(js::NativeIterator *ni) | |
30945 | { | |
30946 | setPrivate(ni); | |
30947 | } | |
30948 | ||
30949 | inline JSLinearString * | |
30950 | JSObject::getNamePrefix() const | |
30951 | { | |
30952 | ((void) 0); | |
30953 | const js::Value &v = getSlot(JSSLOT_NAME_PREFIX); | |
30954 | return !v.isUndefined() ? v.toString()->assertIsLinear() : __null; | |
30955 | } | |
30956 | ||
30957 | inline jsval | |
30958 | JSObject::getNamePrefixVal() const | |
30959 | { | |
30960 | ((void) 0); | |
30961 | return js::Jsvalify(getSlot(JSSLOT_NAME_PREFIX)); | |
30962 | } | |
30963 | ||
30964 | inline void | |
30965 | JSObject::setNamePrefix(JSLinearString *prefix) | |
30966 | { | |
30967 | ((void) 0); | |
30968 | setSlot(JSSLOT_NAME_PREFIX, prefix ? js::StringValue(prefix) : js::UndefinedValue()); | |
30969 | } | |
30970 | ||
30971 | inline void | |
30972 | JSObject::clearNamePrefix() | |
30973 | { | |
30974 | ((void) 0); | |
30975 | setSlot(JSSLOT_NAME_PREFIX, js::UndefinedValue()); | |
30976 | } | |
30977 | ||
30978 | inline JSLinearString * | |
30979 | JSObject::getNameURI() const | |
30980 | { | |
30981 | ((void) 0); | |
30982 | const js::Value &v = getSlot(JSSLOT_NAME_URI); | |
30983 | return !v.isUndefined() ? v.toString()->assertIsLinear() : __null; | |
30984 | } | |
30985 | ||
30986 | inline jsval | |
30987 | JSObject::getNameURIVal() const | |
30988 | { | |
30989 | ((void) 0); | |
30990 | return js::Jsvalify(getSlot(JSSLOT_NAME_URI)); | |
30991 | } | |
30992 | ||
30993 | inline void | |
30994 | JSObject::setNameURI(JSLinearString *uri) | |
30995 | { | |
30996 | ((void) 0); | |
30997 | setSlot(JSSLOT_NAME_URI, uri ? js::StringValue(uri) : js::UndefinedValue()); | |
30998 | } | |
30999 | ||
31000 | inline jsval | |
31001 | JSObject::getNamespaceDeclared() const | |
31002 | { | |
31003 | ((void) 0); | |
31004 | return js::Jsvalify(getSlot(JSSLOT_NAMESPACE_DECLARED)); | |
31005 | } | |
31006 | ||
31007 | inline void | |
31008 | JSObject::setNamespaceDeclared(jsval decl) | |
31009 | { | |
31010 | ((void) 0); | |
31011 | setSlot(JSSLOT_NAMESPACE_DECLARED, js::Valueify(decl)); | |
31012 | } | |
31013 | ||
31014 | inline JSLinearString * | |
31015 | JSObject::getQNameLocalName() const | |
31016 | { | |
31017 | ((void) 0); | |
31018 | const js::Value &v = getSlot(JSSLOT_QNAME_LOCAL_NAME); | |
31019 | return !v.isUndefined() ? v.toString()->assertIsLinear() : __null; | |
31020 | } | |
31021 | ||
31022 | inline jsval | |
31023 | JSObject::getQNameLocalNameVal() const | |
31024 | { | |
31025 | ((void) 0); | |
31026 | return js::Jsvalify(getSlot(JSSLOT_QNAME_LOCAL_NAME)); | |
31027 | } | |
31028 | ||
31029 | inline void | |
31030 | JSObject::setQNameLocalName(JSLinearString *name) | |
31031 | { | |
31032 | ((void) 0); | |
31033 | setSlot(JSSLOT_QNAME_LOCAL_NAME, name ? js::StringValue(name) : js::UndefinedValue()); | |
31034 | } | |
31035 | ||
31036 | inline JSObject * | |
31037 | JSObject::getWithThis() const | |
31038 | { | |
31039 | return &getSlot(JSSLOT_WITH_THIS).toObject(); | |
31040 | } | |
31041 | ||
31042 | inline void | |
31043 | JSObject::setWithThis(JSObject *thisp) | |
31044 | { | |
31045 | getSlotRef(JSSLOT_WITH_THIS).setObject(*thisp); | |
31046 | } | |
31047 | ||
31048 | inline void | |
31049 | JSObject::init(JSContext *cx, js::Class *aclasp, JSObject *proto, JSObject *parent, | |
31050 | void *priv, bool useHoles) | |
31051 | { | |
31052 | clasp = aclasp; | |
31053 | flags = 0; | |
31054 | # 731 "jsobjinlines.h" | |
31055 | setProto(proto); | |
31056 | setParent(parent); | |
31057 | ||
31058 | privateData = priv; | |
31059 | slots = fixedSlots(); | |
31060 | ||
31061 | ||
31062 | ||
31063 | ||
31064 | ||
31065 | ((void) 0); | |
31066 | ClearValueRange(slots, capacity, useHoles); | |
31067 | ||
31068 | emptyShapes = __null; | |
31069 | } | |
31070 | ||
31071 | inline void | |
31072 | JSObject::finish(JSContext *cx) | |
31073 | { | |
31074 | ||
31075 | ||
31076 | ||
31077 | ||
31078 | if (hasSlotsArray()) | |
31079 | freeSlotsArray(cx); | |
31080 | if (emptyShapes) | |
31081 | cx->free(emptyShapes); | |
31082 | } | |
31083 | ||
31084 | inline | |
31085 | ||
31086 | # 760 "jsobjinlines.h" | |
31087 | bool | |
31088 | JSObject::initSharingEmptyShape(JSContext *cx, | |
31089 | js::Class *aclasp, | |
31090 | JSObject *proto, | |
31091 | JSObject *parent, | |
31092 | void *privateValue, | |
31093 | unsigned kind) | |
31094 | { | |
31095 | init(cx, aclasp, proto, parent, privateValue, false); | |
31096 | ||
31097 | ((void) 0); | |
31098 | ||
31099 | js::EmptyShape *empty = proto->getEmptyShape(cx, aclasp, kind); | |
31100 | if (!empty) | |
31101 | return false; | |
31102 | ||
31103 | setMap(empty); | |
31104 | return true; | |
31105 | } | |
31106 | ||
31107 | inline void | |
31108 | JSObject::freeSlotsArray(JSContext *cx) | |
31109 | { | |
31110 | ((void) 0); | |
31111 | cx->free(slots); | |
31112 | } | |
31113 | ||
31114 | inline void | |
31115 | JSObject::revertToFixedSlots(JSContext *cx) | |
31116 | { | |
31117 | ((void) 0); | |
31118 | size_t fixed = numFixedSlots(); | |
31119 | ((void) 0); | |
31120 | memcpy(fixedSlots(), slots, fixed * sizeof(js::Value)); | |
31121 | freeSlotsArray(cx); | |
31122 | slots = fixedSlots(); | |
31123 | capacity = fixed; | |
31124 | } | |
31125 | ||
31126 | inline | |
31127 | ||
31128 | # 799 "jsobjinlines.h" | |
31129 | bool | |
31130 | JSObject::hasProperty(JSContext *cx, jsid id, bool *foundp, uintN flags) | |
31131 | { | |
31132 | JSObject *pobj; | |
31133 | JSProperty *prop; | |
31134 | JSAutoResolveFlags rf(cx, flags); | |
31135 | if (!lookupProperty(cx, id, &pobj, &prop)) | |
31136 | return false; | |
31137 | *foundp = !!prop; | |
31138 | return true; | |
31139 | } | |
31140 | ||
31141 | inline | |
31142 | ||
31143 | # 811 "jsobjinlines.h" | |
31144 | bool | |
31145 | JSObject::isCallable() | |
31146 | { | |
31147 | return isFunction() || getClass()->call; | |
31148 | } | |
31149 | ||
31150 | static inline | |
31151 | ||
31152 | # 817 "jsobjinlines.h" | |
31153 | bool | |
31154 | js_IsCallable(const js::Value &v) | |
31155 | { | |
31156 | return v.isObject() && v.toObject().isCallable(); | |
31157 | } | |
31158 | ||
31159 | namespace js { | |
31160 | ||
31161 | class AutoPropDescArrayRooter : private AutoGCRooter | |
31162 | { | |
31163 | public: | |
31164 | AutoPropDescArrayRooter(JSContext *cx) | |
31165 | : AutoGCRooter(cx, DESCRIPTORS), descriptors(cx) | |
31166 | { } | |
31167 | ||
31168 | PropDesc *append() { | |
31169 | if (!descriptors.append(PropDesc())) | |
31170 | return __null; | |
31171 | return &descriptors.back(); | |
31172 | } | |
31173 | ||
31174 | PropDesc& operator[](size_t i) { | |
31175 | ((void) 0); | |
31176 | return descriptors[i]; | |
31177 | } | |
31178 | ||
31179 | friend void AutoGCRooter::trace(JSTracer *trc); | |
31180 | ||
31181 | private: | |
31182 | PropDescArray descriptors; | |
31183 | }; | |
31184 | ||
31185 | class AutoPropertyDescriptorRooter : private AutoGCRooter, public PropertyDescriptor | |
31186 | { | |
31187 | public: | |
31188 | AutoPropertyDescriptorRooter(JSContext *cx) : AutoGCRooter(cx, DESCRIPTOR) { | |
31189 | obj = __null; | |
31190 | attrs = 0; | |
31191 | getter = (PropertyOp) __null; | |
31192 | setter = (StrictPropertyOp) __null; | |
31193 | value.setUndefined(); | |
31194 | } | |
31195 | ||
31196 | AutoPropertyDescriptorRooter(JSContext *cx, PropertyDescriptor *desc) | |
31197 | : AutoGCRooter(cx, DESCRIPTOR) | |
31198 | { | |
31199 | obj = desc->obj; | |
31200 | attrs = desc->attrs; | |
31201 | getter = desc->getter; | |
31202 | setter = desc->setter; | |
31203 | value = desc->value; | |
31204 | } | |
31205 | ||
31206 | friend void AutoGCRooter::trace(JSTracer *trc); | |
31207 | }; | |
31208 | ||
31209 | static inline | |
31210 | ||
31211 | # 873 "jsobjinlines.h" | |
31212 | bool | |
31213 | InitScopeForObject(JSContext* cx, JSObject* obj, js::Class *clasp, JSObject* proto, | |
31214 | gc::FinalizeKind kind) | |
31215 | { | |
31216 | ((void) 0); | |
31217 | ((void) 0); | |
31218 | ||
31219 | ||
31220 | js::EmptyShape *empty = __null; | |
31221 | ||
31222 | if (proto) { | |
31223 | if (proto->canProvideEmptyShape(clasp)) { | |
31224 | empty = proto->getEmptyShape(cx, clasp, kind); | |
31225 | if (!empty) | |
31226 | goto bad; | |
31227 | } | |
31228 | } | |
31229 | ||
31230 | if (!empty) { | |
31231 | empty = js::EmptyShape::create(cx, clasp); | |
31232 | if (!empty) | |
31233 | goto bad; | |
31234 | uint32 freeslot = (((clasp)->flags >> 8) & (((JSUint32)1 << (8)) - 1)); | |
31235 | if (freeslot > obj->numSlots() && !obj->allocSlots(cx, freeslot)) | |
31236 | goto bad; | |
31237 | } | |
31238 | ||
31239 | obj->setMap(empty); | |
31240 | return true; | |
31241 | ||
31242 | bad: | |
31243 | ||
31244 | ((void) 0); | |
31245 | return false; | |
31246 | } | |
31247 | ||
31248 | ||
31249 | ||
31250 | ||
31251 | ||
31252 | ||
31253 | ||
31254 | static inline JSObject * | |
31255 | NewNativeClassInstance(JSContext *cx, Class *clasp, JSObject *proto, | |
31256 | JSObject *parent, gc::FinalizeKind kind) | |
31257 | { | |
31258 | ((void) 0); | |
31259 | ((void) 0); | |
31260 | ||
31261 | ||
31262 | ||
31263 | ||
31264 | ||
31265 | JSObject* obj = js_NewGCObject(cx, kind); | |
31266 | ||
31267 | if (obj) { | |
31268 | ||
31269 | ||
31270 | ||
31271 | ||
31272 | bool useHoles = (clasp == &js_ArrayClass); | |
31273 | obj->init(cx, clasp, proto, parent, __null, useHoles); | |
31274 | ||
31275 | ((void) 0); | |
31276 | js::EmptyShape *empty = proto->getEmptyShape(cx, clasp, kind); | |
31277 | ||
31278 | if (empty) | |
31279 | obj->setMap(empty); | |
31280 | else | |
31281 | obj = __null; | |
31282 | } | |
31283 | ||
31284 | return obj; | |
31285 | } | |
31286 | ||
31287 | static inline JSObject * | |
31288 | NewNativeClassInstance(JSContext *cx, Class *clasp, JSObject *proto, JSObject *parent) | |
31289 | { | |
31290 | gc::FinalizeKind kind = gc::GetGCObjectKind((((clasp)->flags >> 8) & (((JSUint32)1 << (8)) - 1))); | |
31291 | return NewNativeClassInstance(cx, clasp, proto, parent, kind); | |
31292 | } | |
31293 | ||
31294 | ||
31295 | bool | |
31296 | # 956 "jsobjinlines.h" | |
31297 | FindClassPrototype(JSContext *cx, JSObject *scope, JSProtoKey protoKey, JSObject **protop, | |
31298 | Class *clasp); | |
31299 | ||
31300 | ||
31301 | ||
31302 | ||
31303 | ||
31304 | ||
31305 | ||
31306 | static inline JSObject * | |
31307 | NewBuiltinClassInstance(JSContext *cx, Class *clasp, gc::FinalizeKind kind) | |
31308 | { | |
31309 | ((void) 0); | |
31310 | ||
31311 | JSProtoKey protoKey = ((JSProtoKey) (((clasp)->flags >> ((8 + 8) + 8)) & (((JSUint32)1 << (8)) - 1))); | |
31312 | ((void) 0); | |
31313 | ||
31314 | ||
31315 | JSObject *global; | |
31316 | if (!cx->hasfp()) { | |
31317 | global = cx->globalObject; | |
31318 | OBJ_TO_INNER_OBJECT(cx, global); | |
31319 | if (!global) | |
31320 | return __null; | |
31321 | } else { | |
31322 | global = cx->fp()->scopeChain().getGlobal(); | |
31323 | } | |
31324 | ((void) 0); | |
31325 | ||
31326 | const Value &v = global->getReservedSlot(JSProto_LIMIT + protoKey); | |
31327 | JSObject *proto; | |
31328 | if (v.isObject()) { | |
31329 | proto = &v.toObject(); | |
31330 | ((void) 0); | |
31331 | } else { | |
31332 | if (!FindClassPrototype(cx, global, protoKey, &proto, clasp)) | |
31333 | return __null; | |
31334 | } | |
31335 | ||
31336 | return NewNativeClassInstance(cx, clasp, proto, global, kind); | |
31337 | } | |
31338 | ||
31339 | static inline JSObject * | |
31340 | NewBuiltinClassInstance(JSContext *cx, Class *clasp) | |
31341 | { | |
31342 | gc::FinalizeKind kind = gc::GetGCObjectKind((((clasp)->flags >> 8) & (((JSUint32)1 << (8)) - 1))); | |
31343 | return NewBuiltinClassInstance(cx, clasp, kind); | |
31344 | } | |
31345 | ||
31346 | static inline JSProtoKey | |
31347 | GetClassProtoKey(js::Class *clasp) | |
31348 | { | |
31349 | JSProtoKey key = ((JSProtoKey) (((clasp)->flags >> ((8 + 8) + 8)) & (((JSUint32)1 << (8)) - 1))); | |
31350 | if (key != JSProto_Null) | |
31351 | return key; | |
31352 | if (clasp->flags & (1<<((8 + 8)+1))) | |
31353 | return JSProto_Object; | |
31354 | return JSProto_Null; | |
31355 | } | |
31356 | ||
31357 | namespace WithProto { | |
31358 | enum e { | |
31359 | Class = 0, | |
31360 | Given = 1 | |
31361 | }; | |
31362 | } | |
31363 | # 1049 "jsobjinlines.h" | |
31364 | static __attribute__((always_inline)) inline | |
31365 | ||
31366 | # 1049 "jsobjinlines.h" | |
31367 | bool | |
31368 | FindProto(JSContext *cx, js::Class *clasp, JSObject *parent, JSObject ** proto) | |
31369 | { | |
31370 | JSProtoKey protoKey = GetClassProtoKey(clasp); | |
31371 | if (!js_GetClassPrototype(cx, parent, protoKey, proto, clasp)) | |
31372 | return false; | |
31373 | if (!(*proto) && !js_GetClassPrototype(cx, parent, JSProto_Object, proto)) | |
31374 | return false; | |
31375 | ||
31376 | return true; | |
31377 | } | |
31378 | ||
31379 | namespace detail | |
31380 | { | |
31381 | template <bool withProto, bool isFunction> | |
31382 | static __attribute__((always_inline)) inline JSObject * | |
31383 | NewObject(JSContext *cx, js::Class *clasp, JSObject *proto, JSObject *parent, | |
31384 | gc::FinalizeKind kind) | |
31385 | { | |
31386 | ||
31387 | if (withProto == WithProto::Class && !proto) { | |
31388 | if (!FindProto(cx, clasp, parent, &proto)) | |
31389 | return __null; | |
31390 | } | |
31391 | # 1081 "jsobjinlines.h" | |
31392 | JSObject* obj = isFunction ? js_NewGCFunction(cx) : js_NewGCObject(cx, kind); | |
31393 | if (!obj) | |
31394 | goto out; | |
31395 | ||
31396 | ||
31397 | ((void) 0); | |
31398 | ||
31399 | ||
31400 | ||
31401 | ||
31402 | ||
31403 | obj->init(cx, clasp, proto, | |
31404 | (!parent && proto) ? proto->getParent() : parent, | |
31405 | __null, clasp == &js_ArrayClass); | |
31406 | ||
31407 | if (clasp->isNative()) { | |
31408 | if (!InitScopeForObject(cx, obj, clasp, proto, kind)) { | |
31409 | obj = __null; | |
31410 | goto out; | |
31411 | } | |
31412 | } else { | |
31413 | obj->setSharedNonNativeMap(); | |
31414 | } | |
31415 | ||
31416 | out: | |
31417 | Probes::createObject(cx, obj); | |
31418 | return obj; | |
31419 | } | |
31420 | } | |
31421 | ||
31422 | static __attribute__((always_inline)) inline JSObject * | |
31423 | NewFunction(JSContext *cx, JSObject *parent) | |
31424 | { | |
31425 | return detail::NewObject<WithProto::Class, true>(cx, &js_FunctionClass, __null, parent, | |
31426 | gc::FINALIZE_OBJECT2); | |
31427 | } | |
31428 | ||
31429 | template <WithProto::e withProto> | |
31430 | static __attribute__((always_inline)) inline JSObject * | |
31431 | NewNonFunction(JSContext *cx, js::Class *clasp, JSObject *proto, JSObject *parent, | |
31432 | gc::FinalizeKind kind) | |
31433 | { | |
31434 | return detail::NewObject<withProto, false>(cx, clasp, proto, parent, kind); | |
31435 | } | |
31436 | ||
31437 | template <WithProto::e withProto> | |
31438 | static __attribute__((always_inline)) inline JSObject * | |
31439 | NewNonFunction(JSContext *cx, js::Class *clasp, JSObject *proto, JSObject *parent) | |
31440 | { | |
31441 | gc::FinalizeKind kind = gc::GetGCObjectKind((((clasp)->flags >> 8) & (((JSUint32)1 << (8)) - 1))); | |
31442 | return detail::NewObject<withProto, false>(cx, clasp, proto, parent, kind); | |
31443 | } | |
31444 | ||
31445 | template <WithProto::e withProto> | |
31446 | static __attribute__((always_inline)) inline JSObject * | |
31447 | NewObject(JSContext *cx, js::Class *clasp, JSObject *proto, JSObject *parent, | |
31448 | gc::FinalizeKind kind) | |
31449 | { | |
31450 | if (clasp == &js_FunctionClass) | |
31451 | return detail::NewObject<withProto, true>(cx, clasp, proto, parent, kind); | |
31452 | return detail::NewObject<withProto, false>(cx, clasp, proto, parent, kind); | |
31453 | } | |
31454 | ||
31455 | template <WithProto::e withProto> | |
31456 | static __attribute__((always_inline)) inline JSObject * | |
31457 | NewObject(JSContext *cx, js::Class *clasp, JSObject *proto, JSObject *parent) | |
31458 | { | |
31459 | gc::FinalizeKind kind = gc::GetGCObjectKind((((clasp)->flags >> 8) & (((JSUint32)1 << (8)) - 1))); | |
31460 | return NewObject<withProto>(cx, clasp, proto, parent, kind); | |
31461 | } | |
31462 | ||
31463 | ||
31464 | ||
31465 | ||
31466 | ||
31467 | static inline gc::FinalizeKind | |
31468 | GuessObjectGCKind(size_t numSlots, bool isArray) | |
31469 | { | |
31470 | if (numSlots) | |
31471 | return gc::GetGCObjectKind(numSlots); | |
31472 | return isArray ? gc::FINALIZE_OBJECT8 : gc::FINALIZE_OBJECT4; | |
31473 | } | |
31474 | ||
31475 | ||
31476 | ||
31477 | ||
31478 | ||
31479 | static inline gc::FinalizeKind | |
31480 | NewObjectGCKind(JSContext *cx, js::Class *clasp) | |
31481 | { | |
31482 | if (clasp == &js_ArrayClass || clasp == &js_SlowArrayClass) | |
31483 | return gc::FINALIZE_OBJECT8; | |
31484 | if (clasp == &js_FunctionClass) | |
31485 | return gc::FINALIZE_OBJECT2; | |
31486 | return gc::FINALIZE_OBJECT4; | |
31487 | } | |
31488 | ||
31489 | ||
31490 | static inline JSObject * | |
31491 | CopyInitializerObject(JSContext *cx, JSObject *baseobj) | |
31492 | { | |
31493 | ((void) 0); | |
31494 | ((void) 0); | |
31495 | ||
31496 | gc::FinalizeKind kind = gc::FinalizeKind(baseobj->finalizeKind()); | |
31497 | JSObject *obj = NewBuiltinClassInstance(cx, &js_ObjectClass, kind); | |
31498 | ||
31499 | if (!obj || !obj->ensureSlots(cx, baseobj->numSlots())) | |
31500 | return __null; | |
31501 | ||
31502 | obj->flags = baseobj->flags; | |
31503 | obj->lastProp = baseobj->lastProp; | |
31504 | obj->objShape = baseobj->objShape; | |
31505 | ||
31506 | return obj; | |
31507 | } | |
31508 | # 1206 "jsobjinlines.h" | |
31509 | static __attribute__((always_inline)) inline | |
31510 | ||
31511 | # 1206 "jsobjinlines.h" | |
31512 | bool | |
31513 | ClassMethodIsNative(JSContext *cx, JSObject *obj, Class *clasp, jsid methodid, | |
31514 | Native native) | |
31515 | { | |
31516 | ((void) 0); | |
31517 | ||
31518 | if (HasNativeMethod(obj, methodid, native)) | |
31519 | return true; | |
31520 | ||
31521 | JSObject *pobj = obj->getProto(); | |
31522 | return pobj && pobj->getClass() == clasp && | |
31523 | HasNativeMethod(pobj, methodid, native); | |
31524 | } | |
31525 | ||
31526 | } | |
31527 | # 77 "jsxml.cpp" 2 | |
31528 | ||
31529 | ||
31530 | ||
31531 | ||
31532 | ||
31533 | ||
31534 | using namespace js; | |
31535 | using namespace js::gc; | |
31536 | # 98 "jsxml.cpp" | |
31537 | static inline | |
31538 | ||
31539 | # 98 "jsxml.cpp" | |
31540 | bool | |
31541 | js_EnterLocalRootScope(JSContext *cx) | |
31542 | { | |
31543 | return true; | |
31544 | } | |
31545 | ||
31546 | static inline void | |
31547 | js_LeaveLocalRootScope(JSContext *cx) | |
31548 | { | |
31549 | } | |
31550 | ||
31551 | static inline void | |
31552 | js_LeaveLocalRootScopeWithResult(JSContext *cx, jsval rval) | |
31553 | { | |
31554 | } | |
31555 | ||
31556 | static inline void | |
31557 | js_LeaveLocalRootScopeWithResult(JSContext *cx, Value rval) | |
31558 | { | |
31559 | } | |
31560 | ||
31561 | static inline void | |
31562 | js_LeaveLocalRootScopeWithResult(JSContext *cx, void *rval) | |
31563 | { | |
31564 | } | |
31565 | # 142 "jsxml.cpp" | |
31566 | const char js_AttributeName_str[] = "AttributeName"; | |
31567 | const char js_isXMLName_str[] = "isXMLName"; | |
31568 | const char js_XMLList_str[] = "XMLList"; | |
31569 | const char js_localName_str[] = "localName"; | |
31570 | const char js_xml_parent_str[] = "parent"; | |
31571 | const char js_prefix_str[] = "prefix"; | |
31572 | const char js_toXMLString_str[] = "toXMLString"; | |
31573 | const char js_uri_str[] = "uri"; | |
31574 | ||
31575 | const char js_amp_entity_str[] = "&"; | |
31576 | const char js_gt_entity_str[] = ">"; | |
31577 | const char js_lt_entity_str[] = "<"; | |
31578 | const char js_quot_entity_str[] = """; | |
31579 | const char js_leftcurly_entity_str[] = "{"; | |
31580 | ||
31581 | ||
31582 | ||
31583 | static JSBool | |
31584 | GetXMLFunction(JSContext *cx, JSObject *obj, jsid id, jsval *vp); | |
31585 | ||
31586 | static JSBool | |
31587 | IsDeclared(const JSObject *obj) | |
31588 | { | |
31589 | jsval v; | |
31590 | ||
31591 | ((void) 0); | |
31592 | v = obj->getNamespaceDeclared(); | |
31593 | ((void) 0); | |
31594 | return v == ((((uint64)(uint32)(JSVAL_TAG_BOOLEAN)) << 47) | ((JSIntn)1)); | |
31595 | } | |
31596 | ||
31597 | static JSBool | |
31598 | xml_isXMLName(JSContext *cx, uintN argc, jsval *vp) | |
31599 | { | |
31600 | *vp = BOOLEAN_TO_JSVAL(js_IsXMLName(cx, argc ? vp[2] : ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0)))); | |
31601 | return (JSIntn)1; | |
31602 | } | |
31603 | ||
31604 | ||
31605 | ||
31606 | ||
31607 | ||
31608 | ||
31609 | static inline JSObject * | |
31610 | NewBuiltinClassInstanceXML(JSContext *cx, Class *clasp) | |
31611 | { | |
31612 | JSObject *obj = NewBuiltinClassInstance(cx, clasp); | |
31613 | if (obj) | |
31614 | obj->syncSpecialEquality(); | |
31615 | return obj; | |
31616 | } | |
31617 | # 205 "jsxml.cpp" | |
31618 | static JSBool NamePrefix_getter(JSContext *cx, JSObject *obj, jsid id, jsval *vp) { if (obj->getClass() == &js_NamespaceClass) *vp = obj->getNamePrefixVal(); return true; } | |
31619 | ||
31620 | static JSBool NameURI_getter(JSContext *cx, JSObject *obj, jsid id, jsval *vp) { if (obj->getClass() == &js_NamespaceClass) *vp = obj->getNameURIVal(); return true; } | |
31621 | ||
31622 | ||
31623 | static JSBool | |
31624 | namespace_equality(JSContext *cx, JSObject *obj, const Value *v, JSBool *bp) | |
31625 | { | |
31626 | JSObject *obj2; | |
31627 | ||
31628 | ((void) 0); | |
31629 | obj2 = v->toObjectOrNull(); | |
31630 | *bp = (!obj2 || obj2->getClass() != &js_NamespaceClass) | |
31631 | ? (JSIntn)0 | |
31632 | : EqualStrings(obj->getNameURI(), obj2->getNameURI()); | |
31633 | return (JSIntn)1; | |
31634 | } | |
31635 | ||
31636 | __attribute__((visibility ("default"))) Class js_NamespaceClass = { | |
31637 | "Namespace", | |
31638 | (1<<6) | | |
31639 | (((JSObject::NAMESPACE_CLASS_RESERVED_SLOTS) & (((JSUint32)1 << (8)) - 1)) << 8) | | |
31640 | (1<<((8 + 8)+3)) | ((JSProto_Namespace) << ((8 + 8) + 8)), | |
31641 | PropertyStub, | |
31642 | PropertyStub, | |
31643 | PropertyStub, | |
31644 | StrictPropertyStub, | |
31645 | EnumerateStub, | |
31646 | ResolveStub, | |
31647 | ConvertStub, | |
31648 | FinalizeStub, | |
31649 | __null, | |
31650 | __null, | |
31651 | __null, | |
31652 | __null, | |
31653 | __null, | |
31654 | __null, | |
31655 | __null, | |
31656 | { | |
31657 | namespace_equality, | |
31658 | __null, | |
31659 | __null, | |
31660 | __null, | |
31661 | __null, | |
31662 | } | |
31663 | }; | |
31664 | ||
31665 | ||
31666 | ||
31667 | ||
31668 | static JSPropertySpec namespace_props[] = { | |
31669 | {js_prefix_str, 0, (0x01 | 0x02 | 0x04 | 0x40), NamePrefix_getter, 0}, | |
31670 | {js_uri_str, 0, (0x01 | 0x02 | 0x04 | 0x40), NameURI_getter, 0}, | |
31671 | {0,0,0,0,0} | |
31672 | }; | |
31673 | ||
31674 | static JSBool | |
31675 | namespace_toString(JSContext *cx, uintN argc, Value *vp) | |
31676 | { | |
31677 | JSObject *obj = ToObject(cx, &vp[1]); | |
31678 | if (!obj) | |
31679 | return (JSIntn)0; | |
31680 | if (!JS_InstanceOf(cx, obj, Jsvalify(&js_NamespaceClass), Jsvalify(vp + 2))) | |
31681 | return (JSIntn)0; | |
31682 | *vp = Valueify(obj->getNameURIVal()); | |
31683 | return (JSIntn)1; | |
31684 | } | |
31685 | ||
31686 | static JSFunctionSpec namespace_methods[] = { | |
31687 | {js_toString_str, ((JSNative)(namespace_toString)), 0, (0) | 0x1000}, | |
31688 | {__null, __null, 0, 0} | |
31689 | }; | |
31690 | ||
31691 | static JSObject * | |
31692 | NewXMLNamespace(JSContext *cx, JSLinearString *prefix, JSLinearString *uri, JSBool declared) | |
31693 | { | |
31694 | JSObject *obj; | |
31695 | ||
31696 | obj = NewBuiltinClassInstanceXML(cx, &js_NamespaceClass); | |
31697 | if (!obj) | |
31698 | return (JSIntn)0; | |
31699 | ((void) 0); | |
31700 | ((void) 0); | |
31701 | ((void) 0); | |
31702 | if (prefix) | |
31703 | obj->setNamePrefix(prefix); | |
31704 | if (uri) | |
31705 | obj->setNameURI(uri); | |
31706 | if (declared) | |
31707 | obj->setNamespaceDeclared(((((uint64)(uint32)(JSVAL_TAG_BOOLEAN)) << 47) | ((JSIntn)1))); | |
31708 | ; | |
31709 | return obj; | |
31710 | } | |
31711 | ||
31712 | ||
31713 | ||
31714 | ||
31715 | static JSBool QNameNameURI_getter(JSContext *cx, JSObject *obj, jsid id, jsval *vp) { if (obj->getClass() == &js_QNameClass) *vp = JSVAL_IS_VOID(obj->getNameURIVal()) ? ((((uint64)(uint32)(JSVAL_TAG_NULL)) << 47) | (0)) : obj->getNameURIVal(); return true; } | |
31716 | ||
31717 | ||
31718 | static JSBool QNameLocalName_getter(JSContext *cx, JSObject *obj, jsid id, jsval *vp) { if (obj->getClass() == &js_QNameClass) *vp = obj->getQNameLocalNameVal(); return true; } | |
31719 | ||
31720 | ||
31721 | ||
31722 | static JSBool | |
31723 | qname_identity(JSObject *qna, JSObject *qnb) | |
31724 | { | |
31725 | JSLinearString *uri1 = qna->getNameURI(); | |
31726 | JSLinearString *uri2 = qnb->getNameURI(); | |
31727 | ||
31728 | if (!uri1 ^ !uri2) | |
31729 | return (JSIntn)0; | |
31730 | if (uri1 && !EqualStrings(uri1, uri2)) | |
31731 | return (JSIntn)0; | |
31732 | return EqualStrings(qna->getQNameLocalName(), qnb->getQNameLocalName()); | |
31733 | } | |
31734 | ||
31735 | static JSBool | |
31736 | qname_equality(JSContext *cx, JSObject *qn, const Value *v, JSBool *bp) | |
31737 | { | |
31738 | JSObject *obj2; | |
31739 | ||
31740 | obj2 = v->toObjectOrNull(); | |
31741 | *bp = (!obj2 || obj2->getClass() != &js_QNameClass) | |
31742 | ? (JSIntn)0 | |
31743 | : qname_identity(qn, obj2); | |
31744 | return (JSIntn)1; | |
31745 | } | |
31746 | ||
31747 | __attribute__((visibility ("default"))) Class js_QNameClass = { | |
31748 | "QName", | |
31749 | (1<<6) | | |
31750 | (((JSObject::QNAME_CLASS_RESERVED_SLOTS) & (((JSUint32)1 << (8)) - 1)) << 8) | | |
31751 | (1<<((8 + 8)+3)) | ((JSProto_QName) << ((8 + 8) + 8)), | |
31752 | PropertyStub, | |
31753 | PropertyStub, | |
31754 | PropertyStub, | |
31755 | StrictPropertyStub, | |
31756 | EnumerateStub, | |
31757 | ResolveStub, | |
31758 | ConvertStub, | |
31759 | FinalizeStub, | |
31760 | __null, | |
31761 | __null, | |
31762 | __null, | |
31763 | __null, | |
31764 | __null, | |
31765 | __null, | |
31766 | __null, | |
31767 | { | |
31768 | qname_equality, | |
31769 | __null, | |
31770 | __null, | |
31771 | __null, | |
31772 | __null, | |
31773 | } | |
31774 | }; | |
31775 | ||
31776 | ||
31777 | ||
31778 | ||
31779 | ||
31780 | ||
31781 | ||
31782 | __attribute__((visibility ("default"))) Class js_AttributeNameClass = { | |
31783 | js_AttributeName_str, | |
31784 | (1<<6) | | |
31785 | (((JSObject::QNAME_CLASS_RESERVED_SLOTS) & (((JSUint32)1 << (8)) - 1)) << 8) | | |
31786 | (1<<((8 + 8)+3)) | (1<<((8 + 8)+1)), | |
31787 | PropertyStub, | |
31788 | PropertyStub, | |
31789 | PropertyStub, | |
31790 | StrictPropertyStub, | |
31791 | EnumerateStub, | |
31792 | ResolveStub, | |
31793 | ConvertStub, | |
31794 | FinalizeStub | |
31795 | }; | |
31796 | ||
31797 | __attribute__((visibility ("default"))) Class js_AnyNameClass = { | |
31798 | js_AnyName_str, | |
31799 | (1<<6) | | |
31800 | (((JSObject::QNAME_CLASS_RESERVED_SLOTS) & (((JSUint32)1 << (8)) - 1)) << 8) | | |
31801 | (1<<((8 + 8)+3)) | (1<<((8 + 8)+1)), | |
31802 | PropertyStub, | |
31803 | PropertyStub, | |
31804 | PropertyStub, | |
31805 | StrictPropertyStub, | |
31806 | EnumerateStub, | |
31807 | ResolveStub, | |
31808 | ConvertStub, | |
31809 | FinalizeStub | |
31810 | }; | |
31811 | ||
31812 | ||
31813 | ||
31814 | static JSPropertySpec qname_props[] = { | |
31815 | {js_uri_str, 0, (0x01 | 0x02 | 0x04 | 0x40), QNameNameURI_getter, 0}, | |
31816 | {js_localName_str, 0, (0x01 | 0x02 | 0x04 | 0x40), QNameLocalName_getter, 0}, | |
31817 | {0,0,0,0,0} | |
31818 | }; | |
31819 | ||
31820 | static JSString * | |
31821 | ConvertQNameToString(JSContext *cx, JSObject *obj) | |
31822 | { | |
31823 | ((void) 0); | |
31824 | JSString *uri = obj->getNameURI(); | |
31825 | JSString *str; | |
31826 | if (!uri) { | |
31827 | ||
31828 | str = (cx->runtime->atomState.starQualifierAtom); | |
31829 | } else if (uri->empty()) { | |
31830 | ||
31831 | str = cx->runtime->emptyString; | |
31832 | } else { | |
31833 | JSString *qualstr = (cx->runtime->atomState.qualifierAtom); | |
31834 | str = js_ConcatStrings(cx, uri, qualstr); | |
31835 | if (!str) | |
31836 | return __null; | |
31837 | } | |
31838 | str = js_ConcatStrings(cx, str, obj->getQNameLocalName()); | |
31839 | if (!str) | |
31840 | return __null; | |
31841 | ||
31842 | if (obj->getClass() == &js_AttributeNameClass) { | |
31843 | JS::Anchor<JSString *> anchor(str); | |
31844 | size_t length = str->length(); | |
31845 | jschar *chars = (jschar *) cx->malloc((length + 2) * sizeof(jschar)); | |
31846 | if (!chars) | |
31847 | return (JSIntn)0; | |
31848 | *chars = '@'; | |
31849 | const jschar *strChars = str->getChars(cx); | |
31850 | if (!strChars) { | |
31851 | cx->free(chars); | |
31852 | return __null; | |
31853 | } | |
31854 | memcpy((chars + 1), (strChars), (length) * sizeof(jschar)); | |
31855 | chars[++length] = 0; | |
31856 | str = js_NewString(cx, chars, length); | |
31857 | if (!str) { | |
31858 | cx->free(chars); | |
31859 | return __null; | |
31860 | } | |
31861 | } | |
31862 | return str; | |
31863 | } | |
31864 | ||
31865 | static JSBool | |
31866 | qname_toString(JSContext *cx, uintN argc, Value *vp) | |
31867 | { | |
31868 | JSObject *obj = ToObject(cx, &vp[1]); | |
31869 | if (!obj) | |
31870 | return false; | |
31871 | ||
31872 | if (!InstanceOf(cx, obj, &js_QNameClass, vp + 2)) | |
31873 | return false; | |
31874 | ||
31875 | JSString *str = ConvertQNameToString(cx, obj); | |
31876 | if (!str) | |
31877 | return false; | |
31878 | ||
31879 | vp->setString(str); | |
31880 | return true; | |
31881 | } | |
31882 | ||
31883 | static JSFunctionSpec qname_methods[] = { | |
31884 | {js_toString_str, ((JSNative)(qname_toString)), 0, (0) | 0x1000}, | |
31885 | {__null, __null, 0, 0} | |
31886 | }; | |
31887 | ||
31888 | ||
31889 | static void | |
31890 | InitXMLQName(JSObject *obj, JSLinearString *uri, JSLinearString *prefix, | |
31891 | JSLinearString *localName) | |
31892 | { | |
31893 | ((void) 0); | |
31894 | ((void) 0); | |
31895 | ((void) 0); | |
31896 | ((void) 0); | |
31897 | if (uri) | |
31898 | obj->setNameURI(uri); | |
31899 | if (prefix) | |
31900 | obj->setNamePrefix(prefix); | |
31901 | if (localName) | |
31902 | obj->setQNameLocalName(localName); | |
31903 | } | |
31904 | ||
31905 | static JSObject * | |
31906 | NewXMLQName(JSContext *cx, JSLinearString *uri, JSLinearString *prefix, | |
31907 | JSLinearString *localName) | |
31908 | { | |
31909 | JSObject *obj = NewBuiltinClassInstanceXML(cx, &js_QNameClass); | |
31910 | if (!obj) | |
31911 | return __null; | |
31912 | InitXMLQName(obj, uri, prefix, localName); | |
31913 | ; | |
31914 | return obj; | |
31915 | } | |
31916 | ||
31917 | static JSObject * | |
31918 | NewXMLAttributeName(JSContext *cx, JSLinearString *uri, JSLinearString *prefix, | |
31919 | JSLinearString *localName) | |
31920 | { | |
31921 | ||
31922 | ||
31923 | ||
31924 | ||
31925 | JSObject *obj = NewNonFunction<WithProto::Given>(cx, &js_AttributeNameClass, __null, __null); | |
31926 | if (!obj) | |
31927 | return __null; | |
31928 | ((void) 0); | |
31929 | InitXMLQName(obj, uri, prefix, localName); | |
31930 | ; | |
31931 | return obj; | |
31932 | } | |
31933 | ||
31934 | JSObject * | |
31935 | js_ConstructXMLQNameObject(JSContext *cx, const Value &nsval, const Value &lnval) | |
31936 | { | |
31937 | Value argv[2]; | |
31938 | ||
31939 | ||
31940 | ||
31941 | ||
31942 | ||
31943 | ||
31944 | if (nsval.isObject() && | |
31945 | nsval.toObject().getClass() == &js_AnyNameClass) { | |
31946 | argv[0].setNull(); | |
31947 | } else { | |
31948 | argv[0] = nsval; | |
31949 | } | |
31950 | argv[1] = lnval; | |
31951 | return js_ConstructObject(cx, &js_QNameClass, __null, __null, 2, argv); | |
31952 | } | |
31953 | ||
31954 | static JSBool | |
31955 | IsXMLName(const jschar *cp, size_t n) | |
31956 | { | |
31957 | JSBool rv; | |
31958 | jschar c; | |
31959 | ||
31960 | rv = (JSIntn)0; | |
31961 | if (n != 0 && (((js_A[js_Y[(js_X[(uint16)(*cp)>>6]<<6)|((*cp)&0x3F)]]) & 0x00000100) || (*cp) == '_')) { | |
31962 | while (--n != 0) { | |
31963 | c = *++cp; | |
31964 | if (!(((js_A[js_Y[(js_X[(uint16)(c)>>6]<<6)|((c)&0x3F)]]) & 0x00000080) || (c) == '.' || (c) == '-' || (c) == '_')) | |
31965 | return rv; | |
31966 | } | |
31967 | rv = (JSIntn)1; | |
31968 | } | |
31969 | return rv; | |
31970 | } | |
31971 | ||
31972 | JSBool | |
31973 | js_IsXMLName(JSContext *cx, jsval v) | |
31974 | { | |
31975 | JSLinearString *name = __null; | |
31976 | JSErrorReporter older; | |
31977 | ||
31978 | ||
31979 | ||
31980 | ||
31981 | ||
31982 | ||
31983 | ||
31984 | if (!JSVAL_IS_PRIMITIVE(v) && | |
31985 | JSVAL_TO_OBJECT(v)->isQName()) { | |
31986 | name = JSVAL_TO_OBJECT(v)->getQNameLocalName(); | |
31987 | } else { | |
31988 | older = JS_SetErrorReporter(cx, __null); | |
31989 | JSString *str = js_ValueToString(cx, Valueify(v)); | |
31990 | if (str) | |
31991 | name = str->ensureLinear(cx); | |
31992 | JS_SetErrorReporter(cx, older); | |
31993 | if (!name) { | |
31994 | JS_ClearPendingException(cx); | |
31995 | return (JSIntn)0; | |
31996 | } | |
31997 | } | |
31998 | ||
31999 | return IsXMLName(name->chars(), name->length()); | |
32000 | } | |
32001 | ||
32002 | ||
32003 | ||
32004 | ||
32005 | ||
32006 | static JSBool | |
32007 | NamespaceHelper(JSContext *cx, JSObject *obj, intN argc, jsval *argv, | |
32008 | jsval *rval) | |
32009 | { | |
32010 | jsval urival, prefixval; | |
32011 | JSObject *uriobj; | |
32012 | JSBool isNamespace, isQName; | |
32013 | Class *clasp; | |
32014 | JSLinearString *empty, *prefix, *uri; | |
32015 | ||
32016 | isNamespace = isQName = (JSIntn)0; | |
32017 | ||
32018 | uriobj = __null; | |
32019 | ||
32020 | if (argc <= 0) { | |
32021 | urival = ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0)); | |
32022 | } else { | |
32023 | urival = argv[argc > 1]; | |
32024 | if (!JSVAL_IS_PRIMITIVE(urival)) { | |
32025 | uriobj = JSVAL_TO_OBJECT(urival); | |
32026 | clasp = uriobj->getClass(); | |
32027 | isNamespace = (clasp == &js_NamespaceClass); | |
32028 | isQName = (clasp == &js_QNameClass); | |
32029 | } | |
32030 | } | |
32031 | ||
32032 | if (!obj) { | |
32033 | ||
32034 | if (argc == 1 && isNamespace) { | |
32035 | ||
32036 | *rval = urival; | |
32037 | return (JSIntn)1; | |
32038 | } | |
32039 | ||
32040 | obj = NewBuiltinClassInstanceXML(cx, &js_NamespaceClass); | |
32041 | if (!obj) | |
32042 | return (JSIntn)0; | |
32043 | } | |
32044 | *rval = OBJECT_TO_JSVAL(obj); | |
32045 | ; | |
32046 | ||
32047 | empty = cx->runtime->emptyString; | |
32048 | obj->setNamePrefix(empty); | |
32049 | obj->setNameURI(empty); | |
32050 | ||
32051 | if (argc == 1 || argc == -1) { | |
32052 | if (isNamespace) { | |
32053 | obj->setNameURI(uriobj->getNameURI()); | |
32054 | obj->setNamePrefix(uriobj->getNamePrefix()); | |
32055 | } else if (isQName && (uri = uriobj->getNameURI())) { | |
32056 | obj->setNameURI(uri); | |
32057 | obj->setNamePrefix(uriobj->getNamePrefix()); | |
32058 | } else { | |
32059 | JSString *str = js_ValueToString(cx, Valueify(urival)); | |
32060 | if (!str) | |
32061 | return (JSIntn)0; | |
32062 | uri = str->ensureLinear(cx); | |
32063 | if (!uri) | |
32064 | return (JSIntn)0; | |
32065 | obj->setNameURI(uri); | |
32066 | if (!uri->empty()) | |
32067 | obj->clearNamePrefix(); | |
32068 | } | |
32069 | } else if (argc == 2) { | |
32070 | if (!isQName || !(uri = uriobj->getNameURI())) { | |
32071 | JSString *str = js_ValueToString(cx, Valueify(urival)); | |
32072 | if (!str) | |
32073 | return (JSIntn)0; | |
32074 | uri = str->ensureLinear(cx); | |
32075 | if (!uri) | |
32076 | return (JSIntn)0; | |
32077 | } | |
32078 | obj->setNameURI(uri); | |
32079 | ||
32080 | prefixval = argv[0]; | |
32081 | if (uri->empty()) { | |
32082 | if (!JSVAL_IS_VOID(prefixval)) { | |
32083 | JSString *str = js_ValueToString(cx, Valueify(prefixval)); | |
32084 | if (!str) | |
32085 | return (JSIntn)0; | |
32086 | if (!str->empty()) { | |
32087 | JSAutoByteString bytes; | |
32088 | if (js_ValueToPrintable(cx, StringValue(str), &bytes)) { | |
32089 | JS_ReportErrorNumber(cx, js_GetErrorMessage, __null, | |
32090 | JSMSG_BAD_XML_NAMESPACE, bytes.ptr()); | |
32091 | } | |
32092 | return (JSIntn)0; | |
32093 | } | |
32094 | } | |
32095 | } else if (JSVAL_IS_VOID(prefixval) || !js_IsXMLName(cx, prefixval)) { | |
32096 | obj->clearNamePrefix(); | |
32097 | } else { | |
32098 | JSString *str = js_ValueToString(cx, Valueify(prefixval)); | |
32099 | if (!str) | |
32100 | return (JSIntn)0; | |
32101 | prefix = str->ensureLinear(cx); | |
32102 | if (!prefix) | |
32103 | return (JSIntn)0; | |
32104 | obj->setNamePrefix(prefix); | |
32105 | } | |
32106 | } | |
32107 | return (JSIntn)1; | |
32108 | } | |
32109 | ||
32110 | static JSBool | |
32111 | Namespace(JSContext *cx, uintN argc, Value *vp) | |
32112 | { | |
32113 | JSObject *thisobj = __null; | |
32114 | (void)IsConstructing_PossiblyWithGivenThisObject(vp, &thisobj); | |
32115 | return NamespaceHelper(cx, thisobj, argc, Jsvalify(vp + 2), Jsvalify(vp)); | |
32116 | } | |
32117 | ||
32118 | ||
32119 | ||
32120 | ||
32121 | ||
32122 | static JSBool | |
32123 | QNameHelper(JSContext *cx, JSObject *obj, intN argc, jsval *argv, jsval *rval) | |
32124 | { | |
32125 | jsval nameval, nsval; | |
32126 | JSBool isQName, isNamespace; | |
32127 | JSObject *qn; | |
32128 | JSLinearString *uri, *prefix, *name; | |
32129 | JSObject *obj2; | |
32130 | ||
32131 | if (argc <= 0) { | |
32132 | nameval = ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0)); | |
32133 | isQName = (JSIntn)0; | |
32134 | } else { | |
32135 | nameval = argv[argc > 1]; | |
32136 | isQName = | |
32137 | !JSVAL_IS_PRIMITIVE(nameval) && | |
32138 | JSVAL_TO_OBJECT(nameval)->getClass() == &js_QNameClass; | |
32139 | } | |
32140 | ||
32141 | if (!obj) { | |
32142 | ||
32143 | if (argc == 1 && isQName) { | |
32144 | ||
32145 | *rval = nameval; | |
32146 | return (JSIntn)1; | |
32147 | } | |
32148 | ||
32149 | ||
32150 | obj = NewBuiltinClassInstanceXML(cx, &js_QNameClass); | |
32151 | if (!obj) | |
32152 | return (JSIntn)0; | |
32153 | } | |
32154 | *rval = OBJECT_TO_JSVAL(obj); | |
32155 | ; | |
32156 | ||
32157 | if (isQName) { | |
32158 | ||
32159 | qn = JSVAL_TO_OBJECT(nameval); | |
32160 | if (argc == 1) { | |
32161 | uri = qn->getNameURI(); | |
32162 | prefix = qn->getNamePrefix(); | |
32163 | name = qn->getQNameLocalName(); | |
32164 | goto out; | |
32165 | } | |
32166 | ||
32167 | ||
32168 | nameval = qn->getQNameLocalNameVal(); | |
32169 | } | |
32170 | ||
32171 | if (argc == 0) { | |
32172 | name = cx->runtime->emptyString; | |
32173 | } else if (argc < 0) { | |
32174 | name = (cx->runtime->atomState.typeAtoms[JSTYPE_VOID]); | |
32175 | } else { | |
32176 | JSString *str = js_ValueToString(cx, Valueify(nameval)); | |
32177 | if (!str) | |
32178 | return (JSIntn)0; | |
32179 | name = str->ensureLinear(cx); | |
32180 | if (!name) | |
32181 | return (JSIntn)0; | |
32182 | argv[argc > 1] = STRING_TO_JSVAL(name); | |
32183 | } | |
32184 | ||
32185 | if (argc > 1 && !JSVAL_IS_VOID(argv[0])) { | |
32186 | nsval = argv[0]; | |
32187 | } else if (((name)->length() == 1 && *(name)->chars() == '*')) { | |
32188 | nsval = ((((uint64)(uint32)(JSVAL_TAG_NULL)) << 47) | (0)); | |
32189 | } else { | |
32190 | if (!js_GetDefaultXMLNamespace(cx, &nsval)) | |
32191 | return (JSIntn)0; | |
32192 | ((void) 0); | |
32193 | ((void) 0) | |
32194 | ; | |
32195 | } | |
32196 | ||
32197 | if (JSVAL_IS_NULL(nsval)) { | |
32198 | ||
32199 | prefix = uri = __null; | |
32200 | } else { | |
32201 | ||
32202 | ||
32203 | ||
32204 | ||
32205 | ||
32206 | ||
32207 | ||
32208 | isNamespace = isQName = (JSIntn)0; | |
32209 | if (!JSVAL_IS_PRIMITIVE(nsval)) { | |
32210 | obj2 = JSVAL_TO_OBJECT(nsval); | |
32211 | isNamespace = (obj2->getClass() == &js_NamespaceClass); | |
32212 | isQName = (obj2->getClass() == &js_QNameClass); | |
32213 | } | |
32214 | ||
32215 | else obj2 = __null; | |
32216 | ||
32217 | ||
32218 | if (isNamespace) { | |
32219 | uri = obj2->getNameURI(); | |
32220 | prefix = obj2->getNamePrefix(); | |
32221 | } else if (isQName && (uri = obj2->getNameURI())) { | |
32222 | ((void) 0); | |
32223 | prefix = obj2->getNamePrefix(); | |
32224 | } else { | |
32225 | ((void) 0); | |
32226 | JSString *str = js_ValueToString(cx, Valueify(nsval)); | |
32227 | if (!str) | |
32228 | return (JSIntn)0; | |
32229 | uri = str->ensureLinear(cx); | |
32230 | if (!uri) | |
32231 | return (JSIntn)0; | |
32232 | argv[0] = STRING_TO_JSVAL(uri); | |
32233 | ||
32234 | ||
32235 | prefix = uri->empty() ? cx->runtime->emptyString : __null; | |
32236 | } | |
32237 | } | |
32238 | ||
32239 | out: | |
32240 | InitXMLQName(obj, uri, prefix, name); | |
32241 | return (JSIntn)1; | |
32242 | } | |
32243 | ||
32244 | static JSBool | |
32245 | QName(JSContext *cx, uintN argc, Value *vp) | |
32246 | { | |
32247 | JSObject *thisobj = __null; | |
32248 | (void)IsConstructing_PossiblyWithGivenThisObject(vp, &thisobj); | |
32249 | return QNameHelper(cx, thisobj, argc, Jsvalify(vp + 2), Jsvalify(vp)); | |
32250 | } | |
32251 | ||
32252 | ||
32253 | ||
32254 | ||
32255 | static JSBool | |
32256 | namespace_identity(const void *a, const void *b) | |
32257 | { | |
32258 | const JSObject *nsa = (const JSObject *) a; | |
32259 | const JSObject *nsb = (const JSObject *) b; | |
32260 | JSLinearString *prefixa = nsa->getNamePrefix(); | |
32261 | JSLinearString *prefixb = nsb->getNamePrefix(); | |
32262 | ||
32263 | if (prefixa && prefixb) { | |
32264 | if (!EqualStrings(prefixa, prefixb)) | |
32265 | return (JSIntn)0; | |
32266 | } else { | |
32267 | if (prefixa || prefixb) | |
32268 | return (JSIntn)0; | |
32269 | } | |
32270 | return EqualStrings(nsa->getNameURI(), nsb->getNameURI()); | |
32271 | } | |
32272 | ||
32273 | static JSBool | |
32274 | attr_identity(const void *a, const void *b) | |
32275 | { | |
32276 | const JSXML *xmla = (const JSXML *) a; | |
32277 | const JSXML *xmlb = (const JSXML *) b; | |
32278 | ||
32279 | return qname_identity(xmla->name, xmlb->name); | |
32280 | } | |
32281 | ||
32282 | void | |
32283 | JSXMLArrayCursor::trace(JSTracer *trc) { | |
32284 | ||
32285 | ||
32286 | ||
32287 | for (JSXMLArrayCursor *cursor = this; cursor; cursor = cursor->next) | |
32288 | js::gc::MarkGCThing(trc, cursor->root, "cursor_root", index++); | |
32289 | } | |
32290 | ||
32291 | static void | |
32292 | XMLArrayCursorTrace(JSTracer *trc, JSXMLArrayCursor *cursor) | |
32293 | { | |
32294 | cursor->trace(trc); | |
32295 | } | |
32296 | ||
32297 | ||
32298 | ||
32299 | bool | |
32300 | # 886 "jsxml.cpp" | |
32301 | JSXMLArray::setCapacity(JSContext *cx, uint32 newCapacity) | |
32302 | { | |
32303 | if (newCapacity == 0) { | |
32304 | ||
32305 | if (vector) { | |
32306 | if (cx) | |
32307 | cx->free(vector); | |
32308 | else | |
32309 | js_free(vector); | |
32310 | } | |
32311 | vector = __null; | |
32312 | } else { | |
32313 | void **tmp; | |
32314 | ||
32315 | if ( | |
32316 | ||
32317 | ||
32318 | ||
32319 | !(tmp = (void **) js_realloc(vector, newCapacity * sizeof(void *)))) { | |
32320 | if (cx) | |
32321 | JS_ReportOutOfMemory(cx); | |
32322 | return false; | |
32323 | } | |
32324 | vector = tmp; | |
32325 | } | |
32326 | capacity = ((JSUint32)1 << (31)) | newCapacity; | |
32327 | return true; | |
32328 | } | |
32329 | ||
32330 | void | |
32331 | JSXMLArray::trim() | |
32332 | { | |
32333 | if (capacity & ((JSUint32)1 << (31))) | |
32334 | return; | |
32335 | if (length < capacity) | |
32336 | setCapacity(__null, length); | |
32337 | } | |
32338 | ||
32339 | void | |
32340 | JSXMLArray::finish(JSContext *cx) | |
32341 | { | |
32342 | cx->free(vector); | |
32343 | ||
32344 | while (JSXMLArrayCursor *cursor = cursors) | |
32345 | cursor->disconnect(); | |
32346 | ||
32347 | ||
32348 | ||
32349 | ||
32350 | } | |
32351 | ||
32352 | ||
32353 | ||
32354 | static uint32 | |
32355 | XMLArrayFindMember(const JSXMLArray *array, void *elt, JSIdentityOp identity) | |
32356 | { | |
32357 | void **vector; | |
32358 | uint32 i, n; | |
32359 | ||
32360 | ||
32361 | vector = array->vector; | |
32362 | if (identity) { | |
32363 | for (i = 0, n = array->length; i < n; i++) { | |
32364 | if (identity(vector[i], elt)) | |
32365 | return i; | |
32366 | } | |
32367 | } else { | |
32368 | for (i = 0, n = array->length; i < n; i++) { | |
32369 | if (vector[i] == elt) | |
32370 | return i; | |
32371 | } | |
32372 | } | |
32373 | return ((uint32) -1); | |
32374 | } | |
32375 | # 969 "jsxml.cpp" | |
32376 | static JSBool | |
32377 | XMLArrayAddMember(JSContext *cx, JSXMLArray *array, uint32 index, void *elt) | |
32378 | { | |
32379 | uint32 capacity, i; | |
32380 | int log2; | |
32381 | void **vector; | |
32382 | ||
32383 | if (index >= array->length) { | |
32384 | if (index >= ((array)->capacity & (((JSUint32)1 << (31)) - 1))) { | |
32385 | ||
32386 | capacity = index + 1; | |
32387 | if (index >= 256) { | |
32388 | capacity = ((((capacity)+(32)-1)/(32))*(32)); | |
32389 | } else { | |
32390 | do { unsigned int j_ = (unsigned int)(capacity); (log2) = (j_ <= 1 ? 0 : 32 - __builtin_clz(j_ - 1)); } while (0); | |
32391 | capacity = ((JSUint32)1 << (log2)); | |
32392 | } | |
32393 | if ( | |
32394 | ||
32395 | ||
32396 | ||
32397 | !(vector = (void **) | |
32398 | js_realloc(array->vector, capacity * sizeof(void *)))) { | |
32399 | JS_ReportOutOfMemory(cx); | |
32400 | return (JSIntn)0; | |
32401 | } | |
32402 | array->capacity = capacity; | |
32403 | array->vector = vector; | |
32404 | for (i = array->length; i < index; i++) | |
32405 | vector[i] = __null; | |
32406 | } | |
32407 | array->length = index + 1; | |
32408 | } | |
32409 | ||
32410 | array->vector[index] = elt; | |
32411 | return (JSIntn)1; | |
32412 | } | |
32413 | ||
32414 | static JSBool | |
32415 | XMLArrayInsert(JSContext *cx, JSXMLArray *array, uint32 i, uint32 n) | |
32416 | { | |
32417 | uint32 j; | |
32418 | JSXMLArrayCursor *cursor; | |
32419 | ||
32420 | j = array->length; | |
32421 | ((void) 0); | |
32422 | if (!array->setCapacity(cx, j + n)) | |
32423 | return (JSIntn)0; | |
32424 | ||
32425 | array->length = j + n; | |
32426 | ((void) 0); | |
32427 | while (j != i) { | |
32428 | --j; | |
32429 | array->vector[j + n] = array->vector[j]; | |
32430 | } | |
32431 | ||
32432 | for (cursor = array->cursors; cursor; cursor = cursor->next) { | |
32433 | if (cursor->index > i) | |
32434 | cursor->index += n; | |
32435 | } | |
32436 | return (JSIntn)1; | |
32437 | } | |
32438 | ||
32439 | static void * | |
32440 | XMLArrayDelete(JSContext *cx, JSXMLArray *array, uint32 index, JSBool compress) | |
32441 | { | |
32442 | uint32 length; | |
32443 | void **vector, *elt; | |
32444 | JSXMLArrayCursor *cursor; | |
32445 | ||
32446 | length = array->length; | |
32447 | if (index >= length) | |
32448 | return __null; | |
32449 | ||
32450 | vector = array->vector; | |
32451 | elt = vector[index]; | |
32452 | if (compress) { | |
32453 | while (++index < length) | |
32454 | vector[index-1] = vector[index]; | |
32455 | array->length = length - 1; | |
32456 | array->capacity = ((array)->capacity & (((JSUint32)1 << (31)) - 1)); | |
32457 | } else { | |
32458 | vector[index] = __null; | |
32459 | } | |
32460 | ||
32461 | for (cursor = array->cursors; cursor; cursor = cursor->next) { | |
32462 | if (cursor->index > index) | |
32463 | --cursor->index; | |
32464 | } | |
32465 | return elt; | |
32466 | } | |
32467 | ||
32468 | static void | |
32469 | XMLArrayTruncate(JSContext *cx, JSXMLArray *array, uint32 length) | |
32470 | { | |
32471 | void **vector; | |
32472 | ||
32473 | ((void) 0); | |
32474 | if (length >= array->length) | |
32475 | return; | |
32476 | ||
32477 | if (length == 0) { | |
32478 | if (array->vector) | |
32479 | cx->free(array->vector); | |
32480 | vector = __null; | |
32481 | } else { | |
32482 | vector = (void **) js_realloc(array->vector, length * sizeof(void *)); | |
32483 | if (!vector) | |
32484 | return; | |
32485 | } | |
32486 | ||
32487 | if (array->length > length) | |
32488 | array->length = length; | |
32489 | array->capacity = length; | |
32490 | array->vector = vector; | |
32491 | } | |
32492 | # 1107 "jsxml.cpp" | |
32493 | static const char js_ignoreComments_str[] = "ignoreComments"; | |
32494 | static const char js_ignoreProcessingInstructions_str[] | |
32495 | = "ignoreProcessingInstructions"; | |
32496 | static const char js_ignoreWhitespace_str[] = "ignoreWhitespace"; | |
32497 | static const char js_prettyPrinting_str[] = "prettyPrinting"; | |
32498 | static const char js_prettyIndent_str[] = "prettyIndent"; | |
32499 | ||
32500 | ||
32501 | ||
32502 | ||
32503 | ||
32504 | ||
32505 | static JSPropertySpec xml_static_props[] = { | |
32506 | {js_ignoreComments_str, 0, 0x04, __null, __null}, | |
32507 | {js_ignoreProcessingInstructions_str, 0, 0x04, __null, __null}, | |
32508 | {js_ignoreWhitespace_str, 0, 0x04, __null, __null}, | |
32509 | {js_prettyPrinting_str, 0, 0x04, __null, __null}, | |
32510 | {js_prettyIndent_str, 0, 0x04, __null, __null}, | |
32511 | {0,0,0,0,0} | |
32512 | }; | |
32513 | # 1150 "jsxml.cpp" | |
32514 | static const char xml_namespace_str[] = "http://www.w3.org/XML/1998/namespace"; | |
32515 | static const char xmlns_namespace_str[] = "http://www.w3.org/2000/xmlns/"; | |
32516 | ||
32517 | static JSObject * | |
32518 | ParseNodeToQName(Parser *parser, JSParseNode *pn, | |
32519 | JSXMLArray *inScopeNSes, JSBool isAttributeName) | |
32520 | { | |
32521 | JSContext *cx = parser->context; | |
32522 | JSLinearString *str, *uri, *prefix, *localName; | |
32523 | size_t length, offset; | |
32524 | const jschar *start, *limit, *colon; | |
32525 | uint32 n; | |
32526 | JSObject *ns; | |
32527 | JSLinearString *nsprefix; | |
32528 | ||
32529 | ((void) 0); | |
32530 | str = pn->pn_u.name.atom; | |
32531 | start = str->chars(); | |
32532 | length = str->length(); | |
32533 | ((void) 0); | |
32534 | ((void) 0); | |
32535 | ||
32536 | uri = cx->runtime->emptyString; | |
32537 | limit = start + length; | |
32538 | colon = js_strchr_limit(start, ':', limit); | |
32539 | if (colon) { | |
32540 | offset = colon - start; | |
32541 | prefix = js_NewDependentString(cx, str, 0, offset); | |
32542 | if (!prefix) | |
32543 | return __null; | |
32544 | ||
32545 | if ((offset >= 3 && (((jschar) (((js_A[js_Y[(js_X[(uint16)((start)[0])>>6]<<6)|(((start)[0])&0x3F)]]) & 0x00200000) ? ((start)[0]) + ((int32)(js_A[js_Y[(js_X[(uint16)((start)[0])>>6]<<6)|(((start)[0])&0x3F)]]) >> 22) : ((start)[0]))) == 'x' && ((jschar) (((js_A[js_Y[(js_X[(uint16)((start)[1])>>6]<<6)|(((start)[1])&0x3F)]]) & 0x00200000) ? ((start)[1]) + ((int32)(js_A[js_Y[(js_X[(uint16)((start)[1])>>6]<<6)|(((start)[1])&0x3F)]]) >> 22) : ((start)[1]))) == 'm' && ((jschar) (((js_A[js_Y[(js_X[(uint16)((start)[2])>>6]<<6)|(((start)[2])&0x3F)]]) & 0x00200000) ? ((start)[2]) + ((int32)(js_A[js_Y[(js_X[(uint16)((start)[2])>>6]<<6)|(((start)[2])&0x3F)]]) >> 22) : ((start)[2]))) == 'l'))) { | |
32546 | if (offset == 3) { | |
32547 | uri = JS_ASSERT_STRING_IS_FLAT(JS_InternString(cx, xml_namespace_str)); | |
32548 | if (!uri) | |
32549 | return __null; | |
32550 | } else if (offset == 5 && (((jschar) (((js_A[js_Y[(js_X[(uint16)((start)[3])>>6]<<6)|(((start)[3])&0x3F)]]) & 0x00200000) ? ((start)[3]) + ((int32)(js_A[js_Y[(js_X[(uint16)((start)[3])>>6]<<6)|(((start)[3])&0x3F)]]) >> 22) : ((start)[3]))) == 'n' && ((jschar) (((js_A[js_Y[(js_X[(uint16)((start)[4])>>6]<<6)|(((start)[4])&0x3F)]]) & 0x00200000) ? ((start)[4]) + ((int32)(js_A[js_Y[(js_X[(uint16)((start)[4])>>6]<<6)|(((start)[4])&0x3F)]]) >> 22) : ((start)[4]))) == 's')) { | |
32551 | uri = JS_ASSERT_STRING_IS_FLAT(JS_InternString(cx, xmlns_namespace_str)); | |
32552 | if (!uri) | |
32553 | return __null; | |
32554 | } else { | |
32555 | uri = __null; | |
32556 | } | |
32557 | } else { | |
32558 | uri = __null; | |
32559 | n = inScopeNSes->length; | |
32560 | while (n != 0) { | |
32561 | --n; | |
32562 | ns = (((n) < (inScopeNSes)->length) ? (JSObject *) (inScopeNSes)->vector[n] : __null); | |
32563 | nsprefix = ns->getNamePrefix(); | |
32564 | if (nsprefix && EqualStrings(nsprefix, prefix)) { | |
32565 | uri = ns->getNameURI(); | |
32566 | break; | |
32567 | } | |
32568 | } | |
32569 | } | |
32570 | ||
32571 | if (!uri) { | |
32572 | Value v = StringValue(prefix); | |
32573 | JSAutoByteString bytes; | |
32574 | if (js_ValueToPrintable(parser->context, v, &bytes)) { | |
32575 | ReportCompileErrorNumber(parser->context, &parser->tokenStream, pn, | |
32576 | 0x0, JSMSG_BAD_XML_NAMESPACE, bytes.ptr()); | |
32577 | } | |
32578 | return __null; | |
32579 | } | |
32580 | ||
32581 | localName = js_NewStringCopyN(parser->context, colon + 1, length - (offset + 1)); | |
32582 | if (!localName) | |
32583 | return __null; | |
32584 | } else { | |
32585 | if (isAttributeName) { | |
32586 | ||
32587 | ||
32588 | ||
32589 | ||
32590 | prefix = uri; | |
32591 | } else { | |
32592 | ||
32593 | ||
32594 | ||
32595 | ||
32596 | n = inScopeNSes->length; | |
32597 | while (n != 0) { | |
32598 | --n; | |
32599 | ns = (((n) < (inScopeNSes)->length) ? (JSObject *) (inScopeNSes)->vector[n] : __null); | |
32600 | nsprefix = ns->getNamePrefix(); | |
32601 | if (!nsprefix || nsprefix->empty()) { | |
32602 | uri = ns->getNameURI(); | |
32603 | break; | |
32604 | } | |
32605 | } | |
32606 | prefix = uri->empty() ? parser->context->runtime->emptyString : __null; | |
32607 | } | |
32608 | localName = str; | |
32609 | } | |
32610 | ||
32611 | return NewXMLQName(parser->context, uri, prefix, localName); | |
32612 | } | |
32613 | ||
32614 | static JSString * | |
32615 | ChompXMLWhitespace(JSContext *cx, JSString *str) | |
32616 | { | |
32617 | size_t length, newlength, offset; | |
32618 | const jschar *cp, *start, *end; | |
32619 | jschar c; | |
32620 | ||
32621 | length = str->length(); | |
32622 | start = str->getChars(cx); | |
32623 | if (!start) | |
32624 | return __null; | |
32625 | ||
32626 | for (cp = start, end = cp + length; cp < end; cp++) { | |
32627 | c = *cp; | |
32628 | if (!((c) == ' ' || (c) == '\t' || (c) == '\r' || (c) == '\n')) | |
32629 | break; | |
32630 | } | |
32631 | while (end > cp) { | |
32632 | c = end[-1]; | |
32633 | if (!((c) == ' ' || (c) == '\t' || (c) == '\r' || (c) == '\n')) | |
32634 | break; | |
32635 | --end; | |
32636 | } | |
32637 | newlength = end - cp; | |
32638 | if (newlength == length) | |
32639 | return str; | |
32640 | offset = cp - start; | |
32641 | return js_NewDependentString(cx, str, offset, newlength); | |
32642 | } | |
32643 | ||
32644 | static JSXML * | |
32645 | ParseNodeToXML(Parser *parser, JSParseNode *pn, | |
32646 | JSXMLArray *inScopeNSes, uintN flags) | |
32647 | { | |
32648 | JSContext *cx = parser->context; | |
32649 | JSXML *xml, *kid, *attr, *attrj; | |
32650 | JSLinearString *str; | |
32651 | uint32 length, n, i, j; | |
32652 | JSParseNode *pn2, *pn3, *head, **pnp; | |
32653 | JSObject *ns; | |
32654 | JSObject *qn, *attrjqn; | |
32655 | JSXMLClass xml_class; | |
32656 | int stackDummy; | |
32657 | ||
32658 | if (!((jsuword)(&stackDummy) > cx->stackLimit)) { | |
32659 | ReportCompileErrorNumber(cx, &parser->tokenStream, pn, 0x0, | |
32660 | JSMSG_OVER_RECURSED); | |
32661 | return __null; | |
32662 | } | |
32663 | # 1307 "jsxml.cpp" | |
32664 | xml = __null; | |
32665 | if (!js_EnterLocalRootScope(cx)) | |
32666 | return __null; | |
32667 | switch (pn->pn_type) { | |
32668 | case TOK_XMLELEM: | |
32669 | length = inScopeNSes->length; | |
32670 | pn2 = pn->pn_u.list.head; | |
32671 | xml = ParseNodeToXML(parser, pn2, inScopeNSes, flags); | |
32672 | if (!xml) | |
32673 | goto fail; | |
32674 | ||
32675 | n = pn->pn_u.list.count; | |
32676 | ((void) 0); | |
32677 | n -= 2; | |
32678 | if (!xml->u.list.kids.setCapacity(cx, n)) | |
32679 | goto fail; | |
32680 | ||
32681 | i = 0; | |
32682 | while ((pn2 = pn2->pn_next) != __null) { | |
32683 | if (!pn2->pn_next) { | |
32684 | ||
32685 | ((void) 0); | |
32686 | break; | |
32687 | } | |
32688 | ||
32689 | if ((flags & ((JSUint32)1 << (2))) && | |
32690 | n > 1 && pn2->pn_type == TOK_XMLSPACE) { | |
32691 | --n; | |
32692 | continue; | |
32693 | } | |
32694 | ||
32695 | kid = ParseNodeToXML(parser, pn2, inScopeNSes, flags); | |
32696 | if (kid == ((JSXML *) 1)) { | |
32697 | --n; | |
32698 | continue; | |
32699 | } | |
32700 | ||
32701 | if (!kid) | |
32702 | goto fail; | |
32703 | ||
32704 | ||
32705 | do { if ((&xml->u.list.kids)->length <= (i)) (&xml->u.list.kids)->length = (i) + 1; ((&xml->u.list.kids)->vector[i] = (void *)(kid)); } while (0); | |
32706 | kid->parent = xml; | |
32707 | ++i; | |
32708 | ||
32709 | ||
32710 | if ((flags & ((JSUint32)1 << (2))) && | |
32711 | n > 1 && kid->xml_class == JSXML_CLASS_TEXT) { | |
32712 | JSString *str = ChompXMLWhitespace(cx, kid->u.value); | |
32713 | if (!str) | |
32714 | goto fail; | |
32715 | kid->u.value = str; | |
32716 | } | |
32717 | } | |
32718 | ||
32719 | ((void) 0); | |
32720 | if (n < pn->pn_u.list.count - 2) | |
32721 | xml->u.list.kids.trim(); | |
32722 | XMLArrayTruncate(cx, inScopeNSes, length); | |
32723 | break; | |
32724 | ||
32725 | case TOK_XMLLIST: | |
32726 | xml = js_NewXML(cx, JSXML_CLASS_LIST); | |
32727 | if (!xml) | |
32728 | goto fail; | |
32729 | ||
32730 | n = pn->pn_u.list.count; | |
32731 | if (!xml->u.list.kids.setCapacity(cx, n)) | |
32732 | goto fail; | |
32733 | ||
32734 | i = 0; | |
32735 | for (pn2 = pn->pn_u.list.head; pn2; pn2 = pn2->pn_next) { | |
32736 | ||
32737 | ||
32738 | ||
32739 | ||
32740 | ||
32741 | if (pn2->pn_type == TOK_XMLSPACE) { | |
32742 | --n; | |
32743 | continue; | |
32744 | } | |
32745 | ||
32746 | kid = ParseNodeToXML(parser, pn2, inScopeNSes, flags); | |
32747 | if (kid == ((JSXML *) 1)) { | |
32748 | --n; | |
32749 | continue; | |
32750 | } | |
32751 | ||
32752 | if (!kid) | |
32753 | goto fail; | |
32754 | ||
32755 | do { if ((&xml->u.list.kids)->length <= (i)) (&xml->u.list.kids)->length = (i) + 1; ((&xml->u.list.kids)->vector[i] = (void *)(kid)); } while (0); | |
32756 | ++i; | |
32757 | } | |
32758 | ||
32759 | if (n < pn->pn_u.list.count) | |
32760 | xml->u.list.kids.trim(); | |
32761 | break; | |
32762 | ||
32763 | case TOK_XMLSTAGO: | |
32764 | case TOK_XMLPTAGC: | |
32765 | length = inScopeNSes->length; | |
32766 | pn2 = pn->pn_u.list.head; | |
32767 | ((void) 0); | |
32768 | if (pn2->pn_arity == PN_LIST) | |
32769 | goto syntax; | |
32770 | ||
32771 | xml = js_NewXML(cx, JSXML_CLASS_ELEMENT); | |
32772 | if (!xml) | |
32773 | goto fail; | |
32774 | ||
32775 | ||
32776 | ((void) 0); | |
32777 | n = pn->pn_u.list.count - 1; | |
32778 | pnp = &pn2->pn_next; | |
32779 | head = *pnp; | |
32780 | while ((pn2 = *pnp) != __null) { | |
32781 | size_t length; | |
32782 | const jschar *chars; | |
32783 | ||
32784 | if (pn2->pn_type != TOK_XMLNAME || pn2->pn_arity != PN_NULLARY) | |
32785 | goto syntax; | |
32786 | ||
32787 | ||
32788 | for (pn3 = head; pn3 != pn2; pn3 = pn3->pn_next->pn_next) { | |
32789 | if (pn3->pn_u.name.atom == pn2->pn_u.name.atom) { | |
32790 | Value v = StringValue((pn2->pn_u.name.atom)); | |
32791 | JSAutoByteString bytes; | |
32792 | if (js_ValueToPrintable(cx, v, &bytes)) { | |
32793 | ReportCompileErrorNumber(cx, &parser->tokenStream, pn2, | |
32794 | 0x0, JSMSG_DUPLICATE_XML_ATTR, | |
32795 | bytes.ptr()); | |
32796 | } | |
32797 | goto fail; | |
32798 | } | |
32799 | } | |
32800 | ||
32801 | JSAtom *atom = pn2->pn_u.name.atom; | |
32802 | pn2 = pn2->pn_next; | |
32803 | ((void) 0); | |
32804 | if (pn2->pn_type != TOK_XMLATTR) | |
32805 | goto syntax; | |
32806 | ||
32807 | chars = atom->chars(); | |
32808 | length = atom->length(); | |
32809 | if (length >= 5 && | |
32810 | ((((jschar) (((js_A[js_Y[(js_X[(uint16)((chars)[0])>>6]<<6)|(((chars)[0])&0x3F)]]) & 0x00200000) ? ((chars)[0]) + ((int32)(js_A[js_Y[(js_X[(uint16)((chars)[0])>>6]<<6)|(((chars)[0])&0x3F)]]) >> 22) : ((chars)[0]))) == 'x' && ((jschar) (((js_A[js_Y[(js_X[(uint16)((chars)[1])>>6]<<6)|(((chars)[1])&0x3F)]]) & 0x00200000) ? ((chars)[1]) + ((int32)(js_A[js_Y[(js_X[(uint16)((chars)[1])>>6]<<6)|(((chars)[1])&0x3F)]]) >> 22) : ((chars)[1]))) == 'm' && ((jschar) (((js_A[js_Y[(js_X[(uint16)((chars)[2])>>6]<<6)|(((chars)[2])&0x3F)]]) & 0x00200000) ? ((chars)[2]) + ((int32)(js_A[js_Y[(js_X[(uint16)((chars)[2])>>6]<<6)|(((chars)[2])&0x3F)]]) >> 22) : ((chars)[2]))) == 'l') && (((jschar) (((js_A[js_Y[(js_X[(uint16)((chars)[3])>>6]<<6)|(((chars)[3])&0x3F)]]) & 0x00200000) ? ((chars)[3]) + ((int32)(js_A[js_Y[(js_X[(uint16)((chars)[3])>>6]<<6)|(((chars)[3])&0x3F)]]) >> 22) : ((chars)[3]))) == 'n' && ((jschar) (((js_A[js_Y[(js_X[(uint16)((chars)[4])>>6]<<6)|(((chars)[4])&0x3F)]]) & 0x00200000) ? ((chars)[4]) + ((int32)(js_A[js_Y[(js_X[(uint16)((chars)[4])>>6]<<6)|(((chars)[4])&0x3F)]]) >> 22) : ((chars)[4]))) == 's')) && | |
32811 | (length == 5 || chars[5] == ':')) { | |
32812 | JSLinearString *uri, *prefix; | |
32813 | ||
32814 | uri = (pn2->pn_u.name.atom); | |
32815 | if (length == 5) { | |
32816 | ||
32817 | prefix = cx->runtime->emptyString; | |
32818 | } else { | |
32819 | prefix = js_NewStringCopyN(cx, chars + 6, length - 6); | |
32820 | if (!prefix) | |
32821 | goto fail; | |
32822 | } | |
32823 | ||
32824 | ||
32825 | ||
32826 | ||
32827 | ||
32828 | ||
32829 | ||
32830 | ns = NewXMLNamespace(cx, prefix, uri, (JSIntn)1); | |
32831 | if (!ns) | |
32832 | goto fail; | |
32833 | # 1484 "jsxml.cpp" | |
32834 | if (!(XMLArrayFindMember(inScopeNSes, (void *)(ns), namespace_identity) != ((uint32) -1))) { | |
32835 | if (!XMLArrayAddMember(cx, inScopeNSes, (inScopeNSes)->length, (void *)((ns))) || | |
32836 | !XMLArrayAddMember(cx, &xml->u.elem.namespaces, (&xml->u.elem.namespaces)->length, (void *)((ns)))) { | |
32837 | goto fail; | |
32838 | } | |
32839 | } | |
32840 | ||
32841 | ((void) 0); | |
32842 | n -= 2; | |
32843 | *pnp = pn2->pn_next; | |
32844 | ||
32845 | continue; | |
32846 | } | |
32847 | ||
32848 | pnp = &pn2->pn_next; | |
32849 | } | |
32850 | ||
32851 | xml->u.elem.namespaces.trim(); | |
32852 | ||
32853 | ||
32854 | pn2 = pn->pn_u.list.head; | |
32855 | qn = ParseNodeToQName(parser, pn2, inScopeNSes, (JSIntn)0); | |
32856 | if (!qn) | |
32857 | goto fail; | |
32858 | xml->name = qn; | |
32859 | ||
32860 | ((void) 0); | |
32861 | n >>= 1; | |
32862 | if (!xml->u.elem.attrs.setCapacity(cx, n)) | |
32863 | goto fail; | |
32864 | ||
32865 | for (i = 0; (pn2 = pn2->pn_next) != __null; i++) { | |
32866 | qn = ParseNodeToQName(parser, pn2, inScopeNSes, (JSIntn)1); | |
32867 | if (!qn) { | |
32868 | xml->u.elem.attrs.length = i; | |
32869 | goto fail; | |
32870 | } | |
32871 | ||
32872 | ||
32873 | ||
32874 | ||
32875 | ||
32876 | for (j = 0; j < i; j++) { | |
32877 | attrj = (((j) < (&xml->u.elem.attrs)->length) ? (JSXML *) (&xml->u.elem.attrs)->vector[j] : __null); | |
32878 | attrjqn = attrj->name; | |
32879 | if (EqualStrings(attrjqn->getNameURI(), qn->getNameURI()) && | |
32880 | EqualStrings(attrjqn->getQNameLocalName(), qn->getQNameLocalName())) { | |
32881 | Value v = StringValue((pn2->pn_u.name.atom)); | |
32882 | JSAutoByteString bytes; | |
32883 | if (js_ValueToPrintable(cx, v, &bytes)) { | |
32884 | ReportCompileErrorNumber(cx, &parser->tokenStream, pn2, | |
32885 | 0x0, JSMSG_DUPLICATE_XML_ATTR, | |
32886 | bytes.ptr()); | |
32887 | } | |
32888 | goto fail; | |
32889 | } | |
32890 | } | |
32891 | ||
32892 | pn2 = pn2->pn_next; | |
32893 | ((void) 0); | |
32894 | ((void) 0); | |
32895 | ||
32896 | attr = js_NewXML(cx, JSXML_CLASS_ATTRIBUTE); | |
32897 | if (!attr) | |
32898 | goto fail; | |
32899 | ||
32900 | do { if ((&xml->u.elem.attrs)->length <= (i)) (&xml->u.elem.attrs)->length = (i) + 1; ((&xml->u.elem.attrs)->vector[i] = (void *)(attr)); } while (0); | |
32901 | attr->parent = xml; | |
32902 | attr->name = qn; | |
32903 | attr->u.value = (pn2->pn_u.name.atom); | |
32904 | } | |
32905 | ||
32906 | ||
32907 | if (pn->pn_type == TOK_XMLPTAGC) | |
32908 | XMLArrayTruncate(cx, inScopeNSes, length); | |
32909 | break; | |
32910 | ||
32911 | case TOK_XMLSPACE: | |
32912 | case TOK_XMLTEXT: | |
32913 | case TOK_XMLCDATA: | |
32914 | case TOK_XMLCOMMENT: | |
32915 | case TOK_XMLPI: | |
32916 | str = (pn->pn_u.name.atom); | |
32917 | qn = __null; | |
32918 | if (pn->pn_type == TOK_XMLCOMMENT) { | |
32919 | if (flags & ((JSUint32)1 << (0))) | |
32920 | goto skip_child; | |
32921 | xml_class = JSXML_CLASS_COMMENT; | |
32922 | } else if (pn->pn_type == TOK_XMLPI) { | |
32923 | if ((str->length() == 3 && (((jschar) (((js_A[js_Y[(js_X[(uint16)((str->chars())[0])>>6]<<6)|(((str->chars())[0])&0x3F)]]) & 0x00200000) ? ((str->chars())[0]) + ((int32)(js_A[js_Y[(js_X[(uint16)((str->chars())[0])>>6]<<6)|(((str->chars())[0])&0x3F)]]) >> 22) : ((str->chars())[0]))) == 'x' && ((jschar) (((js_A[js_Y[(js_X[(uint16)((str->chars())[1])>>6]<<6)|(((str->chars())[1])&0x3F)]]) & 0x00200000) ? ((str->chars())[1]) + ((int32)(js_A[js_Y[(js_X[(uint16)((str->chars())[1])>>6]<<6)|(((str->chars())[1])&0x3F)]]) >> 22) : ((str->chars())[1]))) == 'm' && ((jschar) (((js_A[js_Y[(js_X[(uint16)((str->chars())[2])>>6]<<6)|(((str->chars())[2])&0x3F)]]) & 0x00200000) ? ((str->chars())[2]) + ((int32)(js_A[js_Y[(js_X[(uint16)((str->chars())[2])>>6]<<6)|(((str->chars())[2])&0x3F)]]) >> 22) : ((str->chars())[2]))) == 'l'))) { | |
32924 | Value v = StringValue(str); | |
32925 | JSAutoByteString bytes; | |
32926 | if (js_ValueToPrintable(cx, v, &bytes)) { | |
32927 | ReportCompileErrorNumber(cx, &parser->tokenStream, pn, | |
32928 | 0x0, JSMSG_RESERVED_ID, bytes.ptr()); | |
32929 | } | |
32930 | goto fail; | |
32931 | } | |
32932 | ||
32933 | if (flags & ((JSUint32)1 << (1))) | |
32934 | goto skip_child; | |
32935 | ||
32936 | qn = ParseNodeToQName(parser, pn, inScopeNSes, (JSIntn)0); | |
32937 | if (!qn) | |
32938 | goto fail; | |
32939 | ||
32940 | str = pn->pn_u.apair.atom2 | |
32941 | ? (pn->pn_u.apair.atom2) | |
32942 | : cx->runtime->emptyString; | |
32943 | xml_class = JSXML_CLASS_PROCESSING_INSTRUCTION; | |
32944 | } else { | |
32945 | ||
32946 | xml_class = JSXML_CLASS_TEXT; | |
32947 | } | |
32948 | ||
32949 | xml = js_NewXML(cx, xml_class); | |
32950 | if (!xml) | |
32951 | goto fail; | |
32952 | xml->name = qn; | |
32953 | if (pn->pn_type == TOK_XMLSPACE) | |
32954 | xml->xml_flags |= 0x1; | |
32955 | xml->u.value = str; | |
32956 | break; | |
32957 | ||
32958 | default: | |
32959 | goto syntax; | |
32960 | } | |
32961 | ||
32962 | js_LeaveLocalRootScopeWithResult(cx, xml); | |
32963 | return xml; | |
32964 | ||
32965 | skip_child: | |
32966 | js_LeaveLocalRootScope(cx); | |
32967 | return ((JSXML *) 1); | |
32968 | ||
32969 | ||
32970 | ||
32971 | syntax: | |
32972 | ReportCompileErrorNumber(cx, &parser->tokenStream, pn, 0x0, JSMSG_BAD_XML_MARKUP); | |
32973 | fail: | |
32974 | js_LeaveLocalRootScope(cx); | |
32975 | return __null; | |
32976 | } | |
32977 | ||
32978 | ||
32979 | ||
32980 | ||
32981 | ||
32982 | static JSBool | |
32983 | GetXMLSetting(JSContext *cx, const char *name, jsval *vp) | |
32984 | { | |
32985 | jsval v; | |
32986 | ||
32987 | if (!js_FindClassObject(cx, __null, JSProto_XML, Valueify(&v))) | |
32988 | return (JSIntn)0; | |
32989 | if (!(!JSVAL_IS_PRIMITIVE(v) && JSVAL_TO_OBJECT(v)->isFunction())) { | |
32990 | *vp = ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0)); | |
32991 | return (JSIntn)1; | |
32992 | } | |
32993 | return JS_GetProperty(cx, JSVAL_TO_OBJECT(v), name, vp); | |
32994 | } | |
32995 | ||
32996 | static JSBool | |
32997 | GetBooleanXMLSetting(JSContext *cx, const char *name, JSBool *bp) | |
32998 | { | |
32999 | jsval v; | |
33000 | ||
33001 | return GetXMLSetting(cx, name, &v) && JS_ValueToBoolean(cx, v, bp); | |
33002 | } | |
33003 | ||
33004 | static JSBool | |
33005 | GetUint32XMLSetting(JSContext *cx, const char *name, uint32 *uip) | |
33006 | { | |
33007 | jsval v; | |
33008 | ||
33009 | return GetXMLSetting(cx, name, &v) && JS_ValueToECMAUint32(cx, v, uip); | |
33010 | } | |
33011 | ||
33012 | static JSBool | |
33013 | GetXMLSettingFlags(JSContext *cx, uintN *flagsp) | |
33014 | { | |
33015 | JSBool flag[4]; | |
33016 | ||
33017 | if (!GetBooleanXMLSetting(cx, js_ignoreComments_str, &flag[0]) || | |
33018 | !GetBooleanXMLSetting(cx, js_ignoreProcessingInstructions_str, &flag[1]) || | |
33019 | !GetBooleanXMLSetting(cx, js_ignoreWhitespace_str, &flag[2]) || | |
33020 | !GetBooleanXMLSetting(cx, js_prettyPrinting_str, &flag[3])) { | |
33021 | return false; | |
33022 | } | |
33023 | ||
33024 | *flagsp = 0; | |
33025 | for (size_t n = 0; n < 4; ++n) | |
33026 | if (flag[n]) | |
33027 | *flagsp |= ((JSUint32)1 << (n)); | |
33028 | return true; | |
33029 | } | |
33030 | ||
33031 | static JSXML * | |
33032 | ParseXMLSource(JSContext *cx, JSString *src) | |
33033 | { | |
33034 | jsval nsval; | |
33035 | JSLinearString *uri; | |
33036 | size_t urilen, srclen, length, offset, dstlen; | |
33037 | jschar *chars; | |
33038 | const jschar *srcp, *endp; | |
33039 | JSXML *xml; | |
33040 | const char *filename; | |
33041 | uintN lineno; | |
33042 | JSOp op; | |
33043 | ||
33044 | static const char prefix[] = "<parent xmlns=\""; | |
33045 | static const char middle[] = "\">"; | |
33046 | static const char suffix[] = "</parent>"; | |
33047 | ||
33048 | ||
33049 | ||
33050 | if (!js_GetDefaultXMLNamespace(cx, &nsval)) | |
33051 | return __null; | |
33052 | uri = JSVAL_TO_OBJECT(nsval)->getNameURI(); | |
33053 | uri = js_EscapeAttributeValue(cx, uri, (JSIntn)0); | |
33054 | if (!uri) | |
33055 | return __null; | |
33056 | ||
33057 | urilen = uri->length(); | |
33058 | srclen = src->length(); | |
33059 | length = (sizeof(prefix) - 1) + urilen + (sizeof(middle) - 1) + srclen + | |
33060 | (sizeof(suffix) - 1); | |
33061 | ||
33062 | chars = (jschar *) cx->malloc((length + 1) * sizeof(jschar)); | |
33063 | if (!chars) | |
33064 | return __null; | |
33065 | ||
33066 | dstlen = length; | |
33067 | js_InflateStringToBuffer(cx, prefix, (sizeof(prefix) - 1), chars, &dstlen); | |
33068 | offset = dstlen; | |
33069 | memcpy((chars + offset), (uri->chars()), (urilen) * sizeof(jschar)); | |
33070 | offset += urilen; | |
33071 | dstlen = length - offset + 1; | |
33072 | js_InflateStringToBuffer(cx, middle, (sizeof(middle) - 1), chars + offset, | |
33073 | &dstlen); | |
33074 | offset += dstlen; | |
33075 | srcp = src->getChars(cx); | |
33076 | if (!srcp) { | |
33077 | cx->free(chars); | |
33078 | return __null; | |
33079 | } | |
33080 | memcpy((chars + offset), (srcp), (srclen) * sizeof(jschar)); | |
33081 | offset += srclen; | |
33082 | dstlen = length - offset + 1; | |
33083 | js_InflateStringToBuffer(cx, suffix, (sizeof(suffix) - 1), chars + offset, | |
33084 | &dstlen); | |
33085 | chars [offset + dstlen] = 0; | |
33086 | ||
33087 | LeaveTrace(cx); | |
33088 | xml = __null; | |
33089 | FrameRegsIter i(cx); | |
33090 | for (; !i.done() && !i.pc(); ++i) | |
33091 | ((void) 0); | |
33092 | filename = __null; | |
33093 | lineno = 1; | |
33094 | if (!i.done()) { | |
33095 | JSStackFrame *fp = i.fp(); | |
33096 | op = (JSOp) *i.pc(); | |
33097 | if (op == JSOP_TOXML || op == JSOP_TOXMLLIST) { | |
33098 | filename = fp->script()->filename; | |
33099 | lineno = js_FramePCToLineNumber(cx, fp); | |
33100 | for (endp = srcp + srclen; srcp < endp; srcp++) { | |
33101 | if (*srcp == '\n') | |
33102 | --lineno; | |
33103 | } | |
33104 | } | |
33105 | } | |
33106 | ||
33107 | { | |
33108 | Parser parser(cx); | |
33109 | if (parser.init(chars, length, filename, lineno, cx->findVersion())) { | |
33110 | JSObject *scopeChain = GetScopeChain(cx); | |
33111 | if (!scopeChain) { | |
33112 | cx->free(chars); | |
33113 | return __null; | |
33114 | } | |
33115 | JSParseNode *pn = parser.parseXMLText(scopeChain, false); | |
33116 | uintN flags; | |
33117 | if (pn && GetXMLSettingFlags(cx, &flags)) { | |
33118 | AutoNamespaceArray namespaces(cx); | |
33119 | if (namespaces.array.setCapacity(cx, 1)) | |
33120 | xml = ParseNodeToXML(&parser, pn, &namespaces.array, flags); | |
33121 | } | |
33122 | } | |
33123 | } | |
33124 | ||
33125 | cx->free(chars); | |
33126 | return xml; | |
33127 | ||
33128 | ||
33129 | } | |
33130 | # 1800 "jsxml.cpp" | |
33131 | static JSXML * | |
33132 | OrphanXMLChild(JSContext *cx, JSXML *xml, uint32 i) | |
33133 | { | |
33134 | JSObject *ns; | |
33135 | ||
33136 | ns = (((0) < (&xml->u.elem.namespaces)->length) ? (JSObject *) (&xml->u.elem.namespaces)->vector[0] : __null); | |
33137 | xml = (((i) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[i] : __null); | |
33138 | if (!ns || !xml) | |
33139 | return xml; | |
33140 | if (xml->xml_class == JSXML_CLASS_ELEMENT) { | |
33141 | if (!XMLArrayAddMember(cx, &xml->u.elem.namespaces, (&xml->u.elem.namespaces)->length, (void *)((ns)))) | |
33142 | return __null; | |
33143 | ns->setNamespaceDeclared(((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0))); | |
33144 | } | |
33145 | xml->parent = __null; | |
33146 | return xml; | |
33147 | } | |
33148 | ||
33149 | static JSObject * | |
33150 | ToXML(JSContext *cx, jsval v) | |
33151 | { | |
33152 | JSObject *obj; | |
33153 | JSXML *xml; | |
33154 | Class *clasp; | |
33155 | JSString *str; | |
33156 | uint32 length; | |
33157 | ||
33158 | if (JSVAL_IS_PRIMITIVE(v)) { | |
33159 | if (JSVAL_IS_NULL(v) || JSVAL_IS_VOID(v)) | |
33160 | goto bad; | |
33161 | } else { | |
33162 | obj = JSVAL_TO_OBJECT(v); | |
33163 | if (obj->isXML()) { | |
33164 | xml = (JSXML *) obj->getPrivate(); | |
33165 | if (xml->xml_class == JSXML_CLASS_LIST) { | |
33166 | if (xml->u.list.kids.length != 1) | |
33167 | goto bad; | |
33168 | xml = (((0) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[0] : __null); | |
33169 | if (xml) { | |
33170 | ((void) 0); | |
33171 | return js_GetXMLObject(cx, xml); | |
33172 | } | |
33173 | } | |
33174 | return obj; | |
33175 | } | |
33176 | ||
33177 | clasp = obj->getClass(); | |
33178 | if (clasp->flags & (1<<7)) { | |
33179 | ((void) 0); | |
33180 | } | |
33181 | ||
33182 | if (clasp != &js_StringClass && | |
33183 | clasp != &js_NumberClass && | |
33184 | clasp != &js_BooleanClass) { | |
33185 | goto bad; | |
33186 | } | |
33187 | } | |
33188 | ||
33189 | str = js_ValueToString(cx, Valueify(v)); | |
33190 | if (!str) | |
33191 | return __null; | |
33192 | if (str->empty()) { | |
33193 | length = 0; | |
33194 | ||
33195 | xml = __null; | |
33196 | ||
33197 | } else { | |
33198 | xml = ParseXMLSource(cx, str); | |
33199 | if (!xml) | |
33200 | return __null; | |
33201 | length = ((((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (xml)->u.list.kids.length : 0); | |
33202 | } | |
33203 | ||
33204 | if (length == 0) { | |
33205 | obj = js_NewXMLObject(cx, JSXML_CLASS_TEXT); | |
33206 | if (!obj) | |
33207 | return __null; | |
33208 | } else if (length == 1) { | |
33209 | xml = OrphanXMLChild(cx, xml, 0); | |
33210 | if (!xml) | |
33211 | return __null; | |
33212 | obj = js_GetXMLObject(cx, xml); | |
33213 | if (!obj) | |
33214 | return __null; | |
33215 | } else { | |
33216 | JS_ReportErrorNumber(cx, js_GetErrorMessage, __null, JSMSG_SYNTAX_ERROR); | |
33217 | return __null; | |
33218 | } | |
33219 | return obj; | |
33220 | ||
33221 | bad: | |
33222 | ((void)js_ReportValueErrorFlags(cx, 0x0, JSMSG_BAD_XML_CONVERSION, 0, Valueify(v), __null, __null, __null)) | |
33223 | ; | |
33224 | return __null; | |
33225 | } | |
33226 | ||
33227 | static JSBool | |
33228 | Append(JSContext *cx, JSXML *list, JSXML *kid); | |
33229 | ||
33230 | static JSObject * | |
33231 | ToXMLList(JSContext *cx, jsval v) | |
33232 | { | |
33233 | JSObject *obj, *listobj; | |
33234 | JSXML *xml, *list, *kid; | |
33235 | Class *clasp; | |
33236 | JSString *str; | |
33237 | uint32 i, length; | |
33238 | ||
33239 | if (JSVAL_IS_PRIMITIVE(v)) { | |
33240 | if (JSVAL_IS_NULL(v) || JSVAL_IS_VOID(v)) | |
33241 | goto bad; | |
33242 | } else { | |
33243 | obj = JSVAL_TO_OBJECT(v); | |
33244 | if (obj->isXML()) { | |
33245 | xml = (JSXML *) obj->getPrivate(); | |
33246 | if (xml->xml_class != JSXML_CLASS_LIST) { | |
33247 | listobj = js_NewXMLObject(cx, JSXML_CLASS_LIST); | |
33248 | if (!listobj) | |
33249 | return __null; | |
33250 | list = (JSXML *) listobj->getPrivate(); | |
33251 | if (!Append(cx, list, xml)) | |
33252 | return __null; | |
33253 | return listobj; | |
33254 | } | |
33255 | return obj; | |
33256 | } | |
33257 | ||
33258 | clasp = obj->getClass(); | |
33259 | if (clasp->flags & (1<<7)) { | |
33260 | ((void) 0); | |
33261 | } | |
33262 | ||
33263 | if (clasp != &js_StringClass && | |
33264 | clasp != &js_NumberClass && | |
33265 | clasp != &js_BooleanClass) { | |
33266 | goto bad; | |
33267 | } | |
33268 | } | |
33269 | ||
33270 | str = js_ValueToString(cx, Valueify(v)); | |
33271 | if (!str) | |
33272 | return __null; | |
33273 | if (str->empty()) { | |
33274 | xml = __null; | |
33275 | length = 0; | |
33276 | } else { | |
33277 | if (!js_EnterLocalRootScope(cx)) | |
33278 | return __null; | |
33279 | xml = ParseXMLSource(cx, str); | |
33280 | if (!xml) { | |
33281 | js_LeaveLocalRootScope(cx); | |
33282 | return __null; | |
33283 | } | |
33284 | length = ((((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (xml)->u.list.kids.length : 0); | |
33285 | } | |
33286 | ||
33287 | listobj = js_NewXMLObject(cx, JSXML_CLASS_LIST); | |
33288 | if (listobj) { | |
33289 | list = (JSXML *) listobj->getPrivate(); | |
33290 | for (i = 0; i < length; i++) { | |
33291 | kid = OrphanXMLChild(cx, xml, i); | |
33292 | if (!kid || !Append(cx, list, kid)) { | |
33293 | listobj = __null; | |
33294 | break; | |
33295 | } | |
33296 | } | |
33297 | } | |
33298 | ||
33299 | if (xml) | |
33300 | js_LeaveLocalRootScopeWithResult(cx, listobj); | |
33301 | return listobj; | |
33302 | ||
33303 | bad: | |
33304 | ((void)js_ReportValueErrorFlags(cx, 0x0, JSMSG_BAD_XMLLIST_CONVERSION, 0, Valueify(v), __null, __null, __null)) | |
33305 | ; | |
33306 | return __null; | |
33307 | } | |
33308 | # 1986 "jsxml.cpp" | |
33309 | static JSFlatString * | |
33310 | MakeXMLSpecialString(JSContext *cx, StringBuffer &sb, | |
33311 | JSString *str, JSString *str2, | |
33312 | const jschar *prefix, size_t prefixlength, | |
33313 | const jschar *suffix, size_t suffixlength) | |
33314 | { | |
33315 | if (!sb.append(prefix, prefixlength) || !sb.append(str)) | |
33316 | return __null; | |
33317 | if (str2 && !str2->empty()) { | |
33318 | if (!sb.append(' ') || !sb.append(str2)) | |
33319 | return __null; | |
33320 | } | |
33321 | if (!sb.append(suffix, suffixlength)) | |
33322 | return __null; | |
33323 | ||
33324 | return sb.finishString(); | |
33325 | } | |
33326 | ||
33327 | static JSFlatString * | |
33328 | MakeXMLCDATAString(JSContext *cx, StringBuffer &sb, JSString *str) | |
33329 | { | |
33330 | static const jschar cdata_prefix_ucNstr[] = {'<', '!', '[', | |
33331 | 'C', 'D', 'A', 'T', 'A', | |
33332 | '['}; | |
33333 | static const jschar cdata_suffix_ucNstr[] = {']', ']', '>'}; | |
33334 | ||
33335 | return MakeXMLSpecialString(cx, sb, str, __null, | |
33336 | cdata_prefix_ucNstr, 9, | |
33337 | cdata_suffix_ucNstr, 3); | |
33338 | } | |
33339 | ||
33340 | static JSFlatString * | |
33341 | MakeXMLCommentString(JSContext *cx, StringBuffer &sb, JSString *str) | |
33342 | { | |
33343 | static const jschar comment_prefix_ucNstr[] = {'<', '!', '-', '-'}; | |
33344 | static const jschar comment_suffix_ucNstr[] = {'-', '-', '>'}; | |
33345 | ||
33346 | return MakeXMLSpecialString(cx, sb, str, __null, | |
33347 | comment_prefix_ucNstr, 4, | |
33348 | comment_suffix_ucNstr, 3); | |
33349 | } | |
33350 | ||
33351 | static JSFlatString * | |
33352 | MakeXMLPIString(JSContext *cx, StringBuffer &sb, JSString *name, | |
33353 | JSString *value) | |
33354 | { | |
33355 | static const jschar pi_prefix_ucNstr[] = {'<', '?'}; | |
33356 | static const jschar pi_suffix_ucNstr[] = {'?', '>'}; | |
33357 | ||
33358 | return MakeXMLSpecialString(cx, sb, name, value, | |
33359 | pi_prefix_ucNstr, 2, | |
33360 | pi_suffix_ucNstr, 2); | |
33361 | } | |
33362 | ||
33363 | ||
33364 | ||
33365 | ||
33366 | ||
33367 | static | |
33368 | ||
33369 | # 2044 "jsxml.cpp" | |
33370 | bool | |
33371 | AppendAttributeValue(JSContext *cx, StringBuffer &sb, JSString *valstr) | |
33372 | { | |
33373 | if (!sb.append('=')) | |
33374 | return false; | |
33375 | valstr = js_EscapeAttributeValue(cx, valstr, (JSIntn)1); | |
33376 | return valstr && sb.append(valstr); | |
33377 | } | |
33378 | ||
33379 | ||
33380 | ||
33381 | ||
33382 | ||
33383 | ||
33384 | static JSFlatString * | |
33385 | EscapeElementValue(JSContext *cx, StringBuffer &sb, JSString *str, uint32 toSourceFlag) | |
33386 | { | |
33387 | size_t length = str->length(); | |
33388 | const jschar *start = str->getChars(cx); | |
33389 | if (!start) | |
33390 | return __null; | |
33391 | ||
33392 | for (const jschar *cp = start, *end = start + length; cp != end; ++cp) { | |
33393 | jschar c = *cp; | |
33394 | switch (*cp) { | |
33395 | case '<': | |
33396 | if (!sb.append(js_lt_entity_str)) | |
33397 | return __null; | |
33398 | break; | |
33399 | case '>': | |
33400 | if (!sb.append(js_gt_entity_str)) | |
33401 | return __null; | |
33402 | break; | |
33403 | case '&': | |
33404 | if (!sb.append(js_amp_entity_str)) | |
33405 | return __null; | |
33406 | break; | |
33407 | case '{': | |
33408 | ||
33409 | ||
33410 | ||
33411 | ||
33412 | if (toSourceFlag) { | |
33413 | if (!sb.append(js_leftcurly_entity_str)) | |
33414 | return __null; | |
33415 | break; | |
33416 | } | |
33417 | ||
33418 | default: | |
33419 | if (!sb.append(c)) | |
33420 | return __null; | |
33421 | } | |
33422 | } | |
33423 | return sb.finishString(); | |
33424 | } | |
33425 | ||
33426 | ||
33427 | ||
33428 | ||
33429 | ||
33430 | ||
33431 | static JSFlatString * | |
33432 | EscapeAttributeValue(JSContext *cx, StringBuffer &sb, JSString *str, JSBool quote) | |
33433 | { | |
33434 | size_t length = str->length(); | |
33435 | const jschar *start = str->getChars(cx); | |
33436 | if (!start) | |
33437 | return __null; | |
33438 | ||
33439 | if (quote && !sb.append('"')) | |
33440 | return __null; | |
33441 | ||
33442 | for (const jschar *cp = start, *end = start + length; cp != end; ++cp) { | |
33443 | jschar c = *cp; | |
33444 | switch (c) { | |
33445 | case '"': | |
33446 | if (!sb.append(js_quot_entity_str)) | |
33447 | return __null; | |
33448 | break; | |
33449 | case '<': | |
33450 | if (!sb.append(js_lt_entity_str)) | |
33451 | return __null; | |
33452 | break; | |
33453 | case '&': | |
33454 | if (!sb.append(js_amp_entity_str)) | |
33455 | return __null; | |
33456 | break; | |
33457 | case '\n': | |
33458 | if (!sb.append("
")) | |
33459 | return __null; | |
33460 | break; | |
33461 | case '\r': | |
33462 | if (!sb.append("
")) | |
33463 | return __null; | |
33464 | break; | |
33465 | case '\t': | |
33466 | if (!sb.append("	")) | |
33467 | return __null; | |
33468 | break; | |
33469 | default: | |
33470 | if (!sb.append(c)) | |
33471 | return __null; | |
33472 | } | |
33473 | } | |
33474 | ||
33475 | if (quote && !sb.append('"')) | |
33476 | return __null; | |
33477 | ||
33478 | return sb.finishString(); | |
33479 | } | |
33480 | ||
33481 | ||
33482 | static JSObject * | |
33483 | GetNamespace(JSContext *cx, JSObject *qn, const JSXMLArray *inScopeNSes) | |
33484 | { | |
33485 | JSLinearString *uri, *prefix, *nsprefix; | |
33486 | JSObject *match, *ns; | |
33487 | uint32 i, n; | |
33488 | jsval argv[2]; | |
33489 | ||
33490 | uri = qn->getNameURI(); | |
33491 | prefix = qn->getNamePrefix(); | |
33492 | ((void) 0); | |
33493 | if (!uri) { | |
33494 | JSAutoByteString bytes; | |
33495 | const char *s = !prefix ? | |
33496 | js_undefined_str | |
33497 | : js_ValueToPrintable(cx, StringValue(prefix), &bytes); | |
33498 | if (s) | |
33499 | JS_ReportErrorNumber(cx, js_GetErrorMessage, __null, JSMSG_BAD_XML_NAMESPACE, s); | |
33500 | return __null; | |
33501 | } | |
33502 | ||
33503 | ||
33504 | match = __null; | |
33505 | if (inScopeNSes) { | |
33506 | for (i = 0, n = inScopeNSes->length; i < n; i++) { | |
33507 | ns = (((i) < (inScopeNSes)->length) ? (JSObject *) (inScopeNSes)->vector[i] : __null); | |
33508 | if (!ns) | |
33509 | continue; | |
33510 | # 2212 "jsxml.cpp" | |
33511 | if (EqualStrings(ns->getNameURI(), uri)) { | |
33512 | nsprefix = ns->getNamePrefix(); | |
33513 | if (nsprefix == prefix || | |
33514 | ((nsprefix && prefix) | |
33515 | ? EqualStrings(nsprefix, prefix) | |
33516 | : (nsprefix ? nsprefix : prefix)->empty())) { | |
33517 | match = ns; | |
33518 | break; | |
33519 | } | |
33520 | } | |
33521 | } | |
33522 | } | |
33523 | ||
33524 | ||
33525 | if (!match) { | |
33526 | argv[0] = prefix ? STRING_TO_JSVAL(prefix) : ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0)); | |
33527 | argv[1] = STRING_TO_JSVAL(uri); | |
33528 | ns = js_ConstructObject(cx, &js_NamespaceClass, __null, __null, | |
33529 | 2, Valueify(argv)); | |
33530 | if (!ns) | |
33531 | return __null; | |
33532 | match = ns; | |
33533 | } | |
33534 | return match; | |
33535 | } | |
33536 | ||
33537 | static JSLinearString * | |
33538 | GeneratePrefix(JSContext *cx, JSLinearString *uri, JSXMLArray *decls) | |
33539 | { | |
33540 | const jschar *cp, *start, *end; | |
33541 | size_t length, newlength, offset; | |
33542 | uint32 i, n, m, serial; | |
33543 | jschar *bp, *dp; | |
33544 | JSBool done; | |
33545 | JSObject *ns; | |
33546 | JSLinearString *nsprefix, *prefix; | |
33547 | ||
33548 | ((void) 0); | |
33549 | # 2262 "jsxml.cpp" | |
33550 | if (decls->length == 0) | |
33551 | return js_NewStringCopyZ(cx, "a"); | |
33552 | ||
33553 | ||
33554 | ||
33555 | ||
33556 | ||
33557 | ||
33558 | ||
33559 | start = uri->chars(); | |
33560 | end = start + uri->length(); | |
33561 | cp = end; | |
33562 | while (--cp > start) { | |
33563 | if (*cp == '.' || *cp == '/' || *cp == ':') { | |
33564 | ++cp; | |
33565 | length = end - cp; | |
33566 | if (IsXMLName(cp, length) && !(length >= 3 && (((jschar) (((js_A[js_Y[(js_X[(uint16)((cp)[0])>>6]<<6)|(((cp)[0])&0x3F)]]) & 0x00200000) ? ((cp)[0]) + ((int32)(js_A[js_Y[(js_X[(uint16)((cp)[0])>>6]<<6)|(((cp)[0])&0x3F)]]) >> 22) : ((cp)[0]))) == 'x' && ((jschar) (((js_A[js_Y[(js_X[(uint16)((cp)[1])>>6]<<6)|(((cp)[1])&0x3F)]]) & 0x00200000) ? ((cp)[1]) + ((int32)(js_A[js_Y[(js_X[(uint16)((cp)[1])>>6]<<6)|(((cp)[1])&0x3F)]]) >> 22) : ((cp)[1]))) == 'm' && ((jschar) (((js_A[js_Y[(js_X[(uint16)((cp)[2])>>6]<<6)|(((cp)[2])&0x3F)]]) & 0x00200000) ? ((cp)[2]) + ((int32)(js_A[js_Y[(js_X[(uint16)((cp)[2])>>6]<<6)|(((cp)[2])&0x3F)]]) >> 22) : ((cp)[2]))) == 'l'))) | |
33567 | break; | |
33568 | end = --cp; | |
33569 | } | |
33570 | } | |
33571 | length = end - cp; | |
33572 | # 2292 "jsxml.cpp" | |
33573 | bp = (jschar *) cp; | |
33574 | newlength = length; | |
33575 | if ((length >= 3 && (((jschar) (((js_A[js_Y[(js_X[(uint16)((cp)[0])>>6]<<6)|(((cp)[0])&0x3F)]]) & 0x00200000) ? ((cp)[0]) + ((int32)(js_A[js_Y[(js_X[(uint16)((cp)[0])>>6]<<6)|(((cp)[0])&0x3F)]]) >> 22) : ((cp)[0]))) == 'x' && ((jschar) (((js_A[js_Y[(js_X[(uint16)((cp)[1])>>6]<<6)|(((cp)[1])&0x3F)]]) & 0x00200000) ? ((cp)[1]) + ((int32)(js_A[js_Y[(js_X[(uint16)((cp)[1])>>6]<<6)|(((cp)[1])&0x3F)]]) >> 22) : ((cp)[1]))) == 'm' && ((jschar) (((js_A[js_Y[(js_X[(uint16)((cp)[2])>>6]<<6)|(((cp)[2])&0x3F)]]) & 0x00200000) ? ((cp)[2]) + ((int32)(js_A[js_Y[(js_X[(uint16)((cp)[2])>>6]<<6)|(((cp)[2])&0x3F)]]) >> 22) : ((cp)[2]))) == 'l')) || !IsXMLName(cp, length)) { | |
33576 | newlength = length + 2 + (size_t) log10((double) decls->length); | |
33577 | bp = (jschar *) | |
33578 | cx->malloc((newlength + 1) * sizeof(jschar)); | |
33579 | if (!bp) | |
33580 | return __null; | |
33581 | ||
33582 | bp[newlength] = 0; | |
33583 | for (i = 0; i < newlength; i++) | |
33584 | bp[i] = 'a'; | |
33585 | } | |
33586 | ||
33587 | ||
33588 | ||
33589 | ||
33590 | ||
33591 | serial = 0; | |
33592 | do { | |
33593 | done = (JSIntn)1; | |
33594 | for (i = 0, n = decls->length; i < n; i++) { | |
33595 | ns = (((i) < (decls)->length) ? (JSObject *) (decls)->vector[i] : __null); | |
33596 | if (ns && (nsprefix = ns->getNamePrefix()) && | |
33597 | nsprefix->length() == newlength && | |
33598 | !memcmp(nsprefix->chars(), bp, | |
33599 | newlength * sizeof(jschar))) { | |
33600 | if (bp == cp) { | |
33601 | newlength = length + 2 + (size_t) log10((double) n); | |
33602 | bp = (jschar *) | |
33603 | cx->malloc((newlength + 1) * sizeof(jschar)); | |
33604 | if (!bp) | |
33605 | return __null; | |
33606 | memcpy((bp), (cp), (length) * sizeof(jschar)); | |
33607 | } | |
33608 | ||
33609 | ++serial; | |
33610 | ((void) 0); | |
33611 | dp = bp + length + 2 + (size_t) log10((double) serial); | |
33612 | *dp = 0; | |
33613 | for (m = serial; m != 0; m /= 10) | |
33614 | *--dp = (jschar)('0' + m % 10); | |
33615 | *--dp = '-'; | |
33616 | ((void) 0); | |
33617 | ||
33618 | done = (JSIntn)0; | |
33619 | break; | |
33620 | } | |
33621 | } | |
33622 | } while (!done); | |
33623 | ||
33624 | if (bp == cp) { | |
33625 | offset = cp - start; | |
33626 | prefix = js_NewDependentString(cx, uri, offset, length); | |
33627 | } else { | |
33628 | prefix = js_NewString(cx, bp, newlength); | |
33629 | if (!prefix) | |
33630 | cx->free(bp); | |
33631 | } | |
33632 | return prefix; | |
33633 | } | |
33634 | ||
33635 | static JSBool | |
33636 | namespace_match(const void *a, const void *b) | |
33637 | { | |
33638 | const JSObject *nsa = (const JSObject *) a; | |
33639 | const JSObject *nsb = (const JSObject *) b; | |
33640 | JSLinearString *prefixa, *prefixb = nsb->getNamePrefix(); | |
33641 | ||
33642 | if (prefixb) { | |
33643 | prefixa = nsa->getNamePrefix(); | |
33644 | return prefixa && EqualStrings(prefixa, prefixb); | |
33645 | } | |
33646 | return EqualStrings(nsa->getNameURI(), nsb->getNameURI()); | |
33647 | } | |
33648 | ||
33649 | ||
33650 | ||
33651 | ||
33652 | static JSString * | |
33653 | XMLToXMLString(JSContext *cx, JSXML *xml, const JSXMLArray *ancestorNSes, | |
33654 | uint32 indentLevel) | |
33655 | { | |
33656 | JSBool pretty, indentKids; | |
33657 | StringBuffer sb(cx); | |
33658 | JSString *str; | |
33659 | JSLinearString *prefix, *nsuri; | |
33660 | uint32 i, n, nextIndentLevel; | |
33661 | JSObject *ns, *ns2; | |
33662 | AutoNamespaceArray empty(cx), decls(cx), ancdecls(cx); | |
33663 | ||
33664 | if (!GetBooleanXMLSetting(cx, js_prettyPrinting_str, &pretty)) | |
33665 | return __null; | |
33666 | ||
33667 | if (pretty) { | |
33668 | if (!sb.appendN(' ', indentLevel & ~0x80000000)) | |
33669 | return __null; | |
33670 | } | |
33671 | ||
33672 | str = __null; | |
33673 | ||
33674 | switch (xml->xml_class) { | |
33675 | case JSXML_CLASS_TEXT: | |
33676 | ||
33677 | if (pretty) { | |
33678 | str = ChompXMLWhitespace(cx, xml->u.value); | |
33679 | if (!str) | |
33680 | return __null; | |
33681 | } else { | |
33682 | str = xml->u.value; | |
33683 | } | |
33684 | return EscapeElementValue(cx, sb, str, indentLevel & 0x80000000); | |
33685 | ||
33686 | case JSXML_CLASS_ATTRIBUTE: | |
33687 | ||
33688 | return EscapeAttributeValue(cx, sb, xml->u.value, | |
33689 | (indentLevel & 0x80000000) != 0); | |
33690 | ||
33691 | case JSXML_CLASS_COMMENT: | |
33692 | ||
33693 | return MakeXMLCommentString(cx, sb, xml->u.value); | |
33694 | ||
33695 | case JSXML_CLASS_PROCESSING_INSTRUCTION: | |
33696 | ||
33697 | return MakeXMLPIString(cx, sb, xml->name->getQNameLocalName(), | |
33698 | xml->u.value); | |
33699 | ||
33700 | case JSXML_CLASS_LIST: | |
33701 | ||
33702 | { | |
33703 | JSXMLArrayCursor cursor(&xml->u.list.kids); | |
33704 | i = 0; | |
33705 | while (JSXML *kid = (JSXML *) cursor.getNext()) { | |
33706 | if (pretty && i != 0) { | |
33707 | if (!sb.append('\n')) | |
33708 | return __null; | |
33709 | } | |
33710 | ||
33711 | JSString *kidstr = XMLToXMLString(cx, kid, ancestorNSes, indentLevel); | |
33712 | if (!kidstr || !sb.append(kidstr)) | |
33713 | return __null; | |
33714 | ++i; | |
33715 | } | |
33716 | } | |
33717 | ||
33718 | if (sb.empty()) | |
33719 | return cx->runtime->emptyString; | |
33720 | return sb.finishString(); | |
33721 | ||
33722 | default:; | |
33723 | } | |
33724 | ||
33725 | ||
33726 | if (!js_EnterLocalRootScope(cx)) | |
33727 | return __null; | |
33728 | ||
33729 | ||
33730 | if (!ancestorNSes) | |
33731 | ancestorNSes = &empty.array; | |
33732 | ||
33733 | ||
33734 | { | |
33735 | JSXMLArrayCursor cursor(&xml->u.elem.namespaces); | |
33736 | while ((ns = (JSObject *) cursor.getNext()) != __null) { | |
33737 | if (!IsDeclared(ns)) | |
33738 | continue; | |
33739 | if (!(XMLArrayFindMember(ancestorNSes, (void *)(ns), namespace_identity) != ((uint32) -1))) { | |
33740 | ||
33741 | ns2 = NewXMLNamespace(cx, ns->getNamePrefix(), ns->getNameURI(), (JSIntn)1); | |
33742 | if (!ns2 || !XMLArrayAddMember(cx, &decls.array, (&decls.array)->length, (void *)((ns2)))) | |
33743 | goto out; | |
33744 | } | |
33745 | } | |
33746 | } | |
33747 | ||
33748 | ||
33749 | ||
33750 | ||
33751 | ||
33752 | ||
33753 | ||
33754 | if (!ancdecls.array.setCapacity(cx, ancestorNSes->length + decls.length())) | |
33755 | goto out; | |
33756 | for (i = 0, n = ancestorNSes->length; i < n; i++) { | |
33757 | ns2 = (((i) < (ancestorNSes)->length) ? (JSObject *) (ancestorNSes)->vector[i] : __null); | |
33758 | if (!ns2) | |
33759 | continue; | |
33760 | ((void) 0); | |
33761 | if (!XMLArrayAddMember(cx, &ancdecls.array, (&ancdecls.array)->length, (void *)((ns2)))) | |
33762 | goto out; | |
33763 | } | |
33764 | for (i = 0, n = decls.length(); i < n; i++) { | |
33765 | ns2 = (((i) < (&decls.array)->length) ? (JSObject *) (&decls.array)->vector[i] : __null); | |
33766 | if (!ns2) | |
33767 | continue; | |
33768 | ((void) 0); | |
33769 | if (!XMLArrayAddMember(cx, &ancdecls.array, (&ancdecls.array)->length, (void *)((ns2)))) | |
33770 | goto out; | |
33771 | } | |
33772 | ||
33773 | ||
33774 | ns = GetNamespace(cx, xml->name, &ancdecls.array); | |
33775 | if (!ns) | |
33776 | goto out; | |
33777 | ||
33778 | ||
33779 | prefix = ns->getNamePrefix(); | |
33780 | if (!prefix) { | |
33781 | # 2514 "jsxml.cpp" | |
33782 | nsuri = ns->getNameURI(); | |
33783 | if (!xml->name->getNamePrefix()) { | |
33784 | prefix = cx->runtime->emptyString; | |
33785 | } else { | |
33786 | prefix = GeneratePrefix(cx, nsuri, &ancdecls.array); | |
33787 | if (!prefix) | |
33788 | goto out; | |
33789 | } | |
33790 | ns = NewXMLNamespace(cx, prefix, nsuri, (JSIntn)1); | |
33791 | if (!ns) | |
33792 | goto out; | |
33793 | # 2539 "jsxml.cpp" | |
33794 | if (prefix->empty()) { | |
33795 | i = XMLArrayFindMember(&decls.array, ns, namespace_match); | |
33796 | if (i != ((uint32) -1)) | |
33797 | XMLArrayDelete(cx, &decls.array, i, (JSIntn)1); | |
33798 | } | |
33799 | # 2552 "jsxml.cpp" | |
33800 | if (!XMLArrayAddMember(cx, &ancdecls.array, (&ancdecls.array)->length, (void *)((ns))) || | |
33801 | !XMLArrayAddMember(cx, &decls.array, (&decls.array)->length, (void *)((ns)))) { | |
33802 | goto out; | |
33803 | } | |
33804 | } | |
33805 | ||
33806 | ||
33807 | if (!sb.append('<')) | |
33808 | goto out; | |
33809 | ||
33810 | if (!prefix->empty()) { | |
33811 | if (!sb.append(prefix) || !sb.append(':')) | |
33812 | goto out; | |
33813 | } | |
33814 | if (!sb.append(xml->name->getQNameLocalName())) | |
33815 | goto out; | |
33816 | # 2576 "jsxml.cpp" | |
33817 | { | |
33818 | JSXMLArrayCursor cursor(&xml->u.elem.attrs); | |
33819 | while (JSXML *attr = (JSXML *) cursor.getNext()) { | |
33820 | if (!sb.append(' ')) | |
33821 | goto out; | |
33822 | ns2 = GetNamespace(cx, attr->name, &ancdecls.array); | |
33823 | if (!ns2) | |
33824 | goto out; | |
33825 | ||
33826 | ||
33827 | prefix = ns2->getNamePrefix(); | |
33828 | if (!prefix) { | |
33829 | prefix = GeneratePrefix(cx, ns2->getNameURI(), &ancdecls.array); | |
33830 | if (!prefix) | |
33831 | goto out; | |
33832 | ||
33833 | ||
33834 | ns2 = NewXMLNamespace(cx, prefix, ns2->getNameURI(), (JSIntn)1); | |
33835 | if (!ns2) | |
33836 | goto out; | |
33837 | # 2604 "jsxml.cpp" | |
33838 | if (!XMLArrayAddMember(cx, &ancdecls.array, (&ancdecls.array)->length, (void *)((ns2))) || | |
33839 | !XMLArrayAddMember(cx, &decls.array, (&decls.array)->length, (void *)((ns2)))) { | |
33840 | goto out; | |
33841 | } | |
33842 | } | |
33843 | ||
33844 | ||
33845 | if (!prefix->empty()) { | |
33846 | if (!sb.append(prefix) || !sb.append(':')) | |
33847 | goto out; | |
33848 | } | |
33849 | ||
33850 | ||
33851 | if (!sb.append(attr->name->getQNameLocalName())) | |
33852 | goto out; | |
33853 | ||
33854 | ||
33855 | if (!AppendAttributeValue(cx, sb, attr->u.value)) | |
33856 | goto out; | |
33857 | } | |
33858 | } | |
33859 | ||
33860 | ||
33861 | { | |
33862 | JSXMLArrayCursor cursor(&decls.array); | |
33863 | while (JSObject *ns3 = (JSObject *) cursor.getNext()) { | |
33864 | ((void) 0); | |
33865 | ||
33866 | if (!sb.append(" xmlns")) | |
33867 | goto out; | |
33868 | ||
33869 | ||
33870 | prefix = ns3->getNamePrefix(); | |
33871 | if (!prefix) { | |
33872 | prefix = GeneratePrefix(cx, ns3->getNameURI(), &ancdecls.array); | |
33873 | if (!prefix) | |
33874 | goto out; | |
33875 | ns3->setNamePrefix(prefix); | |
33876 | } | |
33877 | ||
33878 | ||
33879 | if (!prefix->empty()) { | |
33880 | if (!sb.append(':') || !sb.append(prefix)) | |
33881 | goto out; | |
33882 | } | |
33883 | ||
33884 | ||
33885 | if (!AppendAttributeValue(cx, sb, ns3->getNameURI())) | |
33886 | goto out; | |
33887 | } | |
33888 | } | |
33889 | ||
33890 | ||
33891 | n = xml->u.list.kids.length; | |
33892 | if (n == 0) { | |
33893 | if (!sb.append("/>")) | |
33894 | goto out; | |
33895 | } else { | |
33896 | ||
33897 | if (!sb.append('>')) | |
33898 | goto out; | |
33899 | { | |
33900 | JSXML *kid; | |
33901 | indentKids = n > 1 || | |
33902 | (n == 1 && | |
33903 | (kid = (((0) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[0] : __null)) && | |
33904 | kid->xml_class != JSXML_CLASS_TEXT); | |
33905 | } | |
33906 | ||
33907 | if (pretty && indentKids) { | |
33908 | if (!GetUint32XMLSetting(cx, js_prettyIndent_str, &i)) | |
33909 | goto out; | |
33910 | nextIndentLevel = indentLevel + i; | |
33911 | } else { | |
33912 | nextIndentLevel = indentLevel & 0x80000000; | |
33913 | } | |
33914 | ||
33915 | { | |
33916 | JSXMLArrayCursor cursor(&xml->u.list.kids); | |
33917 | while (JSXML *kid = (JSXML *) cursor.getNext()) { | |
33918 | if (pretty && indentKids) { | |
33919 | if (!sb.append('\n')) | |
33920 | goto out; | |
33921 | } | |
33922 | ||
33923 | JSString *kidstr = XMLToXMLString(cx, kid, &ancdecls.array, nextIndentLevel); | |
33924 | if (!kidstr) | |
33925 | goto out; | |
33926 | ||
33927 | if (!sb.append(kidstr)) | |
33928 | goto out; | |
33929 | } | |
33930 | } | |
33931 | ||
33932 | if (pretty && indentKids) { | |
33933 | if (!sb.append('\n') || | |
33934 | !sb.appendN(' ', indentLevel & ~0x80000000)) | |
33935 | goto out; | |
33936 | } | |
33937 | if (!sb.append("</")) | |
33938 | goto out; | |
33939 | ||
33940 | ||
33941 | prefix = ns->getNamePrefix(); | |
33942 | if (prefix && !prefix->empty()) { | |
33943 | if (!sb.append(prefix) || !sb.append(':')) | |
33944 | goto out; | |
33945 | } | |
33946 | ||
33947 | ||
33948 | if (!sb.append(xml->name->getQNameLocalName()) || !sb.append('>')) | |
33949 | goto out; | |
33950 | } | |
33951 | ||
33952 | str = sb.finishString(); | |
33953 | out: | |
33954 | js_LeaveLocalRootScopeWithResult(cx, str); | |
33955 | return str; | |
33956 | } | |
33957 | ||
33958 | ||
33959 | static JSString * | |
33960 | ToXMLString(JSContext *cx, jsval v, uint32 toSourceFlag) | |
33961 | { | |
33962 | JSObject *obj; | |
33963 | JSString *str; | |
33964 | JSXML *xml; | |
33965 | ||
33966 | if (JSVAL_IS_NULL(v) || JSVAL_IS_VOID(v)) { | |
33967 | JS_ReportErrorNumber(cx, js_GetErrorMessage, __null, | |
33968 | JSMSG_BAD_XML_CONVERSION, | |
33969 | JSVAL_IS_NULL(v) ? js_null_str : js_undefined_str); | |
33970 | return __null; | |
33971 | } | |
33972 | ||
33973 | if (JSVAL_IS_BOOLEAN(v) || JSVAL_IS_NUMBER(v)) | |
33974 | return js_ValueToString(cx, Valueify(v)); | |
33975 | ||
33976 | if (JSVAL_IS_STRING(v)) { | |
33977 | StringBuffer sb(cx); | |
33978 | return EscapeElementValue(cx, sb, JSVAL_TO_STRING(v), toSourceFlag); | |
33979 | } | |
33980 | ||
33981 | obj = JSVAL_TO_OBJECT(v); | |
33982 | if (!obj->isXML()) { | |
33983 | if (!DefaultValue(cx, obj, JSTYPE_STRING, Valueify(&v))) | |
33984 | return __null; | |
33985 | str = js_ValueToString(cx, Valueify(v)); | |
33986 | if (!str) | |
33987 | return __null; | |
33988 | StringBuffer sb(cx); | |
33989 | return EscapeElementValue(cx, sb, str, toSourceFlag); | |
33990 | } | |
33991 | ||
33992 | ||
33993 | xml = (JSXML *) obj->getPrivate(); | |
33994 | return XMLToXMLString(cx, xml, __null, toSourceFlag | 0); | |
33995 | } | |
33996 | ||
33997 | static JSObject * | |
33998 | ToAttributeName(JSContext *cx, jsval v) | |
33999 | { | |
34000 | JSLinearString *name, *uri, *prefix; | |
34001 | JSObject *obj; | |
34002 | Class *clasp; | |
34003 | JSObject *qn; | |
34004 | ||
34005 | if (JSVAL_IS_STRING(v)) { | |
34006 | name = JSVAL_TO_STRING(v)->ensureLinear(cx); | |
34007 | if (!name) | |
34008 | return __null; | |
34009 | uri = prefix = cx->runtime->emptyString; | |
34010 | } else { | |
34011 | if (JSVAL_IS_PRIMITIVE(v)) { | |
34012 | ((void)js_ReportValueErrorFlags(cx, 0x0, JSMSG_BAD_XML_ATTR_NAME, 0, Valueify(v), __null, __null, __null)) | |
34013 | ; | |
34014 | return __null; | |
34015 | } | |
34016 | ||
34017 | obj = JSVAL_TO_OBJECT(v); | |
34018 | clasp = obj->getClass(); | |
34019 | if (clasp == &js_AttributeNameClass) | |
34020 | return obj; | |
34021 | ||
34022 | if (clasp == &js_QNameClass) { | |
34023 | qn = obj; | |
34024 | uri = qn->getNameURI(); | |
34025 | prefix = qn->getNamePrefix(); | |
34026 | name = qn->getQNameLocalName(); | |
34027 | } else { | |
34028 | if (clasp == &js_AnyNameClass) { | |
34029 | name = (cx->runtime->atomState.starAtom); | |
34030 | } else { | |
34031 | JSString *str = js_ValueToString(cx, Valueify(v)); | |
34032 | if (!str) | |
34033 | return __null; | |
34034 | name = str->ensureLinear(cx); | |
34035 | if (!name) | |
34036 | return __null; | |
34037 | } | |
34038 | uri = prefix = cx->runtime->emptyString; | |
34039 | } | |
34040 | } | |
34041 | ||
34042 | qn = NewXMLAttributeName(cx, uri, prefix, name); | |
34043 | if (!qn) | |
34044 | return __null; | |
34045 | return qn; | |
34046 | } | |
34047 | ||
34048 | static void | |
34049 | ReportBadXMLName(JSContext *cx, const Value &idval) | |
34050 | { | |
34051 | ((void)js_ReportValueErrorFlags(cx, 0x0, JSMSG_BAD_XML_NAME, 0, idval, __null, __null, __null)); | |
34052 | } | |
34053 | ||
34054 | static JSBool | |
34055 | IsFunctionQName(JSContext *cx, JSObject *qn, jsid *funidp) | |
34056 | { | |
34057 | JSAtom *atom; | |
34058 | JSLinearString *uri; | |
34059 | ||
34060 | atom = cx->runtime->atomState.functionNamespaceURIAtom; | |
34061 | uri = qn->getNameURI(); | |
34062 | if (uri && | |
34063 | (uri == (atom) || | |
34064 | EqualStrings(uri, (atom)))) { | |
34065 | return JS_ValueToId(cx, STRING_TO_JSVAL(qn->getQNameLocalName()), funidp); | |
34066 | } | |
34067 | *funidp = ((jsid)0x2); | |
34068 | return (JSIntn)1; | |
34069 | } | |
34070 | ||
34071 | JSBool | |
34072 | js_IsFunctionQName(JSContext *cx, JSObject *obj, jsid *funidp) | |
34073 | { | |
34074 | if (obj->getClass() == &js_QNameClass) | |
34075 | return IsFunctionQName(cx, obj, funidp); | |
34076 | *funidp = ((jsid)0x2); | |
34077 | return (JSIntn)1; | |
34078 | } | |
34079 | ||
34080 | static JSObject * | |
34081 | ToXMLName(JSContext *cx, jsval v, jsid *funidp) | |
34082 | { | |
34083 | JSAtom *atomizedName; | |
34084 | JSString *name; | |
34085 | JSObject *obj; | |
34086 | Class *clasp; | |
34087 | uint32 index; | |
34088 | ||
34089 | if (JSVAL_IS_STRING(v)) { | |
34090 | name = JSVAL_TO_STRING(v); | |
34091 | } else { | |
34092 | if (JSVAL_IS_PRIMITIVE(v)) { | |
34093 | ReportBadXMLName(cx, Valueify(v)); | |
34094 | return __null; | |
34095 | } | |
34096 | ||
34097 | obj = JSVAL_TO_OBJECT(v); | |
34098 | clasp = obj->getClass(); | |
34099 | if (clasp == &js_AttributeNameClass || clasp == &js_QNameClass) | |
34100 | goto out; | |
34101 | if (clasp == &js_AnyNameClass) { | |
34102 | name = (cx->runtime->atomState.starAtom); | |
34103 | goto construct; | |
34104 | } | |
34105 | name = js_ValueToString(cx, Valueify(v)); | |
34106 | if (!name) | |
34107 | return __null; | |
34108 | } | |
34109 | ||
34110 | atomizedName = js_AtomizeString(cx, name, 0); | |
34111 | if (!atomizedName) | |
34112 | return __null; | |
34113 | # 2893 "jsxml.cpp" | |
34114 | if (js_IdIsIndex(ATOM_TO_JSID(atomizedName), &index)) | |
34115 | goto bad; | |
34116 | ||
34117 | if (*atomizedName->chars() == '@') { | |
34118 | name = js_NewDependentString(cx, name, 1, name->length() - 1); | |
34119 | if (!name) | |
34120 | return __null; | |
34121 | *funidp = ((jsid)0x2); | |
34122 | return ToAttributeName(cx, STRING_TO_JSVAL(name)); | |
34123 | } | |
34124 | ||
34125 | construct: | |
34126 | v = STRING_TO_JSVAL(name); | |
34127 | obj = js_ConstructObject(cx, &js_QNameClass, __null, __null, 1, Valueify(&v)); | |
34128 | if (!obj) | |
34129 | return __null; | |
34130 | ||
34131 | out: | |
34132 | if (!IsFunctionQName(cx, obj, funidp)) | |
34133 | return __null; | |
34134 | return obj; | |
34135 | ||
34136 | bad: | |
34137 | JSAutoByteString bytes; | |
34138 | if (js_ValueToPrintable(cx, StringValue(name), &bytes)) | |
34139 | JS_ReportErrorNumber(cx, js_GetErrorMessage, __null, JSMSG_BAD_XML_NAME, bytes.ptr()); | |
34140 | return __null; | |
34141 | } | |
34142 | ||
34143 | ||
34144 | static JSBool | |
34145 | AddInScopeNamespace(JSContext *cx, JSXML *xml, JSObject *ns) | |
34146 | { | |
34147 | JSLinearString *prefix, *prefix2; | |
34148 | JSObject *match, *ns2; | |
34149 | uint32 i, n, m; | |
34150 | ||
34151 | if (xml->xml_class != JSXML_CLASS_ELEMENT) | |
34152 | return (JSIntn)1; | |
34153 | ||
34154 | ||
34155 | prefix = ns->getNamePrefix(); | |
34156 | if (!prefix) { | |
34157 | match = __null; | |
34158 | for (i = 0, n = xml->u.elem.namespaces.length; i < n; i++) { | |
34159 | ns2 = (((i) < (&xml->u.elem.namespaces)->length) ? (JSObject *) (&xml->u.elem.namespaces)->vector[i] : __null); | |
34160 | if (ns2 && EqualStrings(ns2->getNameURI(), ns->getNameURI())) { | |
34161 | match = ns2; | |
34162 | break; | |
34163 | } | |
34164 | } | |
34165 | if (!match && !XMLArrayAddMember(cx, &xml->u.elem.namespaces, n, (void *)(ns))) | |
34166 | return (JSIntn)0; | |
34167 | } else { | |
34168 | if (prefix->empty() && xml->name->getNameURI()->empty()) | |
34169 | return (JSIntn)1; | |
34170 | match = __null; | |
34171 | ||
34172 | m = ((uint32) -1); | |
34173 | ||
34174 | for (i = 0, n = xml->u.elem.namespaces.length; i < n; i++) { | |
34175 | ns2 = (((i) < (&xml->u.elem.namespaces)->length) ? (JSObject *) (&xml->u.elem.namespaces)->vector[i] : __null); | |
34176 | if (ns2 && (prefix2 = ns2->getNamePrefix()) && | |
34177 | EqualStrings(prefix2, prefix)) { | |
34178 | match = ns2; | |
34179 | m = i; | |
34180 | break; | |
34181 | } | |
34182 | } | |
34183 | if (match && !EqualStrings(match->getNameURI(), ns->getNameURI())) { | |
34184 | ns2 = ((JSObject *) XMLArrayDelete(cx, &xml->u.elem.namespaces, m, (JSIntn)1)) | |
34185 | ; | |
34186 | ((void) 0); | |
34187 | match->clearNamePrefix(); | |
34188 | if (!AddInScopeNamespace(cx, xml, match)) | |
34189 | return (JSIntn)0; | |
34190 | } | |
34191 | if (!XMLArrayAddMember(cx, &xml->u.elem.namespaces, (&xml->u.elem.namespaces)->length, (void *)((ns)))) | |
34192 | return (JSIntn)0; | |
34193 | } | |
34194 | ||
34195 | ||
34196 | return (JSIntn)1; | |
34197 | } | |
34198 | ||
34199 | ||
34200 | static JSBool | |
34201 | Append(JSContext *cx, JSXML *list, JSXML *xml) | |
34202 | { | |
34203 | uint32 i, j, k, n; | |
34204 | JSXML *kid; | |
34205 | ||
34206 | ((void) 0); | |
34207 | i = list->u.list.kids.length; | |
34208 | n = 1; | |
34209 | if (xml->xml_class == JSXML_CLASS_LIST) { | |
34210 | list->u.list.target = xml->u.list.target; | |
34211 | list->u.list.targetprop = xml->u.list.targetprop; | |
34212 | n = ((((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (xml)->u.list.kids.length : 0); | |
34213 | k = i + n; | |
34214 | if (!list->u.list.kids.setCapacity(cx, k)) | |
34215 | return (JSIntn)0; | |
34216 | for (j = 0; j < n; j++) { | |
34217 | kid = (((j) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[j] : __null); | |
34218 | if (kid) | |
34219 | do { if ((&list->u.list.kids)->length <= (i + j)) (&list->u.list.kids)->length = (i + j) + 1; ((&list->u.list.kids)->vector[i + j] = (void *)(kid)); } while (0); | |
34220 | } | |
34221 | return (JSIntn)1; | |
34222 | } | |
34223 | ||
34224 | list->u.list.target = xml->parent; | |
34225 | if (xml->xml_class == JSXML_CLASS_PROCESSING_INSTRUCTION) | |
34226 | list->u.list.targetprop = __null; | |
34227 | else | |
34228 | list->u.list.targetprop = xml->name; | |
34229 | if (!XMLArrayAddMember(cx, &list->u.list.kids, i, (void *)(xml))) | |
34230 | return (JSIntn)0; | |
34231 | return (JSIntn)1; | |
34232 | } | |
34233 | ||
34234 | ||
34235 | static JSXML * | |
34236 | DeepCopyInLRS(JSContext *cx, JSXML *xml, uintN flags); | |
34237 | ||
34238 | static JSXML * | |
34239 | DeepCopy(JSContext *cx, JSXML *xml, JSObject *obj, uintN flags) | |
34240 | { | |
34241 | JSXML *copy; | |
34242 | ||
34243 | ||
34244 | if (!js_EnterLocalRootScope(cx)) | |
34245 | return __null; | |
34246 | copy = DeepCopyInLRS(cx, xml, flags); | |
34247 | if (copy) { | |
34248 | if (obj) { | |
34249 | ||
34250 | obj->setPrivate(copy); | |
34251 | copy->object = obj; | |
34252 | } else if (!js_GetXMLObject(cx, copy)) { | |
34253 | copy = __null; | |
34254 | } | |
34255 | } | |
34256 | js_LeaveLocalRootScopeWithResult(cx, copy); | |
34257 | return copy; | |
34258 | } | |
34259 | ||
34260 | ||
34261 | ||
34262 | ||
34263 | ||
34264 | ||
34265 | static JSBool | |
34266 | DeepCopySetInLRS(JSContext *cx, JSXMLArray *from, JSXMLArray *to, JSXML *parent, | |
34267 | uintN flags) | |
34268 | { | |
34269 | uint32 j, n; | |
34270 | JSXML *kid2; | |
34271 | JSString *str; | |
34272 | ||
34273 | n = from->length; | |
34274 | if (!to->setCapacity(cx, n)) | |
34275 | return (JSIntn)0; | |
34276 | ||
34277 | JSXMLArrayCursor cursor(from); | |
34278 | j = 0; | |
34279 | while (JSXML *kid = (JSXML *) cursor.getNext()) { | |
34280 | if ((flags & ((JSUint32)1 << (0))) && | |
34281 | kid->xml_class == JSXML_CLASS_COMMENT) { | |
34282 | continue; | |
34283 | } | |
34284 | if ((flags & ((JSUint32)1 << (1))) && | |
34285 | kid->xml_class == JSXML_CLASS_PROCESSING_INSTRUCTION) { | |
34286 | continue; | |
34287 | } | |
34288 | if ((flags & ((JSUint32)1 << (2))) && | |
34289 | (kid->xml_flags & 0x1)) { | |
34290 | continue; | |
34291 | } | |
34292 | kid2 = DeepCopyInLRS(cx, kid, flags); | |
34293 | if (!kid2) { | |
34294 | to->length = j; | |
34295 | return (JSIntn)0; | |
34296 | } | |
34297 | ||
34298 | if ((flags & ((JSUint32)1 << (2))) && | |
34299 | n > 1 && kid2->xml_class == JSXML_CLASS_TEXT) { | |
34300 | str = ChompXMLWhitespace(cx, kid2->u.value); | |
34301 | if (!str) { | |
34302 | to->length = j; | |
34303 | return (JSIntn)0; | |
34304 | } | |
34305 | kid2->u.value = str; | |
34306 | } | |
34307 | ||
34308 | do { if ((to)->length <= (j)) (to)->length = (j) + 1; ((to)->vector[j] = (void *)(kid2)); } while (0); | |
34309 | ++j; | |
34310 | if (parent->xml_class != JSXML_CLASS_LIST) | |
34311 | kid2->parent = parent; | |
34312 | } | |
34313 | ||
34314 | if (j < n) | |
34315 | to->trim(); | |
34316 | return (JSIntn)1; | |
34317 | } | |
34318 | ||
34319 | static JSXML * | |
34320 | DeepCopyInLRS(JSContext *cx, JSXML *xml, uintN flags) | |
34321 | { | |
34322 | JSXML *copy; | |
34323 | JSObject *qn; | |
34324 | JSBool ok; | |
34325 | uint32 i, n; | |
34326 | JSObject *ns, *ns2; | |
34327 | ||
34328 | do { int stackDummy_; if (!((jsuword)(&stackDummy_) > cx->stackLimit)) { js_ReportOverRecursed(cx); return __null; } } while (0); | |
34329 | ||
34330 | copy = js_NewXML(cx, JSXMLClass(xml->xml_class)); | |
34331 | if (!copy) | |
34332 | return __null; | |
34333 | qn = xml->name; | |
34334 | if (qn) { | |
34335 | qn = NewXMLQName(cx, qn->getNameURI(), qn->getNamePrefix(), qn->getQNameLocalName()); | |
34336 | if (!qn) { | |
34337 | ok = (JSIntn)0; | |
34338 | goto out; | |
34339 | } | |
34340 | } | |
34341 | copy->name = qn; | |
34342 | copy->xml_flags = xml->xml_flags; | |
34343 | ||
34344 | if ((((xml)->xml_class) >= JSXML_CLASS_ATTRIBUTE)) { | |
34345 | copy->u.value = xml->u.value; | |
34346 | ok = (JSIntn)1; | |
34347 | } else { | |
34348 | ok = DeepCopySetInLRS(cx, &xml->u.list.kids, ©->u.list.kids, copy, flags); | |
34349 | if (!ok) | |
34350 | goto out; | |
34351 | ||
34352 | if (xml->xml_class == JSXML_CLASS_LIST) { | |
34353 | copy->u.list.target = xml->u.list.target; | |
34354 | copy->u.list.targetprop = xml->u.list.targetprop; | |
34355 | } else { | |
34356 | n = xml->u.elem.namespaces.length; | |
34357 | ok = copy->u.elem.namespaces.setCapacity(cx, n); | |
34358 | if (!ok) | |
34359 | goto out; | |
34360 | for (i = 0; i < n; i++) { | |
34361 | ns = (((i) < (&xml->u.elem.namespaces)->length) ? (JSObject *) (&xml->u.elem.namespaces)->vector[i] : __null); | |
34362 | if (!ns) | |
34363 | continue; | |
34364 | ns2 = NewXMLNamespace(cx, ns->getNamePrefix(), ns->getNameURI(), | |
34365 | IsDeclared(ns)); | |
34366 | if (!ns2) { | |
34367 | copy->u.elem.namespaces.length = i; | |
34368 | ok = (JSIntn)0; | |
34369 | goto out; | |
34370 | } | |
34371 | do { if ((©->u.elem.namespaces)->length <= (i)) (©->u.elem.namespaces)->length = (i) + 1; ((©->u.elem.namespaces)->vector[i] = (void *)(ns2)); } while (0); | |
34372 | } | |
34373 | ||
34374 | ok = DeepCopySetInLRS(cx, &xml->u.elem.attrs, ©->u.elem.attrs, copy, | |
34375 | 0); | |
34376 | if (!ok) | |
34377 | goto out; | |
34378 | } | |
34379 | } | |
34380 | ||
34381 | out: | |
34382 | if (!ok) | |
34383 | return __null; | |
34384 | return copy; | |
34385 | } | |
34386 | ||
34387 | ||
34388 | static void | |
34389 | DeleteByIndex(JSContext *cx, JSXML *xml, uint32 index) | |
34390 | { | |
34391 | JSXML *kid; | |
34392 | ||
34393 | if ((((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE) && index < xml->u.list.kids.length) { | |
34394 | kid = (((index) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[index] : __null); | |
34395 | if (kid) | |
34396 | kid->parent = __null; | |
34397 | XMLArrayDelete(cx, &xml->u.list.kids, index, (JSIntn)1); | |
34398 | } | |
34399 | } | |
34400 | ||
34401 | typedef JSBool (*JSXMLNameMatcher)(JSObject *nameqn, JSXML *xml); | |
34402 | ||
34403 | static JSBool | |
34404 | MatchAttrName(JSObject *nameqn, JSXML *attr) | |
34405 | { | |
34406 | JSObject *attrqn = attr->name; | |
34407 | JSLinearString *localName = nameqn->getQNameLocalName(); | |
34408 | JSLinearString *uri; | |
34409 | ||
34410 | return (((localName)->length() == 1 && *(localName)->chars() == '*') || | |
34411 | EqualStrings(attrqn->getQNameLocalName(), localName)) && | |
34412 | (!(uri = nameqn->getNameURI()) || | |
34413 | EqualStrings(attrqn->getNameURI(), uri)); | |
34414 | } | |
34415 | ||
34416 | static JSBool | |
34417 | MatchElemName(JSObject *nameqn, JSXML *elem) | |
34418 | { | |
34419 | JSLinearString *localName = nameqn->getQNameLocalName(); | |
34420 | JSLinearString *uri; | |
34421 | ||
34422 | return (((localName)->length() == 1 && *(localName)->chars() == '*') || | |
34423 | (elem->xml_class == JSXML_CLASS_ELEMENT && | |
34424 | EqualStrings(elem->name->getQNameLocalName(), localName))) && | |
34425 | (!(uri = nameqn->getNameURI()) || | |
34426 | (elem->xml_class == JSXML_CLASS_ELEMENT && | |
34427 | EqualStrings(elem->name->getNameURI(), uri))); | |
34428 | } | |
34429 | ||
34430 | ||
34431 | static JSBool | |
34432 | DescendantsHelper(JSContext *cx, JSXML *xml, JSObject *nameqn, JSXML *list) | |
34433 | { | |
34434 | uint32 i, n; | |
34435 | JSXML *attr, *kid; | |
34436 | ||
34437 | do { int stackDummy_; if (!((jsuword)(&stackDummy_) > cx->stackLimit)) { js_ReportOverRecursed(cx); return (JSIntn)0; } } while (0); | |
34438 | ||
34439 | if (xml->xml_class == JSXML_CLASS_ELEMENT && | |
34440 | nameqn->getClass() == &js_AttributeNameClass) { | |
34441 | for (i = 0, n = xml->u.elem.attrs.length; i < n; i++) { | |
34442 | attr = (((i) < (&xml->u.elem.attrs)->length) ? (JSXML *) (&xml->u.elem.attrs)->vector[i] : __null); | |
34443 | if (attr && MatchAttrName(nameqn, attr)) { | |
34444 | if (!Append(cx, list, attr)) | |
34445 | return (JSIntn)0; | |
34446 | } | |
34447 | } | |
34448 | } | |
34449 | ||
34450 | for (i = 0, n = ((((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (xml)->u.list.kids.length : 0); i < n; i++) { | |
34451 | kid = (((i) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[i] : __null); | |
34452 | if (!kid) | |
34453 | continue; | |
34454 | if (nameqn->getClass() != &js_AttributeNameClass && | |
34455 | MatchElemName(nameqn, kid)) { | |
34456 | if (!Append(cx, list, kid)) | |
34457 | return (JSIntn)0; | |
34458 | } | |
34459 | if (!DescendantsHelper(cx, kid, nameqn, list)) | |
34460 | return (JSIntn)0; | |
34461 | } | |
34462 | return (JSIntn)1; | |
34463 | } | |
34464 | ||
34465 | static JSXML * | |
34466 | Descendants(JSContext *cx, JSXML *xml, jsval id) | |
34467 | { | |
34468 | jsid funid; | |
34469 | JSObject *nameqn; | |
34470 | JSObject *listobj; | |
34471 | JSXML *list, *kid; | |
34472 | uint32 i, n; | |
34473 | JSBool ok; | |
34474 | ||
34475 | nameqn = ToXMLName(cx, id, &funid); | |
34476 | if (!nameqn) | |
34477 | return __null; | |
34478 | ||
34479 | listobj = js_NewXMLObject(cx, JSXML_CLASS_LIST); | |
34480 | if (!listobj) | |
34481 | return __null; | |
34482 | list = (JSXML *) listobj->getPrivate(); | |
34483 | if (!JSID_IS_VOID(funid)) | |
34484 | return list; | |
34485 | ||
34486 | ||
34487 | ||
34488 | ||
34489 | ||
34490 | ||
34491 | ||
34492 | list->name = nameqn; | |
34493 | if (!js_EnterLocalRootScope(cx)) | |
34494 | return __null; | |
34495 | if (xml->xml_class == JSXML_CLASS_LIST) { | |
34496 | ok = (JSIntn)1; | |
34497 | for (i = 0, n = xml->u.list.kids.length; i < n; i++) { | |
34498 | kid = (((i) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[i] : __null); | |
34499 | if (kid && kid->xml_class == JSXML_CLASS_ELEMENT) { | |
34500 | ok = DescendantsHelper(cx, kid, nameqn, list); | |
34501 | if (!ok) | |
34502 | break; | |
34503 | } | |
34504 | } | |
34505 | } else { | |
34506 | ok = DescendantsHelper(cx, xml, nameqn, list); | |
34507 | } | |
34508 | js_LeaveLocalRootScopeWithResult(cx, list); | |
34509 | if (!ok) | |
34510 | return __null; | |
34511 | list->name = __null; | |
34512 | return list; | |
34513 | } | |
34514 | ||
34515 | ||
34516 | static JSBool | |
34517 | XMLEquals(JSContext *cx, JSXML *xml, JSXML *vxml, JSBool *bp) | |
34518 | { | |
34519 | JSObject *qn, *vqn; | |
34520 | uint32 i, j, n; | |
34521 | JSXML *kid, *vkid, *attr, *vattr; | |
34522 | JSObject *xobj, *vobj; | |
34523 | ||
34524 | retry: | |
34525 | if (xml->xml_class != vxml->xml_class) { | |
34526 | if (xml->xml_class == JSXML_CLASS_LIST && xml->u.list.kids.length == 1) { | |
34527 | xml = (((0) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[0] : __null); | |
34528 | if (xml) | |
34529 | goto retry; | |
34530 | } | |
34531 | if (vxml->xml_class == JSXML_CLASS_LIST && vxml->u.list.kids.length == 1) { | |
34532 | vxml = (((0) < (&vxml->u.list.kids)->length) ? (JSXML *) (&vxml->u.list.kids)->vector[0] : __null); | |
34533 | if (vxml) | |
34534 | goto retry; | |
34535 | } | |
34536 | *bp = (JSIntn)0; | |
34537 | return (JSIntn)1; | |
34538 | } | |
34539 | ||
34540 | qn = xml->name; | |
34541 | vqn = vxml->name; | |
34542 | if (qn) { | |
34543 | *bp = vqn && | |
34544 | EqualStrings(qn->getQNameLocalName(), vqn->getQNameLocalName()) && | |
34545 | EqualStrings(qn->getNameURI(), vqn->getNameURI()); | |
34546 | } else { | |
34547 | *bp = vqn == __null; | |
34548 | } | |
34549 | if (!*bp) | |
34550 | return (JSIntn)1; | |
34551 | ||
34552 | if ((((xml)->xml_class) >= JSXML_CLASS_ATTRIBUTE)) { | |
34553 | if (!EqualStrings(cx, xml->u.value, vxml->u.value, bp)) | |
34554 | return (JSIntn)0; | |
34555 | } else if (xml->u.list.kids.length != vxml->u.list.kids.length) { | |
34556 | *bp = (JSIntn)0; | |
34557 | } else { | |
34558 | { | |
34559 | JSXMLArrayCursor cursor(&xml->u.list.kids); | |
34560 | JSXMLArrayCursor vcursor(&vxml->u.list.kids); | |
34561 | for (;;) { | |
34562 | kid = (JSXML *) cursor.getNext(); | |
34563 | vkid = (JSXML *) vcursor.getNext(); | |
34564 | if (!kid || !vkid) { | |
34565 | *bp = !kid && !vkid; | |
34566 | break; | |
34567 | } | |
34568 | xobj = js_GetXMLObject(cx, kid); | |
34569 | vobj = js_GetXMLObject(cx, vkid); | |
34570 | if (!xobj || !vobj || | |
34571 | !js_TestXMLEquality(cx, ObjectValue(*xobj), ObjectValue(*vobj), bp)) | |
34572 | return (JSIntn)0; | |
34573 | if (!*bp) | |
34574 | break; | |
34575 | } | |
34576 | } | |
34577 | ||
34578 | if (*bp && xml->xml_class == JSXML_CLASS_ELEMENT) { | |
34579 | n = xml->u.elem.attrs.length; | |
34580 | if (n != vxml->u.elem.attrs.length) | |
34581 | *bp = (JSIntn)0; | |
34582 | for (i = 0; *bp && i < n; i++) { | |
34583 | attr = (((i) < (&xml->u.elem.attrs)->length) ? (JSXML *) (&xml->u.elem.attrs)->vector[i] : __null); | |
34584 | if (!attr) | |
34585 | continue; | |
34586 | j = XMLArrayFindMember(&vxml->u.elem.attrs, (void *)(attr), attr_identity); | |
34587 | if (j == ((uint32) -1)) { | |
34588 | *bp = (JSIntn)0; | |
34589 | break; | |
34590 | } | |
34591 | vattr = (((j) < (&vxml->u.elem.attrs)->length) ? (JSXML *) (&vxml->u.elem.attrs)->vector[j] : __null); | |
34592 | if (!vattr) | |
34593 | continue; | |
34594 | if (!EqualStrings(cx, attr->u.value, vattr->u.value, bp)) | |
34595 | return (JSIntn)0; | |
34596 | } | |
34597 | } | |
34598 | } | |
34599 | ||
34600 | return (JSIntn)1; | |
34601 | } | |
34602 | ||
34603 | ||
34604 | static JSBool | |
34605 | Equals(JSContext *cx, JSXML *xml, jsval v, JSBool *bp) | |
34606 | { | |
34607 | JSObject *vobj; | |
34608 | JSXML *vxml; | |
34609 | ||
34610 | if (JSVAL_IS_PRIMITIVE(v)) { | |
34611 | *bp = (JSIntn)0; | |
34612 | if (xml->xml_class == JSXML_CLASS_LIST) { | |
34613 | if (xml->u.list.kids.length == 1) { | |
34614 | vxml = (((0) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[0] : __null); | |
34615 | if (!vxml) | |
34616 | return (JSIntn)1; | |
34617 | vobj = js_GetXMLObject(cx, vxml); | |
34618 | if (!vobj) | |
34619 | return (JSIntn)0; | |
34620 | return js_TestXMLEquality(cx, ObjectValue(*vobj), Valueify(v), bp); | |
34621 | } | |
34622 | if (JSVAL_IS_VOID(v) && xml->u.list.kids.length == 0) | |
34623 | *bp = (JSIntn)1; | |
34624 | } | |
34625 | } else { | |
34626 | vobj = JSVAL_TO_OBJECT(v); | |
34627 | if (!vobj->isXML()) { | |
34628 | *bp = (JSIntn)0; | |
34629 | } else { | |
34630 | vxml = (JSXML *) vobj->getPrivate(); | |
34631 | if (!XMLEquals(cx, xml, vxml, bp)) | |
34632 | return (JSIntn)0; | |
34633 | } | |
34634 | } | |
34635 | return (JSIntn)1; | |
34636 | } | |
34637 | ||
34638 | static JSBool | |
34639 | CheckCycle(JSContext *cx, JSXML *xml, JSXML *kid) | |
34640 | { | |
34641 | ((void) 0); | |
34642 | ||
34643 | do { | |
34644 | if (xml == kid) { | |
34645 | JS_ReportErrorNumber(cx, js_GetErrorMessage, __null, | |
34646 | JSMSG_CYCLIC_VALUE, js_XML_str); | |
34647 | return (JSIntn)0; | |
34648 | } | |
34649 | } while ((xml = xml->parent) != __null); | |
34650 | ||
34651 | return (JSIntn)1; | |
34652 | } | |
34653 | ||
34654 | ||
34655 | static JSBool | |
34656 | Insert(JSContext *cx, JSXML *xml, uint32 i, jsval v) | |
34657 | { | |
34658 | uint32 j, n; | |
34659 | JSXML *vxml, *kid; | |
34660 | JSObject *vobj; | |
34661 | JSString *str; | |
34662 | ||
34663 | if (!(((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE)) | |
34664 | return (JSIntn)1; | |
34665 | ||
34666 | n = 1; | |
34667 | vxml = __null; | |
34668 | if (!JSVAL_IS_PRIMITIVE(v)) { | |
34669 | vobj = JSVAL_TO_OBJECT(v); | |
34670 | if (vobj->isXML()) { | |
34671 | vxml = (JSXML *) vobj->getPrivate(); | |
34672 | if (vxml->xml_class == JSXML_CLASS_LIST) { | |
34673 | n = vxml->u.list.kids.length; | |
34674 | if (n == 0) | |
34675 | return (JSIntn)1; | |
34676 | for (j = 0; j < n; j++) { | |
34677 | kid = (((j) < (&vxml->u.list.kids)->length) ? (JSXML *) (&vxml->u.list.kids)->vector[j] : __null); | |
34678 | if (!kid) | |
34679 | continue; | |
34680 | if (!CheckCycle(cx, xml, kid)) | |
34681 | return (JSIntn)0; | |
34682 | } | |
34683 | } else if (vxml->xml_class == JSXML_CLASS_ELEMENT) { | |
34684 | ||
34685 | if (!CheckCycle(cx, xml, vxml)) | |
34686 | return (JSIntn)0; | |
34687 | } | |
34688 | } | |
34689 | } | |
34690 | if (!vxml) { | |
34691 | str = js_ValueToString(cx, Valueify(v)); | |
34692 | if (!str) | |
34693 | return (JSIntn)0; | |
34694 | ||
34695 | vxml = js_NewXML(cx, JSXML_CLASS_TEXT); | |
34696 | if (!vxml) | |
34697 | return (JSIntn)0; | |
34698 | vxml->u.value = str; | |
34699 | } | |
34700 | ||
34701 | if (i > xml->u.list.kids.length) | |
34702 | i = xml->u.list.kids.length; | |
34703 | ||
34704 | if (!XMLArrayInsert(cx, &xml->u.list.kids, i, n)) | |
34705 | return (JSIntn)0; | |
34706 | ||
34707 | if (vxml->xml_class == JSXML_CLASS_LIST) { | |
34708 | for (j = 0; j < n; j++) { | |
34709 | kid = (((j) < (&vxml->u.list.kids)->length) ? (JSXML *) (&vxml->u.list.kids)->vector[j] : __null); | |
34710 | if (!kid) | |
34711 | continue; | |
34712 | kid->parent = xml; | |
34713 | do { if ((&xml->u.list.kids)->length <= (i + j)) (&xml->u.list.kids)->length = (i + j) + 1; ((&xml->u.list.kids)->vector[i + j] = (void *)(kid)); } while (0); | |
34714 | ||
34715 | ||
34716 | } | |
34717 | } else { | |
34718 | vxml->parent = xml; | |
34719 | do { if ((&xml->u.list.kids)->length <= (i)) (&xml->u.list.kids)->length = (i) + 1; ((&xml->u.list.kids)->vector[i] = (void *)(vxml)); } while (0); | |
34720 | } | |
34721 | return (JSIntn)1; | |
34722 | } | |
34723 | ||
34724 | static JSBool | |
34725 | IndexToId(JSContext *cx, uint32 index, jsid *idp) | |
34726 | { | |
34727 | JSAtom *atom; | |
34728 | JSString *str; | |
34729 | ||
34730 | if (index <= ((1 << 30) - 1)) { | |
34731 | *idp = INT_TO_JSID(index); | |
34732 | } else { | |
34733 | str = js_NumberToString(cx, (jsdouble) index); | |
34734 | if (!str) | |
34735 | return (JSIntn)0; | |
34736 | atom = js_AtomizeString(cx, str, 0); | |
34737 | if (!atom) | |
34738 | return (JSIntn)0; | |
34739 | *idp = ATOM_TO_JSID(atom); | |
34740 | } | |
34741 | return (JSIntn)1; | |
34742 | } | |
34743 | ||
34744 | ||
34745 | static JSBool | |
34746 | Replace(JSContext *cx, JSXML *xml, uint32 i, jsval v) | |
34747 | { | |
34748 | uint32 n; | |
34749 | JSXML *vxml, *kid; | |
34750 | JSObject *vobj; | |
34751 | JSString *str; | |
34752 | ||
34753 | if (!(((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE)) | |
34754 | return (JSIntn)1; | |
34755 | ||
34756 | ||
34757 | ||
34758 | ||
34759 | ||
34760 | ||
34761 | n = xml->u.list.kids.length; | |
34762 | if (i > n) | |
34763 | i = n; | |
34764 | ||
34765 | vxml = __null; | |
34766 | if (!JSVAL_IS_PRIMITIVE(v)) { | |
34767 | vobj = JSVAL_TO_OBJECT(v); | |
34768 | if (vobj->isXML()) | |
34769 | vxml = (JSXML *) vobj->getPrivate(); | |
34770 | } | |
34771 | ||
34772 | switch (vxml ? JSXMLClass(vxml->xml_class) : JSXML_CLASS_LIMIT) { | |
34773 | case JSXML_CLASS_ELEMENT: | |
34774 | ||
34775 | if (!CheckCycle(cx, xml, vxml)) | |
34776 | return (JSIntn)0; | |
34777 | case JSXML_CLASS_COMMENT: | |
34778 | case JSXML_CLASS_PROCESSING_INSTRUCTION: | |
34779 | case JSXML_CLASS_TEXT: | |
34780 | goto do_replace; | |
34781 | ||
34782 | case JSXML_CLASS_LIST: | |
34783 | if (i < n) | |
34784 | DeleteByIndex(cx, xml, i); | |
34785 | if (!Insert(cx, xml, i, v)) | |
34786 | return (JSIntn)0; | |
34787 | break; | |
34788 | ||
34789 | default: | |
34790 | str = js_ValueToString(cx, Valueify(v)); | |
34791 | if (!str) | |
34792 | return (JSIntn)0; | |
34793 | ||
34794 | vxml = js_NewXML(cx, JSXML_CLASS_TEXT); | |
34795 | if (!vxml) | |
34796 | return (JSIntn)0; | |
34797 | vxml->u.value = str; | |
34798 | ||
34799 | do_replace: | |
34800 | vxml->parent = xml; | |
34801 | if (i < n) { | |
34802 | kid = (((i) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[i] : __null); | |
34803 | if (kid) | |
34804 | kid->parent = __null; | |
34805 | } | |
34806 | if (!XMLArrayAddMember(cx, &xml->u.list.kids, i, (void *)(vxml))) | |
34807 | return (JSIntn)0; | |
34808 | break; | |
34809 | } | |
34810 | ||
34811 | return (JSIntn)1; | |
34812 | } | |
34813 | ||
34814 | ||
34815 | static void | |
34816 | DeleteNamedProperty(JSContext *cx, JSXML *xml, JSObject *nameqn, | |
34817 | JSBool attributes) | |
34818 | { | |
34819 | JSXMLArray *array; | |
34820 | uint32 index, deleteCount; | |
34821 | JSXML *kid; | |
34822 | JSXMLNameMatcher matcher; | |
34823 | ||
34824 | if (xml->xml_class == JSXML_CLASS_LIST) { | |
34825 | array = &xml->u.list.kids; | |
34826 | for (index = 0; index < array->length; index++) { | |
34827 | kid = (((index) < (array)->length) ? (JSXML *) (array)->vector[index] : __null); | |
34828 | if (kid && kid->xml_class == JSXML_CLASS_ELEMENT) | |
34829 | DeleteNamedProperty(cx, kid, nameqn, attributes); | |
34830 | } | |
34831 | } else if (xml->xml_class == JSXML_CLASS_ELEMENT) { | |
34832 | if (attributes) { | |
34833 | array = &xml->u.elem.attrs; | |
34834 | matcher = MatchAttrName; | |
34835 | } else { | |
34836 | array = &xml->u.list.kids; | |
34837 | matcher = MatchElemName; | |
34838 | } | |
34839 | deleteCount = 0; | |
34840 | for (index = 0; index < array->length; index++) { | |
34841 | kid = (((index) < (array)->length) ? (JSXML *) (array)->vector[index] : __null); | |
34842 | if (kid && matcher(nameqn, kid)) { | |
34843 | kid->parent = __null; | |
34844 | XMLArrayDelete(cx, array, index, (JSIntn)0); | |
34845 | ++deleteCount; | |
34846 | } else if (deleteCount != 0) { | |
34847 | do { if ((array)->length <= (index - deleteCount)) (array)->length = (index - deleteCount) + 1; ((array)->vector[index - deleteCount] = (void *)(array->vector[index])); } while (0) | |
34848 | ||
34849 | ; | |
34850 | } | |
34851 | } | |
34852 | array->length -= deleteCount; | |
34853 | } | |
34854 | } | |
34855 | ||
34856 | ||
34857 | static void | |
34858 | DeleteListElement(JSContext *cx, JSXML *xml, uint32 index) | |
34859 | { | |
34860 | JSXML *kid, *parent; | |
34861 | uint32 kidIndex; | |
34862 | ||
34863 | ((void) 0); | |
34864 | ||
34865 | if (index < xml->u.list.kids.length) { | |
34866 | kid = (((index) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[index] : __null); | |
34867 | if (kid) { | |
34868 | parent = kid->parent; | |
34869 | if (parent) { | |
34870 | ((void) 0); | |
34871 | ((void) 0); | |
34872 | ||
34873 | if (kid->xml_class == JSXML_CLASS_ATTRIBUTE) { | |
34874 | DeleteNamedProperty(cx, parent, kid->name, (JSIntn)1); | |
34875 | } else { | |
34876 | kidIndex = XMLArrayFindMember(&parent->u.list.kids, (void *)(kid), __null) | |
34877 | ; | |
34878 | ((void) 0); | |
34879 | DeleteByIndex(cx, parent, kidIndex); | |
34880 | } | |
34881 | } | |
34882 | XMLArrayDelete(cx, &xml->u.list.kids, index, (JSIntn)1); | |
34883 | } | |
34884 | } | |
34885 | } | |
34886 | ||
34887 | static JSBool | |
34888 | SyncInScopeNamespaces(JSContext *cx, JSXML *xml) | |
34889 | { | |
34890 | JSXMLArray *nsarray; | |
34891 | uint32 i, n; | |
34892 | JSObject *ns; | |
34893 | ||
34894 | nsarray = &xml->u.elem.namespaces; | |
34895 | while ((xml = xml->parent) != __null) { | |
34896 | for (i = 0, n = xml->u.elem.namespaces.length; i < n; i++) { | |
34897 | ns = (((i) < (&xml->u.elem.namespaces)->length) ? (JSObject *) (&xml->u.elem.namespaces)->vector[i] : __null); | |
34898 | if (ns && !(XMLArrayFindMember(nsarray, (void *)(ns), namespace_identity) != ((uint32) -1))) { | |
34899 | if (!XMLArrayAddMember(cx, nsarray, (nsarray)->length, (void *)((ns)))) | |
34900 | return (JSIntn)0; | |
34901 | } | |
34902 | } | |
34903 | } | |
34904 | return (JSIntn)1; | |
34905 | } | |
34906 | ||
34907 | static JSBool | |
34908 | GetNamedProperty(JSContext *cx, JSXML *xml, JSObject* nameqn, JSXML *list) | |
34909 | { | |
34910 | JSXMLArray *array; | |
34911 | JSXMLNameMatcher matcher; | |
34912 | JSBool attrs; | |
34913 | ||
34914 | if (xml->xml_class == JSXML_CLASS_LIST) { | |
34915 | JSXMLArrayCursor cursor(&xml->u.list.kids); | |
34916 | while (JSXML *kid = (JSXML *) cursor.getNext()) { | |
34917 | if (kid->xml_class == JSXML_CLASS_ELEMENT && | |
34918 | !GetNamedProperty(cx, kid, nameqn, list)) { | |
34919 | return (JSIntn)0; | |
34920 | } | |
34921 | } | |
34922 | } else if (xml->xml_class == JSXML_CLASS_ELEMENT) { | |
34923 | attrs = (nameqn->getClass() == &js_AttributeNameClass); | |
34924 | if (attrs) { | |
34925 | array = &xml->u.elem.attrs; | |
34926 | matcher = MatchAttrName; | |
34927 | } else { | |
34928 | array = &xml->u.list.kids; | |
34929 | matcher = MatchElemName; | |
34930 | } | |
34931 | ||
34932 | JSXMLArrayCursor cursor(array); | |
34933 | while (JSXML *kid = (JSXML *) cursor.getNext()) { | |
34934 | if (matcher(nameqn, kid)) { | |
34935 | if (!attrs && | |
34936 | kid->xml_class == JSXML_CLASS_ELEMENT && | |
34937 | !SyncInScopeNamespaces(cx, kid)) { | |
34938 | return (JSIntn)0; | |
34939 | } | |
34940 | if (!Append(cx, list, kid)) | |
34941 | return (JSIntn)0; | |
34942 | } | |
34943 | } | |
34944 | } | |
34945 | ||
34946 | return (JSIntn)1; | |
34947 | } | |
34948 | ||
34949 | ||
34950 | static JSBool | |
34951 | GetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp) | |
34952 | { | |
34953 | JSXML *xml, *list, *kid; | |
34954 | uint32 index; | |
34955 | JSObject *kidobj, *listobj; | |
34956 | JSObject *nameqn; | |
34957 | jsid funid; | |
34958 | ||
34959 | xml = (JSXML *) GetInstancePrivate(cx, obj, &js_XMLClass, __null); | |
34960 | if (!xml) | |
34961 | return true; | |
34962 | ||
34963 | if (js_IdIsIndex(id, &index)) { | |
34964 | if (!(((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE)) { | |
34965 | *vp = (index == 0) ? OBJECT_TO_JSVAL(obj) : ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0)); | |
34966 | } else { | |
34967 | ||
34968 | ||
34969 | ||
34970 | ||
34971 | ||
34972 | ||
34973 | ||
34974 | if (index < xml->u.list.kids.length) { | |
34975 | kid = (((index) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[index] : __null); | |
34976 | if (!kid) { | |
34977 | *vp = ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0)); | |
34978 | return true; | |
34979 | } | |
34980 | kidobj = js_GetXMLObject(cx, kid); | |
34981 | if (!kidobj) | |
34982 | return false; | |
34983 | ||
34984 | *vp = OBJECT_TO_JSVAL(kidobj); | |
34985 | } else { | |
34986 | *vp = ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0)); | |
34987 | } | |
34988 | } | |
34989 | return true; | |
34990 | } | |
34991 | ||
34992 | ||
34993 | ||
34994 | ||
34995 | nameqn = ToXMLName(cx, IdToJsval(id), &funid); | |
34996 | if (!nameqn) | |
34997 | return false; | |
34998 | if (!JSID_IS_VOID(funid)) | |
34999 | return GetXMLFunction(cx, obj, funid, vp); | |
35000 | ||
35001 | jsval roots[2] = { OBJECT_TO_JSVAL(nameqn), ((((uint64)(uint32)(JSVAL_TAG_NULL)) << 47) | (0)) }; | |
35002 | AutoArrayRooter tvr(cx, (sizeof (roots) / sizeof (roots)[0]), Valueify(roots)); | |
35003 | ||
35004 | listobj = js_NewXMLObject(cx, JSXML_CLASS_LIST); | |
35005 | if (!listobj) | |
35006 | return false; | |
35007 | ||
35008 | roots[1] = OBJECT_TO_JSVAL(listobj); | |
35009 | ||
35010 | list = (JSXML *) listobj->getPrivate(); | |
35011 | if (!GetNamedProperty(cx, xml, nameqn, list)) | |
35012 | return false; | |
35013 | # 3800 "jsxml.cpp" | |
35014 | list->u.list.target = xml; | |
35015 | list->u.list.targetprop = nameqn; | |
35016 | *vp = OBJECT_TO_JSVAL(listobj); | |
35017 | return true; | |
35018 | } | |
35019 | ||
35020 | static JSXML * | |
35021 | CopyOnWrite(JSContext *cx, JSXML *xml, JSObject *obj) | |
35022 | { | |
35023 | ((void) 0); | |
35024 | ||
35025 | xml = DeepCopy(cx, xml, obj, 0); | |
35026 | if (!xml) | |
35027 | return __null; | |
35028 | ||
35029 | ((void) 0); | |
35030 | return xml; | |
35031 | } | |
35032 | ||
35033 | ||
35034 | ||
35035 | ||
35036 | static JSString * | |
35037 | KidToString(JSContext *cx, JSXML *xml, uint32 index) | |
35038 | { | |
35039 | JSXML *kid; | |
35040 | JSObject *kidobj; | |
35041 | ||
35042 | kid = (((index) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[index] : __null); | |
35043 | if (!kid) | |
35044 | return cx->runtime->emptyString; | |
35045 | kidobj = js_GetXMLObject(cx, kid); | |
35046 | if (!kidobj) | |
35047 | return __null; | |
35048 | return js_ValueToString(cx, ObjectValue(*kidobj)); | |
35049 | } | |
35050 | ||
35051 | ||
35052 | static JSBool | |
35053 | ResolveValue(JSContext *cx, JSXML *list, JSXML **result); | |
35054 | ||
35055 | ||
35056 | static JSBool | |
35057 | PutProperty(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp) | |
35058 | { | |
35059 | JSBool ok, primitiveAssign; | |
35060 | enum { OBJ_ROOT, ID_ROOT, VAL_ROOT }; | |
35061 | JSXML *xml, *vxml, *rxml, *kid, *attr, *parent, *copy, *kid2, *match; | |
35062 | JSObject *vobj, *nameobj, *attrobj, *parentobj, *kidobj, *copyobj; | |
35063 | JSObject *targetprop, *nameqn, *attrqn; | |
35064 | uint32 index, i, j, k, n, q, matchIndex; | |
35065 | jsval attrval, nsval; | |
35066 | jsid funid; | |
35067 | JSObject *ns; | |
35068 | ||
35069 | xml = (JSXML *) GetInstancePrivate(cx, obj, &js_XMLClass, __null); | |
35070 | if (!xml) | |
35071 | return (JSIntn)1; | |
35072 | ||
35073 | xml = (xml->object == obj ? xml : CopyOnWrite(cx, xml, obj)); | |
35074 | if (!xml) | |
35075 | return (JSIntn)0; | |
35076 | ||
35077 | ||
35078 | vxml = __null; | |
35079 | if (!JSVAL_IS_PRIMITIVE(*vp)) { | |
35080 | vobj = JSVAL_TO_OBJECT(*vp); | |
35081 | if (vobj->isXML()) | |
35082 | vxml = (JSXML *) vobj->getPrivate(); | |
35083 | } | |
35084 | ||
35085 | ok = js_EnterLocalRootScope(cx); | |
35086 | if (!ok) | |
35087 | return (JSIntn)0; | |
35088 | ||
35089 | ((void) 0); | |
35090 | jsval roots[3]; | |
35091 | roots[OBJ_ROOT] = OBJECT_TO_JSVAL(obj); | |
35092 | roots[ID_ROOT] = IdToJsval(id); | |
35093 | roots[VAL_ROOT] = *vp; | |
35094 | AutoArrayRooter tvr(cx, (sizeof (roots) / sizeof (roots)[0]), Valueify(roots)); | |
35095 | ||
35096 | if (js_IdIsIndex(id, &index)) { | |
35097 | if (xml->xml_class != JSXML_CLASS_LIST) { | |
35098 | ||
35099 | ReportBadXMLName(cx, IdToValue(id)); | |
35100 | goto bad; | |
35101 | } | |
35102 | ||
35103 | ||
35104 | ||
35105 | ||
35106 | i = index; | |
35107 | ||
35108 | ||
35109 | if (xml->u.list.target) { | |
35110 | ok = ResolveValue(cx, xml->u.list.target, &rxml); | |
35111 | if (!ok) | |
35112 | goto out; | |
35113 | if (!rxml) | |
35114 | goto out; | |
35115 | ((void) 0); | |
35116 | } else { | |
35117 | rxml = __null; | |
35118 | } | |
35119 | ||
35120 | ||
35121 | if (index >= xml->u.list.kids.length) { | |
35122 | ||
35123 | if (rxml) { | |
35124 | if (rxml->xml_class == JSXML_CLASS_LIST) { | |
35125 | if (rxml->u.list.kids.length != 1) | |
35126 | goto out; | |
35127 | rxml = (((0) < (&rxml->u.list.kids)->length) ? (JSXML *) (&rxml->u.list.kids)->vector[0] : __null); | |
35128 | if (!rxml) | |
35129 | goto out; | |
35130 | ok = js_GetXMLObject(cx, rxml) != __null; | |
35131 | if (!ok) | |
35132 | goto out; | |
35133 | } | |
35134 | # 3936 "jsxml.cpp" | |
35135 | if (!(((rxml)->xml_class) < JSXML_CLASS_ATTRIBUTE)) | |
35136 | goto out; | |
35137 | } | |
35138 | ||
35139 | ||
35140 | targetprop = xml->u.list.targetprop; | |
35141 | if (!targetprop || ((targetprop->getQNameLocalName())->length() == 1 && *(targetprop->getQNameLocalName())->chars() == '*')) { | |
35142 | ||
35143 | kid = js_NewXML(cx, JSXML_CLASS_TEXT); | |
35144 | if (!kid) | |
35145 | goto bad; | |
35146 | } else { | |
35147 | nameobj = targetprop; | |
35148 | if (nameobj->getClass() == &js_AttributeNameClass) { | |
35149 | ||
35150 | ||
35151 | ||
35152 | ||
35153 | ||
35154 | ok = GetProperty(cx, rxml->object, id, &attrval); | |
35155 | if (!ok) | |
35156 | goto out; | |
35157 | if (JSVAL_IS_PRIMITIVE(attrval)) | |
35158 | goto out; | |
35159 | attrobj = JSVAL_TO_OBJECT(attrval); | |
35160 | attr = (JSXML *) attrobj->getPrivate(); | |
35161 | if (((((attr)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (attr)->u.list.kids.length : 0) != 0) | |
35162 | goto out; | |
35163 | ||
35164 | kid = js_NewXML(cx, JSXML_CLASS_ATTRIBUTE); | |
35165 | } else { | |
35166 | ||
35167 | kid = js_NewXML(cx, JSXML_CLASS_ELEMENT); | |
35168 | } | |
35169 | if (!kid) | |
35170 | goto bad; | |
35171 | ||
35172 | ||
35173 | kid->name = targetprop; | |
35174 | } | |
35175 | ||
35176 | ||
35177 | kid->parent = rxml; | |
35178 | ||
35179 | ||
35180 | i = xml->u.list.kids.length; | |
35181 | if (kid->xml_class != JSXML_CLASS_ATTRIBUTE) { | |
35182 | ||
35183 | ||
35184 | ||
35185 | ||
35186 | ||
35187 | ||
35188 | if (rxml) { | |
35189 | ((void) 0); | |
35190 | n = rxml->u.list.kids.length; | |
35191 | j = n - 1; | |
35192 | if (n != 0 && i != 0) { | |
35193 | for (n = j, j = 0; j < n; j++) { | |
35194 | if (rxml->u.list.kids.vector[j] == | |
35195 | xml->u.list.kids.vector[i-1]) { | |
35196 | break; | |
35197 | } | |
35198 | } | |
35199 | } | |
35200 | ||
35201 | kidobj = js_GetXMLObject(cx, kid); | |
35202 | if (!kidobj) | |
35203 | goto bad; | |
35204 | ok = Insert(cx, rxml, j + 1, OBJECT_TO_JSVAL(kidobj)); | |
35205 | if (!ok) | |
35206 | goto out; | |
35207 | } | |
35208 | ||
35209 | ||
35210 | ||
35211 | ||
35212 | ||
35213 | ||
35214 | if (vxml) { | |
35215 | kid->name = (vxml->xml_class == JSXML_CLASS_LIST) | |
35216 | ? vxml->u.list.targetprop | |
35217 | : vxml->name; | |
35218 | } | |
35219 | } | |
35220 | ||
35221 | ||
35222 | ok = Append(cx, xml, kid); | |
35223 | if (!ok) | |
35224 | goto out; | |
35225 | } | |
35226 | ||
35227 | ||
35228 | if (!vxml || | |
35229 | vxml->xml_class == JSXML_CLASS_TEXT || | |
35230 | vxml->xml_class == JSXML_CLASS_ATTRIBUTE) { | |
35231 | ok = JS_ConvertValue(cx, *vp, JSTYPE_STRING, vp); | |
35232 | if (!ok) | |
35233 | goto out; | |
35234 | roots[VAL_ROOT] = *vp; | |
35235 | } | |
35236 | ||
35237 | ||
35238 | kid = (((i) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[i] : __null); | |
35239 | if (!kid) | |
35240 | goto out; | |
35241 | parent = kid->parent; | |
35242 | if (kid->xml_class == JSXML_CLASS_ATTRIBUTE) { | |
35243 | nameobj = kid->name; | |
35244 | if (nameobj->getClass() != &js_AttributeNameClass) { | |
35245 | nameobj = NewXMLAttributeName(cx, nameobj->getNameURI(), nameobj->getNamePrefix(), | |
35246 | nameobj->getQNameLocalName()); | |
35247 | if (!nameobj) | |
35248 | goto bad; | |
35249 | } | |
35250 | id = OBJECT_TO_JSID(nameobj); | |
35251 | ||
35252 | if (parent) { | |
35253 | ||
35254 | parentobj = js_GetXMLObject(cx, parent); | |
35255 | if (!parentobj) | |
35256 | goto bad; | |
35257 | ok = PutProperty(cx, parentobj, id, strict, vp); | |
35258 | if (!ok) | |
35259 | goto out; | |
35260 | ||
35261 | ||
35262 | ok = GetProperty(cx, parentobj, id, vp); | |
35263 | if (!ok) | |
35264 | goto out; | |
35265 | attr = (JSXML *) JSVAL_TO_OBJECT(*vp)->getPrivate(); | |
35266 | ||
35267 | ||
35268 | if (attr->u.list.kids.length != 0) | |
35269 | xml->u.list.kids.vector[i] = attr->u.list.kids.vector[0]; | |
35270 | } | |
35271 | } | |
35272 | ||
35273 | ||
35274 | else if (vxml && vxml->xml_class == JSXML_CLASS_LIST) { | |
35275 | # 4085 "jsxml.cpp" | |
35276 | copy = DeepCopyInLRS(cx, vxml, 0); | |
35277 | if (!copy) | |
35278 | goto bad; | |
35279 | copyobj = js_GetXMLObject(cx, copy); | |
35280 | if (!copyobj) | |
35281 | goto bad; | |
35282 | ||
35283 | ((void) 0); | |
35284 | if (parent) { | |
35285 | q = XMLArrayFindMember(&parent->u.list.kids, (void *)(kid), __null); | |
35286 | ((void) 0); | |
35287 | ok = Replace(cx, parent, q, OBJECT_TO_JSVAL(copyobj)); | |
35288 | if (!ok) | |
35289 | goto out; | |
35290 | # 4108 "jsxml.cpp" | |
35291 | } | |
35292 | ||
35293 | ||
35294 | ||
35295 | ||
35296 | ||
35297 | ||
35298 | n = copy->u.list.kids.length; | |
35299 | if (n == 0) { | |
35300 | XMLArrayDelete(cx, &xml->u.list.kids, i, (JSIntn)1); | |
35301 | } else { | |
35302 | ok = XMLArrayInsert(cx, &xml->u.list.kids, i + 1, n - 1); | |
35303 | if (!ok) | |
35304 | goto out; | |
35305 | ||
35306 | for (j = 0; j < n; j++) | |
35307 | xml->u.list.kids.vector[i + j] = copy->u.list.kids.vector[j]; | |
35308 | } | |
35309 | } | |
35310 | ||
35311 | ||
35312 | else if (vxml || (((kid)->xml_class) >= JSXML_CLASS_ATTRIBUTE)) { | |
35313 | if (parent) { | |
35314 | q = XMLArrayFindMember(&parent->u.list.kids, (void *)(kid), __null); | |
35315 | ((void) 0); | |
35316 | ok = Replace(cx, parent, q, *vp); | |
35317 | if (!ok) | |
35318 | goto out; | |
35319 | ||
35320 | vxml = (((q) < (&parent->u.list.kids)->length) ? (JSXML *) (&parent->u.list.kids)->vector[q] : __null); | |
35321 | if (!vxml) | |
35322 | goto out; | |
35323 | roots[VAL_ROOT] = *vp = OBJECT_TO_JSVAL(vxml->object); | |
35324 | } | |
35325 | # 4153 "jsxml.cpp" | |
35326 | if (!vxml) { | |
35327 | ((void) 0); | |
35328 | vobj = ToXML(cx, *vp); | |
35329 | if (!vobj) | |
35330 | goto bad; | |
35331 | roots[VAL_ROOT] = *vp = OBJECT_TO_JSVAL(vobj); | |
35332 | vxml = (JSXML *) vobj->getPrivate(); | |
35333 | } | |
35334 | do { if ((&xml->u.list.kids)->length <= (i)) (&xml->u.list.kids)->length = (i) + 1; ((&xml->u.list.kids)->vector[i] = (void *)(vxml)); } while (0); | |
35335 | } | |
35336 | ||
35337 | ||
35338 | else { | |
35339 | kidobj = js_GetXMLObject(cx, kid); | |
35340 | if (!kidobj) | |
35341 | goto bad; | |
35342 | id = ATOM_TO_JSID(cx->runtime->atomState.starAtom); | |
35343 | ok = PutProperty(cx, kidobj, id, strict, vp); | |
35344 | if (!ok) | |
35345 | goto out; | |
35346 | } | |
35347 | } else { | |
35348 | ||
35349 | ||
35350 | ||
35351 | nameqn = ToXMLName(cx, IdToJsval(id), &funid); | |
35352 | if (!nameqn) | |
35353 | goto bad; | |
35354 | if (!JSID_IS_VOID(funid)) { | |
35355 | ok = js_SetProperty(cx, obj, funid, Valueify(vp), false); | |
35356 | goto out; | |
35357 | } | |
35358 | nameobj = nameqn; | |
35359 | roots[ID_ROOT] = OBJECT_TO_JSVAL(nameobj); | |
35360 | ||
35361 | if (xml->xml_class == JSXML_CLASS_LIST) { | |
35362 | ||
35363 | ||
35364 | ||
35365 | ||
35366 | ||
35367 | n = ((((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (xml)->u.list.kids.length : 0); | |
35368 | if (n > 1) | |
35369 | goto type_error; | |
35370 | if (n == 0) { | |
35371 | ok = ResolveValue(cx, xml, &rxml); | |
35372 | if (!ok) | |
35373 | goto out; | |
35374 | if (!rxml || ((((rxml)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (rxml)->u.list.kids.length : 0) != 1) | |
35375 | goto type_error; | |
35376 | ok = Append(cx, xml, rxml); | |
35377 | if (!ok) | |
35378 | goto out; | |
35379 | } | |
35380 | ((void) 0); | |
35381 | xml = (((0) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[0] : __null); | |
35382 | if (!xml) | |
35383 | goto out; | |
35384 | ((void) 0); | |
35385 | obj = js_GetXMLObject(cx, xml); | |
35386 | if (!obj) | |
35387 | goto bad; | |
35388 | roots[OBJ_ROOT] = OBJECT_TO_JSVAL(obj); | |
35389 | ||
35390 | ||
35391 | } | |
35392 | ||
35393 | ||
35394 | ||
35395 | ||
35396 | ||
35397 | ||
35398 | ||
35399 | if ((((xml)->xml_class) >= JSXML_CLASS_ATTRIBUTE)) | |
35400 | goto out; | |
35401 | ||
35402 | if (!vxml || | |
35403 | vxml->xml_class == JSXML_CLASS_TEXT || | |
35404 | vxml->xml_class == JSXML_CLASS_ATTRIBUTE) { | |
35405 | ok = JS_ConvertValue(cx, *vp, JSTYPE_STRING, vp); | |
35406 | if (!ok) | |
35407 | goto out; | |
35408 | } else { | |
35409 | rxml = DeepCopyInLRS(cx, vxml, 0); | |
35410 | if (!rxml || !js_GetXMLObject(cx, rxml)) | |
35411 | goto bad; | |
35412 | vxml = rxml; | |
35413 | *vp = OBJECT_TO_JSVAL(vxml->object); | |
35414 | } | |
35415 | roots[VAL_ROOT] = *vp; | |
35416 | ||
35417 | ||
35418 | ||
35419 | ||
35420 | ||
35421 | ok = js_GetDefaultXMLNamespace(cx, &nsval); | |
35422 | if (!ok) | |
35423 | goto out; | |
35424 | ||
35425 | if (nameobj->getClass() == &js_AttributeNameClass) { | |
35426 | ||
35427 | if (!js_IsXMLName(cx, OBJECT_TO_JSVAL(nameobj))) | |
35428 | goto out; | |
35429 | ||
35430 | ||
35431 | if (vxml && vxml->xml_class == JSXML_CLASS_LIST) { | |
35432 | n = vxml->u.list.kids.length; | |
35433 | if (n == 0) { | |
35434 | *vp = STRING_TO_JSVAL(cx->runtime->emptyString); | |
35435 | } else { | |
35436 | JSString *left = KidToString(cx, vxml, 0); | |
35437 | if (!left) | |
35438 | goto bad; | |
35439 | ||
35440 | JSString *space = cx->runtime->atomState.spaceAtom; | |
35441 | for (i = 1; i < n; i++) { | |
35442 | left = js_ConcatStrings(cx, left, space); | |
35443 | if (!left) | |
35444 | goto bad; | |
35445 | JSString *right = KidToString(cx, vxml, i); | |
35446 | if (!right) | |
35447 | goto bad; | |
35448 | left = js_ConcatStrings(cx, left, right); | |
35449 | if (!left) | |
35450 | goto bad; | |
35451 | } | |
35452 | ||
35453 | roots[VAL_ROOT] = *vp = STRING_TO_JSVAL(left); | |
35454 | } | |
35455 | } else { | |
35456 | ok = JS_ConvertValue(cx, *vp, JSTYPE_STRING, vp); | |
35457 | if (!ok) | |
35458 | goto out; | |
35459 | roots[VAL_ROOT] = *vp; | |
35460 | } | |
35461 | ||
35462 | ||
35463 | match = __null; | |
35464 | for (i = 0, n = xml->u.elem.attrs.length; i < n; i++) { | |
35465 | attr = (((i) < (&xml->u.elem.attrs)->length) ? (JSXML *) (&xml->u.elem.attrs)->vector[i] : __null); | |
35466 | if (!attr) | |
35467 | continue; | |
35468 | attrqn = attr->name; | |
35469 | if (EqualStrings(attrqn->getQNameLocalName(), nameqn->getQNameLocalName())) { | |
35470 | JSLinearString *uri = nameqn->getNameURI(); | |
35471 | if (!uri || EqualStrings(attrqn->getNameURI(), uri)) { | |
35472 | if (!match) { | |
35473 | match = attr; | |
35474 | } else { | |
35475 | DeleteNamedProperty(cx, xml, attrqn, (JSIntn)1); | |
35476 | --i; | |
35477 | } | |
35478 | } | |
35479 | } | |
35480 | } | |
35481 | ||
35482 | ||
35483 | attr = match; | |
35484 | if (!attr) { | |
35485 | ||
35486 | JSLinearString *uri = nameqn->getNameURI(); | |
35487 | JSLinearString *left, *right; | |
35488 | if (!uri) { | |
35489 | left = right = cx->runtime->emptyString; | |
35490 | } else { | |
35491 | left = uri; | |
35492 | right = nameqn->getNamePrefix(); | |
35493 | } | |
35494 | nameqn = NewXMLQName(cx, left, right, nameqn->getQNameLocalName()); | |
35495 | if (!nameqn) | |
35496 | goto bad; | |
35497 | ||
35498 | ||
35499 | attr = js_NewXML(cx, JSXML_CLASS_ATTRIBUTE); | |
35500 | if (!attr) | |
35501 | goto bad; | |
35502 | attr->parent = xml; | |
35503 | attr->name = nameqn; | |
35504 | ||
35505 | ||
35506 | ok = XMLArrayAddMember(cx, &xml->u.elem.attrs, n, (void *)(attr)); | |
35507 | if (!ok) | |
35508 | goto out; | |
35509 | ||
35510 | ||
35511 | ns = GetNamespace(cx, nameqn, __null); | |
35512 | if (!ns) | |
35513 | goto bad; | |
35514 | ok = AddInScopeNamespace(cx, xml, ns); | |
35515 | if (!ok) | |
35516 | goto out; | |
35517 | } | |
35518 | ||
35519 | ||
35520 | attr->u.value = JSVAL_TO_STRING(*vp); | |
35521 | goto out; | |
35522 | } | |
35523 | ||
35524 | ||
35525 | if (!js_IsXMLName(cx, OBJECT_TO_JSVAL(nameobj)) && | |
35526 | !((nameqn->getQNameLocalName())->length() == 1 && *(nameqn->getQNameLocalName())->chars() == '*')) { | |
35527 | goto out; | |
35528 | } | |
35529 | ||
35530 | ||
35531 | id = ((jsid)0x2); | |
35532 | primitiveAssign = !vxml && !((nameqn->getQNameLocalName())->length() == 1 && *(nameqn->getQNameLocalName())->chars() == '*'); | |
35533 | ||
35534 | ||
35535 | k = n = xml->u.list.kids.length; | |
35536 | matchIndex = ((uint32) -1); | |
35537 | kid2 = __null; | |
35538 | while (k != 0) { | |
35539 | --k; | |
35540 | kid = (((k) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[k] : __null); | |
35541 | if (kid && MatchElemName(nameqn, kid)) { | |
35542 | if (matchIndex != ((uint32) -1)) | |
35543 | DeleteByIndex(cx, xml, matchIndex); | |
35544 | matchIndex = k; | |
35545 | kid2 = kid; | |
35546 | } | |
35547 | } | |
35548 | # 4392 "jsxml.cpp" | |
35549 | if (kid2) { | |
35550 | ((void) 0); | |
35551 | if (!kid2->parent) | |
35552 | kid2->parent = xml; | |
35553 | } | |
35554 | ||
35555 | ||
35556 | if (matchIndex == ((uint32) -1)) { | |
35557 | ||
35558 | matchIndex = n; | |
35559 | ||
35560 | ||
35561 | if (primitiveAssign) { | |
35562 | JSLinearString *uri = nameqn->getNameURI(); | |
35563 | JSLinearString *left, *right; | |
35564 | if (!uri) { | |
35565 | ns = JSVAL_TO_OBJECT(nsval); | |
35566 | left = ns->getNameURI(); | |
35567 | right = ns->getNamePrefix(); | |
35568 | } else { | |
35569 | left = uri; | |
35570 | right = nameqn->getNamePrefix(); | |
35571 | } | |
35572 | nameqn = NewXMLQName(cx, left, right, nameqn->getQNameLocalName()); | |
35573 | if (!nameqn) | |
35574 | goto bad; | |
35575 | ||
35576 | ||
35577 | vobj = js_NewXMLObject(cx, JSXML_CLASS_ELEMENT); | |
35578 | if (!vobj) | |
35579 | goto bad; | |
35580 | vxml = (JSXML *) vobj->getPrivate(); | |
35581 | vxml->parent = xml; | |
35582 | vxml->name = nameqn; | |
35583 | ||
35584 | ||
35585 | ns = GetNamespace(cx, nameqn, __null); | |
35586 | if (!ns) | |
35587 | goto bad; | |
35588 | ok = Replace(cx, xml, matchIndex, OBJECT_TO_JSVAL(vobj)); | |
35589 | if (!ok) | |
35590 | goto out; | |
35591 | ok = AddInScopeNamespace(cx, vxml, ns); | |
35592 | if (!ok) | |
35593 | goto out; | |
35594 | } | |
35595 | } | |
35596 | ||
35597 | ||
35598 | if (primitiveAssign) { | |
35599 | JSXMLArrayCursor cursor(&xml->u.list.kids); | |
35600 | cursor.index = matchIndex; | |
35601 | kid = (JSXML *) cursor.getCurrent(); | |
35602 | if ((((kid)->xml_class) < JSXML_CLASS_ATTRIBUTE)) { | |
35603 | kid->u.list.kids.finish(cx); | |
35604 | kid->u.list.kids.init(); | |
35605 | ok = kid->u.list.kids.setCapacity(cx, 1); | |
35606 | } | |
35607 | ||
35608 | ||
35609 | ||
35610 | if (ok) { | |
35611 | ok = JS_ConvertValue(cx, *vp, JSTYPE_STRING, vp); | |
35612 | if (ok && !JSVAL_TO_STRING(*vp)->empty()) { | |
35613 | roots[VAL_ROOT] = *vp; | |
35614 | if ((JSXML *) cursor.getCurrent() == kid) | |
35615 | ok = Replace(cx, kid, 0, *vp); | |
35616 | } | |
35617 | } | |
35618 | } else { | |
35619 | ||
35620 | ok = Replace(cx, xml, matchIndex, *vp); | |
35621 | } | |
35622 | } | |
35623 | ||
35624 | out: | |
35625 | js_LeaveLocalRootScope(cx); | |
35626 | return ok; | |
35627 | ||
35628 | type_error: | |
35629 | { | |
35630 | JSAutoByteString bytes; | |
35631 | if (js_ValueToPrintable(cx, IdToValue(id), &bytes)) | |
35632 | JS_ReportErrorNumber(cx, js_GetErrorMessage, __null, JSMSG_BAD_XMLLIST_PUT, bytes.ptr()); | |
35633 | } | |
35634 | bad: | |
35635 | ok = (JSIntn)0; | |
35636 | goto out; | |
35637 | } | |
35638 | ||
35639 | ||
35640 | static JSBool | |
35641 | ResolveValue(JSContext *cx, JSXML *list, JSXML **result) | |
35642 | { | |
35643 | JSXML *target, *base; | |
35644 | JSObject *targetprop; | |
35645 | jsid id; | |
35646 | jsval tv; | |
35647 | ||
35648 | if (list->xml_class != JSXML_CLASS_LIST || list->u.list.kids.length != 0) { | |
35649 | if (!js_GetXMLObject(cx, list)) | |
35650 | return (JSIntn)0; | |
35651 | *result = list; | |
35652 | return (JSIntn)1; | |
35653 | } | |
35654 | ||
35655 | target = list->u.list.target; | |
35656 | targetprop = list->u.list.targetprop; | |
35657 | if (!target || !targetprop || ((targetprop->getQNameLocalName())->length() == 1 && *(targetprop->getQNameLocalName())->chars() == '*')) { | |
35658 | *result = __null; | |
35659 | return (JSIntn)1; | |
35660 | } | |
35661 | ||
35662 | if (targetprop->getClass() == &js_AttributeNameClass) { | |
35663 | *result = __null; | |
35664 | return (JSIntn)1; | |
35665 | } | |
35666 | ||
35667 | if (!ResolveValue(cx, target, &base)) | |
35668 | return (JSIntn)0; | |
35669 | if (!base) { | |
35670 | *result = __null; | |
35671 | return (JSIntn)1; | |
35672 | } | |
35673 | if (!js_GetXMLObject(cx, base)) | |
35674 | return (JSIntn)0; | |
35675 | ||
35676 | id = OBJECT_TO_JSID(targetprop); | |
35677 | if (!GetProperty(cx, base->object, id, &tv)) | |
35678 | return (JSIntn)0; | |
35679 | target = (JSXML *) JSVAL_TO_OBJECT(tv)->getPrivate(); | |
35680 | ||
35681 | if (((((target)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (target)->u.list.kids.length : 0) == 0) { | |
35682 | if (base->xml_class == JSXML_CLASS_LIST && ((((base)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (base)->u.list.kids.length : 0) > 1) { | |
35683 | *result = __null; | |
35684 | return (JSIntn)1; | |
35685 | } | |
35686 | tv = STRING_TO_JSVAL(cx->runtime->emptyString); | |
35687 | if (!PutProperty(cx, base->object, id, false, &tv)) | |
35688 | return (JSIntn)0; | |
35689 | if (!GetProperty(cx, base->object, id, &tv)) | |
35690 | return (JSIntn)0; | |
35691 | target = (JSXML *) JSVAL_TO_OBJECT(tv)->getPrivate(); | |
35692 | } | |
35693 | ||
35694 | *result = target; | |
35695 | return (JSIntn)1; | |
35696 | } | |
35697 | ||
35698 | static JSBool | |
35699 | HasNamedProperty(JSXML *xml, JSObject *nameqn) | |
35700 | { | |
35701 | JSBool found; | |
35702 | JSXMLArray *array; | |
35703 | JSXMLNameMatcher matcher; | |
35704 | uint32 i, n; | |
35705 | ||
35706 | if (xml->xml_class == JSXML_CLASS_LIST) { | |
35707 | found = (JSIntn)0; | |
35708 | JSXMLArrayCursor cursor(&xml->u.list.kids); | |
35709 | while (JSXML *kid = (JSXML *) cursor.getNext()) { | |
35710 | found = HasNamedProperty(kid, nameqn); | |
35711 | if (found) | |
35712 | break; | |
35713 | } | |
35714 | return found; | |
35715 | } | |
35716 | ||
35717 | if (xml->xml_class == JSXML_CLASS_ELEMENT) { | |
35718 | if (nameqn->getClass() == &js_AttributeNameClass) { | |
35719 | array = &xml->u.elem.attrs; | |
35720 | matcher = MatchAttrName; | |
35721 | } else { | |
35722 | array = &xml->u.list.kids; | |
35723 | matcher = MatchElemName; | |
35724 | } | |
35725 | for (i = 0, n = array->length; i < n; i++) { | |
35726 | JSXML *kid = (((i) < (array)->length) ? (JSXML *) (array)->vector[i] : __null); | |
35727 | if (kid && matcher(nameqn, kid)) | |
35728 | return (JSIntn)1; | |
35729 | } | |
35730 | } | |
35731 | ||
35732 | return (JSIntn)0; | |
35733 | } | |
35734 | ||
35735 | static JSBool | |
35736 | HasIndexedProperty(JSXML *xml, uint32 i) | |
35737 | { | |
35738 | if (xml->xml_class == JSXML_CLASS_LIST) | |
35739 | return i < ((((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (xml)->u.list.kids.length : 0); | |
35740 | ||
35741 | if (xml->xml_class == JSXML_CLASS_ELEMENT) | |
35742 | return i == 0; | |
35743 | ||
35744 | return (JSIntn)0; | |
35745 | } | |
35746 | ||
35747 | static JSBool | |
35748 | HasSimpleContent(JSXML *xml); | |
35749 | ||
35750 | static JSBool | |
35751 | HasFunctionProperty(JSContext *cx, JSObject *obj, jsid funid, JSBool *found) | |
35752 | { | |
35753 | JSObject *pobj; | |
35754 | JSProperty *prop; | |
35755 | JSXML *xml; | |
35756 | ||
35757 | ((void) 0); | |
35758 | ||
35759 | if (!js_LookupProperty(cx, obj, funid, &pobj, &prop)) | |
35760 | return false; | |
35761 | if (!prop) { | |
35762 | xml = (JSXML *) obj->getPrivate(); | |
35763 | if (HasSimpleContent(xml)) { | |
35764 | AutoObjectRooter tvr(cx); | |
35765 | ||
35766 | ||
35767 | ||
35768 | ||
35769 | ||
35770 | if (!js_GetClassPrototype(cx, __null, JSProto_String, tvr.addr())) | |
35771 | return false; | |
35772 | ||
35773 | ((void) 0); | |
35774 | if (!js_LookupProperty(cx, tvr.object(), funid, &pobj, &prop)) | |
35775 | return false; | |
35776 | } | |
35777 | } | |
35778 | *found = (prop != __null); | |
35779 | return true; | |
35780 | } | |
35781 | ||
35782 | ||
35783 | static JSBool | |
35784 | HasProperty(JSContext *cx, JSObject *obj, jsval id, JSBool *found) | |
35785 | { | |
35786 | JSXML *xml; | |
35787 | bool isIndex; | |
35788 | uint32 i; | |
35789 | JSObject *qn; | |
35790 | jsid funid; | |
35791 | ||
35792 | xml = (JSXML *) obj->getPrivate(); | |
35793 | if (!js_IdValIsIndex(cx, id, &i, &isIndex)) | |
35794 | return (JSIntn)0; | |
35795 | ||
35796 | if (isIndex) { | |
35797 | *found = HasIndexedProperty(xml, i); | |
35798 | } else { | |
35799 | qn = ToXMLName(cx, id, &funid); | |
35800 | if (!qn) | |
35801 | return (JSIntn)0; | |
35802 | if (!JSID_IS_VOID(funid)) { | |
35803 | if (!HasFunctionProperty(cx, obj, funid, found)) | |
35804 | return (JSIntn)0; | |
35805 | } else { | |
35806 | *found = HasNamedProperty(xml, qn); | |
35807 | } | |
35808 | } | |
35809 | return (JSIntn)1; | |
35810 | } | |
35811 | ||
35812 | static void | |
35813 | xml_finalize(JSContext *cx, JSObject *obj) | |
35814 | { | |
35815 | JSXML *xml = (JSXML *) obj->getPrivate(); | |
35816 | if (!xml) | |
35817 | return; | |
35818 | if (xml->object == obj) | |
35819 | xml->object = __null; | |
35820 | } | |
35821 | ||
35822 | static void | |
35823 | xml_trace_vector(JSTracer *trc, JSXML **vec, uint32 len) | |
35824 | { | |
35825 | uint32 i; | |
35826 | JSXML *xml; | |
35827 | ||
35828 | for (i = 0; i < len; i++) { | |
35829 | xml = vec[i]; | |
35830 | if (xml) { | |
35831 | do { } while (0); | |
35832 | Mark(trc, xml); | |
35833 | } | |
35834 | } | |
35835 | } | |
35836 | # 4703 "jsxml.cpp" | |
35837 | static JSBool | |
35838 | xml_lookupProperty(JSContext *cx, JSObject *obj, jsid id, JSObject **objp, | |
35839 | JSProperty **propp) | |
35840 | { | |
35841 | JSBool found; | |
35842 | JSXML *xml; | |
35843 | uint32 i; | |
35844 | JSObject *qn; | |
35845 | jsid funid; | |
35846 | ||
35847 | xml = (JSXML *) obj->getPrivate(); | |
35848 | if (js_IdIsIndex(id, &i)) { | |
35849 | found = HasIndexedProperty(xml, i); | |
35850 | } else { | |
35851 | qn = ToXMLName(cx, IdToJsval(id), &funid); | |
35852 | if (!qn) | |
35853 | return (JSIntn)0; | |
35854 | if (!JSID_IS_VOID(funid)) | |
35855 | return js_LookupProperty(cx, obj, funid, objp, propp); | |
35856 | found = HasNamedProperty(xml, qn); | |
35857 | } | |
35858 | if (!found) { | |
35859 | *objp = __null; | |
35860 | *propp = __null; | |
35861 | } else { | |
35862 | const Shape *shape = | |
35863 | js_AddNativeProperty(cx, obj, id, | |
35864 | Valueify(GetProperty), Valueify(PutProperty), | |
35865 | 0xffffffff, 0x01, | |
35866 | 0, 0); | |
35867 | if (!shape) | |
35868 | return (JSIntn)0; | |
35869 | ||
35870 | *objp = obj; | |
35871 | *propp = (JSProperty *) shape; | |
35872 | } | |
35873 | return (JSIntn)1; | |
35874 | } | |
35875 | ||
35876 | static JSBool | |
35877 | xml_defineProperty(JSContext *cx, JSObject *obj, jsid id, const Value *v, | |
35878 | PropertyOp getter, StrictPropertyOp setter, uintN attrs) | |
35879 | { | |
35880 | if (IsFunctionObject(*v) || getter || setter || | |
35881 | (attrs & 0x01) == 0 || | |
35882 | (attrs & (0x02 | 0x04 | 0x40))) { | |
35883 | return js_DefineProperty(cx, obj, id, v, getter, setter, attrs); | |
35884 | } | |
35885 | ||
35886 | jsval tmp = Jsvalify(*v); | |
35887 | return PutProperty(cx, obj, id, false, &tmp); | |
35888 | } | |
35889 | ||
35890 | static JSBool | |
35891 | xml_getProperty(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, Value *vp) | |
35892 | { | |
35893 | if (JSID_IS_DEFAULT_XML_NAMESPACE(id)) { | |
35894 | vp->setUndefined(); | |
35895 | return (JSIntn)1; | |
35896 | } | |
35897 | ||
35898 | return GetProperty(cx, obj, id, Jsvalify(vp)); | |
35899 | } | |
35900 | ||
35901 | static JSBool | |
35902 | xml_setProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp, JSBool strict) | |
35903 | { | |
35904 | return PutProperty(cx, obj, id, strict, Jsvalify(vp)); | |
35905 | } | |
35906 | ||
35907 | static JSBool | |
35908 | xml_getAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp) | |
35909 | { | |
35910 | JSBool found; | |
35911 | if (!HasProperty(cx, obj, IdToJsval(id), &found)) | |
35912 | return false; | |
35913 | ||
35914 | *attrsp = found ? 0x01 : 0; | |
35915 | return (JSIntn)1; | |
35916 | } | |
35917 | ||
35918 | static JSBool | |
35919 | xml_setAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp) | |
35920 | { | |
35921 | JSBool found; | |
35922 | if (!HasProperty(cx, obj, IdToJsval(id), &found)) | |
35923 | return false; | |
35924 | ||
35925 | if (found) { | |
35926 | JS_ReportErrorNumber(cx, js_GetErrorMessage, __null, | |
35927 | JSMSG_CANT_SET_XML_ATTRS); | |
35928 | return false; | |
35929 | } | |
35930 | return true; | |
35931 | } | |
35932 | ||
35933 | static JSBool | |
35934 | xml_deleteProperty(JSContext *cx, JSObject *obj, jsid id, Value *rval, JSBool strict) | |
35935 | { | |
35936 | JSXML *xml; | |
35937 | jsval idval; | |
35938 | uint32 index; | |
35939 | JSObject *nameqn; | |
35940 | jsid funid; | |
35941 | ||
35942 | idval = IdToJsval(id); | |
35943 | xml = (JSXML *) obj->getPrivate(); | |
35944 | if (js_IdIsIndex(id, &index)) { | |
35945 | if (xml->xml_class != JSXML_CLASS_LIST) { | |
35946 | ||
35947 | ReportBadXMLName(cx, IdToValue(id)); | |
35948 | return false; | |
35949 | } | |
35950 | ||
35951 | ||
35952 | DeleteListElement(cx, xml, index); | |
35953 | } else { | |
35954 | nameqn = ToXMLName(cx, idval, &funid); | |
35955 | if (!nameqn) | |
35956 | return false; | |
35957 | if (!JSID_IS_VOID(funid)) | |
35958 | return js_DeleteProperty(cx, obj, funid, rval, false); | |
35959 | ||
35960 | DeleteNamedProperty(cx, xml, nameqn, | |
35961 | nameqn->getClass() == &js_AttributeNameClass); | |
35962 | } | |
35963 | # 4837 "jsxml.cpp" | |
35964 | if (!obj->nativeEmpty() && !js_DeleteProperty(cx, obj, id, rval, false)) | |
35965 | return false; | |
35966 | ||
35967 | rval->setBoolean(true); | |
35968 | return true; | |
35969 | } | |
35970 | ||
35971 | JSBool | |
35972 | xml_convert(JSContext *cx, JSObject *obj, JSType type, Value *rval) | |
35973 | { | |
35974 | return js_TryMethod(cx, obj, cx->runtime->atomState.toStringAtom, 0, __null, rval); | |
35975 | } | |
35976 | ||
35977 | static JSBool | |
35978 | xml_enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op, Value *statep, jsid *idp) | |
35979 | { | |
35980 | JSXML *xml; | |
35981 | uint32 length, index; | |
35982 | JSXMLArrayCursor *cursor; | |
35983 | ||
35984 | xml = (JSXML *)obj->getPrivate(); | |
35985 | length = ((((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (xml)->u.list.kids.length : 0); | |
35986 | ||
35987 | switch (enum_op) { | |
35988 | case JSENUMERATE_INIT: | |
35989 | case JSENUMERATE_INIT_ALL: | |
35990 | if (length == 0) { | |
35991 | statep->setInt32(0); | |
35992 | } else { | |
35993 | cursor = cx->create<JSXMLArrayCursor>(&xml->u.list.kids); | |
35994 | if (!cursor) | |
35995 | return (JSIntn)0; | |
35996 | statep->setPrivate(cursor); | |
35997 | } | |
35998 | if (idp) | |
35999 | *idp = INT_TO_JSID(length); | |
36000 | break; | |
36001 | ||
36002 | case JSENUMERATE_NEXT: | |
36003 | if (statep->isInt32(0)) { | |
36004 | statep->setNull(); | |
36005 | break; | |
36006 | } | |
36007 | cursor = (JSXMLArrayCursor *) statep->toPrivate(); | |
36008 | if (cursor && cursor->array && (index = cursor->index) < length) { | |
36009 | *idp = INT_TO_JSID(index); | |
36010 | cursor->index = index + 1; | |
36011 | break; | |
36012 | } | |
36013 | ||
36014 | ||
36015 | case JSENUMERATE_DESTROY: | |
36016 | if (!statep->isInt32(0)) { | |
36017 | cursor = (JSXMLArrayCursor *) statep->toPrivate(); | |
36018 | if (cursor) | |
36019 | cx->destroy(cursor); | |
36020 | } | |
36021 | statep->setNull(); | |
36022 | break; | |
36023 | } | |
36024 | return (JSIntn)1; | |
36025 | } | |
36026 | ||
36027 | static JSType | |
36028 | xml_typeOf(JSContext *cx, JSObject *obj) | |
36029 | { | |
36030 | return JSTYPE_XML; | |
36031 | } | |
36032 | ||
36033 | static JSBool | |
36034 | xml_hasInstance(JSContext *cx, JSObject *obj, const Value *, JSBool *bp) | |
36035 | { | |
36036 | return (JSIntn)1; | |
36037 | } | |
36038 | ||
36039 | static void | |
36040 | xml_trace(JSTracer *trc, JSObject *obj) | |
36041 | { | |
36042 | JSXML *xml = (JSXML *) obj->getPrivate(); | |
36043 | if (xml) | |
36044 | do { do { } while (0); JS_CallTracer((trc), (xml), (2)); } while (0); | |
36045 | } | |
36046 | ||
36047 | static JSBool | |
36048 | xml_fix(JSContext *cx, JSObject *obj, bool *success, AutoIdVector *props) | |
36049 | { | |
36050 | ((void) 0); | |
36051 | *success = false; | |
36052 | return true; | |
36053 | } | |
36054 | ||
36055 | static void | |
36056 | xml_clear(JSContext *cx, JSObject *obj) | |
36057 | { | |
36058 | } | |
36059 | ||
36060 | static JSBool | |
36061 | HasSimpleContent(JSXML *xml) | |
36062 | { | |
36063 | JSXML *kid; | |
36064 | JSBool simple; | |
36065 | uint32 i, n; | |
36066 | ||
36067 | again: | |
36068 | switch (xml->xml_class) { | |
36069 | case JSXML_CLASS_COMMENT: | |
36070 | case JSXML_CLASS_PROCESSING_INSTRUCTION: | |
36071 | return (JSIntn)0; | |
36072 | case JSXML_CLASS_LIST: | |
36073 | if (xml->u.list.kids.length == 0) | |
36074 | return (JSIntn)1; | |
36075 | if (xml->u.list.kids.length == 1) { | |
36076 | kid = (((0) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[0] : __null); | |
36077 | if (kid) { | |
36078 | xml = kid; | |
36079 | goto again; | |
36080 | } | |
36081 | } | |
36082 | ||
36083 | default: | |
36084 | simple = (JSIntn)1; | |
36085 | for (i = 0, n = ((((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (xml)->u.list.kids.length : 0); i < n; i++) { | |
36086 | kid = (((i) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[i] : __null); | |
36087 | if (kid && kid->xml_class == JSXML_CLASS_ELEMENT) { | |
36088 | simple = (JSIntn)0; | |
36089 | break; | |
36090 | } | |
36091 | } | |
36092 | return simple; | |
36093 | } | |
36094 | } | |
36095 | ||
36096 | ||
36097 | ||
36098 | ||
36099 | JSBool | |
36100 | js_GetXMLMethod(JSContext *cx, JSObject *obj, jsid id, Value *vp) | |
36101 | { | |
36102 | ((void) 0); | |
36103 | ||
36104 | if (JSID_IS_OBJECT(id)) { | |
36105 | jsid funid; | |
36106 | ||
36107 | if (!js_IsFunctionQName(cx, JSID_TO_OBJECT(id), &funid)) | |
36108 | return (JSIntn)0; | |
36109 | if (!JSID_IS_VOID(funid)) | |
36110 | id = funid; | |
36111 | } | |
36112 | ||
36113 | ||
36114 | ||
36115 | ||
36116 | ||
36117 | AutoValueRooter tvr(cx); | |
36118 | JSBool ok = GetXMLFunction(cx, obj, id, Jsvalify(tvr.addr())); | |
36119 | *vp = tvr.value(); | |
36120 | return ok; | |
36121 | } | |
36122 | ||
36123 | JSBool | |
36124 | js_TestXMLEquality(JSContext *cx, const Value &v1, const Value &v2, JSBool *bp) | |
36125 | { | |
36126 | JSXML *xml, *vxml; | |
36127 | JSObject *vobj; | |
36128 | JSBool ok; | |
36129 | JSString *str, *vstr; | |
36130 | jsdouble d, d2; | |
36131 | ||
36132 | JSObject *obj; | |
36133 | jsval v; | |
36134 | if (v1.isObject() && v1.toObject().isXML()) { | |
36135 | obj = &v1.toObject(); | |
36136 | v = Jsvalify(v2); | |
36137 | } else { | |
36138 | v = Jsvalify(v1); | |
36139 | obj = &v2.toObject(); | |
36140 | } | |
36141 | ||
36142 | ((void) 0); | |
36143 | ||
36144 | xml = (JSXML *) obj->getPrivate(); | |
36145 | vxml = __null; | |
36146 | if (!JSVAL_IS_PRIMITIVE(v)) { | |
36147 | vobj = JSVAL_TO_OBJECT(v); | |
36148 | if (vobj->isXML()) | |
36149 | vxml = (JSXML *) vobj->getPrivate(); | |
36150 | } | |
36151 | ||
36152 | if (xml->xml_class == JSXML_CLASS_LIST) { | |
36153 | ok = Equals(cx, xml, v, bp); | |
36154 | } else if (vxml) { | |
36155 | if (vxml->xml_class == JSXML_CLASS_LIST) { | |
36156 | ok = Equals(cx, vxml, OBJECT_TO_JSVAL(obj), bp); | |
36157 | } else { | |
36158 | if (((xml->xml_class == JSXML_CLASS_TEXT || | |
36159 | xml->xml_class == JSXML_CLASS_ATTRIBUTE) && | |
36160 | HasSimpleContent(vxml)) || | |
36161 | ((vxml->xml_class == JSXML_CLASS_TEXT || | |
36162 | vxml->xml_class == JSXML_CLASS_ATTRIBUTE) && | |
36163 | HasSimpleContent(xml))) { | |
36164 | ok = js_EnterLocalRootScope(cx); | |
36165 | if (ok) { | |
36166 | ok = (str = js_ValueToString(cx, ObjectValue(*obj))) && | |
36167 | (vstr = js_ValueToString(cx, Valueify(v))); | |
36168 | if (ok) | |
36169 | ok = EqualStrings(cx, str, vstr, bp); | |
36170 | js_LeaveLocalRootScope(cx); | |
36171 | } | |
36172 | } else { | |
36173 | ok = XMLEquals(cx, xml, vxml, bp); | |
36174 | } | |
36175 | } | |
36176 | } else { | |
36177 | ok = js_EnterLocalRootScope(cx); | |
36178 | if (ok) { | |
36179 | if (HasSimpleContent(xml)) { | |
36180 | ok = (str = js_ValueToString(cx, ObjectValue(*obj))) && | |
36181 | (vstr = js_ValueToString(cx, Valueify(v))); | |
36182 | if (ok) | |
36183 | ok = EqualStrings(cx, str, vstr, bp); | |
36184 | } else if (JSVAL_IS_STRING(v) || JSVAL_IS_NUMBER(v)) { | |
36185 | str = js_ValueToString(cx, ObjectValue(*obj)); | |
36186 | if (!str) { | |
36187 | ok = (JSIntn)0; | |
36188 | } else if (JSVAL_IS_STRING(v)) { | |
36189 | ok = EqualStrings(cx, str, JSVAL_TO_STRING(v), bp); | |
36190 | } else { | |
36191 | ok = JS_ValueToNumber(cx, STRING_TO_JSVAL(str), &d); | |
36192 | if (ok) { | |
36193 | d2 = JSVAL_IS_INT(v) ? JSVAL_TO_INT(v) | |
36194 | : JSVAL_TO_DOUBLE(v); | |
36195 | *bp = ((d) == (d2)); | |
36196 | } | |
36197 | } | |
36198 | } else { | |
36199 | *bp = (JSIntn)0; | |
36200 | } | |
36201 | js_LeaveLocalRootScope(cx); | |
36202 | } | |
36203 | } | |
36204 | return ok; | |
36205 | } | |
36206 | ||
36207 | JSBool | |
36208 | js_ConcatenateXML(JSContext *cx, JSObject *obj, JSObject *robj, Value *vp) | |
36209 | { | |
36210 | JSBool ok; | |
36211 | JSObject *listobj; | |
36212 | JSXML *list, *lxml, *rxml; | |
36213 | ||
36214 | ((void) 0); | |
36215 | ok = js_EnterLocalRootScope(cx); | |
36216 | if (!ok) | |
36217 | return (JSIntn)0; | |
36218 | ||
36219 | listobj = js_NewXMLObject(cx, JSXML_CLASS_LIST); | |
36220 | if (!listobj) { | |
36221 | ok = (JSIntn)0; | |
36222 | goto out; | |
36223 | } | |
36224 | ||
36225 | list = (JSXML *) listobj->getPrivate(); | |
36226 | lxml = (JSXML *) obj->getPrivate(); | |
36227 | ok = Append(cx, list, lxml); | |
36228 | if (!ok) | |
36229 | goto out; | |
36230 | ||
36231 | ((void) 0); | |
36232 | rxml = (JSXML *) robj->getPrivate(); | |
36233 | ok = Append(cx, list, rxml); | |
36234 | if (!ok) | |
36235 | goto out; | |
36236 | ||
36237 | vp->setObject(*listobj); | |
36238 | out: | |
36239 | js_LeaveLocalRootScopeWithResult(cx, *vp); | |
36240 | return ok; | |
36241 | } | |
36242 | ||
36243 | __attribute__((visibility ("default"))) Class js_XMLClass = { | |
36244 | js_XML_str, | |
36245 | (1<<0) | (1<<((8 + 8)+3)) | | |
36246 | ((JSProto_XML) << ((8 + 8) + 8)), | |
36247 | PropertyStub, | |
36248 | PropertyStub, | |
36249 | PropertyStub, | |
36250 | StrictPropertyStub, | |
36251 | EnumerateStub, | |
36252 | ResolveStub, | |
36253 | xml_convert, | |
36254 | xml_finalize, | |
36255 | __null, | |
36256 | __null, | |
36257 | __null, | |
36258 | __null, | |
36259 | __null, | |
36260 | xml_hasInstance, | |
36261 | ((JSMarkOp)(xml_trace)), | |
36262 | {__null,__null,__null,__null,__null}, | |
36263 | { | |
36264 | xml_lookupProperty, | |
36265 | xml_defineProperty, | |
36266 | xml_getProperty, | |
36267 | xml_setProperty, | |
36268 | xml_getAttributes, | |
36269 | xml_setAttributes, | |
36270 | xml_deleteProperty, | |
36271 | xml_enumerate, | |
36272 | xml_typeOf, | |
36273 | __null, | |
36274 | xml_fix, | |
36275 | __null, | |
36276 | xml_clear | |
36277 | } | |
36278 | }; | |
36279 | ||
36280 | static JSXML * | |
36281 | StartNonListXMLMethod(JSContext *cx, jsval *vp, JSObject **objp) | |
36282 | { | |
36283 | JSXML *xml; | |
36284 | JSFunction *fun; | |
36285 | char numBuf[12]; | |
36286 | ||
36287 | ((void) 0); | |
36288 | ||
36289 | *objp = ToObject(cx, Valueify(&vp[1])); | |
36290 | if (!*objp) | |
36291 | return __null; | |
36292 | xml = (JSXML *) GetInstancePrivate(cx, *objp, &js_XMLClass, Valueify(vp + 2)); | |
36293 | if (!xml || xml->xml_class != JSXML_CLASS_LIST) | |
36294 | return xml; | |
36295 | ||
36296 | if (xml->u.list.kids.length == 1) { | |
36297 | xml = (((0) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[0] : __null); | |
36298 | if (xml) { | |
36299 | *objp = js_GetXMLObject(cx, xml); | |
36300 | if (!*objp) | |
36301 | return __null; | |
36302 | vp[1] = OBJECT_TO_JSVAL(*objp); | |
36303 | return xml; | |
36304 | } | |
36305 | } | |
36306 | ||
36307 | fun = (((void) 0), (JSFunction *) (JSVAL_TO_OBJECT(*vp))->getPrivate()); | |
36308 | JS_snprintf(numBuf, sizeof numBuf, "%u", xml->u.list.kids.length); | |
36309 | JSAutoByteString funNameBytes; | |
36310 | if (const char *funName = GetFunctionNameBytes(cx, fun, &funNameBytes)) { | |
36311 | JS_ReportErrorNumber(cx, js_GetErrorMessage, __null, JSMSG_NON_LIST_XML_METHOD, | |
36312 | funName, numBuf); | |
36313 | } | |
36314 | return __null; | |
36315 | } | |
36316 | # 5206 "jsxml.cpp" | |
36317 | static JSBool | |
36318 | xml_addNamespace(JSContext *cx, uintN argc, jsval *vp) | |
36319 | { | |
36320 | JSObject *ns; | |
36321 | ||
36322 | JSObject *obj; JSXML *xml = StartNonListXMLMethod(cx, vp, &obj); if (!xml) return (JSIntn)0; ((void) 0); | |
36323 | if (xml->xml_class != JSXML_CLASS_ELEMENT) | |
36324 | goto done; | |
36325 | xml = (xml->object == obj ? xml : CopyOnWrite(cx, xml, obj)); | |
36326 | if (!xml) | |
36327 | return (JSIntn)0; | |
36328 | ||
36329 | if (!NamespaceHelper(cx, __null, argc == 0 ? -1 : 1, vp + 2, vp)) | |
36330 | return (JSIntn)0; | |
36331 | ((void) 0); | |
36332 | ||
36333 | ns = JSVAL_TO_OBJECT(*vp); | |
36334 | if (!AddInScopeNamespace(cx, xml, ns)) | |
36335 | return (JSIntn)0; | |
36336 | ns->setNamespaceDeclared(((((uint64)(uint32)(JSVAL_TAG_BOOLEAN)) << 47) | ((JSIntn)1))); | |
36337 | ||
36338 | done: | |
36339 | *vp = OBJECT_TO_JSVAL(obj); | |
36340 | return (JSIntn)1; | |
36341 | } | |
36342 | ||
36343 | static JSBool | |
36344 | xml_appendChild(JSContext *cx, uintN argc, jsval *vp) | |
36345 | { | |
36346 | jsval v; | |
36347 | JSObject *vobj; | |
36348 | JSXML *vxml; | |
36349 | ||
36350 | JSObject *obj; JSXML *xml = StartNonListXMLMethod(cx, vp, &obj); if (!xml) return (JSIntn)0; ((void) 0); | |
36351 | xml = (xml->object == obj ? xml : CopyOnWrite(cx, xml, obj)); | |
36352 | if (!xml) | |
36353 | return (JSIntn)0; | |
36354 | ||
36355 | jsid name; | |
36356 | if (!js_GetAnyName(cx, &name)) | |
36357 | return (JSIntn)0; | |
36358 | ||
36359 | if (!GetProperty(cx, obj, name, &v)) | |
36360 | return (JSIntn)0; | |
36361 | ||
36362 | ((void) 0); | |
36363 | vobj = JSVAL_TO_OBJECT(v); | |
36364 | ((void) 0); | |
36365 | vxml = (JSXML *) vobj->getPrivate(); | |
36366 | ((void) 0); | |
36367 | ||
36368 | if (!IndexToId(cx, vxml->u.list.kids.length, &name)) | |
36369 | return (JSIntn)0; | |
36370 | *vp = (argc != 0) ? vp[2] : ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0)); | |
36371 | ||
36372 | if (!PutProperty(cx, JSVAL_TO_OBJECT(v), name, false, vp)) | |
36373 | return (JSIntn)0; | |
36374 | ||
36375 | *vp = OBJECT_TO_JSVAL(obj); | |
36376 | return (JSIntn)1; | |
36377 | } | |
36378 | ||
36379 | ||
36380 | static JSBool | |
36381 | xml_attribute(JSContext *cx, uintN argc, jsval *vp) | |
36382 | { | |
36383 | JSObject *qn; | |
36384 | ||
36385 | if (argc == 0) { | |
36386 | js_ReportMissingArg(cx, Valueify(*vp), 0); | |
36387 | return (JSIntn)0; | |
36388 | } | |
36389 | ||
36390 | qn = ToAttributeName(cx, vp[2]); | |
36391 | if (!qn) | |
36392 | return (JSIntn)0; | |
36393 | vp[2] = OBJECT_TO_JSVAL(qn); | |
36394 | ||
36395 | jsid id = OBJECT_TO_JSID(qn); | |
36396 | JSObject *obj = ToObject(cx, Valueify(&vp[1])); | |
36397 | if (!obj) | |
36398 | return (JSIntn)0; | |
36399 | return GetProperty(cx, obj, id, vp); | |
36400 | } | |
36401 | ||
36402 | ||
36403 | static JSBool | |
36404 | xml_attributes(JSContext *cx, uintN argc, jsval *vp) | |
36405 | { | |
36406 | jsval name = STRING_TO_JSVAL((cx->runtime->atomState.starAtom)); | |
36407 | JSObject *qn = ToAttributeName(cx, name); | |
36408 | if (!qn) | |
36409 | return (JSIntn)0; | |
36410 | ||
36411 | AutoObjectRooter tvr(cx, qn); | |
36412 | jsid id = OBJECT_TO_JSID(qn); | |
36413 | JSObject *obj = ToObject(cx, Valueify(&vp[1])); | |
36414 | if (!obj) | |
36415 | return (JSIntn)0; | |
36416 | return GetProperty(cx, obj, id, vp); | |
36417 | } | |
36418 | ||
36419 | static JSXML * | |
36420 | xml_list_helper(JSContext *cx, JSXML *xml, jsval *rval) | |
36421 | { | |
36422 | JSObject *listobj; | |
36423 | JSXML *list; | |
36424 | ||
36425 | listobj = js_NewXMLObject(cx, JSXML_CLASS_LIST); | |
36426 | if (!listobj) | |
36427 | return __null; | |
36428 | ||
36429 | *rval = OBJECT_TO_JSVAL(listobj); | |
36430 | list = (JSXML *) listobj->getPrivate(); | |
36431 | list->u.list.target = xml; | |
36432 | return list; | |
36433 | } | |
36434 | ||
36435 | static JSBool | |
36436 | ValueToId(JSContext *cx, jsval v, AutoIdRooter *idr) | |
36437 | { | |
36438 | if (JSVAL_IS_INT(v)) { | |
36439 | jsint i = JSVAL_TO_INT(v); | |
36440 | if (INT_FITS_IN_JSID(i)) | |
36441 | *idr->addr() = INT_TO_JSID(i); | |
36442 | else if (!js_ValueToStringId(cx, Valueify(v), idr->addr())) | |
36443 | return (JSIntn)0; | |
36444 | } else if (JSVAL_IS_STRING(v)) { | |
36445 | JSAtom *atom = js_AtomizeString(cx, JSVAL_TO_STRING(v), 0); | |
36446 | if (!atom) | |
36447 | return (JSIntn)0; | |
36448 | *idr->addr() = ATOM_TO_JSID(atom); | |
36449 | } else if (!JSVAL_IS_PRIMITIVE(v)) { | |
36450 | *idr->addr() = OBJECT_TO_JSID(JSVAL_TO_OBJECT(v)); | |
36451 | } else { | |
36452 | ReportBadXMLName(cx, Valueify(v)); | |
36453 | return (JSIntn)0; | |
36454 | } | |
36455 | return (JSIntn)1; | |
36456 | } | |
36457 | ||
36458 | static JSBool | |
36459 | xml_child_helper(JSContext *cx, JSObject *obj, JSXML *xml, jsval name, | |
36460 | jsval *rval) | |
36461 | { | |
36462 | bool isIndex; | |
36463 | uint32 index; | |
36464 | JSXML *kid; | |
36465 | JSObject *kidobj; | |
36466 | ||
36467 | ||
36468 | ((void) 0); | |
36469 | ||
36470 | if (!js_IdValIsIndex(cx, name, &index, &isIndex)) | |
36471 | return (JSIntn)0; | |
36472 | ||
36473 | if (isIndex) { | |
36474 | if (index >= ((((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (xml)->u.list.kids.length : 0)) { | |
36475 | *rval = ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0)); | |
36476 | } else { | |
36477 | kid = (((index) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[index] : __null); | |
36478 | if (!kid) { | |
36479 | *rval = ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0)); | |
36480 | } else { | |
36481 | kidobj = js_GetXMLObject(cx, kid); | |
36482 | if (!kidobj) | |
36483 | return (JSIntn)0; | |
36484 | *rval = OBJECT_TO_JSVAL(kidobj); | |
36485 | } | |
36486 | } | |
36487 | return (JSIntn)1; | |
36488 | } | |
36489 | ||
36490 | AutoIdRooter idr(cx); | |
36491 | if (!ValueToId(cx, name, &idr)) | |
36492 | return (JSIntn)0; | |
36493 | ||
36494 | return GetProperty(cx, obj, idr.id(), rval); | |
36495 | } | |
36496 | ||
36497 | ||
36498 | static JSBool | |
36499 | xml_child(JSContext *cx, uintN argc, jsval *vp) | |
36500 | { | |
36501 | jsval v; | |
36502 | JSXML *list, *vxml; | |
36503 | JSObject *kidobj; | |
36504 | ||
36505 | JSObject *obj = ToObject(cx, Valueify(&vp[1])); if (!obj) return (JSIntn)0; JSXML *xml = (JSXML *)GetInstancePrivate(cx, obj, &js_XMLClass, Valueify(vp+2)); if (!xml) return (JSIntn)0; | |
36506 | jsval name = argc != 0 ? vp[2] : ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0)); | |
36507 | if (xml->xml_class == JSXML_CLASS_LIST) { | |
36508 | ||
36509 | list = xml_list_helper(cx, xml, vp); | |
36510 | if (!list) | |
36511 | return (JSIntn)0; | |
36512 | ||
36513 | JSXMLArrayCursor cursor(&xml->u.list.kids); | |
36514 | while (JSXML *kid = (JSXML *) cursor.getNext()) { | |
36515 | kidobj = js_GetXMLObject(cx, kid); | |
36516 | if (!kidobj) | |
36517 | return (JSIntn)0; | |
36518 | if (!xml_child_helper(cx, kidobj, kid, name, &v)) | |
36519 | return (JSIntn)0; | |
36520 | if (JSVAL_IS_VOID(v)) { | |
36521 | ||
36522 | continue; | |
36523 | } | |
36524 | ||
36525 | ((void) 0); | |
36526 | vxml = (JSXML *) JSVAL_TO_OBJECT(v)->getPrivate(); | |
36527 | if ((!(((vxml)->xml_class) < JSXML_CLASS_ATTRIBUTE) || vxml->u.list.kids.length != 0) && | |
36528 | !Append(cx, list, vxml)) { | |
36529 | return (JSIntn)0; | |
36530 | } | |
36531 | } | |
36532 | return (JSIntn)1; | |
36533 | } | |
36534 | ||
36535 | ||
36536 | if (!xml_child_helper(cx, obj, xml, name, vp)) | |
36537 | return (JSIntn)0; | |
36538 | if (JSVAL_IS_VOID(*vp) && !xml_list_helper(cx, xml, vp)) | |
36539 | return (JSIntn)0; | |
36540 | return (JSIntn)1; | |
36541 | } | |
36542 | ||
36543 | static JSBool | |
36544 | xml_childIndex(JSContext *cx, uintN argc, jsval *vp) | |
36545 | { | |
36546 | JSXML *parent; | |
36547 | uint32 i, n; | |
36548 | ||
36549 | JSObject *obj; JSXML *xml = StartNonListXMLMethod(cx, vp, &obj); if (!xml) return (JSIntn)0; ((void) 0); | |
36550 | parent = xml->parent; | |
36551 | if (!parent || xml->xml_class == JSXML_CLASS_ATTRIBUTE) { | |
36552 | *vp = DOUBLE_TO_JSVAL(js_NaN); | |
36553 | return (JSIntn)1; | |
36554 | } | |
36555 | for (i = 0, n = ((((parent)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (parent)->u.list.kids.length : 0); i < n; i++) { | |
36556 | if ((((i) < (&parent->u.list.kids)->length) ? (JSXML *) (&parent->u.list.kids)->vector[i] : __null) == xml) | |
36557 | break; | |
36558 | } | |
36559 | ((void) 0); | |
36560 | if (i <= ((jsint)0x7fffffff)) | |
36561 | *vp = INT_TO_JSVAL(i); | |
36562 | else | |
36563 | *vp = DOUBLE_TO_JSVAL(i); | |
36564 | return (JSIntn)1; | |
36565 | } | |
36566 | ||
36567 | ||
36568 | static JSBool | |
36569 | xml_children(JSContext *cx, uintN argc, jsval *vp) | |
36570 | { | |
36571 | JSObject *obj = ToObject(cx, Valueify(&vp[1])); | |
36572 | if (!obj) | |
36573 | return false; | |
36574 | jsid name = ATOM_TO_JSID(cx->runtime->atomState.starAtom); | |
36575 | return GetProperty(cx, obj, name, vp); | |
36576 | } | |
36577 | ||
36578 | ||
36579 | static JSBool | |
36580 | xml_comments_helper(JSContext *cx, JSObject *obj, JSXML *xml, jsval *vp) | |
36581 | { | |
36582 | JSXML *list, *kid, *vxml; | |
36583 | JSBool ok; | |
36584 | uint32 i, n; | |
36585 | JSObject *kidobj; | |
36586 | jsval v; | |
36587 | ||
36588 | list = xml_list_helper(cx, xml, vp); | |
36589 | if (!list) | |
36590 | return (JSIntn)0; | |
36591 | ||
36592 | ok = (JSIntn)1; | |
36593 | ||
36594 | if (xml->xml_class == JSXML_CLASS_LIST) { | |
36595 | ||
36596 | for (i = 0, n = ((((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (xml)->u.list.kids.length : 0); i < n; i++) { | |
36597 | kid = (((i) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[i] : __null); | |
36598 | if (kid && kid->xml_class == JSXML_CLASS_ELEMENT) { | |
36599 | ok = js_EnterLocalRootScope(cx); | |
36600 | if (!ok) | |
36601 | break; | |
36602 | kidobj = js_GetXMLObject(cx, kid); | |
36603 | if (kidobj) { | |
36604 | ok = xml_comments_helper(cx, kidobj, kid, &v); | |
36605 | } else { | |
36606 | ok = (JSIntn)0; | |
36607 | v = ((((uint64)(uint32)(JSVAL_TAG_NULL)) << 47) | (0)); | |
36608 | } | |
36609 | js_LeaveLocalRootScopeWithResult(cx, Valueify(v)); | |
36610 | if (!ok) | |
36611 | break; | |
36612 | vxml = (JSXML *) JSVAL_TO_OBJECT(v)->getPrivate(); | |
36613 | if (((((vxml)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (vxml)->u.list.kids.length : 0) != 0) { | |
36614 | ok = Append(cx, list, vxml); | |
36615 | if (!ok) | |
36616 | break; | |
36617 | } | |
36618 | } | |
36619 | } | |
36620 | } else { | |
36621 | ||
36622 | for (i = 0, n = ((((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (xml)->u.list.kids.length : 0); i < n; i++) { | |
36623 | kid = (((i) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[i] : __null); | |
36624 | if (kid && kid->xml_class == JSXML_CLASS_COMMENT) { | |
36625 | ok = Append(cx, list, kid); | |
36626 | if (!ok) | |
36627 | break; | |
36628 | } | |
36629 | } | |
36630 | } | |
36631 | ||
36632 | return ok; | |
36633 | } | |
36634 | ||
36635 | static JSBool | |
36636 | xml_comments(JSContext *cx, uintN argc, jsval *vp) | |
36637 | { | |
36638 | JSObject *obj = ToObject(cx, Valueify(&vp[1])); if (!obj) return (JSIntn)0; JSXML *xml = (JSXML *)GetInstancePrivate(cx, obj, &js_XMLClass, Valueify(vp+2)); if (!xml) return (JSIntn)0; | |
36639 | return xml_comments_helper(cx, obj, xml, vp); | |
36640 | } | |
36641 | ||
36642 | ||
36643 | static JSBool | |
36644 | xml_contains(JSContext *cx, uintN argc, jsval *vp) | |
36645 | { | |
36646 | jsval value; | |
36647 | JSBool eq; | |
36648 | JSObject *kidobj; | |
36649 | ||
36650 | JSObject *obj = ToObject(cx, Valueify(&vp[1])); if (!obj) return (JSIntn)0; JSXML *xml = (JSXML *)GetInstancePrivate(cx, obj, &js_XMLClass, Valueify(vp+2)); if (!xml) return (JSIntn)0; | |
36651 | value = argc != 0 ? vp[2] : ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0)); | |
36652 | if (xml->xml_class == JSXML_CLASS_LIST) { | |
36653 | eq = (JSIntn)0; | |
36654 | JSXMLArrayCursor cursor(&xml->u.list.kids); | |
36655 | while (JSXML *kid = (JSXML *) cursor.getNext()) { | |
36656 | kidobj = js_GetXMLObject(cx, kid); | |
36657 | if (!kidobj || !js_TestXMLEquality(cx, ObjectValue(*kidobj), Valueify(value), &eq)) | |
36658 | return (JSIntn)0; | |
36659 | if (eq) | |
36660 | break; | |
36661 | } | |
36662 | } else { | |
36663 | if (!js_TestXMLEquality(cx, ObjectValue(*obj), Valueify(value), &eq)) | |
36664 | return (JSIntn)0; | |
36665 | } | |
36666 | *vp = BOOLEAN_TO_JSVAL(eq); | |
36667 | return (JSIntn)1; | |
36668 | } | |
36669 | ||
36670 | ||
36671 | static JSBool | |
36672 | xml_copy(JSContext *cx, uintN argc, jsval *vp) | |
36673 | { | |
36674 | JSXML *copy; | |
36675 | ||
36676 | JSObject *obj = ToObject(cx, Valueify(&vp[1])); if (!obj) return (JSIntn)0; JSXML *xml = (JSXML *)GetInstancePrivate(cx, obj, &js_XMLClass, Valueify(vp+2)); if (!xml) return (JSIntn)0; | |
36677 | copy = DeepCopy(cx, xml, __null, 0); | |
36678 | if (!copy) | |
36679 | return (JSIntn)0; | |
36680 | *vp = OBJECT_TO_JSVAL(copy->object); | |
36681 | return (JSIntn)1; | |
36682 | } | |
36683 | ||
36684 | ||
36685 | static JSBool | |
36686 | xml_descendants(JSContext *cx, uintN argc, jsval *vp) | |
36687 | { | |
36688 | jsval name; | |
36689 | JSXML *list; | |
36690 | ||
36691 | JSObject *obj = ToObject(cx, Valueify(&vp[1])); if (!obj) return (JSIntn)0; JSXML *xml = (JSXML *)GetInstancePrivate(cx, obj, &js_XMLClass, Valueify(vp+2)); if (!xml) return (JSIntn)0; | |
36692 | name = argc == 0 ? STRING_TO_JSVAL((cx->runtime->atomState.starAtom)) : vp[2]; | |
36693 | list = Descendants(cx, xml, name); | |
36694 | if (!list) | |
36695 | return (JSIntn)0; | |
36696 | *vp = OBJECT_TO_JSVAL(list->object); | |
36697 | return (JSIntn)1; | |
36698 | } | |
36699 | ||
36700 | ||
36701 | static JSBool | |
36702 | xml_elements_helper(JSContext *cx, JSObject *obj, JSXML *xml, | |
36703 | JSObject *nameqn, jsval *vp) | |
36704 | { | |
36705 | JSXML *list, *vxml; | |
36706 | jsval v; | |
36707 | JSBool ok; | |
36708 | JSObject *kidobj; | |
36709 | uint32 i, n; | |
36710 | ||
36711 | list = xml_list_helper(cx, xml, vp); | |
36712 | if (!list) | |
36713 | return (JSIntn)0; | |
36714 | ||
36715 | list->u.list.targetprop = nameqn; | |
36716 | ok = (JSIntn)1; | |
36717 | ||
36718 | if (xml->xml_class == JSXML_CLASS_LIST) { | |
36719 | ||
36720 | JSXMLArrayCursor cursor(&xml->u.list.kids); | |
36721 | while (JSXML *kid = (JSXML *) cursor.getNext()) { | |
36722 | if (kid->xml_class == JSXML_CLASS_ELEMENT) { | |
36723 | ok = js_EnterLocalRootScope(cx); | |
36724 | if (!ok) | |
36725 | break; | |
36726 | kidobj = js_GetXMLObject(cx, kid); | |
36727 | if (kidobj) { | |
36728 | ok = xml_elements_helper(cx, kidobj, kid, nameqn, &v); | |
36729 | } else { | |
36730 | ok = (JSIntn)0; | |
36731 | v = ((((uint64)(uint32)(JSVAL_TAG_NULL)) << 47) | (0)); | |
36732 | } | |
36733 | js_LeaveLocalRootScopeWithResult(cx, Valueify(v)); | |
36734 | if (!ok) | |
36735 | break; | |
36736 | vxml = (JSXML *) JSVAL_TO_OBJECT(v)->getPrivate(); | |
36737 | if (((((vxml)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (vxml)->u.list.kids.length : 0) != 0) { | |
36738 | ok = Append(cx, list, vxml); | |
36739 | if (!ok) | |
36740 | break; | |
36741 | } | |
36742 | } | |
36743 | } | |
36744 | } else { | |
36745 | for (i = 0, n = ((((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (xml)->u.list.kids.length : 0); i < n; i++) { | |
36746 | JSXML *kid = (((i) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[i] : __null); | |
36747 | if (kid && kid->xml_class == JSXML_CLASS_ELEMENT && | |
36748 | MatchElemName(nameqn, kid)) { | |
36749 | ok = Append(cx, list, kid); | |
36750 | if (!ok) | |
36751 | break; | |
36752 | } | |
36753 | } | |
36754 | } | |
36755 | ||
36756 | return ok; | |
36757 | } | |
36758 | ||
36759 | static JSBool | |
36760 | xml_elements(JSContext *cx, uintN argc, jsval *vp) | |
36761 | { | |
36762 | jsval name; | |
36763 | JSObject *nameqn; | |
36764 | jsid funid; | |
36765 | ||
36766 | JSObject *obj = ToObject(cx, Valueify(&vp[1])); if (!obj) return (JSIntn)0; JSXML *xml = (JSXML *)GetInstancePrivate(cx, obj, &js_XMLClass, Valueify(vp+2)); if (!xml) return (JSIntn)0; | |
36767 | ||
36768 | name = (argc == 0) ? STRING_TO_JSVAL((cx->runtime->atomState.starAtom)) : vp[2]; | |
36769 | nameqn = ToXMLName(cx, name, &funid); | |
36770 | if (!nameqn) | |
36771 | return (JSIntn)0; | |
36772 | ||
36773 | if (!JSID_IS_VOID(funid)) | |
36774 | return xml_list_helper(cx, xml, vp) != __null; | |
36775 | ||
36776 | return xml_elements_helper(cx, obj, xml, nameqn, vp); | |
36777 | } | |
36778 | ||
36779 | ||
36780 | static JSBool | |
36781 | xml_hasOwnProperty(JSContext *cx, uintN argc, jsval *vp) | |
36782 | { | |
36783 | jsval name; | |
36784 | JSBool found; | |
36785 | ||
36786 | JSObject *obj = ToObject(cx, Valueify(&vp[1])); | |
36787 | if (!obj) | |
36788 | return (JSIntn)0; | |
36789 | if (!InstanceOf(cx, obj, &js_XMLClass, Valueify(vp + 2))) | |
36790 | return (JSIntn)0; | |
36791 | ||
36792 | name = argc != 0 ? vp[2] : ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0)); | |
36793 | if (!HasProperty(cx, obj, name, &found)) | |
36794 | return (JSIntn)0; | |
36795 | if (found) { | |
36796 | *vp = ((((uint64)(uint32)(JSVAL_TAG_BOOLEAN)) << 47) | ((JSIntn)1)); | |
36797 | return (JSIntn)1; | |
36798 | } | |
36799 | return js_HasOwnPropertyHelper(cx, js_LookupProperty, argc, Valueify(vp)); | |
36800 | } | |
36801 | ||
36802 | ||
36803 | static JSBool | |
36804 | xml_hasComplexContent(JSContext *cx, uintN argc, jsval *vp) | |
36805 | { | |
36806 | JSXML *kid; | |
36807 | JSObject *kidobj; | |
36808 | uint32 i, n; | |
36809 | ||
36810 | JSObject *obj = ToObject(cx, Valueify(&vp[1])); if (!obj) return (JSIntn)0; JSXML *xml = (JSXML *)GetInstancePrivate(cx, obj, &js_XMLClass, Valueify(vp+2)); if (!xml) return (JSIntn)0; | |
36811 | again: | |
36812 | switch (xml->xml_class) { | |
36813 | case JSXML_CLASS_ATTRIBUTE: | |
36814 | case JSXML_CLASS_COMMENT: | |
36815 | case JSXML_CLASS_PROCESSING_INSTRUCTION: | |
36816 | case JSXML_CLASS_TEXT: | |
36817 | *vp = ((((uint64)(uint32)(JSVAL_TAG_BOOLEAN)) << 47) | ((JSIntn)0)); | |
36818 | break; | |
36819 | case JSXML_CLASS_LIST: | |
36820 | if (xml->u.list.kids.length == 0) { | |
36821 | *vp = ((((uint64)(uint32)(JSVAL_TAG_BOOLEAN)) << 47) | ((JSIntn)1)); | |
36822 | } else if (xml->u.list.kids.length == 1) { | |
36823 | kid = (((0) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[0] : __null); | |
36824 | if (kid) { | |
36825 | kidobj = js_GetXMLObject(cx, kid); | |
36826 | if (!kidobj) | |
36827 | return (JSIntn)0; | |
36828 | obj = kidobj; | |
36829 | xml = (JSXML *) obj->getPrivate(); | |
36830 | goto again; | |
36831 | } | |
36832 | } | |
36833 | ||
36834 | default: | |
36835 | *vp = ((((uint64)(uint32)(JSVAL_TAG_BOOLEAN)) << 47) | ((JSIntn)0)); | |
36836 | for (i = 0, n = xml->u.list.kids.length; i < n; i++) { | |
36837 | kid = (((i) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[i] : __null); | |
36838 | if (kid && kid->xml_class == JSXML_CLASS_ELEMENT) { | |
36839 | *vp = ((((uint64)(uint32)(JSVAL_TAG_BOOLEAN)) << 47) | ((JSIntn)1)); | |
36840 | break; | |
36841 | } | |
36842 | } | |
36843 | break; | |
36844 | } | |
36845 | return (JSIntn)1; | |
36846 | } | |
36847 | ||
36848 | ||
36849 | static JSBool | |
36850 | xml_hasSimpleContent(JSContext *cx, uintN argc, jsval *vp) | |
36851 | { | |
36852 | JSObject *obj = ToObject(cx, Valueify(&vp[1])); if (!obj) return (JSIntn)0; JSXML *xml = (JSXML *)GetInstancePrivate(cx, obj, &js_XMLClass, Valueify(vp+2)); if (!xml) return (JSIntn)0; | |
36853 | *vp = BOOLEAN_TO_JSVAL(HasSimpleContent(xml)); | |
36854 | return (JSIntn)1; | |
36855 | } | |
36856 | ||
36857 | static JSBool | |
36858 | FindInScopeNamespaces(JSContext *cx, JSXML *xml, JSXMLArray *nsarray) | |
36859 | { | |
36860 | uint32 length, i, j, n; | |
36861 | JSObject *ns, *ns2; | |
36862 | JSLinearString *prefix, *prefix2; | |
36863 | ||
36864 | length = nsarray->length; | |
36865 | do { | |
36866 | if (xml->xml_class != JSXML_CLASS_ELEMENT) | |
36867 | continue; | |
36868 | for (i = 0, n = xml->u.elem.namespaces.length; i < n; i++) { | |
36869 | ns = (((i) < (&xml->u.elem.namespaces)->length) ? (JSObject *) (&xml->u.elem.namespaces)->vector[i] : __null); | |
36870 | if (!ns) | |
36871 | continue; | |
36872 | ||
36873 | prefix = ns->getNamePrefix(); | |
36874 | for (j = 0; j < length; j++) { | |
36875 | ns2 = (((j) < (nsarray)->length) ? (JSObject *) (nsarray)->vector[j] : __null); | |
36876 | if (ns2) { | |
36877 | prefix2 = ns2->getNamePrefix(); | |
36878 | if ((prefix2 && prefix) | |
36879 | ? EqualStrings(prefix2, prefix) | |
36880 | : EqualStrings(ns2->getNameURI(), ns->getNameURI())) { | |
36881 | break; | |
36882 | } | |
36883 | } | |
36884 | } | |
36885 | ||
36886 | if (j == length) { | |
36887 | if (!XMLArrayAddMember(cx, nsarray, (nsarray)->length, (void *)((ns)))) | |
36888 | return (JSIntn)0; | |
36889 | ++length; | |
36890 | } | |
36891 | } | |
36892 | } while ((xml = xml->parent) != __null); | |
36893 | ((void) 0); | |
36894 | ||
36895 | return (JSIntn)1; | |
36896 | } | |
36897 | ||
36898 | ||
36899 | ||
36900 | ||
36901 | ||
36902 | static | |
36903 | ||
36904 | # 5791 "jsxml.cpp" | |
36905 | bool | |
36906 | NamespacesToJSArray(JSContext *cx, JSXMLArray *array, jsval *rval) | |
36907 | { | |
36908 | JSObject *arrayobj = NewDenseEmptyArray(cx); | |
36909 | if (!arrayobj) | |
36910 | return false; | |
36911 | *rval = OBJECT_TO_JSVAL(arrayobj); | |
36912 | ||
36913 | AutoValueRooter tvr(cx); | |
36914 | for (uint32 i = 0, n = array->length; i < n; i++) { | |
36915 | JSObject *ns = (((i) < (array)->length) ? (JSObject *) (array)->vector[i] : __null); | |
36916 | if (!ns) | |
36917 | continue; | |
36918 | tvr.set(ObjectValue(*ns)); | |
36919 | if (!arrayobj->setProperty(cx, INT_TO_JSID(i), tvr.addr(), false)) | |
36920 | return false; | |
36921 | } | |
36922 | return true; | |
36923 | } | |
36924 | ||
36925 | static JSBool | |
36926 | xml_inScopeNamespaces(JSContext *cx, uintN argc, jsval *vp) | |
36927 | { | |
36928 | JSObject *obj; JSXML *xml = StartNonListXMLMethod(cx, vp, &obj); if (!xml) return (JSIntn)0; ((void) 0); | |
36929 | ||
36930 | AutoNamespaceArray namespaces(cx); | |
36931 | return FindInScopeNamespaces(cx, xml, &namespaces.array) && | |
36932 | NamespacesToJSArray(cx, &namespaces.array, vp); | |
36933 | } | |
36934 | ||
36935 | static JSBool | |
36936 | xml_insertChildAfter(JSContext *cx, uintN argc, jsval *vp) | |
36937 | { | |
36938 | jsval arg; | |
36939 | JSXML *kid; | |
36940 | uint32 i; | |
36941 | ||
36942 | JSObject *obj; JSXML *xml = StartNonListXMLMethod(cx, vp, &obj); if (!xml) return (JSIntn)0; ((void) 0); | |
36943 | *vp = OBJECT_TO_JSVAL(obj); | |
36944 | if (!(((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE) || argc == 0) | |
36945 | return (JSIntn)1; | |
36946 | ||
36947 | arg = vp[2]; | |
36948 | if (JSVAL_IS_NULL(arg)) { | |
36949 | kid = __null; | |
36950 | i = 0; | |
36951 | } else { | |
36952 | if (!(!JSVAL_IS_PRIMITIVE(arg) && JSVAL_TO_OBJECT(arg)->isXML())) | |
36953 | return (JSIntn)1; | |
36954 | kid = (JSXML *) JSVAL_TO_OBJECT(arg)->getPrivate(); | |
36955 | i = XMLArrayFindMember(&xml->u.list.kids, (void *)(kid), __null); | |
36956 | if (i == ((uint32) -1)) | |
36957 | return (JSIntn)1; | |
36958 | ++i; | |
36959 | } | |
36960 | ||
36961 | xml = (xml->object == obj ? xml : CopyOnWrite(cx, xml, obj)); | |
36962 | if (!xml) | |
36963 | return (JSIntn)0; | |
36964 | return Insert(cx, xml, i, argc >= 2 ? vp[3] : ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0))); | |
36965 | } | |
36966 | ||
36967 | static JSBool | |
36968 | xml_insertChildBefore(JSContext *cx, uintN argc, jsval *vp) | |
36969 | { | |
36970 | jsval arg; | |
36971 | JSXML *kid; | |
36972 | uint32 i; | |
36973 | ||
36974 | JSObject *obj; JSXML *xml = StartNonListXMLMethod(cx, vp, &obj); if (!xml) return (JSIntn)0; ((void) 0); | |
36975 | *vp = OBJECT_TO_JSVAL(obj); | |
36976 | if (!(((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE) || argc == 0) | |
36977 | return (JSIntn)1; | |
36978 | ||
36979 | arg = vp[2]; | |
36980 | if (JSVAL_IS_NULL(arg)) { | |
36981 | kid = __null; | |
36982 | i = xml->u.list.kids.length; | |
36983 | } else { | |
36984 | if (!(!JSVAL_IS_PRIMITIVE(arg) && JSVAL_TO_OBJECT(arg)->isXML())) | |
36985 | return (JSIntn)1; | |
36986 | kid = (JSXML *) JSVAL_TO_OBJECT(arg)->getPrivate(); | |
36987 | i = XMLArrayFindMember(&xml->u.list.kids, (void *)(kid), __null); | |
36988 | if (i == ((uint32) -1)) | |
36989 | return (JSIntn)1; | |
36990 | } | |
36991 | ||
36992 | xml = (xml->object == obj ? xml : CopyOnWrite(cx, xml, obj)); | |
36993 | if (!xml) | |
36994 | return (JSIntn)0; | |
36995 | return Insert(cx, xml, i, argc >= 2 ? vp[3] : ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0))); | |
36996 | } | |
36997 | ||
36998 | ||
36999 | static JSBool | |
37000 | xml_length(JSContext *cx, uintN argc, jsval *vp) | |
37001 | { | |
37002 | JSObject *obj = ToObject(cx, Valueify(&vp[1])); if (!obj) return (JSIntn)0; JSXML *xml = (JSXML *)GetInstancePrivate(cx, obj, &js_XMLClass, Valueify(vp+2)); if (!xml) return (JSIntn)0; | |
37003 | if (xml->xml_class != JSXML_CLASS_LIST) { | |
37004 | *vp = ((((uint64)(uint32)(JSVAL_TAG_INT32)) << 47) | (1)); | |
37005 | } else { | |
37006 | uint32 l = xml->u.list.kids.length; | |
37007 | if (l <= ((jsint)0x7fffffff)) | |
37008 | *vp = INT_TO_JSVAL(l); | |
37009 | else | |
37010 | *vp = DOUBLE_TO_JSVAL(l); | |
37011 | } | |
37012 | return (JSIntn)1; | |
37013 | } | |
37014 | ||
37015 | static JSBool | |
37016 | xml_localName(JSContext *cx, uintN argc, jsval *vp) | |
37017 | { | |
37018 | JSObject *obj; JSXML *xml = StartNonListXMLMethod(cx, vp, &obj); if (!xml) return (JSIntn)0; ((void) 0); | |
37019 | *vp = xml->name ? xml->name->getQNameLocalNameVal() : ((((uint64)(uint32)(JSVAL_TAG_NULL)) << 47) | (0)); | |
37020 | return (JSIntn)1; | |
37021 | } | |
37022 | ||
37023 | static JSBool | |
37024 | xml_name(JSContext *cx, uintN argc, jsval *vp) | |
37025 | { | |
37026 | JSObject *obj; JSXML *xml = StartNonListXMLMethod(cx, vp, &obj); if (!xml) return (JSIntn)0; ((void) 0); | |
37027 | *vp = OBJECT_TO_JSVAL(xml->name); | |
37028 | return (JSIntn)1; | |
37029 | } | |
37030 | ||
37031 | static JSBool | |
37032 | xml_namespace(JSContext *cx, uintN argc, jsval *vp) | |
37033 | { | |
37034 | JSLinearString *prefix, *nsprefix; | |
37035 | jsuint i, length; | |
37036 | JSObject *ns; | |
37037 | ||
37038 | JSObject *obj; JSXML *xml = StartNonListXMLMethod(cx, vp, &obj); if (!xml) return (JSIntn)0; ((void) 0); | |
37039 | if (argc == 0 && !((uintN)(((xml)->xml_class) - JSXML_CLASS_ELEMENT) <= (uintN)(JSXML_CLASS_PROCESSING_INSTRUCTION - JSXML_CLASS_ELEMENT))) { | |
37040 | *vp = ((((uint64)(uint32)(JSVAL_TAG_NULL)) << 47) | (0)); | |
37041 | return true; | |
37042 | } | |
37043 | ||
37044 | if (argc == 0) { | |
37045 | prefix = __null; | |
37046 | } else { | |
37047 | JSString *str = js_ValueToString(cx, Valueify(vp[2])); | |
37048 | if (!str) | |
37049 | return false; | |
37050 | prefix = str->ensureLinear(cx); | |
37051 | if (!prefix) | |
37052 | return false; | |
37053 | vp[2] = STRING_TO_JSVAL(prefix); | |
37054 | } | |
37055 | ||
37056 | AutoNamespaceArray inScopeNSes(cx); | |
37057 | if (!FindInScopeNamespaces(cx, xml, &inScopeNSes.array)) | |
37058 | return false; | |
37059 | ||
37060 | if (!prefix) { | |
37061 | ns = GetNamespace(cx, xml->name, &inScopeNSes.array); | |
37062 | if (!ns) | |
37063 | return false; | |
37064 | } else { | |
37065 | ns = __null; | |
37066 | for (i = 0, length = inScopeNSes.array.length; i < length; i++) { | |
37067 | ns = (((i) < (&inScopeNSes.array)->length) ? (JSObject *) (&inScopeNSes.array)->vector[i] : __null); | |
37068 | if (ns) { | |
37069 | nsprefix = ns->getNamePrefix(); | |
37070 | if (nsprefix && EqualStrings(nsprefix, prefix)) | |
37071 | break; | |
37072 | ns = __null; | |
37073 | } | |
37074 | } | |
37075 | } | |
37076 | ||
37077 | *vp = (!ns) ? ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0)) : OBJECT_TO_JSVAL(ns); | |
37078 | return true; | |
37079 | } | |
37080 | ||
37081 | static JSBool | |
37082 | xml_namespaceDeclarations(JSContext *cx, uintN argc, jsval *vp) | |
37083 | { | |
37084 | JSObject *obj; JSXML *xml = StartNonListXMLMethod(cx, vp, &obj); if (!xml) return (JSIntn)0; ((void) 0); | |
37085 | if ((((xml)->xml_class) >= JSXML_CLASS_ATTRIBUTE)) | |
37086 | return true; | |
37087 | ||
37088 | AutoNamespaceArray ancestors(cx); | |
37089 | AutoNamespaceArray declared(cx); | |
37090 | ||
37091 | JSXML *yml = xml; | |
37092 | while ((yml = yml->parent) != __null) { | |
37093 | ((void) 0); | |
37094 | for (uint32 i = 0, n = yml->u.elem.namespaces.length; i < n; i++) { | |
37095 | JSObject *ns = (((i) < (&yml->u.elem.namespaces)->length) ? (JSObject *) (&yml->u.elem.namespaces)->vector[i] : __null); | |
37096 | if (ns && !(XMLArrayFindMember(&ancestors.array, (void *)(ns), namespace_match) != ((uint32) -1))) { | |
37097 | if (!XMLArrayAddMember(cx, &ancestors.array, (&ancestors.array)->length, (void *)((ns)))) | |
37098 | return false; | |
37099 | } | |
37100 | } | |
37101 | } | |
37102 | ||
37103 | for (uint32 i = 0, n = xml->u.elem.namespaces.length; i < n; i++) { | |
37104 | JSObject *ns = (((i) < (&xml->u.elem.namespaces)->length) ? (JSObject *) (&xml->u.elem.namespaces)->vector[i] : __null); | |
37105 | if (!ns) | |
37106 | continue; | |
37107 | if (!IsDeclared(ns)) | |
37108 | continue; | |
37109 | if (!(XMLArrayFindMember(&ancestors.array, (void *)(ns), namespace_match) != ((uint32) -1))) { | |
37110 | if (!XMLArrayAddMember(cx, &declared.array, (&declared.array)->length, (void *)((ns)))) | |
37111 | return false; | |
37112 | } | |
37113 | } | |
37114 | ||
37115 | return NamespacesToJSArray(cx, &declared.array, vp); | |
37116 | } | |
37117 | ||
37118 | static const char js_attribute_str[] = "attribute"; | |
37119 | static const char js_text_str[] = "text"; | |
37120 | ||
37121 | ||
37122 | const char *js_xml_class_str[] = { | |
37123 | "list", | |
37124 | "element", | |
37125 | js_attribute_str, | |
37126 | "processing-instruction", | |
37127 | js_text_str, | |
37128 | "comment" | |
37129 | }; | |
37130 | ||
37131 | static JSBool | |
37132 | xml_nodeKind(JSContext *cx, uintN argc, jsval *vp) | |
37133 | { | |
37134 | JSString *str; | |
37135 | ||
37136 | JSObject *obj; JSXML *xml = StartNonListXMLMethod(cx, vp, &obj); if (!xml) return (JSIntn)0; ((void) 0); | |
37137 | str = JS_InternString(cx, js_xml_class_str[xml->xml_class]); | |
37138 | if (!str) | |
37139 | return (JSIntn)0; | |
37140 | *vp = STRING_TO_JSVAL(str); | |
37141 | return (JSIntn)1; | |
37142 | } | |
37143 | ||
37144 | static void | |
37145 | NormalizingDelete(JSContext *cx, JSXML *xml, uint32 index) | |
37146 | { | |
37147 | if (xml->xml_class == JSXML_CLASS_LIST) | |
37148 | DeleteListElement(cx, xml, index); | |
37149 | else | |
37150 | DeleteByIndex(cx, xml, index); | |
37151 | } | |
37152 | ||
37153 | ||
37154 | static JSBool | |
37155 | xml_normalize_helper(JSContext *cx, JSObject *obj, JSXML *xml) | |
37156 | { | |
37157 | JSXML *kid, *kid2; | |
37158 | uint32 i, n; | |
37159 | JSObject *kidobj; | |
37160 | JSString *str; | |
37161 | ||
37162 | if (!(((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE)) | |
37163 | return (JSIntn)1; | |
37164 | ||
37165 | xml = (xml->object == obj ? xml : CopyOnWrite(cx, xml, obj)); | |
37166 | if (!xml) | |
37167 | return (JSIntn)0; | |
37168 | ||
37169 | for (i = 0, n = xml->u.list.kids.length; i < n; i++) { | |
37170 | kid = (((i) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[i] : __null); | |
37171 | if (!kid) | |
37172 | continue; | |
37173 | if (kid->xml_class == JSXML_CLASS_ELEMENT) { | |
37174 | kidobj = js_GetXMLObject(cx, kid); | |
37175 | if (!kidobj || !xml_normalize_helper(cx, kidobj, kid)) | |
37176 | return (JSIntn)0; | |
37177 | } else if (kid->xml_class == JSXML_CLASS_TEXT) { | |
37178 | while (i + 1 < n && | |
37179 | (kid2 = (((i + 1) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[i + 1] : __null)) && | |
37180 | kid2->xml_class == JSXML_CLASS_TEXT) { | |
37181 | str = js_ConcatStrings(cx, kid->u.value, kid2->u.value); | |
37182 | if (!str) | |
37183 | return (JSIntn)0; | |
37184 | NormalizingDelete(cx, xml, i + 1); | |
37185 | n = xml->u.list.kids.length; | |
37186 | kid->u.value = str; | |
37187 | } | |
37188 | if (kid->u.value->empty()) { | |
37189 | NormalizingDelete(cx, xml, i); | |
37190 | n = xml->u.list.kids.length; | |
37191 | --i; | |
37192 | } | |
37193 | } | |
37194 | } | |
37195 | ||
37196 | return (JSIntn)1; | |
37197 | } | |
37198 | ||
37199 | static JSBool | |
37200 | xml_normalize(JSContext *cx, uintN argc, jsval *vp) | |
37201 | { | |
37202 | JSObject *obj = ToObject(cx, Valueify(&vp[1])); if (!obj) return (JSIntn)0; JSXML *xml = (JSXML *)GetInstancePrivate(cx, obj, &js_XMLClass, Valueify(vp+2)); if (!xml) return (JSIntn)0; | |
37203 | *vp = OBJECT_TO_JSVAL(obj); | |
37204 | return xml_normalize_helper(cx, obj, xml); | |
37205 | } | |
37206 | ||
37207 | ||
37208 | static JSBool | |
37209 | xml_parent(JSContext *cx, uintN argc, jsval *vp) | |
37210 | { | |
37211 | JSXML *parent, *kid; | |
37212 | uint32 i, n; | |
37213 | JSObject *parentobj; | |
37214 | ||
37215 | JSObject *obj = ToObject(cx, Valueify(&vp[1])); if (!obj) return (JSIntn)0; JSXML *xml = (JSXML *)GetInstancePrivate(cx, obj, &js_XMLClass, Valueify(vp+2)); if (!xml) return (JSIntn)0; | |
37216 | parent = xml->parent; | |
37217 | if (xml->xml_class == JSXML_CLASS_LIST) { | |
37218 | *vp = ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0)); | |
37219 | n = xml->u.list.kids.length; | |
37220 | if (n == 0) | |
37221 | return (JSIntn)1; | |
37222 | ||
37223 | kid = (((0) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[0] : __null); | |
37224 | if (!kid) | |
37225 | return (JSIntn)1; | |
37226 | parent = kid->parent; | |
37227 | for (i = 1; i < n; i++) { | |
37228 | kid = (((i) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[i] : __null); | |
37229 | if (kid && kid->parent != parent) | |
37230 | return (JSIntn)1; | |
37231 | } | |
37232 | } | |
37233 | ||
37234 | if (!parent) { | |
37235 | *vp = ((((uint64)(uint32)(JSVAL_TAG_NULL)) << 47) | (0)); | |
37236 | return (JSIntn)1; | |
37237 | } | |
37238 | ||
37239 | parentobj = js_GetXMLObject(cx, parent); | |
37240 | if (!parentobj) | |
37241 | return (JSIntn)0; | |
37242 | *vp = OBJECT_TO_JSVAL(parentobj); | |
37243 | return (JSIntn)1; | |
37244 | } | |
37245 | ||
37246 | ||
37247 | static JSBool | |
37248 | xml_processingInstructions_helper(JSContext *cx, JSObject *obj, JSXML *xml, | |
37249 | JSObject *nameqn, jsval *vp) | |
37250 | { | |
37251 | JSXML *list, *vxml; | |
37252 | JSBool ok; | |
37253 | JSObject *kidobj; | |
37254 | jsval v; | |
37255 | uint32 i, n; | |
37256 | ||
37257 | list = xml_list_helper(cx, xml, vp); | |
37258 | if (!list) | |
37259 | return (JSIntn)0; | |
37260 | ||
37261 | list->u.list.targetprop = nameqn; | |
37262 | ok = (JSIntn)1; | |
37263 | ||
37264 | if (xml->xml_class == JSXML_CLASS_LIST) { | |
37265 | ||
37266 | JSXMLArrayCursor cursor(&xml->u.list.kids); | |
37267 | while (JSXML *kid = (JSXML *) cursor.getNext()) { | |
37268 | if (kid->xml_class == JSXML_CLASS_ELEMENT) { | |
37269 | ok = js_EnterLocalRootScope(cx); | |
37270 | if (!ok) | |
37271 | break; | |
37272 | kidobj = js_GetXMLObject(cx, kid); | |
37273 | if (kidobj) { | |
37274 | ok = xml_processingInstructions_helper(cx, kidobj, kid, | |
37275 | nameqn, &v); | |
37276 | } else { | |
37277 | ok = (JSIntn)0; | |
37278 | v = ((((uint64)(uint32)(JSVAL_TAG_NULL)) << 47) | (0)); | |
37279 | } | |
37280 | js_LeaveLocalRootScopeWithResult(cx, Valueify(v)); | |
37281 | if (!ok) | |
37282 | break; | |
37283 | vxml = (JSXML *) JSVAL_TO_OBJECT(v)->getPrivate(); | |
37284 | if (((((vxml)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (vxml)->u.list.kids.length : 0) != 0) { | |
37285 | ok = Append(cx, list, vxml); | |
37286 | if (!ok) | |
37287 | break; | |
37288 | } | |
37289 | } | |
37290 | } | |
37291 | } else { | |
37292 | ||
37293 | for (i = 0, n = ((((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (xml)->u.list.kids.length : 0); i < n; i++) { | |
37294 | JSXML *kid = (((i) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[i] : __null); | |
37295 | if (kid && kid->xml_class == JSXML_CLASS_PROCESSING_INSTRUCTION) { | |
37296 | JSLinearString *localName = nameqn->getQNameLocalName(); | |
37297 | if (((localName)->length() == 1 && *(localName)->chars() == '*') || | |
37298 | EqualStrings(localName, kid->name->getQNameLocalName())) { | |
37299 | ok = Append(cx, list, kid); | |
37300 | if (!ok) | |
37301 | break; | |
37302 | } | |
37303 | } | |
37304 | } | |
37305 | } | |
37306 | ||
37307 | return ok; | |
37308 | } | |
37309 | ||
37310 | static JSBool | |
37311 | xml_processingInstructions(JSContext *cx, uintN argc, jsval *vp) | |
37312 | { | |
37313 | jsval name; | |
37314 | JSObject *nameqn; | |
37315 | jsid funid; | |
37316 | ||
37317 | JSObject *obj = ToObject(cx, Valueify(&vp[1])); if (!obj) return (JSIntn)0; JSXML *xml = (JSXML *)GetInstancePrivate(cx, obj, &js_XMLClass, Valueify(vp+2)); if (!xml) return (JSIntn)0; | |
37318 | ||
37319 | name = (argc == 0) ? STRING_TO_JSVAL((cx->runtime->atomState.starAtom)) : vp[2]; | |
37320 | nameqn = ToXMLName(cx, name, &funid); | |
37321 | if (!nameqn) | |
37322 | return (JSIntn)0; | |
37323 | vp[2] = OBJECT_TO_JSVAL(nameqn); | |
37324 | ||
37325 | if (!JSID_IS_VOID(funid)) | |
37326 | return xml_list_helper(cx, xml, vp) != __null; | |
37327 | ||
37328 | return xml_processingInstructions_helper(cx, obj, xml, nameqn, vp); | |
37329 | } | |
37330 | ||
37331 | static JSBool | |
37332 | xml_prependChild(JSContext *cx, uintN argc, jsval *vp) | |
37333 | { | |
37334 | JSObject *obj; JSXML *xml = StartNonListXMLMethod(cx, vp, &obj); if (!xml) return (JSIntn)0; ((void) 0); | |
37335 | xml = (xml->object == obj ? xml : CopyOnWrite(cx, xml, obj)); | |
37336 | if (!xml) | |
37337 | return (JSIntn)0; | |
37338 | *vp = OBJECT_TO_JSVAL(obj); | |
37339 | return Insert(cx, xml, 0, argc != 0 ? vp[2] : ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0))); | |
37340 | } | |
37341 | ||
37342 | ||
37343 | static JSBool | |
37344 | xml_propertyIsEnumerable(JSContext *cx, uintN argc, jsval *vp) | |
37345 | { | |
37346 | bool isIndex; | |
37347 | uint32 index; | |
37348 | ||
37349 | JSObject *obj = ToObject(cx, Valueify(&vp[1])); if (!obj) return (JSIntn)0; JSXML *xml = (JSXML *)GetInstancePrivate(cx, obj, &js_XMLClass, Valueify(vp+2)); if (!xml) return (JSIntn)0; | |
37350 | *vp = ((((uint64)(uint32)(JSVAL_TAG_BOOLEAN)) << 47) | ((JSIntn)0)); | |
37351 | if (argc != 0) { | |
37352 | if (!js_IdValIsIndex(cx, vp[2], &index, &isIndex)) | |
37353 | return (JSIntn)0; | |
37354 | ||
37355 | if (isIndex) { | |
37356 | if (xml->xml_class == JSXML_CLASS_LIST) { | |
37357 | ||
37358 | *vp = BOOLEAN_TO_JSVAL(index < xml->u.list.kids.length); | |
37359 | } else { | |
37360 | ||
37361 | *vp = BOOLEAN_TO_JSVAL(index == 0); | |
37362 | } | |
37363 | } | |
37364 | } | |
37365 | return (JSIntn)1; | |
37366 | } | |
37367 | ||
37368 | static JSBool | |
37369 | namespace_full_match(const void *a, const void *b) | |
37370 | { | |
37371 | const JSObject *nsa = (const JSObject *) a; | |
37372 | const JSObject *nsb = (const JSObject *) b; | |
37373 | JSLinearString *prefixa = nsa->getNamePrefix(); | |
37374 | JSLinearString *prefixb; | |
37375 | ||
37376 | if (prefixa) { | |
37377 | prefixb = nsb->getNamePrefix(); | |
37378 | if (prefixb && !EqualStrings(prefixa, prefixb)) | |
37379 | return (JSIntn)0; | |
37380 | } | |
37381 | return EqualStrings(nsa->getNameURI(), nsb->getNameURI()); | |
37382 | } | |
37383 | ||
37384 | static JSBool | |
37385 | xml_removeNamespace_helper(JSContext *cx, JSXML *xml, JSObject *ns) | |
37386 | { | |
37387 | JSObject *thisns, *attrns; | |
37388 | uint32 i, n; | |
37389 | JSXML *attr, *kid; | |
37390 | ||
37391 | thisns = GetNamespace(cx, xml->name, &xml->u.elem.namespaces); | |
37392 | ((void) 0); | |
37393 | if (thisns == ns) | |
37394 | return (JSIntn)1; | |
37395 | ||
37396 | for (i = 0, n = xml->u.elem.attrs.length; i < n; i++) { | |
37397 | attr = (((i) < (&xml->u.elem.attrs)->length) ? (JSXML *) (&xml->u.elem.attrs)->vector[i] : __null); | |
37398 | if (!attr) | |
37399 | continue; | |
37400 | attrns = GetNamespace(cx, attr->name, &xml->u.elem.namespaces); | |
37401 | ((void) 0); | |
37402 | if (attrns == ns) | |
37403 | return (JSIntn)1; | |
37404 | } | |
37405 | ||
37406 | i = XMLArrayFindMember(&xml->u.elem.namespaces, (void *)(ns), namespace_full_match); | |
37407 | if (i != ((uint32) -1)) | |
37408 | XMLArrayDelete(cx, &xml->u.elem.namespaces, i, (JSIntn)1); | |
37409 | ||
37410 | for (i = 0, n = xml->u.list.kids.length; i < n; i++) { | |
37411 | kid = (((i) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[i] : __null); | |
37412 | if (kid && kid->xml_class == JSXML_CLASS_ELEMENT) { | |
37413 | if (!xml_removeNamespace_helper(cx, kid, ns)) | |
37414 | return (JSIntn)0; | |
37415 | } | |
37416 | } | |
37417 | return (JSIntn)1; | |
37418 | } | |
37419 | ||
37420 | static JSBool | |
37421 | xml_removeNamespace(JSContext *cx, uintN argc, jsval *vp) | |
37422 | { | |
37423 | JSObject *ns; | |
37424 | ||
37425 | JSObject *obj; JSXML *xml = StartNonListXMLMethod(cx, vp, &obj); if (!xml) return (JSIntn)0; ((void) 0); | |
37426 | if (xml->xml_class != JSXML_CLASS_ELEMENT) | |
37427 | goto done; | |
37428 | xml = (xml->object == obj ? xml : CopyOnWrite(cx, xml, obj)); | |
37429 | if (!xml) | |
37430 | return (JSIntn)0; | |
37431 | ||
37432 | if (!NamespaceHelper(cx, __null, argc == 0 ? -1 : 1, vp + 2, vp)) | |
37433 | return (JSIntn)0; | |
37434 | ((void) 0); | |
37435 | ns = JSVAL_TO_OBJECT(*vp); | |
37436 | ||
37437 | ||
37438 | if (!xml_removeNamespace_helper(cx, xml, ns)) | |
37439 | return (JSIntn)0; | |
37440 | done: | |
37441 | *vp = OBJECT_TO_JSVAL(obj); | |
37442 | return (JSIntn)1; | |
37443 | } | |
37444 | ||
37445 | static JSBool | |
37446 | xml_replace(JSContext *cx, uintN argc, jsval *vp) | |
37447 | { | |
37448 | jsval value; | |
37449 | JSXML *vxml, *kid; | |
37450 | uint32 index, i; | |
37451 | JSObject *nameqn; | |
37452 | ||
37453 | JSObject *obj; JSXML *xml = StartNonListXMLMethod(cx, vp, &obj); if (!xml) return (JSIntn)0; ((void) 0); | |
37454 | if (xml->xml_class != JSXML_CLASS_ELEMENT) | |
37455 | goto done; | |
37456 | ||
37457 | if (argc <= 1) { | |
37458 | value = STRING_TO_JSVAL((cx->runtime->atomState.typeAtoms[JSTYPE_VOID])); | |
37459 | } else { | |
37460 | value = vp[3]; | |
37461 | vxml = (!JSVAL_IS_PRIMITIVE(value) && JSVAL_TO_OBJECT(value)->isXML()) | |
37462 | ? (JSXML *) JSVAL_TO_OBJECT(value)->getPrivate() | |
37463 | : __null; | |
37464 | if (!vxml) { | |
37465 | if (!JS_ConvertValue(cx, value, JSTYPE_STRING, &vp[3])) | |
37466 | return (JSIntn)0; | |
37467 | value = vp[3]; | |
37468 | } else { | |
37469 | vxml = DeepCopy(cx, vxml, __null, 0); | |
37470 | if (!vxml) | |
37471 | return (JSIntn)0; | |
37472 | value = vp[3] = OBJECT_TO_JSVAL(vxml->object); | |
37473 | } | |
37474 | } | |
37475 | ||
37476 | xml = (xml->object == obj ? xml : CopyOnWrite(cx, xml, obj)); | |
37477 | if (!xml) | |
37478 | return (JSIntn)0; | |
37479 | ||
37480 | bool haveIndex; | |
37481 | if (argc == 0) { | |
37482 | haveIndex = false; | |
37483 | } else { | |
37484 | if (!js_IdValIsIndex(cx, vp[2], &index, &haveIndex)) | |
37485 | return (JSIntn)0; | |
37486 | } | |
37487 | ||
37488 | if (!haveIndex) { | |
37489 | ||
37490 | ||
37491 | ||
37492 | ||
37493 | if (!QNameHelper(cx, __null, argc == 0 ? -1 : 1, vp + 2, vp)) | |
37494 | return (JSIntn)0; | |
37495 | ((void) 0); | |
37496 | nameqn = JSVAL_TO_OBJECT(*vp); | |
37497 | ||
37498 | i = xml->u.list.kids.length; | |
37499 | index = ((uint32) -1); | |
37500 | while (i != 0) { | |
37501 | --i; | |
37502 | kid = (((i) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[i] : __null); | |
37503 | if (kid && MatchElemName(nameqn, kid)) { | |
37504 | if (i != ((uint32) -1)) | |
37505 | DeleteByIndex(cx, xml, i); | |
37506 | index = i; | |
37507 | } | |
37508 | } | |
37509 | ||
37510 | if (index == ((uint32) -1)) | |
37511 | goto done; | |
37512 | } | |
37513 | ||
37514 | if (!Replace(cx, xml, index, value)) | |
37515 | return (JSIntn)0; | |
37516 | ||
37517 | done: | |
37518 | *vp = OBJECT_TO_JSVAL(obj); | |
37519 | return (JSIntn)1; | |
37520 | } | |
37521 | ||
37522 | static JSBool | |
37523 | xml_setChildren(JSContext *cx, uintN argc, jsval *vp) | |
37524 | { | |
37525 | JSObject *obj; | |
37526 | ||
37527 | if (!StartNonListXMLMethod(cx, vp, &obj)) | |
37528 | return (JSIntn)0; | |
37529 | ||
37530 | *vp = argc != 0 ? vp[2] : ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0)); | |
37531 | if (!PutProperty(cx, obj, ATOM_TO_JSID(cx->runtime->atomState.starAtom), false, vp)) | |
37532 | return (JSIntn)0; | |
37533 | ||
37534 | *vp = OBJECT_TO_JSVAL(obj); | |
37535 | return (JSIntn)1; | |
37536 | } | |
37537 | ||
37538 | static JSBool | |
37539 | xml_setLocalName(JSContext *cx, uintN argc, jsval *vp) | |
37540 | { | |
37541 | jsval name; | |
37542 | JSObject *nameqn; | |
37543 | JSLinearString *namestr; | |
37544 | ||
37545 | JSObject *obj; JSXML *xml = StartNonListXMLMethod(cx, vp, &obj); if (!xml) return (JSIntn)0; ((void) 0); | |
37546 | if (!((uintN)(((xml)->xml_class) - JSXML_CLASS_ELEMENT) <= (uintN)(JSXML_CLASS_PROCESSING_INSTRUCTION - JSXML_CLASS_ELEMENT))) | |
37547 | return (JSIntn)1; | |
37548 | ||
37549 | if (argc == 0) { | |
37550 | namestr = (cx->runtime->atomState.typeAtoms[JSTYPE_VOID]); | |
37551 | } else { | |
37552 | name = vp[2]; | |
37553 | if (!JSVAL_IS_PRIMITIVE(name) && | |
37554 | JSVAL_TO_OBJECT(name)->getClass() == &js_QNameClass) { | |
37555 | nameqn = JSVAL_TO_OBJECT(name); | |
37556 | namestr = nameqn->getQNameLocalName(); | |
37557 | } else { | |
37558 | if (!JS_ConvertValue(cx, name, JSTYPE_STRING, &vp[2])) | |
37559 | return (JSIntn)0; | |
37560 | name = vp[2]; | |
37561 | namestr = JSVAL_TO_STRING(name)->ensureLinear(cx); | |
37562 | if (!namestr) | |
37563 | return (JSIntn)0; | |
37564 | } | |
37565 | } | |
37566 | ||
37567 | xml = (xml->object == obj ? xml : CopyOnWrite(cx, xml, obj)); | |
37568 | if (!xml) | |
37569 | return (JSIntn)0; | |
37570 | if (namestr) | |
37571 | xml->name->setQNameLocalName(namestr); | |
37572 | return (JSIntn)1; | |
37573 | } | |
37574 | ||
37575 | static JSBool | |
37576 | xml_setName(JSContext *cx, uintN argc, jsval *vp) | |
37577 | { | |
37578 | jsval name; | |
37579 | JSObject *nameqn; | |
37580 | JSXML *nsowner; | |
37581 | JSXMLArray *nsarray; | |
37582 | uint32 i, n; | |
37583 | JSObject *ns; | |
37584 | ||
37585 | JSObject *obj; JSXML *xml = StartNonListXMLMethod(cx, vp, &obj); if (!xml) return (JSIntn)0; ((void) 0); | |
37586 | if (!((uintN)(((xml)->xml_class) - JSXML_CLASS_ELEMENT) <= (uintN)(JSXML_CLASS_PROCESSING_INSTRUCTION - JSXML_CLASS_ELEMENT))) | |
37587 | return (JSIntn)1; | |
37588 | ||
37589 | if (argc == 0) { | |
37590 | name = STRING_TO_JSVAL((cx->runtime->atomState.typeAtoms[JSTYPE_VOID])); | |
37591 | } else { | |
37592 | name = vp[2]; | |
37593 | if (!JSVAL_IS_PRIMITIVE(name) && | |
37594 | JSVAL_TO_OBJECT(name)->getClass() == &js_QNameClass && | |
37595 | !(nameqn = JSVAL_TO_OBJECT(name))->getNameURI()) { | |
37596 | name = vp[2] = nameqn->getQNameLocalNameVal(); | |
37597 | } | |
37598 | } | |
37599 | ||
37600 | nameqn = js_ConstructObject(cx, &js_QNameClass, __null, __null, 1, Valueify(&name)); | |
37601 | if (!nameqn) | |
37602 | return (JSIntn)0; | |
37603 | ||
37604 | ||
37605 | if (xml->xml_class == JSXML_CLASS_PROCESSING_INSTRUCTION) | |
37606 | nameqn->setNameURI(cx->runtime->emptyString); | |
37607 | ||
37608 | xml = (xml->object == obj ? xml : CopyOnWrite(cx, xml, obj)); | |
37609 | if (!xml) | |
37610 | return (JSIntn)0; | |
37611 | xml->name = nameqn; | |
37612 | # 6506 "jsxml.cpp" | |
37613 | if (xml->xml_class == JSXML_CLASS_ELEMENT) { | |
37614 | nsowner = xml; | |
37615 | } else { | |
37616 | if (!xml->parent || xml->parent->xml_class != JSXML_CLASS_ELEMENT) | |
37617 | return (JSIntn)1; | |
37618 | nsowner = xml->parent; | |
37619 | } | |
37620 | ||
37621 | if (nameqn->getNamePrefix()) { | |
37622 | # 6525 "jsxml.cpp" | |
37623 | ns = GetNamespace(cx, nameqn, &nsowner->u.elem.namespaces); | |
37624 | if (!ns) | |
37625 | return (JSIntn)0; | |
37626 | ||
37627 | ||
37628 | if ((XMLArrayFindMember(&nsowner->u.elem.namespaces, (void *)(ns), __null) != ((uint32) -1))) | |
37629 | return (JSIntn)1; | |
37630 | } else { | |
37631 | # 6547 "jsxml.cpp" | |
37632 | ((void) 0); | |
37633 | ||
37634 | nsarray = &nsowner->u.elem.namespaces; | |
37635 | for (i = 0, n = nsarray->length; i < n; i++) { | |
37636 | ns = (((i) < (nsarray)->length) ? (JSObject *) (nsarray)->vector[i] : __null); | |
37637 | if (ns && EqualStrings(ns->getNameURI(), nameqn->getNameURI())) { | |
37638 | nameqn->setNamePrefix(ns->getNamePrefix()); | |
37639 | return (JSIntn)1; | |
37640 | } | |
37641 | } | |
37642 | ||
37643 | ns = NewXMLNamespace(cx, __null, nameqn->getNameURI(), (JSIntn)1); | |
37644 | if (!ns) | |
37645 | return (JSIntn)0; | |
37646 | } | |
37647 | ||
37648 | if (!AddInScopeNamespace(cx, nsowner, ns)) | |
37649 | return (JSIntn)0; | |
37650 | vp[0] = ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0)); | |
37651 | return (JSIntn)1; | |
37652 | } | |
37653 | ||
37654 | static JSBool | |
37655 | xml_setNamespace(JSContext *cx, uintN argc, jsval *vp) | |
37656 | { | |
37657 | JSObject *qn; | |
37658 | JSObject *ns; | |
37659 | jsval qnargv[2]; | |
37660 | JSXML *nsowner; | |
37661 | ||
37662 | JSObject *obj; JSXML *xml = StartNonListXMLMethod(cx, vp, &obj); if (!xml) return (JSIntn)0; ((void) 0); | |
37663 | if (!((uintN)(((xml)->xml_class) - JSXML_CLASS_ELEMENT) <= (uintN)(JSXML_CLASS_PROCESSING_INSTRUCTION - JSXML_CLASS_ELEMENT))) | |
37664 | return (JSIntn)1; | |
37665 | ||
37666 | xml = (xml->object == obj ? xml : CopyOnWrite(cx, xml, obj)); | |
37667 | if (!xml) | |
37668 | return (JSIntn)0; | |
37669 | ||
37670 | ns = js_ConstructObject(cx, &js_NamespaceClass, __null, obj, | |
37671 | argc == 0 ? 0 : 1, Valueify(vp + 2)); | |
37672 | if (!ns) | |
37673 | return (JSIntn)0; | |
37674 | vp[0] = OBJECT_TO_JSVAL(ns); | |
37675 | ns->setNamespaceDeclared(((((uint64)(uint32)(JSVAL_TAG_BOOLEAN)) << 47) | ((JSIntn)1))); | |
37676 | ||
37677 | qnargv[0] = OBJECT_TO_JSVAL(ns); | |
37678 | qnargv[1] = OBJECT_TO_JSVAL(xml->name); | |
37679 | qn = js_ConstructObject(cx, &js_QNameClass, __null, __null, 2, Valueify(qnargv)); | |
37680 | if (!qn) | |
37681 | return (JSIntn)0; | |
37682 | ||
37683 | xml->name = qn; | |
37684 | ||
37685 | ||
37686 | ||
37687 | ||
37688 | ||
37689 | if (xml->xml_class == JSXML_CLASS_ELEMENT) { | |
37690 | nsowner = xml; | |
37691 | } else { | |
37692 | if (!xml->parent || xml->parent->xml_class != JSXML_CLASS_ELEMENT) | |
37693 | return (JSIntn)1; | |
37694 | nsowner = xml->parent; | |
37695 | } | |
37696 | if (!AddInScopeNamespace(cx, nsowner, ns)) | |
37697 | return (JSIntn)0; | |
37698 | vp[0] = ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0)); | |
37699 | return (JSIntn)1; | |
37700 | } | |
37701 | ||
37702 | ||
37703 | static JSBool | |
37704 | xml_text_helper(JSContext *cx, JSObject *obj, JSXML *xml, jsval *vp) | |
37705 | { | |
37706 | JSXML *list, *kid, *vxml; | |
37707 | uint32 i, n; | |
37708 | JSBool ok; | |
37709 | JSObject *kidobj; | |
37710 | jsval v; | |
37711 | ||
37712 | list = xml_list_helper(cx, xml, vp); | |
37713 | if (!list) | |
37714 | return (JSIntn)0; | |
37715 | ||
37716 | if (xml->xml_class == JSXML_CLASS_LIST) { | |
37717 | ok = (JSIntn)1; | |
37718 | for (i = 0, n = xml->u.list.kids.length; i < n; i++) { | |
37719 | kid = (((i) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[i] : __null); | |
37720 | if (kid && kid->xml_class == JSXML_CLASS_ELEMENT) { | |
37721 | ok = js_EnterLocalRootScope(cx); | |
37722 | if (!ok) | |
37723 | break; | |
37724 | kidobj = js_GetXMLObject(cx, kid); | |
37725 | if (kidobj) { | |
37726 | ok = xml_text_helper(cx, kidobj, kid, &v); | |
37727 | } else { | |
37728 | ok = (JSIntn)0; | |
37729 | v = ((((uint64)(uint32)(JSVAL_TAG_NULL)) << 47) | (0)); | |
37730 | } | |
37731 | js_LeaveLocalRootScopeWithResult(cx, Valueify(v)); | |
37732 | if (!ok) | |
37733 | return (JSIntn)0; | |
37734 | vxml = (JSXML *) JSVAL_TO_OBJECT(v)->getPrivate(); | |
37735 | if (((((vxml)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (vxml)->u.list.kids.length : 0) != 0 && !Append(cx, list, vxml)) | |
37736 | return (JSIntn)0; | |
37737 | } | |
37738 | } | |
37739 | } else { | |
37740 | for (i = 0, n = ((((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (xml)->u.list.kids.length : 0); i < n; i++) { | |
37741 | kid = (((i) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[i] : __null); | |
37742 | if (kid && kid->xml_class == JSXML_CLASS_TEXT) { | |
37743 | if (!Append(cx, list, kid)) | |
37744 | return (JSIntn)0; | |
37745 | } | |
37746 | } | |
37747 | } | |
37748 | return (JSIntn)1; | |
37749 | } | |
37750 | ||
37751 | static JSBool | |
37752 | xml_text(JSContext *cx, uintN argc, jsval *vp) | |
37753 | { | |
37754 | JSObject *obj = ToObject(cx, Valueify(&vp[1])); if (!obj) return (JSIntn)0; JSXML *xml = (JSXML *)GetInstancePrivate(cx, obj, &js_XMLClass, Valueify(vp+2)); if (!xml) return (JSIntn)0; | |
37755 | return xml_text_helper(cx, obj, xml, vp); | |
37756 | } | |
37757 | ||
37758 | ||
37759 | static JSString * | |
37760 | xml_toString_helper(JSContext *cx, JSXML *xml) | |
37761 | { | |
37762 | JSString *str, *kidstr; | |
37763 | ||
37764 | if (xml->xml_class == JSXML_CLASS_ATTRIBUTE || | |
37765 | xml->xml_class == JSXML_CLASS_TEXT) { | |
37766 | return xml->u.value; | |
37767 | } | |
37768 | ||
37769 | if (!HasSimpleContent(xml)) | |
37770 | return ToXMLString(cx, OBJECT_TO_JSVAL(xml->object), 0); | |
37771 | ||
37772 | str = cx->runtime->emptyString; | |
37773 | if (!js_EnterLocalRootScope(cx)) | |
37774 | return __null; | |
37775 | JSXMLArrayCursor cursor(&xml->u.list.kids); | |
37776 | while (JSXML *kid = (JSXML *) cursor.getNext()) { | |
37777 | if (kid->xml_class != JSXML_CLASS_COMMENT && | |
37778 | kid->xml_class != JSXML_CLASS_PROCESSING_INSTRUCTION) { | |
37779 | kidstr = xml_toString_helper(cx, kid); | |
37780 | if (!kidstr) { | |
37781 | str = __null; | |
37782 | break; | |
37783 | } | |
37784 | str = js_ConcatStrings(cx, str, kidstr); | |
37785 | if (!str) | |
37786 | break; | |
37787 | } | |
37788 | } | |
37789 | js_LeaveLocalRootScopeWithResult(cx, str); | |
37790 | return str; | |
37791 | } | |
37792 | ||
37793 | static JSBool | |
37794 | xml_toSource(JSContext *cx, uintN argc, jsval *vp) | |
37795 | { | |
37796 | JSObject *obj = ToObject(cx, Valueify(&vp[1])); | |
37797 | if (!obj) | |
37798 | return (JSIntn)0; | |
37799 | JSString *str = ToXMLString(cx, OBJECT_TO_JSVAL(obj), 0x80000000); | |
37800 | if (!str) | |
37801 | return (JSIntn)0; | |
37802 | *vp = STRING_TO_JSVAL(str); | |
37803 | return (JSIntn)1; | |
37804 | } | |
37805 | ||
37806 | static JSBool | |
37807 | xml_toString(JSContext *cx, uintN argc, jsval *vp) | |
37808 | { | |
37809 | JSString *str; | |
37810 | ||
37811 | JSObject *obj = ToObject(cx, Valueify(&vp[1])); if (!obj) return (JSIntn)0; JSXML *xml = (JSXML *)GetInstancePrivate(cx, obj, &js_XMLClass, Valueify(vp+2)); if (!xml) return (JSIntn)0; | |
37812 | str = xml_toString_helper(cx, xml); | |
37813 | if (!str) | |
37814 | return (JSIntn)0; | |
37815 | *vp = STRING_TO_JSVAL(str); | |
37816 | return (JSIntn)1; | |
37817 | } | |
37818 | ||
37819 | ||
37820 | static JSBool | |
37821 | xml_toXMLString(JSContext *cx, uintN argc, jsval *vp) | |
37822 | { | |
37823 | JSObject *obj = ToObject(cx, Valueify(&vp[1])); | |
37824 | if (!obj) | |
37825 | return (JSIntn)0; | |
37826 | JSString *str = ToXMLString(cx, OBJECT_TO_JSVAL(obj), 0); | |
37827 | if (!str) | |
37828 | return (JSIntn)0; | |
37829 | *vp = STRING_TO_JSVAL(str); | |
37830 | return (JSIntn)1; | |
37831 | } | |
37832 | ||
37833 | ||
37834 | static JSBool | |
37835 | xml_valueOf(JSContext *cx, uintN argc, jsval *vp) | |
37836 | { | |
37837 | JSObject *obj = ToObject(cx, Valueify(&vp[1])); | |
37838 | if (!obj) | |
37839 | return false; | |
37840 | *vp = OBJECT_TO_JSVAL(obj); | |
37841 | return true; | |
37842 | } | |
37843 | ||
37844 | static JSFunctionSpec xml_methods[] = { | |
37845 | {"addNamespace", ((JSNative)(xml_addNamespace)), 1, (0) | 0x1000}, | |
37846 | {"appendChild", ((JSNative)(xml_appendChild)), 1, (0) | 0x1000}, | |
37847 | {js_attribute_str, ((JSNative)(xml_attribute)), 1, (0) | 0x1000}, | |
37848 | {"attributes", ((JSNative)(xml_attributes)), 0, (0) | 0x1000}, | |
37849 | {"child", ((JSNative)(xml_child)), 1, (0) | 0x1000}, | |
37850 | {"childIndex", ((JSNative)(xml_childIndex)), 0, (0) | 0x1000}, | |
37851 | {"children", ((JSNative)(xml_children)), 0, (0) | 0x1000}, | |
37852 | {"comments", ((JSNative)(xml_comments)), 0, (0) | 0x1000}, | |
37853 | {"contains", ((JSNative)(xml_contains)), 1, (0) | 0x1000}, | |
37854 | {"copy", ((JSNative)(xml_copy)), 0, (0) | 0x1000}, | |
37855 | {"descendants", ((JSNative)(xml_descendants)), 1, (0) | 0x1000}, | |
37856 | {"elements", ((JSNative)(xml_elements)), 1, (0) | 0x1000}, | |
37857 | {"hasOwnProperty", ((JSNative)(xml_hasOwnProperty)), 1, (0) | 0x1000}, | |
37858 | {"hasComplexContent", ((JSNative)(xml_hasComplexContent)), 1, (0) | 0x1000}, | |
37859 | {"hasSimpleContent", ((JSNative)(xml_hasSimpleContent)), 1, (0) | 0x1000}, | |
37860 | {"inScopeNamespaces", ((JSNative)(xml_inScopeNamespaces)), 0, (0) | 0x1000}, | |
37861 | {"insertChildAfter", ((JSNative)(xml_insertChildAfter)), 2, (0) | 0x1000}, | |
37862 | {"insertChildBefore", ((JSNative)(xml_insertChildBefore)), 2, (0) | 0x1000}, | |
37863 | {js_length_str, ((JSNative)(xml_length)), 0, (0) | 0x1000}, | |
37864 | {js_localName_str, ((JSNative)(xml_localName)), 0, (0) | 0x1000}, | |
37865 | {js_name_str, ((JSNative)(xml_name)), 0, (0) | 0x1000}, | |
37866 | {js_namespace_str, ((JSNative)(xml_namespace)), 1, (0) | 0x1000}, | |
37867 | {"namespaceDeclarations", ((JSNative)(xml_namespaceDeclarations)), 0, (0) | 0x1000}, | |
37868 | {"nodeKind", ((JSNative)(xml_nodeKind)), 0, (0) | 0x1000}, | |
37869 | {"normalize", ((JSNative)(xml_normalize)), 0, (0) | 0x1000}, | |
37870 | {js_xml_parent_str, ((JSNative)(xml_parent)), 0, (0) | 0x1000}, | |
37871 | {"processingInstructions", ((JSNative)(xml_processingInstructions)), 1, (0) | 0x1000}, | |
37872 | {"prependChild", ((JSNative)(xml_prependChild)), 1, (0) | 0x1000}, | |
37873 | {"propertyIsEnumerable", ((JSNative)(xml_propertyIsEnumerable)), 1, (0) | 0x1000}, | |
37874 | {"removeNamespace", ((JSNative)(xml_removeNamespace)), 1, (0) | 0x1000}, | |
37875 | {"replace", ((JSNative)(xml_replace)), 2, (0) | 0x1000}, | |
37876 | {"setChildren", ((JSNative)(xml_setChildren)), 1, (0) | 0x1000}, | |
37877 | {"setLocalName", ((JSNative)(xml_setLocalName)), 1, (0) | 0x1000}, | |
37878 | {"setName", ((JSNative)(xml_setName)), 1, (0) | 0x1000}, | |
37879 | {"setNamespace", ((JSNative)(xml_setNamespace)), 1, (0) | 0x1000}, | |
37880 | {js_text_str, ((JSNative)(xml_text)), 0, (0) | 0x1000}, | |
37881 | {js_toSource_str, ((JSNative)(xml_toSource)), 0, (0) | 0x1000}, | |
37882 | {js_toString_str, ((JSNative)(xml_toString)), 0, (0) | 0x1000}, | |
37883 | {js_toXMLString_str, ((JSNative)(xml_toXMLString)), 0, (0) | 0x1000}, | |
37884 | {js_valueOf_str, ((JSNative)(xml_valueOf)), 0, (0) | 0x1000}, | |
37885 | {__null, __null, 0, 0} | |
37886 | }; | |
37887 | ||
37888 | static JSBool | |
37889 | CopyXMLSettings(JSContext *cx, JSObject *from, JSObject *to) | |
37890 | { | |
37891 | int i; | |
37892 | const char *name; | |
37893 | jsval v; | |
37894 | ||
37895 | ||
37896 | for (i = 0; xml_static_props[i].name; i++) { | |
37897 | name = xml_static_props[i].name; | |
37898 | if (!JS_GetProperty(cx, from, name, &v)) | |
37899 | return false; | |
37900 | if (name == js_prettyIndent_str) { | |
37901 | if (!JSVAL_IS_NUMBER(v)) | |
37902 | continue; | |
37903 | } else { | |
37904 | if (!JSVAL_IS_BOOLEAN(v)) | |
37905 | continue; | |
37906 | } | |
37907 | if (!JS_SetProperty(cx, to, name, &v)) | |
37908 | return false; | |
37909 | } | |
37910 | ||
37911 | return true; | |
37912 | } | |
37913 | ||
37914 | static JSBool | |
37915 | SetDefaultXMLSettings(JSContext *cx, JSObject *obj) | |
37916 | { | |
37917 | int i; | |
37918 | jsval v; | |
37919 | ||
37920 | ||
37921 | for (i = 0; xml_static_props[i].name; i++) { | |
37922 | v = (xml_static_props[i].name != js_prettyIndent_str) | |
37923 | ? ((((uint64)(uint32)(JSVAL_TAG_BOOLEAN)) << 47) | ((JSIntn)1)) : INT_TO_JSVAL(2); | |
37924 | if (!JS_SetProperty(cx, obj, xml_static_props[i].name, &v)) | |
37925 | return (JSIntn)0; | |
37926 | } | |
37927 | return true; | |
37928 | } | |
37929 | ||
37930 | static JSBool | |
37931 | xml_settings(JSContext *cx, uintN argc, jsval *vp) | |
37932 | { | |
37933 | JSObject *settings = JS_NewObject(cx, __null, __null, __null); | |
37934 | if (!settings) | |
37935 | return false; | |
37936 | *vp = OBJECT_TO_JSVAL(settings); | |
37937 | JSObject *obj = ToObject(cx, Valueify(&vp[1])); | |
37938 | if (!obj) | |
37939 | return false; | |
37940 | return CopyXMLSettings(cx, obj, settings); | |
37941 | } | |
37942 | ||
37943 | static JSBool | |
37944 | xml_setSettings(JSContext *cx, uintN argc, jsval *vp) | |
37945 | { | |
37946 | JSObject *settings; | |
37947 | jsval v; | |
37948 | JSBool ok; | |
37949 | ||
37950 | JSObject *obj = ToObject(cx, Valueify(&vp[1])); | |
37951 | if (!obj) | |
37952 | return (JSIntn)0; | |
37953 | v = (argc == 0) ? ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0)) : vp[2]; | |
37954 | if (JSVAL_IS_NULL(v) || JSVAL_IS_VOID(v)) { | |
37955 | ok = SetDefaultXMLSettings(cx, obj); | |
37956 | } else { | |
37957 | if (JSVAL_IS_PRIMITIVE(v)) | |
37958 | return (JSIntn)1; | |
37959 | settings = JSVAL_TO_OBJECT(v); | |
37960 | ok = CopyXMLSettings(cx, settings, obj); | |
37961 | } | |
37962 | return ok; | |
37963 | } | |
37964 | ||
37965 | static JSBool | |
37966 | xml_defaultSettings(JSContext *cx, uintN argc, jsval *vp) | |
37967 | { | |
37968 | JSObject *settings; | |
37969 | ||
37970 | settings = JS_NewObject(cx, __null, __null, __null); | |
37971 | if (!settings) | |
37972 | return (JSIntn)0; | |
37973 | *vp = OBJECT_TO_JSVAL(settings); | |
37974 | return SetDefaultXMLSettings(cx, settings); | |
37975 | } | |
37976 | ||
37977 | static JSFunctionSpec xml_static_methods[] = { | |
37978 | {"settings", ((JSNative)(xml_settings)), 0, (0) | 0x1000}, | |
37979 | {"setSettings", ((JSNative)(xml_setSettings)), 1, (0) | 0x1000}, | |
37980 | {"defaultSettings", ((JSNative)(xml_defaultSettings)), 0, (0) | 0x1000}, | |
37981 | {__null, __null, 0, 0} | |
37982 | }; | |
37983 | ||
37984 | static JSBool | |
37985 | XML(JSContext *cx, uintN argc, Value *vp) | |
37986 | { | |
37987 | JSXML *xml, *copy; | |
37988 | JSObject *xobj, *vobj; | |
37989 | Class *clasp; | |
37990 | ||
37991 | jsval v = argc ? Jsvalify(vp[2]) : ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0)); | |
37992 | ||
37993 | if (JSVAL_IS_NULL(v) || JSVAL_IS_VOID(v)) | |
37994 | v = STRING_TO_JSVAL(cx->runtime->emptyString); | |
37995 | ||
37996 | xobj = ToXML(cx, v); | |
37997 | if (!xobj) | |
37998 | return (JSIntn)0; | |
37999 | xml = (JSXML *) xobj->getPrivate(); | |
38000 | ||
38001 | if (IsConstructing(vp) && !JSVAL_IS_PRIMITIVE(v)) { | |
38002 | vobj = JSVAL_TO_OBJECT(v); | |
38003 | clasp = vobj->getClass(); | |
38004 | if (clasp == &js_XMLClass || | |
38005 | (clasp->flags & (1<<7))) { | |
38006 | copy = DeepCopy(cx, xml, __null, 0); | |
38007 | if (!copy) | |
38008 | return (JSIntn)0; | |
38009 | vp->setObject(*copy->object); | |
38010 | return (JSIntn)1; | |
38011 | } | |
38012 | } | |
38013 | ||
38014 | vp->setObject(*xobj); | |
38015 | return (JSIntn)1; | |
38016 | } | |
38017 | ||
38018 | static JSBool | |
38019 | XMLList(JSContext *cx, uintN argc, jsval *vp) | |
38020 | { | |
38021 | JSObject *vobj, *listobj; | |
38022 | JSXML *xml, *list; | |
38023 | ||
38024 | jsval v = argc ? vp[2] : ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0)); | |
38025 | ||
38026 | if (JSVAL_IS_NULL(v) || JSVAL_IS_VOID(v)) | |
38027 | v = STRING_TO_JSVAL(cx->runtime->emptyString); | |
38028 | ||
38029 | if (IsConstructing(Valueify(vp)) && !JSVAL_IS_PRIMITIVE(v)) { | |
38030 | vobj = JSVAL_TO_OBJECT(v); | |
38031 | if (vobj->isXML()) { | |
38032 | xml = (JSXML *) vobj->getPrivate(); | |
38033 | if (xml->xml_class == JSXML_CLASS_LIST) { | |
38034 | listobj = js_NewXMLObject(cx, JSXML_CLASS_LIST); | |
38035 | if (!listobj) | |
38036 | return (JSIntn)0; | |
38037 | *vp = OBJECT_TO_JSVAL(listobj); | |
38038 | ||
38039 | list = (JSXML *) listobj->getPrivate(); | |
38040 | if (!Append(cx, list, xml)) | |
38041 | return (JSIntn)0; | |
38042 | return (JSIntn)1; | |
38043 | } | |
38044 | } | |
38045 | } | |
38046 | ||
38047 | ||
38048 | listobj = ToXMLList(cx, v); | |
38049 | if (!listobj) | |
38050 | return (JSIntn)0; | |
38051 | ||
38052 | *vp = OBJECT_TO_JSVAL(listobj); | |
38053 | return (JSIntn)1; | |
38054 | } | |
38055 | ||
38056 | ||
38057 | ||
38058 | ||
38059 | ||
38060 | ||
38061 | JSXML * | |
38062 | js_NewXML(JSContext *cx, JSXMLClass xml_class) | |
38063 | { | |
38064 | JSXML *xml = js_NewGCXML(cx); | |
38065 | if (!xml) | |
38066 | return __null; | |
38067 | ||
38068 | xml->object = __null; | |
38069 | xml->domnode = __null; | |
38070 | xml->parent = __null; | |
38071 | xml->name = __null; | |
38072 | xml->xml_class = xml_class; | |
38073 | xml->xml_flags = 0; | |
38074 | if (((xml_class) >= JSXML_CLASS_ATTRIBUTE)) { | |
38075 | xml->u.value = cx->runtime->emptyString; | |
38076 | } else { | |
38077 | xml->u.list.kids.init(); | |
38078 | if (xml_class == JSXML_CLASS_LIST) { | |
38079 | xml->u.list.target = __null; | |
38080 | xml->u.list.targetprop = __null; | |
38081 | } else { | |
38082 | xml->u.elem.namespaces.init(); | |
38083 | xml->u.elem.attrs.init(); | |
38084 | } | |
38085 | } | |
38086 | ||
38087 | ||
38088 | ||
38089 | ||
38090 | ||
38091 | ; | |
38092 | return xml; | |
38093 | } | |
38094 | ||
38095 | void | |
38096 | js_TraceXML(JSTracer *trc, JSXML *xml) | |
38097 | { | |
38098 | if (xml->object) | |
38099 | MarkObject(trc, *xml->object, "object"); | |
38100 | if (xml->name) | |
38101 | MarkObject(trc, *xml->name, "name"); | |
38102 | if (xml->parent) | |
38103 | do { do { } while (0); JS_CallTracer((trc), (xml->parent), (2)); } while (0); | |
38104 | ||
38105 | if ((((xml)->xml_class) >= JSXML_CLASS_ATTRIBUTE)) { | |
38106 | if (xml->u.value) | |
38107 | MarkString(trc, xml->u.value, "value"); | |
38108 | return; | |
38109 | } | |
38110 | ||
38111 | xml_trace_vector(trc, | |
38112 | (JSXML **) xml->u.list.kids.vector, | |
38113 | xml->u.list.kids.length); | |
38114 | XMLArrayCursorTrace(trc, xml->u.list.kids.cursors); | |
38115 | if (((trc)->callback == __null)) | |
38116 | xml->u.list.kids.trim(); | |
38117 | ||
38118 | if (xml->xml_class == JSXML_CLASS_LIST) { | |
38119 | if (xml->u.list.target) | |
38120 | do { do { } while (0); JS_CallTracer((trc), (xml->u.list.target), (2)); } while (0); | |
38121 | if (xml->u.list.targetprop) | |
38122 | MarkObject(trc, *xml->u.list.targetprop, "targetprop"); | |
38123 | } else { | |
38124 | MarkObjectRange(trc, xml->u.elem.namespaces.length, | |
38125 | (JSObject **) xml->u.elem.namespaces.vector, | |
38126 | "xml_namespaces"); | |
38127 | XMLArrayCursorTrace(trc, xml->u.elem.namespaces.cursors); | |
38128 | if (((trc)->callback == __null)) | |
38129 | xml->u.elem.namespaces.trim(); | |
38130 | ||
38131 | xml_trace_vector(trc, | |
38132 | (JSXML **) xml->u.elem.attrs.vector, | |
38133 | xml->u.elem.attrs.length); | |
38134 | XMLArrayCursorTrace(trc, xml->u.elem.attrs.cursors); | |
38135 | if (((trc)->callback == __null)) | |
38136 | xml->u.elem.attrs.trim(); | |
38137 | } | |
38138 | } | |
38139 | ||
38140 | JSObject * | |
38141 | js_NewXMLObject(JSContext *cx, JSXMLClass xml_class) | |
38142 | { | |
38143 | JSXML *xml = js_NewXML(cx, xml_class); | |
38144 | if (!xml) | |
38145 | return __null; | |
38146 | ||
38147 | AutoXMLRooter root(cx, xml); | |
38148 | return js_GetXMLObject(cx, xml); | |
38149 | } | |
38150 | ||
38151 | static JSObject * | |
38152 | NewXMLObject(JSContext *cx, JSXML *xml) | |
38153 | { | |
38154 | JSObject *obj; | |
38155 | ||
38156 | obj = NewNonFunction<WithProto::Class>(cx, &js_XMLClass, __null, __null); | |
38157 | if (!obj) | |
38158 | return __null; | |
38159 | obj->setPrivate(xml); | |
38160 | ; | |
38161 | return obj; | |
38162 | } | |
38163 | ||
38164 | JSObject * | |
38165 | js_GetXMLObject(JSContext *cx, JSXML *xml) | |
38166 | { | |
38167 | JSObject *obj; | |
38168 | ||
38169 | obj = xml->object; | |
38170 | if (obj) { | |
38171 | ((void) 0); | |
38172 | return obj; | |
38173 | } | |
38174 | ||
38175 | obj = NewXMLObject(cx, xml); | |
38176 | if (!obj) | |
38177 | return __null; | |
38178 | xml->object = obj; | |
38179 | return obj; | |
38180 | } | |
38181 | ||
38182 | JSObject * | |
38183 | js_InitNamespaceClass(JSContext *cx, JSObject *obj) | |
38184 | { | |
38185 | return js_InitClass(cx, obj, __null, &js_NamespaceClass, Namespace, 2, | |
38186 | namespace_props, namespace_methods, __null, __null); | |
38187 | } | |
38188 | ||
38189 | JSObject * | |
38190 | js_InitQNameClass(JSContext *cx, JSObject *obj) | |
38191 | { | |
38192 | return js_InitClass(cx, obj, __null, &js_QNameClass, QName, 2, | |
38193 | qname_props, qname_methods, __null, __null); | |
38194 | } | |
38195 | ||
38196 | JSObject * | |
38197 | js_InitXMLClass(JSContext *cx, JSObject *obj) | |
38198 | { | |
38199 | JSObject *proto, *pobj; | |
38200 | JSFunction *fun; | |
38201 | JSXML *xml; | |
38202 | JSProperty *prop; | |
38203 | Shape *shape; | |
38204 | jsval cval, vp[3]; | |
38205 | ||
38206 | ||
38207 | if (!JS_DefineFunction(cx, obj, js_isXMLName_str, xml_isXMLName, 1, 0)) | |
38208 | return __null; | |
38209 | ||
38210 | ||
38211 | proto = js_InitClass(cx, obj, __null, &js_XMLClass, XML, 1, | |
38212 | __null, xml_methods, | |
38213 | xml_static_props, xml_static_methods); | |
38214 | if (!proto) | |
38215 | return __null; | |
38216 | ||
38217 | xml = js_NewXML(cx, JSXML_CLASS_TEXT); | |
38218 | if (!xml) | |
38219 | return __null; | |
38220 | proto->setPrivate(xml); | |
38221 | xml->object = proto; | |
38222 | ; | |
38223 | ||
38224 | ||
38225 | ||
38226 | ||
38227 | ||
38228 | ||
38229 | ||
38230 | if (!js_LookupProperty(cx, proto, | |
38231 | ATOM_TO_JSID(cx->runtime->atomState.constructorAtom), | |
38232 | &pobj, &prop)) { | |
38233 | return __null; | |
38234 | } | |
38235 | ((void) 0); | |
38236 | shape = (Shape *) prop; | |
38237 | cval = Jsvalify(pobj->nativeGetSlot(shape->slot)); | |
38238 | ((void) 0); | |
38239 | ||
38240 | ||
38241 | vp[0] = ((((uint64)(uint32)(JSVAL_TAG_NULL)) << 47) | (0)); | |
38242 | vp[1] = cval; | |
38243 | vp[2] = ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0)); | |
38244 | if (!xml_setSettings(cx, 1, vp)) | |
38245 | return __null; | |
38246 | ||
38247 | ||
38248 | fun = JS_DefineFunction(cx, obj, js_XMLList_str, XMLList, 1, 0x0200); | |
38249 | if (!fun) | |
38250 | return __null; | |
38251 | if (!js_SetClassPrototype(cx, (static_cast<JSObject *>(fun)), proto, | |
38252 | 0x02 | 0x04)) { | |
38253 | return __null; | |
38254 | } | |
38255 | return proto; | |
38256 | } | |
38257 | ||
38258 | JSObject * | |
38259 | js_InitXMLClasses(JSContext *cx, JSObject *obj) | |
38260 | { | |
38261 | if (!js_InitNamespaceClass(cx, obj)) | |
38262 | return __null; | |
38263 | if (!js_InitQNameClass(cx, obj)) | |
38264 | return __null; | |
38265 | return js_InitXMLClass(cx, obj); | |
38266 | } | |
38267 | ||
38268 | JSBool | |
38269 | js_GetFunctionNamespace(JSContext *cx, Value *vp) | |
38270 | { | |
38271 | JSObject *global = cx->hasfp() ? cx->fp()->scopeChain().getGlobal() : cx->globalObject; | |
38272 | ||
38273 | *vp = global->getReservedSlot(((((JSProto_LIMIT * 3) + 1) + 1) + 1)); | |
38274 | if (vp->isUndefined()) { | |
38275 | JSRuntime *rt = cx->runtime; | |
38276 | JSLinearString *prefix = rt->atomState.typeAtoms[JSTYPE_FUNCTION]; | |
38277 | JSLinearString *uri = rt->atomState.functionNamespaceURIAtom; | |
38278 | JSObject *obj = NewXMLNamespace(cx, prefix, uri, (JSIntn)0); | |
38279 | if (!obj) | |
38280 | return false; | |
38281 | # 7204 "jsxml.cpp" | |
38282 | obj->clearProto(); | |
38283 | ||
38284 | vp->setObject(*obj); | |
38285 | if (!js_SetReservedSlot(cx, global, ((((JSProto_LIMIT * 3) + 1) + 1) + 1), *vp)) | |
38286 | return false; | |
38287 | } | |
38288 | ||
38289 | return true; | |
38290 | } | |
38291 | # 7229 "jsxml.cpp" | |
38292 | JSBool | |
38293 | js_GetDefaultXMLNamespace(JSContext *cx, jsval *vp) | |
38294 | { | |
38295 | JSObject *ns, *obj, *tmp; | |
38296 | jsval v; | |
38297 | ||
38298 | JSObject *scopeChain = GetScopeChain(cx); | |
38299 | ||
38300 | obj = __null; | |
38301 | for (tmp = scopeChain; tmp; tmp = tmp->getParent()) { | |
38302 | Class *clasp = tmp->getClass(); | |
38303 | if (clasp == &js_BlockClass || clasp == &js_WithClass) | |
38304 | continue; | |
38305 | if (!tmp->getProperty(cx, ((jsid)0x6), Valueify(&v))) | |
38306 | return (JSIntn)0; | |
38307 | if (!JSVAL_IS_PRIMITIVE(v)) { | |
38308 | *vp = v; | |
38309 | return (JSIntn)1; | |
38310 | } | |
38311 | obj = tmp; | |
38312 | } | |
38313 | ||
38314 | ns = js_ConstructObject(cx, &js_NamespaceClass, __null, obj, 0, __null); | |
38315 | if (!ns) | |
38316 | return (JSIntn)0; | |
38317 | v = OBJECT_TO_JSVAL(ns); | |
38318 | if (!obj->defineProperty(cx, ((jsid)0x6), Valueify(v), | |
38319 | PropertyStub, StrictPropertyStub, 0x04)) { | |
38320 | return (JSIntn)0; | |
38321 | } | |
38322 | *vp = v; | |
38323 | return (JSIntn)1; | |
38324 | } | |
38325 | ||
38326 | JSBool | |
38327 | js_SetDefaultXMLNamespace(JSContext *cx, const Value &v) | |
38328 | { | |
38329 | Value argv[2]; | |
38330 | argv[0].setString(cx->runtime->emptyString); | |
38331 | argv[1] = v; | |
38332 | JSObject *ns = js_ConstructObject(cx, &js_NamespaceClass, __null, __null, 2, argv); | |
38333 | if (!ns) | |
38334 | return (JSIntn)0; | |
38335 | ||
38336 | JSStackFrame *fp = js_GetTopStackFrame(cx); | |
38337 | JSObject &varobj = fp->varobj(cx); | |
38338 | if (!varobj.defineProperty(cx, ((jsid)0x6), ObjectValue(*ns), | |
38339 | PropertyStub, StrictPropertyStub, 0x04)) { | |
38340 | return (JSIntn)0; | |
38341 | } | |
38342 | return (JSIntn)1; | |
38343 | } | |
38344 | ||
38345 | JSBool | |
38346 | js_ToAttributeName(JSContext *cx, Value *vp) | |
38347 | { | |
38348 | JSObject *qn; | |
38349 | ||
38350 | qn = ToAttributeName(cx, Jsvalify(*vp)); | |
38351 | if (!qn) | |
38352 | return (JSIntn)0; | |
38353 | vp->setObject(*qn); | |
38354 | return (JSIntn)1; | |
38355 | } | |
38356 | ||
38357 | JSFlatString * | |
38358 | js_EscapeAttributeValue(JSContext *cx, JSString *str, JSBool quote) | |
38359 | { | |
38360 | StringBuffer sb(cx); | |
38361 | return EscapeAttributeValue(cx, sb, str, quote); | |
38362 | } | |
38363 | ||
38364 | JSString * | |
38365 | js_AddAttributePart(JSContext *cx, JSBool isName, JSString *str, JSString *str2) | |
38366 | { | |
38367 | size_t len = str->length(); | |
38368 | const jschar *chars = str->getChars(cx); | |
38369 | if (!chars) | |
38370 | return __null; | |
38371 | ||
38372 | size_t len2 = str2->length(); | |
38373 | const jschar *chars2 = str2->getChars(cx); | |
38374 | if (!chars2) | |
38375 | return __null; | |
38376 | ||
38377 | size_t newlen = (isName) ? len + 1 + len2 : len + 2 + len2 + 1; | |
38378 | jschar *newchars = (jschar *) cx->malloc((newlen+1) * sizeof(jschar)); | |
38379 | if (!newchars) | |
38380 | return __null; | |
38381 | ||
38382 | memcpy((newchars), (chars), (len) * sizeof(jschar)); | |
38383 | newchars += len; | |
38384 | if (isName) { | |
38385 | *newchars++ = ' '; | |
38386 | memcpy((newchars), (chars2), (len2) * sizeof(jschar)); | |
38387 | newchars += len2; | |
38388 | } else { | |
38389 | *newchars++ = '='; | |
38390 | *newchars++ = '"'; | |
38391 | memcpy((newchars), (chars2), (len2) * sizeof(jschar)); | |
38392 | newchars += len2; | |
38393 | *newchars++ = '"'; | |
38394 | } | |
38395 | *newchars = 0; | |
38396 | return js_NewString(cx, newchars - newlen, newlen); | |
38397 | } | |
38398 | ||
38399 | JSFlatString * | |
38400 | js_EscapeElementValue(JSContext *cx, JSString *str) | |
38401 | { | |
38402 | StringBuffer sb(cx); | |
38403 | return EscapeElementValue(cx, sb, str, 0); | |
38404 | } | |
38405 | ||
38406 | JSString * | |
38407 | js_ValueToXMLString(JSContext *cx, const Value &v) | |
38408 | { | |
38409 | return ToXMLString(cx, Jsvalify(v), 0); | |
38410 | } | |
38411 | ||
38412 | JSBool | |
38413 | js_GetAnyName(JSContext *cx, jsid *idp) | |
38414 | { | |
38415 | JSObject *global = cx->hasfp() ? cx->fp()->scopeChain().getGlobal() : cx->globalObject; | |
38416 | Value v = global->getReservedSlot(JSProto_AnyName); | |
38417 | if (v.isUndefined()) { | |
38418 | JSObject *obj = NewNonFunction<WithProto::Given>(cx, &js_AnyNameClass, __null, global); | |
38419 | if (!obj) | |
38420 | return false; | |
38421 | ||
38422 | ((void) 0); | |
38423 | ||
38424 | JSRuntime *rt = cx->runtime; | |
38425 | InitXMLQName(obj, rt->emptyString, rt->emptyString, | |
38426 | (rt->atomState.starAtom)); | |
38427 | ; | |
38428 | ||
38429 | v.setObject(*obj); | |
38430 | if (!js_SetReservedSlot(cx, global, JSProto_AnyName, v)) | |
38431 | return false; | |
38432 | } | |
38433 | *idp = OBJECT_TO_JSID(&v.toObject()); | |
38434 | return true; | |
38435 | } | |
38436 | ||
38437 | JSBool | |
38438 | js_FindXMLProperty(JSContext *cx, const Value &nameval, JSObject **objp, jsid *idp) | |
38439 | { | |
38440 | JSObject *nameobj; | |
38441 | jsval v; | |
38442 | JSObject *qn; | |
38443 | jsid funid; | |
38444 | JSObject *obj, *target, *proto, *pobj; | |
38445 | JSXML *xml; | |
38446 | JSBool found; | |
38447 | JSProperty *prop; | |
38448 | ||
38449 | ((void) 0); | |
38450 | nameobj = &nameval.toObject(); | |
38451 | if (nameobj->getClass() == &js_AnyNameClass) { | |
38452 | v = STRING_TO_JSVAL((cx->runtime->atomState.starAtom)); | |
38453 | nameobj = js_ConstructObject(cx, &js_QNameClass, __null, __null, 1, | |
38454 | Valueify(&v)); | |
38455 | if (!nameobj) | |
38456 | return (JSIntn)0; | |
38457 | } else { | |
38458 | ((void) 0) | |
38459 | ; | |
38460 | } | |
38461 | ||
38462 | qn = nameobj; | |
38463 | if (!IsFunctionQName(cx, qn, &funid)) | |
38464 | return (JSIntn)0; | |
38465 | ||
38466 | obj = &js_GetTopStackFrame(cx)->scopeChain(); | |
38467 | do { | |
38468 | ||
38469 | target = obj; | |
38470 | while (target->getClass() == &js_WithClass) { | |
38471 | proto = target->getProto(); | |
38472 | if (!proto) | |
38473 | break; | |
38474 | target = proto; | |
38475 | } | |
38476 | ||
38477 | if (target->isXML()) { | |
38478 | if (JSID_IS_VOID(funid)) { | |
38479 | xml = (JSXML *) target->getPrivate(); | |
38480 | found = HasNamedProperty(xml, qn); | |
38481 | } else { | |
38482 | if (!HasFunctionProperty(cx, target, funid, &found)) | |
38483 | return (JSIntn)0; | |
38484 | } | |
38485 | if (found) { | |
38486 | *idp = OBJECT_TO_JSID(nameobj); | |
38487 | *objp = target; | |
38488 | return (JSIntn)1; | |
38489 | } | |
38490 | } else if (!JSID_IS_VOID(funid)) { | |
38491 | if (!target->lookupProperty(cx, funid, &pobj, &prop)) | |
38492 | return (JSIntn)0; | |
38493 | if (prop) { | |
38494 | *idp = funid; | |
38495 | *objp = target; | |
38496 | return (JSIntn)1; | |
38497 | } | |
38498 | } | |
38499 | } while ((obj = obj->getParent()) != __null); | |
38500 | ||
38501 | JSAutoByteString printable; | |
38502 | JSString *str = ConvertQNameToString(cx, nameobj); | |
38503 | if (str && js_ValueToPrintable(cx, StringValue(str), &printable)) { | |
38504 | JS_ReportErrorFlagsAndNumber(cx, 0x0, js_GetErrorMessage, __null, | |
38505 | JSMSG_UNDEFINED_XML_NAME, printable.ptr()); | |
38506 | } | |
38507 | return (JSIntn)0; | |
38508 | } | |
38509 | ||
38510 | static JSBool | |
38511 | GetXMLFunction(JSContext *cx, JSObject *obj, jsid id, jsval *vp) | |
38512 | { | |
38513 | ((void) 0); | |
38514 | ||
38515 | ||
38516 | ||
38517 | ||
38518 | ||
38519 | JSObject *target = obj; | |
38520 | AutoObjectRooter tvr(cx); | |
38521 | for (;;) { | |
38522 | if (!js_GetProperty(cx, target, id, Valueify(vp))) | |
38523 | return false; | |
38524 | if ((!JSVAL_IS_PRIMITIVE(*vp) && JSVAL_TO_OBJECT(*vp)->isFunction())) | |
38525 | return true; | |
38526 | target = target->getProto(); | |
38527 | if (target == __null || !target->isNative()) | |
38528 | break; | |
38529 | tvr.setObject(target); | |
38530 | } | |
38531 | ||
38532 | JSXML *xml = (JSXML *) obj->getPrivate(); | |
38533 | if (!HasSimpleContent(xml)) | |
38534 | return true; | |
38535 | ||
38536 | ||
38537 | if (!js_GetClassPrototype(cx, __null, JSProto_String, tvr.addr())) | |
38538 | return false; | |
38539 | ||
38540 | ((void) 0); | |
38541 | return tvr.object()->getProperty(cx, id, Valueify(vp)); | |
38542 | } | |
38543 | ||
38544 | static JSXML * | |
38545 | GetPrivate(JSContext *cx, JSObject *obj, const char *method) | |
38546 | { | |
38547 | JSXML *xml; | |
38548 | ||
38549 | xml = (JSXML *) GetInstancePrivate(cx, obj, &js_XMLClass, __null); | |
38550 | if (!xml) { | |
38551 | JS_ReportErrorNumber(cx, js_GetErrorMessage, __null, | |
38552 | JSMSG_INCOMPATIBLE_METHOD, | |
38553 | js_XML_str, method, obj->getClass()->name); | |
38554 | } | |
38555 | return xml; | |
38556 | } | |
38557 | ||
38558 | JSBool | |
38559 | js_GetXMLDescendants(JSContext *cx, JSObject *obj, jsval id, jsval *vp) | |
38560 | { | |
38561 | JSXML *xml, *list; | |
38562 | ||
38563 | xml = GetPrivate(cx, obj, "descendants internal method"); | |
38564 | if (!xml) | |
38565 | return (JSIntn)0; | |
38566 | ||
38567 | list = Descendants(cx, xml, id); | |
38568 | if (!list) | |
38569 | return (JSIntn)0; | |
38570 | *vp = OBJECT_TO_JSVAL(list->object); | |
38571 | return (JSIntn)1; | |
38572 | } | |
38573 | ||
38574 | JSBool | |
38575 | js_DeleteXMLListElements(JSContext *cx, JSObject *listobj) | |
38576 | { | |
38577 | JSXML *list; | |
38578 | uint32 n; | |
38579 | ||
38580 | list = (JSXML *) listobj->getPrivate(); | |
38581 | for (n = list->u.list.kids.length; n != 0; --n) | |
38582 | DeleteListElement(cx, list, 0); | |
38583 | ||
38584 | return (JSIntn)1; | |
38585 | } | |
38586 | ||
38587 | struct JSXMLFilter | |
38588 | { | |
38589 | JSXML *list; | |
38590 | JSXML *result; | |
38591 | JSXML *kid; | |
38592 | JSXMLArrayCursor cursor; | |
38593 | ||
38594 | JSXMLFilter(JSXML *list, JSXMLArray *array) | |
38595 | : list(list), result(__null), kid(__null), cursor(array) {} | |
38596 | ||
38597 | ~JSXMLFilter() {} | |
38598 | }; | |
38599 | ||
38600 | static void | |
38601 | xmlfilter_trace(JSTracer *trc, JSObject *obj) | |
38602 | { | |
38603 | JSXMLFilter *filter = (JSXMLFilter *) obj->getPrivate(); | |
38604 | if (!filter) | |
38605 | return; | |
38606 | ||
38607 | ((void) 0); | |
38608 | do { do { } while (0); JS_CallTracer((trc), (filter->list), (2)); } while (0); | |
38609 | if (filter->result) | |
38610 | do { do { } while (0); JS_CallTracer((trc), (filter->result), (2)); } while (0); | |
38611 | if (filter->kid) | |
38612 | do { do { } while (0); JS_CallTracer((trc), (filter->kid), (2)); } while (0); | |
38613 | ||
38614 | ||
38615 | ||
38616 | ||
38617 | ||
38618 | } | |
38619 | ||
38620 | static void | |
38621 | xmlfilter_finalize(JSContext *cx, JSObject *obj) | |
38622 | { | |
38623 | JSXMLFilter *filter = (JSXMLFilter *) obj->getPrivate(); | |
38624 | if (!filter) | |
38625 | return; | |
38626 | ||
38627 | cx->destroy(filter); | |
38628 | } | |
38629 | ||
38630 | Class js_XMLFilterClass = { | |
38631 | "XMLFilter", | |
38632 | (1<<0) | (1<<((8 + 8)+1)) | (1<<((8 + 8)+3)), | |
38633 | PropertyStub, | |
38634 | PropertyStub, | |
38635 | PropertyStub, | |
38636 | StrictPropertyStub, | |
38637 | EnumerateStub, | |
38638 | ResolveStub, | |
38639 | ConvertStub, | |
38640 | xmlfilter_finalize, | |
38641 | __null, | |
38642 | __null, | |
38643 | __null, | |
38644 | __null, | |
38645 | __null, | |
38646 | __null, | |
38647 | ((JSMarkOp)(xmlfilter_trace)) | |
38648 | }; | |
38649 | ||
38650 | JSBool | |
38651 | js_StepXMLListFilter(JSContext *cx, JSBool initialized) | |
38652 | { | |
38653 | jsval *sp; | |
38654 | JSObject *obj, *filterobj, *resobj, *kidobj; | |
38655 | JSXML *xml, *list; | |
38656 | JSXMLFilter *filter; | |
38657 | ||
38658 | LeaveTrace(cx); | |
38659 | sp = Jsvalify(cx->regs->sp); | |
38660 | if (!initialized) { | |
38661 | ||
38662 | ||
38663 | ||
38664 | ||
38665 | if (!(!JSVAL_IS_PRIMITIVE(sp[-2]) && JSVAL_TO_OBJECT(sp[-2])->isXML())) { | |
38666 | ((void)js_ReportValueErrorFlags(cx, 0x0, JSMSG_NON_XML_FILTER, -2, Valueify(sp[-2]), __null, __null, __null)); | |
38667 | return (JSIntn)0; | |
38668 | } | |
38669 | obj = JSVAL_TO_OBJECT(sp[-2]); | |
38670 | xml = (JSXML *) obj->getPrivate(); | |
38671 | ||
38672 | if (xml->xml_class == JSXML_CLASS_LIST) { | |
38673 | list = xml; | |
38674 | } else { | |
38675 | obj = js_NewXMLObject(cx, JSXML_CLASS_LIST); | |
38676 | if (!obj) | |
38677 | return (JSIntn)0; | |
38678 | ||
38679 | ||
38680 | ||
38681 | ||
38682 | ||
38683 | sp[-1] = OBJECT_TO_JSVAL(obj); | |
38684 | list = (JSXML *) obj->getPrivate(); | |
38685 | if (!Append(cx, list, xml)) | |
38686 | return (JSIntn)0; | |
38687 | } | |
38688 | ||
38689 | filterobj = NewNonFunction<WithProto::Given>(cx, &js_XMLFilterClass, __null, __null); | |
38690 | if (!filterobj) | |
38691 | return (JSIntn)0; | |
38692 | ||
38693 | ||
38694 | ||
38695 | ||
38696 | ||
38697 | filter = cx->create<JSXMLFilter>(list, &list->u.list.kids); | |
38698 | if (!filter) | |
38699 | return (JSIntn)0; | |
38700 | filterobj->setPrivate(filter); | |
38701 | ||
38702 | ||
38703 | sp[-2] = OBJECT_TO_JSVAL(filterobj); | |
38704 | ||
38705 | resobj = js_NewXMLObject(cx, JSXML_CLASS_LIST); | |
38706 | if (!resobj) | |
38707 | return (JSIntn)0; | |
38708 | ||
38709 | ||
38710 | filter->result = (JSXML *) resobj->getPrivate(); | |
38711 | } else { | |
38712 | ||
38713 | ((void) 0); | |
38714 | ((void) 0); | |
38715 | filter = (JSXMLFilter *) JSVAL_TO_OBJECT(sp[-2])->getPrivate(); | |
38716 | ((void) 0); | |
38717 | ||
38718 | ||
38719 | if (js_ValueToBoolean(Valueify(sp[-1])) && | |
38720 | !Append(cx, filter->result, filter->kid)) { | |
38721 | return (JSIntn)0; | |
38722 | } | |
38723 | } | |
38724 | ||
38725 | ||
38726 | filter->kid = (JSXML *) filter->cursor.getNext(); | |
38727 | if (!filter->kid) { | |
38728 | ||
38729 | ||
38730 | ||
38731 | ||
38732 | filter->cursor.disconnect(); | |
38733 | ((void) 0); | |
38734 | sp[-2] = OBJECT_TO_JSVAL(filter->result->object); | |
38735 | kidobj = __null; | |
38736 | } else { | |
38737 | kidobj = js_GetXMLObject(cx, filter->kid); | |
38738 | if (!kidobj) | |
38739 | return (JSIntn)0; | |
38740 | } | |
38741 | ||
38742 | ||
38743 | sp[-1] = OBJECT_TO_JSVAL(kidobj); | |
38744 | return (JSIntn)1; | |
38745 | } | |
38746 | ||
38747 | JSObject * | |
38748 | js_ValueToXMLObject(JSContext *cx, const Value &v) | |
38749 | { | |
38750 | return ToXML(cx, Jsvalify(v)); | |
38751 | } | |
38752 | ||
38753 | JSObject * | |
38754 | js_ValueToXMLListObject(JSContext *cx, const Value &v) | |
38755 | { | |
38756 | return ToXMLList(cx, Jsvalify(v)); | |
38757 | } | |
38758 | ||
38759 | JSObject * | |
38760 | js_NewXMLSpecialObject(JSContext *cx, JSXMLClass xml_class, JSString *name, | |
38761 | JSString *value) | |
38762 | { | |
38763 | uintN flags; | |
38764 | JSObject *obj; | |
38765 | JSXML *xml; | |
38766 | JSObject *qn; | |
38767 | ||
38768 | if (!GetXMLSettingFlags(cx, &flags)) | |
38769 | return __null; | |
38770 | ||
38771 | if ((xml_class == JSXML_CLASS_COMMENT && | |
38772 | (flags & ((JSUint32)1 << (0)))) || | |
38773 | (xml_class == JSXML_CLASS_PROCESSING_INSTRUCTION && | |
38774 | (flags & ((JSUint32)1 << (1))))) { | |
38775 | return js_NewXMLObject(cx, JSXML_CLASS_TEXT); | |
38776 | } | |
38777 | ||
38778 | obj = js_NewXMLObject(cx, xml_class); | |
38779 | if (!obj) | |
38780 | return __null; | |
38781 | xml = (JSXML *) obj->getPrivate(); | |
38782 | if (name) { | |
38783 | JSLinearString *linearName = name->ensureLinear(cx); | |
38784 | if (!linearName) | |
38785 | return __null; | |
38786 | qn = NewXMLQName(cx, cx->runtime->emptyString, __null, linearName); | |
38787 | if (!qn) | |
38788 | return __null; | |
38789 | xml->name = qn; | |
38790 | } | |
38791 | xml->u.value = value; | |
38792 | return obj; | |
38793 | } | |
38794 | ||
38795 | JSString * | |
38796 | js_MakeXMLCDATAString(JSContext *cx, JSString *str) | |
38797 | { | |
38798 | StringBuffer sb(cx); | |
38799 | return MakeXMLCDATAString(cx, sb, str); | |
38800 | } | |
38801 | ||
38802 | JSString * | |
38803 | js_MakeXMLCommentString(JSContext *cx, JSString *str) | |
38804 | { | |
38805 | StringBuffer sb(cx); | |
38806 | return MakeXMLCommentString(cx, sb, str); | |
38807 | } | |
38808 | ||
38809 | JSString * | |
38810 | js_MakeXMLPIString(JSContext *cx, JSString *name, JSString *str) | |
38811 | { | |
38812 | StringBuffer sb(cx); | |
38813 | return MakeXMLPIString(cx, sb, name, str); | |
38814 | } |