46 import jdk.nashorn.internal.runtime.GlobalObject; |
46 import jdk.nashorn.internal.runtime.GlobalObject; |
47 import jdk.nashorn.internal.runtime.JSType; |
47 import jdk.nashorn.internal.runtime.JSType; |
48 import jdk.nashorn.internal.runtime.NativeJavaPackage; |
48 import jdk.nashorn.internal.runtime.NativeJavaPackage; |
49 import jdk.nashorn.internal.runtime.OptionsObject; |
49 import jdk.nashorn.internal.runtime.OptionsObject; |
50 import jdk.nashorn.internal.runtime.PropertyDescriptor; |
50 import jdk.nashorn.internal.runtime.PropertyDescriptor; |
|
51 import jdk.nashorn.internal.runtime.RegExpMatch; |
51 import jdk.nashorn.internal.runtime.Scope; |
52 import jdk.nashorn.internal.runtime.Scope; |
52 import jdk.nashorn.internal.runtime.ScriptFunction; |
53 import jdk.nashorn.internal.runtime.ScriptFunction; |
53 import jdk.nashorn.internal.runtime.ScriptObject; |
54 import jdk.nashorn.internal.runtime.ScriptObject; |
54 import jdk.nashorn.internal.runtime.ScriptRuntime; |
55 import jdk.nashorn.internal.runtime.ScriptRuntime; |
55 import jdk.nashorn.internal.runtime.ScriptingFunctions; |
56 import jdk.nashorn.internal.runtime.ScriptingFunctions; |
335 private int splitState = -1; |
336 private int splitState = -1; |
336 |
337 |
337 // class cache |
338 // class cache |
338 private ClassCache classCache; |
339 private ClassCache classCache; |
339 |
340 |
|
341 // Used to store the last RegExp result to support deprecated RegExp constructor properties |
|
342 private RegExpMatch lastRegExpMatch; |
|
343 |
340 private static final MethodHandle EVAL = findOwnMH("eval", Object.class, Object.class, Object.class); |
344 private static final MethodHandle EVAL = findOwnMH("eval", Object.class, Object.class, Object.class); |
341 private static final MethodHandle PRINT = findOwnMH("print", Object.class, Object.class, Object[].class); |
345 private static final MethodHandle PRINT = findOwnMH("print", Object.class, Object.class, Object[].class); |
342 private static final MethodHandle PRINTLN = findOwnMH("println", Object.class, Object.class, Object[].class); |
346 private static final MethodHandle PRINTLN = findOwnMH("println", Object.class, Object.class, Object[].class); |
343 private static final MethodHandle LOAD = findOwnMH("load", Object.class, Object.class, Object.class); |
347 private static final MethodHandle LOAD = findOwnMH("load", Object.class, Object.class, Object.class); |
344 private static final MethodHandle EXIT = findOwnMH("exit", Object.class, Object.class, Object.class); |
348 private static final MethodHandle EXIT = findOwnMH("exit", Object.class, Object.class, Object.class); |
1372 |
1376 |
1373 // RegExp.prototype should behave like a RegExp object. So copy the |
1377 // RegExp.prototype should behave like a RegExp object. So copy the |
1374 // properties. |
1378 // properties. |
1375 final ScriptObject regExpProto = getRegExpPrototype(); |
1379 final ScriptObject regExpProto = getRegExpPrototype(); |
1376 regExpProto.addBoundProperties(DEFAULT_REGEXP); |
1380 regExpProto.addBoundProperties(DEFAULT_REGEXP); |
1377 |
|
1378 // add hook to support "deprecated" "static" properties of RegExp constructor object |
|
1379 final ScriptFunction handler = ScriptFunctionImpl.makeFunction(NO_SUCH_METHOD_NAME, NativeRegExp.REGEXP_STATICS_HANDLER); |
|
1380 builtinRegExp.addOwnProperty(NO_SUCH_PROPERTY_NAME, Attribute.NOT_ENUMERABLE, handler); |
|
1381 |
|
1382 // add initial undefined "last successful match" property RegExp |
|
1383 builtinRegExp.addOwnProperty(NativeRegExp.LAST_REGEXP_MATCH, Attribute.NOT_ENUMERABLE, UNDEFINED); |
|
1384 |
1381 |
1385 // Error stuff |
1382 // Error stuff |
1386 initErrorObjects(); |
1383 initErrorObjects(); |
1387 |
1384 |
1388 // java access |
1385 // java access |
1701 |
1698 |
1702 |
1699 |
1703 private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) { |
1700 private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) { |
1704 return MH.findStatic(MethodHandles.publicLookup(), Global.class, name, MH.type(rtype, types)); |
1701 return MH.findStatic(MethodHandles.publicLookup(), Global.class, name, MH.type(rtype, types)); |
1705 } |
1702 } |
|
1703 |
|
1704 RegExpMatch getLastRegExpMatch() { |
|
1705 return lastRegExpMatch; |
|
1706 } |
|
1707 |
|
1708 void setLastRegExpMatch(RegExpMatch regExpMatch) { |
|
1709 this.lastRegExpMatch = regExpMatch; |
|
1710 } |
|
1711 |
1706 } |
1712 } |