|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jmlspecs.jml4.rac.RacTranslator
public abstract class RacTranslator
Abstract superclass defining several utility methods for RAC translation.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.jmlspecs.jml4.rac.RacConstants |
---|
RacConstants.Behavior, RacConstants.Condition |
Field Summary |
---|
Constructor Summary | |
---|---|
RacTranslator()
|
Method Summary | |
---|---|
static java.lang.StringBuffer |
argumentsToString(AbstractMethodDeclaration meth)
Returns the arguments of the given method as a comma-separated list of names. |
static java.lang.StringBuffer |
argumentsToString(MethodBinding meth)
Returns the arguments of the given method as a comma-separated list of names. |
static ImportReference[] |
createImportForRacRuntimePackage(CompilationUnitDeclaration cunit)
Creates and returns an import statement to import RAC tuntime package ( org.jmlspecs.jml4.rac.runtime ) if the given compilation
unit doesn't import it; otherwise, returns null. |
static java.lang.String |
escapeString(char[] val)
Returns a String formed by translating Unicode characters for the standard Java escape sequences into the corresponding escape sequences from JLS2, 3.10.6. |
static java.lang.String |
escapeString(java.lang.String val)
Returns a String formed by translating Unicode characters for the standard Java escape sequences into the corresponding escape sequences from JLS2, 3.10.6. |
static java.lang.String |
escapeString(java.lang.String val,
boolean escapeApostrophes)
Returns a String formed by translating Unicode characters for the standard Java escape sequences into the corresponding escape sequences from JLS2, 3.10.6. |
static java.lang.String |
getBoxedValue(TypeBinding binding,
java.lang.String varName)
Returns a boxed value. |
static int |
getCharacterNumber(int pos,
CompilationResult cresult)
Given a compilation result, returns the character number of the given position counted in the line in which the character appears. |
static java.lang.String |
getClassType(TypeBinding binding)
Return the class object of the given type. |
static char[] |
getDeclaringClassName(AbstractMethodDeclaration meth)
Returns the name of the class that declaring the given method. |
static char[] |
getDeclaringClassName(FieldBinding bind)
Returns the name of the class that declaring the given field. |
static java.lang.String |
getDefaultValue(TypeBinding binding)
Returns the default value of the given type. |
static java.lang.StringBuffer |
getErrorLocation(int pos,
CompilationResult cresult)
Given a compilation result, returns the location information of a source position. |
static java.lang.String |
getFullyQualifiedName(TypeBinding binding)
Returns the fully qualified name of the given type. |
static java.lang.String |
getFullyQualifiedName(TypeReference ref)
Returns the fully qualified name of the given type. |
static int |
getLineNumber(int pos,
CompilationResult cresult)
Given a compilation result, returns the line number of the given position. |
static java.lang.StringBuffer |
getRacErrorLocation(int pos,
CompilationResult cresult)
Given a compilation result, returns the location information of a source position. |
static JmlMethodSpecification |
getSpecification(AbstractMethodDeclaration meth)
Returns the specification of the given method or constructor. |
static java.lang.String |
getUnboxedValue(TypeBinding binding,
java.lang.String code)
Given code for a (boxed) expression of the given type, returns code that, if evaluated, will give the value boxed in the expression. |
static java.lang.String |
getWrapperType(TypeBinding binding)
Given a primitive type, returns its wrapper type; otherwise, return null . |
static boolean |
hasVoidReturnType(JmlMethodDeclaration meth)
Does the given method have void return type? |
static boolean |
hasVoidReturnType(MethodBinding meth)
Does the given method have void return type? |
static boolean |
isGhostField(FieldDeclaration field)
Is the given field a JML ghost field? A field is a JML ghost field if it has a Ghost annotation. |
static boolean |
isModelField(FieldDeclaration field)
Is the given field a JML model field? A field is a JML model field if it has a Model annotation. |
static RacMethodDeclaration |
makeMethod(java.lang.StringBuffer body,
CompilationResult result)
Creates a method declaration with given body using the given compilation result. |
static RacMethodDeclaration |
makeMethod(java.lang.String body,
CompilationResult result)
Creates a method declaration with given body using the given compilation result. |
static RacMethodDeclaration |
makeMethod(java.lang.String body,
int modifiers,
CompilationResult result)
Creates a method declaration with given body and modifiers using the given compilation result. |
static java.lang.StringBuffer |
parameterDeclarationToString(AbstractMethodDeclaration meth)
Returns the formal parameter declaration of the given method as a string. |
static java.lang.StringBuffer |
parameterDeclarationToString(MethodBinding meth)
Returns the formal parameter declaration of the given method as a string. |
static java.lang.StringBuffer |
racErrorDeclaration(int tab,
java.lang.String errorVar,
java.lang.String stateVar)
Returns an indented code that declares two RAC variables used for reporting an assertion violation. |
static java.lang.StringBuffer |
racErrorDefinition(int tab,
java.lang.String errorVar,
java.lang.String stateVar,
int sourceStart,
CompilationResult cresult,
java.util.Collection<ASTNode> terms)
Returns an indented code that defines the values of two RAC variables used for reporting an assertion violation. |
static java.util.List<MethodDeclaration> |
racMethodForName(TypeDeclaration type)
Creates RAC runtime methods for the given types. |
static java.util.List<MethodDeclaration> |
racMethodsForGhostOrModel(TypeDeclaration type)
Returns a RAC runtime method for inheriting a ghost/model field. |
static java.util.List<MethodDeclaration> |
racMethodsForSurrogate()
|
static java.util.List<MethodDeclaration> |
racRuntimeMethods(TypeDeclaration type)
Creates RAC runtime methods for the given types. |
static java.lang.StringBuffer |
throwsClauseToString(AbstractMethodDeclaration meth)
Returns the throws clause of the given method as a string. |
static java.lang.StringBuffer |
throwsClauseToString(MethodBinding meth)
Returns the throws clause of the given method as a string. |
static java.lang.String |
typeName(ReferenceBinding declaringClass)
Returns the type declaration name of declaringClass . |
static java.lang.String |
typeName(TypeDeclaration typeDecl)
Returns the type declaration name of typeDecl . |
static java.lang.String |
unescapeString(java.lang.String val)
Returns a String formed by translating Java escape sequences in the given String into single Unicode characters. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RacTranslator()
Method Detail |
---|
public static RacMethodDeclaration makeMethod(java.lang.String body, CompilationResult result)
public static RacMethodDeclaration makeMethod(java.lang.StringBuffer body, CompilationResult result)
public static RacMethodDeclaration makeMethod(java.lang.String body, int modifiers, CompilationResult result)
public static java.lang.StringBuffer argumentsToString(AbstractMethodDeclaration meth)
T1 x1, ..., Tn xn, the return value will be
x1, ..., xn
; an empty string is returned if the
method have no parameter.
public static java.lang.StringBuffer parameterDeclarationToString(AbstractMethodDeclaration meth)
T1 x1, T2 x2, ..., Tn xnIf the method has no parameter, an empty string is returned.
public static java.lang.StringBuffer throwsClauseToString(AbstractMethodDeclaration meth)
throws E1, E2, ..., EnIf the method has no throws clause, an empty string is returned.
public static java.lang.StringBuffer argumentsToString(MethodBinding meth)
T1 x1, ..., Tn xn, the return value will be
x1, ..., xn
; an empty string is returned if the
method have no parameter.
public static java.lang.StringBuffer parameterDeclarationToString(MethodBinding meth)
T1 x1, T2 x2, ..., Tn xnIf the method has no parameter, an empty string is returned.
public static java.lang.StringBuffer throwsClauseToString(MethodBinding meth)
throws E1, E2, ..., EnIf the method has no throws clause, an empty string is returned.
public static boolean hasVoidReturnType(MethodBinding meth)
public static boolean hasVoidReturnType(JmlMethodDeclaration meth)
public static boolean isGhostField(FieldDeclaration field)
Ghost
annotation.
public static boolean isModelField(FieldDeclaration field)
Model
annotation.
public static char[] getDeclaringClassName(FieldBinding bind)
public static char[] getDeclaringClassName(AbstractMethodDeclaration meth)
public static java.lang.String getFullyQualifiedName(TypeBinding binding)
java.lang.Object
.
public static java.lang.String getFullyQualifiedName(TypeReference ref)
java.lang.Object
.
public static java.lang.String getDefaultValue(TypeBinding binding)
public static java.lang.String getBoxedValue(TypeBinding binding, java.lang.String varName)
varName)
of the given type (binding) is of a primitive type,
this methods returns a string representation of its boxed value;
otherwise, it returns the variable.
I.e., new java.lang.Integer(x) if
the variable x is the int type;
x if x is a reference type.
public static java.lang.String getUnboxedValue(TypeBinding binding, java.lang.String code)
((java.lang.Integer) code).intValue()
for int and ((Sting) code)
for String.
public static java.lang.String getClassType(TypeBinding binding)
public static java.lang.String getWrapperType(TypeBinding binding)
null
. I.e., java.lang.Integer
for int,
public static int getCharacterNumber(int pos, CompilationResult cresult)
public static int getLineNumber(int pos, CompilationResult cresult)
public static java.lang.StringBuffer getErrorLocation(int pos, CompilationResult cresult)
File: MyClass.java Line: 10 Character: 20
public static java.lang.StringBuffer getRacErrorLocation(int pos, CompilationResult cresult)
new JMLAssertionError.location("MyClass.java", 10, 20)
public static JmlMethodSpecification getSpecification(AbstractMethodDeclaration meth)
public static java.util.List<MethodDeclaration> racMethodForName(TypeDeclaration type)
rac$forName
method.
public static java.util.List<MethodDeclaration> racRuntimeMethods(TypeDeclaration type)
public static java.util.List<MethodDeclaration> racMethodsForSurrogate()
public static java.util.List<MethodDeclaration> racMethodsForGhostOrModel(TypeDeclaration type)
racRuntimeMethods(TypeDeclaration)
.
public static java.lang.StringBuffer racErrorDeclaration(int tab, java.lang.String errorVar, java.lang.String stateVar)
java.util.Set errorVar = new java.util.HashSet(); java.util.MapstateVar = new java.util.HashMap ();
public static java.lang.StringBuffer racErrorDefinition(int tab, java.lang.String errorVar, java.lang.String stateVar, int sourceStart, CompilationResult cresult, java.util.Collection<ASTNode> terms)
errorVar.add(new JMLAssertionError.Location("X.java", 4, 14)); stateVar.put("x1", x1); ... stateVar.put("xn", xn);where the error location is calculating using
sourceStar
and cresult
, and each xi
is a node
contained in terms
.
public static ImportReference[] createImportForRacRuntimePackage(CompilationUnitDeclaration cunit)
org.jmlspecs.jml4.rac.runtime
) if the given compilation
unit doesn't import it; otherwise, returns null.
public static final java.lang.String unescapeString(java.lang.String val)
escapeString(String)
public static final java.lang.String escapeString(java.lang.String val)
escapeString(String,boolean)
,
unescapeString(String)
public static final java.lang.String escapeString(char[] val)
escapeString(String,boolean)
,
unescapeString(String)
public static final java.lang.String escapeString(java.lang.String val, boolean escapeApostrophes)
unescapeString(String)
public static java.lang.String typeName(TypeDeclaration typeDecl)
typeDecl
. It returns
the simple name of the type preceded by the package name.
typeDecl
-
public static java.lang.String typeName(ReferenceBinding declaringClass)
declaringClass
. It
returns the simple name of the type preceded by the package name.
typeDecl
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |