当前位置: 首页>>代码示例>>Java>>正文


Java Type.Boolean方法代码示例

本文整理汇总了Java中com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type.Boolean方法的典型用法代码示例。如果您正苦于以下问题:Java Type.Boolean方法的具体用法?Java Type.Boolean怎么用?Java Type.Boolean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type的用法示例。


在下文中一共展示了Type.Boolean方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: typeCheck

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
/**
 * Type check the two parameters for this function
 */
public Type typeCheck(SymbolTable stable) throws TypeCheckError {

    // Check that the function was passed exactly two arguments
    if (argumentCount() != 2) {
        throw new TypeCheckError(ErrorMsg.ILLEGAL_ARG_ERR, getName(), this);
    }

    // The first argument must be a String, or cast to a String
    _base = argument(0);
    Type baseType = _base.typeCheck(stable);
    if (baseType != Type.String)
        _base = new CastExpr(_base, Type.String);

    // The second argument must also be a String, or cast to a String
    _token = argument(1);
    Type tokenType = _token.typeCheck(stable);
    if (tokenType != Type.String)
        _token = new CastExpr(_token, Type.String);

    return _type = Type.Boolean;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:ContainsCall.java

示例2: translateDesynthesized

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
/**
 * Compile the function call and treat as an expression
 * Update true/false-lists.
 */
@Override
public void translateDesynthesized(ClassGenerator classGen,
                                   MethodGenerator methodGen)
{
    Type type = Type.Boolean;
    if (_chosenMethodType != null)
        type = _chosenMethodType.resultType();

    final InstructionList il = methodGen.getInstructionList();
    translate(classGen, methodGen);

    if ((type instanceof BooleanType) || (type instanceof IntType)) {
        _falseList.add(il.append(new IFEQ(null)));
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:FunctionCall.java

示例3: typeCheck

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
/**
 * Type check the two parameters for this function
 */
public Type typeCheck(SymbolTable stable) throws TypeCheckError {

    // Check that the function was passed exactly two arguments
    if (argumentCount() != 2) {
        ErrorMsg err = new ErrorMsg(ErrorMsg.ILLEGAL_ARG_ERR,
                                    getName(), this);
        throw new TypeCheckError(err);
    }

    // The first argument must be a String, or cast to a String
    _base = argument(0);
    Type baseType = _base.typeCheck(stable);
    if (baseType != Type.String)
        _base = new CastExpr(_base, Type.String);

    // The second argument must also be a String, or cast to a String
    _token = argument(1);
    Type tokenType = _token.typeCheck(stable);
    if (tokenType != Type.String)
        _token = new CastExpr(_token, Type.String);

    return _type = Type.Boolean;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:StartsWithCall.java

示例4: CastExpr

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
/**
 * Construct a cast expression and check that the conversion is
 * valid by calling typeCheck().
 */
public CastExpr(Expression left, Type type) throws TypeCheckError {
    _left = left;
    _type = type;           // use inherited field

    if ((_left instanceof Step) && (_type == Type.Boolean)) {
        Step step = (Step)_left;
        if ((step.getAxis() == Axis.SELF) && (step.getNodeType() != -1))
            _typeTest = true;
    }

    // check if conversion is valid
    setParser(left.getParser());
    setParent(left.getParent());
    left.setParent(this);
    typeCheck(left.getParser().getSymbolTable());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:CastExpr.java

示例5: typeCheck

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
/**
 * Type-check the "test" expression and contents of this element.
 * The contents will be ignored if we know the test will always fail.
 */
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    // Type-check the "test" expression
    if (_test.typeCheck(stable) instanceof BooleanType == false) {
        _test = new CastExpr(_test, Type.Boolean);
    }
    // Type check the element contents
    if (!_ignore) {
        typeCheckContents(stable);
    }
    return Type.Void;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:If.java

示例6: typeCheck

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
/**
 *
 */
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    _langType = _lang.typeCheck(stable);
    if (!(_langType instanceof StringType)) {
        _lang = new CastExpr(_lang, Type.String);
    }
    return Type.Boolean;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:LangCall.java

示例7: typeCheck

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
/**
 * Argument of function-available call must be literal, typecheck
 * returns the type of function-available to be boolean.
 */
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    if (_type != null) {
       return _type;
    }
    if (_arg instanceof LiteralExpr) {
        return _type = Type.Boolean;
    }
    ErrorMsg err = new ErrorMsg(ErrorMsg.NEED_LITERAL_ERR,
                    "function-available", this);
    throw new TypeCheckError(err);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:FunctionAvailableCall.java

示例8: typeCheck

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
/**
 * Type-check this when element. The test should always be type checked,
 * while we do not bother with the contents if we know the test fails.
 * This is important in cases where the "test" expression tests for
 * the support of a non-available element, and the <xsl:when> body contains
 * this non-available element.
 */
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    // Type-check the test expression
    if (_test.typeCheck(stable) instanceof BooleanType == false) {
        _test = new CastExpr(_test, Type.Boolean);
    }
    // Type-check the contents (if necessary)
    if (!_ignore) {
        typeCheckContents(stable);
    }

    return Type.Void;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:When.java

示例9: typeCheck

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
/**
 * Typing rules: see XSLT Reference by M. Kay page 345.
 */
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    final Type tleft = _left.typeCheck(stable);
    final Type tright = _right.typeCheck(stable);

    if (tleft.isSimple() && tright.isSimple()) {
        if (tleft != tright) {
            if (tleft instanceof BooleanType) {
                _right = new CastExpr(_right, Type.Boolean);
            }
            else if (tright instanceof BooleanType) {
                _left = new CastExpr(_left, Type.Boolean);
            }
            else if (tleft instanceof NumberType ||
                     tright instanceof NumberType) {
                _left = new CastExpr(_left, Type.Real);
                _right = new CastExpr(_right, Type.Real);
            }
            else {          // both compared as strings
                _left = new CastExpr(_left,   Type.String);
                _right = new CastExpr(_right, Type.String);
            }
        }
    }
    else if (tleft instanceof ReferenceType) {
        _right = new CastExpr(_right, Type.Reference);
    }
    else if (tright instanceof ReferenceType) {
        _left = new CastExpr(_left, Type.Reference);
    }
    // the following 2 cases optimize @attr|.|.. = 'string'
    else if (tleft instanceof NodeType && tright == Type.String) {
        _left = new CastExpr(_left, Type.String);
    }
    else if (tleft == Type.String && tright instanceof NodeType) {
        _right = new CastExpr(_right, Type.String);
    }
    // optimize node/node
    else if (tleft instanceof NodeType && tright instanceof NodeType) {
        _left = new CastExpr(_left, Type.String);
        _right = new CastExpr(_right, Type.String);
    }
    else if (tleft instanceof NodeType && tright instanceof NodeSetType) {
        // compare(Node, NodeSet) will be invoked
    }
    else if (tleft instanceof NodeSetType && tright instanceof NodeType) {
        swapArguments();    // for compare(Node, NodeSet)
    }
    else {
        // At least one argument is of type node, node-set or result-tree

        // Promote an expression of type node to node-set
        if (tleft instanceof NodeType) {
            _left = new CastExpr(_left, Type.NodeSet);
        }
        if (tright instanceof NodeType) {
            _right = new CastExpr(_right, Type.NodeSet);
        }

        // If one arg is a node-set then make it the left one
        if (tleft.isSimple() ||
            tleft instanceof ResultTreeType &&
            tright instanceof NodeSetType) {
            swapArguments();
        }

        // Promote integers to doubles to have fewer compares
        if (_right.getType() instanceof IntType) {
            _right = new CastExpr(_right, Type.Real);
        }
    }
    return _type = Type.Boolean;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:76,代码来源:EqualityExpr.java

示例10: typeCheck

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    _type = Type.Boolean;
    return _type;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:BooleanExpr.java

示例11: typeCheck

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
/**
 * Type check a predicate expression. If the type of the expression is
 * number convert it to boolean by adding a comparison with position().
 * Note that if the expression is a parameter, we cannot distinguish
 * at compile time if its type is number or not. Hence, expressions of
 * reference type are always converted to booleans.
 *
 * This method may be called twice, before and after calling
 * <code>dontOptimize()</code>. If so, the second time it should honor
 * the new value of <code>_canOptimize</code>.
 */
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    Type texp = _exp.typeCheck(stable);

    // We need explicit type information for reference types - no good!
    if (texp instanceof ReferenceType) {
        _exp = new CastExpr(_exp, texp = Type.Real);
    }

    // A result tree fragment should not be cast directly to a number type,
    // but rather to a boolean value, and then to a numer (0 or 1).
    // Ref. section 11.2 of the XSLT 1.0 spec
    if (texp instanceof ResultTreeType) {
        _exp = new CastExpr(_exp, Type.Boolean);
        _exp = new CastExpr(_exp, Type.Real);
        texp = _exp.typeCheck(stable);
    }

    // Numerical types will be converted to a position filter
    if (texp instanceof NumberType) {
        // Cast any numerical types to an integer
        if (texp instanceof IntType == false) {
            _exp = new CastExpr(_exp, Type.Int);
        }

        if (_canOptimize) {
            // Nth position optimization. Expression must not depend on context
            _nthPositionFilter =
                !_exp.hasLastCall() && !_exp.hasPositionCall();

            // _nthDescendant optimization - only if _nthPositionFilter is on
            if (_nthPositionFilter) {
                SyntaxTreeNode parent = getParent();
                _nthDescendant = (parent instanceof Step) &&
                    (parent.getParent() instanceof AbsoluteLocationPath);
                return _type = Type.NodeSet;
            }
        }

       // Reset optimization flags
        _nthPositionFilter = _nthDescendant = false;

       // Otherwise, expand [e] to [position() = e]
       final QName position =
            getParser().getQNameIgnoreDefaultNs("position");
       final PositionCall positionCall =
            new PositionCall(position);
       positionCall.setParser(getParser());
       positionCall.setParent(this);

       _exp = new EqualityExpr(Operators.EQ, positionCall,
                                _exp);
       if (_exp.typeCheck(stable) != Type.Boolean) {
           _exp = new CastExpr(_exp, Type.Boolean);
       }
       return _type = Type.Boolean;
    }
    else {
        // All other types will be handled as boolean values
        if (texp instanceof BooleanType == false) {
            _exp = new CastExpr(_exp, Type.Boolean);
        }
        return _type = Type.Boolean;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:76,代码来源:Predicate.java

示例12: getType

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
/**
 *
 */
public Type getType() {
    return(Type.Boolean);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:7,代码来源:LangCall.java

示例13: typeCheck

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    _arg.typeCheck(stable);
    return _type = Type.Boolean;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:BooleanCall.java


注:本文中的com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type.Boolean方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。