Package de.jplag.semantics
Class CodeSemantics
java.lang.Object
de.jplag.semantics.CodeSemantics
Contains semantic information about a code snippet, in our case either a token or a statement.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates new semantics with the following meaning: The code snippet may be removed, and its position relative to other code snippets may change. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a variable to the set of variables which were (potentially) read from in this code snippet.voidAdd a variable to the set of variables which were (potentially) written to in this code snippet.intstatic CodeSemanticsstatic CodeSemanticsstatic CodeSemanticsstatic CodeSemanticsstatic CodeSemanticsbooleanbooleanstatic CodeSemanticsjoin(List<CodeSemantics> semanticsList) Create new joint semantics by joining a number of existing ones.booleankeep()voidMark this code snippet as having full position significance.voidmarkKeep()Mark this code snippet as having to be kept.reads()toString()writes()
-
Constructor Details
-
CodeSemantics
public CodeSemantics()Creates new semantics with the following meaning: The code snippet may be removed, and its position relative to other code snippets may change. Example: An assignment to a local variable.
-
-
Method Details
-
createKeep
- Returns:
- new semantics with the following meaning: The code snippet may not be removed, and its position relative to other code snippets may change. Example: An attribute declaration.
-
createCritical
- Returns:
- new semantics with the following meaning: The code snippet may not be removed, and its position must stay invariant to other code snippets of the same type. Example: A method call which is guaranteed to not result in an exception.
-
createControl
- Returns:
- new semantics with the following meaning: The code snippet may not be removed, and its position must stay invariant to all other code snippets. Example: A return statement.
-
createLoopBegin
- Returns:
- new semantics with the following meaning: The code snippet may not be removed, and its position must stay invariant to all other code snippets, which also begins a bidirectional block. Example: The beginning of a while loop.
-
createLoopEnd
- Returns:
- new semantics with the following meaning: The code snippet may not be removed, and its position must stay invariant to all other code snippets, which also ends a bidirectional block. Example: The end of a while loop.
-
keep
public boolean keep()- Returns:
- whether this code snippet must be kept.
-
markKeep
public void markKeep()Mark this code snippet as having to be kept. -
bidirectionalBlockDepthChange
public int bidirectionalBlockDepthChange()- Returns:
- the change this code snippet causes in the depth of bidirectional loops.
-
hasPartialPositionSignificance
public boolean hasPartialPositionSignificance()- Returns:
- whether this code snippet has partial position significance.
-
hasFullPositionSignificance
public boolean hasFullPositionSignificance()- Returns:
- whether this code snippet has full position significance.
-
markFullPositionSignificance
public void markFullPositionSignificance()Mark this code snippet as having full position significance. -
reads
- Returns:
- an unmodifiable set of the variables which were (potentially) read from in this code snippet.
-
writes
- Returns:
- an unmodifiable set of the variables which were (potentially) written to in this code snippet.
-
addRead
Add a variable to the set of variables which were (potentially) read from in this code snippet.- Parameters:
variable- The variable which is added.
-
addWrite
Add a variable to the set of variables which were (potentially) written to in this code snippet.- Parameters:
variable- The variable which is added.
-
join
Create new joint semantics by joining a number of existing ones. It has the following properties:- keep is the disjunction of all keeps
- position significance is the most significant
- bidirectionalBlockDepthChange is the sum of all bidirectionalBlockDepthChanges
- reads is the union of all reads
- writes is the union of all writes
- Parameters:
semanticsList- A list of the semantics which should be joined.- Returns:
- New semantics which were created by joining the elements in the semanticsList.
-
toString
-