Java Code Examples for jdk.nashorn.internal.codegen.types.Type#OBJECT
The following examples show how to use
jdk.nashorn.internal.codegen.types.Type#OBJECT .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ObjectClassGenerator.java From jdk8u_nashorn with GNU General Public License v2.0 | 6 votes |
/** * Generates the needed fields. * * @param classEmitter Open class emitter. * @param fieldCount Number of fields. * * @return List fields that need to be initialized. */ private List<String> addFields(final ClassEmitter classEmitter, final int fieldCount) { final List<String> initFields = new LinkedList<>(); final Type[] fieldTypes = dualFields ? FIELD_TYPES_DUAL : FIELD_TYPES_OBJECT; for (int i = 0; i < fieldCount; i++) { for (final Type type : fieldTypes) { final String fieldName = getFieldName(i, type); classEmitter.field(fieldName, type.getTypeClass()); if (type == Type.OBJECT) { initFields.add(fieldName); } } } return initFields; }
Example 2
Source File: MethodEmitter.java From jdk8u_nashorn with GNU General Public License v2.0 | 6 votes |
/** * Generate dynamic getter. Pop scope from stack. Push result * * @param valueType type of the value to set * @param name name of property * @param flags call site flags * @param isMethod should it prefer retrieving methods * @param isIndex is this an index operation? * @return the method emitter */ MethodEmitter dynamicGet(final Type valueType, final String name, final int flags, final boolean isMethod, final boolean isIndex) { if (name.length() > LARGE_STRING_THRESHOLD) { // use getIndex for extremely long names return load(name).dynamicGetIndex(valueType, flags, isMethod); } debug("dynamic_get", name, valueType, getProgramPoint(flags)); Type type = valueType; if (type.isObject() || type.isBoolean()) { type = Type.OBJECT; //promote e.g strings to object generic setter } popType(Type.SCOPE); method.visitInvokeDynamicInsn(dynGetOperation(isMethod, isIndex) + ':' + NameCodec.encode(name), Type.getMethodDescriptor(type, Type.OBJECT), LINKERBOOTSTRAP, flags); pushType(type); convert(valueType); //most probably a nop return this; }
Example 3
Source File: MethodEmitter.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Generate dynamic getter. Pop scope from stack. Push result * * @param valueType type of the value to set * @param name name of property * @param flags call site flags * @param isMethod should it prefer retrieving methods * * @return the method emitter */ MethodEmitter dynamicGet(final Type valueType, final String name, final int flags, final boolean isMethod) { debug("dynamic_get", name, valueType); Type type = valueType; if (type.isObject() || type.isBoolean()) { type = Type.OBJECT; //promote e.g strings to object generic setter } popType(Type.SCOPE); method.visitInvokeDynamicInsn((isMethod ? "dyn:getMethod|getProp|getElem:" : "dyn:getProp|getElem|getMethod:") + NameCodec.encode(name), Type.getMethodDescriptor(type, Type.OBJECT), LINKERBOOTSTRAP, flags); pushType(type); convert(valueType); //most probably a nop return this; }
Example 4
Source File: CodeGeneratorLexicalContext.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
static Type getTypeForSlotDescriptor(final char typeDesc) { // Recognizing both lowercase and uppercase as we're using both to signify symbol boundaries; see // MethodEmitter.markSymbolBoundariesInLvarTypesDescriptor(). switch (typeDesc) { case 'I': case 'i': return Type.INT; case 'J': case 'j': return Type.LONG; case 'D': case 'd': return Type.NUMBER; case 'A': case 'a': return Type.OBJECT; case 'U': case 'u': return Type.UNKNOWN; default: throw new AssertionError(); } }
Example 5
Source File: TypeEvaluator.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
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)); }
Example 6
Source File: MethodEmitter.java From nashorn with GNU General Public License v2.0 | 5 votes |
/** * Generate dynamic setter. Pop receiver and property from stack. * * @param valueType the type of the value to set * @param name name of property * @param flags call site flags */ void dynamicSet(final Type valueType, final String name, final int flags) { debug("dynamic_set", name, peekType()); Type type = valueType; if (type.isObject() || type.isBoolean()) { //promote strings to objects etc type = Type.OBJECT; convert(Type.OBJECT); //TODO bad- until we specialize boolean setters, } popType(type); popType(Type.SCOPE); method.visitInvokeDynamicInsn("dyn:setProp|setElem:" + NameCodec.encode(name), methodDescriptor(void.class, Object.class, type.getTypeClass()), LINKERBOOTSTRAP, flags); }
Example 7
Source File: BaseNode.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override public Type getMostPessimisticType() { return Type.OBJECT; }
Example 8
Source File: UnaryNode.java From nashorn with GNU General Public License v2.0 | 4 votes |
@Override public Type getWidestOperationType() { return isAssignment() ? Type.NUMBER : Type.OBJECT; }
Example 9
Source File: LiteralNode.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
@Override public Type getType() { return Type.OBJECT; }
Example 10
Source File: LiteralNode.java From jdk8u_nashorn with GNU General Public License v2.0 | 4 votes |
@Override public Type getType() { return Type.OBJECT; }
Example 11
Source File: OptimisticReturnFilters.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
@SuppressWarnings("unused") private static int ensureInt(final int programPoint) { // Turns a void into UNDEFINED throw new UnwarrantedOptimismException(ScriptRuntime.UNDEFINED, programPoint, Type.OBJECT); }
Example 12
Source File: LiteralNode.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override public Type getType() { return Type.OBJECT; }
Example 13
Source File: RuntimeNode.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private Request() { this(TokenType.VOID, Type.OBJECT, 0); }
Example 14
Source File: LiteralNode.java From hottub with GNU General Public License v2.0 | 4 votes |
@Override public Type getType() { return Type.OBJECT; }
Example 15
Source File: ObjectNode.java From jdk8u_nashorn with GNU General Public License v2.0 | 4 votes |
@Override public Type getType() { return Type.OBJECT; }
Example 16
Source File: OptimisticReturnFilters.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
@SuppressWarnings("unused") private static int ensureInt(final boolean arg, final int programPoint) { throw new UnwarrantedOptimismException(arg, programPoint, Type.OBJECT); }
Example 17
Source File: ClassNode.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override public Type getType() { return Type.OBJECT; }
Example 18
Source File: ErrorNode.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override public Type getType() { return Type.OBJECT; }
Example 19
Source File: Expression.java From jdk8u60 with GNU General Public License v2.0 | 2 votes |
/** * Returns widest operation type of this operation. * * @return the widest type for this operation */ public Type getWidestOperationType() { return Type.OBJECT; }
Example 20
Source File: ArrayData.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 2 votes |
/** * Returns the optimistic type of this array data. Basically, when an array data object needs to throw an * {@link UnwarrantedOptimismException}, this type is used as the actual type of the return value. * @return the optimistic type of this array data. */ public Type getOptimisticType() { return Type.OBJECT; }