author | sundar |
Thu, 18 Jul 2013 18:08:26 +0530 | |
changeset 19085 | 066c9e5afd79 |
parent 18855 | 408663ef8f66 |
child 19088 | 153f268bfa72 |
permissions | -rw-r--r-- |
16147 | 1 |
/* |
16151 | 2 |
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. |
16147 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
package jdk.nashorn.internal.objects; |
|
27 |
||
18610 | 28 |
import static jdk.nashorn.internal.lookup.Lookup.MH; |
16147 | 29 |
import static jdk.nashorn.internal.runtime.ECMAErrors.typeError; |
30 |
import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED; |
|
31 |
||
32 |
import java.io.IOException; |
|
33 |
import java.io.PrintWriter; |
|
34 |
import java.lang.invoke.MethodHandle; |
|
35 |
import java.lang.invoke.MethodHandles; |
|
36 |
import java.lang.ref.SoftReference; |
|
16522 | 37 |
import java.lang.reflect.Field; |
38 |
import java.security.AccessController; |
|
39 |
import java.security.PrivilegedAction; |
|
18326
512bdf9535a6
8016453: loadWithNewGlobal does not allow apply operation
jlaskey
parents:
18321
diff
changeset
|
40 |
import java.util.Arrays; |
16147 | 41 |
import java.util.LinkedHashMap; |
42 |
import java.util.List; |
|
43 |
import java.util.Map; |
|
16234
86cb162cec6c
8008085: Integrate Dynalink source code into Nashorn codebase
attila
parents:
16233
diff
changeset
|
44 |
import jdk.internal.dynalink.linker.GuardedInvocation; |
86cb162cec6c
8008085: Integrate Dynalink source code into Nashorn codebase
attila
parents:
16233
diff
changeset
|
45 |
import jdk.internal.dynalink.linker.LinkRequest; |
16147 | 46 |
import jdk.nashorn.internal.objects.annotations.Attribute; |
47 |
import jdk.nashorn.internal.objects.annotations.Property; |
|
48 |
import jdk.nashorn.internal.objects.annotations.ScriptClass; |
|
49 |
import jdk.nashorn.internal.runtime.ConsString; |
|
50 |
import jdk.nashorn.internal.runtime.Context; |
|
51 |
import jdk.nashorn.internal.runtime.GlobalFunctions; |
|
52 |
import jdk.nashorn.internal.runtime.GlobalObject; |
|
53 |
import jdk.nashorn.internal.runtime.JSType; |
|
54 |
import jdk.nashorn.internal.runtime.NativeJavaPackage; |
|
18618
136279c4cbe6
8019157: Avoid calling ScriptObject.setProto() if possible
hannesw
parents:
18610
diff
changeset
|
55 |
import jdk.nashorn.internal.runtime.PropertyMap; |
16262
75513555e603
8008731: Separate configuration environment (options, error/output writer etc.) from Context
sundar
parents:
16258
diff
changeset
|
56 |
import jdk.nashorn.internal.runtime.ScriptEnvironment; |
16147 | 57 |
import jdk.nashorn.internal.runtime.PropertyDescriptor; |
18618
136279c4cbe6
8019157: Avoid calling ScriptObject.setProto() if possible
hannesw
parents:
18610
diff
changeset
|
58 |
import jdk.nashorn.internal.runtime.arrays.ArrayData; |
16258 | 59 |
import jdk.nashorn.internal.runtime.regexp.RegExpResult; |
16147 | 60 |
import jdk.nashorn.internal.runtime.Scope; |
61 |
import jdk.nashorn.internal.runtime.ScriptFunction; |
|
62 |
import jdk.nashorn.internal.runtime.ScriptObject; |
|
63 |
import jdk.nashorn.internal.runtime.ScriptRuntime; |
|
64 |
import jdk.nashorn.internal.runtime.ScriptingFunctions; |
|
65 |
import jdk.nashorn.internal.runtime.Source; |
|
66 |
import jdk.nashorn.internal.runtime.linker.InvokeByName; |
|
16275 | 67 |
import jdk.nashorn.internal.scripts.JO; |
16147 | 68 |
|
69 |
/** |
|
70 |
* Representation of global scope. |
|
71 |
*/ |
|
72 |
@ScriptClass("Global") |
|
73 |
public final class Global extends ScriptObject implements GlobalObject, Scope { |
|
74 |
private static final InvokeByName TO_STRING = new InvokeByName("toString", ScriptObject.class); |
|
75 |
private static final InvokeByName VALUE_OF = new InvokeByName("valueOf", ScriptObject.class); |
|
76 |
||
77 |
/** ECMA 15.1.2.2 parseInt (string , radix) */ |
|
78 |
@Property(attributes = Attribute.NOT_ENUMERABLE) |
|
79 |
public Object parseInt; |
|
80 |
||
81 |
/** ECMA 15.1.2.3 parseFloat (string) */ |
|
82 |
@Property(attributes = Attribute.NOT_ENUMERABLE) |
|
83 |
public Object parseFloat; |
|
84 |
||
85 |
/** ECMA 15.1.2.4 isNaN (number) */ |
|
86 |
@Property(attributes = Attribute.NOT_ENUMERABLE) |
|
87 |
public Object isNaN; |
|
88 |
||
89 |
/** ECMA 15.1.2.5 isFinite (number) */ |
|
90 |
@Property(attributes = Attribute.NOT_ENUMERABLE) |
|
91 |
public Object isFinite; |
|
92 |
||
93 |
/** ECMA 15.1.3.3 encodeURI */ |
|
94 |
@Property(attributes = Attribute.NOT_ENUMERABLE) |
|
95 |
public Object encodeURI; |
|
96 |
||
97 |
/** ECMA 15.1.3.4 encodeURIComponent */ |
|
98 |
@Property(attributes = Attribute.NOT_ENUMERABLE) |
|
99 |
public Object encodeURIComponent; |
|
100 |
||
101 |
/** ECMA 15.1.3.1 decodeURI */ |
|
102 |
@Property(attributes = Attribute.NOT_ENUMERABLE) |
|
103 |
public Object decodeURI; |
|
104 |
||
105 |
/** ECMA 15.1.3.2 decodeURIComponent */ |
|
106 |
@Property(attributes = Attribute.NOT_ENUMERABLE) |
|
107 |
public Object decodeURIComponent; |
|
108 |
||
109 |
/** ECMA B.2.1 escape (string) */ |
|
110 |
@Property(attributes = Attribute.NOT_ENUMERABLE) |
|
111 |
public Object escape; |
|
112 |
||
113 |
/** ECMA B.2.2 unescape (string) */ |
|
114 |
@Property(attributes = Attribute.NOT_ENUMERABLE) |
|
115 |
public Object unescape; |
|
116 |
||
117 |
/** Nashorn extension: global.print */ |
|
118 |
@Property(attributes = Attribute.NOT_ENUMERABLE) |
|
119 |
public Object print; |
|
120 |
||
121 |
/** Nashorn extension: global.load */ |
|
122 |
@Property(attributes = Attribute.NOT_ENUMERABLE) |
|
123 |
public Object load; |
|
124 |
||
17974
a2818f17324e
8015741: Need a global.load function that starts with a new global scope.
jlaskey
parents:
17972
diff
changeset
|
125 |
/** Nashorn extension: global.loadWithNewGlobal */ |
a2818f17324e
8015741: Need a global.load function that starts with a new global scope.
jlaskey
parents:
17972
diff
changeset
|
126 |
@Property(attributes = Attribute.NOT_ENUMERABLE) |
a2818f17324e
8015741: Need a global.load function that starts with a new global scope.
jlaskey
parents:
17972
diff
changeset
|
127 |
public Object loadWithNewGlobal; |
a2818f17324e
8015741: Need a global.load function that starts with a new global scope.
jlaskey
parents:
17972
diff
changeset
|
128 |
|
16219 | 129 |
/** Nashorn extension: global.exit */ |
130 |
@Property(attributes = Attribute.NOT_ENUMERABLE) |
|
131 |
public Object exit; |
|
132 |
||
133 |
/** Nashorn extension: global.quit */ |
|
134 |
@Property(attributes = Attribute.NOT_ENUMERABLE) |
|
135 |
public Object quit; |
|
136 |
||
16147 | 137 |
/** Value property NaN of the Global Object - ECMA 15.1.1.1 NaN */ |
138 |
@Property(attributes = Attribute.NON_ENUMERABLE_CONSTANT) |
|
139 |
public final Object NaN = Double.NaN; |
|
140 |
||
141 |
/** Value property Infinity of the Global Object - ECMA 15.1.1.2 Infinity */ |
|
142 |
@Property(attributes = Attribute.NON_ENUMERABLE_CONSTANT) |
|
143 |
public final Object Infinity = Double.POSITIVE_INFINITY; |
|
144 |
||
145 |
/** Value property Undefined of the Global Object - ECMA 15.1.1.3 Undefined */ |
|
146 |
@Property(attributes = Attribute.NON_ENUMERABLE_CONSTANT) |
|
147 |
public final Object undefined = UNDEFINED; |
|
148 |
||
149 |
/** ECMA 15.1.2.1 eval(x) */ |
|
150 |
@Property(attributes = Attribute.NOT_ENUMERABLE) |
|
151 |
public Object eval; |
|
152 |
||
153 |
/** ECMA 15.1.4.1 Object constructor. */ |
|
154 |
@Property(name = "Object", attributes = Attribute.NOT_ENUMERABLE) |
|
155 |
public volatile Object object; |
|
156 |
||
157 |
/** ECMA 15.1.4.2 Function constructor. */ |
|
158 |
@Property(name = "Function", attributes = Attribute.NOT_ENUMERABLE) |
|
159 |
public volatile Object function; |
|
160 |
||
161 |
/** ECMA 15.1.4.3 Array constructor. */ |
|
162 |
@Property(name = "Array", attributes = Attribute.NOT_ENUMERABLE) |
|
163 |
public volatile Object array; |
|
164 |
||
165 |
/** ECMA 15.1.4.4 String constructor */ |
|
166 |
@Property(name = "String", attributes = Attribute.NOT_ENUMERABLE) |
|
167 |
public volatile Object string; |
|
168 |
||
169 |
/** ECMA 15.1.4.5 Boolean constructor */ |
|
170 |
@Property(name = "Boolean", attributes = Attribute.NOT_ENUMERABLE) |
|
171 |
public volatile Object _boolean; |
|
172 |
||
173 |
/** ECMA 15.1.4.6 - Number constructor */ |
|
174 |
@Property(name = "Number", attributes = Attribute.NOT_ENUMERABLE) |
|
175 |
public volatile Object number; |
|
176 |
||
177 |
/** ECMA 15.1.4.7 Date constructor */ |
|
178 |
@Property(name = "Date", attributes = Attribute.NOT_ENUMERABLE) |
|
179 |
public volatile Object date; |
|
180 |
||
181 |
/** ECMA 15.1.4.8 RegExp constructor */ |
|
182 |
@Property(name = "RegExp", attributes = Attribute.NOT_ENUMERABLE) |
|
183 |
public volatile Object regexp; |
|
184 |
||
185 |
/** ECMA 15.12 - The JSON object */ |
|
186 |
@Property(name = "JSON", attributes = Attribute.NOT_ENUMERABLE) |
|
187 |
public volatile Object json; |
|
188 |
||
189 |
/** Nashorn extension: global.JSAdapter */ |
|
190 |
@Property(name = "JSAdapter", attributes = Attribute.NOT_ENUMERABLE) |
|
191 |
public volatile Object jsadapter; |
|
192 |
||
193 |
/** ECMA 15.8 - The Math object */ |
|
194 |
@Property(name = "Math", attributes = Attribute.NOT_ENUMERABLE) |
|
195 |
public volatile Object math; |
|
196 |
||
197 |
/** Error object */ |
|
198 |
@Property(name = "Error", attributes = Attribute.NOT_ENUMERABLE) |
|
199 |
public volatile Object error; |
|
200 |
||
201 |
/** EvalError object */ |
|
202 |
@Property(name = "EvalError", attributes = Attribute.NOT_ENUMERABLE) |
|
203 |
public volatile Object evalError; |
|
204 |
||
205 |
/** RangeError object */ |
|
206 |
@Property(name = "RangeError", attributes = Attribute.NOT_ENUMERABLE) |
|
207 |
public volatile Object rangeError; |
|
208 |
||
209 |
/** ReferenceError object */ |
|
210 |
@Property(name = "ReferenceError", attributes = Attribute.NOT_ENUMERABLE) |
|
211 |
public volatile Object referenceError; |
|
212 |
||
213 |
/** SyntaxError object */ |
|
214 |
@Property(name = "SyntaxError", attributes = Attribute.NOT_ENUMERABLE) |
|
215 |
public volatile Object syntaxError; |
|
216 |
||
217 |
/** TypeError object */ |
|
218 |
@Property(name = "TypeError", attributes = Attribute.NOT_ENUMERABLE) |
|
219 |
public volatile Object typeError; |
|
220 |
||
221 |
/** URIError object */ |
|
222 |
@Property(name = "URIError", attributes = Attribute.NOT_ENUMERABLE) |
|
223 |
public volatile Object uriError; |
|
224 |
||
225 |
/** ArrayBuffer object */ |
|
226 |
@Property(name = "ArrayBuffer", attributes = Attribute.NOT_ENUMERABLE) |
|
227 |
public volatile Object arrayBuffer; |
|
228 |
||
229 |
/** TypedArray (int8) */ |
|
230 |
@Property(name = "Int8Array", attributes = Attribute.NOT_ENUMERABLE) |
|
231 |
public volatile Object int8Array; |
|
232 |
||
233 |
/** TypedArray (uint8) */ |
|
234 |
@Property(name = "Uint8Array", attributes = Attribute.NOT_ENUMERABLE) |
|
235 |
public volatile Object uint8Array; |
|
236 |
||
237 |
/** TypedArray (uint8) - Clamped */ |
|
238 |
@Property(name = "Uint8ClampedArray", attributes = Attribute.NOT_ENUMERABLE) |
|
239 |
public volatile Object uint8ClampedArray; |
|
240 |
||
241 |
/** TypedArray (int16) */ |
|
242 |
@Property(name = "Int16Array", attributes = Attribute.NOT_ENUMERABLE) |
|
243 |
public volatile Object int16Array; |
|
244 |
||
245 |
/** TypedArray (uint16) */ |
|
246 |
@Property(name = "Uint16Array", attributes = Attribute.NOT_ENUMERABLE) |
|
247 |
public volatile Object uint16Array; |
|
248 |
||
249 |
/** TypedArray (int32) */ |
|
250 |
@Property(name = "Int32Array", attributes = Attribute.NOT_ENUMERABLE) |
|
251 |
public volatile Object int32Array; |
|
252 |
||
253 |
/** TypedArray (uint32) */ |
|
254 |
@Property(name = "Uint32Array", attributes = Attribute.NOT_ENUMERABLE) |
|
255 |
public volatile Object uint32Array; |
|
256 |
||
257 |
/** TypedArray (float32) */ |
|
258 |
@Property(name = "Float32Array", attributes = Attribute.NOT_ENUMERABLE) |
|
259 |
public volatile Object float32Array; |
|
260 |
||
261 |
/** TypedArray (float64) */ |
|
262 |
@Property(name = "Float64Array", attributes = Attribute.NOT_ENUMERABLE) |
|
263 |
public volatile Object float64Array; |
|
264 |
||
265 |
/** Nashorn extension: Java access - global.Packages */ |
|
266 |
@Property(name = "Packages", attributes = Attribute.NOT_ENUMERABLE) |
|
267 |
public volatile Object packages; |
|
268 |
||
16532 | 269 |
/** Nashorn extension: Java access - global.com */ |
270 |
@Property(attributes = Attribute.NOT_ENUMERABLE) |
|
271 |
public volatile Object com; |
|
272 |
||
273 |
/** Nashorn extension: Java access - global.edu */ |
|
274 |
@Property(attributes = Attribute.NOT_ENUMERABLE) |
|
275 |
public volatile Object edu; |
|
276 |
||
16147 | 277 |
/** Nashorn extension: Java access - global.java */ |
278 |
@Property(attributes = Attribute.NOT_ENUMERABLE) |
|
279 |
public volatile Object java; |
|
280 |
||
16532 | 281 |
/** Nashorn extension: Java access - global.javafx */ |
282 |
@Property(attributes = Attribute.NOT_ENUMERABLE) |
|
283 |
public volatile Object javafx; |
|
284 |
||
16147 | 285 |
/** Nashorn extension: Java access - global.javax */ |
286 |
@Property(attributes = Attribute.NOT_ENUMERABLE) |
|
16532 | 287 |
public volatile Object javax; |
288 |
||
289 |
/** Nashorn extension: Java access - global.org */ |
|
290 |
@Property(attributes = Attribute.NOT_ENUMERABLE) |
|
291 |
public volatile Object org; |
|
16147 | 292 |
|
293 |
/** Nashorn extension: Java access - global.javaImporter */ |
|
294 |
@Property(name = "JavaImporter", attributes = Attribute.NOT_ENUMERABLE) |
|
295 |
public volatile Object javaImporter; |
|
296 |
||
297 |
/** Nashorn extension: global.Java Object constructor. */ |
|
298 |
@Property(name = "Java", attributes = Attribute.NOT_ENUMERABLE) |
|
299 |
public volatile Object javaApi; |
|
300 |
||
301 |
/** Nashorn extension: current script's file name */ |
|
302 |
@Property(name = "__FILE__", attributes = Attribute.NON_ENUMERABLE_CONSTANT) |
|
303 |
public Object __FILE__; |
|
304 |
||
305 |
/** Nashorn extension: current script's directory */ |
|
306 |
@Property(name = "__DIR__", attributes = Attribute.NON_ENUMERABLE_CONSTANT) |
|
307 |
public Object __DIR__; |
|
308 |
||
309 |
/** Nashorn extension: current source line number being executed */ |
|
310 |
@Property(name = "__LINE__", attributes = Attribute.NON_ENUMERABLE_CONSTANT) |
|
311 |
public Object __LINE__; |
|
312 |
||
313 |
/** Used as Date.prototype's default value */ |
|
314 |
public NativeDate DEFAULT_DATE; |
|
315 |
||
316 |
/** Used as RegExp.prototype's default value */ |
|
317 |
public NativeRegExp DEFAULT_REGEXP; |
|
318 |
||
319 |
/* |
|
320 |
* Built-in constructor objects: Even if user changes dynamic values of |
|
321 |
* "Object", "Array" etc., we still want to keep original values of these |
|
322 |
* constructors here. For example, we need to be able to create array, |
|
323 |
* regexp literals even after user overwrites global "Array" or "RegExp" |
|
324 |
* constructor - see also ECMA 262 spec. Annex D. |
|
325 |
*/ |
|
326 |
private ScriptFunction builtinFunction; |
|
327 |
private ScriptFunction builtinObject; |
|
328 |
private ScriptFunction builtinArray; |
|
329 |
private ScriptFunction builtinBoolean; |
|
330 |
private ScriptFunction builtinDate; |
|
331 |
private ScriptObject builtinJSON; |
|
332 |
private ScriptFunction builtinJSAdapter; |
|
333 |
private ScriptObject builtinMath; |
|
334 |
private ScriptFunction builtinNumber; |
|
335 |
private ScriptFunction builtinRegExp; |
|
336 |
private ScriptFunction builtinString; |
|
337 |
private ScriptFunction builtinError; |
|
338 |
private ScriptFunction builtinEval; |
|
339 |
private ScriptFunction builtinEvalError; |
|
340 |
private ScriptFunction builtinRangeError; |
|
341 |
private ScriptFunction builtinReferenceError; |
|
342 |
private ScriptFunction builtinSyntaxError; |
|
343 |
private ScriptFunction builtinTypeError; |
|
344 |
private ScriptFunction builtinURIError; |
|
345 |
private ScriptObject builtinPackages; |
|
16532 | 346 |
private ScriptObject builtinCom; |
347 |
private ScriptObject builtinEdu; |
|
16147 | 348 |
private ScriptObject builtinJava; |
16532 | 349 |
private ScriptObject builtinJavafx; |
16147 | 350 |
private ScriptObject builtinJavax; |
16532 | 351 |
private ScriptObject builtinOrg; |
16147 | 352 |
private ScriptObject builtinJavaImporter; |
353 |
private ScriptObject builtinJavaApi; |
|
354 |
private ScriptObject builtinArrayBuffer; |
|
355 |
private ScriptObject builtinInt8Array; |
|
356 |
private ScriptObject builtinUint8Array; |
|
357 |
private ScriptObject builtinUint8ClampedArray; |
|
358 |
private ScriptObject builtinInt16Array; |
|
359 |
private ScriptObject builtinUint16Array; |
|
360 |
private ScriptObject builtinInt32Array; |
|
361 |
private ScriptObject builtinUint32Array; |
|
362 |
private ScriptObject builtinFloat32Array; |
|
363 |
private ScriptObject builtinFloat64Array; |
|
364 |
||
18851
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
365 |
private PropertyMap accessorPropertyDescriptorMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
366 |
private PropertyMap arrayBufferViewMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
367 |
private PropertyMap dataPropertyDescriptorMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
368 |
private PropertyMap genericPropertyDescriptorMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
369 |
private PropertyMap nativeArgumentsMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
370 |
private PropertyMap nativeArrayMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
371 |
private PropertyMap nativeArrayBufferMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
372 |
private PropertyMap nativeBooleanMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
373 |
private PropertyMap nativeDateMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
374 |
private PropertyMap nativeErrorMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
375 |
private PropertyMap nativeEvalErrorMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
376 |
private PropertyMap nativeJSAdapterMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
377 |
private PropertyMap nativeJavaImporterMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
378 |
private PropertyMap nativeNumberMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
379 |
private PropertyMap nativeRangeErrorMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
380 |
private PropertyMap nativeReferenceErrorMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
381 |
private PropertyMap nativeRegExpMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
382 |
private PropertyMap nativeRegExpExecResultMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
383 |
private PropertyMap nativeStrictArgumentsMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
384 |
private PropertyMap nativeStringMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
385 |
private PropertyMap nativeSyntaxErrorMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
386 |
private PropertyMap nativeTypeErrorMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
387 |
private PropertyMap nativeURIErrorMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
388 |
private PropertyMap prototypeObjectMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
389 |
private PropertyMap objectMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
390 |
private PropertyMap functionMap; |
18855
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
391 |
private PropertyMap anonymousFunctionMap; |
18851
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
392 |
private PropertyMap strictFunctionMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
393 |
private PropertyMap boundFunctionMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
394 |
|
16147 | 395 |
// Flag to indicate that a split method issued a return statement |
396 |
private int splitState = -1; |
|
397 |
||
398 |
// class cache |
|
399 |
private ClassCache classCache; |
|
400 |
||
16223
dff592a332a4
8007718: Make static RegExp properties fully compatible to other engines
hannesw
parents:
16219
diff
changeset
|
401 |
// Used to store the last RegExp result to support deprecated RegExp constructor properties |
16258 | 402 |
private RegExpResult lastRegExpResult; |
16223
dff592a332a4
8007718: Make static RegExp properties fully compatible to other engines
hannesw
parents:
16219
diff
changeset
|
403 |
|
17974
a2818f17324e
8015741: Need a global.load function that starts with a new global scope.
jlaskey
parents:
17972
diff
changeset
|
404 |
private static final MethodHandle EVAL = findOwnMH("eval", Object.class, Object.class, Object.class); |
a2818f17324e
8015741: Need a global.load function that starts with a new global scope.
jlaskey
parents:
17972
diff
changeset
|
405 |
private static final MethodHandle PRINT = findOwnMH("print", Object.class, Object.class, Object[].class); |
a2818f17324e
8015741: Need a global.load function that starts with a new global scope.
jlaskey
parents:
17972
diff
changeset
|
406 |
private static final MethodHandle PRINTLN = findOwnMH("println", Object.class, Object.class, Object[].class); |
a2818f17324e
8015741: Need a global.load function that starts with a new global scope.
jlaskey
parents:
17972
diff
changeset
|
407 |
private static final MethodHandle LOAD = findOwnMH("load", Object.class, Object.class, Object.class); |
18326
512bdf9535a6
8016453: loadWithNewGlobal does not allow apply operation
jlaskey
parents:
18321
diff
changeset
|
408 |
private static final MethodHandle LOADWITHNEWGLOBAL = findOwnMH("loadWithNewGlobal", Object.class, Object.class, Object[].class); |
17974
a2818f17324e
8015741: Need a global.load function that starts with a new global scope.
jlaskey
parents:
17972
diff
changeset
|
409 |
private static final MethodHandle EXIT = findOwnMH("exit", Object.class, Object.class, Object.class); |
16147 | 410 |
|
18618
136279c4cbe6
8019157: Avoid calling ScriptObject.setProto() if possible
hannesw
parents:
18610
diff
changeset
|
411 |
// initialized by nasgen |
136279c4cbe6
8019157: Avoid calling ScriptObject.setProto() if possible
hannesw
parents:
18610
diff
changeset
|
412 |
private static PropertyMap $nasgenmap$; |
136279c4cbe6
8019157: Avoid calling ScriptObject.setProto() if possible
hannesw
parents:
18610
diff
changeset
|
413 |
|
19085
066c9e5afd79
8020731: Revisit checkPermission calls in Context class
sundar
parents:
18855
diff
changeset
|
414 |
// performs initialization checks for Global constructor and returns the |
066c9e5afd79
8020731: Revisit checkPermission calls in Context class
sundar
parents:
18855
diff
changeset
|
415 |
// PropertyMap, if everything is fine. |
066c9e5afd79
8020731: Revisit checkPermission calls in Context class
sundar
parents:
18855
diff
changeset
|
416 |
private static PropertyMap checkAndGetMap(final Context context) { |
066c9e5afd79
8020731: Revisit checkPermission calls in Context class
sundar
parents:
18855
diff
changeset
|
417 |
// security check first |
066c9e5afd79
8020731: Revisit checkPermission calls in Context class
sundar
parents:
18855
diff
changeset
|
418 |
final SecurityManager sm = System.getSecurityManager(); |
066c9e5afd79
8020731: Revisit checkPermission calls in Context class
sundar
parents:
18855
diff
changeset
|
419 |
if (sm != null) { |
066c9e5afd79
8020731: Revisit checkPermission calls in Context class
sundar
parents:
18855
diff
changeset
|
420 |
sm.checkPermission(new RuntimePermission("nashorn.newGlobal")); |
066c9e5afd79
8020731: Revisit checkPermission calls in Context class
sundar
parents:
18855
diff
changeset
|
421 |
} |
066c9e5afd79
8020731: Revisit checkPermission calls in Context class
sundar
parents:
18855
diff
changeset
|
422 |
|
066c9e5afd79
8020731: Revisit checkPermission calls in Context class
sundar
parents:
18855
diff
changeset
|
423 |
// null check on context |
066c9e5afd79
8020731: Revisit checkPermission calls in Context class
sundar
parents:
18855
diff
changeset
|
424 |
context.getClass(); |
066c9e5afd79
8020731: Revisit checkPermission calls in Context class
sundar
parents:
18855
diff
changeset
|
425 |
|
066c9e5afd79
8020731: Revisit checkPermission calls in Context class
sundar
parents:
18855
diff
changeset
|
426 |
/* |
066c9e5afd79
8020731: Revisit checkPermission calls in Context class
sundar
parents:
18855
diff
changeset
|
427 |
* Duplicate global's map and use it. This way the initial Map filled |
066c9e5afd79
8020731: Revisit checkPermission calls in Context class
sundar
parents:
18855
diff
changeset
|
428 |
* by nasgen (referenced from static field in this class) is retained |
066c9e5afd79
8020731: Revisit checkPermission calls in Context class
sundar
parents:
18855
diff
changeset
|
429 |
* 'as is' (as that one is process wide singleton. |
066c9e5afd79
8020731: Revisit checkPermission calls in Context class
sundar
parents:
18855
diff
changeset
|
430 |
*/ |
066c9e5afd79
8020731: Revisit checkPermission calls in Context class
sundar
parents:
18855
diff
changeset
|
431 |
return $nasgenmap$.duplicate(); |
066c9e5afd79
8020731: Revisit checkPermission calls in Context class
sundar
parents:
18855
diff
changeset
|
432 |
} |
066c9e5afd79
8020731: Revisit checkPermission calls in Context class
sundar
parents:
18855
diff
changeset
|
433 |
|
16147 | 434 |
/** |
435 |
* Constructor |
|
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
16228
diff
changeset
|
436 |
* |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
16228
diff
changeset
|
437 |
* @param context the context |
16147 | 438 |
*/ |
16226
0e4f37e6cc40
8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
16223
diff
changeset
|
439 |
public Global(final Context context) { |
19085
066c9e5afd79
8020731: Revisit checkPermission calls in Context class
sundar
parents:
18855
diff
changeset
|
440 |
super(checkAndGetMap(context)); |
18855
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
441 |
this.setContext(context); |
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
442 |
this.setIsScope(); |
16147 | 443 |
|
16262
75513555e603
8008731: Separate configuration environment (options, error/output writer etc.) from Context
sundar
parents:
16258
diff
changeset
|
444 |
final int cacheSize = context.getEnv()._class_cache_size; |
16147 | 445 |
if (cacheSize > 0) { |
446 |
classCache = new ClassCache(cacheSize); |
|
447 |
} |
|
448 |
} |
|
449 |
||
450 |
/** |
|
16226
0e4f37e6cc40
8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
16223
diff
changeset
|
451 |
* Script access to "current" Global instance |
16147 | 452 |
* |
453 |
* @return the global singleton |
|
454 |
*/ |
|
455 |
public static Global instance() { |
|
16226
0e4f37e6cc40
8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
16223
diff
changeset
|
456 |
ScriptObject global = Context.getGlobal(); |
0e4f37e6cc40
8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
16223
diff
changeset
|
457 |
if (! (global instanceof Global)) { |
0e4f37e6cc40
8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
16223
diff
changeset
|
458 |
throw new IllegalStateException("no current global instance"); |
0e4f37e6cc40
8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
16223
diff
changeset
|
459 |
} |
0e4f37e6cc40
8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
16223
diff
changeset
|
460 |
return (Global)global; |
16147 | 461 |
} |
462 |
||
463 |
/** |
|
16262
75513555e603
8008731: Separate configuration environment (options, error/output writer etc.) from Context
sundar
parents:
16258
diff
changeset
|
464 |
* Script access to {@link ScriptEnvironment} |
75513555e603
8008731: Separate configuration environment (options, error/output writer etc.) from Context
sundar
parents:
16258
diff
changeset
|
465 |
* |
75513555e603
8008731: Separate configuration environment (options, error/output writer etc.) from Context
sundar
parents:
16258
diff
changeset
|
466 |
* @return the script environment |
75513555e603
8008731: Separate configuration environment (options, error/output writer etc.) from Context
sundar
parents:
16258
diff
changeset
|
467 |
*/ |
75513555e603
8008731: Separate configuration environment (options, error/output writer etc.) from Context
sundar
parents:
16258
diff
changeset
|
468 |
static ScriptEnvironment getEnv() { |
18851
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
469 |
return instance().getContext().getEnv(); |
16262
75513555e603
8008731: Separate configuration environment (options, error/output writer etc.) from Context
sundar
parents:
16258
diff
changeset
|
470 |
} |
75513555e603
8008731: Separate configuration environment (options, error/output writer etc.) from Context
sundar
parents:
16258
diff
changeset
|
471 |
|
75513555e603
8008731: Separate configuration environment (options, error/output writer etc.) from Context
sundar
parents:
16258
diff
changeset
|
472 |
/** |
16147 | 473 |
* Script access to {@link Context} |
474 |
* |
|
475 |
* @return the context |
|
476 |
*/ |
|
16185 | 477 |
static Context getThisContext() { |
18851
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
478 |
return instance().getContext(); |
16147 | 479 |
} |
480 |
||
481 |
// GlobalObject interface implementation |
|
482 |
||
483 |
@Override |
|
484 |
public void initBuiltinObjects() { |
|
485 |
if (this.builtinObject != null) { |
|
486 |
// already initialized, just return |
|
487 |
return; |
|
488 |
} |
|
489 |
||
16185 | 490 |
init(); |
16147 | 491 |
} |
492 |
||
493 |
@Override |
|
494 |
public ScriptFunction newScriptFunction(final String name, final MethodHandle handle, final ScriptObject scope, final boolean strict) { |
|
16228 | 495 |
return new ScriptFunctionImpl(name, handle, scope, null, strict, false, true); |
16147 | 496 |
} |
497 |
||
498 |
@Override |
|
499 |
public Object wrapAsObject(final Object obj) { |
|
500 |
if (obj instanceof Boolean) { |
|
18851
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
501 |
return new NativeBoolean((Boolean)obj, this); |
16147 | 502 |
} else if (obj instanceof Number) { |
18851
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
503 |
return new NativeNumber(((Number)obj).doubleValue(), this); |
16147 | 504 |
} else if (obj instanceof String || obj instanceof ConsString) { |
18851
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
505 |
return new NativeString((CharSequence)obj, this); |
16147 | 506 |
} else if (obj instanceof Object[]) { // extension |
507 |
return new NativeArray((Object[])obj); |
|
508 |
} else if (obj instanceof double[]) { // extension |
|
509 |
return new NativeArray((double[])obj); |
|
510 |
} else if (obj instanceof long[]) { |
|
511 |
return new NativeArray((long[])obj); |
|
512 |
} else if (obj instanceof int[]) { |
|
513 |
return new NativeArray((int[])obj); |
|
514 |
} else { |
|
515 |
// FIXME: more special cases? Map? List? |
|
516 |
return obj; |
|
517 |
} |
|
518 |
} |
|
519 |
||
520 |
@Override |
|
16195
3f6c0ab2597a
8006766: Array-like access to characters of a string is slow
hannesw
parents:
16188
diff
changeset
|
521 |
public GuardedInvocation primitiveLookup(final LinkRequest request, final Object self) { |
3f6c0ab2597a
8006766: Array-like access to characters of a string is slow
hannesw
parents:
16188
diff
changeset
|
522 |
if (self instanceof String || self instanceof ConsString) { |
3f6c0ab2597a
8006766: Array-like access to characters of a string is slow
hannesw
parents:
16188
diff
changeset
|
523 |
return NativeString.lookupPrimitive(request, self); |
3f6c0ab2597a
8006766: Array-like access to characters of a string is slow
hannesw
parents:
16188
diff
changeset
|
524 |
} else if (self instanceof Number) { |
3f6c0ab2597a
8006766: Array-like access to characters of a string is slow
hannesw
parents:
16188
diff
changeset
|
525 |
return NativeNumber.lookupPrimitive(request, self); |
3f6c0ab2597a
8006766: Array-like access to characters of a string is slow
hannesw
parents:
16188
diff
changeset
|
526 |
} else if (self instanceof Boolean) { |
3f6c0ab2597a
8006766: Array-like access to characters of a string is slow
hannesw
parents:
16188
diff
changeset
|
527 |
return NativeBoolean.lookupPrimitive(request, self); |
3f6c0ab2597a
8006766: Array-like access to characters of a string is slow
hannesw
parents:
16188
diff
changeset
|
528 |
} |
3f6c0ab2597a
8006766: Array-like access to characters of a string is slow
hannesw
parents:
16188
diff
changeset
|
529 |
throw new IllegalArgumentException("Unsupported primitive: " + self); |
16147 | 530 |
} |
531 |
||
532 |
@Override |
|
533 |
public ScriptObject newObject() { |
|
18851
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
534 |
return new JO(getObjectPrototype(), getObjectMap()); |
16147 | 535 |
} |
536 |
||
537 |
@Override |
|
538 |
public Object getDefaultValue(final ScriptObject sobj, final Class<?> typeHint) { |
|
539 |
// When the [[DefaultValue]] internal method of O is called with no hint, |
|
540 |
// then it behaves as if the hint were Number, unless O is a Date object |
|
541 |
// in which case it behaves as if the hint were String. |
|
542 |
Class<?> hint = typeHint; |
|
543 |
if (hint == null) { |
|
544 |
hint = Number.class; |
|
545 |
} |
|
546 |
||
547 |
try { |
|
548 |
if (hint == String.class) { |
|
549 |
||
550 |
final Object toString = TO_STRING.getGetter().invokeExact(sobj); |
|
551 |
if (toString instanceof ScriptFunction) { |
|
552 |
final Object value = TO_STRING.getInvoker().invokeExact(toString, sobj); |
|
553 |
if (JSType.isPrimitive(value)) { |
|
554 |
return value; |
|
555 |
} |
|
556 |
} |
|
557 |
||
558 |
final Object valueOf = VALUE_OF.getGetter().invokeExact(sobj); |
|
559 |
if (valueOf instanceof ScriptFunction) { |
|
560 |
final Object value = VALUE_OF.getInvoker().invokeExact(valueOf, sobj); |
|
561 |
if (JSType.isPrimitive(value)) { |
|
562 |
return value; |
|
563 |
} |
|
564 |
} |
|
16256
f2d9a0c49914
8007002: Replace implicit exception throwing methods with explicit throws - simplify control flow and remove useless code
lagergren
parents:
16234
diff
changeset
|
565 |
throw typeError(this, "cannot.get.default.string"); |
16147 | 566 |
} |
567 |
||
568 |
if (hint == Number.class) { |
|
569 |
final Object valueOf = VALUE_OF.getGetter().invokeExact(sobj); |
|
570 |
if (valueOf instanceof ScriptFunction) { |
|
571 |
final Object value = VALUE_OF.getInvoker().invokeExact(valueOf, sobj); |
|
572 |
if (JSType.isPrimitive(value)) { |
|
573 |
return value; |
|
574 |
} |
|
575 |
} |
|
576 |
||
577 |
final Object toString = TO_STRING.getGetter().invokeExact(sobj); |
|
578 |
if (toString instanceof ScriptFunction) { |
|
579 |
final Object value = TO_STRING.getInvoker().invokeExact(toString, sobj); |
|
580 |
if (JSType.isPrimitive(value)) { |
|
581 |
return value; |
|
582 |
} |
|
583 |
} |
|
584 |
||
16256
f2d9a0c49914
8007002: Replace implicit exception throwing methods with explicit throws - simplify control flow and remove useless code
lagergren
parents:
16234
diff
changeset
|
585 |
throw typeError(this, "cannot.get.default.number"); |
16147 | 586 |
} |
587 |
} catch (final RuntimeException | Error e) { |
|
588 |
throw e; |
|
589 |
} catch (final Throwable t) { |
|
590 |
throw new RuntimeException(t); |
|
591 |
} |
|
592 |
||
593 |
return UNDEFINED; |
|
594 |
} |
|
595 |
||
596 |
@Override |
|
597 |
public boolean isError(final ScriptObject sobj) { |
|
598 |
final ScriptObject errorProto = getErrorPrototype(); |
|
599 |
ScriptObject proto = sobj.getProto(); |
|
600 |
while (proto != null) { |
|
601 |
if (proto == errorProto) { |
|
602 |
return true; |
|
603 |
} |
|
604 |
proto = proto.getProto(); |
|
605 |
} |
|
606 |
return false; |
|
607 |
} |
|
608 |
||
609 |
@Override |
|
610 |
public ScriptObject newError(final String msg) { |
|
18851
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
611 |
return new NativeError(msg, this); |
16147 | 612 |
} |
613 |
||
614 |
@Override |
|
615 |
public ScriptObject newEvalError(final String msg) { |
|
18851
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
616 |
return new NativeEvalError(msg, this); |
16147 | 617 |
} |
618 |
||
619 |
@Override |
|
620 |
public ScriptObject newRangeError(final String msg) { |
|
18851
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
621 |
return new NativeRangeError(msg, this); |
16147 | 622 |
} |
623 |
||
624 |
@Override |
|
625 |
public ScriptObject newReferenceError(final String msg) { |
|
18851
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
626 |
return new NativeReferenceError(msg, this); |
16147 | 627 |
} |
628 |
||
629 |
@Override |
|
630 |
public ScriptObject newSyntaxError(final String msg) { |
|
18851
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
631 |
return new NativeSyntaxError(msg, this); |
16147 | 632 |
} |
633 |
||
634 |
@Override |
|
635 |
public ScriptObject newTypeError(final String msg) { |
|
18851
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
636 |
return new NativeTypeError(msg, this); |
16147 | 637 |
} |
638 |
||
639 |
@Override |
|
640 |
public ScriptObject newURIError(final String msg) { |
|
18851
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
641 |
return new NativeURIError(msg, this); |
16147 | 642 |
} |
643 |
||
644 |
@Override |
|
645 |
public PropertyDescriptor newGenericDescriptor(final boolean configurable, final boolean enumerable) { |
|
18851
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
646 |
return new GenericPropertyDescriptor(configurable, enumerable, this); |
16147 | 647 |
} |
648 |
||
649 |
@Override |
|
650 |
public PropertyDescriptor newDataDescriptor(final Object value, final boolean configurable, final boolean enumerable, final boolean writable) { |
|
18851
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
651 |
return new DataPropertyDescriptor(configurable, enumerable, writable, value, this); |
16147 | 652 |
} |
653 |
||
654 |
@Override |
|
655 |
public PropertyDescriptor newAccessorDescriptor(final Object get, final Object set, final boolean configurable, final boolean enumerable) { |
|
18851
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
656 |
final AccessorPropertyDescriptor desc = new AccessorPropertyDescriptor(configurable, enumerable, get == null ? UNDEFINED : get, set == null ? UNDEFINED : set, this); |
16147 | 657 |
|
658 |
if (get == null) { |
|
18328
ebd24057f163
8015355: Array.prototype functions don't honour non-writable length and / or index properties
sundar
parents:
18326
diff
changeset
|
659 |
desc.delete(PropertyDescriptor.GET, false); |
16147 | 660 |
} |
661 |
||
662 |
if (set == null) { |
|
18328
ebd24057f163
8015355: Array.prototype functions don't honour non-writable length and / or index properties
sundar
parents:
18326
diff
changeset
|
663 |
desc.delete(PropertyDescriptor.SET, false); |
16147 | 664 |
} |
665 |
||
666 |
return desc; |
|
667 |
} |
|
668 |
||
669 |
||
670 |
/** |
|
671 |
* Cache for compiled script classes. |
|
672 |
*/ |
|
673 |
@SuppressWarnings("serial") |
|
674 |
private static class ClassCache extends LinkedHashMap<Source, SoftReference<Class<?>>> { |
|
675 |
private final int size; |
|
676 |
||
677 |
ClassCache(int size) { |
|
678 |
super(size, 0.75f, true); |
|
679 |
this.size = size; |
|
680 |
} |
|
681 |
||
682 |
@Override |
|
683 |
protected boolean removeEldestEntry(final Map.Entry<Source, SoftReference<Class<?>>> eldest) { |
|
684 |
return size() >= size; |
|
685 |
} |
|
686 |
} |
|
687 |
||
688 |
// Class cache management |
|
689 |
@Override |
|
690 |
public Class<?> findCachedClass(final Source source) { |
|
691 |
assert classCache != null : "Class cache used without being initialized"; |
|
692 |
SoftReference<Class<?>> ref = classCache.get(source); |
|
693 |
if (ref != null) { |
|
694 |
final Class<?> clazz = ref.get(); |
|
695 |
if (clazz == null) { |
|
696 |
classCache.remove(source); |
|
697 |
} |
|
698 |
return clazz; |
|
699 |
} |
|
700 |
||
701 |
return null; |
|
702 |
} |
|
703 |
||
704 |
@Override |
|
705 |
public void cacheClass(final Source source, final Class<?> clazz) { |
|
706 |
assert classCache != null : "Class cache used without being initialized"; |
|
707 |
classCache.put(source, new SoftReference<Class<?>>(clazz)); |
|
708 |
} |
|
709 |
||
710 |
/** |
|
711 |
* This is the eval used when 'indirect' eval call is made. |
|
712 |
* |
|
713 |
* var global = this; |
|
714 |
* global.eval("print('hello')"); |
|
715 |
* |
|
716 |
* @param self eval scope |
|
717 |
* @param str eval string |
|
718 |
* |
|
719 |
* @return the result of eval |
|
720 |
*/ |
|
721 |
public static Object eval(final Object self, final Object str) { |
|
722 |
return directEval(self, str, UNDEFINED, UNDEFINED, UNDEFINED); |
|
723 |
} |
|
724 |
||
725 |
/** |
|
726 |
* Direct eval |
|
727 |
* |
|
728 |
* @param self The scope of eval passed as 'self' |
|
729 |
* @param str Evaluated code |
|
730 |
* @param callThis "this" to be passed to the evaluated code |
|
731 |
* @param location location of the eval call |
|
732 |
* @param strict is eval called a strict mode code? |
|
733 |
* |
|
734 |
* @return the return value of the eval |
|
735 |
* |
|
736 |
* This is directly invoked from generated when eval(code) is called in user code |
|
737 |
*/ |
|
738 |
public static Object directEval(final Object self, final Object str, final Object callThis, final Object location, final Object strict) { |
|
739 |
if (!(str instanceof String || str instanceof ConsString)) { |
|
740 |
return str; |
|
741 |
} |
|
16185 | 742 |
final Global global = Global.instance(); |
743 |
final ScriptObject scope = (self instanceof ScriptObject) ? (ScriptObject)self : global; |
|
16147 | 744 |
|
18851
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
745 |
return global.getContext().eval(scope, str.toString(), callThis, location, Boolean.TRUE.equals(strict)); |
16147 | 746 |
} |
747 |
||
748 |
/** |
|
749 |
* Global print implementation - Nashorn extension |
|
750 |
* |
|
751 |
* @param self scope |
|
752 |
* @param objects arguments to print |
|
753 |
* |
|
754 |
* @return result of print (undefined) |
|
755 |
*/ |
|
756 |
public static Object print(final Object self, final Object... objects) { |
|
757 |
return printImpl(false, objects); |
|
758 |
} |
|
759 |
||
760 |
/** |
|
761 |
* Global println implementation - Nashorn extension |
|
762 |
* |
|
763 |
* @param self scope |
|
764 |
* @param objects arguments to print |
|
765 |
* |
|
766 |
* @return result of println (undefined) |
|
767 |
*/ |
|
768 |
public static Object println(final Object self, final Object... objects) { |
|
769 |
return printImpl(true, objects); |
|
770 |
} |
|
771 |
||
772 |
/** |
|
773 |
* Global load implementation - Nashorn extension |
|
774 |
* |
|
775 |
* @param self scope |
|
776 |
* @param source source to load |
|
777 |
* |
|
778 |
* @return result of load (undefined) |
|
779 |
* |
|
780 |
* @throws IOException if source could not be read |
|
781 |
*/ |
|
782 |
public static Object load(final Object self, final Object source) throws IOException { |
|
16185 | 783 |
final Global global = Global.instance(); |
784 |
final ScriptObject scope = (self instanceof ScriptObject) ? (ScriptObject)self : global; |
|
18851
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
785 |
return global.getContext().load(scope, source); |
16147 | 786 |
} |
787 |
||
16219 | 788 |
/** |
17974
a2818f17324e
8015741: Need a global.load function that starts with a new global scope.
jlaskey
parents:
17972
diff
changeset
|
789 |
* Global loadWithNewGlobal implementation - Nashorn extension |
a2818f17324e
8015741: Need a global.load function that starts with a new global scope.
jlaskey
parents:
17972
diff
changeset
|
790 |
* |
18326
512bdf9535a6
8016453: loadWithNewGlobal does not allow apply operation
jlaskey
parents:
18321
diff
changeset
|
791 |
* @param self scope |
512bdf9535a6
8016453: loadWithNewGlobal does not allow apply operation
jlaskey
parents:
18321
diff
changeset
|
792 |
* @param args from plus (optional) arguments to be passed to the loaded script |
17974
a2818f17324e
8015741: Need a global.load function that starts with a new global scope.
jlaskey
parents:
17972
diff
changeset
|
793 |
* |
18326
512bdf9535a6
8016453: loadWithNewGlobal does not allow apply operation
jlaskey
parents:
18321
diff
changeset
|
794 |
* @return result of load (may be undefined) |
17974
a2818f17324e
8015741: Need a global.load function that starts with a new global scope.
jlaskey
parents:
17972
diff
changeset
|
795 |
* |
a2818f17324e
8015741: Need a global.load function that starts with a new global scope.
jlaskey
parents:
17972
diff
changeset
|
796 |
* @throws IOException if source could not be read |
a2818f17324e
8015741: Need a global.load function that starts with a new global scope.
jlaskey
parents:
17972
diff
changeset
|
797 |
*/ |
18326
512bdf9535a6
8016453: loadWithNewGlobal does not allow apply operation
jlaskey
parents:
18321
diff
changeset
|
798 |
public static Object loadWithNewGlobal(final Object self, final Object...args) throws IOException { |
17974
a2818f17324e
8015741: Need a global.load function that starts with a new global scope.
jlaskey
parents:
17972
diff
changeset
|
799 |
final Global global = Global.instance(); |
18326
512bdf9535a6
8016453: loadWithNewGlobal does not allow apply operation
jlaskey
parents:
18321
diff
changeset
|
800 |
final int length = args.length; |
512bdf9535a6
8016453: loadWithNewGlobal does not allow apply operation
jlaskey
parents:
18321
diff
changeset
|
801 |
final boolean hasArgs = 0 < length; |
512bdf9535a6
8016453: loadWithNewGlobal does not allow apply operation
jlaskey
parents:
18321
diff
changeset
|
802 |
final Object from = hasArgs ? args[0] : UNDEFINED; |
512bdf9535a6
8016453: loadWithNewGlobal does not allow apply operation
jlaskey
parents:
18321
diff
changeset
|
803 |
final Object[] arguments = hasArgs ? Arrays.copyOfRange(args, 1, length) : args; |
512bdf9535a6
8016453: loadWithNewGlobal does not allow apply operation
jlaskey
parents:
18321
diff
changeset
|
804 |
|
18851
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
805 |
return global.getContext().loadWithNewGlobal(from, arguments); |
17974
a2818f17324e
8015741: Need a global.load function that starts with a new global scope.
jlaskey
parents:
17972
diff
changeset
|
806 |
} |
a2818f17324e
8015741: Need a global.load function that starts with a new global scope.
jlaskey
parents:
17972
diff
changeset
|
807 |
|
a2818f17324e
8015741: Need a global.load function that starts with a new global scope.
jlaskey
parents:
17972
diff
changeset
|
808 |
/** |
16219 | 809 |
* Global exit and quit implementation - Nashorn extension: perform a {@code System.exit} call from the script |
810 |
* |
|
811 |
* @param self self reference |
|
812 |
* @param code exit code |
|
813 |
* |
|
814 |
* @return undefined (will never be reacheD) |
|
815 |
*/ |
|
816 |
public static Object exit(final Object self, final Object code) { |
|
817 |
System.exit(JSType.toInt32(code)); |
|
818 |
return UNDEFINED; |
|
819 |
} |
|
820 |
||
18851
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
821 |
// builtin prototype accessors |
16147 | 822 |
ScriptObject getFunctionPrototype() { |
823 |
return ScriptFunction.getPrototype(builtinFunction); |
|
824 |
} |
|
825 |
||
826 |
ScriptObject getObjectPrototype() { |
|
827 |
return ScriptFunction.getPrototype(builtinObject); |
|
828 |
} |
|
829 |
||
830 |
ScriptObject getArrayPrototype() { |
|
831 |
return ScriptFunction.getPrototype(builtinArray); |
|
832 |
} |
|
833 |
||
834 |
ScriptObject getBooleanPrototype() { |
|
835 |
return ScriptFunction.getPrototype(builtinBoolean); |
|
836 |
} |
|
837 |
||
838 |
ScriptObject getNumberPrototype() { |
|
839 |
return ScriptFunction.getPrototype(builtinNumber); |
|
840 |
} |
|
841 |
||
842 |
ScriptObject getDatePrototype() { |
|
843 |
return ScriptFunction.getPrototype(builtinDate); |
|
844 |
} |
|
845 |
||
846 |
ScriptObject getRegExpPrototype() { |
|
847 |
return ScriptFunction.getPrototype(builtinRegExp); |
|
848 |
} |
|
849 |
||
850 |
ScriptObject getStringPrototype() { |
|
851 |
return ScriptFunction.getPrototype(builtinString); |
|
852 |
} |
|
853 |
||
854 |
ScriptObject getErrorPrototype() { |
|
855 |
return ScriptFunction.getPrototype(builtinError); |
|
856 |
} |
|
857 |
||
858 |
ScriptObject getEvalErrorPrototype() { |
|
859 |
return ScriptFunction.getPrototype(builtinEvalError); |
|
860 |
} |
|
861 |
||
862 |
ScriptObject getRangeErrorPrototype() { |
|
863 |
return ScriptFunction.getPrototype(builtinRangeError); |
|
864 |
} |
|
865 |
||
866 |
ScriptObject getReferenceErrorPrototype() { |
|
867 |
return ScriptFunction.getPrototype(builtinReferenceError); |
|
868 |
} |
|
869 |
||
870 |
ScriptObject getSyntaxErrorPrototype() { |
|
871 |
return ScriptFunction.getPrototype(builtinSyntaxError); |
|
872 |
} |
|
873 |
||
874 |
ScriptObject getTypeErrorPrototype() { |
|
875 |
return ScriptFunction.getPrototype(builtinTypeError); |
|
876 |
} |
|
877 |
||
878 |
ScriptObject getURIErrorPrototype() { |
|
879 |
return ScriptFunction.getPrototype(builtinURIError); |
|
880 |
} |
|
881 |
||
882 |
ScriptObject getJavaImporterPrototype() { |
|
883 |
return ScriptFunction.getPrototype(builtinJavaImporter); |
|
884 |
} |
|
885 |
||
886 |
ScriptObject getJSAdapterPrototype() { |
|
887 |
return ScriptFunction.getPrototype(builtinJSAdapter); |
|
888 |
} |
|
889 |
||
890 |
ScriptObject getArrayBufferPrototype() { |
|
891 |
return ScriptFunction.getPrototype(builtinArrayBuffer); |
|
892 |
} |
|
893 |
||
894 |
ScriptObject getInt8ArrayPrototype() { |
|
895 |
return ScriptFunction.getPrototype(builtinInt8Array); |
|
896 |
} |
|
897 |
||
898 |
ScriptObject getUint8ArrayPrototype() { |
|
899 |
return ScriptFunction.getPrototype(builtinUint8Array); |
|
900 |
} |
|
901 |
||
902 |
ScriptObject getUint8ClampedArrayPrototype() { |
|
903 |
return ScriptFunction.getPrototype(builtinUint8ClampedArray); |
|
904 |
} |
|
905 |
||
906 |
ScriptObject getInt16ArrayPrototype() { |
|
907 |
return ScriptFunction.getPrototype(builtinInt16Array); |
|
908 |
} |
|
909 |
||
910 |
ScriptObject getUint16ArrayPrototype() { |
|
911 |
return ScriptFunction.getPrototype(builtinUint16Array); |
|
912 |
} |
|
913 |
||
914 |
ScriptObject getInt32ArrayPrototype() { |
|
915 |
return ScriptFunction.getPrototype(builtinInt32Array); |
|
916 |
} |
|
917 |
||
918 |
ScriptObject getUint32ArrayPrototype() { |
|
919 |
return ScriptFunction.getPrototype(builtinUint32Array); |
|
920 |
} |
|
921 |
||
922 |
ScriptObject getFloat32ArrayPrototype() { |
|
923 |
return ScriptFunction.getPrototype(builtinFloat32Array); |
|
924 |
} |
|
925 |
||
926 |
ScriptObject getFloat64ArrayPrototype() { |
|
927 |
return ScriptFunction.getPrototype(builtinFloat64Array); |
|
928 |
} |
|
929 |
||
18851
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
930 |
// Builtin PropertyMap accessors |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
931 |
PropertyMap getAccessorPropertyDescriptorMap() { |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
932 |
return accessorPropertyDescriptorMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
933 |
} |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
934 |
|
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
935 |
PropertyMap getArrayBufferViewMap() { |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
936 |
return arrayBufferViewMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
937 |
} |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
938 |
|
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
939 |
PropertyMap getDataPropertyDescriptorMap() { |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
940 |
return dataPropertyDescriptorMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
941 |
} |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
942 |
|
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
943 |
PropertyMap getGenericPropertyDescriptorMap() { |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
944 |
return genericPropertyDescriptorMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
945 |
} |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
946 |
|
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
947 |
PropertyMap getArgumentsMap() { |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
948 |
return nativeArgumentsMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
949 |
} |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
950 |
|
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
951 |
PropertyMap getArrayMap() { |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
952 |
return nativeArrayMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
953 |
} |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
954 |
|
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
955 |
PropertyMap getArrayBufferMap() { |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
956 |
return nativeArrayBufferMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
957 |
} |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
958 |
|
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
959 |
PropertyMap getBooleanMap() { |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
960 |
return nativeBooleanMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
961 |
} |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
962 |
|
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
963 |
PropertyMap getDateMap() { |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
964 |
return nativeDateMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
965 |
} |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
966 |
|
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
967 |
PropertyMap getErrorMap() { |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
968 |
return nativeErrorMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
969 |
} |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
970 |
|
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
971 |
PropertyMap getEvalErrorMap() { |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
972 |
return nativeEvalErrorMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
973 |
} |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
974 |
|
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
975 |
PropertyMap getJSAdapterMap() { |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
976 |
return nativeJSAdapterMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
977 |
} |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
978 |
|
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
979 |
PropertyMap getJavaImporterMap() { |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
980 |
return nativeJavaImporterMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
981 |
} |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
982 |
|
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
983 |
PropertyMap getNumberMap() { |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
984 |
return nativeNumberMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
985 |
} |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
986 |
|
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
987 |
PropertyMap getRangeErrorMap() { |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
988 |
return nativeRangeErrorMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
989 |
} |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
990 |
|
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
991 |
PropertyMap getReferenceErrorMap() { |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
992 |
return nativeReferenceErrorMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
993 |
} |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
994 |
|
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
995 |
PropertyMap getRegExpMap() { |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
996 |
return nativeRegExpMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
997 |
} |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
998 |
|
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
999 |
PropertyMap getRegExpExecResultMap() { |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1000 |
return nativeRegExpExecResultMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1001 |
} |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1002 |
|
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1003 |
PropertyMap getStrictArgumentsMap() { |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1004 |
return nativeStrictArgumentsMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1005 |
} |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1006 |
|
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1007 |
PropertyMap getStringMap() { |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1008 |
return nativeStringMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1009 |
} |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1010 |
|
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1011 |
PropertyMap getSyntaxErrorMap() { |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1012 |
return nativeSyntaxErrorMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1013 |
} |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1014 |
|
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1015 |
PropertyMap getTypeErrorMap() { |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1016 |
return nativeTypeErrorMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1017 |
} |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1018 |
|
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1019 |
PropertyMap getURIErrorMap() { |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1020 |
return nativeURIErrorMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1021 |
} |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1022 |
|
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1023 |
PropertyMap getPrototypeObjectMap() { |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1024 |
return prototypeObjectMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1025 |
} |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1026 |
|
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1027 |
PropertyMap getObjectMap() { |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1028 |
return objectMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1029 |
} |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1030 |
|
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1031 |
PropertyMap getFunctionMap() { |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1032 |
return functionMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1033 |
} |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1034 |
|
18855
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
1035 |
PropertyMap getAnonymousFunctionMap() { |
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
1036 |
return anonymousFunctionMap; |
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
1037 |
} |
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
1038 |
|
18851
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1039 |
PropertyMap getStrictFunctionMap() { |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1040 |
return strictFunctionMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1041 |
} |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1042 |
|
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1043 |
PropertyMap getBoundFunctionMap() { |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1044 |
return boundFunctionMap; |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1045 |
} |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1046 |
|
16147 | 1047 |
private ScriptFunction getBuiltinArray() { |
1048 |
return builtinArray; |
|
1049 |
} |
|
1050 |
||
1051 |
/** |
|
1052 |
* Called from compiled script code to test if builtin has been overridden |
|
1053 |
* |
|
1054 |
* @return true if builtin array has not been overridden |
|
1055 |
*/ |
|
1056 |
public static boolean isBuiltinArray() { |
|
1057 |
final Global instance = Global.instance(); |
|
1058 |
return instance.array == instance.getBuiltinArray(); |
|
1059 |
} |
|
1060 |
||
1061 |
private ScriptFunction getBuiltinBoolean() { |
|
1062 |
return builtinBoolean; |
|
1063 |
} |
|
1064 |
||
1065 |
/** |
|
1066 |
* Called from compiled script code to test if builtin has been overridden |
|
1067 |
* |
|
1068 |
* @return true if builtin boolean has not been overridden |
|
1069 |
*/ |
|
1070 |
public static boolean isBuiltinBoolean() { |
|
1071 |
final Global instance = Global.instance(); |
|
1072 |
return instance._boolean == instance.getBuiltinBoolean(); |
|
1073 |
} |
|
1074 |
||
1075 |
private ScriptFunction getBuiltinDate() { |
|
1076 |
return builtinDate; |
|
1077 |
} |
|
1078 |
||
1079 |
/** |
|
1080 |
* Called from compiled script code to test if builtin has been overridden |
|
1081 |
* |
|
1082 |
* @return true if builtin date has not been overridden |
|
1083 |
*/ |
|
1084 |
public static boolean isBuiltinDate() { |
|
1085 |
final Global instance = Global.instance(); |
|
1086 |
return instance.date == instance.getBuiltinDate(); |
|
1087 |
} |
|
1088 |
||
1089 |
private ScriptFunction getBuiltinError() { |
|
1090 |
return builtinError; |
|
1091 |
} |
|
1092 |
||
1093 |
/** |
|
1094 |
* Called from compiled script code to test if builtin has been overridden |
|
1095 |
* |
|
1096 |
* @return true if builtin error has not been overridden |
|
1097 |
*/ |
|
1098 |
public static boolean isBuiltinError() { |
|
1099 |
final Global instance = Global.instance(); |
|
1100 |
return instance.error == instance.getBuiltinError(); |
|
1101 |
} |
|
1102 |
||
1103 |
private ScriptFunction getBuiltinEvalError() { |
|
1104 |
return builtinEvalError; |
|
1105 |
} |
|
1106 |
||
1107 |
/** |
|
1108 |
* Called from compiled script code to test if builtin has been overridden |
|
1109 |
* |
|
1110 |
* @return true if builtin eval error has not been overridden |
|
1111 |
*/ |
|
1112 |
public static boolean isBuiltinEvalError() { |
|
1113 |
final Global instance = Global.instance(); |
|
1114 |
return instance.evalError == instance.getBuiltinEvalError(); |
|
1115 |
} |
|
1116 |
||
1117 |
private ScriptFunction getBuiltinFunction() { |
|
1118 |
return builtinFunction; |
|
1119 |
} |
|
1120 |
||
1121 |
/** |
|
1122 |
* Called from compiled script code to test if builtin has been overridden |
|
1123 |
* |
|
1124 |
* @return true if builtin function has not been overridden |
|
1125 |
*/ |
|
1126 |
public static boolean isBuiltinFunction() { |
|
1127 |
final Global instance = Global.instance(); |
|
1128 |
return instance.function == instance.getBuiltinFunction(); |
|
1129 |
} |
|
1130 |
||
1131 |
private ScriptFunction getBuiltinJSAdapter() { |
|
1132 |
return builtinJSAdapter; |
|
1133 |
} |
|
1134 |
||
1135 |
/** |
|
1136 |
* Called from compiled script code to test if builtin has been overridden |
|
1137 |
* |
|
1138 |
* @return true if builtin JSAdapter has not been overridden |
|
1139 |
*/ |
|
1140 |
public static boolean isBuiltinJSAdapter() { |
|
1141 |
final Global instance = Global.instance(); |
|
1142 |
return instance.jsadapter == instance.getBuiltinJSAdapter(); |
|
1143 |
} |
|
1144 |
||
1145 |
private ScriptObject getBuiltinJSON() { |
|
1146 |
return builtinJSON; |
|
1147 |
} |
|
1148 |
||
1149 |
/** |
|
1150 |
* Called from compiled script code to test if builtin has been overridden |
|
1151 |
* |
|
1152 |
* @return true if builtin JSON has has not been overridden |
|
1153 |
*/ |
|
1154 |
public static boolean isBuiltinJSON() { |
|
1155 |
final Global instance = Global.instance(); |
|
1156 |
return instance.json == instance.getBuiltinJSON(); |
|
1157 |
} |
|
1158 |
||
1159 |
private ScriptObject getBuiltinJava() { |
|
1160 |
return builtinJava; |
|
1161 |
} |
|
1162 |
||
1163 |
/** |
|
1164 |
* Called from compiled script code to test if builtin has been overridden |
|
1165 |
* |
|
1166 |
* @return true if builtin Java has not been overridden |
|
1167 |
*/ |
|
1168 |
public static boolean isBuiltinJava() { |
|
1169 |
final Global instance = Global.instance(); |
|
1170 |
return instance.java == instance.getBuiltinJava(); |
|
1171 |
} |
|
1172 |
||
1173 |
private ScriptObject getBuiltinJavax() { |
|
1174 |
return builtinJavax; |
|
1175 |
} |
|
1176 |
||
1177 |
/** |
|
1178 |
* Called from compiled script code to test if builtin has been overridden |
|
1179 |
* |
|
1180 |
* @return true if builtin Javax has not been overridden |
|
1181 |
*/ |
|
1182 |
public static boolean isBuiltinJavax() { |
|
1183 |
final Global instance = Global.instance(); |
|
1184 |
return instance.javax == instance.getBuiltinJavax(); |
|
1185 |
} |
|
1186 |
||
1187 |
private ScriptObject getBuiltinJavaImporter() { |
|
1188 |
return builtinJavaImporter; |
|
1189 |
} |
|
1190 |
||
1191 |
/** |
|
1192 |
* Called from compiled script code to test if builtin has been overridden |
|
1193 |
* |
|
1194 |
* @return true if builtin Java importer has not been overridden |
|
1195 |
*/ |
|
1196 |
public static boolean isBuiltinJavaImporter() { |
|
1197 |
final Global instance = Global.instance(); |
|
1198 |
return instance.javaImporter == instance.getBuiltinJavaImporter(); |
|
1199 |
} |
|
1200 |
||
1201 |
private ScriptObject getBuiltinMath() { |
|
1202 |
return builtinMath; |
|
1203 |
} |
|
1204 |
||
1205 |
/** |
|
1206 |
* Called from compiled script code to test if builtin has been overridden |
|
1207 |
* |
|
1208 |
* @return true if builtin math has not been overridden |
|
1209 |
*/ |
|
1210 |
public static boolean isBuiltinMath() { |
|
1211 |
final Global instance = Global.instance(); |
|
1212 |
return instance.math == instance.getBuiltinMath(); |
|
1213 |
} |
|
1214 |
||
1215 |
private ScriptFunction getBuiltinNumber() { |
|
1216 |
return builtinNumber; |
|
1217 |
} |
|
1218 |
||
1219 |
/** |
|
1220 |
* Called from compiled script code to test if builtin has been overridden |
|
1221 |
* |
|
1222 |
* @return true if builtin number has not been overridden |
|
1223 |
*/ |
|
1224 |
public static boolean isBuiltinNumber() { |
|
1225 |
final Global instance = Global.instance(); |
|
1226 |
return instance.number == instance.getBuiltinNumber(); |
|
1227 |
} |
|
1228 |
||
1229 |
private ScriptFunction getBuiltinObject() { |
|
1230 |
return builtinObject; |
|
1231 |
} |
|
1232 |
||
1233 |
/** |
|
1234 |
* Called from compiled script code to test if builtin has been overridden |
|
1235 |
* |
|
1236 |
* @return true if builtin object has not been overridden |
|
1237 |
*/ |
|
1238 |
public static boolean isBuiltinObject() { |
|
1239 |
final Global instance = Global.instance(); |
|
1240 |
return instance.object == instance.getBuiltinObject(); |
|
1241 |
} |
|
1242 |
||
1243 |
private ScriptObject getBuiltinPackages() { |
|
1244 |
return builtinPackages; |
|
1245 |
} |
|
1246 |
||
1247 |
/** |
|
1248 |
* Called from compiled script code to test if builtin has been overridden |
|
1249 |
* |
|
1250 |
* @return true if builtin package has not been overridden |
|
1251 |
*/ |
|
1252 |
public static boolean isBuiltinPackages() { |
|
1253 |
final Global instance = Global.instance(); |
|
1254 |
return instance.packages == instance.getBuiltinPackages(); |
|
1255 |
} |
|
1256 |
||
1257 |
private ScriptFunction getBuiltinRangeError() { |
|
1258 |
return builtinRangeError; |
|
1259 |
} |
|
1260 |
||
1261 |
/** |
|
1262 |
* Called from compiled script code to test if builtin has been overridden |
|
1263 |
* |
|
1264 |
* @return true if builtin range error has not been overridden |
|
1265 |
*/ |
|
1266 |
public static boolean isBuiltinRangeError() { |
|
1267 |
final Global instance = Global.instance(); |
|
1268 |
return instance.rangeError == instance.getBuiltinRangeError(); |
|
1269 |
} |
|
1270 |
||
1271 |
private ScriptFunction getBuiltinReferenceError() { |
|
1272 |
return builtinReferenceError; |
|
1273 |
} |
|
1274 |
||
1275 |
/** |
|
1276 |
* Called from compiled script code to test if builtin has been overridden |
|
1277 |
* |
|
1278 |
* @return true if builtin reference error has not been overridden |
|
1279 |
*/ |
|
1280 |
public static boolean isBuiltinReferenceError() { |
|
1281 |
final Global instance = Global.instance(); |
|
1282 |
return instance.referenceError == instance.getBuiltinReferenceError(); |
|
1283 |
} |
|
1284 |
||
1285 |
private ScriptFunction getBuiltinRegExp() { |
|
1286 |
return builtinRegExp; |
|
1287 |
} |
|
1288 |
||
1289 |
/** |
|
1290 |
* Called from compiled script code to test if builtin has been overridden |
|
1291 |
* |
|
1292 |
* @return true if builtin regexp has not been overridden |
|
1293 |
*/ |
|
1294 |
public static boolean isBuiltinRegExp() { |
|
1295 |
final Global instance = Global.instance(); |
|
1296 |
return instance.regexp == instance.getBuiltinRegExp(); |
|
1297 |
} |
|
1298 |
||
1299 |
private ScriptFunction getBuiltinString() { |
|
1300 |
return builtinString; |
|
1301 |
} |
|
1302 |
||
1303 |
/** |
|
1304 |
* Called from compiled script code to test if builtin has been overridden |
|
1305 |
* |
|
1306 |
* @return true if builtin Java has not been overridden |
|
1307 |
*/ |
|
1308 |
public static boolean isBuiltinString() { |
|
1309 |
final Global instance = Global.instance(); |
|
1310 |
return instance.string == instance.getBuiltinString(); |
|
1311 |
} |
|
1312 |
||
1313 |
private ScriptFunction getBuiltinSyntaxError() { |
|
1314 |
return builtinSyntaxError; |
|
1315 |
} |
|
1316 |
||
1317 |
/** |
|
1318 |
* Called from compiled script code to test if builtin has been overridden |
|
1319 |
* |
|
1320 |
* @return true if builtin syntax error has not been overridden |
|
1321 |
*/ |
|
1322 |
public static boolean isBuiltinSyntaxError() { |
|
1323 |
final Global instance = Global.instance(); |
|
1324 |
return instance.syntaxError == instance.getBuiltinSyntaxError(); |
|
1325 |
} |
|
1326 |
||
1327 |
private ScriptFunction getBuiltinTypeError() { |
|
1328 |
return builtinTypeError; |
|
1329 |
} |
|
1330 |
||
1331 |
/** |
|
1332 |
* Called from compiled script code to test if builtin has been overridden |
|
1333 |
* |
|
1334 |
* @return true if builtin type error has not been overridden |
|
1335 |
*/ |
|
1336 |
public static boolean isBuiltinTypeError() { |
|
1337 |
final Global instance = Global.instance(); |
|
1338 |
return instance.typeError == instance.getBuiltinTypeError(); |
|
1339 |
} |
|
1340 |
||
1341 |
private ScriptFunction getBuiltinURIError() { |
|
1342 |
return builtinURIError; |
|
1343 |
} |
|
1344 |
||
1345 |
/** |
|
1346 |
* Called from compiled script code to test if builtin has been overridden |
|
1347 |
* |
|
1348 |
* @return true if builtin URI error has not been overridden |
|
1349 |
*/ |
|
1350 |
public static boolean isBuiltinURIError() { |
|
1351 |
final Global instance = Global.instance(); |
|
1352 |
return instance.uriError == instance.getBuiltinURIError(); |
|
1353 |
} |
|
1354 |
||
1355 |
@Override |
|
1356 |
public String getClassName() { |
|
1357 |
return "global"; |
|
1358 |
} |
|
1359 |
||
1360 |
/** |
|
1361 |
* Copy function used to clone NativeRegExp objects. |
|
1362 |
* |
|
1363 |
* @param regexp a NativeRegExp to clone |
|
1364 |
* |
|
1365 |
* @return copy of the given regexp object |
|
1366 |
*/ |
|
1367 |
public static Object regExpCopy(final Object regexp) { |
|
1368 |
return new NativeRegExp((NativeRegExp)regexp); |
|
1369 |
} |
|
1370 |
||
1371 |
/** |
|
1372 |
* Convert given object to NativeRegExp type. |
|
1373 |
* |
|
1374 |
* @param obj object to be converted |
|
1375 |
* @return NativeRegExp instance |
|
1376 |
*/ |
|
1377 |
public static NativeRegExp toRegExp(final Object obj) { |
|
1378 |
if (obj instanceof NativeRegExp) { |
|
1379 |
return (NativeRegExp)obj; |
|
1380 |
} |
|
1381 |
return new NativeRegExp(JSType.toString(obj)); |
|
1382 |
} |
|
1383 |
||
1384 |
/** |
|
1385 |
* ECMA 9.9 ToObject implementation |
|
1386 |
* |
|
1387 |
* @param obj an item for which to run ToObject |
|
1388 |
* @return ToObject version of given item |
|
1389 |
*/ |
|
1390 |
public static Object toObject(final Object obj) { |
|
1391 |
if (obj == null || obj == UNDEFINED) { |
|
16256
f2d9a0c49914
8007002: Replace implicit exception throwing methods with explicit throws - simplify control flow and remove useless code
lagergren
parents:
16234
diff
changeset
|
1392 |
throw typeError("not.an.object", ScriptRuntime.safeToString(obj)); |
16147 | 1393 |
} |
1394 |
||
1395 |
if (obj instanceof ScriptObject) { |
|
1396 |
return obj; |
|
1397 |
} |
|
1398 |
||
1399 |
return instance().wrapAsObject(obj); |
|
1400 |
} |
|
1401 |
||
1402 |
/** |
|
1403 |
* Allocate a new object array. |
|
1404 |
* |
|
1405 |
* @param initial object values. |
|
1406 |
* @return the new array |
|
1407 |
*/ |
|
16210
8ad1381b69d0
8007215: Varargs broken for the case of passing more than the arg limit arguments.
lagergren
parents:
16207
diff
changeset
|
1408 |
public static NativeArray allocate(final Object[] initial) { |
18618
136279c4cbe6
8019157: Avoid calling ScriptObject.setProto() if possible
hannesw
parents:
18610
diff
changeset
|
1409 |
ArrayData arrayData = ArrayData.allocate(initial); |
136279c4cbe6
8019157: Avoid calling ScriptObject.setProto() if possible
hannesw
parents:
18610
diff
changeset
|
1410 |
|
136279c4cbe6
8019157: Avoid calling ScriptObject.setProto() if possible
hannesw
parents:
18610
diff
changeset
|
1411 |
for (int index = 0; index < initial.length; index++) { |
136279c4cbe6
8019157: Avoid calling ScriptObject.setProto() if possible
hannesw
parents:
18610
diff
changeset
|
1412 |
final Object value = initial[index]; |
136279c4cbe6
8019157: Avoid calling ScriptObject.setProto() if possible
hannesw
parents:
18610
diff
changeset
|
1413 |
|
136279c4cbe6
8019157: Avoid calling ScriptObject.setProto() if possible
hannesw
parents:
18610
diff
changeset
|
1414 |
if (value == ScriptRuntime.EMPTY) { |
136279c4cbe6
8019157: Avoid calling ScriptObject.setProto() if possible
hannesw
parents:
18610
diff
changeset
|
1415 |
arrayData = arrayData.delete(index); |
136279c4cbe6
8019157: Avoid calling ScriptObject.setProto() if possible
hannesw
parents:
18610
diff
changeset
|
1416 |
} |
136279c4cbe6
8019157: Avoid calling ScriptObject.setProto() if possible
hannesw
parents:
18610
diff
changeset
|
1417 |
} |
136279c4cbe6
8019157: Avoid calling ScriptObject.setProto() if possible
hannesw
parents:
18610
diff
changeset
|
1418 |
|
136279c4cbe6
8019157: Avoid calling ScriptObject.setProto() if possible
hannesw
parents:
18610
diff
changeset
|
1419 |
return new NativeArray(arrayData); |
16147 | 1420 |
} |
1421 |
||
1422 |
/** |
|
1423 |
* Allocate a new number array. |
|
1424 |
* |
|
1425 |
* @param initial number values. |
|
1426 |
* @return the new array |
|
1427 |
*/ |
|
16210
8ad1381b69d0
8007215: Varargs broken for the case of passing more than the arg limit arguments.
lagergren
parents:
16207
diff
changeset
|
1428 |
public static NativeArray allocate(final double[] initial) { |
18618
136279c4cbe6
8019157: Avoid calling ScriptObject.setProto() if possible
hannesw
parents:
18610
diff
changeset
|
1429 |
return new NativeArray(ArrayData.allocate(initial)); |
16147 | 1430 |
} |
1431 |
||
1432 |
/** |
|
1433 |
* Allocate a new long array. |
|
1434 |
* |
|
1435 |
* @param initial number values. |
|
1436 |
* @return the new array |
|
1437 |
*/ |
|
16210
8ad1381b69d0
8007215: Varargs broken for the case of passing more than the arg limit arguments.
lagergren
parents:
16207
diff
changeset
|
1438 |
public static NativeArray allocate(final long[] initial) { |
18618
136279c4cbe6
8019157: Avoid calling ScriptObject.setProto() if possible
hannesw
parents:
18610
diff
changeset
|
1439 |
return new NativeArray(ArrayData.allocate(initial)); |
16147 | 1440 |
} |
1441 |
||
1442 |
/** |
|
1443 |
* Allocate a new integer array. |
|
1444 |
* |
|
1445 |
* @param initial number values. |
|
1446 |
* @return the new array |
|
1447 |
*/ |
|
16210
8ad1381b69d0
8007215: Varargs broken for the case of passing more than the arg limit arguments.
lagergren
parents:
16207
diff
changeset
|
1448 |
public static NativeArray allocate(final int[] initial) { |
18618
136279c4cbe6
8019157: Avoid calling ScriptObject.setProto() if possible
hannesw
parents:
18610
diff
changeset
|
1449 |
return new NativeArray(ArrayData.allocate(initial)); |
16147 | 1450 |
} |
1451 |
||
1452 |
/** |
|
1453 |
* Allocate a new object array for arguments. |
|
1454 |
* |
|
1455 |
* @param arguments initial arguments passed. |
|
1456 |
* @param callee reference to the function that uses arguments object |
|
1457 |
* @param numParams actual number of declared parameters |
|
1458 |
* |
|
1459 |
* @return the new array |
|
1460 |
*/ |
|
16206
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
16196
diff
changeset
|
1461 |
public static ScriptObject allocateArguments(final Object[] arguments, final Object callee, final int numParams) { |
16147 | 1462 |
return NativeArguments.allocate(arguments, (ScriptFunction)callee, numParams); |
1463 |
} |
|
1464 |
||
1465 |
/** |
|
1466 |
* Called from generated to check if given function is the builtin 'eval'. If |
|
1467 |
* eval is used in a script, a lot of optimizations and assumptions cannot be done. |
|
1468 |
* |
|
1469 |
* @param fn function object that is checked |
|
1470 |
* @return true if fn is the builtin eval |
|
1471 |
*/ |
|
1472 |
public static boolean isEval(final Object fn) { |
|
1473 |
return fn == Global.instance().builtinEval; |
|
1474 |
} |
|
1475 |
||
1476 |
/** |
|
1477 |
* Create a new RegExp object. |
|
1478 |
* |
|
1479 |
* @param expression Regular expression. |
|
1480 |
* @param options Search options. |
|
1481 |
* |
|
1482 |
* @return New RegExp object. |
|
1483 |
*/ |
|
1484 |
public static Object newRegExp(final String expression, final String options) { |
|
1485 |
if (options == null) { |
|
1486 |
return new NativeRegExp(expression); |
|
1487 |
} |
|
1488 |
return new NativeRegExp(expression, options); |
|
1489 |
} |
|
1490 |
||
1491 |
/** |
|
1492 |
* Get the object prototype |
|
1493 |
* |
|
1494 |
* @return the object prototype |
|
1495 |
*/ |
|
1496 |
public static ScriptObject objectPrototype() { |
|
1497 |
return Global.instance().getObjectPrototype(); |
|
1498 |
} |
|
1499 |
||
1500 |
/** |
|
1501 |
* Create a new empty object instance. |
|
1502 |
* |
|
1503 |
* @return New empty object. |
|
1504 |
*/ |
|
1505 |
public static ScriptObject newEmptyInstance() { |
|
18618
136279c4cbe6
8019157: Avoid calling ScriptObject.setProto() if possible
hannesw
parents:
18610
diff
changeset
|
1506 |
return Global.instance().newObject(); |
16147 | 1507 |
} |
1508 |
||
1509 |
/** |
|
1510 |
* Check if a given object is a ScriptObject, raises an exception if this is |
|
1511 |
* not the case |
|
1512 |
* |
|
1513 |
* @param obj and object to check |
|
1514 |
*/ |
|
1515 |
public static void checkObject(final Object obj) { |
|
1516 |
if (!(obj instanceof ScriptObject)) { |
|
16256
f2d9a0c49914
8007002: Replace implicit exception throwing methods with explicit throws - simplify control flow and remove useless code
lagergren
parents:
16234
diff
changeset
|
1517 |
throw typeError("not.an.object", ScriptRuntime.safeToString(obj)); |
16147 | 1518 |
} |
1519 |
} |
|
1520 |
||
1521 |
/** |
|
1522 |
* ECMA 9.10 - implementation of CheckObjectCoercible, i.e. raise an exception |
|
1523 |
* if this object is null or undefined. |
|
1524 |
* |
|
1525 |
* @param obj an object to check |
|
1526 |
*/ |
|
1527 |
public static void checkObjectCoercible(final Object obj) { |
|
1528 |
if (obj == null || obj == UNDEFINED) { |
|
16256
f2d9a0c49914
8007002: Replace implicit exception throwing methods with explicit throws - simplify control flow and remove useless code
lagergren
parents:
16234
diff
changeset
|
1529 |
throw typeError("not.an.object", ScriptRuntime.safeToString(obj)); |
16147 | 1530 |
} |
1531 |
} |
|
1532 |
||
1533 |
/** |
|
1534 |
* Get the current split state. |
|
1535 |
* |
|
1536 |
* @return current split state |
|
1537 |
*/ |
|
1538 |
@Override |
|
1539 |
public int getSplitState() { |
|
1540 |
return splitState; |
|
1541 |
} |
|
1542 |
||
1543 |
/** |
|
1544 |
* Set the current split state. |
|
1545 |
* |
|
1546 |
* @param state current split state |
|
1547 |
*/ |
|
1548 |
@Override |
|
1549 |
public void setSplitState(final int state) { |
|
1550 |
splitState = state; |
|
1551 |
} |
|
1552 |
||
1553 |
private void init() { |
|
16185 | 1554 |
assert Context.getGlobal() == this : "this global is not set as current"; |
1555 |
||
18851
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1556 |
final ScriptEnvironment env = getContext().getEnv(); |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1557 |
|
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1558 |
// duplicate PropertyMaps of Native* classes |
18855
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
1559 |
copyInitialMaps(env); |
18851
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1560 |
|
16147 | 1561 |
// initialize Function and Object constructor |
1562 |
initFunctionAndObject(); |
|
1563 |
||
1564 |
// Now fix Global's own proto. |
|
1565 |
this.setProto(getObjectPrototype()); |
|
1566 |
||
1567 |
// initialize global function properties |
|
1568 |
this.eval = this.builtinEval = ScriptFunctionImpl.makeFunction("eval", EVAL); |
|
1569 |
||
1570 |
this.parseInt = ScriptFunctionImpl.makeFunction("parseInt", GlobalFunctions.PARSEINT); |
|
1571 |
this.parseFloat = ScriptFunctionImpl.makeFunction("parseFloat", GlobalFunctions.PARSEFLOAT); |
|
1572 |
this.isNaN = ScriptFunctionImpl.makeFunction("isNaN", GlobalFunctions.IS_NAN); |
|
1573 |
this.isFinite = ScriptFunctionImpl.makeFunction("isFinite", GlobalFunctions.IS_FINITE); |
|
1574 |
this.encodeURI = ScriptFunctionImpl.makeFunction("encodeURI", GlobalFunctions.ENCODE_URI); |
|
1575 |
this.encodeURIComponent = ScriptFunctionImpl.makeFunction("encodeURIComponent", GlobalFunctions.ENCODE_URICOMPONENT); |
|
1576 |
this.decodeURI = ScriptFunctionImpl.makeFunction("decodeURI", GlobalFunctions.DECODE_URI); |
|
1577 |
this.decodeURIComponent = ScriptFunctionImpl.makeFunction("decodeURIComponent", GlobalFunctions.DECODE_URICOMPONENT); |
|
1578 |
this.escape = ScriptFunctionImpl.makeFunction("escape", GlobalFunctions.ESCAPE); |
|
1579 |
this.unescape = ScriptFunctionImpl.makeFunction("unescape", GlobalFunctions.UNESCAPE); |
|
16262
75513555e603
8008731: Separate configuration environment (options, error/output writer etc.) from Context
sundar
parents:
16258
diff
changeset
|
1580 |
this.print = ScriptFunctionImpl.makeFunction("print", env._print_no_newline ? PRINT : PRINTLN); |
16147 | 1581 |
this.load = ScriptFunctionImpl.makeFunction("load", LOAD); |
17974
a2818f17324e
8015741: Need a global.load function that starts with a new global scope.
jlaskey
parents:
17972
diff
changeset
|
1582 |
this.loadWithNewGlobal = ScriptFunctionImpl.makeFunction("loadWithNewGlobal", LOADWITHNEWGLOBAL); |
16219 | 1583 |
this.exit = ScriptFunctionImpl.makeFunction("exit", EXIT); |
1584 |
this.quit = ScriptFunctionImpl.makeFunction("quit", EXIT); |
|
16147 | 1585 |
|
1586 |
// built-in constructors |
|
1587 |
this.builtinArray = (ScriptFunction)initConstructor("Array"); |
|
1588 |
this.builtinBoolean = (ScriptFunction)initConstructor("Boolean"); |
|
1589 |
this.builtinDate = (ScriptFunction)initConstructor("Date"); |
|
1590 |
this.builtinJSON = initConstructor("JSON"); |
|
1591 |
this.builtinJSAdapter = (ScriptFunction)initConstructor("JSAdapter"); |
|
1592 |
this.builtinMath = initConstructor("Math"); |
|
1593 |
this.builtinNumber = (ScriptFunction)initConstructor("Number"); |
|
1594 |
this.builtinRegExp = (ScriptFunction)initConstructor("RegExp"); |
|
1595 |
this.builtinString = (ScriptFunction)initConstructor("String"); |
|
1596 |
||
1597 |
// initialize String.prototype.length to 0 |
|
1598 |
// add String.prototype.length |
|
1599 |
final ScriptObject stringPrototype = getStringPrototype(); |
|
1600 |
stringPrototype.addOwnProperty("length", Attribute.NON_ENUMERABLE_CONSTANT, 0.0); |
|
1601 |
||
1602 |
// add Array.prototype.length |
|
1603 |
final ScriptObject arrayPrototype = getArrayPrototype(); |
|
16276
4437442f3523
8009553: Object.create(Array.prototype) doesn't respect reset length
sundar
parents:
16275
diff
changeset
|
1604 |
arrayPrototype.addOwnProperty("length", Attribute.NOT_ENUMERABLE|Attribute.NOT_CONFIGURABLE, 0.0); |
16147 | 1605 |
|
18851
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1606 |
this.DEFAULT_DATE = new NativeDate(Double.NaN, this); |
16147 | 1607 |
|
1608 |
// initialize default regexp object |
|
18851
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1609 |
this.DEFAULT_REGEXP = new NativeRegExp("(?:)", this); |
16147 | 1610 |
|
1611 |
// RegExp.prototype should behave like a RegExp object. So copy the |
|
1612 |
// properties. |
|
1613 |
final ScriptObject regExpProto = getRegExpPrototype(); |
|
1614 |
regExpProto.addBoundProperties(DEFAULT_REGEXP); |
|
1615 |
||
1616 |
// Error stuff |
|
1617 |
initErrorObjects(); |
|
1618 |
||
1619 |
// java access |
|
18855
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
1620 |
if (! env._no_java) { |
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
1621 |
initJavaAccess(); |
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
1622 |
} |
16147 | 1623 |
|
18855
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
1624 |
if (! env._no_typed_arrays) { |
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
1625 |
initTypedArray(); |
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
1626 |
} |
16147 | 1627 |
|
16262
75513555e603
8008731: Separate configuration environment (options, error/output writer etc.) from Context
sundar
parents:
16258
diff
changeset
|
1628 |
if (env._scripting) { |
18855
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
1629 |
initScripting(env); |
16147 | 1630 |
} |
1631 |
||
16185 | 1632 |
if (Context.DEBUG && System.getSecurityManager() == null) { |
16147 | 1633 |
initDebug(); |
1634 |
} |
|
1635 |
||
1636 |
copyBuiltins(); |
|
1637 |
||
1638 |
// initialized with strings so that typeof will work as expected. |
|
1639 |
this.__FILE__ = ""; |
|
1640 |
this.__DIR__ = ""; |
|
1641 |
this.__LINE__ = 0.0; |
|
1642 |
||
1643 |
// expose script (command line) arguments as "arguments" property of global |
|
16262
75513555e603
8008731: Separate configuration environment (options, error/output writer etc.) from Context
sundar
parents:
16258
diff
changeset
|
1644 |
final List<String> arguments = env.getArguments(); |
16147 | 1645 |
final Object argsObj = wrapAsObject(arguments.toArray()); |
1646 |
||
1647 |
addOwnProperty("arguments", Attribute.NOT_ENUMERABLE, argsObj); |
|
16262
75513555e603
8008731: Separate configuration environment (options, error/output writer etc.) from Context
sundar
parents:
16258
diff
changeset
|
1648 |
if (env._scripting) { |
16147 | 1649 |
// synonym for "arguments" in scripting mode |
1650 |
addOwnProperty("$ARG", Attribute.NOT_ENUMERABLE, argsObj); |
|
1651 |
} |
|
1652 |
} |
|
1653 |
||
1654 |
private void initErrorObjects() { |
|
1655 |
// Error objects |
|
1656 |
this.builtinError = (ScriptFunction)initConstructor("Error"); |
|
1657 |
final ScriptObject errorProto = getErrorPrototype(); |
|
1658 |
||
1659 |
// Nashorn specific accessors on Error.prototype - stack, lineNumber, columnNumber and fileName |
|
1660 |
final ScriptFunction getStack = ScriptFunctionImpl.makeFunction("getStack", NativeError.GET_STACK); |
|
1661 |
final ScriptFunction setStack = ScriptFunctionImpl.makeFunction("setStack", NativeError.SET_STACK); |
|
1662 |
errorProto.addOwnProperty("stack", Attribute.NOT_ENUMERABLE, getStack, setStack); |
|
1663 |
final ScriptFunction getLineNumber = ScriptFunctionImpl.makeFunction("getLineNumber", NativeError.GET_LINENUMBER); |
|
1664 |
final ScriptFunction setLineNumber = ScriptFunctionImpl.makeFunction("setLineNumber", NativeError.SET_LINENUMBER); |
|
1665 |
errorProto.addOwnProperty("lineNumber", Attribute.NOT_ENUMERABLE, getLineNumber, setLineNumber); |
|
1666 |
final ScriptFunction getColumnNumber = ScriptFunctionImpl.makeFunction("getColumnNumber", NativeError.GET_COLUMNNUMBER); |
|
1667 |
final ScriptFunction setColumnNumber = ScriptFunctionImpl.makeFunction("setColumnNumber", NativeError.SET_COLUMNNUMBER); |
|
1668 |
errorProto.addOwnProperty("columnNumber", Attribute.NOT_ENUMERABLE, getColumnNumber, setColumnNumber); |
|
1669 |
final ScriptFunction getFileName = ScriptFunctionImpl.makeFunction("getFileName", NativeError.GET_FILENAME); |
|
1670 |
final ScriptFunction setFileName = ScriptFunctionImpl.makeFunction("setFileName", NativeError.SET_FILENAME); |
|
1671 |
errorProto.addOwnProperty("fileName", Attribute.NOT_ENUMERABLE, getFileName, setFileName); |
|
1672 |
||
1673 |
// ECMA 15.11.4.2 Error.prototype.name |
|
1674 |
// Error.prototype.name = "Error"; |
|
18328
ebd24057f163
8015355: Array.prototype functions don't honour non-writable length and / or index properties
sundar
parents:
18326
diff
changeset
|
1675 |
errorProto.set(NativeError.NAME, "Error", false); |
16147 | 1676 |
// ECMA 15.11.4.3 Error.prototype.message |
1677 |
// Error.prototype.message = ""; |
|
18328
ebd24057f163
8015355: Array.prototype functions don't honour non-writable length and / or index properties
sundar
parents:
18326
diff
changeset
|
1678 |
errorProto.set(NativeError.MESSAGE, "", false); |
16147 | 1679 |
|
1680 |
this.builtinEvalError = initErrorSubtype("EvalError", errorProto); |
|
1681 |
this.builtinRangeError = initErrorSubtype("RangeError", errorProto); |
|
1682 |
this.builtinReferenceError = initErrorSubtype("ReferenceError", errorProto); |
|
1683 |
this.builtinSyntaxError = initErrorSubtype("SyntaxError", errorProto); |
|
1684 |
this.builtinTypeError = initErrorSubtype("TypeError", errorProto); |
|
1685 |
this.builtinURIError = initErrorSubtype("URIError", errorProto); |
|
1686 |
} |
|
1687 |
||
1688 |
private ScriptFunction initErrorSubtype(final String name, final ScriptObject errorProto) { |
|
1689 |
final ScriptObject cons = initConstructor(name); |
|
1690 |
final ScriptObject prototype = ScriptFunction.getPrototype(cons); |
|
18328
ebd24057f163
8015355: Array.prototype functions don't honour non-writable length and / or index properties
sundar
parents:
18326
diff
changeset
|
1691 |
prototype.set(NativeError.NAME, name, false); |
ebd24057f163
8015355: Array.prototype functions don't honour non-writable length and / or index properties
sundar
parents:
18326
diff
changeset
|
1692 |
prototype.set(NativeError.MESSAGE, "", false); |
16147 | 1693 |
prototype.setProto(errorProto); |
1694 |
return (ScriptFunction)cons; |
|
1695 |
} |
|
1696 |
||
1697 |
private void initJavaAccess() { |
|
1698 |
final ScriptObject objectProto = getObjectPrototype(); |
|
1699 |
this.builtinPackages = new NativeJavaPackage("", objectProto); |
|
16532 | 1700 |
this.builtinCom = new NativeJavaPackage("com", objectProto); |
1701 |
this.builtinEdu = new NativeJavaPackage("edu", objectProto); |
|
16147 | 1702 |
this.builtinJava = new NativeJavaPackage("java", objectProto); |
16532 | 1703 |
this.builtinJavafx = new NativeJavaPackage("javafx", objectProto); |
16147 | 1704 |
this.builtinJavax = new NativeJavaPackage("javax", objectProto); |
16532 | 1705 |
this.builtinOrg = new NativeJavaPackage("org", objectProto); |
16147 | 1706 |
this.builtinJavaImporter = initConstructor("JavaImporter"); |
1707 |
this.builtinJavaApi = initConstructor("Java"); |
|
1708 |
} |
|
1709 |
||
18855
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
1710 |
private void initScripting(final ScriptEnvironment scriptEnv) { |
16147 | 1711 |
Object value; |
1712 |
value = ScriptFunctionImpl.makeFunction("readLine", ScriptingFunctions.READLINE); |
|
1713 |
addOwnProperty("readLine", Attribute.NOT_ENUMERABLE, value); |
|
1714 |
||
16196
58f6f046bb5e
8006983: Introduce a command line option to switch off syntactic extensions of nashorn
sundar
parents:
16195
diff
changeset
|
1715 |
value = ScriptFunctionImpl.makeFunction("readFully", ScriptingFunctions.READFULLY); |
58f6f046bb5e
8006983: Introduce a command line option to switch off syntactic extensions of nashorn
sundar
parents:
16195
diff
changeset
|
1716 |
addOwnProperty("readFully", Attribute.NOT_ENUMERABLE, value); |
16147 | 1717 |
|
16211 | 1718 |
final String execName = ScriptingFunctions.EXEC_NAME; |
1719 |
value = ScriptFunctionImpl.makeFunction(execName, ScriptingFunctions.EXEC); |
|
1720 |
addOwnProperty(execName, Attribute.NOT_ENUMERABLE, value); |
|
1721 |
||
16147 | 1722 |
// Nashorn extension: global.echo (scripting-mode-only) |
1723 |
// alias for "print" |
|
1724 |
value = get("print"); |
|
1725 |
addOwnProperty("echo", Attribute.NOT_ENUMERABLE, value); |
|
1726 |
||
1727 |
// Nashorn extension: global.$OPTIONS (scripting-mode-only) |
|
18618
136279c4cbe6
8019157: Avoid calling ScriptObject.setProto() if possible
hannesw
parents:
18610
diff
changeset
|
1728 |
final ScriptObject options = newObject(); |
16522 | 1729 |
copyOptions(options, scriptEnv); |
1730 |
addOwnProperty("$OPTIONS", Attribute.NOT_ENUMERABLE, options); |
|
16211 | 1731 |
|
1732 |
// Nashorn extension: global.$ENV (scripting-mode-only) |
|
16213
66cb726a76d5
8007521: $ENV should be undefined when security manager is present
sundar
parents:
16211
diff
changeset
|
1733 |
if (System.getSecurityManager() == null) { |
66cb726a76d5
8007521: $ENV should be undefined when security manager is present
sundar
parents:
16211
diff
changeset
|
1734 |
// do not fill $ENV if we have a security manager around |
66cb726a76d5
8007521: $ENV should be undefined when security manager is present
sundar
parents:
16211
diff
changeset
|
1735 |
// Retrieve current state of ENV variables. |
18618
136279c4cbe6
8019157: Avoid calling ScriptObject.setProto() if possible
hannesw
parents:
18610
diff
changeset
|
1736 |
final ScriptObject env = newObject(); |
16213
66cb726a76d5
8007521: $ENV should be undefined when security manager is present
sundar
parents:
16211
diff
changeset
|
1737 |
env.putAll(System.getenv()); |
66cb726a76d5
8007521: $ENV should be undefined when security manager is present
sundar
parents:
16211
diff
changeset
|
1738 |
addOwnProperty(ScriptingFunctions.ENV_NAME, Attribute.NOT_ENUMERABLE, env); |
66cb726a76d5
8007521: $ENV should be undefined when security manager is present
sundar
parents:
16211
diff
changeset
|
1739 |
} else { |
66cb726a76d5
8007521: $ENV should be undefined when security manager is present
sundar
parents:
16211
diff
changeset
|
1740 |
addOwnProperty(ScriptingFunctions.ENV_NAME, Attribute.NOT_ENUMERABLE, UNDEFINED); |
66cb726a76d5
8007521: $ENV should be undefined when security manager is present
sundar
parents:
16211
diff
changeset
|
1741 |
} |
66cb726a76d5
8007521: $ENV should be undefined when security manager is present
sundar
parents:
16211
diff
changeset
|
1742 |
|
66cb726a76d5
8007521: $ENV should be undefined when security manager is present
sundar
parents:
16211
diff
changeset
|
1743 |
// add other special properties for exec support |
66cb726a76d5
8007521: $ENV should be undefined when security manager is present
sundar
parents:
16211
diff
changeset
|
1744 |
addOwnProperty(ScriptingFunctions.OUT_NAME, Attribute.NOT_ENUMERABLE, UNDEFINED); |
66cb726a76d5
8007521: $ENV should be undefined when security manager is present
sundar
parents:
16211
diff
changeset
|
1745 |
addOwnProperty(ScriptingFunctions.ERR_NAME, Attribute.NOT_ENUMERABLE, UNDEFINED); |
66cb726a76d5
8007521: $ENV should be undefined when security manager is present
sundar
parents:
16211
diff
changeset
|
1746 |
addOwnProperty(ScriptingFunctions.EXIT_NAME, Attribute.NOT_ENUMERABLE, UNDEFINED); |
16147 | 1747 |
} |
1748 |
||
16525
1409942e618e
8009982: Lazy execution bugfix. Added lazy sunspider unit test. Added mandreel to compile-octane test. Fixed warnings
lagergren
parents:
16522
diff
changeset
|
1749 |
private static void copyOptions(final ScriptObject options, final ScriptEnvironment scriptEnv) { |
16522 | 1750 |
AccessController.doPrivileged(new PrivilegedAction<Void>() { |
16525
1409942e618e
8009982: Lazy execution bugfix. Added lazy sunspider unit test. Added mandreel to compile-octane test. Fixed warnings
lagergren
parents:
16522
diff
changeset
|
1751 |
@Override |
16522 | 1752 |
public Void run() { |
1753 |
for (Field f : scriptEnv.getClass().getFields()) { |
|
1754 |
try { |
|
1755 |
options.set(f.getName(), f.get(scriptEnv), false); |
|
1756 |
} catch (final IllegalArgumentException | IllegalAccessException exp) { |
|
1757 |
throw new RuntimeException(exp); |
|
1758 |
} |
|
1759 |
} |
|
1760 |
return null; |
|
1761 |
} |
|
1762 |
}); |
|
1763 |
} |
|
1764 |
||
16147 | 1765 |
private void initTypedArray() { |
1766 |
this.builtinArrayBuffer = initConstructor("ArrayBuffer"); |
|
1767 |
this.builtinInt8Array = initConstructor("Int8Array"); |
|
1768 |
this.builtinUint8Array = initConstructor("Uint8Array"); |
|
1769 |
this.builtinUint8ClampedArray = initConstructor("Uint8ClampedArray"); |
|
1770 |
this.builtinInt16Array = initConstructor("Int16Array"); |
|
1771 |
this.builtinUint16Array = initConstructor("Uint16Array"); |
|
1772 |
this.builtinInt32Array = initConstructor("Int32Array"); |
|
1773 |
this.builtinUint32Array = initConstructor("Uint32Array"); |
|
1774 |
this.builtinFloat32Array = initConstructor("Float32Array"); |
|
1775 |
this.builtinFloat64Array = initConstructor("Float64Array"); |
|
1776 |
} |
|
1777 |
||
1778 |
private void copyBuiltins() { |
|
1779 |
this.array = this.builtinArray; |
|
1780 |
this._boolean = this.builtinBoolean; |
|
1781 |
this.date = this.builtinDate; |
|
1782 |
this.error = this.builtinError; |
|
1783 |
this.evalError = this.builtinEvalError; |
|
1784 |
this.function = this.builtinFunction; |
|
1785 |
this.jsadapter = this.builtinJSAdapter; |
|
1786 |
this.json = this.builtinJSON; |
|
16532 | 1787 |
this.com = this.builtinCom; |
1788 |
this.edu = this.builtinEdu; |
|
16147 | 1789 |
this.java = this.builtinJava; |
16532 | 1790 |
this.javafx = this.builtinJavafx; |
16147 | 1791 |
this.javax = this.builtinJavax; |
16532 | 1792 |
this.org = this.builtinOrg; |
16147 | 1793 |
this.javaImporter = this.builtinJavaImporter; |
1794 |
this.javaApi = this.builtinJavaApi; |
|
1795 |
this.math = this.builtinMath; |
|
1796 |
this.number = this.builtinNumber; |
|
1797 |
this.object = this.builtinObject; |
|
1798 |
this.packages = this.builtinPackages; |
|
1799 |
this.rangeError = this.builtinRangeError; |
|
1800 |
this.referenceError = this.builtinReferenceError; |
|
1801 |
this.regexp = this.builtinRegExp; |
|
1802 |
this.string = this.builtinString; |
|
1803 |
this.syntaxError = this.builtinSyntaxError; |
|
1804 |
this.typeError = this.builtinTypeError; |
|
1805 |
this.uriError = this.builtinURIError; |
|
1806 |
this.arrayBuffer = this.builtinArrayBuffer; |
|
1807 |
this.int8Array = this.builtinInt8Array; |
|
1808 |
this.uint8Array = this.builtinUint8Array; |
|
1809 |
this.uint8ClampedArray = this.builtinUint8ClampedArray; |
|
1810 |
this.int16Array = this.builtinInt16Array; |
|
1811 |
this.uint16Array = this.builtinUint16Array; |
|
1812 |
this.int32Array = this.builtinInt32Array; |
|
1813 |
this.uint32Array = this.builtinUint32Array; |
|
1814 |
this.float32Array = this.builtinFloat32Array; |
|
1815 |
this.float64Array = this.builtinFloat64Array; |
|
1816 |
} |
|
1817 |
||
1818 |
private void initDebug() { |
|
1819 |
this.addOwnProperty("Debug", Attribute.NOT_ENUMERABLE, initConstructor("Debug")); |
|
1820 |
} |
|
1821 |
||
17524
703643aeb0d6
8013914: Removed explicit LineNumberNodes that were too brittle when code moves around, and also introduced unnecessary footprint. Introduced the Statement node and fixed dead code elimination issues that were discovered by the absense of labels for LineNumberNodes.
lagergren
parents:
17519
diff
changeset
|
1822 |
@SuppressWarnings("resource") |
16147 | 1823 |
private static Object printImpl(final boolean newLine, final Object... objects) { |
16262
75513555e603
8008731: Separate configuration environment (options, error/output writer etc.) from Context
sundar
parents:
16258
diff
changeset
|
1824 |
final PrintWriter out = Global.getEnv().getOut(); |
17972 | 1825 |
final StringBuilder sb = new StringBuilder(); |
16147 | 1826 |
|
1827 |
for (final Object object : objects) { |
|
17972 | 1828 |
if (sb.length() != 0) { |
1829 |
sb.append(' '); |
|
16147 | 1830 |
} |
1831 |
||
17972 | 1832 |
sb.append(JSType.toString(object)); |
16147 | 1833 |
} |
1834 |
||
17972 | 1835 |
// Print all at once to ensure thread friendly result. |
16147 | 1836 |
if (newLine) { |
17972 | 1837 |
out.println(sb.toString()); |
1838 |
} else { |
|
1839 |
out.print(sb.toString()); |
|
16147 | 1840 |
} |
1841 |
||
1842 |
out.flush(); |
|
1843 |
||
1844 |
return UNDEFINED; |
|
1845 |
} |
|
1846 |
||
1847 |
/** |
|
1848 |
* These classes are generated by nasgen tool and so we have to use |
|
1849 |
* reflection to load and create new instance of these classes. |
|
1850 |
*/ |
|
1851 |
private ScriptObject initConstructor(final String name) { |
|
1852 |
try { |
|
1853 |
// Assuming class name pattern for built-in JS constructors. |
|
1854 |
final StringBuilder sb = new StringBuilder("jdk.nashorn.internal.objects."); |
|
1855 |
||
1856 |
sb.append("Native"); |
|
1857 |
sb.append(name); |
|
1858 |
sb.append("$Constructor"); |
|
1859 |
||
1860 |
final Class<?> funcClass = Class.forName(sb.toString()); |
|
1861 |
final ScriptObject res = (ScriptObject)funcClass.newInstance(); |
|
1862 |
||
1863 |
if (res instanceof ScriptFunction) { |
|
1864 |
// All global constructor prototypes are not-writable, |
|
1865 |
// not-enumerable and not-configurable. |
|
1866 |
final ScriptFunction func = (ScriptFunction)res; |
|
1867 |
func.modifyOwnProperty(func.getProperty("prototype"), Attribute.NON_ENUMERABLE_CONSTANT); |
|
1868 |
} |
|
1869 |
||
1870 |
if (res.getProto() == null) { |
|
1871 |
res.setProto(getObjectPrototype()); |
|
1872 |
} |
|
1873 |
||
1874 |
return res; |
|
1875 |
||
1876 |
} catch (final ClassNotFoundException | InstantiationException | IllegalAccessException e) { |
|
1877 |
throw new RuntimeException(e); |
|
1878 |
} |
|
1879 |
} |
|
1880 |
||
18855
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
1881 |
private void copyInitialMaps(final ScriptEnvironment env) { |
18851
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1882 |
this.accessorPropertyDescriptorMap = AccessorPropertyDescriptor.getInitialMap().duplicate(); |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1883 |
this.dataPropertyDescriptorMap = DataPropertyDescriptor.getInitialMap().duplicate(); |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1884 |
this.genericPropertyDescriptorMap = GenericPropertyDescriptor.getInitialMap().duplicate(); |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1885 |
this.nativeArgumentsMap = NativeArguments.getInitialMap().duplicate(); |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1886 |
this.nativeArrayMap = NativeArray.getInitialMap().duplicate(); |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1887 |
this.nativeBooleanMap = NativeBoolean.getInitialMap().duplicate(); |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1888 |
this.nativeDateMap = NativeDate.getInitialMap().duplicate(); |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1889 |
this.nativeErrorMap = NativeError.getInitialMap().duplicate(); |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1890 |
this.nativeEvalErrorMap = NativeEvalError.getInitialMap().duplicate(); |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1891 |
this.nativeJSAdapterMap = NativeJSAdapter.getInitialMap().duplicate(); |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1892 |
this.nativeNumberMap = NativeNumber.getInitialMap().duplicate(); |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1893 |
this.nativeRangeErrorMap = NativeRangeError.getInitialMap().duplicate(); |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1894 |
this.nativeReferenceErrorMap = NativeReferenceError.getInitialMap().duplicate(); |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1895 |
this.nativeRegExpMap = NativeRegExp.getInitialMap().duplicate(); |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1896 |
this.nativeRegExpExecResultMap = NativeRegExpExecResult.getInitialMap().duplicate(); |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1897 |
this.nativeStrictArgumentsMap = NativeStrictArguments.getInitialMap().duplicate(); |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1898 |
this.nativeStringMap = NativeString.getInitialMap().duplicate(); |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1899 |
this.nativeSyntaxErrorMap = NativeSyntaxError.getInitialMap().duplicate(); |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1900 |
this.nativeTypeErrorMap = NativeTypeError.getInitialMap().duplicate(); |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1901 |
this.nativeURIErrorMap = NativeURIError.getInitialMap().duplicate(); |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1902 |
this.prototypeObjectMap = PrototypeObject.getInitialMap().duplicate(); |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1903 |
this.objectMap = JO.getInitialMap().duplicate(); |
18855
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
1904 |
this.functionMap = ScriptFunctionImpl.getInitialMap().duplicate(); |
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
1905 |
this.anonymousFunctionMap = ScriptFunctionImpl.getInitialAnonymousMap().duplicate(); |
18851
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1906 |
this.strictFunctionMap = ScriptFunctionImpl.getInitialStrictMap().duplicate(); |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1907 |
this.boundFunctionMap = ScriptFunctionImpl.getInitialBoundMap().duplicate(); |
18855
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
1908 |
|
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
1909 |
// java |
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
1910 |
if (! env._no_java) { |
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
1911 |
this.nativeJavaImporterMap = NativeJavaImporter.getInitialMap().duplicate(); |
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
1912 |
} |
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
1913 |
|
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
1914 |
// typed arrays |
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
1915 |
if (! env._no_typed_arrays) { |
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
1916 |
this.arrayBufferViewMap = ArrayBufferView.getInitialMap().duplicate(); |
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
1917 |
this.nativeArrayBufferMap = NativeArrayBuffer.getInitialMap().duplicate(); |
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
1918 |
} |
18851
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1919 |
} |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
1920 |
|
16147 | 1921 |
// Function and Object constructors are inter-dependent. Also, |
1922 |
// Function.prototype |
|
1923 |
// functions are not properly initialized. We fix the references here. |
|
1924 |
// NOTE: be careful if you want to re-order the operations here. You may |
|
1925 |
// have |
|
1926 |
// to play with object references carefully!! |
|
1927 |
private void initFunctionAndObject() { |
|
1928 |
// First-n-foremost is Function |
|
1929 |
this.builtinFunction = (ScriptFunction)initConstructor("Function"); |
|
1930 |
||
1931 |
// create global anonymous function |
|
18855
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
1932 |
final ScriptFunction anon = ScriptFunctionImpl.newAnonymousFunction(this); |
16147 | 1933 |
// need to copy over members of Function.prototype to anon function |
1934 |
anon.addBoundProperties(getFunctionPrototype()); |
|
1935 |
||
1936 |
// Function.prototype === Object.getPrototypeOf(Function) === |
|
1937 |
// <anon-function> |
|
1938 |
builtinFunction.setProto(anon); |
|
1939 |
builtinFunction.setPrototype(anon); |
|
18328
ebd24057f163
8015355: Array.prototype functions don't honour non-writable length and / or index properties
sundar
parents:
18326
diff
changeset
|
1940 |
anon.set("constructor", builtinFunction, false); |
16147 | 1941 |
anon.deleteOwnProperty(anon.getMap().findProperty("prototype")); |
1942 |
||
1943 |
// now initialize Object |
|
1944 |
this.builtinObject = (ScriptFunction)initConstructor("Object"); |
|
1945 |
final ScriptObject ObjectPrototype = getObjectPrototype(); |
|
1946 |
// Object.getPrototypeOf(Function.prototype) === Object.prototype |
|
1947 |
anon.setProto(ObjectPrototype); |
|
1948 |
||
1949 |
// Function valued properties of Function.prototype were not properly |
|
1950 |
// initialized. Because, these were created before global.function and |
|
1951 |
// global.object were not initialized. |
|
1952 |
jdk.nashorn.internal.runtime.Property[] properties = getFunctionPrototype().getMap().getProperties(); |
|
1953 |
for (final jdk.nashorn.internal.runtime.Property property : properties) { |
|
1954 |
final Object key = property.getKey(); |
|
1955 |
final Object value = builtinFunction.get(key); |
|
1956 |
||
1957 |
if (value instanceof ScriptFunction && value != anon) { |
|
1958 |
final ScriptFunction func = (ScriptFunction)value; |
|
1959 |
func.setProto(getFunctionPrototype()); |
|
1960 |
final ScriptObject prototype = ScriptFunction.getPrototype(func); |
|
1961 |
if (prototype != null) { |
|
1962 |
prototype.setProto(ObjectPrototype); |
|
1963 |
} |
|
1964 |
} |
|
1965 |
} |
|
1966 |
||
1967 |
// For function valued properties of Object and Object.prototype, make |
|
1968 |
// sure prototype's proto chain ends with Object.prototype |
|
1969 |
for (final jdk.nashorn.internal.runtime.Property property : builtinObject.getMap().getProperties()) { |
|
1970 |
final Object key = property.getKey(); |
|
1971 |
final Object value = builtinObject.get(key); |
|
1972 |
||
1973 |
if (value instanceof ScriptFunction) { |
|
1974 |
final ScriptFunction func = (ScriptFunction)value; |
|
1975 |
final ScriptObject prototype = ScriptFunction.getPrototype(func); |
|
1976 |
if (prototype != null) { |
|
1977 |
prototype.setProto(ObjectPrototype); |
|
1978 |
} |
|
1979 |
} |
|
1980 |
} |
|
1981 |
||
1982 |
properties = getObjectPrototype().getMap().getProperties(); |
|
1983 |
for (final jdk.nashorn.internal.runtime.Property property : properties) { |
|
1984 |
final Object key = property.getKey(); |
|
1985 |
final Object value = ObjectPrototype.get(key); |
|
1986 |
||
1987 |
if (key.equals("constructor")) { |
|
1988 |
continue; |
|
1989 |
} |
|
1990 |
||
1991 |
if (value instanceof ScriptFunction) { |
|
1992 |
final ScriptFunction func = (ScriptFunction)value; |
|
1993 |
final ScriptObject prototype = ScriptFunction.getPrototype(func); |
|
1994 |
if (prototype != null) { |
|
1995 |
prototype.setProto(ObjectPrototype); |
|
1996 |
} |
|
1997 |
} |
|
1998 |
} |
|
1999 |
} |
|
2000 |
||
2001 |
private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) { |
|
18851
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18842
diff
changeset
|
2002 |
return MH.findStatic(MethodHandles.lookup(), Global.class, name, MH.type(rtype, types)); |
16147 | 2003 |
} |
16223
dff592a332a4
8007718: Make static RegExp properties fully compatible to other engines
hannesw
parents:
16219
diff
changeset
|
2004 |
|
16258 | 2005 |
RegExpResult getLastRegExpResult() { |
2006 |
return lastRegExpResult; |
|
16223
dff592a332a4
8007718: Make static RegExp properties fully compatible to other engines
hannesw
parents:
16219
diff
changeset
|
2007 |
} |
dff592a332a4
8007718: Make static RegExp properties fully compatible to other engines
hannesw
parents:
16219
diff
changeset
|
2008 |
|
16258 | 2009 |
void setLastRegExpResult(final RegExpResult regExpResult) { |
2010 |
this.lastRegExpResult = regExpResult; |
|
16223
dff592a332a4
8007718: Make static RegExp properties fully compatible to other engines
hannesw
parents:
16219
diff
changeset
|
2011 |
} |
dff592a332a4
8007718: Make static RegExp properties fully compatible to other engines
hannesw
parents:
16219
diff
changeset
|
2012 |
|
16147 | 2013 |
} |