/** * 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(ClassGenerator classGen, MethodGenerator methodGen) { final InstructionList il = methodGen.getInstructionList(); _test.translateDesynthesized(classGen, methodGen); // remember end of condition final InstructionHandle truec = il.getEnd(); if (!_ignore) { translateContents(classGen, methodGen); } _test.backPatchFalseList(il.append(NOP)); _test.backPatchTrueList(truec.getNext()); } }
/** * Redefined by expressions of type boolean that use flow lists. */ public void translateDesynthesized(ClassGenerator classGen, MethodGenerator methodGen) { translate(classGen, methodGen); if (_type instanceof BooleanType) { desynthesize(classGen, methodGen); } }
public void parseContents(Parser parser) { _test = parser.parseExpression(this, "test", null); // Ignore xsl:if when test is false (function-available() and // element-available()) Object result = _test.evaluateAtCompileTime(); if (result != null && result instanceof Boolean) { _ignore = !((Boolean) result).booleanValue(); } parseChildren(parser); // Make sure required attribute(s) have been set if (_test.isDummy()) { reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "test"); } }
public void translate(ClassGenerator classGen, MethodGenerator methodGen) { final Type ltype = _left.getType(); _left.translate(classGen, methodGen); if (_type.identicalTo(ltype) == false) { _left.startIterator(classGen, methodGen); ltype.translateTo(classGen, methodGen, _type); } } }
public void translateDesynthesized(ClassGenerator classGen, MethodGenerator methodGen) { final Type tleft = _left.getType(); final InstructionList il = methodGen.getInstructionList(); _left.translate(classGen, methodGen); _right.translate(classGen, methodGen); _falseList.add(il.append(_op == Operators.EQ ? (BranchInstruction)new IF_ICMPNE(null) : _left.translate(classGen, methodGen); _right.translate(classGen, methodGen); desynthesize(classGen, methodGen);
/** * Compile the value of the parameter, which is either in an expression in * a 'select' attribute, or in the with-param element's body */ public void translateValue(ClassGenerator classGen, MethodGenerator methodGen) { // Compile expression is 'select' attribute if present if (_select != null) { _select.translate(classGen, methodGen); _select.startIterator(classGen, methodGen); } // If not, compile result tree from parameter body if present. else if (hasContents()) { compileResultTree(classGen, methodGen); } // If neither are present then store empty string in parameter slot else { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); il.append(new PUSH(cpg, Constants.EMPTYSTRING)); } }
Type texp = _exp.typeCheck(stable); _exp = new CastExpr(_exp, Type.Boolean); _exp = new CastExpr(_exp, Type.Real); texp = _exp.typeCheck(stable); !_exp.hasLastCall() && !_exp.hasPositionCall(); if (_exp.typeCheck(stable) != Type.Boolean) { _exp = new CastExpr(_exp, Type.Boolean);
/** * Returns true if this expressions contains a call to position(). This is * needed for context changes in node steps containing multiple predicates. */ public boolean hasPositionCall() { if (_left.hasPositionCall()) return true; if (_right.hasPositionCall()) return true; return false; }
/** * Returns true if this expressions contains a call to last() */ public boolean hasLastCall() { return (_left.hasLastCall() || _right.hasLastCall()); }
public String toString() { return "AbsoluteLocationPath(" + (_path != null ? _path.toString() : "null") + ')'; }
/** * This method compiles code for the select expression for this * xsl:sort element. The method is called from the static code-generating * methods in this class. */ public void translateSelect(ClassGenerator classGen, MethodGenerator methodGen) { _select.translate(classGen,methodGen); }
/** * Returns an object representing the compile-time evaluation * of an expression. We are only using this for function-available * and element-available at this time. */ public Object evaluateAtCompileTime() { final Object leftb = _left.evaluateAtCompileTime(); final Object rightb = _right.evaluateAtCompileTime(); // Return null if we can't evaluate at compile time if (leftb == null || rightb == null) { return null; } if (_op == AND) { return (leftb == Boolean.TRUE && rightb == Boolean.TRUE) ? Boolean.TRUE : Boolean.FALSE; } else { return (leftb == Boolean.TRUE || rightb == Boolean.TRUE) ? Boolean.TRUE : Boolean.FALSE; } }
/** * Type checking a cast expression amounts to verifying that the * type conversion is legal. Cast expressions are created during * type checking, but typeCheck() is usually not called on them. * As a result, this method is called from the constructor. */ public Type typeCheck(SymbolTable stable) throws TypeCheckError { Type tleft = _left.getType(); if (tleft == null) { tleft = _left.typeCheck(stable); } if (tleft instanceof NodeType) { tleft = Type.Node; // multiple instances } else if (tleft instanceof ResultTreeType) { tleft = Type.ResultTree; // multiple instances } if (InternalTypeMap.maps(tleft, _type) != null) { return _type; } // throw new TypeCheckError(this); throw new TypeCheckError(new ErrorMsg( ErrorMsg.DATA_CONVERSION_ERR, tleft.toString(), _type.toString())); }
_left.translateDesynthesized(classGen, methodGen); _right.translateDesynthesized(classGen, methodGen); _left.backPatchTrueList(middle); _left.backPatchTrueList(middle); _right.backPatchTrueList(after); _right.backPatchTrueList(after); _left.translateDesynthesized(classGen, methodGen); _right.translateDesynthesized(classGen, methodGen);
public void translateDesynthesized(ClassGenerator classGen, MethodGenerator methodGen) { final Type tleft = _left.getType(); final InstructionList il = methodGen.getInstructionList(); _left.translate(classGen, methodGen); _right.translate(classGen, methodGen); _falseList.add(il.append(_op == Operators.EQ ? (BranchInstruction)new IF_ICMPNE(null) : _left.translate(classGen, methodGen); _right.translate(classGen, methodGen);
_left.backPatchTrueList(begin);
_left.backPatchFalseList(ancestor.getLoopHandle()); // clears list
public void translate(ClassGenerator classGen, MethodGenerator methodGen) { _arg.translate(classGen, methodGen); final Type targ = _arg.getType(); if (!targ.identicalTo(Type.Boolean)) { _arg.startIterator(classGen, methodGen); targ.translateTo(classGen, methodGen, Type.Boolean); } } }
public void translateDesynthesized(ClassGenerator classGen, MethodGenerator methodGen) { final Type tleft = _left.getType(); final InstructionList il = methodGen.getInstructionList(); _left.translate(classGen, methodGen); _right.translate(classGen, methodGen); _falseList.add(il.append(_op == Operators.EQ ? (BranchInstruction)new IF_ICMPNE(null) : _left.translate(classGen, methodGen); _right.translate(classGen, methodGen); desynthesize(classGen, methodGen);