public class FieldingAnalyzer
extends java.lang.Object
Most AST nodes just propagate invalid and so use of Java exception is convenient and efficient.
The only AST nodes that respond to invalid are validating operations, so it might seem appropriate to just catch all validating operation inputs.
However VariableExps enable a value computed elsewhere to be re-used. Therefore if the re-use is by a validating operation, the computation elsewhere must be caught in the sharing LetExp.
A tree descent/ascent maintains a set of external variable references from a node and its descendants. Wherever a validating operation is encountered on the ascent, all external references from source and parameters are marked as caught variables.
A tree descent/ascent computes the isCaught state of all nodes. On the ascent children with incompatible isCaught state are corrected by insertion of a CGCaughtExp to catch a not-isCaught or a CHThrowExp to throw an isCaught..
Modifier and Type | Class and Description |
---|---|
static class |
FieldingAnalyzer.AnalysisVisitor |
static class |
FieldingAnalyzer.RewriteVisitor |
Modifier and Type | Field and Description |
---|---|
protected CodeGenAnalyzer |
analyzer |
Constructor and Description |
---|
FieldingAnalyzer(CodeGenAnalyzer analyzer) |
Modifier and Type | Method and Description |
---|---|
void |
analyze(CGElement cgTree,
boolean mustBeCaught) |
protected FieldingAnalyzer.AnalysisVisitor |
createAnalysisVisitor() |
protected FieldingAnalyzer.RewriteVisitor |
createRewriteVisitor(java.util.Set<CGVariable> caughtVariables) |
protected boolean |
isValidating(org.eclipse.emf.ecore.EObject eObject) |
void |
setCaught(java.util.Set<CGVariable> catchers) |
@NonNull protected final CodeGenAnalyzer analyzer
public FieldingAnalyzer(@NonNull CodeGenAnalyzer analyzer)
public void analyze(@NonNull CGElement cgTree, boolean mustBeCaught)
@NonNull protected FieldingAnalyzer.AnalysisVisitor createAnalysisVisitor()
@NonNull protected FieldingAnalyzer.RewriteVisitor createRewriteVisitor(@NonNull java.util.Set<CGVariable> caughtVariables)
protected boolean isValidating(org.eclipse.emf.ecore.EObject eObject)
public void setCaught(@Nullable java.util.Set<CGVariable> catchers)