compiler

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2024 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Package compiler is responsible for orchestrating the different FSPL compilation stages, as well as invoking the LLVM IR compiler.

Index

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 (this *Compiler) AnalyzeModule(
	semanticTree *analyzer.Tree,
	path string,
	skim bool,
) (
	uuid.UUID,
	error,
)

func (*Compiler) AnalyzeSourceFile

func (this *Compiler) AnalyzeSourceFile(
	semanticTree *analyzer.Tree,
	path string,
	skim bool,
) (
	uuid.UUID,
	error,
)

func (*Compiler) AnalyzeUnit

func (this *Compiler) AnalyzeUnit(
	semanticTree *analyzer.Tree,
	path string,
	skim bool,
) (
	uuid.UUID,
	error,
)

func (*Compiler) CompileIRModule

func (this *Compiler) CompileIRModule(module *llvm.Module, filetype Filetype) error

func (*Compiler) CompileUnit

func (this *Compiler) CompileUnit(address entity.Address) error

func (*Compiler) FindBackend

func (this *Compiler) FindBackend(filetype Filetype) (string, []string, error)

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 (this *Compiler) ParseModule(
	syntaxTree *fsplParser.Tree,
	path string,
	skim bool,
) error

func (*Compiler) ParseSourceFile

func (this *Compiler) ParseSourceFile(
	syntaxTree *fsplParser.Tree,
	path string,
	skim bool,
) error

func (*Compiler) ParseUnit

func (this *Compiler) ParseUnit(
	syntaxTree *fsplParser.Tree,
	path string,
	skim bool,
) error

type Filetype added in v0.4.1

type Filetype int

Filetype represents an output filetype.

const (
	FiletypeUnknown Filetype = iota
	FiletypeObject
	FiletypeLibrary
	FiletypeAssembly
	FiletypeIR
	FiletypeExecutable
)

func FiletypeFromExt added in v0.4.1

func FiletypeFromExt(target generator.Target, ext string) (Filetype, bool)

FiletypeFromExt returns a filetype based on the given filename extension.

func FiletypeFromString added in v0.4.1

func FiletypeFromString(ext string) (Filetype, bool)

FiletypeFromString returns a filetype based on the given name.

func (Filetype) Ext added in v0.4.1

func (filetype Filetype) Ext(target generator.Target) string

Ext returns the standard filename extension of the filetype.

func (Filetype) Extend added in v0.4.1

func (filetype Filetype) Extend(target generator.Target, path string) string

Extend adds the extension of the filetype onto the specified path.

func (Filetype) String added in v0.4.1

func (filetype Filetype) String() string

String returns a string representation of the filetype.

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.

func (OsFS) Open added in v0.5.0

func (this OsFS) Open(name string) (fs.File, error)

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

func NewResolver(path ...string) *Resolver

NewResolver creates a new resolver with OsFS.

func (*Resolver) AddPath

func (resolver *Resolver) AddPath(path ...string)

AddPath adds one or more items to the resolver's search path.

func (*Resolver) AddPathFront

func (resolver *Resolver) AddPathFront(path ...string)

AddPathFront adds one or more items to the beginning of the resolver's search path.

func (*Resolver) Resolve

func (resolver *Resolver) Resolve(context string, address entity.Address) (string, error)

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

func (*Resolver) ResolveCwd

func (resolver *Resolver) ResolveCwd(address entity.Address) (string, error)

ResolveCwd resolves the address within the context of the current working directory.

Directories

Path Synopsis
Package native provides OS native parameters for the compilation process.
Package native provides OS native parameters for the compilation process.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL