コード例 #1
0
  public TCExplicitFunctionDefinition(
      TCAccessSpecifier accessSpecifier,
      TCNameToken name,
      TCNameList typeParams,
      TCFunctionType type,
      TCPatternListList parameters,
      TCExpression body,
      TCExpression precondition,
      TCExpression postcondition,
      boolean typeInvariant,
      TCNameToken measure) {
    super(Pass.DEFS, name.getLocation(), name, NameScope.GLOBAL);

    this.accessSpecifier = accessSpecifier;
    this.typeParams = typeParams;
    this.type = type;
    this.paramPatternList = parameters;
    this.precondition = precondition;
    this.postcondition = postcondition;
    this.body = body;
    this.isTypeInvariant = typeInvariant;
    this.measure = measure;
    this.isCurried = parameters.size() > 1;

    type.definitions = new TCDefinitionList(this);
    type.instantiated = typeParams == null ? null : false;
  }
コード例 #2
0
  private TCExplicitFunctionDefinition getPostDefinition() {
    TCPatternList last = new TCPatternList();
    int psize = paramPatternList.size();

    for (TCPattern p : paramPatternList.get(psize - 1)) {
      last.add(p);
    }

    last.add(new TCIdentifierPattern(name.getResultName(location)));

    TCPatternListList parameters = new TCPatternListList();

    if (psize > 1) {
      parameters.addAll(paramPatternList.subList(0, psize - 1));
    }

    parameters.add(last);

    TCExplicitFunctionDefinition def =
        new TCExplicitFunctionDefinition(
            accessSpecifier,
            name.getPostName(postcondition.location),
            typeParams,
            type.getCurriedPostType(isCurried),
            parameters,
            postcondition,
            null,
            null,
            false,
            null);

    def.classDefinition = classDefinition;
    return def;
  }