Class CompilableProgram

java.lang.Object
org.ek9lang.compiler.CompilableProgram
All Implemented Interfaces:
Serializable

public class CompilableProgram extends Object implements Serializable
Represents the whole program(s) that the developer is attempting to create. This is the main route in and holds module symbol tables and references to the compilable source code and the resulting parse trees. So access to this object needs to be tightly controlled. This should be done via the SharedThreadContext object. This also acts as a scope to enable symbols to be defined and resolved (across parsed modules if needs be). No longer using a global symbol table, but will use 'implicit' modules a bit like java does. So, will use module name 'org.ek9.lang' as the main implicit module to define build in types/symbols.
See Also:
  • Constructor Details

    • CompilableProgram

      public CompilableProgram()
  • Method Details

    • getParsedModuleForCompilableSource

      public ParsedModule getParsedModuleForCompilableSource(CompilableSource source)
      For a specific source the ParsedModule is returned.
    • getEk9Types

      public Ek9Types getEk9Types()
    • getCompilationData

      public CompilationData getCompilationData()
    • setCompilationData

      public void setCompilationData(CompilationData compilationData)
    • setEk9Types

      public void setEk9Types(Ek9Types ek9Types)
    • add

      public void add(ParsedModule parsedModule)
      Add in a newly parsed module to the list of parsed modules. Classify in the same set under the same module name.
      Parameters:
      parsedModule - The new parsed module to add in.
    • remove

      public void remove(ParsedModule parsedModule)
      If some source has been altered, then its corresponding parsedModule must be removed. Once it has, then been parsed it can be added back in.
      Parameters:
      parsedModule - The existing parsed module to be removed.
    • getParsedModules

      public List<ParsedModule> getParsedModules(String moduleName)
      Provide read only access to the list of modules for a particular moduleName. Returns an empty list of the module name cannot be located.
    • getParsedModuleNames

      public List<String> getParsedModuleNames()
      Provides a list of all the module names in the program. This can be very long.
    • resolveByFullyQualifiedSearch

      public Optional<ISymbol> resolveByFullyQualifiedSearch(SymbolSearch search)
      Resolve some symbol via a fully qualified search.
    • resolveOrDefine

      public ResolvedOrDefineResult resolveOrDefine(PossibleGenericSymbol possibleGenericSymbol)
      When using generic types, the parameterised type goes into the same module namespace as the Generic Type. i.e. org.ek9.lang::List of some.mod.area::Thing would be given a fully qualified name like org.ek9.lang::_List_SOMEDIGEST_OF_FULLY_QULIFIED_NAMES. So once a List of String has been defined it can be used everywhere as it will be in the org.ek9.lang module.
    • resolveFromModule

      public Optional<ISymbol> resolveFromModule(String moduleName, SymbolSearch search)
      A package name (moduleName) can actually have multiple parsedModules (i.e. a module can be made from multiple source files, each of which has its own parsed module). But they are all part of the same namespace (package/module). This method finds the appropriate set of parsed modules (if that module name exists) and then checks each of the modules to see if the search can be resolved. It returns the first resolution or Optional empty if it cannot be resolved.
    • getOriginalReferenceLocation

      public Optional<IToken> getOriginalReferenceLocation(String moduleName, SymbolSearch search)
      Locates the token when the first reference was established.
    • resolveReferenceFromModule

      public Optional<ISymbol> resolveReferenceFromModule(String moduleName, SymbolSearch search)
      Check the existing set of references in the moduleName. So that means as there are multiple sources per module it is necessary to check in each.
    • resolveFromImplicitScopes

      public Optional<ISymbol> resolveFromImplicitScopes(SymbolSearch search)
      Search in the implicit ek9 module namespaces of: org.ek9.lang etc.