Java Code Examples for com.sun.org.apache.xalan.internal.xsltc.runtime.BasisLibrary#mapQNameToJavaName()

The following examples show how to use com.sun.org.apache.xalan.internal.xsltc.runtime.BasisLibrary#mapQNameToJavaName() . 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: Param.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    if (_ignore) return;
    _ignore = true;

    /*
     * To fix bug 24518 related to setting parameters of the form
     * {namespaceuri}localName which will get mapped to an instance
     * variable in the class.
     */
    final String name = BasisLibrary.mapQNameToJavaName(_name.toString());
    final String signature = _type.toSignature();
    final String className = _type.getClassName();

    if (isLocal()) {
        /*
          * If simple named template then generate a conditional init of the
          * param using its default value:
          *       if (param == null) param = <default-value>
          */
        if (_isInSimpleNamedTemplate) {
            il.append(loadInstruction());
            BranchHandle ifBlock = il.append(new IFNONNULL(null));
            translateValue(classGen, methodGen);
            il.append(storeInstruction());
            ifBlock.setTarget(il.append(NOP));
            return;
        }

        il.append(classGen.loadTranslet());
        il.append(new PUSH(cpg, name));
        translateValue(classGen, methodGen);
        il.append(new PUSH(cpg, true));

        // Call addParameter() from this class
        il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS,
                                                     ADD_PARAMETER,
                                                     ADD_PARAMETER_SIG)));
        if (className != EMPTYSTRING) {
            il.append(new CHECKCAST(cpg.addClass(className)));
        }

        _type.translateUnBox(classGen, methodGen);

        if (_refs.isEmpty()) { // nobody uses the value
            il.append(_type.POP());
            _local = null;
        }
        else {              // normal case
            _local = methodGen.addLocalVariable2(name,
                                                 _type.toJCType(),
                                                 il.getEnd());
            // Cache the result of addParameter() in a local variable
            il.append(_type.STORE(_local.getIndex()));
        }
    }
    else {
        if (classGen.containsField(name) == null) {
            classGen.addField(new Field(ACC_PUBLIC, cpg.addUtf8(name),
                                        cpg.addUtf8(signature),
                                        null, cpg.getConstantPool()));
            il.append(classGen.loadTranslet());
            il.append(DUP);
            il.append(new PUSH(cpg, name));
            translateValue(classGen, methodGen);
            il.append(new PUSH(cpg, true));

            // Call addParameter() from this class
            il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS,
                                                 ADD_PARAMETER,
                                                 ADD_PARAMETER_SIG)));

            _type.translateUnBox(classGen, methodGen);

            // Cache the result of addParameter() in a field
            if (className != EMPTYSTRING) {
                il.append(new CHECKCAST(cpg.addClass(className)));
            }
            il.append(new PUTFIELD(cpg.addFieldref(classGen.getClassName(),
                                                   name, signature)));
        }
    }
}
 
Example 2
Source File: Param.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    if (_ignore) return;
    _ignore = true;

    /*
     * To fix bug 24518 related to setting parameters of the form
     * {namespaceuri}localName which will get mapped to an instance
     * variable in the class.
     */
    final String name = BasisLibrary.mapQNameToJavaName(_name.toString());
    final String signature = _type.toSignature();
    final String className = _type.getClassName();

    if (isLocal()) {
        /*
          * If simple named template then generate a conditional init of the
          * param using its default value:
          *       if (param == null) param = <default-value>
          */
        if (_isInSimpleNamedTemplate) {
            il.append(loadInstruction());
            BranchHandle ifBlock = il.append(new IFNONNULL(null));
            translateValue(classGen, methodGen);
            il.append(storeInstruction());
            ifBlock.setTarget(il.append(NOP));
            return;
        }

        il.append(classGen.loadTranslet());
        il.append(new PUSH(cpg, name));
        translateValue(classGen, methodGen);
        il.append(new PUSH(cpg, true));

        // Call addParameter() from this class
        il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS,
                                                     ADD_PARAMETER,
                                                     ADD_PARAMETER_SIG)));
        if (className != EMPTYSTRING) {
            il.append(new CHECKCAST(cpg.addClass(className)));
        }

        _type.translateUnBox(classGen, methodGen);

        if (_refs.isEmpty()) { // nobody uses the value
            il.append(_type.POP());
            _local = null;
        }
        else {              // normal case
            _local = methodGen.addLocalVariable2(name,
                                                 _type.toJCType(),
                                                 il.getEnd());
            // Cache the result of addParameter() in a local variable
            il.append(_type.STORE(_local.getIndex()));
        }
    }
    else {
        if (classGen.containsField(name) == null) {
            classGen.addField(new Field(ACC_PUBLIC, cpg.addUtf8(name),
                                        cpg.addUtf8(signature),
                                        null, cpg.getConstantPool()));
            il.append(classGen.loadTranslet());
            il.append(DUP);
            il.append(new PUSH(cpg, name));
            translateValue(classGen, methodGen);
            il.append(new PUSH(cpg, true));

            // Call addParameter() from this class
            il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS,
                                                 ADD_PARAMETER,
                                                 ADD_PARAMETER_SIG)));

            _type.translateUnBox(classGen, methodGen);

            // Cache the result of addParameter() in a field
            if (className != EMPTYSTRING) {
                il.append(new CHECKCAST(cpg.addClass(className)));
            }
            il.append(new PUTFIELD(cpg.addFieldref(classGen.getClassName(),
                                                   name, signature)));
        }
    }
}
 
Example 3
Source File: Param.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    if (_ignore) return;
    _ignore = true;

    /*
     * To fix bug 24518 related to setting parameters of the form
     * {namespaceuri}localName which will get mapped to an instance
     * variable in the class.
     */
    final String name = BasisLibrary.mapQNameToJavaName(_name.toString());
    final String signature = _type.toSignature();
    final String className = _type.getClassName();

    if (isLocal()) {
        /*
          * If simple named template then generate a conditional init of the
          * param using its default value:
          *       if (param == null) param = <default-value>
          */
        if (_isInSimpleNamedTemplate) {
            il.append(loadInstruction());
            BranchHandle ifBlock = il.append(new IFNONNULL(null));
            translateValue(classGen, methodGen);
            il.append(storeInstruction());
            ifBlock.setTarget(il.append(NOP));
            return;
        }

        il.append(classGen.loadTranslet());
        il.append(new PUSH(cpg, name));
        translateValue(classGen, methodGen);
        il.append(new PUSH(cpg, true));

        // Call addParameter() from this class
        il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS,
                                                     ADD_PARAMETER,
                                                     ADD_PARAMETER_SIG)));
        if (className != EMPTYSTRING) {
            il.append(new CHECKCAST(cpg.addClass(className)));
        }

        _type.translateUnBox(classGen, methodGen);

        if (_refs.isEmpty()) { // nobody uses the value
            il.append(_type.POP());
            _local = null;
        }
        else {              // normal case
            _local = methodGen.addLocalVariable2(name,
                                                 _type.toJCType(),
                                                 il.getEnd());
            // Cache the result of addParameter() in a local variable
            il.append(_type.STORE(_local.getIndex()));
        }
    }
    else {
        if (classGen.containsField(name) == null) {
            classGen.addField(new Field(ACC_PUBLIC, cpg.addUtf8(name),
                                        cpg.addUtf8(signature),
                                        null, cpg.getConstantPool()));
            il.append(classGen.loadTranslet());
            il.append(DUP);
            il.append(new PUSH(cpg, name));
            translateValue(classGen, methodGen);
            il.append(new PUSH(cpg, true));

            // Call addParameter() from this class
            il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS,
                                                 ADD_PARAMETER,
                                                 ADD_PARAMETER_SIG)));

            _type.translateUnBox(classGen, methodGen);

            // Cache the result of addParameter() in a field
            if (className != EMPTYSTRING) {
                il.append(new CHECKCAST(cpg.addClass(className)));
            }
            il.append(new PUTFIELD(cpg.addFieldref(classGen.getClassName(),
                                                   name, signature)));
        }
    }
}
 
Example 4
Source File: ParameterRef.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    /*
     * To fix bug 24518 related to setting parameters of the form
     * {namespaceuri}localName, which will get mapped to an instance
     * variable in the class.
     */
    final String name = BasisLibrary.mapQNameToJavaName (_name.toString());
    final String signature = _type.toSignature();

    if (_variable.isLocal()) {
        if (classGen.isExternal()) {
            Closure variableClosure = _closure;
            while (variableClosure != null) {
                if (variableClosure.inInnerClass()) break;
                variableClosure = variableClosure.getParentClosure();
            }

            if (variableClosure != null) {
                il.append(ALOAD_0);
                il.append(new GETFIELD(
                    cpg.addFieldref(variableClosure.getInnerClassName(),
                        name, signature)));
            }
            else {
                il.append(_variable.loadInstruction());
            }
        }
        else {
            il.append(_variable.loadInstruction());
        }
    }
    else {
        final String className = classGen.getClassName();
        il.append(classGen.loadTranslet());
        if (classGen.isExternal()) {
            il.append(new CHECKCAST(cpg.addClass(className)));
        }
        il.append(new GETFIELD(cpg.addFieldref(className,name,signature)));
    }

    if (_variable.getType() instanceof NodeSetType) {
        // The method cloneIterator() also does resetting
        final int clone = cpg.addInterfaceMethodref(NODE_ITERATOR,
                                                   "cloneIterator",
                                                   "()" +
                                                    NODE_ITERATOR_SIG);
        il.append(new INVOKEINTERFACE(clone, 1));
    }
}
 
Example 5
Source File: Param.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    if (_ignore) return;
    _ignore = true;

    /*
     * To fix bug 24518 related to setting parameters of the form
     * {namespaceuri}localName which will get mapped to an instance
     * variable in the class.
     */
    final String name = BasisLibrary.mapQNameToJavaName(_name.toString());
    final String signature = _type.toSignature();
    final String className = _type.getClassName();

    if (isLocal()) {
        /*
          * If simple named template then generate a conditional init of the
          * param using its default value:
          *       if (param == null) param = <default-value>
          */
        if (_isInSimpleNamedTemplate) {
            il.append(loadInstruction());
            BranchHandle ifBlock = il.append(new IFNONNULL(null));
            translateValue(classGen, methodGen);
            il.append(storeInstruction());
            ifBlock.setTarget(il.append(NOP));
            return;
        }

        il.append(classGen.loadTranslet());
        il.append(new PUSH(cpg, name));
        translateValue(classGen, methodGen);
        il.append(new PUSH(cpg, true));

        // Call addParameter() from this class
        il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS,
                                                     ADD_PARAMETER,
                                                     ADD_PARAMETER_SIG)));
        if (className != EMPTYSTRING) {
            il.append(new CHECKCAST(cpg.addClass(className)));
        }

        _type.translateUnBox(classGen, methodGen);

        if (_refs.isEmpty()) { // nobody uses the value
            il.append(_type.POP());
            _local = null;
        }
        else {              // normal case
            _local = methodGen.addLocalVariable2(name,
                                                 _type.toJCType(),
                                                 il.getEnd());
            // Cache the result of addParameter() in a local variable
            il.append(_type.STORE(_local.getIndex()));
        }
    }
    else {
        if (classGen.containsField(name) == null) {
            classGen.addField(new Field(ACC_PUBLIC, cpg.addUtf8(name),
                                        cpg.addUtf8(signature),
                                        null, cpg.getConstantPool()));
            il.append(classGen.loadTranslet());
            il.append(DUP);
            il.append(new PUSH(cpg, name));
            translateValue(classGen, methodGen);
            il.append(new PUSH(cpg, true));

            // Call addParameter() from this class
            il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS,
                                                 ADD_PARAMETER,
                                                 ADD_PARAMETER_SIG)));

            _type.translateUnBox(classGen, methodGen);

            // Cache the result of addParameter() in a field
            if (className != EMPTYSTRING) {
                il.append(new CHECKCAST(cpg.addClass(className)));
            }
            il.append(new PUTFIELD(cpg.addFieldref(classGen.getClassName(),
                                                   name, signature)));
        }
    }
}
 
Example 6
Source File: ParameterRef.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    /*
     * To fix bug 24518 related to setting parameters of the form
     * {namespaceuri}localName, which will get mapped to an instance
     * variable in the class.
     */
    final String name = BasisLibrary.mapQNameToJavaName (_name.toString());
    final String signature = _type.toSignature();

    if (_variable.isLocal()) {
        if (classGen.isExternal()) {
            Closure variableClosure = _closure;
            while (variableClosure != null) {
                if (variableClosure.inInnerClass()) break;
                variableClosure = variableClosure.getParentClosure();
            }

            if (variableClosure != null) {
                il.append(ALOAD_0);
                il.append(new GETFIELD(
                    cpg.addFieldref(variableClosure.getInnerClassName(),
                        name, signature)));
            }
            else {
                il.append(_variable.loadInstruction());
            }
        }
        else {
            il.append(_variable.loadInstruction());
        }
    }
    else {
        final String className = classGen.getClassName();
        il.append(classGen.loadTranslet());
        if (classGen.isExternal()) {
            il.append(new CHECKCAST(cpg.addClass(className)));
        }
        il.append(new GETFIELD(cpg.addFieldref(className,name,signature)));
    }

    if (_variable.getType() instanceof NodeSetType) {
        // The method cloneIterator() also does resetting
        final int clone = cpg.addInterfaceMethodref(NODE_ITERATOR,
                                                   "cloneIterator",
                                                   "()" +
                                                    NODE_ITERATOR_SIG);
        il.append(new INVOKEINTERFACE(clone, 1));
    }
}
 
Example 7
Source File: ParameterRef.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    /*
     * To fix bug 24518 related to setting parameters of the form
     * {namespaceuri}localName, which will get mapped to an instance
     * variable in the class.
     */
    final String name = BasisLibrary.mapQNameToJavaName (_name.toString());
    final String signature = _type.toSignature();

    if (_variable.isLocal()) {
        if (classGen.isExternal()) {
            Closure variableClosure = _closure;
            while (variableClosure != null) {
                if (variableClosure.inInnerClass()) break;
                variableClosure = variableClosure.getParentClosure();
            }

            if (variableClosure != null) {
                il.append(ALOAD_0);
                il.append(new GETFIELD(
                    cpg.addFieldref(variableClosure.getInnerClassName(),
                        name, signature)));
            }
            else {
                il.append(_variable.loadInstruction());
            }
        }
        else {
            il.append(_variable.loadInstruction());
        }
    }
    else {
        final String className = classGen.getClassName();
        il.append(classGen.loadTranslet());
        if (classGen.isExternal()) {
            il.append(new CHECKCAST(cpg.addClass(className)));
        }
        il.append(new GETFIELD(cpg.addFieldref(className,name,signature)));
    }

    if (_variable.getType() instanceof NodeSetType) {
        // The method cloneIterator() also does resetting
        final int clone = cpg.addInterfaceMethodref(NODE_ITERATOR,
                                                   "cloneIterator",
                                                   "()" +
                                                    NODE_ITERATOR_SIG);
        il.append(new INVOKEINTERFACE(clone, 1));
    }
}
 
Example 8
Source File: ParameterRef.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    /*
     * To fix bug 24518 related to setting parameters of the form
     * {namespaceuri}localName, which will get mapped to an instance
     * variable in the class.
     */
    final String name = BasisLibrary.mapQNameToJavaName (_name.toString());
    final String signature = _type.toSignature();

    if (_variable.isLocal()) {
        if (classGen.isExternal()) {
            Closure variableClosure = _closure;
            while (variableClosure != null) {
                if (variableClosure.inInnerClass()) break;
                variableClosure = variableClosure.getParentClosure();
            }

            if (variableClosure != null) {
                il.append(ALOAD_0);
                il.append(new GETFIELD(
                    cpg.addFieldref(variableClosure.getInnerClassName(),
                        name, signature)));
            }
            else {
                il.append(_variable.loadInstruction());
            }
        }
        else {
            il.append(_variable.loadInstruction());
        }
    }
    else {
        final String className = classGen.getClassName();
        il.append(classGen.loadTranslet());
        if (classGen.isExternal()) {
            il.append(new CHECKCAST(cpg.addClass(className)));
        }
        il.append(new GETFIELD(cpg.addFieldref(className,name,signature)));
    }

    if (_variable.getType() instanceof NodeSetType) {
        // The method cloneIterator() also does resetting
        final int clone = cpg.addInterfaceMethodref(NODE_ITERATOR,
                                                   "cloneIterator",
                                                   "()" +
                                                    NODE_ITERATOR_SIG);
        il.append(new INVOKEINTERFACE(clone, 1));
    }
}
 
Example 9
Source File: Param.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    if (_ignore) return;
    _ignore = true;

    /*
     * To fix bug 24518 related to setting parameters of the form
     * {namespaceuri}localName which will get mapped to an instance
     * variable in the class.
     */
    final String name = BasisLibrary.mapQNameToJavaName(_name.toString());
    final String signature = _type.toSignature();
    final String className = _type.getClassName();

    if (isLocal()) {
        /*
          * If simple named template then generate a conditional init of the
          * param using its default value:
          *       if (param == null) param = <default-value>
          */
        if (_isInSimpleNamedTemplate) {
            il.append(loadInstruction());
            BranchHandle ifBlock = il.append(new IFNONNULL(null));
            translateValue(classGen, methodGen);
            il.append(storeInstruction());
            ifBlock.setTarget(il.append(NOP));
            return;
        }

        il.append(classGen.loadTranslet());
        il.append(new PUSH(cpg, name));
        translateValue(classGen, methodGen);
        il.append(new PUSH(cpg, true));

        // Call addParameter() from this class
        il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS,
                                                     ADD_PARAMETER,
                                                     ADD_PARAMETER_SIG)));
        if (className != EMPTYSTRING) {
            il.append(new CHECKCAST(cpg.addClass(className)));
        }

        _type.translateUnBox(classGen, methodGen);

        if (_refs.isEmpty()) { // nobody uses the value
            il.append(_type.POP());
            _local = null;
        }
        else {              // normal case
            _local = methodGen.addLocalVariable2(name,
                                                 _type.toJCType(),
                                                 il.getEnd());
            // Cache the result of addParameter() in a local variable
            il.append(_type.STORE(_local.getIndex()));
        }
    }
    else {
        if (classGen.containsField(name) == null) {
            classGen.addField(new Field(ACC_PUBLIC, cpg.addUtf8(name),
                                        cpg.addUtf8(signature),
                                        null, cpg.getConstantPool()));
            il.append(classGen.loadTranslet());
            il.append(DUP);
            il.append(new PUSH(cpg, name));
            translateValue(classGen, methodGen);
            il.append(new PUSH(cpg, true));

            // Call addParameter() from this class
            il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS,
                                                 ADD_PARAMETER,
                                                 ADD_PARAMETER_SIG)));

            _type.translateUnBox(classGen, methodGen);

            // Cache the result of addParameter() in a field
            if (className != EMPTYSTRING) {
                il.append(new CHECKCAST(cpg.addClass(className)));
            }
            il.append(new PUTFIELD(cpg.addFieldref(classGen.getClassName(),
                                                   name, signature)));
        }
    }
}
 
Example 10
Source File: ParameterRef.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    /*
     * To fix bug 24518 related to setting parameters of the form
     * {namespaceuri}localName, which will get mapped to an instance
     * variable in the class.
     */
    final String name = BasisLibrary.mapQNameToJavaName (_name.toString());
    final String signature = _type.toSignature();

    if (_variable.isLocal()) {
        if (classGen.isExternal()) {
            Closure variableClosure = _closure;
            while (variableClosure != null) {
                if (variableClosure.inInnerClass()) break;
                variableClosure = variableClosure.getParentClosure();
            }

            if (variableClosure != null) {
                il.append(ALOAD_0);
                il.append(new GETFIELD(
                    cpg.addFieldref(variableClosure.getInnerClassName(),
                        name, signature)));
            }
            else {
                il.append(_variable.loadInstruction());
            }
        }
        else {
            il.append(_variable.loadInstruction());
        }
    }
    else {
        final String className = classGen.getClassName();
        il.append(classGen.loadTranslet());
        if (classGen.isExternal()) {
            il.append(new CHECKCAST(cpg.addClass(className)));
        }
        il.append(new GETFIELD(cpg.addFieldref(className,name,signature)));
    }

    if (_variable.getType() instanceof NodeSetType) {
        // The method cloneIterator() also does resetting
        final int clone = cpg.addInterfaceMethodref(NODE_ITERATOR,
                                                   "cloneIterator",
                                                   "()" +
                                                    NODE_ITERATOR_SIG);
        il.append(new INVOKEINTERFACE(clone, 1));
    }
}
 
Example 11
Source File: Param.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    if (_ignore) return;
    _ignore = true;

    /*
     * To fix bug 24518 related to setting parameters of the form
     * {namespaceuri}localName which will get mapped to an instance
     * variable in the class.
     */
    final String name = BasisLibrary.mapQNameToJavaName(_name.toString());
    final String signature = _type.toSignature();
    final String className = _type.getClassName();

    if (isLocal()) {
        /*
          * If simple named template then generate a conditional init of the
          * param using its default value:
          *       if (param == null) param = <default-value>
          */
        if (_isInSimpleNamedTemplate) {
            il.append(loadInstruction());
            BranchHandle ifBlock = il.append(new IFNONNULL(null));
            translateValue(classGen, methodGen);
            il.append(storeInstruction());
            ifBlock.setTarget(il.append(NOP));
            return;
        }

        il.append(classGen.loadTranslet());
        il.append(new PUSH(cpg, name));
        translateValue(classGen, methodGen);
        il.append(new PUSH(cpg, true));

        // Call addParameter() from this class
        il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS,
                                                     ADD_PARAMETER,
                                                     ADD_PARAMETER_SIG)));
        if (className != EMPTYSTRING) {
            il.append(new CHECKCAST(cpg.addClass(className)));
        }

        _type.translateUnBox(classGen, methodGen);

        if (_refs.isEmpty()) { // nobody uses the value
            il.append(_type.POP());
            _local = null;
        }
        else {              // normal case
            _local = methodGen.addLocalVariable2(name,
                                                 _type.toJCType(),
                                                 il.getEnd());
            // Cache the result of addParameter() in a local variable
            il.append(_type.STORE(_local.getIndex()));
        }
    }
    else {
        if (classGen.containsField(name) == null) {
            classGen.addField(new Field(ACC_PUBLIC, cpg.addUtf8(name),
                                        cpg.addUtf8(signature),
                                        null, cpg.getConstantPool()));
            il.append(classGen.loadTranslet());
            il.append(DUP);
            il.append(new PUSH(cpg, name));
            translateValue(classGen, methodGen);
            il.append(new PUSH(cpg, true));

            // Call addParameter() from this class
            il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS,
                                                 ADD_PARAMETER,
                                                 ADD_PARAMETER_SIG)));

            _type.translateUnBox(classGen, methodGen);

            // Cache the result of addParameter() in a field
            if (className != EMPTYSTRING) {
                il.append(new CHECKCAST(cpg.addClass(className)));
            }
            il.append(new PUTFIELD(cpg.addFieldref(classGen.getClassName(),
                                                   name, signature)));
        }
    }
}
 
Example 12
Source File: ParameterRef.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    /*
     * To fix bug 24518 related to setting parameters of the form
     * {namespaceuri}localName, which will get mapped to an instance
     * variable in the class.
     */
    final String name = BasisLibrary.mapQNameToJavaName (_name.toString());
    final String signature = _type.toSignature();

    if (_variable.isLocal()) {
        if (classGen.isExternal()) {
            Closure variableClosure = _closure;
            while (variableClosure != null) {
                if (variableClosure.inInnerClass()) break;
                variableClosure = variableClosure.getParentClosure();
            }

            if (variableClosure != null) {
                il.append(ALOAD_0);
                il.append(new GETFIELD(
                    cpg.addFieldref(variableClosure.getInnerClassName(),
                        name, signature)));
            }
            else {
                il.append(_variable.loadInstruction());
            }
        }
        else {
            il.append(_variable.loadInstruction());
        }
    }
    else {
        final String className = classGen.getClassName();
        il.append(classGen.loadTranslet());
        if (classGen.isExternal()) {
            il.append(new CHECKCAST(cpg.addClass(className)));
        }
        il.append(new GETFIELD(cpg.addFieldref(className,name,signature)));
    }

    if (_variable.getType() instanceof NodeSetType) {
        // The method cloneIterator() also does resetting
        final int clone = cpg.addInterfaceMethodref(NODE_ITERATOR,
                                                   "cloneIterator",
                                                   "()" +
                                                    NODE_ITERATOR_SIG);
        il.append(new INVOKEINTERFACE(clone, 1));
    }
}
 
Example 13
Source File: Param.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    if (_ignore) return;
    _ignore = true;

    /*
     * To fix bug 24518 related to setting parameters of the form
     * {namespaceuri}localName which will get mapped to an instance
     * variable in the class.
     */
    final String name = BasisLibrary.mapQNameToJavaName(_name.toString());
    final String signature = _type.toSignature();
    final String className = _type.getClassName();

    if (isLocal()) {
        /*
          * If simple named template then generate a conditional init of the
          * param using its default value:
          *       if (param == null) param = <default-value>
          */
        if (_isInSimpleNamedTemplate) {
            il.append(loadInstruction());
            BranchHandle ifBlock = il.append(new IFNONNULL(null));
            translateValue(classGen, methodGen);
            il.append(storeInstruction());
            ifBlock.setTarget(il.append(NOP));
            return;
        }

        il.append(classGen.loadTranslet());
        il.append(new PUSH(cpg, name));
        translateValue(classGen, methodGen);
        il.append(new PUSH(cpg, true));

        // Call addParameter() from this class
        il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS,
                                                     ADD_PARAMETER,
                                                     ADD_PARAMETER_SIG)));
        if (className != EMPTYSTRING) {
            il.append(new CHECKCAST(cpg.addClass(className)));
        }

        _type.translateUnBox(classGen, methodGen);

        if (_refs.isEmpty()) { // nobody uses the value
            il.append(_type.POP());
            _local = null;
        }
        else {              // normal case
            _local = methodGen.addLocalVariable2(name,
                                                 _type.toJCType(),
                                                 il.getEnd());
            // Cache the result of addParameter() in a local variable
            il.append(_type.STORE(_local.getIndex()));
        }
    }
    else {
        if (classGen.containsField(name) == null) {
            classGen.addField(new Field(ACC_PUBLIC, cpg.addUtf8(name),
                                        cpg.addUtf8(signature),
                                        null, cpg.getConstantPool()));
            il.append(classGen.loadTranslet());
            il.append(DUP);
            il.append(new PUSH(cpg, name));
            translateValue(classGen, methodGen);
            il.append(new PUSH(cpg, true));

            // Call addParameter() from this class
            il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS,
                                                 ADD_PARAMETER,
                                                 ADD_PARAMETER_SIG)));

            _type.translateUnBox(classGen, methodGen);

            // Cache the result of addParameter() in a field
            if (className != EMPTYSTRING) {
                il.append(new CHECKCAST(cpg.addClass(className)));
            }
            il.append(new PUTFIELD(cpg.addFieldref(classGen.getClassName(),
                                                   name, signature)));
        }
    }
}
 
Example 14
Source File: ParameterRef.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    /*
     * To fix bug 24518 related to setting parameters of the form
     * {namespaceuri}localName, which will get mapped to an instance
     * variable in the class.
     */
    final String name = BasisLibrary.mapQNameToJavaName (_name.toString());
    final String signature = _type.toSignature();

    if (_variable.isLocal()) {
        if (classGen.isExternal()) {
            Closure variableClosure = _closure;
            while (variableClosure != null) {
                if (variableClosure.inInnerClass()) break;
                variableClosure = variableClosure.getParentClosure();
            }

            if (variableClosure != null) {
                il.append(ALOAD_0);
                il.append(new GETFIELD(
                    cpg.addFieldref(variableClosure.getInnerClassName(),
                        name, signature)));
            }
            else {
                il.append(_variable.loadInstruction());
            }
        }
        else {
            il.append(_variable.loadInstruction());
        }
    }
    else {
        final String className = classGen.getClassName();
        il.append(classGen.loadTranslet());
        if (classGen.isExternal()) {
            il.append(new CHECKCAST(cpg.addClass(className)));
        }
        il.append(new GETFIELD(cpg.addFieldref(className,name,signature)));
    }

    if (_variable.getType() instanceof NodeSetType) {
        // The method cloneIterator() also does resetting
        final int clone = cpg.addInterfaceMethodref(NODE_ITERATOR,
                                                   "cloneIterator",
                                                   "()" +
                                                    NODE_ITERATOR_SIG);
        il.append(new INVOKEINTERFACE(clone, 1));
    }
}
 
Example 15
Source File: Param.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    if (_ignore) return;
    _ignore = true;

    /*
     * To fix bug 24518 related to setting parameters of the form
     * {namespaceuri}localName which will get mapped to an instance
     * variable in the class.
     */
    final String name = BasisLibrary.mapQNameToJavaName(_name.toString());
    final String signature = _type.toSignature();
    final String className = _type.getClassName();

    if (isLocal()) {
        /*
          * If simple named template then generate a conditional init of the
          * param using its default value:
          *       if (param == null) param = <default-value>
          */
        if (_isInSimpleNamedTemplate) {
            il.append(loadInstruction());
            BranchHandle ifBlock = il.append(new IFNONNULL(null));
            translateValue(classGen, methodGen);
            il.append(storeInstruction());
            ifBlock.setTarget(il.append(NOP));
            return;
        }

        il.append(classGen.loadTranslet());
        il.append(new PUSH(cpg, name));
        translateValue(classGen, methodGen);
        il.append(new PUSH(cpg, true));

        // Call addParameter() from this class
        il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS,
                                                     ADD_PARAMETER,
                                                     ADD_PARAMETER_SIG)));
        if (className != EMPTYSTRING) {
            il.append(new CHECKCAST(cpg.addClass(className)));
        }

        _type.translateUnBox(classGen, methodGen);

        if (_refs.isEmpty()) { // nobody uses the value
            il.append(_type.POP());
            _local = null;
        }
        else {              // normal case
            _local = methodGen.addLocalVariable2(name,
                                                 _type.toJCType(),
                                                 il.getEnd());
            // Cache the result of addParameter() in a local variable
            il.append(_type.STORE(_local.getIndex()));
        }
    }
    else {
        if (classGen.containsField(name) == null) {
            classGen.addField(new Field(ACC_PUBLIC, cpg.addUtf8(name),
                                        cpg.addUtf8(signature),
                                        null, cpg.getConstantPool()));
            il.append(classGen.loadTranslet());
            il.append(DUP);
            il.append(new PUSH(cpg, name));
            translateValue(classGen, methodGen);
            il.append(new PUSH(cpg, true));

            // Call addParameter() from this class
            il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS,
                                                 ADD_PARAMETER,
                                                 ADD_PARAMETER_SIG)));

            _type.translateUnBox(classGen, methodGen);

            // Cache the result of addParameter() in a field
            if (className != EMPTYSTRING) {
                il.append(new CHECKCAST(cpg.addClass(className)));
            }
            il.append(new PUTFIELD(cpg.addFieldref(classGen.getClassName(),
                                                   name, signature)));
        }
    }
}
 
Example 16
Source File: ParameterRef.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    /*
     * To fix bug 24518 related to setting parameters of the form
     * {namespaceuri}localName, which will get mapped to an instance
     * variable in the class.
     */
    final String name = BasisLibrary.mapQNameToJavaName (_name.toString());
    final String signature = _type.toSignature();

    if (_variable.isLocal()) {
        if (classGen.isExternal()) {
            Closure variableClosure = _closure;
            while (variableClosure != null) {
                if (variableClosure.inInnerClass()) break;
                variableClosure = variableClosure.getParentClosure();
            }

            if (variableClosure != null) {
                il.append(ALOAD_0);
                il.append(new GETFIELD(
                    cpg.addFieldref(variableClosure.getInnerClassName(),
                        name, signature)));
            }
            else {
                il.append(_variable.loadInstruction());
            }
        }
        else {
            il.append(_variable.loadInstruction());
        }
    }
    else {
        final String className = classGen.getClassName();
        il.append(classGen.loadTranslet());
        if (classGen.isExternal()) {
            il.append(new CHECKCAST(cpg.addClass(className)));
        }
        il.append(new GETFIELD(cpg.addFieldref(className,name,signature)));
    }

    if (_variable.getType() instanceof NodeSetType) {
        // The method cloneIterator() also does resetting
        final int clone = cpg.addInterfaceMethodref(NODE_ITERATOR,
                                                   "cloneIterator",
                                                   "()" +
                                                    NODE_ITERATOR_SIG);
        il.append(new INVOKEINTERFACE(clone, 1));
    }
}
 
Example 17
Source File: Param.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    if (_ignore) return;
    _ignore = true;

    /*
     * To fix bug 24518 related to setting parameters of the form
     * {namespaceuri}localName which will get mapped to an instance
     * variable in the class.
     */
    final String name = BasisLibrary.mapQNameToJavaName(_name.toString());
    final String signature = _type.toSignature();
    final String className = _type.getClassName();

    if (isLocal()) {
        /*
          * If simple named template then generate a conditional init of the
          * param using its default value:
          *       if (param == null) param = <default-value>
          */
        if (_isInSimpleNamedTemplate) {
            il.append(loadInstruction());
            BranchHandle ifBlock = il.append(new IFNONNULL(null));
            translateValue(classGen, methodGen);
            il.append(storeInstruction());
            ifBlock.setTarget(il.append(NOP));
            return;
        }

        il.append(classGen.loadTranslet());
        il.append(new PUSH(cpg, name));
        translateValue(classGen, methodGen);
        il.append(new PUSH(cpg, true));

        // Call addParameter() from this class
        il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS,
                                                     ADD_PARAMETER,
                                                     ADD_PARAMETER_SIG)));
        if (className != EMPTYSTRING) {
            il.append(new CHECKCAST(cpg.addClass(className)));
        }

        _type.translateUnBox(classGen, methodGen);

        if (_refs.isEmpty()) { // nobody uses the value
            il.append(_type.POP());
            _local = null;
        }
        else {              // normal case
            _local = methodGen.addLocalVariable2(name,
                                                 _type.toJCType(),
                                                 il.getEnd());
            // Cache the result of addParameter() in a local variable
            il.append(_type.STORE(_local.getIndex()));
        }
    }
    else {
        if (classGen.containsField(name) == null) {
            classGen.addField(new Field(ACC_PUBLIC, cpg.addUtf8(name),
                                        cpg.addUtf8(signature),
                                        null, cpg.getConstantPool()));
            il.append(classGen.loadTranslet());
            il.append(DUP);
            il.append(new PUSH(cpg, name));
            translateValue(classGen, methodGen);
            il.append(new PUSH(cpg, true));

            // Call addParameter() from this class
            il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS,
                                                 ADD_PARAMETER,
                                                 ADD_PARAMETER_SIG)));

            _type.translateUnBox(classGen, methodGen);

            // Cache the result of addParameter() in a field
            if (className != EMPTYSTRING) {
                il.append(new CHECKCAST(cpg.addClass(className)));
            }
            il.append(new PUTFIELD(cpg.addFieldref(classGen.getClassName(),
                                                   name, signature)));
        }
    }
}
 
Example 18
Source File: ParameterRef.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    /*
     * To fix bug 24518 related to setting parameters of the form
     * {namespaceuri}localName, which will get mapped to an instance
     * variable in the class.
     */
    final String name = BasisLibrary.mapQNameToJavaName (_name.toString());
    final String signature = _type.toSignature();

    if (_variable.isLocal()) {
        if (classGen.isExternal()) {
            Closure variableClosure = _closure;
            while (variableClosure != null) {
                if (variableClosure.inInnerClass()) break;
                variableClosure = variableClosure.getParentClosure();
            }

            if (variableClosure != null) {
                il.append(ALOAD_0);
                il.append(new GETFIELD(
                    cpg.addFieldref(variableClosure.getInnerClassName(),
                        name, signature)));
            }
            else {
                il.append(_variable.loadInstruction());
            }
        }
        else {
            il.append(_variable.loadInstruction());
        }
    }
    else {
        final String className = classGen.getClassName();
        il.append(classGen.loadTranslet());
        if (classGen.isExternal()) {
            il.append(new CHECKCAST(cpg.addClass(className)));
        }
        il.append(new GETFIELD(cpg.addFieldref(className,name,signature)));
    }

    if (_variable.getType() instanceof NodeSetType) {
        // The method cloneIterator() also does resetting
        final int clone = cpg.addInterfaceMethodref(NODE_ITERATOR,
                                                   "cloneIterator",
                                                   "()" +
                                                    NODE_ITERATOR_SIG);
        il.append(new INVOKEINTERFACE(clone, 1));
    }
}
 
Example 19
Source File: Param.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    if (_ignore) return;
    _ignore = true;

    /*
     * To fix bug 24518 related to setting parameters of the form
     * {namespaceuri}localName which will get mapped to an instance
     * variable in the class.
     */
    final String name = BasisLibrary.mapQNameToJavaName(_name.toString());
    final String signature = _type.toSignature();
    final String className = _type.getClassName();

    if (isLocal()) {
        /*
          * If simple named template then generate a conditional init of the
          * param using its default value:
          *       if (param == null) param = <default-value>
          */
        if (_isInSimpleNamedTemplate) {
            il.append(loadInstruction());
            BranchHandle ifBlock = il.append(new IFNONNULL(null));
            translateValue(classGen, methodGen);
            il.append(storeInstruction());
            ifBlock.setTarget(il.append(NOP));
            return;
        }

        il.append(classGen.loadTranslet());
        il.append(new PUSH(cpg, name));
        translateValue(classGen, methodGen);
        il.append(new PUSH(cpg, true));

        // Call addParameter() from this class
        il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS,
                                                     ADD_PARAMETER,
                                                     ADD_PARAMETER_SIG)));
        if (className != EMPTYSTRING) {
            il.append(new CHECKCAST(cpg.addClass(className)));
        }

        _type.translateUnBox(classGen, methodGen);

        if (_refs.isEmpty()) { // nobody uses the value
            il.append(_type.POP());
            _local = null;
        }
        else {              // normal case
            _local = methodGen.addLocalVariable2(name,
                                                 _type.toJCType(),
                                                 il.getEnd());
            // Cache the result of addParameter() in a local variable
            il.append(_type.STORE(_local.getIndex()));
        }
    }
    else {
        if (classGen.containsField(name) == null) {
            classGen.addField(new Field(ACC_PUBLIC, cpg.addUtf8(name),
                                        cpg.addUtf8(signature),
                                        null, cpg.getConstantPool()));
            il.append(classGen.loadTranslet());
            il.append(DUP);
            il.append(new PUSH(cpg, name));
            translateValue(classGen, methodGen);
            il.append(new PUSH(cpg, true));

            // Call addParameter() from this class
            il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS,
                                                 ADD_PARAMETER,
                                                 ADD_PARAMETER_SIG)));

            _type.translateUnBox(classGen, methodGen);

            // Cache the result of addParameter() in a field
            if (className != EMPTYSTRING) {
                il.append(new CHECKCAST(cpg.addClass(className)));
            }
            il.append(new PUTFIELD(cpg.addFieldref(classGen.getClassName(),
                                                   name, signature)));
        }
    }
}
 
Example 20
Source File: ParameterRef.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    /*
     * To fix bug 24518 related to setting parameters of the form
     * {namespaceuri}localName, which will get mapped to an instance
     * variable in the class.
     */
    final String name = BasisLibrary.mapQNameToJavaName (_name.toString());
    final String signature = _type.toSignature();

    if (_variable.isLocal()) {
        if (classGen.isExternal()) {
            Closure variableClosure = _closure;
            while (variableClosure != null) {
                if (variableClosure.inInnerClass()) break;
                variableClosure = variableClosure.getParentClosure();
            }

            if (variableClosure != null) {
                il.append(ALOAD_0);
                il.append(new GETFIELD(
                    cpg.addFieldref(variableClosure.getInnerClassName(),
                        name, signature)));
            }
            else {
                il.append(_variable.loadInstruction());
            }
        }
        else {
            il.append(_variable.loadInstruction());
        }
    }
    else {
        final String className = classGen.getClassName();
        il.append(classGen.loadTranslet());
        if (classGen.isExternal()) {
            il.append(new CHECKCAST(cpg.addClass(className)));
        }
        il.append(new GETFIELD(cpg.addFieldref(className,name,signature)));
    }

    if (_variable.getType() instanceof NodeSetType) {
        // The method cloneIterator() also does resetting
        final int clone = cpg.addInterfaceMethodref(NODE_ITERATOR,
                                                   "cloneIterator",
                                                   "()" +
                                                    NODE_ITERATOR_SIG);
        il.append(new INVOKEINTERFACE(clone, 1));
    }
}