public final class CompileTask extends Object implements wybs.lang.Build.Task
Lexing and Parsing, where the source file is converted into an Abstract Syntax Tree (AST) representation.
Name Resolution, where the fully qualified names of all external symbols are determined.
Type Propagation, where the types of all expressions are determined by propagation from e.g. declared parameter types.
WYIL Generation, where the the AST is converted into the Whiley Intermediate Language (WYIL). A number of passes are then made over this before it is ready for code generation.
Code Generation. Here, the executable code is finally generated. This could be Java bytecode, or something else (e.g. JavaScript).
| Constructor and Description |
|---|
CompileTask(wybs.lang.Build.Project project) |
| Modifier and Type | Method and Description |
|---|---|
Set<wyfs.lang.Path.Entry<?>> |
build(Collection<wycc.util.Pair<wyfs.lang.Path.Entry<?>,wyfs.lang.Path.Root>> delta,
wybs.lang.Build.Graph graph) |
boolean |
exists(wyfs.lang.Path.ID id) |
WyilFile |
getModule(wyfs.lang.Path.ID mid)
Get the (compiled) module associated with a given module identifier.
|
WhileyFile |
getSourceFile(wyfs.lang.Path.ID mid)
Get the source file associated with a given module identifier.
|
TypeSystem |
getTypeSystem()
Access the type system object this compile task is using.
|
boolean |
hasModifier(wybs.lang.NameID nid,
WhileyFile.Context context,
Modifier modifier)
Determine whether a named item has a modifier matching one of a given
list.
|
String |
id() |
List<wyfs.lang.Path.ID> |
imports(wyfs.util.Trie key)
This method takes a given import declaration, and expands it to find all
matching modules.
|
boolean |
isName(wybs.lang.NameID nid)
Determine whether a given name exists or not.
|
boolean |
isNameVisible(wybs.lang.NameID nid,
WhileyFile.Context context)
Determine whether a name is visible in a given context.
|
boolean |
isTypeVisible(wybs.lang.NameID nid,
WhileyFile.Context context)
Determine whether a named type is fully visible in a given context.
|
wybs.lang.Build.Project |
project() |
wyfs.lang.Path.ID |
resolveAsModule(String name,
WhileyFile.Context context)
This method attempts to resolve a name as a module in a given name
context.
|
wybs.lang.NameID |
resolveAsName(List<String> names,
WhileyFile.Context context)
This methods attempts to resolve the given list of names into a single
named item (e.g.
|
wybs.lang.NameID |
resolveAsName(String name,
WhileyFile.Context context)
Responsible for resolve names, types, constants and functions / methods
at the global level.
|
void |
setLogger(wycc.util.Logger logger) |
Type |
toSemanticType(wyal.lang.WyalFile.Type type,
WhileyFile.Context context)
Convert a Whiley "syntactic" type into a wyil type.
|
public String id()
public wybs.lang.Build.Project project()
project in interface wybs.lang.Build.Taskpublic TypeSystem getTypeSystem()
public void setLogger(wycc.util.Logger logger)
public Set<wyfs.lang.Path.Entry<?>> build(Collection<wycc.util.Pair<wyfs.lang.Path.Entry<?>,wyfs.lang.Path.Root>> delta, wybs.lang.Build.Graph graph) throws IOException
build in interface wybs.lang.Build.TaskIOExceptionpublic boolean exists(wyfs.lang.Path.ID id)
public boolean isName(wybs.lang.NameID nid)
throws IOException
nid - --- Name ID to checkIOExceptionpublic boolean isNameVisible(wybs.lang.NameID nid,
WhileyFile.Context context)
throws IOException
nid - Name to check modifiers ofcontext - Context in which we are trying to access named itemIOExceptionpublic boolean isTypeVisible(wybs.lang.NameID nid,
WhileyFile.Context context)
throws IOException
nid - Name to check modifiers ofcontext - Context in which we are trying to access named itemIOExceptionpublic boolean hasModifier(wybs.lang.NameID nid,
WhileyFile.Context context,
Modifier modifier)
throws IOException
nid - Name to check modifiers ofcontext - Context in which we are trying to access named itemmodifiers - IOExceptionpublic List<wyfs.lang.Path.ID> imports(wyfs.util.Trie key) throws wybs.util.ResolveError
imp - wybs.util.ResolveErrorpublic WhileyFile getSourceFile(wyfs.lang.Path.ID mid) throws IOException
mid - IOExceptionpublic WyilFile getModule(wyfs.lang.Path.ID mid) throws IOException
mid - IOExceptionpublic wybs.lang.NameID resolveAsName(String name, WhileyFile.Context context) throws IOException, wybs.util.ResolveError
Responsible for resolve names, types, constants and functions / methods at the global level. Resolution is determined by the context in which a given name/type/constant/function/method appears. That is, what imports are active in the enclosing WhileyFile. For example, consider this:
import whiley.lang.* type nat is Int.uint import whiley.ui.*
In this example, the statement "import whiley.lang.*" is
active for the type declaration, whilst the statement "
import whiley.ui.*". The context of the type declaration is
everything in the enclosing file up to the declaration itself. Therefore,
in resolving the name Int.uint, this will examine the
package whiley.lang to see whether a compilation unit named "Int" exists.
If so, it will then resolve the name Int.uint to
whiley.lang.Int.uint.
name - A module name without package specifier.context - --- context in which to resolve.IOException - if it couldn't resolve the namewybs.util.ResolveErrorpublic wybs.lang.NameID resolveAsName(List<String> names, WhileyFile.Context context) throws IOException, wybs.util.ResolveError
["whiley","lang","Math","max"] would be resolved, since
whiley.lang.Math.max is a valid function name. In contrast,
["whiley","lang","Math"] does not resolve since
whiley.lang.Math refers to a module.names - A list of components making up the name, which may include the
package and enclosing module.context - --- context in which to resolve *IOException - if it couldn't resolve the namewybs.util.ResolveErrorpublic wyfs.lang.Path.ID resolveAsModule(String name, WhileyFile.Context context) throws IOException, wybs.util.ResolveError
name - --- name to be resolvedcontext - --- context in which to resolveIOExceptionwybs.util.ResolveErrorpublic Type toSemanticType(wyal.lang.WyalFile.Type type, WhileyFile.Context context) throws wybs.util.ResolveError, IOException
type - The type to be convertedwybs.util.ResolveError - If a named type within this condition cannot be resolved
within the enclosing project.IOExceptionCopyright © 2017. All rights reserved.