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


Java MethodType类代码示例

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


MethodType类属于com.sun.org.apache.xalan.internal.xsltc.compiler.util包,在下文中一共展示了MethodType类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: typeCheck

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodType; //导入依赖的package包/类
/**
 * Type-check this expression, and possibly child expressions.
 */
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    // Get the left and right operand types
    Type tleft = _left.typeCheck(stable);
    Type tright = _right.typeCheck(stable);

    // Check if the operator supports the two operand types
    MethodType wantType = new MethodType(Type.Void, tleft, tright);
    MethodType haveType = lookupPrimop(stable, Ops[_op], wantType);

    // Yes, the operation is supported
    if (haveType != null) {
        // Check if left-hand side operand must be type casted
        Type arg1 = (Type)haveType.argsType().elementAt(0);
        if (!arg1.identicalTo(tleft))
            _left = new CastExpr(_left, arg1);
        // Check if right-hand side operand must be type casted
        Type arg2 = (Type) haveType.argsType().elementAt(1);
        if (!arg2.identicalTo(tright))
            _right = new CastExpr(_right, arg1);
        // Return the result type for the operator we will use
        return _type = haveType.resultType();
    }
    throw new TypeCheckError(this);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:28,代码来源:LogicalExpr.java

示例2: typeCheck

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodType; //导入依赖的package包/类
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    final Type tleft = _left.typeCheck(stable);
    final MethodType ptype = lookupPrimop(stable, "u-",
                                          new MethodType(Type.Void,
                                                         tleft));

    if (ptype != null) {
        final Type arg1 = (Type) ptype.argsType().elementAt(0);
        if (!arg1.identicalTo(tleft)) {
            _left = new CastExpr(_left, arg1);
        }
        return _type = ptype.resultType();
    }

    throw new TypeCheckError(this);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:UnaryOpExpr.java

示例3: typeCheck

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodType; //导入依赖的package包/类
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    final Type tleft = _left.typeCheck(stable);
    final Type tright = _right.typeCheck(stable);
    final MethodType ptype = lookupPrimop(stable, Ops[_op],
                                          new MethodType(Type.Void,
                                                         tleft, tright));
    if (ptype != null) {
        final Type arg1 = (Type) ptype.argsType().elementAt(0);
        if (!arg1.identicalTo(tleft)) {
            _left = new CastExpr(_left, arg1);
        }
        final Type arg2 = (Type) ptype.argsType().elementAt(1);
        if (!arg2.identicalTo(tright)) {
            _right = new CastExpr(_right, arg1);
        }
        return _type = ptype.resultType();
    }
    throw new TypeCheckError(this);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:BinOpExpr.java

示例4: lookupPrimop

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodType; //导入依赖的package包/类
/**
 * Search for a primop in the symbol table that matches the method type
 * <code>ctype</code>. Two methods match if they have the same arity.
 * If a primop is overloaded then the "closest match" is returned. The
 * first entry in the vector of primops that has the right arity is
 * considered to be the default one.
 */
public MethodType lookupPrimop(SymbolTable stable, String op,
                               MethodType ctype) {
    MethodType result = null;
    final Vector primop = stable.lookupPrimop(op);
    if (primop != null) {
        final int n = primop.size();
        int minDistance = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            final MethodType ptype = (MethodType) primop.elementAt(i);
            // Skip if different arity
            if (ptype.argsCount() != ctype.argsCount()) {
                continue;
            }

            // The first method with the right arity is the default
            if (result == null) {
                result = ptype;             // default method
            }

            // Check if better than last one found
            final int distance = ctype.distanceTo(ptype);
            if (distance < minDistance) {
                minDistance = distance;
                result = ptype;
            }
        }
    }
    return result;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:37,代码来源:Expression.java

示例5: typeCheckStandard

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodType; //导入依赖的package包/类
/**
 * Type check a call to a standard function. Insert CastExprs when needed.
 * If as a result of the insertion of a CastExpr a type check error is
 * thrown, then catch it and re-throw it with a new "this".
 */
public Type typeCheckStandard(SymbolTable stable) throws TypeCheckError {
    _fname.clearNamespace();        // HACK!!!

    final int n = _arguments.size();
    final Vector argsType = typeCheckArgs(stable);
    final MethodType args = new MethodType(Type.Void, argsType);
    final MethodType ptype =
        lookupPrimop(stable, _fname.getLocalPart(), args);

    if (ptype != null) {
        for (int i = 0; i < n; i++) {
            final Type argType = (Type) ptype.argsType().elementAt(i);
            final Expression exp = (Expression)_arguments.elementAt(i);
            if (!argType.identicalTo(exp.getType())) {
                try {
                    _arguments.setElementAt(new CastExpr(exp, argType), i);
                }
                catch (TypeCheckError e) {
                    throw new TypeCheckError(this); // invalid conversion
                }
            }
        }
        _chosenMethodType = ptype;
        return _type = ptype.resultType();
    }
    throw new TypeCheckError(this);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:33,代码来源:FunctionCall.java

示例6: addPrimop

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodType; //导入依赖的package包/类
/**
 * Add a primitive operator or function to the symbol table. To avoid
 * name clashes with user-defined names, the prefix <tt>PrimopPrefix</tt>
 * is prepended.
 */
public void addPrimop(String name, MethodType mtype) {
    Vector methods = (Vector)_primops.get(name);
    if (methods == null) {
        _primops.put(name, methods = new Vector());
    }
    methods.addElement(mtype);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:SymbolTable.java

示例7: addPrimop

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodType; //导入依赖的package包/类
/**
 * Add a primitive operator or function to the symbol table. To avoid
 * name clashes with user-defined names, the prefix <tt>PrimopPrefix</tt>
 * is prepended.
 */
public void addPrimop(String name, MethodType mtype) {
    Vector methods = _primops.get(name);
    if (methods == null) {
        _primops.put(name, methods = new Vector());
    }
    methods.addElement(mtype);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:SymbolTable.java


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