• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java FindProperty类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中jdk.nashorn.internal.runtime.FindProperty的典型用法代码示例。如果您正苦于以下问题:Java FindProperty类的具体用法?Java FindProperty怎么用?Java FindProperty使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FindProperty类属于jdk.nashorn.internal.runtime包,在下文中一共展示了FindProperty类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: primitiveSetter

import jdk.nashorn.internal.runtime.FindProperty; //导入依赖的package包/类
@SuppressWarnings("unused")
private static void primitiveSetter(final ScriptObject wrappedSelf, final Object self, final Object key,
                                    final boolean strict, final Object value) {
    // See ES5.1 8.7.2 PutValue (V, W)
    final String name = JSType.toString(key);
    final FindProperty find = wrappedSelf.findProperty(name, true);
    if (find == null || !find.getProperty().isAccessorProperty() || !find.getProperty().hasNativeSetter()) {
        if (strict) {
            if (find == null || !find.getProperty().isAccessorProperty()) {
                throw typeError("property.not.writable", name, ScriptRuntime.safeToString(self));
            } else {
                throw typeError("property.has.no.setter", name, ScriptRuntime.safeToString(self));
            }
        }
        return;
    }
    // property found and is a UserAccessorProperty
    find.setValue(value, strict);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:PrimitiveLookup.java


示例2: findGetMethod

import jdk.nashorn.internal.runtime.FindProperty; //导入依赖的package包/类
@Override
protected GuardedInvocation findGetMethod(final CallSiteDescriptor desc, final LinkRequest request, final String operation) {
    final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND);
    if (overrides && super.hasOwnProperty(name)) {
        try {
            final GuardedInvocation inv = super.findGetMethod(desc, request, operation);
            if (inv != null) {
                return inv;
            }
        } catch (final Exception e) {
            //ignored
        }
    }

    switch(operation) {
    case "getProp":
    case "getElem":
        return findHook(desc, __get__);
    case "getMethod":
        final FindProperty find = adaptee.findProperty(__call__, true);
        if (find != null) {
            final Object value = find.getObjectValue();
            if (value instanceof ScriptFunction) {
                final ScriptFunctionImpl func = (ScriptFunctionImpl)value;
                // TODO: It's a shame we need to produce a function bound to this and name, when we'd only need it bound
                // to name. Probably not a big deal, but if we can ever make it leaner, it'd be nice.
                return new GuardedInvocation(MH.dropArguments(MH.constant(Object.class,
                        func.makeBoundFunction(this, new Object[] { name })), 0, Object.class),
                        testJSAdaptor(adaptee, null, null, null),
                        adaptee.getProtoSwitchPoint(__call__, find.getOwner()));
            }
        }
        throw typeError("no.such.function", desc.getNameToken(2), ScriptRuntime.safeToString(this));
    default:
        break;
    }

    throw new AssertionError("should not reach here");
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:40,代码来源:NativeJSAdapter.java


示例3: getPropertyType

import jdk.nashorn.internal.runtime.FindProperty; //导入依赖的package包/类
private static Type getPropertyType(final ScriptObject sobj, final String name) {
    final FindProperty find = sobj.findProperty(name, true);
    if (find == null) {
        return null;
    }

    final Property property      = find.getProperty();
    final Class<?> propertyClass = property.getType();
    if (propertyClass == null) {
        // propertyClass == null means its value is Undefined. It is probably not initialized yet, so we won't make
        // a type assumption yet.
        return null;
    } else if (propertyClass.isPrimitive()) {
        return Type.typeFor(propertyClass);
    }

    final ScriptObject owner = find.getOwner();
    if (property.hasGetterFunction(owner)) {
        // Can have side effects, so we can't safely evaluate it; since !propertyClass.isPrimitive(), it's Object.
        return Type.OBJECT;
    }

    // Safely evaluate the property, and return the narrowest type for the actual value (e.g. Type.INT for a boxed
    // integer).
    final Object value = property.needsDeclaration() ? ScriptRuntime.UNDEFINED : property.getObjectValue(owner, owner);
    if (value == ScriptRuntime.UNDEFINED) {
        return null;
    }
    return Type.typeFor(JSType.unboxedFieldType(value));
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:31,代码来源:TypeEvaluator.java


示例4: evaluatePropertySafely

import jdk.nashorn.internal.runtime.FindProperty; //导入依赖的package包/类
private static Object evaluatePropertySafely(final ScriptObject sobj, final String name) {
    final FindProperty find = sobj.findProperty(name, true);
    if (find == null) {
        return null;
    }
    final Property     property = find.getProperty();
    final ScriptObject owner    = find.getOwner();
    if (property.hasGetterFunction(owner)) {
        // Possible side effects; can't evaluate safely
        return null;
    }
    return property.getObjectValue(owner, owner);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:14,代码来源:TypeEvaluator.java


示例5: findGetMethod

import jdk.nashorn.internal.runtime.FindProperty; //导入依赖的package包/类
@Override
protected GuardedInvocation findGetMethod(final CallSiteDescriptor desc, final LinkRequest request) {
    final String name = NashornCallSiteDescriptor.getOperand(desc);
    if (overrides && super.hasOwnProperty(name)) {
        try {
            final GuardedInvocation inv = super.findGetMethod(desc, request);
            if (inv != null) {
                return inv;
            }
        } catch (final Exception e) {
            //ignored
        }
    }

    if (!NashornCallSiteDescriptor.isMethodFirstOperation(desc)) {
        return findHook(desc, __get__);
    } else {
        final FindProperty find = adaptee.findProperty(__call__, true);
        if (find != null) {
            final Object value = find.getObjectValue();
            if (value instanceof ScriptFunction) {
                final ScriptFunction func = (ScriptFunction)value;
                // TODO: It's a shame we need to produce a function bound to this and name, when we'd only need it bound
                // to name. Probably not a big deal, but if we can ever make it leaner, it'd be nice.
                return new GuardedInvocation(MH.dropArguments(MH.constant(Object.class,
                        func.createBound(this, new Object[] { name })), 0, Object.class),
                        testJSAdapter(adaptee, null, null, null),
                        adaptee.getProtoSwitchPoints(__call__, find.getOwner()), null);
            }
        }
        throw typeError("no.such.function", name, ScriptRuntime.safeToString(this));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:34,代码来源:NativeJSAdapter.java


示例6: findProperty

import jdk.nashorn.internal.runtime.FindProperty; //导入依赖的package包/类
@Override
protected FindProperty findProperty(final Object key, final boolean deep, final boolean isScope, final ScriptObject start) {
    if (lexicalScope != null && isScope) {
        final FindProperty find = lexicalScope.findProperty(key, false);
        if (find != null) {
            return find;
        }
    }
    return super.findProperty(key, deep, isScope, start);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:Global.java


示例7: findGetMethod

import jdk.nashorn.internal.runtime.FindProperty; //导入依赖的package包/类
@Override
protected GuardedInvocation findGetMethod(final CallSiteDescriptor desc, final LinkRequest request, final StandardOperation operation) {
    final String name = NashornCallSiteDescriptor.getOperand(desc);
    if (overrides && super.hasOwnProperty(name)) {
        try {
            final GuardedInvocation inv = super.findGetMethod(desc, request, operation);
            if (inv != null) {
                return inv;
            }
        } catch (final Exception e) {
            //ignored
        }
    }

    switch(operation) {
    case GET_PROPERTY:
    case GET_ELEMENT:
        return findHook(desc, __get__);
    case GET_METHOD:
        final FindProperty find = adaptee.findProperty(__call__, true);
        if (find != null) {
            final Object value = find.getObjectValue();
            if (value instanceof ScriptFunction) {
                final ScriptFunction func = (ScriptFunction)value;
                // TODO: It's a shame we need to produce a function bound to this and name, when we'd only need it bound
                // to name. Probably not a big deal, but if we can ever make it leaner, it'd be nice.
                return new GuardedInvocation(MH.dropArguments(MH.constant(Object.class,
                        func.createBound(this, new Object[] { name })), 0, Object.class),
                        testJSAdapter(adaptee, null, null, null),
                        adaptee.getProtoSwitchPoints(__call__, find.getOwner()), null);
            }
        }
        throw typeError("no.such.function", name, ScriptRuntime.safeToString(this));
    default:
        break;
    }

    throw new AssertionError("should not reach here");
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:40,代码来源:NativeJSAdapter.java


示例8: findProperty

import jdk.nashorn.internal.runtime.FindProperty; //导入依赖的package包/类
@Override
protected FindProperty findProperty(final Object key, final boolean deep, final ScriptObject start) {
    if (lexicalScope != null && start != this && start.isScope()) {
        final FindProperty find = lexicalScope.findProperty(key, false);
        if (find != null) {
            return find;
        }
    }
    return super.findProperty(key, deep, start);
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:11,代码来源:Global.java


示例9: findProperty

import jdk.nashorn.internal.runtime.FindProperty; //导入依赖的package包/类
@Override
protected FindProperty findProperty(final String key, final boolean deep, final ScriptObject start) {
    if (lexicalScope != null && start != this && start.isScope()) {
        final FindProperty find = lexicalScope.findProperty(key, false);
        if (find != null) {
            return find;
        }
    }
    return super.findProperty(key, deep, start);
}
 
开发者ID:malaporte,项目名称:kaziranga,代码行数:11,代码来源:Global.java


示例10: primitiveSetter

import jdk.nashorn.internal.runtime.FindProperty; //导入依赖的package包/类
@SuppressWarnings("unused")
private static void primitiveSetter(final ScriptObject wrappedSelf, final Object self, final Object key,
                                    final boolean strict, final Object value) {
    // See ES5.1 8.7.2 PutValue (V, W)
    final String name = JSType.toString(key);
    final FindProperty find = wrappedSelf.findProperty(name, true);
    if (find == null || !(find.getProperty() instanceof UserAccessorProperty) || !find.getProperty().isWritable()) {
        if (strict) {
            throw typeError("property.not.writable", name, ScriptRuntime.safeToString(self));
        }
        return;
    }
    // property found and is a UserAccessorProperty
    find.setValue(value, strict);
}
 
开发者ID:malaporte,项目名称:kaziranga,代码行数:16,代码来源:PrimitiveLookup.java


示例11: findGetMethod

import jdk.nashorn.internal.runtime.FindProperty; //导入依赖的package包/类
@Override
protected GuardedInvocation findGetMethod(final CallSiteDescriptor desc, final LinkRequest request, final String operation) {
    final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND);
    if (overrides && super.hasOwnProperty(name)) {
        try {
            final GuardedInvocation inv = super.findGetMethod(desc, request, operation);
            if (inv != null) {
                return inv;
            }
        } catch (final Exception e) {
            //ignored
        }
    }

    switch(operation) {
    case "getProp":
    case "getElem":
        return findHook(desc, __get__);
    case "getMethod":
        final FindProperty find = adaptee.findProperty(__call__, true);
        if (find != null) {
            final Object value = find.getObjectValue();
            if (value instanceof ScriptFunction) {
                final ScriptFunction func = (ScriptFunction)value;
                // TODO: It's a shame we need to produce a function bound to this and name, when we'd only need it bound
                // to name. Probably not a big deal, but if we can ever make it leaner, it'd be nice.
                return new GuardedInvocation(MH.dropArguments(MH.constant(Object.class,
                        func.createBound(this, new Object[] { name })), 0, Object.class),
                        testJSAdaptor(adaptee, null, null, null),
                        adaptee.getProtoSwitchPoints(__call__, find.getOwner()), null);
            }
        }
        throw typeError("no.such.function", desc.getNameToken(2), ScriptRuntime.safeToString(this));
    default:
        break;
    }

    throw new AssertionError("should not reach here");
}
 
开发者ID:ojdkbuild,项目名称:lookaside_java-1.8.0-openjdk,代码行数:40,代码来源:NativeJSAdapter.java


示例12: findGetMethod

import jdk.nashorn.internal.runtime.FindProperty; //导入依赖的package包/类
@Override
protected GuardedInvocation findGetMethod(final CallSiteDescriptor desc, final LinkRequest request, final String operation) {
    final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND);
    if (overrides && super.hasOwnProperty(name)) {
        try {
            final GuardedInvocation inv = super.findGetMethod(desc, request, operation);
            if (inv != null) {
                return inv;
            }
        } catch (final Exception e) {
            //ignored
        }
    }

    switch(operation) {
    case "getProp":
    case "getElem":
        return findHook(desc, __get__);
    case "getMethod":
        final FindProperty find = adaptee.findProperty(__call__, true);
        if (find != null) {
            final Object value = getObjectValue(find);
            if (value instanceof ScriptFunction) {
                final ScriptFunctionImpl func = (ScriptFunctionImpl)value;
                // TODO: It's a shame we need to produce a function bound to this and name, when we'd only need it bound
                // to name. Probably not a big deal, but if we can ever make it leaner, it'd be nice.
                return new GuardedInvocation(MH.dropArguments(MH.constant(Object.class,
                        func.makeBoundFunction(this, new Object[] { name })), 0, Object.class),
                        adaptee.getMap().getProtoGetSwitchPoint(adaptee.getProto(), __call__),
                        testJSAdaptor(adaptee, null, null, null));
            }
        }
        throw typeError("no.such.function", desc.getNameToken(2), ScriptRuntime.safeToString(this));
    default:
        break;
    }

    throw new AssertionError("should not reach here");
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:40,代码来源:NativeJSAdapter.java


示例13: findGetMethod

import jdk.nashorn.internal.runtime.FindProperty; //导入依赖的package包/类
@Override
protected GuardedInvocation findGetMethod(final CallSiteDescriptor desc, final LinkRequest request, final String operation) {
    final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND);
    if (overrides && super.hasOwnProperty(name)) {
        try {
            final GuardedInvocation inv = super.findGetMethod(desc, request, operation);
            if (inv != null) {
                return inv;
            }
        } catch (final Exception e) {
            //ignored
        }
    }

    switch(operation) {
    case "getProp":
    case "getElem":
        return findHook(desc, __get__);
    case "getMethod":
        final FindProperty find = adaptee.findProperty(__call__, true);
        if (find != null) {
            final Object value = getObjectValue(find);
            if (value instanceof ScriptFunction) {
                final ScriptFunctionImpl func = (ScriptFunctionImpl)value;
                // TODO: It's a shame we need to produce a function bound to this and name, when we'd only need it bound
                // to name. Probably not a big deal, but if we can ever make it leaner, it'd be nice.
                return new GuardedInvocation(MH.dropArguments(MH.constant(Object.class,
                        func.makeBoundFunction(this, new Object[] { name })), 0, Object.class),
                        adaptee.getMap().getProtoGetSwitchPoint(adaptee.getProto(), __call__), testJSAdaptor(adaptee, null, null, null));
            }
        }
        throw typeError("no.such.function", desc.getNameToken(2), ScriptRuntime.safeToString(this));
    default:
        break;
    }

    throw new AssertionError("should not reach here");
}
 
开发者ID:wro4j,项目名称:nashorn-backport,代码行数:39,代码来源:NativeJSAdapter.java



注:本文中的jdk.nashorn.internal.runtime.FindProperty类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AuthenticationRequest类代码示例发布时间:2022-05-22
下一篇:
Java RpcRequestHeaderProto类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap