Package eu.bandm.tools.d2d2.base
Class Resolver3
java.lang.Object
eu.bandm.tools.d2d2.model.MATCH_ONLY_00
eu.bandm.tools.d2d2.model.Rewrite
eu.bandm.tools.d2d2.base.Resolver3
- All Implemented Interfaces:
Rewriter
Transforms a "raw" module into an "instantiated" one.
Usage: create a new object of this class for one top level raw module and
call
The resulting
The overall control flow is roughly as follows:
First all public definitions from the top-level raw module are given one
Every
In the second phase this set is emptied one-by-one by
If for the characteristic pair of the reference a "bound()"
Otherwise an
As soon as one such call succeeds,
If this does not happen, the new Instance is made its own class by
The equivalence test implemented by the class
Failure is signalled by throwing the local Exception
As soon as the two constructors of the compared expression sub-tree are not identical, a failure is found.
The same holds vor un-equal constant values.
When two
The
Whenever a hypothesis fails, the failure is propagated to all in its ".requiredBy" set, and the representing
TESTS as with 20160826:
d2d2/test> make expand MODULE=basic.deliverables
(( ALTE VBERSION !?!)) d2d2/test/basic.deliverables.expanded 853 lines without equivalence.
d2d2/test/EXPANDED_basic.deliverables 998 line with equivalence.
d2d2/test> make expand MODULE=d2d-meta
resolveAllPublics()
.
The resulting
resolvedModule
ist self-contained: All Definitions rewritten
from imported modules are cloned to definitions contained directly therein;
as NAME they get the original name prepended by the complete import prefix path.
The overall control flow is roughly as follows:
resolveAllPublics() | | | | V createNewInstance(..) ^ V / Clone the definition object, | Call rewriting match(..) for the | RegExp = def.value. | | | | | V | | | action(Subst/Insertion) | =update rewriting contexts | V | | rewriteFields([div. constructors]) | =rewrite expression objects, filling | fields with rewrite of sub-expr | V | rewriteFields(Reference) | () Apply local rewrites and | visit target expression recursively | () or else apply import level rewrites | and visit target expr. recursively | () or else restore "frozen @" replacement context | and visit again. | () otherwise: | | | V | visitPossiblyImportedDef(..) | V | | loadImportedModule() | V | visitDefinition(..) | () if instance for this combination (of rawDef and importContext) | does NOT exist: | create a new Instance and start its rewriting. | on return: if ".cyclic" is not set: set ".complete" | // now an instance exists: | () if instance is not "bound()": memorize a classifcation request | () if !.complete and insert mode then set .cyclic | () if insertMode and !cyclic: rewrite reference to | rewritten contents/expression | () if insertMode and cyclic: rewrite reference to | "@ x" combination, "x" the rewritten definition | () else store rewritten instance as reference's ".resolved" | (The results are stored in two maps : | "reference2rawDef" and "reference2importContext".) | | | | | | | | \ V \ processWaitingReferences() \ V \ ->processWaitingReference(..) /\ creates a new Instance object, which / \ is either its own class, or related to another / \ Instance of the same raw def as its representative / \ (hypothetically or confirmed). | \ | | | \V | | createNewInstance(..) | V | equivalent(ref's def, old instantiation of same def) | V | (new Equivalence()).match() \ V \ descend(Reference) \----------------Central object is
Resolver3.Instance
which is built for every found combination of
Definition
and Resolver3.ImportContext
.
(Additionally Instances will be needed for combinations of local substitution,
insert operation and recursive call as in "@x^(a/b)" with "x=...x...".
This is done by the methods createNewInstance(eu.bandm.tools.d2d2.base.Resolver3.ImportContext,eu.bandm.tools.d2d2.model.Definition,@eu.bandm.tools.annotations.Opt eu.bandm.tools.d2d2.model.Reference)
and Resolver3.Instance.newHypothesis(Instance)
.
The former also does the CLONING of the Definition
object and the rewriting
of the expression. (The latter only creates a new Instance object reflecting the
hypothesis of being equivalent with the method's argument.)
First all public definitions from the top-level raw module are given one
Resolver3.Instance
, which is an "equivalence class", i.e. its own representative.
During this, each expression value is visited with the rewriting method
of this class, and all rewriting directives (local and coming with module imports)
are applied.
As a result, all reached Reference
s are attributed by the maps
reference2rawDef
and reference2importContext
, reflecting the result
of applying all rewrite directives. Every
Resolver3.Instance
is addressed globally by a "characteristic pair"
of raw definition and import context.
Additionally a reached reference is entered in the set waitingForEquivalence
,
iff there is no Resolver3.Instance
yet for this combination, or only one with a failed
hypothesis.
In the second phase this set is emptied one-by-one by
processWaitingReference(eu.bandm.tools.d2d2.model.Reference)
: If for the characteristic pair of the reference a "bound()"
Resolver3.Instance
exists,
nothing is done.Otherwise an
Resolver3.Instance
is created. Every already existing Resolver3.Instance
for the same raw definition, which is an equivalence class, i.e. its own
representative, is tested against the import context of the critical reference
by calling equivalent(Definition,Definition)
.As soon as one such call succeeds,
Resolver3.Instance.hypothesisConfirmed()
is called
on this hypothesis, making it a permanent fact.If this does not happen, the new Instance is made its own class by
Resolver3.Instance.setIsClass()
.
The equivalence test implemented by the class
Resolver3.Equivalence
goes from the two
definitions to the two expressions, and visits them pairwise. Failure is signalled by throwing the local Exception
Resolver3.DifferenceFound
.As soon as the two constructors of the compared expression sub-tree are not identical, a failure is found.
The same holds vor un-equal constant values.
When two
Reference
s are reached, first processWaitingReference(eu.bandm.tools.d2d2.model.Reference)
is called for both of them recursively, and then the representatives of the two
resulting Instance objects are compared.The
Resolver3.Instance
which is currently under test against some equivalence class has
been stored in currentHypothesis
. So, whenever an Resolver3.Instance
(=x) is reached
which is itself hypothetical, the dependency is memorized by adding "currentHypothesis"
to "x.requiredBy" and setting "currentHypothesis.requires=true" (This is for optimization
/object reuse only).
Whenever a hypothesis fails, the failure is propagated to all in its ".requiredBy" set, and the representing
Reference
(from Resolver3.Instance.reprRef
is re-entered into
waitingForEquivalence
.
TESTS as with 20160826:
d2d2/test> make expand MODULE=basic.deliverables
(( ALTE VBERSION !?!)) d2d2/test/basic.deliverables.expanded 853 lines without equivalence.
d2d2/test/EXPANDED_basic.deliverables 998 line with equivalence.
d2d2/test> make expand MODULE=d2d-meta
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
Stack frame which memorizes a particular single rewriting clause, mapping an identifier to an expression.protected class
class
Adjusts alle reachable references to point to the representative of its equivalence class: by the pointer ".resolved" to the rewritten Definition object, as well as by "sourceText" to the compound name.protected class
protected class
Stack frame which memorizes the situation when parsing an "insert operator" = "@".static class
protected class
Stack frames which represent dynamic import situations.protected class
The parametrized instance of one particular d2d modelDefinition
.(package private) class
Represents rewrite results of insertion operators which must be reified because of recursion. -
Field Summary
Modifier and TypeFieldDescriptionThe name of the definition (local to its containing module), the expression of which is currently rewritten.protected Resolver3.FlattenContext
Top of the stack ofResolver3.FlattenContext
s.(package private) Resolver3.Instance
The instance which is currently matched against another instance which is an equivalence class, and so initiated the application of anResolver3.Equivalence
.protected @Opt ImportItem
The ImportItem when an expression is rewritten like "a" in "import A from modA ^(a/b)".protected Resolver3.Binding<Expression>
Stack of bindings representing the nesting of local substitution expressions of formexp^(a/b)
.(package private) Reference
The Reference reached by the top-level rewriter.protected final Resolver3.DifferenceFound
protected final CheckedMap_RD<String,
Definition> A constant map which contains NO local definitions, used as the value of "localDefs" when a definition is cloned/instantiated.protected Resolver3.ImportContext
Where to look for the definition, meant by some particular reference value.protected Resolver3.ImportContext
Where to look for rewrite instructions coming with the "ImportItem", when rewriting references.protected Map<Definition,
Map<Resolver3.ImportContext, Resolver3.Instance>> Maps indexed by the raw (=source level) definitions.protected final ModuleRegistry
Where imported raw modules are loaded from.protected final MessageTee<SimpleMessage<XMLDocumentIdentifier>>
protected final MessageCounter
protected Map<Reference,
Resolver3.ImportContext> Central result of the rewriting process, which maps rewritten Reference objects to the import context (=module import prefix chain=rewriting context) of the finally meant definition.protected Map<Reference,
Definition> Central result of the rewriting process, which maps rewritten Reference objects to the definition in the "raw" source module which is meant.protected final ResolvedModule
Output data: the result of the resolution process.protected final Resolver3.ImportContext
A synthetic/pseudo import context, to fulfill the role of "importContext" for the top-level module, which is indeed NOT imported.protected final Module
Input data: the source module to be resolved.static final String
static final String
(package private) boolean
The kind of the parser currently under rewriting.protected boolean
Whether unification shall be used for minimization of instantiated definitions.protected final int
Set of all references which have not yet been classified for equivalence.Fields inherited from class eu.bandm.tools.d2d2.model.MATCH_ONLY_00
_visitor_debug_stream, partial
-
Constructor Summary
ConstructorDescriptionResolver3
(MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msgoutput, ModuleRegistry moduleRegistry, Module rootModule, int verbosity) Central service providing method. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Insert a newResolver3.FlattenContext
on top of the stack of flatten contexts, then descend into the sub-expression.void
void
Simply insert a newResolver3.Binding
on top of the stack of local substs, then descend into the sub-expression.protected Resolver3.Instance
createNewInstance
(Resolver3.ImportContext ic, Definition raw, @Opt Reference reprRef) Central routine for processing a new instantiation of a particular definition in a particular import context.
In case ofXRegExp
: Calls the main class visitor methods for applying all rewriting expressions to the def's value.void
protected boolean
equivalent
(Definition def1, Definition def2) protected boolean
equivalent
(Expression exp1, Expression exp2) protected void
error
(Location<XMLDocumentIdentifier> loc, String txt, Object... obj) protected <T> @Opt Resolver3.Binding<T>
findBinding
(@Opt Resolver3.Binding<T> binding, String id) Is called withcurrentLocalSubsts
; iterate through the chain ofResolver3.Binding
.protected @Opt Resolver3.Instance
protected Map<Resolver3.ImportContext,
Resolver3.Instance> findInstances
(Definition raw) protected @Opt Resolver3.ImportContext
loadImportedModule
(Location<XMLDocumentIdentifier> loc, Resolver3.ImportContext ic, String pref) Load the imported module referred to in theImportItem
with the given name, and create and store a newResolver3.ImportContext
, if not yet done.protected Resolver3.Instance
Process one reference which has not yet been classified, but already been resolved (i.e.protected void
Main service provider entry point to process all reachable references.Central service providing method.resolveAllPublics
(boolean unify) Central service providing method.protected void
rewriteFields
(Alt clone) Rewrite all sub-expessions; propagate "all are empty" upwards, or replace singleton-alternative by its only member.protected void
rewriteFields
(CharBinary clone) Rewrite all sub-expessions; propagate "all are empty" upwards, or replace singleton expression by its only member.protected void
rewriteFields
(CharSetConst clone) Simply clones.protected void
rewriteFields
(GrUnary clone) Rewrite the sub-expression; propagate "empty" upwards.protected void
rewriteFields
(ParseParticle clone) Rewrite sub-expression and propagate "empty" upwards.protected void
rewriteFields
(Perm clone) Rewrite all sub-expessions; propagate "all are empty" upwards, or replace singleton-permutation by its only member.void
rewriteFields
(Reference ref) Central rewriting method: for one particular reference, apply local rewrite, module import rewrite and inlining-expansion, in this sequential order.protected void
rewriteFields
(Seq clone) Rewrite all sub-expessions; propagate "all are empty" upwards, or replace singleton-sequence by its only member.protected void
rewriteFields
(StringConst clone) Simply clones.protected void
switchModuleRest
(Location<XMLDocumentIdentifier> loc, String... prefs) Skip the first id in compound id, since it has just been processed and caused a module import context switch, and continue to resolve the rest, if any.protected void
visitDefinition
(Location<XMLDocumentIdentifier> loc, String... prefs) We are currently rewriting a reference (the on-stock produced clone iscurrentReference
) and resolving it, and have finally applied all rewritings of all levels and reached a reference text, one identifier or more than one identifiers, joined byChars.STRING_NAMING_LEVEL_SEPARATOR
.protected void
protected void
visitPossiblyImportedDefinition
(Location<XMLDocumentIdentifier> loc, String... prefs) After all substitutions have been applied: find the source text meant by a reference.protected void
warning
(Location<XMLDocumentIdentifier> loc, String txt, Object... obj) Methods inherited from class eu.bandm.tools.d2d2.model.Rewrite
action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, breakLoop, descend_Module$definitions, descend_Module$imports, descend_TagsRegExp$localdefs, getResult, isMulti, lookUp, putToCache, revert, rewrite, rewrite_typed, rewriteFields, rewriteFields, rewriteFields, rewriteFields, rewriteFields, rewriteFields, rewriteFields, rewriteFields, rewriteFields, rewriteFields, rewriteFields, rewriteFields, rewriteFields, rewriteFields, rewriteFields, rewriteFields, rewriteFields, rewriteFields, rewriteFields, rewriteFields, rewriteFields, rewriteFields, rewriteFields, rewriteFields, rewriteFields, rewriteFields, rewriteFields, rewriteFields, rewriteFields, substitute, substitute_empty, useCache
Methods inherited from class eu.bandm.tools.d2d2.model.MATCH_ONLY_00
_visitor_trace, action, action, action, action, compile, descend_Alt$on, descend_ImportItem$globalSubsts, descend_ImportItem$localSubsts, descend_Module$modules, descend_Perm$on, descend_Seq$on, foreignObject, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, nomatch
-
Field Details
-
msg
-
msgcount
-
verbosity
protected final int verbosity -
moduleRegistry
Where imported raw modules are loaded from. -
rootModule
Input data: the source module to be resolved. -
rootImportContext
A synthetic/pseudo import context, to fulfill the role of "importContext" for the top-level module, which is indeed NOT imported. -
resolvedModule
Output data: the result of the resolution process. -
unify
protected boolean unifyWhether unification shall be used for minimization of instantiated definitions. Is set to false ONLY FOR TEST AND DEBUG purposes. -
rootModuleSymbolicName
- See Also:
-
rootModuleExpandedSuffix
- See Also:
-
emptyLocals
A constant map which contains NO local definitions, used as the value of "localDefs" when a definition is cloned/instantiated. -
currentLocalSubsts
Stack of bindings representing the nesting of local substitution expressions of formexp^(a/b)
. -
importContextForRews
Where to look for rewrite instructions coming with the "ImportItem", when rewriting references. Is initially set up bycreateNewInstance(eu.bandm.tools.d2d2.base.Resolver3.ImportContext,eu.bandm.tools.d2d2.model.Definition,@eu.bandm.tools.annotations.Opt eu.bandm.tools.d2d2.model.Reference)
to the definition's import context, before starting the rewrite of the definitions's expression.
Whenever such a substitution expression is found and before it is visited, the value of this variable it is set to the import context of that expression, which is the ".predec" of the current value ( =^= the ImportItem to evaluate), because only in this context the expressions can (in the current implementation) be interpreted.
Whenever a definition is inlined (= its expression is visited, due to an @ operator), then this variable is re-adjusted for the duration of this visit to the current value ofimportContextForDefs
, where that definition has been found.
Whenever a frozenResolver3.FlattenContext
is applied to a reference, it is among the reconstructed context state. (This is the only situation when it differs fromimportContextForDefs
, because a verbatim, non-rewritten reference to a definition is meant in the same ImportContext as the original definition currently under flattening, not in the ImportContext containing the "@ A.B.x" statement.) -
importContextForDefs
Where to look for the definition, meant by some particular reference value. Esp. in the case this reference is NOT rewritten, but meant in the same context as the containing definition. Is initially set up bycreateNewInstance(eu.bandm.tools.d2d2.base.Resolver3.ImportContext,eu.bandm.tools.d2d2.model.Definition,@eu.bandm.tools.annotations.Opt eu.bandm.tools.d2d2.model.Reference)
to the definition's import context.
Is advanced through the chain of import prefixes whenvisitPossiblyImportedDefinition(eu.bandm.tools.message.Location<eu.bandm.tools.message.XMLDocumentIdentifier>,java.lang.String...)
resolves the import prefices.
FIXME WEITERMACHEN +++ -
currentDefinitionName
The name of the definition (local to its containing module), the expression of which is currently rewritten. Is only used to select the local substitution requests of form "import A from modA IN DEFNAME ^(a/b)". Must be ==null whenever an expression is rewritten which is NOT in a definition, but in a module import rewriting. -
currentLexicalImportItem
The ImportItem when an expression is rewritten like "a" in "import A from modA ^(a/b)". Must be ==null whenever an expression is rewritten which not in such a rewrite expression but in a definition. 20181024 NOT NEEDED (war nur fürs name mangling bei "a/b^@c" ANGEDACHT !?!?) -
currentFlattenContext
Top of the stack ofResolver3.FlattenContext
s. Pushed onto when an insert operator is rewritten; popped from (in two steps) when aReference
is reached by this Rewriter and all other rewrite directives do not match. -
instances
Maps indexed by the raw (=source level) definitions. Accessed only for reading byfindInstances(eu.bandm.tools.d2d2.model.Definition)
and byfindInstance(eu.bandm.tools.d2d2.model.Definition,eu.bandm.tools.d2d2.base.Resolver3.ImportContext)
; written only bycreateNewInstance(eu.bandm.tools.d2d2.base.Resolver3.ImportContext,eu.bandm.tools.d2d2.model.Definition,@eu.bandm.tools.annotations.Opt eu.bandm.tools.d2d2.model.Reference)
. -
reference2rawDef
Central result of the rewriting process, which maps rewritten Reference objects to the definition in the "raw" source module which is meant. FINALLY via DistributeSolutions the results are entered into ".resolved" -
reference2importContext
Central result of the rewriting process, which maps rewritten Reference objects to the import context (=module import prefix chain=rewriting context) of the finally meant definition. FINALLY viaResolver3.DistributeSolutions
the results are entered into ".resolved" -
waitingForEquivalence
Set of all references which have not yet been classified for equivalence. Is filled bycreateNewInstance(eu.bandm.tools.d2d2.base.Resolver3.ImportContext,eu.bandm.tools.d2d2.model.Definition,@eu.bandm.tools.annotations.Opt eu.bandm.tools.d2d2.model.Reference)
visitDefinition(eu.bandm.tools.message.Location<eu.bandm.tools.message.XMLDocumentIdentifier>,java.lang.String...)
. ((FIXME REALLY !?!??)) -
currentReference
Reference currentReferenceThe Reference reached by the top-level rewriter. Only for convenience globally passed from rewriteFields(..) via visitPossiblyImportedDef(..), switchModuleRest, down to visitDefinition(..). COULD as well be an ordinary function parameter. -
currentHypothesis
Resolver3.Instance currentHypothesisThe instance which is currently matched against another instance which is an equivalence class, and so initiated the application of anResolver3.Equivalence
. All other hypothetical Instances reached during this will add this to their setResolver3.Instance.requiredBy
. -
tagsNotCharParser
boolean tagsNotCharParserThe kind of the parser currently under rewriting. (Enums are not rewritten at all.) -
differenceFound
-
-
Constructor Details
-
Resolver3
public Resolver3(MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msgoutput, ModuleRegistry moduleRegistry, Module rootModule, int verbosity) Central service providing method. Create a new instance for one particular raw root module. AfterwardsresolveAllPublics()
must be called. (Can only by used once.)
-
-
Method Details
-
resolveAllPublics
Central service providing method.- Returns:
- a copy of the top module with all references replaced by references to resolved definitions. Returns null in case of error.
-
resolveAllPublics
Central service providing method.- Returns:
- a copy of the top module with all references replaced by references to resolved definitions. Returns null in case of error.
-
error
-
warning
-
findBinding
@Opt protected <T> @Opt Resolver3.Binding<T> findBinding(@Opt @Opt Resolver3.Binding<T> binding, String id) Is called withcurrentLocalSubsts
; iterate through the chain ofResolver3.Binding
.- Returns:
- the first one which maps "id", or null if none is found.
-
dumpInstances
public void dumpInstances() -
findInstances
-
findInstance
-
createNewInstance
protected Resolver3.Instance createNewInstance(Resolver3.ImportContext ic, Definition raw, @Opt @Opt Reference reprRef) Central routine for processing a new instantiation of a particular definition in a particular import context.
In case ofXRegExp
: Calls the main class visitor methods for applying all rewriting expressions to the def's value. (During this, moreReference
s may be added towaitingForEquivalence
.)
Additionally memorizes/reifies all context values into the one single returnedResolver3.Instance
object.
Sets up the state machine for the later classification process.
State of the state machine when returning: isClass, hypothetical, falsified, requires are all false; representative is null.
Is called for top-level classes, and "isClass" is set immediately.
Is called duringprocessWaitingReference(Reference)
and NOT made own class, but first made hypothetically equivalent with all other class-like instances first.
NEW hypotheses (of being equivalent with another class instance) are created byResolver3.Instance.newHypothesis(Instance)
, possibly reusing the object structure physically. -
action
Simply insert a newResolver3.Binding
on top of the stack of local substs, then descend into the sub-expression. Remove the binding on return. -
action
Insert a newResolver3.FlattenContext
on top of the stack of flatten contexts, then descend into the sub-expression. Remove the binding on return. -
rewriteFields
Rewrite the sub-expression; propagate "empty" upwards.- Overrides:
rewriteFields
in classRewrite
-
rewriteFields
Rewrite all sub-expessions; propagate "all are empty" upwards, or replace singleton-alternative by its only member.- Overrides:
rewriteFields
in classRewrite
-
rewriteFields
Rewrite all sub-expessions; propagate "all are empty" upwards, or replace singleton-permutation by its only member.- Overrides:
rewriteFields
in classRewrite
-
rewriteFields
Rewrite all sub-expessions; propagate "all are empty" upwards, or replace singleton-sequence by its only member.- Overrides:
rewriteFields
in classRewrite
-
rewriteFields
Rewrite all sub-expessions; propagate "all are empty" upwards, or replace singleton expression by its only member.- Overrides:
rewriteFields
in classRewrite
-
rewriteFields
Rewrite sub-expression and propagate "empty" upwards.- Overrides:
rewriteFields
in classRewrite
-
rewriteFields
Simply clones.- Overrides:
rewriteFields
in classRewrite
-
rewriteFields
Simply clones.- Overrides:
rewriteFields
in classRewrite
-
action
-
rewriteFields
Central rewriting method: for one particular reference, apply local rewrite, module import rewrite and inlining-expansion, in this sequential order.- Overrides:
rewriteFields
in classRewrite
-
visitPossiblyImportedDefinition
-
visitPossiblyImportedDefinition
protected void visitPossiblyImportedDefinition(Location<XMLDocumentIdentifier> loc, String... prefs) After all substitutions have been applied: find the source text meant by a reference. This can be a compound identifier, and its first component MAY be an import prefix. If not, callvisitDefinition(eu.bandm.tools.message.Location<eu.bandm.tools.message.XMLDocumentIdentifier>,java.lang.String...)
.
Else an import must be processed: First resolve the chain of "module import substitutions". Then load the required raw module. Do so until the start of the name of a definition is reached (i.e. head of id-list is not an import key). This chain is cycle-free by construction. In sync with this resolution: update the global variableimportContextForDefs
and the caches of loaded raw modules. -
switchModuleRest
Skip the first id in compound id, since it has just been processed and caused a module import context switch, and continue to resolve the rest, if any. -
loadImportedModule
@Opt protected @Opt Resolver3.ImportContext loadImportedModule(Location<XMLDocumentIdentifier> loc, Resolver3.ImportContext ic, String pref) Load the imported module referred to in theImportItem
with the given name, and create and store a newResolver3.ImportContext
, if not yet done.- Parameters:
ic
- the import context from which the module is importedpref
- the source text prefix of the import.
-
visitDefinition
We are currently rewriting a reference (the on-stock produced clone iscurrentReference
) and resolving it, and have finally applied all rewritings of all levels and reached a reference text, one identifier or more than one identifiers, joined byChars.STRING_NAMING_LEVEL_SEPARATOR
.
prefs[0] is NOT in import items key set, so we expect a Definition in the module addressed by the GLO IN variableimportContextForDefs
. -
processWaitingReferences
protected void processWaitingReferences()Main service provider entry point to process all reachable references. It picks an arbitrary entity fromwaitingForEquivalence
and callsprocessWaitingReference(eu.bandm.tools.d2d2.model.Reference)
. Processing means resolving all substitutions and classifying the adressed (rewritten) Definition into equivalence classes.
That pool of unprocessed references is filled bycreateNewInstance(ImportContext,Definition,Reference)
, namely when visiting the definion's expression. This is called initially byresolveAllPublics(boolean)
and recursively during processing byprocessWaitingReference(Reference)
. -
processWaitingReference
Process one reference which has not yet been classified, but already been resolved (i.e.reference2rawDef
andreference2importContext
have been set, etc.)
If it has assigned anResolver3.Instance
object (which is not a failed hypothesis) then do nothing. Otherwise test equivalence with all Instances of the same raw definition, which are own equivalence classes. For this, a hypothetical equivalence is constructed andequivalent(eu.bandm.tools.d2d2.model.Definition,eu.bandm.tools.d2d2.model.Definition)
is called. If this succeeds, the hypothesis is confirmed. If all these fail, the Instance is made an equivalence class on its own. -
equivalent
-
equivalent
-