cl

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2021 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package cl compiles Go+ syntax trees (ast) into a backend code. For now the supported backends are `bytecode` and `golang`.

Package cl compiles Go+ syntax trees (ast) into a backend code. For now the supported backends are `bytecode` and `golang`.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrFuncArgNoReturnValue error.
	ErrFuncArgNoReturnValue = errors.New("function argument expression doesn't have return value")
	// ErrFuncArgCantBeMultiValue error.
	ErrFuncArgCantBeMultiValue = errors.New("function argument expression can't be multi values")
)
View Source
var (
	// ErrNotFound error
	ErrNotFound = syscall.ENOENT

	// ErrNotAMainPackage error
	ErrNotAMainPackage = errors.New("not a main package")

	// ErrMainFuncNotFound error
	ErrMainFuncNotFound = errors.New("main function not found")

	// ErrSymbolNotVariable error
	ErrSymbolNotVariable = errors.New("symbol exists but not a variable")

	// ErrSymbolNotFunc error
	ErrSymbolNotFunc = errors.New("symbol exists but not a func")

	// ErrSymbolNotType error
	ErrSymbolNotType = errors.New("symbol exists but not a type")
)
View Source
var (
	// CallBuiltinOp calls BuiltinOp
	CallBuiltinOp func(kind exec.Kind, op exec.Operator, data ...interface{}) interface{}
)

Functions

func Debug

func Debug(pkg *Package)

Debug only

func IsPtrKind

func IsPtrKind(kind reflect.Kind) bool

Types

type CompileError

type CompileError struct {
	At  ast.Node
	Err error
}

CompileError represents a compiling time error.

func (*CompileError) Error

func (p *CompileError) Error() string

type FuncDecl

type FuncDecl struct {
	// contains filtered or unexported fields
}

FuncDecl represents a function declaration.

func (*FuncDecl) Compile

func (p *FuncDecl) Compile() exec.FuncInfo

Compile compiles this function

func (*FuncDecl) Get

func (p *FuncDecl) Get() exec.FuncInfo

Get returns function information.

func (*FuncDecl) Type

func (p *FuncDecl) Type() reflect.Type

Type returns the type of this function.

type Package

type Package struct {
	// contains filtered or unexported fields
}

A Package represents a Go+ package.

func NewPackage

func NewPackage(out exec.Builder, pkg *ast.Package, fset *token.FileSet, act PkgAct) (p *Package, err error)

NewPackage creates a Go+ package instance.

func NewPackageEx

func NewPackageEx(out exec.Builder, pkg *ast.Package, fset *token.FileSet, act PkgAct, imports map[string]string) (p *Package, err error)

func (*Package) Find

func (p *Package) Find(name string) (kind SymKind, v interface{}, ok bool)

Find lookups a symbol and returns it's kind and the object instance.

type PkgAct

type PkgAct int

PkgAct represents a package compiling action.

const (
	// PkgActNone - do nothing
	PkgActNone PkgAct = iota
	// PkgActClMain - compile main function
	PkgActClMain
	// PkgActClAll - compile all things
	PkgActClAll
)

type SymKind

type SymKind uint

SymKind represents a symbol kind.

const (
	// SymInvalid - invalid symbol kind
	SymInvalid SymKind = iota
	// SymConst - symbol is a const
	SymConst
	// SymVar - symbol is a variable
	SymVar
	// SymFunc - symbol is a function
	SymFunc
	// SymType - symbol is a type
	SymType
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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