-
Notifications
You must be signed in to change notification settings - Fork 144
[SQL] Compiler analysis to detect potentially "unbounded" state #6714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b1fa8a3
b457268
b330f51
4794994
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| package org.dbsp.sqlCompiler.compiler.visitors.outer; | ||
|
|
||
| import org.dbsp.sqlCompiler.circuit.operator.DBSPOperator; | ||
| import org.dbsp.sqlCompiler.compiler.DBSPCompiler; | ||
| import org.dbsp.sqlCompiler.compiler.errors.SourcePositionRange; | ||
| import org.dbsp.sqlCompiler.compiler.errors.SourcePositionRanges; | ||
| import org.dbsp.sqlCompiler.compiler.visitors.inner.InnerVisitor; | ||
| import org.dbsp.sqlCompiler.ir.DBSPParameter; | ||
| import org.dbsp.sqlCompiler.ir.IDBSPInnerNode; | ||
| import org.dbsp.sqlCompiler.ir.expression.DBSPExpression; | ||
|
|
||
| import java.util.HashSet; | ||
| import java.util.Set; | ||
|
|
||
| /** Visitor which extracts source position information from the various properties of an operator */ | ||
| public class FindSourcePositions extends InnerVisitor { | ||
| public final Set<SourcePositionRange> positions; | ||
| private final boolean reset; | ||
|
|
||
| public FindSourcePositions(DBSPCompiler compiler, boolean reset) { | ||
| super(compiler); | ||
| this.positions = new HashSet<>(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is an odd syntax HashSet<>
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This has been unchanged in Java for at least 20 years. It means "compiler should infer the type arguments". |
||
| this.reset = reset; | ||
| } | ||
|
|
||
| @Override | ||
| public void postorder(DBSPExpression expression) { | ||
| SourcePositionRange positionRange = expression.getNode().getPositionRange(); | ||
| if (positionRange.isValid()) | ||
| this.positions.add(positionRange); | ||
| } | ||
|
|
||
| @Override | ||
| public void postorder(DBSPParameter parameter) { | ||
| SourcePositionRange positionRange = parameter.getNode().getPositionRange(); | ||
| if (positionRange.isValid()) | ||
| this.positions.add(positionRange); | ||
| } | ||
|
|
||
| @Override | ||
| public void startVisit(IDBSPInnerNode node) { | ||
| super.startVisit(node); | ||
| if (this.reset) | ||
| this.positions.clear(); | ||
| } | ||
|
|
||
| public SourcePositionRanges getPositions() { | ||
| return new SourcePositionRanges(this.positions); | ||
| } | ||
|
|
||
| /** Find the source positions associated with the specified operator */ | ||
| public static SourcePositionRanges getPositions(DBSPCompiler compiler, DBSPOperator operator) { | ||
| FindSourcePositions positions = new FindSourcePositions(compiler, true); | ||
| operator.accept(positions); | ||
| positions.positions.addAll(operator.getSourcePositions()); | ||
| return positions.getPositions(); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class used to be nested inside another one, it is unchanged otherwise.