Class UMod2java.V_compileFieldDefs

java.lang.Object
eu.bandm.tools.umod.UMod.Visitor
eu.bandm.tools.umod.UMod2java.V_compileFieldDefs
Enclosing class:
UMod2java

protected class UMod2java.V_compileFieldDefs extends UMod.Visitor
  • Field Details

    • basevisitor

      protected final GeneratedClass basevisitor
    • visitorcompiler

      protected final UMod2visitors visitorcompiler
    • getterfunctions

      protected final boolean getterfunctions
    • setterfunctions

      protected final boolean setterfunctions
    • modif_field

      protected final int modif_field
    • curclass

      UMod.ClassDef curclass
  • Constructor Details

  • Method Details

    • findSuperField

      @Opt protected UMod.FieldDef findSuperField(UMod.FieldDef fd)
      Finds a field defintion with the same name as its argument in a true super class of the class definition containing this argument.
    • action

      protected void action(UMod.ClassDef cd)
      Sets curclass and descends to field defs and sub class defs.
      Overrides:
      action in class UMod.Visitor
    • action

      protected void action(UMod.FieldDef fd)
      Overrides:
      action in class UMod.Visitor
    • makeSetGet

      protected void makeSetGet(UMod.FieldDef fd, boolean getterfunctions, boolean setterfunctions, boolean isabstract)
    • makePrefixMultiplePut

      protected void makePrefixMultiplePut(String fieldname, List<UMod.Type> types, boolean topIsOpt, boolean lastIsListoid, boolean lastIsMultimap)
      For a field declaration ...
        f: A -> B -> C -> D
        f: A -> SEQ (C -> D)  // at each position;   "SEQ.."
        f: A -> int->C -> D   //    is treated as "int->.."
        
      ... we generate ...
        put_f(a, Map[B,Map[C,D]]) // resp. put_f(a, Seq[Map[C,D]] )
        put_f(a, b, Map[C,D])
        putAll_f(a, b, x:Map[C,D])
        put_f(a, b, c, d){
          m0=g.get(a);
          if(m0==null){m0=new...();f.put(a,m0);}
          m1=m0.get(b);
          if(m1==null){m1=new...();m0.put(b,m0);}
          m1.put(c, d);    // resp. m1.putAll(x);
        }
        
      (The "addAll(..)" method is only realized at the very end of this chain. Up to now it did not show up as urgently requested with shorter prefices. In the example above you currently have to use
        if (get_f().containsKey(a))
          f.get().get(a).putAll(x:MAP[b->MAP[c->d]])
        else
          f.get().put(NEW COPY OF (x:MAP[b->MAP[c->d]]))
        
      A future version could additionally generate such code, if requested by a command line switch.)

      The chain of processed types always ends with a type with more than one element on its "right side", like SET or REL, of primitive type (or OPT, etc.) For a field declaration ...
        f: A -> B -> SET C
        
      ... we generate ...
        put_f(a, Map[B,SET C])
        put_f(a, b, c:SET c){
          m0=g.get(a);
          if(m0==null){m0=new...();f.put(a,m0);}
          m0.put(b,c);
        }
        addAll_f(a, b, x:SET[C]){
        add_f(a, b, c){
          m0=g.get(a);
          if(m0==null){m0=new...();f.put(a,m0);}
          m1=m0.get(b);
          if(m1==null){m1=new set...();m0.put(b,m0);}
          m1.add(c);       // resp. m1.addAll(x);
        }
        
      On the "reading side", the method "containsKey()" is generared for all prefices of the signature. A result of "true" implies the existance of all intermediate container classes and "get(..).get(..).get(..)" can be called conventionally.
      in case of "put()", both following cases are treated identical:
        f: A -> B -> C ->D
        f: A -> OPT B -> C ->D
        
      If the user calls a "put_f(a, b, c...)", then they want want that there exists an f(a), in any case, no matter whether it already existed. But if a "set_F(a, null)" has happened, then the attempt "put_f(a, b, X)" is a misuse and a nullpointer exception.
      The treatment of multiple "get" is of course different:
        f: A -> B -> C
        g: A -> OPT B -> C
        
      get_f(a).get(b) throws an exception if containsKey_f(a) is f false.
      get_g(a).get(b) throws an exception if containsKey_f(a) is f false or if get_g(a) return null.
      In no case "null" represents an empty map. BUT on toplevel "f:OPT(A -> B ->C)" the call "put_f(a, b, c)" will generate the toplevel map, if necessary.
    • makeMultiplePut

      protected void makeMultiplePut(UMod.FieldDef fd)
    • makePrefixMultipleContainsKey

      protected void makePrefixMultipleContainsKey(String fieldname, List<UMod.Type> types)
    • makeMultipleContainsKey

      protected void makeMultipleContainsKey(UMod.FieldDef fd)