Class UMod2visitors

java.lang.Object
eu.bandm.tools.umod.UMod2visitors

public class UMod2visitors extends Object
  • Field Details

  • Constructor Details

  • Method Details

    • ERROR

      protected void ERROR(Location<XMLDocumentIdentifier> loc, String txt)
    • WARNING

      protected void WARNING(Location<XMLDocumentIdentifier> loc, String txt)
    • makebasevisitor

      GeneratedClass makebasevisitor()
      Make and return the common parent of all generated visitor classes. It supports only matching (FIXME: plus field descending??) This method is called from "UMod2java" directly and in advance, since its result is needed for V_compileFieldDefs()--> make descend_() methods (ONLY for calling checkDescendableAndMakeDescendMethod(UMod.ClassDef, UMod.FieldDef), FIXME RAUS ??), UMod2Tsoap, makeswingtree(..), and UMod2format. (The second part of the work is done by UMod2java calling makeVisitors(String).) This method generates the class, some fields, a (maybe NOP) compile() method, the "scc data transmission" fields, part of their init code ("allFields2codeNumber_DATA"), the top-level "match(Object)" instanceOf-cascade.
    • make_all_abstracts

      public static void make_all_abstracts(GeneratedClass visitor, int key)
      Iff visitor optimization is switched on, then the base visitor is derived from OptimizingVisitor, and this method "makes all abstract" methods which are required by this base class. For being compilable, also classes which do not need optimization (e.g. the built-in UMod2format) must implement these methods. Simplest way to guarantee this is to call this method.
      Parameters:
      key - the register number of the generated visitor class
    • makeVisitors

      void makeVisitors(@Opt @Opt String sourceText)
      Generate the source text of all visitors defined in the current input forest.
      Parameters:
      sourceText - adress of the pretty-printed html version of the umod source text, in url/href format, to generate a link in the generated doc comment.
    • makeSCCfields

      public void makeSCCfields(GeneratedClass basevisitor, MetaType maptype, String fieldname, String methodname)
      Generates in the generated base visitor class the field and the access method for one of the "scc data transfer" items.
    • appearsInVisitor

      static final Predicate<UMod.ClassDef> appearsInVisitor(int i)
    • collectRegisters

      protected void collectRegisters()
      The algorithm is basically as follows: +
       field2declaredClasses : Fd -> F Cd // F is *f*inite power set, as in "Z"
       select: Cd -> N -> seq Fd    // seq of fields selected for a certain register 
       super:  Cd -> Cd
       supSub: Cd <-> Cd = symmetricClosurre(reflexiveClosure(transitiveClosure(super)))
       // CANNOT exchange sequence of symmetric and transitive !!
      
       class2declaredClasses: N -> Cd -> F Cd 
          = {n|->c|->field2declaredClasses(|select(c,n).range|)} 
       reach: N-> Cd -> F Cd = subSub(|class2declaredClasses(|n, subSub(|{c}|) |) |)
       r2 = transitiveClosure ( scc (reach))
       
    • warnNoVisit

      protected void warnNoVisit(UMod.ClassDef cd, UMod.FieldDef fd, boolean isPrim, boolean isAbstract)
      Emit a warning or an error for not-visitbable field, erronuously selected by a V ../.. pragma. Whether the field is indeed selected is tested here. FIXME IS WRONG!!!! myfield int->Object V 0/0 V 1/0 L must only warn for register 1, not 0 !!!
    • checkDescendableAndMakeDescendMethod

      @Deprecated void checkDescendableAndMakeDescendMethod(UMod.ClassDef cd, UMod.FieldDef fd)
      Deprecated.
      use the "follow_[fieldname]([class])" and "followAll_[fieldname]([class])" methods in the visitors instead. The former automatically use the correct register number and thus LR code. The latter make full access (quasi implicit visitor code "LR" everywhere)
      Called once for all fields of all classes. Makes "descend_()" for all fields of container class types. For user's direct usage, this is done even for those not selected by any visitor register number.
      Called directly from "umod2java" when compiling a field definition.
      Iff the field carries a visitor register number but is not visitable, the pragma is deleted and a warning is issued via the global message channel.
    • makeDescendAllMethodsInBaseVisitor

      void makeDescendAllMethodsInBaseVisitor(UMod.FieldDef fd)
      Is FIRST called for basematcher. (Afterwards makeLRCodeDescend(UMod.FieldDef, GeneratedClass, int) can be called for all others, with possible LR codes.)
    • makeLRCodeDescend

      void makeLRCodeDescend(UMod.FieldDef fd, GeneratedClass visitor, int register)
    • makeCallDescend

      protected void makeCallDescend(GeneratedClass visitor, UMod.ClassDef cd, String methodname, int keynum, boolean optimizing)
      Compiles the method which recursively calls "match()" on all selected fields, either directly or by calling "descend_()".
      The name of the generated method is "action" in the simple visitor case, or "descend" in the multiphase case.
    • makeVisitorClass

      protected GeneratedClass makeVisitorClass(GeneratedContext context, GeneratedClass basematcher, String name)
    • make_v_simple

      protected GeneratedClass make_v_simple(UMod.Forest model, GeneratedContext context, GeneratedClass basematcher, int keynum, String name)
    • make_v_multiphase

      protected GeneratedClass make_v_multiphase(UMod.Forest model, GeneratedContext context, GeneratedClass basematcher, int keynum, String name)
    • make_prepost

      protected void make_prepost(GeneratedClass visitor, String methname, UMod.ClassDef cd, UMod.ClassDef superclass)
    • make_actionprepost

      protected void make_actionprepost(UMod.ClassDef cd, GeneratedClass visitor, UMod.ClassDef superclass)
    • make_v_dumper

      protected GeneratedClass make_v_dumper(UMod.Forest model, GeneratedContext context, GeneratedClass basematcher, int keynum, String name)
    • make_dumpcode

      protected void make_dumpcode(GeneratedClass visitor, UMod.ClassDef cd, int keynum)
    • make_v_rewritercorewriter

      protected GeneratedClass make_v_rewritercorewriter(UMod.Forest model, GeneratedContext context, GeneratedClass basematcher, int keynum, String name, UMod2visitors.rewriterType rtype, boolean supportMultiSubst)
    • make_breakLoop_method

      protected void make_breakLoop_method(UMod.Forest model, GeneratedClass visitor)