Homework B (benchmarks)
This commit is contained in:
parent
72cc3206c4
commit
76fbabdf53
141 changed files with 7540 additions and 2032 deletions
|
@ -1,40 +1,50 @@
|
|||
package cd.frontend.semantic;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Thrown by the semantic checker when a semantic error is detected
|
||||
* in the user's program. */
|
||||
* in the user's program.
|
||||
*/
|
||||
public class SemanticFailure extends RuntimeException {
|
||||
private static final long serialVersionUID = 5375946759285719123L;
|
||||
|
||||
|
||||
public enum Cause {
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Caused by an assignment to either a final field, {@code this},
|
||||
* or some other kind of expression which cannot be assigned to.
|
||||
* <b>Not</b> used for type errors in assignments, which fall
|
||||
* under {@link #TYPE_ERROR}. */
|
||||
* under {@link #TYPE_ERROR}.
|
||||
*/
|
||||
NOT_ASSIGNABLE,
|
||||
|
||||
/** Two variables, fields, methods, or classes with the same name
|
||||
* were declared in the same scope */
|
||||
/**
|
||||
* Two variables, fields, methods, or classes with the same name
|
||||
* were declared in the same scope
|
||||
*/
|
||||
DOUBLE_DECLARATION,
|
||||
|
||||
/** A field was accessed that does not exist */
|
||||
/**
|
||||
* A field was accessed that does not exist
|
||||
*/
|
||||
NO_SUCH_FIELD,
|
||||
|
||||
/** A method was called that does not exist */
|
||||
|
||||
/**
|
||||
* A method was called that does not exist
|
||||
*/
|
||||
NO_SUCH_METHOD,
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* A variable or other identifier was used in a method
|
||||
* body which has no corresponding declaration */
|
||||
* body which has no corresponding declaration
|
||||
*/
|
||||
NO_SUCH_VARIABLE,
|
||||
|
||||
/**
|
||||
* A method with a return type is missing a return statement among one of its paths */
|
||||
|
||||
/**
|
||||
* A method with a return type is missing a return statement among one of its paths
|
||||
*/
|
||||
MISSING_RETURN,
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Can occur in many contents:
|
||||
* <ul>
|
||||
* <li> Assignment to a variable from an expression of wrong type
|
||||
|
@ -53,12 +63,12 @@ public class SemanticFailure extends RuntimeException {
|
|||
* </ul>
|
||||
*/
|
||||
TYPE_ERROR,
|
||||
|
||||
|
||||
/**
|
||||
* A class is its own super class
|
||||
*/
|
||||
CIRCULAR_INHERITANCE,
|
||||
|
||||
|
||||
/**
|
||||
* One of the following:
|
||||
* <ul>
|
||||
|
@ -69,13 +79,13 @@ public class SemanticFailure extends RuntimeException {
|
|||
* </ul>
|
||||
*/
|
||||
INVALID_START_POINT,
|
||||
|
||||
|
||||
/**
|
||||
* A class {@code Object} was defined. This class is implicitly
|
||||
* defined and cannot be defined explicitly.
|
||||
*/
|
||||
OBJECT_CLASS_DEFINED,
|
||||
|
||||
|
||||
/**
|
||||
* A type name was found for which no class declaration exists.
|
||||
* This can occur in many contexts:
|
||||
|
@ -86,34 +96,36 @@ public class SemanticFailure extends RuntimeException {
|
|||
* </ul>
|
||||
*/
|
||||
NO_SUCH_TYPE,
|
||||
|
||||
|
||||
/**
|
||||
* The parameters of an overridden method have different types
|
||||
* from the base method, there is a different
|
||||
* from the base method, there is a different
|
||||
* number of parameters, or the return value is different.
|
||||
*/
|
||||
INVALID_OVERRIDE,
|
||||
|
||||
/** A method was called with the wrong number of arguments */
|
||||
|
||||
/**
|
||||
* A method was called with the wrong number of arguments
|
||||
*/
|
||||
WRONG_NUMBER_OF_ARGUMENTS,
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Indicates the use of a local variable that may not have been
|
||||
* initialized (ACD only).
|
||||
*/
|
||||
POSSIBLY_UNINITIALIZED,
|
||||
}
|
||||
|
||||
|
||||
public final Cause cause;
|
||||
|
||||
|
||||
public SemanticFailure(Cause cause) {
|
||||
super(cause.name());
|
||||
this.cause = cause;
|
||||
}
|
||||
|
||||
|
||||
public SemanticFailure(Cause cause, String format, Object... args) {
|
||||
super(String.format(format, args));
|
||||
this.cause = cause;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue