compiler

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: GPL-3.0 Imports: 18 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

	Output       string
	Optimization string
	Format       string
}

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 string) error

func (*Compiler) CompileUnit

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

func (*Compiler) FindBackend

func (this *Compiler) FindBackend(filetype string) (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 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 os.DirFS("/").

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.

Jump to

Keyboard shortcuts

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