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


Java Type.isSimple方法代码示例

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


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

示例1: 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


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