Class Program


  • public class Program
    extends Unit
    A program that LiSA can analyze. A program is a Unit that is defined at an unknown program location, and that has a set of ClassUnits defined in it.
    • Field Detail

      • PROGRAM_NAME

        public static final java.lang.String PROGRAM_NAME
        The name of the program.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Program

        public Program​(LanguageFeatures features,
                       TypeSystem types)
        Builds an empty program.
        Parameters:
        features - the language-specific features, algorithms and semantics of this program
        types - the type system knowing about the types that appear in the program
    • Method Detail

      • getFeatures

        public LanguageFeatures getFeatures()
        Yields the language-specific features, algorithms and semantics of this program.
        Returns:
        the features
      • getTypes

        public TypeSystem getTypes()
        Yields the type system knowing about the types that appear in the program.
        Returns:
        the type system
      • addUnit

        public final boolean addUnit​(Unit unit)
        Adds a new ClassUnit, identified by its name (Unit.getName()), to this program.
        Parameters:
        unit - the compilation unit to add
        Returns:
        true if there was no unit previously associated with the same name, false otherwise. If this method returns false, the given unit is discarded.
        Throws:
        java.lang.IllegalArgumentException - if the given unit is an instance of this class
      • addEntryPoint

        public final boolean addEntryPoint​(CFG cm)
        Adds a new CFG to the entry points of this program.
        Parameters:
        cm - the cfg to add
        Returns:
        true if the entry point was successfully added. If this method returns false, the given cfg is discarded.
      • getEntryPoints

        public final java.util.Collection<CFG> getEntryPoints()
        Yields the collection of CFGs that are entry points in this program.
        Returns:
        the collection of entry points
      • getUnits

        public final java.util.Collection<Unit> getUnits()
        Yields the collection of ClassUnits defined in this program. Each compilation unit is uniquely identified by its name, meaning that there are no two compilation units having the same name in a program.
        Returns:
        the collection of compilation units
      • getUnit

        public final Unit getUnit​(java.lang.String name)
        Yields the ClassUnit defined in this unit having the given name (Unit.getName()), if any.
        Parameters:
        name - the name of the compilation unit to find
        Returns:
        the compilation unit with the given name, or null
      • getCodeMembersRecursively

        public java.util.Collection<CodeMember> getCodeMembersRecursively()
        Yields the collection of all the CodeMembers defined in this unit. This method returns the same result as Unit.getCodeMembers(), but subclasses are likely to re-implement it to add additional ones (e.g., instance members).

        This method also returns all the cfgs defined in all the Units in this program, through Unit.getCodeMembersRecursively().
        Overrides:
        getCodeMembersRecursively in class Unit
        Returns:
        the collection of the code members
      • canBeInstantiated

        public boolean canBeInstantiated()
        Description copied from class: Unit
        Yields true if this unit can be instantiated, false otherwise (e.g., interfaces, abstract classes).
        Specified by:
        canBeInstantiated in class Unit
        Returns:
        true if this unit can be instantiated, false otherwise
      • getProgram

        public Program getProgram()
        Description copied from class: Unit
        Yields the Program where this unit is defined.
        Specified by:
        getProgram in class Unit
        Returns:
        the program
      • getAllCFGs

        public java.util.Collection<CFG> getAllCFGs()
        Yields all the CFGs defined in this program, obtained by filtering the results of getCodeMembersRecursively().
        Returns:
        the cfgs