com.sun.org.apache.xalan.internal.xsltc.compiler.Constants Java Examples

The following examples show how to use com.sun.org.apache.xalan.internal.xsltc.compiler.Constants. 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 Project: openjdk-8   Author: bpupadhyaya   File: StringType.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Translates an external (primitive) Java type into a string.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateFrom
 */
public void translateFrom(ClassGenerator classGen,
    MethodGenerator methodGen, Class clazz)
{
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    if (clazz.getName().equals("java.lang.String")) {
        // same internal representation, convert null to ""
        il.append(DUP);
        final BranchHandle ifNonNull = il.append(new IFNONNULL(null));
        il.append(POP);
        il.append(new PUSH(cpg, ""));
        ifNonNull.setTarget(il.append(NOP));
    }
    else {
        ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                    toString(), clazz.getName());
        classGen.getParser().reportError(Constants.FATAL, err);
    }
}
 
Example #2
Source Project: JDKSourceCode1.8   Author: wupeixuan   File: BooleanType.java    License: MIT License 6 votes vote down vote up
/**
 * Translates a real into an object of internal type <code>type</code>. The
 * translation to int is undefined since booleans are always converted to
 * reals in arithmetic expressions.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        Type type) {
    if (type == Type.String) {
        translateTo(classGen, methodGen, (StringType) type);
    }
    else if (type == Type.Real) {
        translateTo(classGen, methodGen, (RealType) type);
    }
    else if (type == Type.Reference) {
        translateTo(classGen, methodGen, (ReferenceType) type);
    }
    else {
        ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                    toString(), type.toString());
        classGen.getParser().reportError(Constants.FATAL, err);
    }
}
 
Example #3
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: RealType.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Translates an external (primitive) Java type into a real. Expects a java
 * object on the stack and pushes a real (i.e., a double).
 */
public void translateFrom(ClassGenerator classGen, MethodGenerator methodGen,
                          Class clazz) {
    InstructionList il = methodGen.getInstructionList();

    if (clazz == Character.TYPE || clazz == Byte.TYPE ||
        clazz == Short.TYPE || clazz == Integer.TYPE) {
        il.append(I2D);
    }
    else if (clazz == Long.TYPE) {
        il.append(L2D);
    }
    else if (clazz == Float.TYPE) {
        il.append(F2D);
    }
    else if (clazz == Double.TYPE) {
        il.append(NOP);
    }
    else {
        ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                    toString(), clazz.getName());
        classGen.getParser().reportError(Constants.FATAL, err);
    }
}
 
Example #4
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: RealType.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Translates an external (primitive) Java type into a real. Expects a java
 * object on the stack and pushes a real (i.e., a double).
 */
public void translateFrom(ClassGenerator classGen, MethodGenerator methodGen,
                          Class clazz) {
    InstructionList il = methodGen.getInstructionList();

    if (clazz == Character.TYPE || clazz == Byte.TYPE ||
        clazz == Short.TYPE || clazz == Integer.TYPE) {
        il.append(I2D);
    }
    else if (clazz == Long.TYPE) {
        il.append(L2D);
    }
    else if (clazz == Float.TYPE) {
        il.append(F2D);
    }
    else if (clazz == Double.TYPE) {
        il.append(NOP);
    }
    else {
        ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                    toString(), clazz.getName());
        classGen.getParser().reportError(Constants.FATAL, err);
    }
}
 
Example #5
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: BooleanType.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Translates an internal boolean into an external (Java) boolean.
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        Class clazz) {
    if (clazz == java.lang.Boolean.TYPE) {
        methodGen.getInstructionList().append(NOP);
    }
    // Is Boolean <: clazz? I.e. clazz in { Boolean, Object }
    else if (clazz.isAssignableFrom(java.lang.Boolean.class)) {
        translateTo(classGen, methodGen, Type.Reference);
    }
    else {
        ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                    toString(), clazz.getName());
        classGen.getParser().reportError(Constants.FATAL, err);
    }
}
 
Example #6
Source Project: JDKSourceCode1.8   Author: wupeixuan   File: StringType.java    License: MIT License 6 votes vote down vote up
/**
 * Translates a string into an object of internal type <code>type</code>.
 * The translation to int is undefined since strings are always converted
 * to reals in arithmetic expressions.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        Type type) {
    if (type == Type.Boolean) {
        translateTo(classGen, methodGen, (BooleanType) type);
    }
    else if (type == Type.Real) {
        translateTo(classGen, methodGen, (RealType) type);
    }
    else if (type == Type.Reference) {
        translateTo(classGen, methodGen, (ReferenceType) type);
    }
    else if (type == Type.ObjectString) {
        // NOP -> same representation
    }
    else {
        ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                    toString(), type.toString());
        classGen.getParser().reportError(Constants.FATAL, err);
    }
}
 
Example #7
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: BooleanType.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Translates a real into an object of internal type <code>type</code>. The
 * translation to int is undefined since booleans are always converted to
 * reals in arithmetic expressions.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        Type type) {
    if (type == Type.String) {
        translateTo(classGen, methodGen, (StringType) type);
    }
    else if (type == Type.Real) {
        translateTo(classGen, methodGen, (RealType) type);
    }
    else if (type == Type.Reference) {
        translateTo(classGen, methodGen, (ReferenceType) type);
    }
    else {
        ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                    toString(), type.toString());
        classGen.getParser().reportError(Constants.FATAL, err);
    }
}
 
Example #8
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: StringType.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Translates an external (primitive) Java type into a string.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateFrom
 */
public void translateFrom(ClassGenerator classGen,
    MethodGenerator methodGen, Class clazz)
{
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    if (clazz.getName().equals("java.lang.String")) {
        // same internal representation, convert null to ""
        il.append(DUP);
        final BranchHandle ifNonNull = il.append(new IFNONNULL(null));
        il.append(POP);
        il.append(new PUSH(cpg, ""));
        ifNonNull.setTarget(il.append(NOP));
    }
    else {
        ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                    toString(), clazz.getName());
        classGen.getParser().reportError(Constants.FATAL, err);
    }
}
 
Example #9
Source Project: openjdk-8-source   Author: keerath   File: StringType.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Translates an external (primitive) Java type into a string.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateFrom
 */
public void translateFrom(ClassGenerator classGen,
    MethodGenerator methodGen, Class clazz)
{
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    if (clazz.getName().equals("java.lang.String")) {
        // same internal representation, convert null to ""
        il.append(DUP);
        final BranchHandle ifNonNull = il.append(new IFNONNULL(null));
        il.append(POP);
        il.append(new PUSH(cpg, ""));
        ifNonNull.setTarget(il.append(NOP));
    }
    else {
        ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                    toString(), clazz.getName());
        classGen.getParser().reportError(Constants.FATAL, err);
    }
}
 
Example #10
Source Project: jdk8u60   Author: chenghanpeng   File: BooleanType.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Translates an internal boolean into an external (Java) boolean.
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        Class clazz) {
    if (clazz == java.lang.Boolean.TYPE) {
        methodGen.getInstructionList().append(NOP);
    }
    // Is Boolean <: clazz? I.e. clazz in { Boolean, Object }
    else if (clazz.isAssignableFrom(java.lang.Boolean.class)) {
        translateTo(classGen, methodGen, Type.Reference);
    }
    else {
        ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                    toString(), clazz.getName());
        classGen.getParser().reportError(Constants.FATAL, err);
    }
}
 
Example #11
Source Project: openjdk-8-source   Author: keerath   File: IntType.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Translates an integer into an object of internal type <code>type</code>.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        final Type type) {
    if (type == Type.Real) {
        translateTo(classGen, methodGen, (RealType) type);
    }
    else if (type == Type.String) {
        translateTo(classGen, methodGen, (StringType) type);
    }
    else if (type == Type.Boolean) {
        translateTo(classGen, methodGen, (BooleanType) type);
    }
    else if (type == Type.Reference) {
        translateTo(classGen, methodGen, (ReferenceType) type);
    }
    else {
        ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                    toString(), type.toString());
        classGen.getParser().reportError(Constants.FATAL, err);
    }
}
 
Example #12
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: BooleanType.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Translates a real into an object of internal type <code>type</code>. The
 * translation to int is undefined since booleans are always converted to
 * reals in arithmetic expressions.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        Type type) {
    if (type == Type.String) {
        translateTo(classGen, methodGen, (StringType) type);
    }
    else if (type == Type.Real) {
        translateTo(classGen, methodGen, (RealType) type);
    }
    else if (type == Type.Reference) {
        translateTo(classGen, methodGen, (ReferenceType) type);
    }
    else {
        ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                    toString(), type.toString());
        classGen.getParser().reportError(Constants.FATAL, err);
    }
}
 
Example #13
Source Project: TencentKona-8   Author: Tencent   File: RealType.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Translates an external (primitive) Java type into a real. Expects a java
 * object on the stack and pushes a real (i.e., a double).
 */
public void translateFrom(ClassGenerator classGen, MethodGenerator methodGen,
                          Class clazz) {
    InstructionList il = methodGen.getInstructionList();

    if (clazz == Character.TYPE || clazz == Byte.TYPE ||
        clazz == Short.TYPE || clazz == Integer.TYPE) {
        il.append(I2D);
    }
    else if (clazz == Long.TYPE) {
        il.append(L2D);
    }
    else if (clazz == Float.TYPE) {
        il.append(F2D);
    }
    else if (clazz == Double.TYPE) {
        il.append(NOP);
    }
    else {
        ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                    toString(), clazz.getName());
        classGen.getParser().reportError(Constants.FATAL, err);
    }
}
 
Example #14
Source Project: JDKSourceCode1.8   Author: wupeixuan   File: TransformerFactoryImpl.java    License: MIT License 6 votes vote down vote up
/**
 * This method implements XSLTC's SourceLoader interface. It is used to
 * glue a TrAX URIResolver to the XSLTC compiler's Input and Import classes.
 *
 * @param href The URI of the document to load
 * @param context The URI of the currently loaded document
 * @param xsltc The compiler that resuests the document
 * @return An InputSource with the loaded document
 */
@Override
public InputSource loadSource(String href, String context, XSLTC xsltc) {
    try {
        if (_uriResolver != null) {
            final Source source = _uriResolver.resolve(href, context);
            if (source != null) {
                return Util.getInputSource(xsltc, source);
            }
        }
    }
    catch (TransformerException e) {
        // should catch it when the resolver explicitly throws the exception
        final ErrorMsg msg = new ErrorMsg(ErrorMsg.INVALID_URI_ERR, href + "\n" + e.getMessage(), this);
        xsltc.getParser().reportError(Constants.FATAL, msg);
    }

    return null;
}
 
Example #15
Source Project: jdk8u60   Author: chenghanpeng   File: BooleanType.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Translates a real into an object of internal type <code>type</code>. The
 * translation to int is undefined since booleans are always converted to
 * reals in arithmetic expressions.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        Type type) {
    if (type == Type.String) {
        translateTo(classGen, methodGen, (StringType) type);
    }
    else if (type == Type.Real) {
        translateTo(classGen, methodGen, (RealType) type);
    }
    else if (type == Type.Reference) {
        translateTo(classGen, methodGen, (ReferenceType) type);
    }
    else {
        ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                    toString(), type.toString());
        classGen.getParser().reportError(Constants.FATAL, err);
    }
}
 
Example #16
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: TransformerFactoryImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * This method implements XSLTC's SourceLoader interface. It is used to
 * glue a TrAX URIResolver to the XSLTC compiler's Input and Import classes.
 *
 * @param href The URI of the document to load
 * @param context The URI of the currently loaded document
 * @param xsltc The compiler that resuests the document
 * @return An InputSource with the loaded document
 */
@Override
public InputSource loadSource(String href, String context, XSLTC xsltc) {
    try {
        if (_uriResolver != null) {
            final Source source = _uriResolver.resolve(href, context);
            if (source != null) {
                return Util.getInputSource(xsltc, source);
            }
        }
    }
    catch (TransformerException e) {
        // should catch it when the resolver explicitly throws the exception
        final ErrorMsg msg = new ErrorMsg(ErrorMsg.INVALID_URI_ERR, href + "\n" + e.getMessage(), this);
        xsltc.getParser().reportError(Constants.FATAL, msg);
    }

    return null;
}
 
Example #17
Source Project: TencentKona-8   Author: Tencent   File: CompareGenerator.java    License: GNU General Public License v2.0 6 votes vote down vote up
public CompareGenerator(int access_flags, Type return_type,
                        Type[] arg_types, String[] arg_names,
                        String method_name, String class_name,
                        InstructionList il, ConstantPoolGen cp) {
    super(access_flags, return_type, arg_types, arg_names, method_name,
          class_name, il, cp);

    _iloadCurrent = new ILOAD(CURRENT_INDEX);
    _istoreCurrent = new ISTORE(CURRENT_INDEX);
    _aloadDom = new ALOAD(DOM_INDEX);
    _iloadLast = new ILOAD(LAST_INDEX);

    LocalVariableGen iterator =
        addLocalVariable("iterator",
                         Util.getJCRefType(Constants.NODE_ITERATOR_SIG),
                         null, null);
    ITERATOR_INDEX = iterator.getIndex();
    _aloadIterator = new ALOAD(ITERATOR_INDEX);
    _astoreIterator = new ASTORE(ITERATOR_INDEX);
    il.append(new ACONST_NULL());
    il.append(storeIterator());
}
 
Example #18
Source Project: jdk8u60   Author: chenghanpeng   File: TransformerFactoryImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * This method implements XSLTC's SourceLoader interface. It is used to
 * glue a TrAX URIResolver to the XSLTC compiler's Input and Import classes.
 *
 * @param href The URI of the document to load
 * @param context The URI of the currently loaded document
 * @param xsltc The compiler that resuests the document
 * @return An InputSource with the loaded document
 */
@Override
public InputSource loadSource(String href, String context, XSLTC xsltc) {
    try {
        if (_uriResolver != null) {
            final Source source = _uriResolver.resolve(href, context);
            if (source != null) {
                return Util.getInputSource(xsltc, source);
            }
        }
    }
    catch (TransformerException e) {
        // should catch it when the resolver explicitly throws the exception
        final ErrorMsg msg = new ErrorMsg(ErrorMsg.INVALID_URI_ERR, href + "\n" + e.getMessage(), this);
        xsltc.getParser().reportError(Constants.FATAL, msg);
    }

    return null;
}
 
Example #19
Source Project: jdk8u60   Author: chenghanpeng   File: StringType.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Translates an external (primitive) Java type into a string.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateFrom
 */
public void translateFrom(ClassGenerator classGen,
    MethodGenerator methodGen, Class clazz)
{
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    if (clazz.getName().equals("java.lang.String")) {
        // same internal representation, convert null to ""
        il.append(DUP);
        final BranchHandle ifNonNull = il.append(new IFNONNULL(null));
        il.append(POP);
        il.append(new PUSH(cpg, ""));
        ifNonNull.setTarget(il.append(NOP));
    }
    else {
        ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                    toString(), clazz.getName());
        classGen.getParser().reportError(Constants.FATAL, err);
    }
}
 
Example #20
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: StringType.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Translates a string into an object of internal type <code>type</code>.
 * The translation to int is undefined since strings are always converted
 * to reals in arithmetic expressions.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        Type type) {
    if (type == Type.Boolean) {
        translateTo(classGen, methodGen, (BooleanType) type);
    }
    else if (type == Type.Real) {
        translateTo(classGen, methodGen, (RealType) type);
    }
    else if (type == Type.Reference) {
        translateTo(classGen, methodGen, (ReferenceType) type);
    }
    else if (type == Type.ObjectString) {
        // NOP -> same representation
    }
    else {
        ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                    toString(), type.toString());
        classGen.getParser().reportError(Constants.FATAL, err);
    }
}
 
Example #21
Source Project: Bytecoder   Author: mirkosertic   File: IntType.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Translates an integer into an object of internal type <code>type</code>.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        final Type type) {
    if (type == Type.Real) {
        translateTo(classGen, methodGen, (RealType) type);
    }
    else if (type == Type.String) {
        translateTo(classGen, methodGen, (StringType) type);
    }
    else if (type == Type.Boolean) {
        translateTo(classGen, methodGen, (BooleanType) type);
    }
    else if (type == Type.Reference) {
        translateTo(classGen, methodGen, (ReferenceType) type);
    }
    else {
        ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                    toString(), type.toString());
        classGen.getParser().reportError(Constants.FATAL, err);
    }
}
 
Example #22
Source Project: hottub   Author: dsrg-uoft   File: TransformerFactoryImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * This method implements XSLTC's SourceLoader interface. It is used to
 * glue a TrAX URIResolver to the XSLTC compiler's Input and Import classes.
 *
 * @param href The URI of the document to load
 * @param context The URI of the currently loaded document
 * @param xsltc The compiler that resuests the document
 * @return An InputSource with the loaded document
 */
@Override
public InputSource loadSource(String href, String context, XSLTC xsltc) {
    try {
        if (_uriResolver != null) {
            final Source source = _uriResolver.resolve(href, context);
            if (source != null) {
                return Util.getInputSource(xsltc, source);
            }
        }
    }
    catch (TransformerException e) {
        // should catch it when the resolver explicitly throws the exception
        final ErrorMsg msg = new ErrorMsg(ErrorMsg.INVALID_URI_ERR, href + "\n" + e.getMessage(), this);
        xsltc.getParser().reportError(Constants.FATAL, msg);
    }

    return null;
}
 
Example #23
Source Project: hottub   Author: dsrg-uoft   File: CompareGenerator.java    License: GNU General Public License v2.0 6 votes vote down vote up
public CompareGenerator(int access_flags, Type return_type,
                        Type[] arg_types, String[] arg_names,
                        String method_name, String class_name,
                        InstructionList il, ConstantPoolGen cp) {
    super(access_flags, return_type, arg_types, arg_names, method_name,
          class_name, il, cp);

    _iloadCurrent = new ILOAD(CURRENT_INDEX);
    _istoreCurrent = new ISTORE(CURRENT_INDEX);
    _aloadDom = new ALOAD(DOM_INDEX);
    _iloadLast = new ILOAD(LAST_INDEX);

    LocalVariableGen iterator =
        addLocalVariable("iterator",
                         Util.getJCRefType(Constants.NODE_ITERATOR_SIG),
                         null, null);
    ITERATOR_INDEX = iterator.getIndex();
    _aloadIterator = new ALOAD(ITERATOR_INDEX);
    _astoreIterator = new ASTORE(ITERATOR_INDEX);
    il.append(new ACONST_NULL());
    il.append(storeIterator());
}
 
Example #24
Source Project: openjdk-8   Author: bpupadhyaya   File: CompareGenerator.java    License: GNU General Public License v2.0 6 votes vote down vote up
public CompareGenerator(int access_flags, Type return_type,
                        Type[] arg_types, String[] arg_names,
                        String method_name, String class_name,
                        InstructionList il, ConstantPoolGen cp) {
    super(access_flags, return_type, arg_types, arg_names, method_name,
          class_name, il, cp);

    _iloadCurrent = new ILOAD(CURRENT_INDEX);
    _istoreCurrent = new ISTORE(CURRENT_INDEX);
    _aloadDom = new ALOAD(DOM_INDEX);
    _iloadLast = new ILOAD(LAST_INDEX);

    LocalVariableGen iterator =
        addLocalVariable("iterator",
                         Util.getJCRefType(Constants.NODE_ITERATOR_SIG),
                         null, null);
    ITERATOR_INDEX = iterator.getIndex();
    _aloadIterator = new ALOAD(ITERATOR_INDEX);
    _astoreIterator = new ASTORE(ITERATOR_INDEX);
    il.append(new ACONST_NULL());
    il.append(storeIterator());
}
 
Example #25
Source Project: jdk8u60   Author: chenghanpeng   File: CompareGenerator.java    License: GNU General Public License v2.0 6 votes vote down vote up
public CompareGenerator(int access_flags, Type return_type,
                        Type[] arg_types, String[] arg_names,
                        String method_name, String class_name,
                        InstructionList il, ConstantPoolGen cp) {
    super(access_flags, return_type, arg_types, arg_names, method_name,
          class_name, il, cp);

    _iloadCurrent = new ILOAD(CURRENT_INDEX);
    _istoreCurrent = new ISTORE(CURRENT_INDEX);
    _aloadDom = new ALOAD(DOM_INDEX);
    _iloadLast = new ILOAD(LAST_INDEX);

    LocalVariableGen iterator =
        addLocalVariable("iterator",
                         Util.getJCRefType(Constants.NODE_ITERATOR_SIG),
                         null, null);
    ITERATOR_INDEX = iterator.getIndex();
    _aloadIterator = new ALOAD(ITERATOR_INDEX);
    _astoreIterator = new ASTORE(ITERATOR_INDEX);
    il.append(new ACONST_NULL());
    il.append(storeIterator());
}
 
Example #26
Source Project: hottub   Author: dsrg-uoft   File: ObjectType.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Translates a void into an object of internal type <code>type</code>.
 * This translation is needed when calling external functions
 * that return void.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        Type type) {
    if (type == Type.String) {
        translateTo(classGen, methodGen, (StringType) type);
    }
    else {
        ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                    toString(), type.toString());
        classGen.getParser().reportError(Constants.FATAL, err);
    }
}
 
Example #27
Source Project: JDKSourceCode1.8   Author: wupeixuan   File: IntType.java    License: MIT License 5 votes vote down vote up
/**
 * Translates an integer into the Java type denoted by <code>clazz</code>.
 * Expects an integer on the stack and pushes a number of the appropriate
 * type after coercion.
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        Class clazz) {
    final InstructionList il = methodGen.getInstructionList();
    if (clazz == Character.TYPE) {
        il.append(I2C);
    }
    else if (clazz == Byte.TYPE) {
        il.append(I2B);
    }
    else if (clazz == Short.TYPE) {
        il.append(I2S);
    }
    else if (clazz == Integer.TYPE) {
        il.append(NOP);
    }
    else if (clazz == Long.TYPE) {
        il.append(I2L);
    }
    else if (clazz == Float.TYPE) {
        il.append(I2F);
    }
    else if (clazz == Double.TYPE) {
        il.append(I2D);
    }
     // Is Double <: clazz? I.e. clazz in { Double, Number, Object }
   else if (clazz.isAssignableFrom(java.lang.Double.class)) {
       il.append(I2D);
       Type.Real.translateTo(classGen, methodGen, Type.Reference);
    }
    else {
        ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                    toString(), clazz.getName());
        classGen.getParser().reportError(Constants.FATAL, err);
    }
}
 
Example #28
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: StringType.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Translates a internal string into an external (Java) string.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateFrom
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        Class clazz)
{
    // Is String <: clazz? I.e. clazz in { String, Object }
    if (clazz.isAssignableFrom(java.lang.String.class)) {
        methodGen.getInstructionList().append(NOP);
    }
    else {
        ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                    toString(), clazz.getName());
        classGen.getParser().reportError(Constants.FATAL, err);
    }
}
 
Example #29
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: NodeType.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Expects a node on the stack and pushes its string value.
 *
 * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        StringType type) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    switch (_type) {
    case NodeTest.ROOT:
    case NodeTest.ELEMENT:
        il.append(methodGen.loadDOM());
        il.append(SWAP); // dom ref must be below node index
        int index = cpg.addInterfaceMethodref(DOM_INTF,
                                              GET_ELEMENT_VALUE,
                                              GET_ELEMENT_VALUE_SIG);
        il.append(new INVOKEINTERFACE(index, 2));
        break;

    case NodeTest.ANODE:
    case NodeTest.COMMENT:
    case NodeTest.ATTRIBUTE:
    case NodeTest.PI:
        il.append(methodGen.loadDOM());
        il.append(SWAP); // dom ref must be below node index
        index = cpg.addInterfaceMethodref(DOM_INTF,
                                          GET_NODE_VALUE,
                                          GET_NODE_VALUE_SIG);
        il.append(new INVOKEINTERFACE(index, 2));
        break;

    default:
        ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                    toString(), type.toString());
        classGen.getParser().reportError(Constants.FATAL, err);
        break;
    }
}
 
Example #30
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: Type.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Translates an object of this type to the external (Java) type denoted
 * by <code>clazz</code>. This method is used to translate parameters
 * when external functions are called.
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
                        Class clazz) {
    ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                toString(), clazz.getClass().toString());
    classGen.getParser().reportError(Constants.FATAL, err);
}