public class ExecutableBooleanExpression
extends java.lang.Object
ExecutableBooleanExpression represents a boolean Java expression, and allows evaluation
on argument values.
This is the executable form of AbstractBooleanExpression.
SpecificationTranslator| Modifier and Type | Field and Description |
|---|---|
private static NameGenerator |
classNameGenerator
The name generator to use to generate class names.
|
private java.lang.String |
comment
The comment describing this expression.
|
private java.lang.String |
contractSource
The Java source code in
ObjectContract format. |
private java.lang.reflect.Method |
expressionMethod
The
java.lang.reflect.Method to test this expression. |
| Constructor and Description |
|---|
ExecutableBooleanExpression(java.lang.reflect.Method expressionMethod,
java.lang.String comment,
java.lang.String contractSource)
Creates a
ExecutableBooleanExpression that calls the method to evaluate the expression. |
ExecutableBooleanExpression(RawSignature signature,
java.lang.String declarations,
java.lang.String expressionSource,
java.lang.String contractSource,
java.lang.String comment,
SequenceCompiler compiler)
Creates a
ExecutableBooleanExpression for evaluating an expression (see Guard) of a specification. |
| Modifier and Type | Method and Description |
|---|---|
(package private) ExecutableBooleanExpression |
addPrestate(java.lang.Object[] args)
Returns the
ExecutableBooleanExpression that checks the expression with the given
argument values as the pre-state. |
boolean |
check(java.lang.Object[] values)
Indicate whether this expression is satisfied by the given values.
|
private static java.lang.String |
createConditionClassSource(java.lang.String methodName,
java.lang.String expressionText,
java.lang.String parameterDeclarations,
java.lang.String packageName,
java.lang.String expressionClassName)
Create the source code for the expression class.
|
(package private) static java.lang.reflect.Method |
createMethod(RawSignature signature,
java.lang.String parameterDeclaration,
java.lang.String expressionSource,
SequenceCompiler compiler)
Creates a
java.lang.reflect.Method to test the expression given by contractSource. |
boolean |
equals(@Nullable java.lang.Object object) |
java.lang.String |
getComment()
Return the code comment for this expression.
|
private static java.lang.String |
getCompilerErrorMessage(java.util.List<javax.tools.Diagnostic<? extends javax.tools.JavaFileObject>> diagnostics,
java.lang.String classText)
Gets the compilation error message for the expression class from the compiler diagnostics
object.
|
java.lang.String |
getContractSource()
Return the Java source code for this expression.
|
int |
hashCode() |
java.lang.String |
toString() |
private static final NameGenerator classNameGenerator
private final java.lang.reflect.Method expressionMethod
java.lang.reflect.Method to test this expression. The method is static (it does not
take a receiver argument).private final java.lang.String comment
private final java.lang.String contractSource
ObjectContract format. See getContractSource() for
format details.ExecutableBooleanExpression(java.lang.reflect.Method expressionMethod,
java.lang.String comment,
java.lang.String contractSource)
ExecutableBooleanExpression that calls the method to evaluate the expression.expressionMethod - the reflection Method for the expressioncomment - a comment describing this expressioncontractSource - the source code for this expression (see getContractSource() for
format details)ExecutableBooleanExpression(RawSignature signature, java.lang.String declarations, java.lang.String expressionSource, java.lang.String contractSource, java.lang.String comment, SequenceCompiler compiler)
ExecutableBooleanExpression for evaluating an expression (see Guard) of a specification.signature - the signature for the expression method to be created. The class name of the
expression method signature is ignored and a new name is generated using classNameGenerator.declarations - the parameter declaration string for the expression method to be created,
including parameter names and wrapped in parenthesesexpressionSource - the source code for a Java expression to be used as the body of the
expression methodcontractSource - a Java expression that is the source code for the expression, in the
format of getContractSource(). The same as expressionSource, except that
it uses dummy variable names x0, x1, instead of formal parameter names.comment - the comment describing the expressioncompiler - the compiler to used to compile the expression methodExecutableBooleanExpression addPrestate(java.lang.Object[] args)
ExecutableBooleanExpression that checks the expression with the given
argument values as the pre-state.
Since pre-state is not yet implemented, this method just returns this object.
args - the pre-state values to the argumentsExecutableBooleanExpression with the pre-state setpublic boolean equals(@Nullable java.lang.Object object)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Objectpublic boolean check(java.lang.Object[] values)
values - the values to check the expression againstpublic java.lang.String getComment()
public java.lang.String getContractSource()
ObjectContract convention where parameters (including the receiver, if any)
are represented by x0, ..., xn for some number n. If the operation has
a return value it will be xn (the last, extra variable).Stringstatic java.lang.reflect.Method createMethod(RawSignature signature, java.lang.String parameterDeclaration, java.lang.String expressionSource, SequenceCompiler compiler)
java.lang.reflect.Method to test the expression given by contractSource.
Generates the Java source for a class with the method, compiles the class, and returns the expression method.
signature - the signature for the expression method. The class name of the expression
method signature is ignored and a new name is generated using classNameGenerator.parameterDeclaration - the parameter declaration string, including parameter names and
wrapped in parenthesesexpressionSource - a Java expression that is the source code for the expression, in the
format of getContractSource()compiler - the compiler to use to compile the expression classMethod object for contractSourceprivate static java.lang.String createConditionClassSource(java.lang.String methodName,
java.lang.String expressionText,
java.lang.String parameterDeclarations,
java.lang.String packageName,
java.lang.String expressionClassName)
methodName - the name of the expression methodexpressionText - the expression source code -- a boolean Java expressionparameterDeclarations - the signature string for the expression methodpackageName - the package of the expression class, or null for the default packageexpressionClassName - the name of the expression classprivate static java.lang.String getCompilerErrorMessage(java.util.List<javax.tools.Diagnostic<? extends javax.tools.JavaFileObject>> diagnostics,
java.lang.String classText)
diagnostics - the compiler diagnostics objectclassText - the source code of the expression class