Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.dynjs.runtime.linker.js.environment;
 
import static java.lang.invoke.MethodHandles.lookup;
import static java.lang.invoke.MethodType.methodType;

Author(s):
Bob McWhirter
public class EnvironmentPropertyGetLink extends SmartLink implements Guard {
    public EnvironmentPropertyGetLink(LinkBuilder builderthrows Exception {
        super(builder);
        this. = this..guardWith(this);
    }
    public boolean guard(Object receiverObject contextString propertyName) {
        boolean result = (receiver instanceof Reference) && (((Referencereceiver).getBase() instanceof EnvironmentRecord);
        //System.out.println( "-- TEST " + this + " >> " + result + " // " + receiver );
        return result;
    }
    @Override
    public MethodHandle guardMethodHandle(MethodType inputTypethrows Exception {
        return lookup()
                .findVirtual(EnvironmentPropertyGetLink.class"guard"methodType(boolean.classObject.classObject.classString.class))
                .bindTo(this);
    }
    public MethodHandle guard() throws Exception {
        return this..getGuard();
    }
    public MethodHandle target() throws Exception {
        return 
                //.convert(Object.class, Reference.class, ExecutionContext.class, String.class)
                .permute(0, 1, 2, 0)
                .convert(Object.classReference.classExecutionContext.classString.classReference.class)
                .filter(0, .)
                .filter(3, .)
                .convert(Object.classEnvironmentRecord.classExecutionContext.classString.classboolean.class)
                .invoke(lookup().findVirtual(EnvironmentRecord.class"getBindingValue"methodType(Object.classExecutionContext.classString.classboolean.class)))
                .target();
    }
New to GrepCode? Check out our FAQ X