Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.dynjs.runtime.linker.js;
  
  import static org.dynjs.runtime.linker.LinkerUtils.*;
  
  
 
 
 
     public JavascriptObjectLinkStrategy(LinkLogger logger) {
         super(ExecutionContext.classlogger);
     }
 
     @Override
     public StrategicLink linkGetProperty(StrategyChain chainObject receiverString propNameBinder binderBinder guardBinderthrows NoSuchMethodException,
             IllegalAccessException {
         
         if (isJavascriptObjectReference(receiver)) {
             MethodHandle handle = binder
                     .filter(0, referenceBaseFilter())
                     .convert(Object.classJSObject.classExecutionContext.classString.class)
                     .invokeVirtual(lookup(), "get");
 
             MethodHandle guard = javascriptObjectReferenceGuard(guardBinder);
             return new StrategicLink(handleguard);
         }
 
         if (isJavascriptEnvironmnetReference(receiver)) {
             MethodHandle handle = binder
                     .convert(Object.classReference.classExecutionContext.classString.class)
                     .permute(0, 1, 2, 0)
                     .filter(0, referenceBaseFilter())
                     .filter(3, referenceStrictnessFilter())
                     .convert(Object.classEnvironmentRecord.classExecutionContext.classString.classboolean.class)
                     .invokeVirtual(lookup(), "getBindingValue");
 
             MethodHandle guard = javascriptEnvironmentReferenceGuard(guardBinder);
             return new StrategicLink(handleguard);
         }
 
         return chain.nextStrategy();
     }
 
     @Override
     public StrategicLink linkSetProperty(StrategyChain chainObject receiverString propNameObject valueBinder binderBinder guardBinder)
             throws NoSuchMethodExceptionIllegalAccessException {
 
         if (isJavascriptObjectReference(receiver)) {
             MethodHandle handle = binder
                     .convert(void.classReference.classExecutionContext.classString.classObject.class)
                     .permute(0, 1, 2, 3, 0)
                     .filter(0, referenceBaseFilter())
                     .filter(4, referenceStrictnessFilter())
                     .convert(void.classJSObject.classExecutionContext.classString.classObject.classboolean.class)
                     .invokeVirtual(lookup(), "put");
 
             MethodHandle guard = javascriptObjectReferenceGuard(guardBinder);
             return new StrategicLink(handleguard);
         }
 
         if (isJavascriptEnvironmnetReference(receiver)) {
             MethodHandle handle = binder
                     .convert(void.classReference.classExecutionContext.classString.classObject.class)
                     .permute(0, 1, 2, 3, 0)
                     .filter(0, referenceBaseFilter())
                     .filter(4, referenceStrictnessFilter())
                     .convert(void.classEnvironmentRecord.classExecutionContext.classString.classObject.classboolean.class)
                     .invokeVirtual(lookup(), "setMutableBinding");
 
             MethodHandle guard = javascriptEnvironmentReferenceGuard(guardBinder);
             return new StrategicLink(handleguard);
         }
         
         if (isJavascriptStrictUndefinedReference(receiver) && ((Reference)receiver).isStrictReference() ) {
             MethodHandle handle = binder
                     .drop(2,2)
                     .drop(1)
                     .filter( 0, createReferenceErrorFilter())
                     .throwException();
             
             MethodHandle guard = javascriptStrictUndefinedReferenceGuard(guardBinder);
             return new StrategicLink(handleguard);
         }
 
        if (isJavascriptUndefinedReference(receiver) && ! ((Reference)receiver).isStrictReference() ) {
            MethodHandle handle = binder
                    .convert(void.classReference.classExecutionContext.classString.classObject.class)
                    .permute(1, 1, 2, 3, 0)
                    .filter(0, globalObjectFilter())
                    .filter(4, referenceStrictnessFilter())
                    .convert(void.classJSObject.classExecutionContext.classString.classObject.classboolean.class)
                    .invokeVirtual(lookup(), "put");
            MethodHandle guard = javascriptUndefinedReferenceGuard(guardBinder);
            return new StrategicLink(handleguard);
        }
        
        return chain.nextStrategy();
    }
    @Override
    public StrategicLink linkCall(StrategyChain chainObject receiverObject selfObject[] argsBinder binderBinder guardBinderthrows NoSuchMethodException,
            IllegalAccessException {
        
        if (isFunctionDereferencedReference(receiver)) {
            MethodHandle handle = binder
                    .convert(Object.classDereferencedReference.classExecutionContext.classObject.classObject[].class)
                    .permute(1, 0, 0, 2, 3)
                    .filter(1, dereferencedReferenceFilter())
                    .filter(2, dereferencedValueFilter())
                    .convert(Object.classExecutionContext.classObject.classJSFunction.classObject.classObject[].class)
                    .invokeVirtual(lookup(), "call");
            MethodHandle guard = functionDereferencedReferenceGuard(guardBinder);
            return new StrategicLink(handleguard);
        }
        if (receiver instanceof JSFunction) {
            MethodHandle handle = binder
                    .permute(1, 0, 2, 3)
                    .convert(Object.classExecutionContext.classJSFunction.classObject.classObject[].class)
                    .invokeVirtual(lookup(), "call");
            MethodHandle guard = getReceiverClassGuard(JSFunction.classguardBinder);
            return new StrategicLink(handleguard);
        }
        if (isJavascriptDereferencedReference(receiver)) {
            MethodHandle handle = binder
                    .drop(0)
                    .drop(1, binder.type().parameterCount() - 2)
                    .convert(Object.classExecutionContext.class)
                    .filter(0, createTypeErrorFilter())
                    .throwException();
            MethodHandle guard = javascriptDereferencedReferenceGuard(guardBinder);
            return new StrategicLink(handleguard);
        }
        if (receiver instanceof JSObject) {
            MethodHandle handle = binder
                    .drop(0)
                    .drop(1, binder.type().parameterCount() - 2)
                    .convert(Object.classExecutionContext.class)
                    .filter(0, createTypeErrorFilter())
                    .throwException();
            MethodHandle guard = getReceiverClassGuard(JSObject.classguardBinder);
            return new StrategicLink(handleguard);
        }
        return chain.nextStrategy();
    }
    @Override
    public StrategicLink linkConstruct(StrategyChain chainObject receiverObject[] argsBinder binderBinder guardBinderthrows NoSuchMethodException,
            IllegalAccessException {
        
        if (isFunctionDereferencedReference(receiver)) {
            MethodHandle handle = binder
                    .permute(1, 0, 2)
                    .convert(Object.classExecutionContext.classReference.classObject[].class)
                    .invokeVirtual(lookup(), "construct");
            MethodHandle guard = functionDereferencedReferenceGuard(guardBinder);
            return new StrategicLink(handleguard);
        }
        if (receiver instanceof JSFunction) {
            MethodHandle handle = binder
                    .permute(1, 0, 2)
                    .convert(Object.classExecutionContext.classJSFunction.classObject[].class)
                    .invokeVirtual(lookup(), "construct");
            MethodHandle guard = getReceiverClassGuard(JSFunction.classguardBinder);
            return new StrategicLink(handleguard);
        }
        if (receiver instanceof JSObject) {
            MethodHandle handle = binder
                    .drop(0)
                    .drop(1, binder.type().parameterCount() - 2)
                    .convert(Object.classExecutionContext.class)
                    .filter(0, createTypeErrorFilter())
                    .throwException();
            MethodHandle guard = getReceiverClassGuard(JSObject.classguardBinder);
            return new StrategicLink(handleguard);
        }
        return chain.nextStrategy();
    }
        return MethodHandles.lookup().findStatic(JavascriptObjectLinkStrategy.class"dereferencedReferenceFilter",
                MethodType.methodType(Reference.classDereferencedReference.class));
    }
        return deref.getReference();
    }
        return MethodHandles.lookup().findStatic(JavascriptObjectLinkStrategy.class"dereferencedValueFilter",
                MethodType.methodType(Object.classDereferencedReference.class));
    }
    public static Object dereferencedValueFilter(DereferencedReference deref) {
        return deref.getValue();
    }
        return MethodHandles.lookup().findStatic(JavascriptObjectLinkStrategy.class"createTypeErrorFilter",
                MethodType.methodType(ThrowException.classExecutionContext.class));
    }
    public static ThrowException createTypeErrorFilter(ExecutionContext context) {
        return new ThrowException(contextcontext.createTypeError("not callable"));
    }
    
        return MethodHandles.lookup().findStatic(JavascriptObjectLinkStrategy.class"createTypeErrorFilter",
                MethodType.methodType(ThrowException.classExecutionContext.class));
    }
    public static ThrowException createReferenceErrorFilter(ExecutionContext context) {
        return new ThrowException(contextcontext.createTypeError("not referenceable"));
    }
    /*
     * @Override
     * public StrategicLink linkConstruct(StrategyChain chain, Object receiver, Object[] args, Binder binder, Binder guardBinder) throws NoSuchMethodException,
     * IllegalAccessException {
     * // TODO Auto-generated method stub
     * return super.linkConstruct(chain, receiver, args, binder, guardBinder);
     * }
     */
New to GrepCode? Check out our FAQ X