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


Java Node.isVarArgs方法代码示例

本文整理汇总了Java中com.google.javascript.rhino.Node.isVarArgs方法的典型用法代码示例。如果您正苦于以下问题:Java Node.isVarArgs方法的具体用法?Java Node.isVarArgs怎么用?Java Node.isVarArgs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.javascript.rhino.Node的用法示例。


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

示例1: convertParameter

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
private Parameter convertParameter(Node jsParameter, String parameterName) {
  return new Parameter(
      parameterName,
      getJavaTypeRegistry().createTypeReference(jsParameter.getJSType()),
      jsParameter.isVarArgs(),
      jsParameter.isOptionalArg());
}
 
开发者ID:google,项目名称:jsinterop-generator,代码行数:8,代码来源:MemberCollector.java

示例2: getMinArguments

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/** Gets the minimum number of arguments that this function requires. */
public int getMinArguments() {
  // NOTE(nicksantos): There are some native functions that have optional
  // parameters before required parameters. This algorithm finds the position
  // of the last required parameter.
  int i = 0;
  int min = 0;
  for (Node n : getParameters()) {
    i++;
    if (!n.isOptionalArg() && !n.isVarArgs()) {
      min = i;
    }
  }
  return min;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:16,代码来源:FunctionType.java

示例3: getMaxArguments

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
 * Gets the maximum number of arguments that this function requires,
 * or Integer.MAX_VALUE if this is a variable argument function.
 */
public int getMaxArguments() {
  Node params = getParametersNode();
  if (params != null) {
    Node lastParam = params.getLastChild();
    if (lastParam == null || !lastParam.isVarArgs()) {
      return params.getChildCount();
    }
  }

  return Integer.MAX_VALUE;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:16,代码来源:FunctionType.java

示例4: hasOptionalOrVarArgs

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
private boolean hasOptionalOrVarArgs() {
  Node lastChild = root.getLastChild();
  return lastChild != null &&
      (lastChild.isOptionalArg() || lastChild.isVarArgs());
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:6,代码来源:FunctionParamBuilder.java

示例5: hasVarArgs

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
public boolean hasVarArgs() {
  Node lastChild = root.getLastChild();
  return lastChild != null && lastChild.isVarArgs();
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:5,代码来源:FunctionParamBuilder.java

示例6: toString

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
 * Informally, a function is represented by
 * {@code function (params): returnType} where the {@code params} is a comma
 * separated list of types, the first one being a special
 * {@code this:T} if the function expects a known type for {@code this}.
 */
@Override
public String toString() {
  if (this == registry.getNativeType(JSTypeNative.FUNCTION_INSTANCE_TYPE)) {
    return "Function";
  }

  StringBuilder b = new StringBuilder(32);
  b.append("function (");
  int paramNum = (call == null || call.parameters == null) ?
      0 : call.parameters.getChildCount();
  boolean hasKnownTypeOfThis = !typeOfThis.isUnknownType();
  if (hasKnownTypeOfThis) {
    b.append("this:");
    b.append(typeOfThis.toString());
  }
  if (paramNum > 0) {
    if (hasKnownTypeOfThis) {
      b.append(", ");
    }
    Node p = call.parameters.getFirstChild();
    if (p.isVarArgs()) {
      appendVarArgsString(b, p.getJSType());
    } else {
      b.append(p.getJSType().toString());
    }
    p = p.getNext();
    while (p != null) {
      b.append(", ");
      if (p.isVarArgs()) {
        appendVarArgsString(b, p.getJSType());
      } else {
        b.append(p.getJSType().toString());
      }
      p = p.getNext();
    }
  }
  b.append(")");
  if (call != null && call.returnType != null) {
    b.append(": ");
    b.append(call.returnType);
  }
  return b.toString();
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:50,代码来源:FunctionType.java

示例7: isSubtype

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
@Override
public boolean isSubtype(JSType other) {
  if (!(other instanceof ArrowType)) {
    return false;
  }

  ArrowType that = (ArrowType) other;

  // this.returnType <: that.returnType (covariant)
  // If the return type is null, this is equivalent to unknown so we do not
  // base our decision on that.
  if (this.returnType != null &&
      that.returnType != null &&
      !this.returnType.isSubtype(that.returnType)) {
    return false;
  }
  // that.paramType[i] <: this.paramType[i] (contravariant)
  // TODO(nicksantos): This is incorrect. It should be invariant.
  // Follow up with closure team on how to fix this without everyone
  // hating on us.
  //
  // If the parameter list is null, this is equivalent of ?... so we do not
  // base our decision on that.
  if (this.parameters != null && that.parameters != null) {
    Node thisParam = parameters.getFirstChild();
    Node thatParam = that.parameters.getFirstChild();
    while (thisParam != null && thatParam != null) {
      JSType thisParamType = thisParam.getJSType();
      if (thisParamType != null) {
        JSType thatParamType = thatParam.getJSType();
        if (thatParamType == null ||
            !thatParamType.isSubtype(thisParamType)) {
          return false;
        }
      }
      boolean thisIsVarArgs = thisParam.isVarArgs();
      boolean thatIsVarArgs = thatParam.isVarArgs();
      // don't advance if we have variable arguments
      if (!thisIsVarArgs) {
        thisParam = thisParam.getNext();
      }
      if (!thatIsVarArgs) {
        thatParam = thatParam.getNext();
      }
      // both var_args indicates the end
      if (thisIsVarArgs && thatIsVarArgs) {
        thisParam = null;
        thatParam = null;
      }
    }

    // Right now, the parser's type system doesn't have a good way
    // to model optional arguments.
    //
    // Suppose we have
    // function f(number, number) {}
    // function g(number) {}
    // If the second arg of f is optional, then f is a subtype of g,
    // but g is not a subtype of f.
    // If the second arg of f is required, then g is a subtype of f,
    // but f is not a subtype of g.
    //
    // Until we model optional params, let's just punt on this.
    // If one type has more arguments than the other, we won't check them.
    //
    // NOTE(nicksantos): This is described in Draft 2 of the ES4 spec,
    // Section 3.4.6: Subtyping Function Types. It seems really
    // strange but I haven't thought a lot about the implementation.
  }

  return true;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:73,代码来源:ArrowType.java


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