Spicy
Public Member Functions | Protected Member Functions | List of all members
spicy::Driver Class Reference

#include <driver.h>

Inheritance diagram for spicy::Driver:
hilti::Driver Spicyc SpicyDriver SpicyDump

Public Member Functions

 Driver (std::string name)
 
 Driver (std::string name, const hilti::rt::filesystem::path &argv0)
 
 Driver (const Driver &)=delete
 
 Driver (Driver &&) noexcept=delete
 
Driveroperator= (const Driver &)=delete
 
Driveroperator= (Driver &&) noexcept=delete
 
spicy::Options spicyCompilerOptions () const
 
void setSpicyCompilerOptions (const spicy::Options &options)
 
- Public Member Functions inherited from hilti::Driver
 Driver (std::string name)
 
 Driver (std::string name, const hilti::rt::filesystem::path &argv0)
 
 Driver (const Driver &)=delete
 
 Driver (Driver &&) noexcept=delete
 
Driveroperator= (const Driver &)=delete
 
Driveroperator= (Driver &&) noexcept=delete
 
Result< NothingparseOptions (int argc, char **argv)
 
Result< NothingaddInput (std::shared_ptr< Unit > u)
 
Result< NothingaddInput (const hilti::rt::filesystem::path &path)
 
bool hasInputs () const
 
const auto & driverOptions () const
 
const auto & hiltiOptions () const
 
void setDriverOptions (driver::Options options)
 
void setCompilerOptions (hilti::Options options)
 
Result< Nothinginitialize ()
 
Result< Nothingcompile ()
 
const auto & context () const
 
const auto & options () const
 
Result< NothinginitRuntime ()
 
Result< NothingexecuteMain ()
 
Result< NothingfinishRuntime ()
 
Result< Nothingrun ()
 

Protected Member Functions

std::string hookAddCommandLineOptions () override
 
bool hookProcessCommandLineOption (char opt, const char *optarg) override
 
std::string hookAugmentUsage () override
 
- Protected Member Functions inherited from hilti::Driver
void usage ()
 
Result< NothingcompileUnits ()
 
Result< NothingcodegenUnits ()
 
Result< NothinglinkUnits ()
 
Result< NothingoutputUnits ()
 
Result< NothingjitUnits ()
 
result::Error error (std::string_view msg, const hilti::rt::filesystem::path &p="")
 
result::Error augmentError (const result::Error &err, const hilti::rt::filesystem::path &p="")
 
Result< std::ofstream > openOutput (const hilti::rt::filesystem::path &p, bool binary=false, bool append=false)
 
Result< NothingopenInput (std::ifstream &in, const hilti::rt::filesystem::path &p)
 
Result< NothingwriteOutput (std::ifstream &in, const hilti::rt::filesystem::path &p)
 
Result< std::stringstream > readInput (const hilti::rt::filesystem::path &p)
 
Result< hilti::rt::filesystem::path > writeToTemp (std::ifstream &in, const std::string &name_hint, const std::string &extension="tmp")
 
void dumpUnit (const Unit &unit)
 
void printHiltiException (const hilti::rt::Exception &e)
 
virtual void hookAddInput (std::shared_ptr< Unit > unit)
 
virtual void hookAddInput (const hilti::rt::filesystem::path &path)
 
virtual void hookNewASTPreCompilation (std::shared_ptr< Unit > unit)
 
virtual void hookNewASTPostCompilation (std::shared_ptr< Unit > unit)
 
virtual Result< NothinghookCompilationFinished (const Plugin &plugin)
 
virtual void hookInitRuntime ()
 
virtual void hookFinishRuntime ()
 

Detailed Description

Compiler driver.

The driver is a high-level building block for writing command-line tools compiling Spicy source files (and more). spicyc is just a tiny wrapper around this class. This class derives from hilti::Driver`, which does all the heavy lifting. Classes can in turn further derive from the driver to expand its functionality.

Constructor & Destructor Documentation

◆ Driver() [1/2]

spicy::Driver::Driver ( std::string  name)
inlineexplicit
Parameters
namedescriptive name for the tool using the driver, which will be used in usage and error messages.

◆ Driver() [2/2]

spicy::Driver::Driver ( std::string  name,
const hilti::rt::filesystem::path &  argv0 
)
inline
Parameters
namedescriptive name for the tool using the driver, which will be used in usage and error messages.
argv0the current exectuable, which will change the path's that the global options instance returns if it's inside Spicy build directory.

Member Function Documentation

◆ hookAddCommandLineOptions()

std::string Driver::hookAddCommandLineOptions ( )
overrideprotectedvirtual

Hook for derived classes to add more options to the getopt() option string.

Reimplemented from hilti::Driver.

◆ hookAugmentUsage()

std::string Driver::hookAugmentUsage ( )
overrideprotectedvirtual

Hook for derived classes for adding content to the driver's usage message (--help).

Reimplemented from hilti::Driver.

◆ hookProcessCommandLineOption()

bool Driver::hookProcessCommandLineOption ( char  opt,
const char *  optarg 
)
overrideprotectedvirtual

Hook for derived classes for parsing additional options.

Reimplemented from hilti::Driver.

◆ setSpicyCompilerOptions()

void Driver::setSpicyCompilerOptions ( const spicy::Options options)

Sets Spicy's compiler options.

Parameters
optionsthe options

◆ spicyCompilerOptions()

spicy::Options Driver::spicyCompilerOptions ( ) const

Returns the Spicy compiler options currently in effect.


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