当前位置: 首页>>代码示例>>Java>>正文


Java Property.getType方法代码示例

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


在下文中一共展示了Property.getType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createObject

import jdk.nashorn.internal.runtime.Property; //导入方法依赖的package包/类
private Object createObject(final PropertyMap propertyMap, final List<Object> values, final ArrayData arrayData) {
    final long[] primitiveSpill = dualFields ? new long[values.size()] : null;
    final Object[] objectSpill = new Object[values.size()];

    for (final Property property : propertyMap.getProperties()) {
        if (!dualFields || property.getType() == Object.class) {
            objectSpill[property.getSlot()] = values.get(property.getSlot());
        } else {
            primitiveSpill[property.getSlot()] = ObjectClassGenerator.pack((Number) values.get(property.getSlot()));
        }
    }

    final ScriptObject object = dualFields ?
            new JD(propertyMap, primitiveSpill, objectSpill) : new JO(propertyMap, null, objectSpill);
    object.setInitialProto(global.getObjectPrototype());
    object.setArray(arrayData);
    return object;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:JSONParser.java

示例2: getPropertyType

import jdk.nashorn.internal.runtime.Property; //导入方法依赖的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


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