Class SmtTextBuilder
- java.lang.Object
-
- ru.ispras.fortress.solver.engine.smt.SmtTextBuilder
-
- All Implemented Interfaces:
ExprTreeVisitor
,TreeVisitor
public final class SmtTextBuilder extends java.lang.Object implements ExprTreeVisitor
TheSMTTextBuilder
class implements logic that generates SMT-LIB code from a syntax structure.Generated code is saved to a text file.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface ru.ispras.fortress.util.TreeVisitor
TreeVisitor.Status
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int[]
getOperandOrder()
Returns an array of operand indexes that specify in which order the operands of the currently visited operator should be visited.TreeVisitor.Status
getStatus()
Returns the current status of the visitor.void
onBegin()
Notifies that processing of a hierarchical structure has been started.void
onBindingBegin(NodeBinding node)
Starts visiting a binding node.void
onBindingEnd(NodeBinding node)
Finishes visiting a binding node.void
onBindingListEnd(NodeBinding node)
Notifies that visiting a bound variables list finished.void
onBoundVariableBegin(NodeBinding node, NodeVariable variable, Node value)
Notifies that visiting a bound variable has started.void
onBoundVariableEnd(NodeBinding node, NodeVariable variable, Node value)
Notifies that visiting a bound variable has finished.void
onEnd()
Notifies that processing of a hierarchical structure has been finished.void
onOperandBegin(NodeOperation expr, Node node, int index)
Notifies that visiting an expression operand has started.void
onOperandEnd(NodeOperation expr, Node node, int index)
Notifies that visiting an expression operand has finished.void
onOperationBegin(NodeOperation expr)
Starts visiting an operation node.void
onOperationEnd(NodeOperation expr)
Finishes visiting an operation node.void
onValue(NodeValue value)
Notifies that a value node has been visited.void
onVariable(NodeVariable variable)
Notifies that a variable node has been visited.void
saveToFile(java.lang.String fileName, java.lang.StringBuilder textBuilder)
Saves the generated SMT-LIB representation to a text file.static void
saveToFile(java.lang.String fileName, java.util.List<java.lang.String> header, java.util.Collection<? extends Node> formulas, java.util.Map<java.lang.Enum<?>,SolverOperation> operations)
Saves the specified data to the file.
-
-
-
Method Detail
-
saveToFile
public static void saveToFile(java.lang.String fileName, java.util.List<java.lang.String> header, java.util.Collection<? extends Node> formulas, java.util.Map<java.lang.Enum<?>,SolverOperation> operations)
Saves the specified data to the file.- Parameters:
fileName
- The file name.header
- The data header.formulas
- The formulas to be saved.operations
- The operations to be saved. // * @throws IOException
-
saveToFile
public void saveToFile(java.lang.String fileName, java.lang.StringBuilder textBuilder) throws java.io.IOException
Saves the generated SMT-LIB representation to a text file.- Parameters:
fileName
- The name of the target file.textBuilder
- Build to put text to be printed in the console.- Throws:
java.io.IOException
- if failed to create the output file.
-
getStatus
public TreeVisitor.Status getStatus()
Description copied from interface:TreeVisitor
Returns the current status of the visitor. The status guides further actions of the walker.- Specified by:
getStatus
in interfaceTreeVisitor
- Returns:
- Current visitor status.
-
onBegin
public void onBegin()
Description copied from interface:TreeVisitor
Notifies that processing of a hierarchical structure has been started.- Specified by:
onBegin
in interfaceTreeVisitor
-
onEnd
public void onEnd()
Description copied from interface:TreeVisitor
Notifies that processing of a hierarchical structure has been finished.- Specified by:
onEnd
in interfaceTreeVisitor
-
onOperationBegin
public void onOperationBegin(NodeOperation expr)
Description copied from interface:ExprTreeVisitor
Starts visiting an operation node.- Specified by:
onOperationBegin
in interfaceExprTreeVisitor
- Parameters:
expr
- Operation node.
-
onOperationEnd
public void onOperationEnd(NodeOperation expr)
Description copied from interface:ExprTreeVisitor
Finishes visiting an operation node.- Specified by:
onOperationEnd
in interfaceExprTreeVisitor
- Parameters:
expr
- Operation node.
-
getOperandOrder
public int[] getOperandOrder()
Description copied from interface:ExprTreeVisitor
Returns an array of operand indexes that specify in which order the operands of the currently visited operator should be visited. If the order is standard (i.e. [0..N-1]),null
is returned.- Specified by:
getOperandOrder
in interfaceExprTreeVisitor
- Returns:
- Array of operand indexes or
null
for the standard order.
-
onOperandBegin
public void onOperandBegin(NodeOperation expr, Node node, int index)
Description copied from interface:ExprTreeVisitor
Notifies that visiting an expression operand has started.- Specified by:
onOperandBegin
in interfaceExprTreeVisitor
- Parameters:
expr
- Operation node.node
- Operand node.index
- Operand index.
-
onOperandEnd
public void onOperandEnd(NodeOperation expr, Node node, int index)
Description copied from interface:ExprTreeVisitor
Notifies that visiting an expression operand has finished.- Specified by:
onOperandEnd
in interfaceExprTreeVisitor
- Parameters:
expr
- Operation node.node
- Operand node.index
- Operand index.
-
onValue
public void onValue(NodeValue value)
Description copied from interface:ExprTreeVisitor
Notifies that a value node has been visited.- Specified by:
onValue
in interfaceExprTreeVisitor
- Parameters:
value
- Value node.
-
onVariable
public void onVariable(NodeVariable variable)
Description copied from interface:ExprTreeVisitor
Notifies that a variable node has been visited.- Specified by:
onVariable
in interfaceExprTreeVisitor
- Parameters:
variable
- Variable node.
-
onBindingBegin
public void onBindingBegin(NodeBinding node)
Description copied from interface:ExprTreeVisitor
Starts visiting a binding node.- Specified by:
onBindingBegin
in interfaceExprTreeVisitor
- Parameters:
node
- Binding node.
-
onBindingListEnd
public void onBindingListEnd(NodeBinding node)
Description copied from interface:ExprTreeVisitor
Notifies that visiting a bound variables list finished.- Specified by:
onBindingListEnd
in interfaceExprTreeVisitor
- Parameters:
node
- Bounding node.
-
onBindingEnd
public void onBindingEnd(NodeBinding node)
Description copied from interface:ExprTreeVisitor
Finishes visiting a binding node.- Specified by:
onBindingEnd
in interfaceExprTreeVisitor
- Parameters:
node
- Binding node.
-
onBoundVariableBegin
public void onBoundVariableBegin(NodeBinding node, NodeVariable variable, Node value)
Description copied from interface:ExprTreeVisitor
Notifies that visiting a bound variable has started. Bound value expression will be visited next as general expression.Bound variables are not visited at all.
- Specified by:
onBoundVariableBegin
in interfaceExprTreeVisitor
- Parameters:
node
- Binding node.variable
- Bound variable reference.value
- Bound value expression.
-
onBoundVariableEnd
public void onBoundVariableEnd(NodeBinding node, NodeVariable variable, Node value)
Description copied from interface:ExprTreeVisitor
Notifies that visiting a bound variable has finished.- Specified by:
onBoundVariableEnd
in interfaceExprTreeVisitor
- Parameters:
node
- Binding node.variable
- Bound variable reference.value
- Bound value expression.
-
-