Commit f018ae26 authored by Miklos Magyari's avatar Miklos Magyari
Browse files

OOP: added timestamp for checking extends list


Signed-off-by: Miklos Magyari's avatarMiklos Magyari <miklos.magyari@sigmatechnology.se>
parent 816b1942
......@@ -262,7 +262,7 @@ public final class ClassTypeBody extends TTCN3Scope implements IReferenceChainEl
extendsReferences.check(timestamp);
final List<ClassTypeBody> bodies = getExtendsInheritedClassBodies();
final List<ClassTypeBody> bodies = getExtendsInheritedClassBodies(timestamp);
for (final ClassTypeBody body : bodies) {
final Map<String, Definition> subDefinitionMap = body.getDefinitionMap();
for (final Definition definition : subDefinitionMap.values()) {
......@@ -364,15 +364,16 @@ public final class ClassTypeBody extends TTCN3Scope implements IReferenceChainEl
*
* @return the collected class type bodies.
* */
public List<ClassTypeBody> getExtendsInheritedClassBodies() {
public List<ClassTypeBody> getExtendsInheritedClassBodies(CompilationTimeStamp timestamp) {
final List<ClassTypeBody> result = new ArrayList<ClassTypeBody>();
final LinkedList<ClassTypeBody> toBeChecked = new LinkedList<ClassTypeBody>(extendsReferences.getClassBodies());
extendsReferences.check(timestamp);
final LinkedList<ClassTypeBody> toBeChecked = new LinkedList<ClassTypeBody>(extendsReferences.getClassBodies(timestamp));
while(!toBeChecked.isEmpty()) {
final ClassTypeBody body = toBeChecked.removeFirst();
if(!result.contains(body)) {
result.add(body);
if (body.extendsReferences != null && body.extendsReferences.getClassBodies() != null) {
for(final ClassTypeBody subBody : body.extendsReferences.getClassBodies()) {
if (body.extendsReferences != null && body.extendsReferences.getClassBodies(null) != null) {
for(final ClassTypeBody subBody : body.extendsReferences.getClassBodies(null)) {
if(!result.contains(subBody) && !toBeChecked.contains(subBody)) {
toBeChecked.add(subBody);
}
......@@ -385,7 +386,7 @@ public final class ClassTypeBody extends TTCN3Scope implements IReferenceChainEl
}
public Assignment getAssFromParents(final CompilationTimeStamp timestamp, final Reference reference) {
final LinkedList<ClassTypeBody> toBeChecked = new LinkedList<ClassTypeBody>(extendsReferences.getClassBodies());
final LinkedList<ClassTypeBody> toBeChecked = new LinkedList<ClassTypeBody>(extendsReferences.getClassBodies(null));
Assignment assignment = null;
for (ClassTypeBody body : toBeChecked) {
......
......@@ -71,7 +71,10 @@ public final class ClassTypeReferenceList extends ASTNode implements ILocateable
this.myClass = parentClass;
}
public List<ClassTypeBody> getClassBodies() {
public List<ClassTypeBody> getClassBodies(CompilationTimeStamp timestamp) {
if (timestamp != null) {
checkUniqueness(timestamp);
}
return orderedClassTypeBodies;
}
......
......@@ -554,14 +554,16 @@ public final class Class_Type extends Type implements ITypeWithComponents {
* @param class to be checked
* @return
*/
public boolean isRelatedClass(Class_Type related) {
List<ClassTypeBody> bodies = getClassBody().getExtendsInheritedClassBodies();
public boolean isRelatedClass(CompilationTimeStamp timestamp, Class_Type related) {
getClassBody().check(timestamp);
List<ClassTypeBody> bodies = getClassBody().getExtendsInheritedClassBodies(timestamp);
for (ClassTypeBody body : bodies) {
if (body.getMyType() == related) {
return true;
}
}
List<ClassTypeBody> relatedBodies = related.getClassBody().getExtendsInheritedClassBodies();
related.getClassBody().check(timestamp);
List<ClassTypeBody> relatedBodies = related.getClassBody().getExtendsInheritedClassBodies(timestamp);
for (ClassTypeBody body : relatedBodies) {
if (body.getMyType() == this) {
return true;
......
......@@ -90,7 +90,7 @@ public class ClassCastingExpression extends Expression_Value {
}
}
if (leftClass != null && rightClass != null) {
if (leftClass.isRelatedClass(rightClass) == false) {
if (leftClass.isRelatedClass(timestamp, rightClass) == false) {
getLocation().reportSemanticError(CASTINGTOUNRELATED);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment