com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator - java examples

Here are the examples of the java api com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

51 Examples 7

19 View Complete Implementation : Step.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * Translate a step by pushing the appropriate iterator onto the stack.
 * The abbreviated steps '.' and '@attr' do not create new iterators
 * if they are not part of a LocationPath and have no filters.
 * In these cases a node index instead of an iterator is pushed
 * onto the stack.
 */
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    translateStep(clreplacedGen, methodGen, hasPredicates() ? _predicates.size() - 1 : -1);
}

19 View Complete Implementation : Variable.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * This method is part of a little trick that is needed to use local
 * variables inside nested for-each loops. See the initializeVariables()
 * method in the ForEach clreplaced for an explanation
 */
public void initialize(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = clreplacedGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    // This is only done for local variables that are actually used
    if (isLocal() && !_refs.isEmpty()) {
        // Create a variable slot if none is allocated
        if (_local == null) {
            _local = methodGen.addLocalVariable2(getEscapedName(), _type.toJCType(), null);
        }
        // Push the default value on the JVM's stack
        if ((_type instanceof IntType) || (_type instanceof NodeType) || (_type instanceof BooleanType))
            // 0 for node-id, integer and boolean
            il.append(new ICONST(0));
        else if (_type instanceof RealType)
            // 0.0 for floating point numbers
            il.append(new DCONST(0));
        else
            // and 'null' for anything else
            il.append(new ACONST_NULL());
        // Mark the store as the start of the live range of the variable
        _local.setStart(il.append(_type.STORE(_local.getIndex())));
    }
}

19 View Complete Implementation : LiteralExpr.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = clreplacedGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    il.append(new PUSH(cpg, _value));
}

19 View Complete Implementation : Pattern.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * Translate this node into JVM bytecodes. Patterns are translated as
 * boolean expressions with true/false lists. Before calling
 * <code>translate</code> on a pattern, make sure that the node being
 * matched is on top of the stack. After calling <code>translate</code>,
 * make sure to backpatch both true and false lists. True lists are the
 * default, in the sense that they always <em>"fall through"</em>. If this
 * is not the intended semantics (e.g., see
 * {@link com.sun.org.apache.xalan.internal.xsltc.compiler.AlternativePattern#translate})
 * then a GOTO must be appended to the instruction list after calling
 * <code>translate</code>.
 */
public abstract void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen);

19 View Complete Implementation : NameCall.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * Translate code that leaves a node's QName (as a String) on the stack
 */
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = clreplacedGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    final int getName = cpg.addInterfaceMethodref(DOM_INTF, GET_NODE_NAME, GET_NODE_NAME_SIG);
    super.translate(clreplacedGen, methodGen);
    il.append(new INVOKEINTERFACE(getName, 2));
}

19 View Complete Implementation : IdKeyPattern.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * This method is called when the constructor is compiled in
 * Stylesheet.compileConstructor() and not as the syntax tree is traversed.
 */
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = clreplacedGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    // Returns the KeyIndex object of a given name
    final int getKeyIndex = cpg.addMethodref(TRANSLET_CLreplaced, "getKeyIndex", "(Ljava/lang/String;)" + KEY_INDEX_SIG);
    // Initialises a KeyIndex to return nodes with specific values
    final int lookupId = cpg.addMethodref(KEY_INDEX_CLreplaced, "containsID", "(ILjava/lang/Object;)I");
    final int lookupKey = cpg.addMethodref(KEY_INDEX_CLreplaced, "containsKey", "(ILjava/lang/Object;)I");
    final int getNodeIdent = cpg.addInterfaceMethodref(DOM_INTF, "getNodeIdent", "(I)" + NODE_SIG);
    // Call getKeyIndex in AbstractTranslet with the name of the key
    // to get the index for this key (which is also a node iterator).
    il.append(clreplacedGen.loadTranslet());
    il.append(new PUSH(cpg, _index));
    il.append(new INVOKEVIRTUAL(getKeyIndex));
    // Now use the value in the second argument to determine what nodes
    // the iterator should return.
    il.append(SWAP);
    il.append(new PUSH(cpg, _value));
    if (this instanceof IdPattern) {
        il.append(new INVOKEVIRTUAL(lookupId));
    } else {
        il.append(new INVOKEVIRTUAL(lookupKey));
    }
    _trueList.add(il.append(new IFNE(null)));
    _falseList.add(il.append(new GOTO(null)));
}

19 View Complete Implementation : Text.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = clreplacedGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    if (!_ignore) {
        // Turn off character escaping if so is wanted.
        final int esc = cpg.addInterfaceMethodref(OUTPUT_HANDLER, "setEscaping", "(Z)Z");
        if (!_escaping) {
            il.append(methodGen.loadHandler());
            il.append(new PUSH(cpg, false));
            il.append(new INVOKEINTERFACE(esc, 2));
        }
        il.append(methodGen.loadHandler());
        // Call characters(String) or characters(char[],int,int), as
        // appropriate.
        if (!canLoadAsArrayOffsetLength()) {
            final int characters = cpg.addInterfaceMethodref(OUTPUT_HANDLER, "characters", "(" + STRING_SIG + ")V");
            il.append(new PUSH(cpg, _text));
            il.append(new INVOKEINTERFACE(characters, 2));
        } else {
            final int characters = cpg.addInterfaceMethodref(OUTPUT_HANDLER, "characters", "([CII)V");
            loadAsArrayOffsetLength(clreplacedGen, methodGen);
            il.append(new INVOKEINTERFACE(characters, 4));
        }
        // Restore character escaping setting to whatever it was.
        // Note: setEscaping(bool) returns the original (old) value
        if (!_escaping) {
            il.append(methodGen.loadHandler());
            il.append(SWAP);
            il.append(new INVOKEINTERFACE(esc, 2));
            il.append(POP);
        }
    }
    translateContents(clreplacedGen, methodGen);
}

19 View Complete Implementation : DecimalFormatting.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * This method is called when the constructor is compiled in
 * Stylesheet.compileConstructor() and not as the syntax tree is traversed.
 */
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    ConstantPoolGen cpg = clreplacedGen.getConstantPool();
    InstructionList il = methodGen.getInstructionList();
    // DecimalFormatSymbols.<init>(Locale);
    // xsl:decimal-format - except for the NaN and infinity attributes.
    final int init = cpg.addMethodref(DFS_CLreplaced, "<init>", "(" + LOCALE_SIG + ")V");
    // Push the format name on the stack for call to addDecimalFormat()
    il.append(clreplacedGen.loadTranslet());
    il.append(new PUSH(cpg, _name.toString()));
    // Manufacture a DecimalFormatSymbols on the stack
    // for call to addDecimalFormat()
    // Use the US Locale as the default, as most of its settings
    // are equivalent to the default settings required of
    il.append(new NEW(cpg.addClreplaced(DFS_CLreplaced)));
    il.append(DUP);
    il.append(new GETSTATIC(cpg.addFieldref(LOCALE_CLreplaced, "US", LOCALE_SIG)));
    il.append(new INVOKESPECIAL(init));
    String tmp = getAttribute("NaN");
    if ((tmp == null) || (tmp.equals(EMPTYSTRING))) {
        int nan = cpg.addMethodref(DFS_CLreplaced, "setNaN", "(Ljava/lang/String;)V");
        il.append(DUP);
        il.append(new PUSH(cpg, "NaN"));
        il.append(new INVOKEVIRTUAL(nan));
    }
    tmp = getAttribute("infinity");
    if ((tmp == null) || (tmp.equals(EMPTYSTRING))) {
        int inf = cpg.addMethodref(DFS_CLreplaced, "setInfinity", "(Ljava/lang/String;)V");
        il.append(DUP);
        il.append(new PUSH(cpg, "Infinity"));
        il.append(new INVOKEVIRTUAL(inf));
    }
    final int nAttributes = _attributes.getLength();
    for (int i = 0; i < nAttributes; i++) {
        final String name = _attributes.getQName(i);
        final String value = _attributes.getValue(i);
        boolean valid = true;
        int method = 0;
        if (name.equals("decimal-separator")) {
            // DecimalFormatSymbols.setDecimalSeparator();
            method = cpg.addMethodref(DFS_CLreplaced, "setDecimalSeparator", "(C)V");
        } else if (name.equals("grouping-separator")) {
            method = cpg.addMethodref(DFS_CLreplaced, "setGroupingSeparator", "(C)V");
        } else if (name.equals("minus-sign")) {
            method = cpg.addMethodref(DFS_CLreplaced, "setMinusSign", "(C)V");
        } else if (name.equals("percent")) {
            method = cpg.addMethodref(DFS_CLreplaced, "setPercent", "(C)V");
        } else if (name.equals("per-mille")) {
            method = cpg.addMethodref(DFS_CLreplaced, "setPerMill", "(C)V");
        } else if (name.equals("zero-digit")) {
            method = cpg.addMethodref(DFS_CLreplaced, "setZeroDigit", "(C)V");
        } else if (name.equals("digit")) {
            method = cpg.addMethodref(DFS_CLreplaced, "setDigit", "(C)V");
        } else if (name.equals("pattern-separator")) {
            method = cpg.addMethodref(DFS_CLreplaced, "setPatternSeparator", "(C)V");
        } else if (name.equals("NaN")) {
            method = cpg.addMethodref(DFS_CLreplaced, "setNaN", "(Ljava/lang/String;)V");
            il.append(DUP);
            il.append(new PUSH(cpg, value));
            il.append(new INVOKEVIRTUAL(method));
            valid = false;
        } else if (name.equals("infinity")) {
            method = cpg.addMethodref(DFS_CLreplaced, "setInfinity", "(Ljava/lang/String;)V");
            il.append(DUP);
            il.append(new PUSH(cpg, value));
            il.append(new INVOKEVIRTUAL(method));
            valid = false;
        } else {
            valid = false;
        }
        if (valid) {
            il.append(DUP);
            il.append(new PUSH(cpg, value.charAt(0)));
            il.append(new INVOKEVIRTUAL(method));
        }
    }
    final int put = cpg.addMethodref(TRANSLET_CLreplaced, "addDecimalFormat", "(" + STRING_SIG + DFS_SIG + ")V");
    il.append(new INVOKEVIRTUAL(put));
}

19 View Complete Implementation : When.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * This method should never be called. An Otherwise object will explicitly
 * translate the "test" expression and and contents of this element.
 */
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    final ErrorMsg msg = new ErrorMsg(ErrorMsg.STRAY_WHEN_ERR, this);
    getParser().reportError(Constants.ERROR, msg);
}

19 View Complete Implementation : ElementAvailableCall.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * Calls to 'element-available' are resolved at compile time since
 * the namespaces declared in the stylsheet are not available at run
 * time. Consequently, arguments to this function must be literals.
 */
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = clreplacedGen.getConstantPool();
    final boolean result = getResult();
    methodGen.getInstructionList().append(new PUSH(cpg, result));
}

19 View Complete Implementation : Otherwise.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    final Parser parser = getParser();
    final ErrorMsg err = new ErrorMsg(ErrorMsg.STRAY_OTHERWISE_ERR, this);
    parser.reportError(Constants.ERROR, err);
}

19 View Complete Implementation : NamespaceUriCall.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * Translate code that leaves a node's namespace URI (as a String)
 * on the stack
 */
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = clreplacedGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    // Returns the string value for a node in the DOM
    final int getNamespace = cpg.addInterfaceMethodref(DOM_INTF, "getNamespaceName", "(I)" + STRING_SIG);
    super.translate(clreplacedGen, methodGen);
    il.append(new INVOKEINTERFACE(getNamespace, 2));
}

19 View Complete Implementation : FunctionAvailableCall.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * Calls to 'function-available' are resolved at compile time since
 * the namespaces declared in the stylsheet are not available at run
 * time. Consequently, arguments to this function must be literals.
 */
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = clreplacedGen.getConstantPool();
    methodGen.getInstructionList().append(new PUSH(cpg, getResult()));
}

19 View Complete Implementation : SimpleAttributeValue.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * Translate this attribute value into JVM bytecodes that pushes the
 * attribute value onto the JVM's stack.
 * @param clreplacedGen BCEL Java clreplaced generator
 * @param methodGen BCEL Java method generator
 */
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = clreplacedGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    il.append(new PUSH(cpg, _value));
}

19 View Complete Implementation : ContainsCall.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * Compile expression and update true/false-lists
 */
public void translateDesynthesized(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = clreplacedGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    _base.translate(clreplacedGen, methodGen);
    _token.translate(clreplacedGen, methodGen);
    il.append(new INVOKEVIRTUAL(cpg.addMethodref(STRING_CLreplaced, "indexOf", "(" + STRING_SIG + ")I")));
    _falseList.add(il.append(new IFLT(null)));
}

19 View Complete Implementation : TestSeq.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * Compile the code for this test sequence. Compile patterns
 * from highest to lowest priority. Note that since patterns
 * can be share by multiple test sequences, instruction lists
 * must be copied before backpatching.
 */
public InstructionHandle compile(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen, InstructionHandle continuation) {
    // Returned cached value if already compiled
    if (_start != null) {
        return _start;
    }
    // If not patterns, then return handle for default template
    final int count = _patterns.size();
    if (count == 0) {
        return (_start = getTemplateHandle(_default));
    }
    // Init handle to jump when all patterns failed
    InstructionHandle fail = (_default == null) ? continuation : getTemplateHandle(_default);
    // Compile all patterns in reverse order
    for (int n = count - 1; n >= 0; n--) {
        final LocationPathPattern pattern = getPattern(n);
        final Template template = pattern.getTemplate();
        final InstructionList il = new InstructionList();
        // Patterns expect current node on top of stack
        il.append(methodGen.loadCurrentNode());
        // Apply the test-code compiled for the pattern
        InstructionList ilist = methodGen.getInstructionList(pattern);
        if (ilist == null) {
            ilist = pattern.compile(clreplacedGen, methodGen);
            methodGen.addInstructionList(pattern, ilist);
        }
        // Make a copy of the instruction list for backpatching
        InstructionList copyOfilist = ilist.copy();
        FlowList trueList = pattern.getTrueList();
        if (trueList != null) {
            trueList = trueList.copyAndRedirect(ilist, copyOfilist);
        }
        FlowList falseList = pattern.getFalseList();
        if (falseList != null) {
            falseList = falseList.copyAndRedirect(ilist, copyOfilist);
        }
        il.append(copyOfilist);
        // On success branch to the template code
        final InstructionHandle gtmpl = getTemplateHandle(template);
        final InstructionHandle success = il.append(new GOTO_W(gtmpl));
        if (trueList != null) {
            trueList.backPatch(success);
        }
        if (falseList != null) {
            falseList.backPatch(fail);
        }
        // Next pattern's 'fail' target is this pattern's first instruction
        fail = il.getStart();
        // Append existing instruction list to the end of this one
        if (_instructionList != null) {
            il.append(_instructionList);
        }
        // Set current instruction list to be this one
        _instructionList = il;
    }
    return (_start = fail);
}

19 View Complete Implementation : Import.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
// do nothing
}

19 View Complete Implementation : UnaryOpExpr.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    InstructionList il = methodGen.getInstructionList();
    _left.translate(clreplacedGen, methodGen);
    il.append(_type.NEG());
}

19 View Complete Implementation : CastCall.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = clreplacedGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    _right.translate(clreplacedGen, methodGen);
    il.append(new CHECKCAST(cpg.addClreplaced(_clreplacedName)));
}

19 View Complete Implementation : VariableRef.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = clreplacedGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    // Fall-through for variables that are implemented as methods
    if (_type.implementedAsMethod())
        return;
    final String name = _variable.getEscapedName();
    final String signature = _type.toSignature();
    if (_variable.isLocal()) {
        if (clreplacedGen.isExternal()) {
            Closure variableClosure = _closure;
            while (variableClosure != null) {
                if (variableClosure.inInnerClreplaced())
                    break;
                variableClosure = variableClosure.getParentClosure();
            }
            if (variableClosure != null) {
                il.append(ALOAD_0);
                il.append(new GETFIELD(cpg.addFieldref(variableClosure.getInnerClreplacedName(), name, signature)));
            } else {
                il.append(_variable.loadInstruction());
            }
        } else {
            il.append(_variable.loadInstruction());
        }
    } else {
        final String clreplacedName = clreplacedGen.getClreplacedName();
        il.append(clreplacedGen.loadTranslet());
        if (clreplacedGen.isExternal()) {
            il.append(new CHECKCAST(cpg.addClreplaced(clreplacedName)));
        }
        il.append(new GETFIELD(cpg.addFieldref(clreplacedName, 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));
    }
}

19 View Complete Implementation : LocationPathPattern.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
// TODO: What does it mean to translate a Pattern ?
}

19 View Complete Implementation : Message.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = clreplacedGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    // Load the translet (for call to displayMessage() function)
    il.append(clreplacedGen.loadTranslet());
    switch(elementCount()) {
        case 0:
            il.append(new PUSH(cpg, ""));
            break;
        case 1:
            SyntaxTreeNode child = (SyntaxTreeNode) elementAt(0);
            if (child instanceof Text) {
                il.append(new PUSH(cpg, ((Text) child).getText()));
                break;
            }
        // falls through
        default:
            // Push current output handler onto the stack
            il.append(methodGen.loadHandler());
            // Replace the current output handler by a ToXMLStream
            il.append(new NEW(cpg.addClreplaced(STREAM_XML_OUTPUT)));
            il.append(methodGen.storeHandler());
            // Push a reference to a StringWriter
            il.append(new NEW(cpg.addClreplaced(STRING_WRITER)));
            il.append(DUP);
            il.append(DUP);
            il.append(new INVOKESPECIAL(cpg.addMethodref(STRING_WRITER, "<init>", "()V")));
            // Load ToXMLStream
            il.append(methodGen.loadHandler());
            il.append(new INVOKESPECIAL(cpg.addMethodref(STREAM_XML_OUTPUT, "<init>", "()V")));
            // Invoke output.setWriter(STRING_WRITER)
            il.append(methodGen.loadHandler());
            il.append(SWAP);
            il.append(new INVOKEINTERFACE(cpg.addInterfaceMethodref(TRANSLET_OUTPUT_INTERFACE, "setWriter", "(" + WRITER_SIG + ")V"), 2));
            // Invoke output.setEncoding("UTF-8")
            il.append(methodGen.loadHandler());
            // other encodings?
            il.append(new PUSH(cpg, "UTF-8"));
            il.append(new INVOKEINTERFACE(cpg.addInterfaceMethodref(TRANSLET_OUTPUT_INTERFACE, "setEncoding", "(" + STRING_SIG + ")V"), 2));
            // Invoke output.setOmitXMLDeclaration(true)
            il.append(methodGen.loadHandler());
            il.append(ICONST_1);
            il.append(new INVOKEINTERFACE(cpg.addInterfaceMethodref(TRANSLET_OUTPUT_INTERFACE, "setOmitXMLDeclaration", "(Z)V"), 2));
            il.append(methodGen.loadHandler());
            il.append(new INVOKEINTERFACE(cpg.addInterfaceMethodref(TRANSLET_OUTPUT_INTERFACE, "startDoreplacedent", "()V"), 1));
            // Inline translation of contents
            translateContents(clreplacedGen, methodGen);
            il.append(methodGen.loadHandler());
            il.append(new INVOKEINTERFACE(cpg.addInterfaceMethodref(TRANSLET_OUTPUT_INTERFACE, "endDoreplacedent", "()V"), 1));
            // Call toString() on StringWriter
            il.append(new INVOKEVIRTUAL(cpg.addMethodref(STRING_WRITER, "toString", "()" + STRING_SIG)));
            // Restore old output handler
            il.append(SWAP);
            il.append(methodGen.storeHandler());
            break;
    }
    // Send the resulting string to the message handling method
    il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLreplaced, "displayMessage", "(" + STRING_SIG + ")V")));
    // If 'terminate' attribute is set to 'yes': Instanciate a
    // RunTimeException, but it on the stack and throw an exception
    if (_terminate == true) {
        // Create a new instance of RunTimeException
        final int einit = cpg.addMethodref("java.lang.RuntimeException", "<init>", "(Ljava/lang/String;)V");
        il.append(new NEW(cpg.addClreplaced("java.lang.RuntimeException")));
        il.append(DUP);
        il.append(new PUSH(cpg, "Termination forced by an " + "xsl:message instruction"));
        il.append(new INVOKESPECIAL(einit));
        il.append(ATHROW);
    }
}

19 View Complete Implementation : CeilingCall.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = clreplacedGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    argument(0).translate(clreplacedGen, methodGen);
    il.append(new INVOKESTATIC(cpg.addMethodref(MATH_CLreplaced, "ceil", "(D)D")));
}

19 View Complete Implementation : NamespaceAlias.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
// do nada
}

19 View Complete Implementation : Fallback.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * Translate contents only if this fallback element is put in place of
 * some unsupported element or non-XSLTC extension element
 */
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = clreplacedGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    if (_active)
        translateContents(clreplacedGen, methodGen);
}

19 View Complete Implementation : NumberCall.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    final InstructionList il = methodGen.getInstructionList();
    Type targ;
    if (argumentCount() == 0) {
        il.append(methodGen.loadContextNode());
        targ = Type.Node;
    } else {
        final Expression arg = argument();
        arg.translate(clreplacedGen, methodGen);
        arg.starreplacederator(clreplacedGen, methodGen);
        targ = arg.getType();
    }
    if (!targ.identicalTo(Type.Real)) {
        targ.translateTo(clreplacedGen, methodGen, Type.Real);
    }
}

19 View Complete Implementation : NotCall.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public void translateDesynthesized(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    final InstructionList il = methodGen.getInstructionList();
    final Expression exp = argument();
    exp.translateDesynthesized(clreplacedGen, methodGen);
    final BranchHandle gotoh = il.append(new GOTO(null));
    // swap flow lists
    _trueList = exp._falseList;
    _falseList = exp._trueList;
    _falseList.add(gotoh);
}

19 View Complete Implementation : FormatNumberCall.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = clreplacedGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    _value.translate(clreplacedGen, methodGen);
    _format.translate(clreplacedGen, methodGen);
    final int fn3arg = cpg.addMethodref(BASIS_LIBRARY_CLreplaced, "formatNumber", "(DLjava/lang/String;" + "Ljava/text/DecimalFormat;)" + "Ljava/lang/String;");
    final int get = cpg.addMethodref(TRANSLET_CLreplaced, "getDecimalFormat", "(Ljava/lang/String;)" + "Ljava/text/DecimalFormat;");
    il.append(clreplacedGen.loadTranslet());
    if (_name == null) {
        il.append(new PUSH(cpg, EMPTYSTRING));
    } else if (_resolvedQName != null) {
        il.append(new PUSH(cpg, _resolvedQName.toString()));
    } else {
        _name.translate(clreplacedGen, methodGen);
    }
    il.append(new INVOKEVIRTUAL(get));
    il.append(new INVOKESTATIC(fn3arg));
}

19 View Complete Implementation : ParameterRef.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = clreplacedGen.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 clreplaced.
         */
    final String name = BasisLibrary.mapQNameToJavaName(_name.toString());
    final String signature = _type.toSignature();
    if (_variable.isLocal()) {
        if (clreplacedGen.isExternal()) {
            Closure variableClosure = _closure;
            while (variableClosure != null) {
                if (variableClosure.inInnerClreplaced())
                    break;
                variableClosure = variableClosure.getParentClosure();
            }
            if (variableClosure != null) {
                il.append(ALOAD_0);
                il.append(new GETFIELD(cpg.addFieldref(variableClosure.getInnerClreplacedName(), name, signature)));
            } else {
                il.append(_variable.loadInstruction());
            }
        } else {
            il.append(_variable.loadInstruction());
        }
    } else {
        final String clreplacedName = clreplacedGen.getClreplacedName();
        il.append(clreplacedGen.loadTranslet());
        if (clreplacedGen.isExternal()) {
            il.append(new CHECKCAST(cpg.addClreplaced(clreplacedName)));
        }
        il.append(new GETFIELD(cpg.addFieldref(clreplacedName, 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));
    }
}

19 View Complete Implementation : ContainsCall.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * Compile the expression - leave boolean expression on stack
 */
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    translateDesynthesized(clreplacedGen, methodGen);
    synthesize(clreplacedGen, methodGen);
}

19 View Complete Implementation : RoundCall.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = clreplacedGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    // Get two copies of the argument on the stack
    argument().translate(clreplacedGen, methodGen);
    il.append(new INVOKESTATIC(cpg.addMethodref(BASIS_LIBRARY_CLreplaced, "roundF", "(D)D")));
}

19 View Complete Implementation : GenerateIdCall.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    final InstructionList il = methodGen.getInstructionList();
    if (argumentCount() == 0) {
        il.append(methodGen.loadContextNode());
    } else {
        // one argument
        argument().translate(clreplacedGen, methodGen);
    }
    final ConstantPoolGen cpg = clreplacedGen.getConstantPool();
    il.append(new INVOKESTATIC(cpg.addMethodref(BASIS_LIBRARY_CLreplaced, "generate_idF", // reuse signature
    GET_NODE_NAME_SIG)));
}

19 View Complete Implementation : StartsWithCall.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * Compile the expression - leave boolean expression on stack
 */
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = clreplacedGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    _base.translate(clreplacedGen, methodGen);
    _token.translate(clreplacedGen, methodGen);
    il.append(new INVOKEVIRTUAL(cpg.addMethodref(STRING_CLreplaced, "startsWith", "(" + STRING_SIG + ")Z")));
}

19 View Complete Implementation : BooleanExpr.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public void translateDesynthesized(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    final InstructionList il = methodGen.getInstructionList();
    if (_value) {
        // true list falls through
        il.append(NOP);
    } else {
        _falseList.add(il.append(new GOTO(null)));
    }
}

19 View Complete Implementation : StringCall.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    final InstructionList il = methodGen.getInstructionList();
    Type targ;
    if (argumentCount() == 0) {
        il.append(methodGen.loadContextNode());
        targ = Type.Node;
    } else {
        final Expression arg = argument();
        arg.translate(clreplacedGen, methodGen);
        arg.starreplacederator(clreplacedGen, methodGen);
        targ = arg.getType();
    }
    if (!targ.identicalTo(Type.String)) {
        targ.translateTo(clreplacedGen, methodGen, Type.String);
    }
}

19 View Complete Implementation : If.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * Translate the "test" expression and contents of this element.
 * The contents will be ignored if we know the test will always fail.
 */
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    final InstructionList il = methodGen.getInstructionList();
    _test.translateDesynthesized(clreplacedGen, methodGen);
    // remember end of condition
    final InstructionHandle truec = il.getEnd();
    if (!_ignore) {
        translateContents(clreplacedGen, methodGen);
    }
    _test.backPatchFalseList(il.append(NOP));
    _test.backPatchTrueList(truec.getNext());
}

19 View Complete Implementation : Text.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * Generates code that loads the array that will contain the character
 * data represented by this Text node, followed by the offset of the
 * data from the start of the array, and then the length of the data.
 *
 * The pre-condition to calling this method is that
 * canLoadAsArrayOffsetLength() returns true.
 * @see #canLoadArrayOffsetLength()
 */
public void loadAsArrayOffsetLength(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = clreplacedGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    final XSLTC xsltc = clreplacedGen.getParser().getXSLTC();
    // The XSLTC object keeps track of character data
    // that is to be stored in char arrays.
    final int offset = xsltc.addCharacterData(_text);
    final int length = _text.length();
    String charDataFieldName = STATIC_CHAR_DATA_FIELD + (xsltc.getCharacterDataCount() - 1);
    il.append(new GETSTATIC(cpg.addFieldref(xsltc.getClreplacedName(), charDataFieldName, STATIC_CHAR_DATA_FIELD_SIG)));
    il.append(new PUSH(cpg, offset));
    il.append(new PUSH(cpg, _text.length()));
}

19 View Complete Implementation : CurrentCall.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    methodGen.getInstructionList().append(methodGen.loadCurrentNode());
}

19 View Complete Implementation : TopLevelElement.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * Translate this node into a fresh instruction list.
 * The original instruction list is saved and restored.
 */
public InstructionList compile(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    final InstructionList result, save = methodGen.getInstructionList();
    methodGen.setInstructionList(result = new InstructionList());
    translate(clreplacedGen, methodGen);
    methodGen.setInstructionList(save);
    return result;
}

19 View Complete Implementation : Instruction.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * Translate this node into JVM bytecodes.
 */
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    ErrorMsg msg = new ErrorMsg(ErrorMsg.NOT_IMPLEMENTED_ERR, getClreplaced(), this);
    getParser().reportError(FATAL, msg);
}

19 View Complete Implementation : UnresolvedRef.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    if (_ref != null)
        _ref.translate(clreplacedGen, methodGen);
    else
        reportError();
}

19 View Complete Implementation : BooleanCall.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    _arg.translate(clreplacedGen, methodGen);
    final Type targ = _arg.getType();
    if (!targ.identicalTo(Type.Boolean)) {
        _arg.starreplacederator(clreplacedGen, methodGen);
        targ.translateTo(clreplacedGen, methodGen, Type.Boolean);
    }
}

19 View Complete Implementation : Variable.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = clreplacedGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    // Don't generate code for unreferenced variables
    if (_refs.isEmpty()) {
        _ignore = true;
    }
    // Make sure that a variable instance is only compiled once
    if (_ignore)
        return;
    _ignore = true;
    final String name = getEscapedName();
    if (isLocal()) {
        // Compile variable value computation
        translateValue(clreplacedGen, methodGen);
        // Add a new local variable and store value
        boolean createLocal = _local == null;
        if (createLocal) {
            mapRegister(methodGen);
        }
        InstructionHandle storeInst = il.append(_type.STORE(_local.getIndex()));
        // If the local is just being created, mark the store as the start
        // of its live range.  Note that it might have been created by
        // initializeVariables already, which would have set the start of
        // the live range already.
        if (createLocal) {
            _local.setStart(storeInst);
        }
    } else {
        String signature = _type.toSignature();
        // Global variables are store in clreplaced fields
        if (clreplacedGen.containsField(name) == null) {
            clreplacedGen.addField(new Field(ACC_PUBLIC, cpg.addUtf8(name), cpg.addUtf8(signature), null, cpg.getConstantPool()));
            // Push a reference to "this" for putfield
            il.append(clreplacedGen.loadTranslet());
            // Compile variable value computation
            translateValue(clreplacedGen, methodGen);
            // Store the variable in the allocated field
            il.append(new PUTFIELD(cpg.addFieldref(clreplacedGen.getClreplacedName(), name, signature)));
        }
    }
}

19 View Complete Implementation : LocalNameCall.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * This method is called when the constructor is compiled in
 * Stylesheet.compileConstructor() and not as the syntax tree is traversed.
 */
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = clreplacedGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    // Returns the name of a node in the DOM
    final int getNodeName = cpg.addInterfaceMethodref(DOM_INTF, "getNodeName", "(I)" + STRING_SIG);
    final int getLocalName = cpg.addMethodref(BASIS_LIBRARY_CLreplaced, "getLocalName", "(Ljava/lang/String;)" + "Ljava/lang/String;");
    super.translate(clreplacedGen, methodGen);
    il.append(new INVOKEINTERFACE(getNodeName, 2));
    il.append(new INVOKESTATIC(getLocalName));
}

19 View Complete Implementation : DecimalFormatting.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * Creates the default, nameless, DecimalFormat object in
 * AbstractTranslet's format_symbols hashtable.
 * This should be called for every stylesheet, and the entry
 * may be overridden by later nameless xsl:decimal-format instructions.
 */
public static void translateDefaultDFS(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    ConstantPoolGen cpg = clreplacedGen.getConstantPool();
    InstructionList il = methodGen.getInstructionList();
    final int init = cpg.addMethodref(DFS_CLreplaced, "<init>", "(" + LOCALE_SIG + ")V");
    // Push the format name, which is empty, on the stack
    // for call to addDecimalFormat()
    il.append(clreplacedGen.loadTranslet());
    il.append(new PUSH(cpg, EMPTYSTRING));
    // Manufacture a DecimalFormatSymbols on the stack for
    // call to addDecimalFormat().  Use the US Locale as the
    // default, as most of its settings are equivalent to
    // the default settings required of xsl:decimal-format -
    // except for the NaN and infinity attributes.
    il.append(new NEW(cpg.addClreplaced(DFS_CLreplaced)));
    il.append(DUP);
    il.append(new GETSTATIC(cpg.addFieldref(LOCALE_CLreplaced, "US", LOCALE_SIG)));
    il.append(new INVOKESPECIAL(init));
    int nan = cpg.addMethodref(DFS_CLreplaced, "setNaN", "(Ljava/lang/String;)V");
    il.append(DUP);
    il.append(new PUSH(cpg, "NaN"));
    il.append(new INVOKEVIRTUAL(nan));
    int inf = cpg.addMethodref(DFS_CLreplaced, "setInfinity", "(Ljava/lang/String;)V");
    il.append(DUP);
    il.append(new PUSH(cpg, "Infinity"));
    il.append(new INVOKEVIRTUAL(inf));
    final int put = cpg.addMethodref(TRANSLET_CLreplaced, "addDecimalFormat", "(" + STRING_SIG + DFS_SIG + ")V");
    il.append(new INVOKEVIRTUAL(put));
}

19 View Complete Implementation : BinOpExpr.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    final InstructionList il = methodGen.getInstructionList();
    _left.translate(clreplacedGen, methodGen);
    _right.translate(clreplacedGen, methodGen);
    switch(_op) {
        case PLUS:
            il.append(_type.ADD());
            break;
        case MINUS:
            il.append(_type.SUB());
            break;
        case TIMES:
            il.append(_type.MUL());
            break;
        case DIV:
            il.append(_type.DIV());
            break;
        case MOD:
            il.append(_type.REM());
            break;
        default:
            ErrorMsg msg = new ErrorMsg(ErrorMsg.ILLEGAL_BINARY_OP_ERR, this);
            getParser().reportError(Constants.ERROR, msg);
    }
}

19 View Complete Implementation : BooleanExpr.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    ConstantPoolGen cpg = clreplacedGen.getConstantPool();
    InstructionList il = methodGen.getInstructionList();
    il.append(new PUSH(cpg, _value));
}

19 View Complete Implementation : Comment.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = clreplacedGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    // Shortcut for literal strings
    Text rawText = null;
    if (elementCount() == 1) {
        Object content = elementAt(0);
        if (content instanceof Text) {
            rawText = (Text) content;
        }
    }
    // If the content is literal text, call comment(char[],int,int) or
    // comment(String), as appropriate.  Otherwise, use a
    // StringValueHandler to gather the textual content of the xsl:comment
    // and call comment(String) with the result.
    if (rawText != null) {
        il.append(methodGen.loadHandler());
        if (rawText.canLoadAsArrayOffsetLength()) {
            rawText.loadAsArrayOffsetLength(clreplacedGen, methodGen);
            final int comment = cpg.addInterfaceMethodref(TRANSLET_OUTPUT_INTERFACE, "comment", "([CII)V");
            il.append(new INVOKEINTERFACE(comment, 4));
        } else {
            il.append(new PUSH(cpg, rawText.getText()));
            final int comment = cpg.addInterfaceMethodref(TRANSLET_OUTPUT_INTERFACE, "comment", "(" + STRING_SIG + ")V");
            il.append(new INVOKEINTERFACE(comment, 2));
        }
    } else {
        // Save the current handler base on the stack
        il.append(methodGen.loadHandler());
        // first arg to "comment" call
        il.append(DUP);
        // Get the translet's StringValueHandler
        il.append(clreplacedGen.loadTranslet());
        il.append(new GETFIELD(cpg.addFieldref(TRANSLET_CLreplaced, "stringValueHandler", STRING_VALUE_HANDLER_SIG)));
        il.append(DUP);
        il.append(methodGen.storeHandler());
        // translate contents with subsreplaceduted handler
        translateContents(clreplacedGen, methodGen);
        // get String out of the handler
        il.append(new INVOKEVIRTUAL(cpg.addMethodref(STRING_VALUE_HANDLER, "getValue", "()" + STRING_SIG)));
        // call "comment"
        final int comment = cpg.addInterfaceMethodref(TRANSLET_OUTPUT_INTERFACE, "comment", "(" + STRING_SIG + ")V");
        il.append(new INVOKEINTERFACE(comment, 2));
        // Restore old handler base from stack
        il.append(methodGen.storeHandler());
    }
}

19 View Complete Implementation : FloorCall.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    argument().translate(clreplacedGen, methodGen);
    methodGen.getInstructionList().append(new INVOKESTATIC(clreplacedGen.getConstantPool().addMethodref(MATH_CLreplaced, "floor", "(D)D")));
}

19 View Complete Implementation : NotCall.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public void translate(ClreplacedGenerator clreplacedGen, MethodGenerator methodGen) {
    final InstructionList il = methodGen.getInstructionList();
    argument().translate(clreplacedGen, methodGen);
    il.append(ICONST_1);
    il.append(IXOR);
}