Package net.sf.laja.parser.grammar.element

Examples of net.sf.laja.parser.grammar.element.Outputmethod


    if (var2b == null) {
      var2b = "";
    }

    if (firstCall) {
      Outputmethod om = getOutputmethod(var1, var2, var2b, origVar, true);
      if (om != null) {
        outputList.add(om, var1, var2, var2b);
      } else {
        if (origVar != null && var2.length() > 0 && !var2.equals("*")) {
          Refdata rd = new Refdata(var1, origVar);
View Full Code Here


      }
    }

    // Check for duplicated definitions.
    for (int i = 0; i < list.size(); i++) {
      Outputmethod om = list.get(i);
      if (om.isClassDefinition()) {
        for (int j = i + 1; j < list.size(); j++) {
          Outputmethod om2 = list.get(j);
          if (om2.isClassDefinition() && om.getClassName().equals(om2.getClassName())) {
            writer.writeln("\n\"" + om.getClassName() + "\" already defined in row " + om.getRow() + ". Error in row " + om2.getRow() + ":\n" + om.getRow() + ". " + om.getStatement() + "\n" + om2.getRow() + ". " + om2.getStatement());
            return false;
          }
        }
      }
    }

    // Check for duplicated method signatures.
    for (int i = 0; i < list.size(); i++) {
      Outputmethod om = list.get(i);
      for (int j = i + 1; j < list.size(); j++) {
        Outputmethod om2 = list.get(j);
        if (om.getArgumentSignature().equals(om2.getArgumentSignature())) {
          writer.writeln("\nElement \"" + om.getArgName() + "\" already defined for \"" + om.getCargName() + "\" in row " + om.getRow() + "\nwith the same argument signature, error in row " + om2.getRow() + ":\n" + om.getRow() + ". " + om + "\n" + om2.getRow() + ". " + om2);
          return false;
        }
      }
    }
View Full Code Here

    }
    return false;
  }

  public String getArgClass() {
    Outputmethod om = getFirstOutputmethod();
    String argClass = getFirstOutputmethod().getArgClass();
    if (argClass != null) {
      return argClass;
    }
    if (om.isClassRef()) {
      return om.getClassRef();
    }
    return null;
  }
View Full Code Here

  public boolean isArgClassVariableDef() {
    return ovSet.isArgClassVariableDef(getFirstOutputmethod());
  }

  public boolean isSameOutputclass(Outputmethod compare) {
    Outputmethod om = getFirstOutputmethod();
    return om.isSameOutputclass(compare);
  }
View Full Code Here

  public void writeSetStatement(int phase, Out out) {
    List<Outputmethod> list = getList(phase);

    int cntClasses = cntClasses(phase);
   
    Outputmethod om2 = getFirstOutputmethod();
    if (cntClasses <= 1 && !((om2.getRefname().equals(om2.getCargName()) &&
      om2.getRefname().equals(om2.getArgName())))) {
      for (Outputmethod om : list) {
        if (om.isClass()) {
          if (om.isDefined()) {
                        PeekStatement peekStatement = new PeekStatement(om.getClassName(), om.getMethodName(), OutDatatype.CLASS, om.getOmargList());
                        peekStatement.setArgClass(om.getArgClass());
View Full Code Here

    }
  }

  // Used when executing the method List<Output>.contains().
  public boolean equals(Object o) {
    Outputmethod om = ((Output) o).getFirstOutputmethod();
    return getFirstOutputmethod().equals(om);
  }
View Full Code Here

      Ref ref2 = refList.getRef(var2);
      if (ref2 == null) {
        ref2 = refList.getRef(var2b);
      }
      if (ref1 != null && ref2 != null) {
        om = new Outputmethod();
        om.setRef(var1);
        om.setArg(ref2.getRefname());

        String argClass = ref2.getClassName();
        if (argClass == null) {
View Full Code Here

    }
  }


  public String getOutputVarName(int phase, String var1, String var2, String var2b, String origVar) {
    Outputmethod om1 = new Outputmethod();
    Outputmethod om2 = new Outputmethod();

    om1.setRef(var1);
    om1.setArg(var2);
    om2.setRef(var1);
    om2.setArg(var2b);

    for (Output output : list) {
      if (output.isSameOutputclass(om1) || output.isSameOutputclass(om2)) {
        if (output.isOutputClass(phase)) {
          return output.getVariableName(phase);
View Full Code Here

    return "";
  }
 
  public void print(int phase) {
    for (Output output : list) {
      Outputmethod om = output.getFirstOutputmethod();
      String setter = om.isVariableSetter() ? "$ " : "";
      System.out.println("# " + setter + om + ", argClass=" + om.getArgClass() + ", argVariableSetter=" + output.isArgVariableSetter(phase) + ", variableSetter=" + output.isVariableSetter() + ", argClassVariableSetter=" + output.isArgClassVariableSetter() + ", argClassVariableDef="
          + output.isArgClassVariableDef());
      output.print();
    }
  }
View Full Code Here

    }
  }

  public void init() {
    for (Output output : list) {
      Outputmethod om = output.getFirstOutputmethod();
      if (!om.isDefined()) {
        if (ovSet.isReference(om.getArgName())) {
          output.getFirstOutputmethod().setVariableSetter();
        }
      }
      // Markera alla primitiva set-metoder som refererar till klasser.
      Ref ref = refList.getRef(om.getOrigArgName());
      if (om.isDefined() && !om.isClass() && ref != null) {
        om.setClassRef(ref.getClassName());
      }
      for (Iterator i = omList.iterator(); i.hasNext();) {
        Outputmethod om2 = (Outputmethod) i.next();
        if (om.isSameOutputclass(om2)) {
          output.add(om2);
        }
      }
    }

    // S�tt flagga "hasOutputMethod" om metod finns deklarerad.
    for (Iterator<Ref> i = refList.iterator(); i.hasNext();) {
      Ref ref = i.next();
      if (omList.get(ref.getRefname()) != null) {
        ref.setHasOutputMethod(true);
      }
    }

    Map<Refdata, Refdata> refdataMap = omList.getRefdataMap();
    for (Refdata refdata : refdataMap.values()) {
      Ref ref = refList.getRef(refdata.getOrigVar());
      if (ref != null && ref.isHasOutputMethod()) {
        // Nu har vi hittat en referens som �r ett objekt med metoder,
        // t ex:
        // valx = ... integer ...;
        // Integer integer.setInt(String *);
        // D� integer i valx-definitionen �r ett objekt, kommer
        // Outputklassen f�r Integer att g�ra "peekInteger().setInt(..),
        // d�rf�r m�ste antingen en set-metod f�r valx.integer vara
        // definierad, detta kan g�ras �t anv�ndare d� det inte ska vara
        // tvingande, exempel:
        // valx.setInteger(Integer integer);
        // Observera att man m�ste ta h�nsyn till hur variabeln refereras,
        // T ex ska satsen...
        // kalle = (integer:idx1):idx2 integer;
        // ...refereras b�de med idx2 och integer.
        Outputmethod om = new Outputmethod();
        om.setRef(refdata.getVar1());
        om.setArgClass(ref.getClassName());
        om.setArg(ref.getRefname());
        Ref varRef = refList.getRef(refdata.getVar1());
        if (varRef == null) {
          System.out.println("Error. The variable '" + refdata.getVar1() +
                      "' must be declared, e.g: " + StringUtils.capitalize(refdata.getVar1()) + " " + refdata.getVar1() + ";");
        } else {
          om.setClass(varRef.getClassName());
        }

        Output output = new Output(omList, ovSet, refList, om, refdata);
        list.add(output);
      }
View Full Code Here

TOP

Related Classes of net.sf.laja.parser.grammar.element.Outputmethod

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.