tan  0.0.1
tanlang::CompilerDriver Class Referencefinal

Compile a list of C++ and/or tan source files, and perform linking. More...

#include <driver.h>

Public Member Functions

 CompilerDriver (TanCompilation config)
 
void run (const vector< str > &files)
 Compile CXX or TAN source files and link their output object files. More...
 
vector< Program * > parse (const vector< str > &files)
 Parse the corresponding source file, and build AST. More...
 
void link (const vector< str > &input_paths)
 
void register_package (const str &name, Package *package)
 Register a Package that has been spotted from source files, with top-level context stored inside. More...
 
Packageget_package (const str &name)
 Get a pointer to a Package. Semantic analysis is not guaranteed to be fully performed on it. More...
 
vector< Package * > stage1_analysis (vector< Program * > ps)
 Get a set of partially analyzed packages that can be used for cross-package dependency analysis. Note that some composite types need a full analysis for the dependent packages to work during codegen. More...
 

Static Public Member Functions

static CompilerDriverinstance ()
 
static vector< str > resolve_package_import (const str &callee_path, const str &import_name)
 Get a list of possible files that corresponds to an import. Check PACKAGES.md. More...
 

Static Public Attributes

static vector< str > import_dirs {}
 Import search directories FIXME: static variable? More...
 

Detailed Description

Compile a list of C++ and/or tan source files, and perform linking.

Definition at line 22 of file driver.h.

Member Function Documentation

◆ get_package()

Package * CompilerDriver::get_package ( const str &  name)

Get a pointer to a Package. Semantic analysis is not guaranteed to be fully performed on it.

Definition at line 183 of file driver.cpp.

◆ parse()

vector< Program * > CompilerDriver::parse ( const vector< str > &  files)

Parse the corresponding source file, and build AST.

Definition at line 313 of file driver.cpp.

References tanlang::Intrinsic::GetIntrinsicFunctionDeclarations().

◆ register_package()

void CompilerDriver::register_package ( const str &  name,
Package package 
)

Register a Package that has been spotted from source files, with top-level context stored inside.

Definition at line 191 of file driver.cpp.

◆ resolve_package_import()

vector< str > CompilerDriver::resolve_package_import ( const str &  callee_path,
const str &  import_name 
)
static

Get a list of possible files that corresponds to an import. Check PACKAGES.md.

Parameters
callee_pathThe path to the file which the import statement is in
import_nameThe filename specified by the import statement
Returns
A list of absolute paths to candidate files

Definition at line 342 of file driver.cpp.

References import_dirs.

◆ run()

void CompilerDriver::run ( const vector< str > &  files)

Compile CXX or TAN source files and link their output object files.

The object files are named as "<name of the source file>.o" and they are located at current working directory. If current build is release, all exceptions are captured and e.what() is printed out to stderr. If current build is debug, all exceptions are not captured, making debugging easier.

Parameters
filesThe path to source files, can be relative or absolute path. They will be distinguished by their file extensions.
configCompilation configuration,
See also
TanCompilation

Definition at line 146 of file driver.cpp.

◆ stage1_analysis()

vector< Package * > CompilerDriver::stage1_analysis ( vector< Program * >  ps)

Get a set of partially analyzed packages that can be used for cross-package dependency analysis. Note that some composite types need a full analysis for the dependent packages to work during codegen.

Package dependencies are analyzed recursively but there's no guarantee that all of them are found.

Note
This function raises an error if it detects cyclic dependency.
Parameters
psA list of Program's returned by the Parser
Returns
A list of partially analyzed packages

Definition at line 193 of file driver.cpp.

Member Data Documentation

◆ import_dirs

vector<str> tanlang::CompilerDriver::import_dirs {}
inlinestatic

Import search directories FIXME: static variable?

Definition at line 34 of file driver.h.

Referenced by resolve_package_import().


The documentation for this class was generated from the following files: