Documentation ¶
Overview ¶
Package compiler is responsible for orchestrating the different FSPL compilation stages, as well as invoking the LLVM IR compiler.
Index ¶
- type Compiler
- func (this *Compiler) AnalyzeModule(semanticTree *analyzer.Tree, path string, skim bool) (uuid.UUID, error)
- func (this *Compiler) AnalyzeSourceFile(semanticTree *analyzer.Tree, path string, skim bool) (uuid.UUID, error)
- func (this *Compiler) AnalyzeUnit(semanticTree *analyzer.Tree, path string, skim bool) (uuid.UUID, error)
- func (this *Compiler) CompileIRModule(module *llvm.Module, filetype Filetype) error
- func (this *Compiler) CompileUnit(address entity.Address) error
- func (this *Compiler) FindBackend(filetype Filetype) (string, []string, error)
- func (this *Compiler) ParseModule(syntaxTree *fsplParser.Tree, path string, skim bool) error
- func (this *Compiler) ParseSourceFile(syntaxTree *fsplParser.Tree, path string, skim bool) error
- func (this *Compiler) ParseUnit(syntaxTree *fsplParser.Tree, path string, skim bool) error
- type Filetype
- type OsFS
- type Resolver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Compiler ¶
type Compiler struct { *Resolver cli.Logger Target *generator.Target Output string Optimization string Filetype Filetype }
func (*Compiler) AnalyzeModule ¶
func (*Compiler) AnalyzeSourceFile ¶
func (*Compiler) AnalyzeUnit ¶
func (*Compiler) CompileIRModule ¶
func (*Compiler) FindBackend ¶
FindBackend returns the name of an LLVM backend command, and a list of arguments to pass to it. It tries commands in this order:
- llc
- llc-<latest> -> llc-14
- clang
If none were found, it returns an error.
func (*Compiler) ParseModule ¶
func (*Compiler) ParseSourceFile ¶
type Filetype ¶ added in v0.4.1
type Filetype int
Filetype represents an output filetype.
func FiletypeFromExt ¶ added in v0.4.1
FiletypeFromExt returns a filetype based on the given filename extension.
func FiletypeFromString ¶ added in v0.4.1
FiletypeFromString returns a filetype based on the given name.
type OsFS ¶ added in v0.5.0
type OsFS struct{}
OsFS returns an fs.FS that represents the operating system's filesystem. In Windows, volume names (A:, B:, C:, etc.) are treated as subdirectories within the root.
type Resolver ¶
type Resolver struct { // FS specifies a filesystem to search. FS fs.FS // Path specifies a list of paths that a unit may exist directly in. The // Resolver will search the FS for each path listed, starting at the // first and ending at the last. Thus, paths nearer the start will have // a higher priority. Path []string }
Resolver turns addresses into absolute filepaths.
func NewResolver ¶
NewResolver creates a new resolver with OsFS.
func (*Resolver) AddPathFront ¶
AddPathFront adds one or more items to the beginning of the resolver's search path.
func (*Resolver) Resolve ¶
Resolve resolves an address into an absolute filepath starting at the filesystem root. It follows these rules:
- If the address starts with '.', '..', it is joined with context
- If the address starts with '/', it is treated as an absolute path from the fs root
- Else, the address is searched for in the resolver's paths