compiler

package
v0.5.0-alpha Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2024 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

This file defines often used utility functions to generate ir

This file defines types and functions to work with the llir representation of ddptypes

This file defines types and functions to work with the llir representation of ddptypes

This file defines functions to define and work with lists.

The "calling convention" for all those functions inside the llir is a bit special for non-primitive types (strings, lists, structs):

All functions that should return a non-primitive type, take a pointer to it as first argument and fill that argument. This means that the caller must allocate the return values properly beforehand.

This file defines functions to generate llvm-ir that interacts with the ddp-runtime

Index

Constants

This section is empty.

Variables

View Source
var Comments_Enabled = true

if the llvm-ir should be commented increases the intermediate file size

Functions

func DumpListDefinitions

func DumpListDefinitions(w io.Writer, outputType OutputType, errorHandler ddperror.Handler, optimizationLevel uint) (err error)

writes the definitions of the inbuilt ddp list types to w optimizationLevel is the same as in the compiler Options

Types

type CompilerError

type CompilerError struct {
	Err        any      // additional data (probably an error, but maybe a string or something from a library), maybe nil
	Msg        string   // an additional message describing the error
	ModulePath string   // the module that was compiled when this error occured
	Node       ast.Node // the node where the error occurred or nil
	StackTrace []byte   // a stack trace
}

func (*CompilerError) Error

func (err *CompilerError) Error() string

func (*CompilerError) String

func (err *CompilerError) String() string

func (*CompilerError) Unwrap

func (err *CompilerError) Unwrap() error

type Options

type Options struct {
	// Optional Filename to name the source
	// this file is read if Source and From are nil
	FileName string
	// Optional ddp-source-code
	// if nil, From is used next
	Source []byte
	// Optional reader to read the source code from
	// if Source is nil
	From io.Reader
	// writer where the result is written to
	// must be non-nil
	To io.Writer
	// type of the output
	OutputType OutputType
	// ErrorHandler used for the scanner, parser, ...
	// May be nil
	ErrorHandler ddperror.Handler
	// optional Log function to print intermediate messages
	Log func(string, ...any)
	// wether or not to delete intermediate .ll files
	DeleteIntermediateFiles bool
	// wether all compiled DDP Modules
	// should be linked into a single llvm-ir-Module
	LinkInModules bool
	// wether the generated code for lists should be
	// linked into the main module
	LinkInListDefs bool
	// level of optimizations
	//	-  0: no optimizations
	//	-  1: only LLVM optimizations
	//	- >2: all optimizations
	OptimizationLevel uint
}

Options on how to compile the given source code and where to get it from

func (*Options) ToParserOptions

func (options *Options) ToParserOptions() parser.Options

type OutputType

type OutputType int
const (
	OutputIR  OutputType = iota // textual llvm ir
	OutputBC                    // llvm bitcode, currently unused
	OutputAsm                   // assembly depending on the target platform
	OutputObj                   // object file depending on the target platform
)

type Result

type Result struct {
	// a set which contains all files needed
	// to link the final executable
	// contains .c, .lib, .a and .o files
	Dependencies map[string]struct{}
}

the result of a compilation

func Compile

func Compile(options Options) (result *Result, err error)

compile ddp-source-code from the given Options if an error occured, the result is nil

Jump to

Keyboard shortcuts

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