Package it.unive.lisa.program
Class InterfaceUnit
- java.lang.Object
-
- it.unive.lisa.program.Unit
-
- it.unive.lisa.program.ProgramUnit
-
- it.unive.lisa.program.CompilationUnit
-
- it.unive.lisa.program.InterfaceUnit
-
- All Implemented Interfaces:
CodeElement
public class InterfaceUnit extends CompilationUnit
A interface unit of the program to analyze. A interface unit is aUnitthat only defines instance members, from which other units (bothClassUnitandInterfaceUnit) can inherit from
-
-
Field Summary
-
Fields inherited from class it.unive.lisa.program.CompilationUnit
instances
-
-
Constructor Summary
Constructors Constructor Description InterfaceUnit(CodeLocation location, Program program, java.lang.String name, boolean sealed)Builds an interface unit, defined at the given location.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddAncestor(CompilationUnit unit)Adds a newCompilationUnitas direct inheritance ancestor (i.e., superclass, interface, or superinterface) of this unit.voidaddInstance(Unit unit)Adds the given unit as an instance of this one, thus marking the former as a type that inherits from the latter.booleanaddSuperinterface(InterfaceUnit unit)Adds the givenInterfaceUnitto the list of direct ancestors of this interface.booleancanBeInstantiated()Yieldstrueif this unit can be instantiated,falseotherwise (e.g., interfaces, abstract classes).java.util.Collection<CompilationUnit>getImmediateAncestors()Yields the collection ofCompilationUnits that are this unit directly inherits from, regardless of their type.booleanisInstanceOf(CompilationUnit unit)Yieldstrueif and only if this unit is an instance of the given one.-
Methods inherited from class it.unive.lisa.program.CompilationUnit
addAnnotation, addInstanceCodeMember, addInstanceGlobal, getAbstractCodeMembers, getAnnotations, getCodeMembersRecursively, getGlobalsRecursively, getInstanceCFGs, getInstanceCodeMember, getInstanceCodeMembers, getInstanceCodeMembersByName, getInstanceConstructs, getInstanceGlobal, getInstanceGlobals, getInstances, getMatchingInstanceCodeMembers, isSealed, searchCodeMembers, searchGlobals
-
Methods inherited from class it.unive.lisa.program.ProgramUnit
getLocation, getProgram
-
Methods inherited from class it.unive.lisa.program.Unit
addCodeMember, addGlobal, getCodeMember, getCodeMembers, getCodeMembersByName, getGlobal, getGlobals, getMatchingCodeMember, getName, toString
-
-
-
-
Constructor Detail
-
InterfaceUnit
public InterfaceUnit(CodeLocation location, Program program, java.lang.String name, boolean sealed)
Builds an interface unit, defined at the given location.- Parameters:
location- the location where the unit is define within the source fileprogram- the program where this unit is definedname- the name of the unitsealed- whether or not this unit can be inherited from
-
-
Method Detail
-
canBeInstantiated
public boolean canBeInstantiated()
Description copied from class:UnitYieldstrueif this unit can be instantiated,falseotherwise (e.g., interfaces, abstract classes).- Specified by:
canBeInstantiatedin classUnit- Returns:
trueif this unit can be instantiated,falseotherwise
-
addSuperinterface
public boolean addSuperinterface(InterfaceUnit unit)
Adds the givenInterfaceUnitto the list of direct ancestors of this interface.- Parameters:
unit- the unit to add- Returns:
trueonly if the list has changed
-
getImmediateAncestors
public java.util.Collection<CompilationUnit> getImmediateAncestors()
Description copied from class:CompilationUnitYields the collection ofCompilationUnits that are this unit directly inherits from, regardless of their type.- Specified by:
getImmediateAncestorsin classCompilationUnit- Returns:
- the collection of units that are direct ancestors of this one
-
addInstance
public void addInstance(Unit unit) throws ProgramValidationException
Description copied from class:CompilationUnitAdds the given unit as an instance of this one, thus marking the former as a type that inherits from the latter.- Specified by:
addInstancein classCompilationUnit- Parameters:
unit- the unit to be added- Throws:
ProgramValidationException- if the given unit cannot be added
-
isInstanceOf
public boolean isInstanceOf(CompilationUnit unit)
Description copied from class:CompilationUnitYieldstrueif and only if this unit is an instance of the given one. This method works correctly even ifProgramValidationLogic.validateAndFinalize(Program)has not been invoked yet, and thus the if collection of instances of the given unit is not yet available.- Specified by:
isInstanceOfin classCompilationUnit- Parameters:
unit- the other unit- Returns:
trueonly if that condition holds
-
addAncestor
public boolean addAncestor(CompilationUnit unit)
Description copied from class:CompilationUnitAdds a newCompilationUnitas direct inheritance ancestor (i.e., superclass, interface, or superinterface) of this unit.- Specified by:
addAncestorin classCompilationUnit- Parameters:
unit- the unit to add- Returns:
trueif the collection of ancestors changed as a result of the call
-
-