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


Java Property类代码示例

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


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

示例1: NativeStrictArguments

import jdk.nashorn.internal.runtime.Property; //导入依赖的package包/类
NativeStrictArguments(final Object[] values, final int numParams,final ScriptObject proto, final PropertyMap map) {
    super(proto, map);
    setIsArguments();

    final ScriptFunction func = Global.instance().getTypeErrorThrower();
    // We have to fill user accessor functions late as these are stored
    // in this object rather than in the PropertyMap of this object.
    final int flags = Property.NOT_ENUMERABLE | Property.NOT_CONFIGURABLE;
    initUserAccessors("caller", flags, func, func);
    initUserAccessors("callee", flags, func, func);

    setArray(ArrayData.allocate(values));
    this.length = values.length;

    // extend/truncate named arg array as needed and copy values
    this.namedArgs = new Object[numParams];
    if (numParams > values.length) {
        Arrays.fill(namedArgs, UNDEFINED);
    }
    System.arraycopy(values, 0, namedArgs, 0, Math.min(namedArgs.length, values.length));
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:NativeStrictArguments.java

示例2: getGuard

import jdk.nashorn.internal.runtime.Property; //导入依赖的package包/类
/**
 * Get the guard for a property access. This returns an identity guard for non-configurable global properties
 * and a map guard for everything else.
 *
 * @param sobj the first object in the prototype chain
 * @param property the property
 * @param desc the callsite descriptor
 * @param explicitInstanceOfCheck true if we should do an explicit script object instanceof check instead of just casting
 * @return method handle for guard
 */
public static MethodHandle getGuard(final ScriptObject sobj, final Property property, final CallSiteDescriptor desc, final boolean explicitInstanceOfCheck) {
    if (!needsGuard(property, desc)) {
        return null;
    }
    if (NashornCallSiteDescriptor.isScope(desc)) {
        if (property != null && property.isBound() && !property.canChangeType()) {
            // This is a declared top level variables in main script or eval, use identity guard.
            return getIdentityGuard(sobj);
        }
        if (!(sobj instanceof Global) && (property == null || property.isConfigurable())) {
            // Undeclared variables in nested evals need stronger guards
            return combineGuards(getIdentityGuard(sobj), getMapGuard(sobj.getMap(), explicitInstanceOfCheck));
        }
    }
    return getMapGuard(sobj.getMap(), explicitInstanceOfCheck);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:NashornGuards.java

示例3: addObjectProperty

import jdk.nashorn.internal.runtime.Property; //导入依赖的package包/类
private PropertyMap addObjectProperty(final PropertyMap propertyMap, final List<Object> values,
                                             final String id, final Object value) {
    final Property oldProperty = propertyMap.findProperty(id);
    final PropertyMap newMap;
    final Class<?> type;
    final int flags;
    if (dualFields) {
        type = getType(value);
        flags = Property.DUAL_FIELDS;
    } else {
        type = Object.class;
        flags = 0;
    }

    if (oldProperty != null) {
        values.set(oldProperty.getSlot(), value);
        newMap = propertyMap.replaceProperty(oldProperty, new SpillProperty(id, flags, oldProperty.getSlot(), type));;
    } else {
        values.add(value);
        newMap = propertyMap.addProperty(new SpillProperty(id, flags, propertyMap.size(), type));
    }

    return newMap;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:JSONParser.java

示例4: 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

示例5: getGuard

import jdk.nashorn.internal.runtime.Property; //导入依赖的package包/类
/**
 * Get the guard for a property access. This returns an identity guard for non-configurable global properties
 * and a map guard for everything else.
 *
 * @param sobj the first object in the prototype chain
 * @param property the property
 * @param desc the callsite descriptor
 * @param explicitInstanceOfCheck true if we should do an explicit script object instanceof check instead of just casting
 * @return method handle for guard
 */
public static MethodHandle getGuard(final ScriptObject sobj, final Property property, final CallSiteDescriptor desc, final boolean explicitInstanceOfCheck) {
    if (!needsGuard(property, desc)) {
        return null;
    }
    if (NashornCallSiteDescriptor.isScope(desc) && sobj.isScope()) {
        if (property != null && property.isBound() && !property.canChangeType()) {
            // This is a declared top level variables in main script or eval, use identity guard.
            return getIdentityGuard(sobj);
        }
        if (!(sobj instanceof Global) && (property == null || property.isConfigurable())) {
            // Undeclared variables in nested evals need stronger guards
            return combineGuards(getIdentityGuard(sobj), getMapGuard(sobj.getMap(), explicitInstanceOfCheck));
        }
    }
    return getMapGuard(sobj.getMap(), explicitInstanceOfCheck);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:NashornGuards.java

示例6: runFXScripts

import jdk.nashorn.internal.runtime.Property; //导入依赖的package包/类
/**
 * Runs launches "fx:bootstrap.js" with the given JavaScript files provided
 * as arguments.
 *
 * @param context the nashorn context
 * @param global the global scope
 * @param files the list of script files to provide
 *
 * @return error code
 * @throws IOException when any script file read results in I/O error
 */
private static int runFXScripts(final Context context, final Global global, final List<String> files) throws IOException {
    final Global oldGlobal = Context.getGlobal();
    final boolean globalChanged = (oldGlobal != global);
    try {
        if (globalChanged) {
            Context.setGlobal(global);
        }

        global.addOwnProperty("$GLOBAL", Property.NOT_ENUMERABLE, global);
        global.addOwnProperty("$SCRIPTS", Property.NOT_ENUMERABLE, files);
        context.load(global, "fx:bootstrap.js");
    } catch (final NashornException e) {
        context.getErrorManager().error(e.toString());
        if (context.getEnv()._dump_on_error) {
            e.printStackTrace(context.getErr());
        }

        return RUNTIME_ERROR;
    } finally {
        context.getOut().flush();
        context.getErr().flush();
        if (globalChanged) {
            Context.setGlobal(oldGlobal);
        }
    }

    return SUCCESS;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:40,代码来源:Shell.java

示例7: getPropertyFlags

import jdk.nashorn.internal.runtime.Property; //导入依赖的package包/类
/**
 * Compute property flags given local state of a field. May be overridden and extended,
 *
 * @param symbol       symbol to check
 * @param hasArguments does the created object have an "arguments" property
 *
 * @return flags to use for fields
 */
protected int getPropertyFlags(final Symbol symbol, final boolean hasArguments) {
    int flags = 0;

    if (symbol.isParam()) {
        flags |= Property.IS_ALWAYS_OBJECT | Property.IS_PARAMETER;
    }

    if (hasArguments) {
        flags |= Property.IS_ALWAYS_OBJECT | Property.HAS_ARGUMENTS;
    }

    if (symbol.isScope()) {
        flags |= Property.NOT_CONFIGURABLE;
    }

    if (symbol.canBePrimitive()) {
        flags |= Property.CAN_BE_PRIMITIVE;
    }

    if (symbol.canBeUndefined()) {
        flags |= Property.CAN_BE_UNDEFINED;
    }

    return flags;
}
 
开发者ID:wro4j,项目名称:nashorn-backport,代码行数:34,代码来源:MapCreator.java

示例8: createStrictModeMap

import jdk.nashorn.internal.runtime.Property; //导入依赖的package包/类
private static PropertyMap createStrictModeMap(final PropertyMap map) {
    final int flags = Property.NOT_ENUMERABLE | Property.NOT_CONFIGURABLE;
    PropertyMap newMap = map;
    // Need to add properties directly to map since slots are assigned speculatively by newUserAccessors.
    newMap = newMap.addPropertyNoHistory(map.newUserAccessors("arguments", flags));
    newMap = newMap.addPropertyNoHistory(map.newUserAccessors("caller", flags));
    return newMap;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:ScriptFunctionImpl.java

示例9: propertyIsEnumerable

import jdk.nashorn.internal.runtime.Property; //导入依赖的package包/类
/**
 * ECMA 15.2.4.7 Object.prototype.propertyIsEnumerable (V)
 *
 * @param self self reference
 * @param v property to check if enumerable
 * @return true if property is enumerable
 */
@Function(attributes = Attribute.NOT_ENUMERABLE)
public static boolean propertyIsEnumerable(final Object self, final Object v) {
    final String str = JSType.toString(v);
    final Object obj = Global.toObject(self);

    if (obj instanceof ScriptObject) {
        final jdk.nashorn.internal.runtime.Property property = ((ScriptObject)obj).getMap().findProperty(str);
        return property != null && property.isEnumerable();
    }

    return false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:NativeObject.java

示例10: 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

示例11: evaluatePropertySafely

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


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