Package eu.bandm.tools.umod
Class UMod2visitors
java.lang.Object
eu.bandm.tools.umod.UMod2visitors
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
protected static enum
protected class
protected class
protected class
Deprecated.protected class
Is created and called for toplevel classes, and then created anew for all sub-classes!protected class
Returns in "result" a Format which represents the descending code. -
Field Summary
Modifier and TypeFieldDescriptionprotected final boolean
protected static final GeneratedAnnotation
protected GeneratedClass
The topmost generated visitor, one per umod model.protected final GeneratedContext
static final int
Pseudo visitor register number for the case when NO LR-code is provided for a particular field, which means: ALL sub-expressions are visited.protected static final String
protected static final String
The generated "scc data transmission code" will write into these fields.protected static final String
protected static final String
protected static final String
(package private) final MetaType
(package private) final MetaType
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
static final String
static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected final UMod.Forest
protected final GeneratedClass
The main Java class representing the complete umod model.protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected final MessageReceiver<SimpleMessage<XMLDocumentIdentifier>>
protected static final String
protected static final String
protected final boolean
protected final boolean
protected final boolean
-
Constructor Summary
ConstructorDescriptionUMod2visitors
(MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msg_, GeneratedContext context_, GeneratedClass modelclass_, UMod.Forest model_, boolean visitordebug_, boolean visitoroptimize_, boolean visitorcompile_, boolean allrewriterwarnings_) Only constructor, sets all constant configuration values. -
Method Summary
Modifier and TypeMethodDescription(package private) static final Predicate<UMod.ClassDef>
appearsInVisitor
(int i) (package private) void
Deprecated.use the "follow_[fieldname]([class])" and "followAll_[fieldname]([class])" methods in the visitors instead.protected void
The algorithm is basically as follows: +protected void
ERROR
(Location<XMLDocumentIdentifier> loc, String txt) protected void
make_actionprepost
(UMod.ClassDef cd, GeneratedClass visitor, UMod.ClassDef superclass) static void
make_all_abstracts
(GeneratedClass visitor, int key) Iff visitor optimization is switched on, then the base visitor is derived fromOptimizingVisitor
, and this method "makes all abstract" methods which are required by this base class.protected void
make_breakLoop_method
(UMod.Forest model, GeneratedClass visitor) protected void
make_dumpcode
(GeneratedClass visitor, UMod.ClassDef cd, int keynum) protected void
make_prepost
(GeneratedClass visitor, String methname, UMod.ClassDef cd, UMod.ClassDef superclass) protected GeneratedClass
make_v_dumper
(UMod.Forest model, GeneratedContext context, GeneratedClass basematcher, int keynum, String name) protected GeneratedClass
make_v_multiphase
(UMod.Forest model, GeneratedContext context, GeneratedClass basematcher, int keynum, String name) protected GeneratedClass
make_v_rewritercorewriter
(UMod.Forest model, GeneratedContext context, GeneratedClass basematcher, int keynum, String name, UMod2visitors.rewriterType rtype, boolean supportMultiSubst) protected GeneratedClass
make_v_simple
(UMod.Forest model, GeneratedContext context, GeneratedClass basematcher, int keynum, String name) (package private) GeneratedClass
Make and return the common parent of all generated visitor classes.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.(package private) void
Is FIRST called for basematcher.(package private) void
makeLRCodeDescend
(UMod.FieldDef fd, GeneratedClass visitor, int register) 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.protected GeneratedClass
makeVisitorClass
(GeneratedContext context, GeneratedClass basematcher, String name) (package private) void
makeVisitors
(@Opt String sourceText) Generate the source text of all visitors defined in the current input forest.protected void
WARNING
(Location<XMLDocumentIdentifier> loc, String txt) 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 aV ../..
pragma.
-
Field Details
-
FIELDNAME__class2scc
The generated "scc data transmission code" will write into these fields. Is declared "abstract" inOptimizingVisitor
and generated bymakeSCCfields(GeneratedClass, MetaType, String, String)
.- See Also:
-
FIELDNAME__field2sccs
- See Also:
-
FIELDNAME__class2reachedSccs
- See Also:
-
METHODNAME__class2scc
- See Also:
-
METHODNAME__field2sccs
- See Also:
-
METHODNAME__class2reachedSccs
- See Also:
-
FIELDNAME_VISITOR_DEBUG_STREAM
- See Also:
-
METHODNAME_VISITOR_DEBUG
- See Also:
-
METHODNAME_getLowestGeneratedClass
- See Also:
-
METHODNAME_getKey
- See Also:
-
METHODNAME_collectFlags
- See Also:
-
allFields2codeNumber_DATA
-
METHODNAME_REWRITER_GETRESULT
- See Also:
-
METHODNAME_REWRITER_ISMULTI
- See Also:
-
METHODNAME_REWRITER_REVERT
- See Also:
-
METHODNAME_REWRITER_changed
- See Also:
-
METHODNAME_REWRITER_useCache
- See Also:
-
METHODNAME_REWRITER_breakLoop
- See Also:
-
METHODNAME_REWRITER_RETURN_EMPTY
- See Also:
-
METHODNAME_REWRITER_RETURN
- See Also:
-
METHODNAME_REWRITER_RETURN_MULTIPLE
- See Also:
-
METHODNAME_REWRITER_RETURN_MULT_INTERN
- See Also:
-
METHODNAME_REWRITER_REWRITE
- See Also:
-
METHODNAME_REWRITER_REWRITETYPED
- See Also:
-
VARNAME_TYPEVAR_REWRITETYPED
- See Also:
-
METHODNAME_REWRITER_LOOKUP
- See Also:
-
METHODNAME_REWRITER_putToCache
- See Also:
-
METHODNAME_COREWRITER_rewriteDone
- See Also:
-
NAME_BASEMATCHER
- See Also:
-
FIELDNAME_lowestGeneratedVisitorClass
- See Also:
-
METHODNAME_MATCHFOREIGNOBJECT
- See Also:
-
METHODNAME_NOMATCH
- See Also:
-
MODIF_STATICCLASS
protected static final int MODIF_STATICCLASS- See Also:
-
MODIF_VISITMETH
protected static final int MODIF_VISITMETH- See Also:
-
MODIF_VISITENTRY
protected static final int MODIF_VISITENTRY- See Also:
-
MODIF_FIELD
protected static final int MODIF_FIELD- See Also:
-
MODIF_PACKAGEVISIBLE
protected static final int MODIF_PACKAGEVISIBLE- See Also:
-
ANNOTATION_SUPPRESS_UNCHECKED
-
visitordebug
protected final boolean visitordebug -
visitoroptimize
protected final boolean visitoroptimize -
visitorcompile
protected final boolean visitorcompile -
allrewriterwarnings
protected final boolean allrewriterwarnings -
msg
-
model
-
context
-
modelclass
The main Java class representing the complete umod model. -
basematcher
The topmost generated visitor, one per umod model. Extends either Object orOptimizingVisitor
. Is generated by code in this class. -
allVisitorNums_classDefs
-
allVisitorNums_visitorDefs
-
allVisitorNums
-
descend_all_branches_case
public static final int descend_all_branches_casePseudo visitor register number for the case when NO LR-code is provided for a particular field, which means: ALL sub-expressions are visited.- See Also:
-
hashmaptype_object_object
-
maptype_object_object
-
-
Constructor Details
-
UMod2visitors
UMod2visitors(MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msg_, GeneratedContext context_, GeneratedClass modelclass_, UMod.Forest model_, boolean visitordebug_, boolean visitoroptimize_, boolean visitorcompile_, boolean allrewriterwarnings_) Only constructor, sets all constant configuration values.
-
-
Method Details
-
ERROR
-
WARNING
-
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 callingcheckDescendableAndMakeDescendMethod(UMod.ClassDef, UMod.FieldDef)
, FIXME RAUS ??), UMod2Tsoap, makeswingtree(..), and UMod2format. (The second part of the work is done by UMod2java callingmakeVisitors(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
Iff visitor optimization is switched on, then the base visitor is derived fromOptimizingVisitor
, 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-inUMod2format
) 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
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. All these fiels are maps indexed by integers; theil values are again maps or multimpas. -
appearsInVisitor
-
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
Emit a warning or an error for not-visitbable field, erronuously selected by aV ../..
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.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
Is FIRST called for basematcher. (AfterwardsmakeLRCodeDescend(UMod.FieldDef, GeneratedClass, int)
can be called for all others, with possible LR codes.) -
makeLRCodeDescend
-
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
-
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
-