微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

jdk.nashorn.internal.runtime.ScriptFunction的实例源码

项目:Openjsharp    文件NashornScriptEngine.java   
private static Object evalImpl(final ScriptFunction script,final ScriptContext ctxt,final Global ctxtGlobal) throws ScriptException {
    if (script == null) {
        return null;
    }
    final Global oldGlobal = Context.getGlobal();
    final boolean globalChanged = (oldGlobal != ctxtGlobal);
    try {
        if (globalChanged) {
            Context.setGlobal(ctxtGlobal);
        }

        ctxtGlobal.setScriptContext(ctxt);
        return ScriptObjectMirror.translateUndefined(ScriptObjectMirror.wrap(ScriptRuntime.apply(script,ctxtGlobal),ctxtGlobal));
    } catch (final Exception e) {
        throwAsScriptException(e,ctxtGlobal);
        throw new AssertionError("should not reach here");
    } finally {
        if (globalChanged) {
            Context.setGlobal(oldGlobal);
        }
    }
}
项目:openjdk-jdk10    文件NativeDebug.java   
/**
 * Dump all Nashorn debug mode counters. Calling this may be better if
 * you want to print all counters. This way you can avoid too many callsites
 * due to counter access itself!!
 * @param self self reference
 * @return undefined
 */
@Function(attributes = Attribute.NOT_ENUMERABLE,where = Where.CONSTRUCTOR)
public static Object dumpCounters(final Object self) {
    final PrintWriter out = Context.getCurrentErr();

    out.println("ScriptObject count " + ScriptObject.getCount());
    out.println("Scope count " + Scope.getScopeCount());
    out.println("ScriptObject listeners added " + PropertyListeners.getListenersAdded());
    out.println("ScriptObject listeners removed " + PropertyListeners.getListenersRemoved());
    out.println("ScriptFunction constructor calls " + ScriptFunction.getConstructorCount());
    out.println("ScriptFunction invokes " + ScriptFunction.getInvokes());
    out.println("ScriptFunction allocations " + ScriptFunction.getAllocations());
    out.println("PropertyMap count " + PropertyMap.getCount());
    out.println("PropertyMap cloned " + PropertyMap.getClonedCount());
    out.println("PropertyMap history hit " + PropertyMap.getHistoryHit());
    out.println("PropertyMap proto invalidations " + PropertyMap.getProtoInvalidations());
    out.println("PropertyMap proto history hit " + PropertyMap.getProtoHistoryHit());
    out.println("PropertyMap setProtoNewMapCount " + PropertyMap.getSetProtoNewMapCount());
    out.println("Callsite count " + LinkerCallSite.getCount());
    out.println("Callsite misses " + LinkerCallSite.getMissCount());
    out.println("Callsite misses by site at " + LinkerCallSite.getMissSamplingPercentage() + "%");

    LinkerCallSite.getMissCounts(out);

    return UNDEFINED;
}
项目:Openjsharp    文件NashornScriptEngine.java   
private ScriptFunction compileImpl(final Source source,final Global newGlobal) throws ScriptException {
    final Global oldGlobal = Context.getGlobal();
    final boolean globalChanged = (oldGlobal != newGlobal);
    try {
        if (globalChanged) {
            Context.setGlobal(newGlobal);
        }

        return nashornContext.compileScript(source,newGlobal);
    } catch (final Exception e) {
        throwAsScriptException(e,newGlobal);
        throw new AssertionError("should not reach here");
    } finally {
        if (globalChanged) {
            Context.setGlobal(oldGlobal);
        }
    }
}
项目:Openjsharp    文件NashornScriptEngine.java   
private static boolean isInterfaceImplemented(final Class<?> iface,final ScriptObject sobj) {
    for (final Method method : iface.getmethods()) {
        // ignore methods of java.lang.Object class
        if (method.getDeclaringClass() == Object.class) {
            continue;
        }

        // skip check for default methods - non-abstract,interface methods
        if (! Modifier.isAbstract(method.getModifiers())) {
            continue;
        }

        final Object obj = sobj.get(method.getName());
        if (! (obj instanceof ScriptFunction)) {
            return false;
        }
    }
    return true;
}
项目:Openjsharp    文件NativeString.java   
/**
 * ECMA 15.5.4.11 String.prototype.replace (searchValue,replaceValue)
 * @param self        self reference
 * @param string      item to replace
 * @param replacement item to replace it with
 * @return string after replacement
 * @throws Throwable if replacement fails
 */
@Function(attributes = Attribute.NOT_ENUMERABLE)
public static String replace(final Object self,final Object string,final Object replacement) throws Throwable {

    final String str = checkObjectToString(self);

    final NativeRegExp nativeRegExp;
    if (string instanceof NativeRegExp) {
        nativeRegExp = (NativeRegExp) string;
    } else {
        nativeRegExp = NativeRegExp.flatRegExp(JSType.toString(string));
    }

    if (replacement instanceof ScriptFunction) {
        return nativeRegExp.replace(str,"",(ScriptFunction)replacement);
    }

    return nativeRegExp.replace(str,JSType.toString(replacement),null);
}
项目:Openjsharp    文件NativeJSAdapter.java   
@Override
public Iterator<String> propertyIterator() {
    // Try __getIds__ first,if not found then try __getKeys__
    // In jdk6,we had added "__getIds__" so this is just for compatibility.
    Object func = adaptee.get(__getIds__);
    if (!(func instanceof ScriptFunction)) {
        func = adaptee.get(__getKeys__);
    }

    Object obj;
    if (func instanceof ScriptFunction) {
        obj = ScriptRuntime.apply((ScriptFunction)func,adaptee);
    } else {
        obj = new NativeArray(0);
    }

    final List<String> array = new ArrayList<>();
    for (final Iterator<Object> iter = ArrayLikeIterator.arrayLikeIterator(obj); iter.hasNext(); ) {
        array.add((String)iter.next());
    }

    return array.iterator();
}
项目:openjdk-jdk10    文件Global.java   
private List<jdk.nashorn.internal.runtime.Property> extractBuiltinProperties(final String name,final ScriptObject func) {
    final List<jdk.nashorn.internal.runtime.Property> list = new ArrayList<>();

    list.addAll(Arrays.asList(func.getMap().getProperties()));

    if (func instanceof ScriptFunction) {
        final ScriptObject proto = ScriptFunction.getPrototype((ScriptFunction)func);
        if (proto != null) {
            list.addAll(Arrays.asList(proto.getMap().getProperties()));
        }
    }

    final jdk.nashorn.internal.runtime.Property prop = getProperty(name);
    if (prop != null) {
        list.add(prop);
    }

    return list;
}
项目:openjdk-jdk10    文件NashornScriptEngine.java   
private ScriptFunction compileImpl(final Source source,newGlobal);
        throw new AssertionError("should not reach here");
    } finally {
        if (globalChanged) {
            Context.setGlobal(oldGlobal);
        }
    }
}
项目:openjdk-jdk10    文件ContextTest.java   
@Test
public void compileErrortest() {
    final Options options = new Options("");
    final ErrorManager errors = new ErrorManager();
    final Context cx = new Context(options,errors,Thread.currentThread().getContextClassLoader());
    final Global oldGlobal = Context.getGlobal();
    Context.setGlobal(cx.createGlobal());
    try {
        final ScriptFunction script = cx.compileScript(sourceFor("<evalCompileErrorTest>","*/"),Context.getGlobal());
        if (script != null) {
            fail("Invalid script compiled without errors");
        }
        if (errors.getNumberOfErrors() != 1) {
            fail("Wrong number of errors: " + errors.getNumberOfErrors());
        }
    } finally {
        Context.setGlobal(oldGlobal);
    }
}
项目:Openjsharp    文件Global.java   
private List<jdk.nashorn.internal.runtime.Property> extractBuiltinProperties(final String name,final ScriptObject func) {
    final List<jdk.nashorn.internal.runtime.Property> list = new ArrayList<>();

    list.addAll(Arrays.asList(func.getMap().getProperties()));

    if (func instanceof ScriptFunction) {
        final ScriptObject proto = ScriptFunction.getPrototype((ScriptFunction)func);
        if (proto != null) {
            list.addAll(Arrays.asList(proto.getMap().getProperties()));
        }
    }

    final jdk.nashorn.internal.runtime.Property prop = getProperty(name);
    if (prop != null) {
        list.add(prop);
    }

    return list;
}
项目:Openjsharp    文件TypeMap.java   
MethodType getCallSiteType(final FunctionNode functionNode) {
    final Type[] types = paramTypeMap.get(functionNode.getId());
    if (types == null) {
        return null;
    }

    MethodType mt = MethodType.methodType(returnTypeMap.get(functionNode.getId()).getTypeClass());
    if (needsCallee) {
        mt = mt.appendParameterTypes(ScriptFunction.class);
    }

    mt = mt.appendParameterTypes(Object.class); //this

    for (final Type type : types) {
        if (type == null) {
            return null; // not all parameter information is supplied
        }
        mt = mt.appendParameterTypes(type.getTypeClass());
    }

    return mt;
}
项目:openjdk-jdk10    文件NativeFunction.java   
/**
 * ECMA 15.3.2.1 new Function (p1,p2,...,pn,body)
 *
 * Constructor
 *
 * @param newObj is the new operator used for constructing this function
 * @param self   self reference
 * @param args   arguments
 * @return new NativeFunction
 */
@Constructor(arity = 1)
public static ScriptFunction function(final boolean newObj,final Object self,final Object... args) {
    final StringBuilder sb = new StringBuilder();

    sb.append("(function (");
    final String funcBody;
    if (args.length > 0) {
        final StringBuilder paramListBuf = new StringBuilder();
        for (int i = 0; i < args.length - 1; i++) {
            paramListBuf.append(JSType.toString(args[i]));
            if (i < args.length - 2) {
                paramListBuf.append(",");
            }
        }

        // Now convert function body to a string
        funcBody = JSType.toString(args[args.length - 1]);

        final String paramList = paramListBuf.toString();
        if (!paramList.isEmpty()) {
            checkFunctionParameters(paramList);
            sb.append(paramList);
        }
    } else {
        funcBody = null;
    }

    sb.append(") {\n");
    if (args.length > 0) {
        checkFunctionBody(funcBody);
        sb.append(funcBody);
        sb.append('\n');
    }
    sb.append("})");

    final Global global = Global.instance();
    final Context context = global.getContext();
    return (ScriptFunction)context.eval(global,sb.toString(),global,"<function>");
}
项目:Openjsharp    文件NativeFunction.java   
/**
 * ECMA 15.3.4.2 Function.prototype.toString ( )
 *
 * @param self self reference
 * @return string representation of Function
 */
@Function(attributes = Attribute.NOT_ENUMERABLE)
public static String toString(final Object self) {
    if (!(self instanceof ScriptFunction)) {
        throw typeError("not.a.function",ScriptRuntime.safetoString(self));
    }
    return ((ScriptFunction)self).toSource();
}
项目:Openjsharp    文件NativeFunction.java   
/**
 * ECMA 15.3.4.3 Function.prototype.apply (thisArg,argArray)
 *
 * @param self   self reference
 * @param thiz   {@code this} arg for apply
 * @param array  array of argument for apply
 * @return result of apply
 */
@Function(attributes = Attribute.NOT_ENUMERABLE)
public static Object apply(final Object self,final Object thiz,final Object array) {
    checkCallable(self);

    final Object[] args = toApplyArgs(array);

    if (self instanceof ScriptFunction) {
        return ScriptRuntime.apply((ScriptFunction)self,thiz,args);
    } else if (self instanceof JSObject) {
        return ((JSObject)self).call(thiz,args);
    }
    throw new AssertionError("Should not reach here");
}
项目:openjdk-jdk10    文件Global.java   
/**
 * Adds jjs shell interactive mode builtin functions to global scope.
 */
public void addShellBuiltins() {
    Object value = ScriptFunction.createBuiltin("input",ShellFunctions.INPUT);
    addOwnProperty("input",Attribute.NOT_ENUMERABLE,value);

    value = ScriptFunction.createBuiltin("evalinput",ShellFunctions.EVALINPUT);
    addOwnProperty("evalinput",value);
}
项目:Openjsharp    文件NativeFunction.java   
/**
 * ECMA 15.3.2.1 new Function (p1,");
            }
        }

        // Now convert function body to a string
        funcBody = JSType.toString(args[args.length - 1]);

        final String paramList = paramListBuf.toString();
        if (!paramList.isEmpty()) {
            checkFunctionParameters(paramList);
            sb.append(paramList);
        }
    } else {
        funcBody = null;
    }

    sb.append(") {\n");
    if (args.length > 0) {
        checkFunctionBody(funcBody);
        sb.append(funcBody);
        sb.append('\n');
    }
    sb.append("})");

    final Global global = Global.instance();

    return (ScriptFunction)Global.directEval(global,"<function>",global.isstrictContext());
}
项目:Openjsharp    文件NativeError.java   
/**
 * Nashorn extension: Error.captureStackTrace. Capture stack trace at the point of call into the Error object provided.
 *
 * @param self self reference
 * @param errorObj the error object
 * @return undefined
 */
@Function(attributes = Attribute.NOT_ENUMERABLE,where = Where.CONSTRUCTOR)
public static Object captureStackTrace(final Object self,final Object errorObj) {
    final ScriptObject sobj = Global.checkObject(errorObj);
    initException(sobj);
    sobj.delete(STACK,false);
    if (! sobj.has("stack")) {
        final ScriptFunction getStack = ScriptFunctionImpl.makeFunction("getStack",GET_STACK);
        final ScriptFunction setStack = ScriptFunctionImpl.makeFunction("setStack",SET_STACK);
        sobj.addOwnProperty("stack",getStack,setStack);
    }
    return UNDEFINED;
}
项目:openjdk-jdk10    文件Bootstrap.java   
/**
 * Returns if the given object is a "callable"
 * @param obj object to be checked for callability
 * @return true if the obj is callable
 */
public static boolean isCallable(final Object obj) {
    if (obj == ScriptRuntime.UNDEFINED || obj == null) {
        return false;
    }

    return obj instanceof ScriptFunction ||
        isJSObjectFunction(obj) ||
        BeansLinker.isDynamicmethod(obj) ||
        obj instanceof BoundCallable ||
        isFunctionalInterfaceObject(obj) ||
        obj instanceof Staticclass;
}
项目:openjdk-jdk10    文件NativeJava.java   
/**
 * Returns synchronized wrapper version of the given ECMAScript function.
 * @param self not used
 * @param func the ECMAScript function whose synchronized version is returned.
 * @param obj the object (i.e,lock) on which the function synchronizes.
 * @return synchronized wrapper version of the given ECMAScript function.
 */
@Function(name="synchronized",attributes = Attribute.NOT_ENUMERABLE,where = Where.CONSTRUCTOR)
public static Object synchronizedFunc(final Object self,final Object func,final Object obj) {
    if (func instanceof ScriptFunction) {
        return ((ScriptFunction)func).createSynchronized(obj);
    }

    throw typeError("not.a.function",ScriptRuntime.safetoString(func));
}
项目:openjdk-jdk10    文件Bootstrap.java   
/**
 * Returns true if the given object is a strict callable
 * @param callable the callable object to be checked for strictness
 * @return true if the obj is a strict callable,false if it is a non-strict callable.
 * @throws ECMAException with {@code TypeError} if the object is not a callable.
 */
public static boolean isstrictCallable(final Object callable) {
    if (callable instanceof ScriptFunction) {
        return ((ScriptFunction)callable).isstrict();
    } else if (isJSObjectFunction(callable)) {
        return ((JSObject)callable).isstrictFunction();
    } else if (callable instanceof BoundCallable) {
        return isstrictCallable(((BoundCallable)callable).getCallable());
    } else if (BeansLinker.isDynamicmethod(callable) ||
            callable instanceof Staticclass ||
            isFunctionalInterfaceObject(callable)) {
        return false;
    }
    throw notFunction(callable);
}
项目:Openjsharp    文件Global.java   
private static boolean isBuiltinFunctionProperty(final String name) {
    final Global instance = Global.instance();
    final ScriptFunction builtinFunction = instance.getBuiltinFunction();
    if (builtinFunction == null) {
        return false; //conservative for compile-only mode
    }
    final boolean isBuiltinFunction = instance.function == builtinFunction;
    return isBuiltinFunction && ScriptFunction.getPrototype(builtinFunction).getProperty(name).isBuiltin();
}
项目:openjdk-jdk10    文件ScriptObjectMirror.java   
@Override
public Object call(final Object thiz,final Object... args) {
    final Global oldGlobal = Context.getGlobal();
    final boolean globalChanged = (oldGlobal != global);

    try {
        if (globalChanged) {
            Context.setGlobal(global);
        }

        if (sobj instanceof ScriptFunction) {
            final Object[] modArgs = globalChanged? wrapArrayLikeMe(args,oldGlobal) : args;
            final Object self = globalChanged? wrapLikeMe(thiz,oldGlobal) : thiz;
            return wrapLikeMe(ScriptRuntime.apply((ScriptFunction)sobj,unwrap(self,global),unwrapArray(modArgs,global)));
        }

        throw new RuntimeException("not a function: " + toString());
    } catch (final NashornException ne) {
        throw ne.initEcmaError(global);
    } catch (final RuntimeException | Error e) {
        throw e;
    } catch (final Throwable t) {
        throw new RuntimeException(t);
    } finally {
        if (globalChanged) {
            Context.setGlobal(oldGlobal);
        }
    }
}
项目:openjdk-jdk10    文件Global.java   
private static boolean isBuiltinFunctionProperty(final String name) {
    final Global instance = Global.instance();
    final ScriptFunction builtinFunction = instance.getBuiltinFunction();
    if (builtinFunction == null) {
        return false; //conservative for compile-only mode
    }
    final boolean isBuiltinFunction = instance.function == builtinFunction;
    return isBuiltinFunction && ScriptFunction.getPrototype(builtinFunction).getProperty(name).isBuiltin();
}
项目:openjdk-jdk10    文件NashornScriptEngine.java   
private Object evalImpl(final ScriptFunction script,final Global ctxtGlobal) throws ScriptException {
    if (script == null) {
        return null;
    }
    final Global oldGlobal = Context.getGlobal();
    final boolean globalChanged = (oldGlobal != ctxtGlobal);
    try {
        if (globalChanged) {
            Context.setGlobal(ctxtGlobal);
        }

        final ScriptContext oldCtxt = ctxtGlobal.getScriptContext();
        ctxtGlobal.setScriptContext(ctxt);
        try {
            return ScriptObjectMirror.translateUndefined(ScriptObjectMirror.wrap(ScriptRuntime.apply(script,ctxtGlobal));
        } finally {
            ctxtGlobal.setScriptContext(oldCtxt);
        }
    } catch (final Exception e) {
        throwAsScriptException(e,ctxtGlobal);
        throw new AssertionError("should not reach here");
    } finally {
        if (globalChanged) {
            Context.setGlobal(oldGlobal);
        }
    }
}
项目:Openjsharp    文件Global.java   
private void initTypedArray() {
    this.builtinArrayBuffer       = initConstructorAndSwitchPoint("ArrayBuffer",ScriptFunction.class);
    this.builtinDataView          = initConstructorAndSwitchPoint("DataView",ScriptFunction.class);
    this.builtinint8Array         = initConstructorAndSwitchPoint("Int8Array",ScriptFunction.class);
    this.builtinUint8Array        = initConstructorAndSwitchPoint("Uint8Array",ScriptFunction.class);
    this.builtinUint8ClampedArray = initConstructorAndSwitchPoint("Uint8ClampedArray",ScriptFunction.class);
    this.builtinint16Array        = initConstructorAndSwitchPoint("Int16Array",ScriptFunction.class);
    this.builtinUint16Array       = initConstructorAndSwitchPoint("Uint16Array",ScriptFunction.class);
    this.builtinint32Array        = initConstructorAndSwitchPoint("Int32Array",ScriptFunction.class);
    this.builtinUint32Array       = initConstructorAndSwitchPoint("Uint32Array",ScriptFunction.class);
    this.builtinFloat32Array      = initConstructorAndSwitchPoint("Float32Array",ScriptFunction.class);
    this.builtinFloat64Array      = initConstructorAndSwitchPoint("Float64Array",ScriptFunction.class);

}
项目:Openjsharp    文件NativeJava.java   
/**
 * Returns synchronized wrapper version of the given ECMAScript function.
 * @param self not used
 * @param func the ECMAScript function whose synchronized version is returned.
 * @param obj the object (i.e,final Object obj) {
    if (func instanceof ScriptFunction) {
        return ((ScriptFunction)func).makeSynchronizedFunction(obj);
    }

    throw typeError("not.a.function",ScriptRuntime.safetoString(func));
}
项目:openjdk-jdk10    文件NativeJSAdapter.java   
@SuppressWarnings("unused")
private static boolean isJSAdapter(final Object self,final Object adaptee,final MethodHandle getter,final Object where,final ScriptFunction func) {
    final boolean res = self instanceof NativeJSAdapter && ((NativeJSAdapter)self).getAdaptee() == adaptee;
    if (res && getter != null) {
        try {
            return getter.invokeExact(where) == func;
        } catch (final RuntimeException | Error e) {
            throw e;
        } catch (final Throwable t) {
            throw new RuntimeException(t);
        }
    }

    return res;
}
项目:Openjsharp    文件ScriptFunctionImpl.java   
private static ScriptFunction makeFunction(final String name,final MethodHandle methodHandle,final Specialization[] specs,final int flags) {
    final ScriptFunctionImpl func = new ScriptFunctionImpl(name,methodHandle,null,specs,flags);
    func.setPrototype(UNDEFINED);
    // Non-constructor built-in functions do not have "prototype" property
    func.deleteOwnProperty(func.getMap().findProperty("prototype"));

    return func;
}
项目:openjdk-jdk10    文件NativeFunction.java   
/**
 * ECMA 15.3.4.3 Function.prototype.apply (thisArg,final Object array) {
    checkCallable(self);
    final Object[] args = toApplyArgs(array);

    if (self instanceof ScriptFunction) {
        return ScriptRuntime.apply((ScriptFunction)self,args);
    }
    throw new AssertionError("Should not reach here");
}
项目:Openjsharp    文件Bootstrap.java   
/**
 * Returns if the given object is a "callable"
 * @param obj object to be checked for callability
 * @return true if the obj is callable
 */
public static boolean isCallable(final Object obj) {
    if (obj == ScriptRuntime.UNDEFINED || obj == null) {
        return false;
    }

    return obj instanceof ScriptFunction ||
        isJSObjectFunction(obj) ||
        BeansLinker.isDynamicmethod(obj) ||
        obj instanceof BoundCallable ||
        isFunctionalInterfaceObject(obj) ||
        obj instanceof Staticclass;
}
项目:openjdk-jdk10    文件Global.java   
private <T extends ScriptObject> T initConstructor(final String name,final Class<T> clazz) {
    try {
        // Assuming class name pattern for built-in JS constructors.
        final StringBuilder sb = new StringBuilder(PACKAGE_PREFIX);

        sb.append("Native");
        sb.append(name);
        sb.append("$Constructor");

        final Class<?> funcclass = Class.forName(sb.toString());
        final T res = clazz.cast(funcclass.getDeclaredConstructor().newInstance());

        if (res instanceof ScriptFunction) {
            // All global constructor prototypes are not-writable,// not-enumerable and not-configurable.
            final ScriptFunction func = (ScriptFunction)res;
            func.modifyOwnProperty(func.getProperty("prototype"),Attribute.NON_ENUMERABLE_CONSTANT);
        }

        if (res.getProto() == null) {
            res.setinitialProto(getobjectPrototype());
        }

        res.setIsBuiltin();

        return res;
    } catch (final Exception e) {
        if (e instanceof RuntimeException) {
            throw (RuntimeException)e;
        } else {
            throw new RuntimeException(e);
        }
    }
}
项目:openjdk-jdk10    文件CompilerTest.java   
private void compileJSFile(final File file,final TestFilter filter) {
    if (VERBOSE) {
        log("Begin compiling " + file.getAbsolutePath());
    }

    final Global oldGlobal = Context.getGlobal();
    final boolean globalChanged = (oldGlobal != global);

    try {
        final char[] buffer = readFully(file);
        boolean excluded = false;

        if (filter != null) {
            final String content = new String(buffer);
            excluded = filter.exclude(file,content);
        }

        if (excluded) {
            if (VERBOSE) {
                log("Skipping " + file.getAbsolutePath());
            }
            skipped++;
            return;
        }

        if (globalChanged) {
            Context.setGlobal(global);
        }
        final Source source = sourceFor(file.getAbsolutePath(),buffer);
        final ScriptFunction script = context.compileScript(source,global);
        if (script == null || context.getErrorManager().getNumberOfErrors() > 0) {
            log("Compile Failed: " + file.getAbsolutePath());
            Failed++;
        } else {
            passed++;
        }
    } catch (final Throwable t) {
        log("Compile Failed: " + file.getAbsolutePath() + " : " + t);
        if (VERBOSE) {
            t.printstacktrace(System.out);
        }
        Failed++;
    } finally {
        if (globalChanged) {
            Context.setGlobal(oldGlobal);
        }
    }

    if (VERBOSE) {
        log("Done compiling " + file.getAbsolutePath());
    }
}
项目:openjdk-jdk10    文件Global.java   
private synchronized ScriptFunction getBuiltinint32Array() {
    if (this.builtinint32Array == null) {
        this.builtinint32Array = initConstructorAndSwitchPoint("Int32Array",ScriptFunction.class);
    }
    return this.builtinint32Array;
}
项目:openjdk-jdk10    文件Global.java   
ScriptObject getErrorPrototype() {
    return ScriptFunction.getPrototype(builtinError);
}
项目:openjdk-jdk10    文件Global.java   
ScriptObject getURIErrorPrototype() {
    return ScriptFunction.getPrototype(getBuiltinURIError());
}
项目:Openjsharp    文件NashornScriptEngine.java   
private Object evalImpl(final ScriptFunction script,final ScriptContext ctxt) throws ScriptException {
    return evalImpl(script,ctxt,getNashornGlobalFrom(ctxt));
}
项目:openjdk-jdk10    文件SharedContextEvaluator.java   
@Override
public int run(final OutputStream out,final OutputStream err,final String[] args) throws IOException {
    final Global oldGlobal = Context.getGlobal();
    try {
        ctxOut.setDelegatee(out);
        ctxErr.setDelegatee(err);
        final ErrorManager errors = context.getErrorManager();
        final Global global = context.createGlobal();
        Context.setGlobal(global);

        // For each file on the command line.
        for (final String fileName : args) {
            if (fileName.startsWith("-")) {
                // ignore options in shared context mode (which was initialized upfront!)
                continue;
            }
            final File file = new File(fileName);
            final ScriptFunction script = context.compileScript(sourceFor(fileName,file.toURI().toURL()),global);

            if (script == null || errors.getNumberOfErrors() != 0) {
                return COMPILATION_ERROR;
            }

            try {
                ScriptRuntime.apply(script,global);
            } catch (final NashornException e) {
                errors.error(e.toString());
                if (context.getEnv()._dump_on_error) {
                    e.printstacktrace(context.getErr());
                }

                return RUNTIME_ERROR;
            }
        }
    } finally {
        context.getout().flush();
        context.getErr().flush();
        Context.setGlobal(oldGlobal);
    }

    return SUCCESS;
}
项目:openjdk-jdk10    文件AccessorPropertyDescriptor.java   
@Override
public ScriptFunction getSetter() {
    return (set instanceof ScriptFunction) ? (ScriptFunction)set : null;
}
项目:openjdk-jdk10    文件Global.java   
ScriptObject getDataViewPrototype() {
    return ScriptFunction.getPrototype(getBuiltinDataView());
}
项目:Openjsharp    文件NativeFunction.java   
private static void checkCallable(final Object self) {
    if (!(self instanceof ScriptFunction || (self instanceof JSObject && ((JSObject)self).isFunction()))) {
        throw typeError("not.a.function",ScriptRuntime.safetoString(self));
    }
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。