Ejemplo n.º 1
0
  @Override
  public void genCyan(
      PWInterface pw, boolean printInMoreThanOneLine, CyanEnv cyanEnv, boolean genFunctions) {

    if (cyanEnv.getCreatingInstanceGenericPrototype()) {
      pw.print(cyanEnv.formalGenericParamToRealParam(selector.getSymbolString()));
    } else {
      pw.print(selector.getSymbolString());
    }
    int size = parameterList.size();
    boolean onlyOneTypeWithoutParameterName = false;
    if (size == 1 && parameterList.get(0).getVariableSymbol() == null) {
      // there is one parameter and the first one does not have a type
      onlyOneTypeWithoutParameterName = true;
    } else if (size == 0) onlyOneTypeWithoutParameterName = true;

    pw.print(" ");
    if (!onlyOneTypeWithoutParameterName) pw.print("(");
    for (ParameterDec p : parameterList) {
      p.genCyan(pw, false, cyanEnv, genFunctions);
      --size;
      if (size > 0) pw.print(", ");
    }
    if (!onlyOneTypeWithoutParameterName) pw.print(")");
    pw.print(" ");
  }
Ejemplo n.º 2
0
 /**
  * generate the parameter declarations of this method.
  *
  * @param env
  */
 public void genJava(PWInterface pw, Env env) {
   int size = parameterList.size();
   for (ParameterDec paramDec : parameterList) {
     paramDec.genJava(pw, env);
     if (--size > 0) pw.print(", ");
   }
 }
Ejemplo n.º 3
0
 /**
  * considering the method has just one parameter, which is its type? If the method is public fun
  * add: Int, String with: Float { } its type is Tuple<int, String, float> An object of this class
  * represents "add: int, String" or "with: float". It would return "int, String" and "float" in
  * these cases.
  */
 @Override
 public String getStringType() {
   int size = parameterList.size();
   if (size == 1) return PWCounter.toStringBuffer(parameterList.get(0).getTypeInDec()).toString();
   else {
     String s = "Tuple<";
     for (ParameterDec p : parameterList) {
       s = s + PWCounter.toStringBuffer(p.getTypeInDec()).toString();
       if (--size > 0) s = s + ", ";
     }
     return s + ">";
   }
 }
Ejemplo n.º 4
0
  public void calcInternalTypes(Env env) {

    for (ParameterDec parameter : parameterList) {
      String parameterName = parameter.getName();
      if (parameterName != null) {
        if (env.searchLocalVariableParameter(parameterName) != null) {
          env.searchLocalVariableParameter(parameterName);
          env.error(
              parameter.getFirstSymbol(),
              "Parameter '" + parameterName + "' is being redeclared",
              true);
        }
      }
      parameter.calcInternalTypes(env);
    }
  }
Ejemplo n.º 5
0
 @Override
 public Object getFullName(Env env) {
   if (parameterList == null || parameterList.size() == 0) return selector.getSymbolString();
   else {
     String s = selector.getSymbolString();
     int size = parameterList.size();
     if (size > 0) s = s + " ";
     for (ParameterDec p : parameterList) {
       if (p.getType(env) == null) {
         s = s + NameServer.dynName;
       } else {
         s = s + p.getType(env).getFullName(env);
       }
       if (--size > 0) s = s + ", ";
     }
     return s;
   }
 }
Ejemplo n.º 6
0
 @Override
 public void calcInterfaceTypes(Env env) {
   for (ParameterDec parameterDec : parameterList) parameterDec.calcInternalTypes(env);
 }