/** * Expects an integer on the stack and translates it to a non-synthesized * boolean. It does not push a 0 or a 1 but instead returns branchhandle * list to be appended to the false list. * * @see org.apache.xalan.xsltc.compiler.util.Type#translateToDesynthesized */ public FlowList translateToDesynthesized(ClassGenerator classGen, MethodGenerator methodGen, BooleanType type) { final InstructionList il = methodGen.getInstructionList(); return new FlowList(il.append(new IFEQ(null))); }
public void translate(ClassGenerator classGen, MethodGenerator methodGen) { final InstructionList il = methodGen.getInstructionList(); _left.translate(classGen, methodGen); final InstructionHandle gotot = il.append(new GOTO(null)); il.append(methodGen.loadContextNode()); _right.translate(classGen, methodGen); _left._trueList.backPatch(gotot); _left._falseList.backPatch(gotot.getNext()); _trueList.append(_right._trueList.add(gotot)); _falseList.append(_right._falseList); } }
trueList = trueList.copyAndRedirect(ilist, copyOfilist); falseList = falseList.copyAndRedirect(ilist, copyOfilist); trueList.backPatch(success); falseList.backPatch(fail);
/** * Redirect the handles from oldList to newList. "This" flow list * is assumed to be relative to oldList. */ public FlowList copyAndRedirect(InstructionList oldList, InstructionList newList) { final FlowList result = new FlowList(); if (_elements == null) { return result; } final int n = _elements.size(); final Iterator oldIter = oldList.iterator(); final Iterator newIter = newList.iterator(); while (oldIter.hasNext()) { final InstructionHandle oldIh = (InstructionHandle) oldIter.next(); final InstructionHandle newIh = (InstructionHandle) newIter.next(); for (int i = 0; i < n; i++) { if (_elements.elementAt(i) == oldIh) { result.add(newIh); } } } return result; } }
public void backPatchFalseList(InstructionHandle ih) { _falseList.backPatch(ih); }
public void desynthesize(ClassGenerator classGen, MethodGenerator methodGen) { final InstructionList il = methodGen.getInstructionList(); _falseList.add(il.append(new IFEQ(null))); }
public void backPatchTrueList(InstructionHandle ih) { _trueList.backPatch(ih); }
BooleanType type) { LocalVariableGen local; final FlowList flowlist = new FlowList(); final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); flowlist.add(il.append(new IFEQ(null))); local.setEnd(il.append(new DLOAD(local.getIndex()))); il.append(DCMPG); flowlist.add(il.append(new IFNE(null))); // NaN != NaN return flowlist;
public void translateDesynthesized(ClassGenerator classGen, MethodGenerator methodGen) { final InstructionList il = methodGen.getInstructionList(); if (_value) { il.append(NOP); // true list falls through } else { _falseList.add(il.append(new GOTO(null))); } } }
il.append(new INVOKEINTERFACE(getType, 2)); il.append(new PUSH(cpg, DTM.PROCESSING_INSTRUCTION_NODE)); _falseList.add(il.append(new IF_ICMPEQ(null))); _falseList.add(il.append(new IFEQ(null))); Expression exp = pred.getExpr(); exp.translateDesynthesized(classGen, methodGen); _trueList.append(exp._trueList); _falseList.append(exp._falseList); _falseList.add(il.append(new GOTO(null)));
/** * Translates a node into a non-synthesized boolean. It does not push a * 0 or a 1 but instead returns branchhandle list to be appended to the * false list. * * @see org.apache.xalan.xsltc.compiler.util.Type#translateToDesynthesized */ public FlowList translateToDesynthesized(ClassGenerator classGen, MethodGenerator methodGen, BooleanType type) { final InstructionList il = methodGen.getInstructionList(); return new FlowList(il.append(new IFEQ(null))); }
/** * Synthesize a boolean expression, i.e., either push a 0 or 1 onto the * operand stack for the next statement to succeed. Returns the handle * of the instruction to be backpatched. */ public void synthesize(ClassGenerator classGen, MethodGenerator methodGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); _trueList.backPatch(il.append(ICONST_1)); final BranchHandle truec = il.append(new GOTO_W(null)); _falseList.backPatch(il.append(ICONST_0)); truec.setTarget(il.append(NOP)); }
/** * Redirect the handles from oldList to newList. "This" flow list * is assumed to be relative to oldList. */ public FlowList copyAndRedirect(InstructionList oldList, InstructionList newList) { final FlowList result = new FlowList(); if (_elements == null) { return result; } final int n = _elements.size(); final Iterator oldIter = oldList.iterator(); final Iterator newIter = newList.iterator(); while (oldIter.hasNext()) { final InstructionHandle oldIh = (InstructionHandle) oldIter.next(); final InstructionHandle newIh = (InstructionHandle) newIter.next(); for (int i = 0; i < n; i++) { if (_elements.elementAt(i) == oldIh) { result.add(newIh); } } } return result; } }
public void translateDesynthesized(ClassGenerator classGen, MethodGenerator methodGen) { final InstructionList il = methodGen.getInstructionList(); final Expression exp = argument(); exp.translateDesynthesized(classGen, methodGen); final BranchHandle gotoh = il.append(new GOTO(null)); _trueList = exp._falseList; // swap flow lists _falseList = exp._trueList; _falseList.add(gotoh); } }
trueList = trueList.copyAndRedirect(ilist, copyOfilist); falseList = falseList.copyAndRedirect(ilist, copyOfilist); trueList.backPatch(success); falseList.backPatch(fail);