Java Code Examples for jdk.nashorn.internal.runtime.Undefined#lookup()

The following examples show how to use jdk.nashorn.internal.runtime.Undefined#lookup() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NashornLinker.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@Override
public GuardedInvocation getGuardedInvocation(final LinkRequest request, final LinkerServices linkerServices) throws Exception {
    final LinkRequest requestWithoutContext = request.withoutRuntimeContext(); // Nashorn has no runtime context
    final Object self = requestWithoutContext.getReceiver();
    final CallSiteDescriptor desc = requestWithoutContext.getCallSiteDescriptor();

    if (desc.getNameTokenCount() < 2 || !"dyn".equals(desc.getNameToken(CallSiteDescriptor.SCHEME))) {
        // We only support standard "dyn:*[:*]" operations
        return null;
    }

    final GuardedInvocation inv;
    if (self instanceof ScriptObject) {
        inv = ((ScriptObject)self).lookup(desc, request);
    } else if (self instanceof Undefined) {
        inv = Undefined.lookup(desc);
    } else {
        throw new AssertionError(); // Should never reach here.
    }

    return Bootstrap.asType(inv, linkerServices, desc);
}
 
Example 2
Source File: NashornLinker.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public GuardedInvocation getGuardedInvocation(final LinkRequest request, final LinkerServices linkerServices) throws Exception {
    final LinkRequest requestWithoutContext = request.withoutRuntimeContext(); // Nashorn has no runtime context
    final Object self = requestWithoutContext.getReceiver();
    final CallSiteDescriptor desc = requestWithoutContext.getCallSiteDescriptor();

    if (desc.getNameTokenCount() < 2 || !"dyn".equals(desc.getNameToken(CallSiteDescriptor.SCHEME))) {
        // We only support standard "dyn:*[:*]" operations
        return null;
    }

    final GuardedInvocation inv;
    if (self instanceof ScriptObject) {
        inv = ((ScriptObject)self).lookup(desc, request);
    } else if (self instanceof Undefined) {
        inv = Undefined.lookup(desc);
    } else {
        throw new AssertionError(); // Should never reach here.
    }

    return Bootstrap.asType(inv, linkerServices, desc);
}
 
Example 3
Source File: NashornLinker.java    From nashorn with GNU General Public License v2.0 6 votes vote down vote up
@Override
public GuardedInvocation getGuardedInvocation(final LinkRequest request, final LinkerServices linkerServices) throws Exception {
    final LinkRequest requestWithoutContext = request.withoutRuntimeContext(); // Nashorn has no runtime context
    final Object self = requestWithoutContext.getReceiver();
    final CallSiteDescriptor desc = requestWithoutContext.getCallSiteDescriptor();

    if (desc.getNameTokenCount() < 2 || !"dyn".equals(desc.getNameToken(CallSiteDescriptor.SCHEME))) {
        // We only support standard "dyn:*[:*]" operations
        return null;
    }

    final GuardedInvocation inv;
    if (self instanceof ScriptObject) {
        inv = ((ScriptObject)self).lookup(desc, request);
    } else if (self instanceof Undefined) {
        inv = Undefined.lookup(desc);
    } else {
        throw new AssertionError(); // Should never reach here.
    }

    return Bootstrap.asType(inv, linkerServices, desc);
}
 
Example 4
Source File: NashornLinker.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static GuardedInvocation getGuardedInvocation(final Object self, final LinkRequest request, final CallSiteDescriptor desc) {
    final GuardedInvocation inv;
    if (self instanceof ScriptObject) {
        inv = ((ScriptObject)self).lookup(desc, request);
    } else if (self instanceof Undefined) {
        inv = Undefined.lookup(desc);
    } else {
        throw new AssertionError(self.getClass().getName()); // Should never reach here.
    }

    return inv;
}
 
Example 5
Source File: NashornLinker.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static GuardedInvocation getGuardedInvocation(final Object self, final LinkRequest request, final CallSiteDescriptor desc) {
    final GuardedInvocation inv;
    if (self instanceof ScriptObject) {
        inv = ((ScriptObject)self).lookup(desc, request);
    } else if (self instanceof Undefined) {
        inv = Undefined.lookup(desc);
    } else {
        throw new AssertionError(self.getClass().getName()); // Should never reach here.
    }

    return inv;
}
 
Example 6
Source File: NashornLinker.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static GuardedInvocation getGuardedInvocation(final Object self, final LinkRequest request, final CallSiteDescriptor desc) {
    final GuardedInvocation inv;
    if (self instanceof ScriptObject) {
        inv = ((ScriptObject)self).lookup(desc, request);
    } else if (self instanceof Undefined) {
        inv = Undefined.lookup(desc);
    } else {
        throw new AssertionError(self.getClass().getName()); // Should never reach here.
    }

    return inv;
}
 
Example 7
Source File: NashornLinker.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static GuardedInvocation getGuardedInvocation(final Object self, final LinkRequest request, final CallSiteDescriptor desc) {
    final GuardedInvocation inv;
    if (self instanceof ScriptObject) {
        inv = ((ScriptObject)self).lookup(desc, request);
    } else if (self instanceof Undefined) {
        inv = Undefined.lookup(desc);
    } else {
        throw new AssertionError(self.getClass().getName()); // Should never reach here.
    }

    return inv;
}
 
Example 8
Source File: NashornLinker.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static GuardedInvocation getGuardedInvocation(final LinkRequest request, final CallSiteDescriptor desc) {
    final Object self = request.getReceiver();

    final GuardedInvocation inv;
    if (self instanceof ScriptObject) {
        inv = ((ScriptObject)self).lookup(desc, request);
    } else if (self instanceof Undefined) {
        inv = Undefined.lookup(desc);
    } else {
        throw new AssertionError(self.getClass().getName()); // Should never reach here.
    }

    return inv;
}
 
Example 9
Source File: NashornLinker.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static GuardedInvocation getGuardedInvocation(final Object self, final LinkRequest request, final CallSiteDescriptor desc) {
    final GuardedInvocation inv;
    if (self instanceof ScriptObject) {
        inv = ((ScriptObject)self).lookup(desc, request);
    } else if (self instanceof Undefined) {
        inv = Undefined.lookup(desc);
    } else {
        throw new AssertionError(self.getClass().getName()); // Should never reach here.
    }

    return inv;
}
 
Example 10
Source File: NashornLinker.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
private static GuardedInvocation getGuardedInvocation(final Object self, final LinkRequest request, final CallSiteDescriptor desc) {
    final GuardedInvocation inv;
    if (self instanceof ScriptObject) {
        inv = ((ScriptObject)self).lookup(desc, request);
    } else if (self instanceof Undefined) {
        inv = Undefined.lookup(desc);
    } else {
        throw new AssertionError(self.getClass().getName()); // Should never reach here.
    }

    return inv;
}