prism

package
v0.0.0-...-d9926d3 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: GPL-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeKindAtomic = iota
	TypeKindVector
	TypeKindStruct
	TypeKindSemiDetermined
	TypeKindGroup
	TypeKindSemiDeterminedGroup
	KindMapOperator
	KindReduceOperator
	TypeInt
	TypeReal
	TypeChar
	TypeBool
	TypeVoid
	TypeString
)
View Source
const CT_OOB = "Index %d overflows %s of length %d"
View Source
const CT_Unexpected = "Expected %s, instead found %s"

Variables

View Source
var BoolType = AtomicType{
	ID:           TypeBool,
	WidthInBytes: 1,
	Name:         ParseIdent("Bool"),
	Actual:       types.I1,
}
View Source
var CharType = AtomicType{
	ID:           TypeChar,
	WidthInBytes: 1,
	Name:         ParseIdent("Char"),
	Actual:       types.I8,
}
View Source
var IntType = AtomicType{
	ID:           TypeInt,
	WidthInBytes: 8,
	Name:         ParseIdent("Int"),
	Actual:       types.I64,
}
View Source
var RealType = AtomicType{
	ID:           TypeReal,
	WidthInBytes: 8,
	Name:         ParseIdent("Real"),
	Actual:       types.Double,
}
View Source
var StringType = VectorType{Type: CharType}
View Source
var VoidType = AtomicType{
	ID:           TypeVoid,
	WidthInBytes: 0,
	Name:         ParseIdent("Void"),
	Actual:       types.Void,
}

Functions

func Blue

func Blue(s ...string) string

Blue format for ...strings then reset colour

func Bold

func Bold(s ...string) string

Bold format for ...strings then reset

func DeferDyadicApplicationTypes

func DeferDyadicApplicationTypes(function DyadicFunction, x, y Expression) (DyadicFunction, Expression, Expression)

func DeferMonadicApplicationTypes

func DeferMonadicApplicationTypes(function MonadicFunction, y Expression) (MonadicFunction, Expression)

func Emit

func Emit(env *Environment)

Emit observes emit specifier and writes LLVM IR to file and invokes Clang Will exit.

func Error

func Error(parts ...string) er

Error message

func Green

func Green(s ...string) string

Green format for ...strings then reset colour

func IsConstant

func IsConstant(e Expression) bool

func IsVector

func IsVector(t Type) bool

IsVector is shorthand for vector interface check

func Notify

func Notify(parts ...string) er

Notify general message

func Panic

func Panic(err string, args ...interface{})

Panic prints red and exits

func PilotEmit

func PilotEmit(env *Environment) (string, bool)

func QueryAutoVector

func QueryAutoVector(atom, vec Type) bool

func QueryCast

func QueryCast(from, to Type) bool

func Red

func Red(s ...string) string

Red format for ...strings then reset colour

func Ref

func Ref(s string) *string

Ref gets reference

func VectorDepth

func VectorDepth(t Type) int

func Verbose

func Verbose(parts ...string) er

Verbose message to be displayed depending on quietP

func VerifyClangVersion

func VerifyClangVersion()

VerifyClangVersion ensures Clang is installed and at least v12

func Warn

func Warn(parts ...string) er

Warn message

func Yellow

func Yellow(s ...string) string

Yellow format for ...strings then reset colour

Types

type Alpha

type Alpha struct {
	TypeOf Type
}

func (Alpha) String

func (a Alpha) String() string

String function for interface

func (Alpha) Type

func (a Alpha) Type() Type

Type property for interface

type AtomicType

type AtomicType struct {
	ID           int
	WidthInBytes int
	Name         Ident
	Actual       types.Type
}

func (AtomicType) Equals

func (a AtomicType) Equals(b Type) bool

Interface prism.Type comparison

func (AtomicType) IsAlgebraic

func (a AtomicType) IsAlgebraic() bool

Interface prism.Type algebraic predicate

func (AtomicType) Kind

func (a AtomicType) Kind() int

func (AtomicType) Realise

func (a AtomicType) Realise() types.Type

func (AtomicType) Resolve

func (a AtomicType) Resolve(t Type) Type

Resolve composes Integrate with Derive, Should not be used on concrete types

func (AtomicType) String

func (a AtomicType) String() string

String function for interface

func (AtomicType) Width

func (a AtomicType) Width() int64

Interface prism.Type width for LLVM codegen

type Attribute

type Attribute struct {
	// Function attributes
	ForceInline        bool
	Special            bool
	SkipBuilder        bool
	DisallowAutoVector bool

	// Expression attributes
	IsConstant bool
}

type Bool

type Bool struct {
	Value bool
}

func (Bool) Equals

func (t Bool) Equals(b Type) bool

Interface Type comparison

func (Bool) IsAlgebraic

func (t Bool) IsAlgebraic() bool

Interface Type algebraic predicate

func (Bool) Resolve

func (i Bool) Resolve(t Type) Type

Resolve composes Integrate with Derive, Should not be used on concrete types

func (Bool) String

func (b Bool) String() string

String function for interface

func (Bool) Type

func (b Bool) Type() Type

Type property for interface

func (Bool) Width

func (t Bool) Width() int

Interface Type width for LLVM codegen

type Callable

type Callable interface {
	Attrs() Attribute
	Arity() int
}

func MakeDC

func MakeDC(d DCallable, noAutoVec bool) Callable

func MakeMC

func MakeMC(d MCallable, noAutoVec bool) Callable

type Cast

type Cast struct {
	Value  Expression
	ToType Type
}

func RoundhouseCast

func RoundhouseCast(from Expression, otherside Type, to Type) (res *Cast)

RoundhouseCast attempts to find a mapping from a type to a type within a sum from is the Expression to have it's type changed (note: this will change to a type if casting is re-implemented this way) otherside is the opposite-hand type (for DyadicFunctions only), used to give hint to is the function-side type which contains the sum type.

func (Cast) String

func (c Cast) String() string

String function for interface

func (Cast) Type

func (c Cast) Type() Type

Type property for interface

type Char

type Char struct {
	Value string
}

func (Char) Equals

func (t Char) Equals(b Type) bool

Interface Type comparison

func (Char) IsAlgebraic

func (t Char) IsAlgebraic() bool

Interface Type algebraic predicate

func (Char) Resolve

func (i Char) Resolve(t Type) Type

Resolve composes Integrate with Derive, Should not be used on concrete types

func (Char) String

func (c Char) String() string

String function for interface

func (Char) Type

func (c Char) Type() Type

Type property for interface

func (Char) Width

func (t Char) Width() int

Interface Type width for LLVM codegen

type DCallable

type DCallable func(left, right Value) value.Value

type DyadicApplication

type DyadicApplication struct {
	Operator DyadicFunction
	Left     Expression
	Right    Expression
}

func (DyadicApplication) String

func (d DyadicApplication) String() string

String function for interface

func (DyadicApplication) Type

func (d DyadicApplication) Type() Type

Type property for interface

type DyadicCallable

type DyadicCallable struct {
	DCallable

	Attribute Attribute
	// contains filtered or unexported fields
}

func (DyadicCallable) Arity

func (DyadicCallable) Arity() int

func (DyadicCallable) Attrs

func (d DyadicCallable) Attrs() Attribute

type DyadicFunction

type DyadicFunction struct {
	Name      Ident
	AlphaType Type
	OmegaType Type
	Returns   Type

	PreBody *[]palisade.Expression
	Body    []Expression

	Attribute Attribute
}

func (DyadicFunction) Arity

func (DyadicFunction) Arity() int

func (DyadicFunction) Attrs

func (d DyadicFunction) Attrs() Attribute

func (DyadicFunction) Ident

func (d DyadicFunction) Ident() Ident

func (DyadicFunction) LLVMise

func (f DyadicFunction) LLVMise() string

func (DyadicFunction) String

func (f DyadicFunction) String() (s string)

String function for interface

func (DyadicFunction) Type

func (f DyadicFunction) Type() Type

Type property for interface

type Environment

type Environment struct {
	Iter       uint
	IsPilotRun bool
	LexResult  *palisade.PalisadeResult
	//
	MonadicFunctions map[Ident]*MonadicFunction
	DyadicFunctions  map[Ident]*DyadicFunction
	Types            map[Ident]Type
	//
	EmitFormat   string
	Output       string
	Verbose      bool
	Optimisation string
	File         string
	//
	ApotheosisIter     int
	EntryFunction      MonadicFunction
	Module             *ir.Module
	Block              *ir.Block
	LLDyadicFunctions  map[string]*ir.Func
	LLMonadicFunctions map[string]*ir.Func
	Specials           map[string]*ir.Func

	LLMonadicCallables map[string]Callable
	LLDyadicCallables  map[string]Callable

	CurrentFunction   *ir.Func
	CurrentFunctionIR Expression
	PanicStrings      map[string]*ir.Global
}

func Init

func Init(env *Environment) *Environment

func Lex

func Lex(env *Environment) *Environment

func NewEnvironment

func NewEnvironment() *Environment

func (*Environment) AwareIntern

func (env *Environment) AwareIntern(i palisade.Ident) (p Ident)

func (*Environment) FetchDVerb

func (env *Environment) FetchDVerb(v *palisade.Ident) DyadicFunction

func (*Environment) FetchDyadicCallable

func (env *Environment) FetchDyadicCallable(v string) Callable

func (*Environment) FetchMVerb

func (env *Environment) FetchMVerb(v *palisade.Ident) MonadicFunction

func (*Environment) FetchMonadicCallable

func (env *Environment) FetchMonadicCallable(v string) Callable

func (*Environment) FetchVerb

func (env *Environment) FetchVerb(v *palisade.Ident) Expression

func (*Environment) Intern

func (env *Environment) Intern(f Function)

func (*Environment) InternBuiltins

func (env *Environment) InternBuiltins()

func (*Environment) Iterate

func (e *Environment) Iterate() int

func (Environment) String

func (e Environment) String() (s string)

func (*Environment) SubstantiateType

func (env *Environment) SubstantiateType(t palisade.Type) Type

type Expression

type Expression interface {
	Type() Type
	String() string
}

func DelegateCast

func DelegateCast(from Expression, to Type) Expression

type Function

type Function interface {
	LLVMise() string
	Attrs() Attribute
	Type() Type
	Ident() Ident
	String() string
}

type GenericType

type GenericType struct{}

func (GenericType) Equals

func (s GenericType) Equals(b Type) bool

Interface Type comparison

func (GenericType) IsAlgebraic

func (s GenericType) IsAlgebraic() bool

Interface Type algebraic predicate

func (GenericType) Kind

func (s GenericType) Kind() int

func (GenericType) Realise

func (s GenericType) Realise() types.Type

func (GenericType) Resolve

func (g GenericType) Resolve(t Type) Type

Resolve composes Integrate with Derive, Fills in sum/generic type based on a concrete type

func (GenericType) String

func (s GenericType) String() string

func (GenericType) Width

func (s GenericType) Width() int64

Interface Type width for LLVM codegen

type Group

type Group interface {
	String() string
	Universal() bool
	Union(t Group) Group
	Intersection(t Group) Group
	Has(typ Type) bool
}

type Ident

type Ident struct {
	Package string
	Name    string
}

func Intern

func Intern(i palisade.Ident) (p Ident)

func ParseIdent

func ParseIdent(s string) (p Ident)

func (Ident) String

func (i Ident) String() string

String function for interface

type Int

type Int struct {
	Value int64
}

func (Int) Equals

func (t Int) Equals(b Type) bool

Interface Type comparison

func (Int) IsAlgebraic

func (t Int) IsAlgebraic() bool

Interface Type algebraic predicate

func (Int) Resolve

func (i Int) Resolve(t Type) Type

Resolve composes Integrate with Derive, Should not be used on concrete types

func (Int) String

func (i Int) String() string

String function for interface

func (Int) Type

func (i Int) Type() Type

Type property for interface

func (Int) Width

func (t Int) Width() int

Interface Type width for LLVM codegen

type MCallable

type MCallable func(val Value) value.Value

type MonadicApplication

type MonadicApplication struct {
	Operator MonadicFunction
	Operand  Expression
}

func (MonadicApplication) String

func (m MonadicApplication) String() string

String function for interface

func (MonadicApplication) Type

func (m MonadicApplication) Type() Type

Type property for interface

type MonadicCallable

type MonadicCallable struct {
	MCallable

	Attribute Attribute
	// contains filtered or unexported fields
}

func (MonadicCallable) Arity

func (MonadicCallable) Arity() int

func (MonadicCallable) Attrs

func (m MonadicCallable) Attrs() Attribute

type MonadicFunction

type MonadicFunction struct {
	Name      Ident
	OmegaType Type

	Returns Type
	PreBody *[]palisade.Expression
	Body    []Expression

	Attribute Attribute
}

func (MonadicFunction) Arity

func (MonadicFunction) Arity() int

func (MonadicFunction) Attrs

func (d MonadicFunction) Attrs() Attribute

func (MonadicFunction) Ident

func (m MonadicFunction) Ident() Ident

func (MonadicFunction) LLVMise

func (f MonadicFunction) LLVMise() string

func (MonadicFunction) String

func (f MonadicFunction) String() (s string)

String function for interface

func (MonadicFunction) Type

func (f MonadicFunction) Type() Type

Type property for interface

type MonadicOperator

type MonadicOperator struct {
	Operator int
	Fn       Function
	ExprType Type
	Returns  Type
}

func (MonadicOperator) Ident

func (do MonadicOperator) Ident() Ident

func (MonadicOperator) IsSpecial

func (do MonadicOperator) IsSpecial() bool

func (MonadicOperator) LLVMise

func (do MonadicOperator) LLVMise() string

func (MonadicOperator) ShouldInline

func (do MonadicOperator) ShouldInline() bool

func (MonadicOperator) String

func (do MonadicOperator) String() string

String function for interface

func (MonadicOperator) Type

func (do MonadicOperator) Type() Type

Type property for interface

Operators each return a type dependant on a different input

type Morpheme

type Morpheme interface {
	// contains filtered or unexported methods
}

type Omega

type Omega struct {
	TypeOf Type
}

func (Omega) String

func (o Omega) String() string

String function for interface

func (Omega) Type

func (a Omega) Type() Type

Type property for interface

type OperatorApplication

type OperatorApplication struct {
	Op   MonadicOperator
	Expr Expression
}

func (OperatorApplication) String

func (d OperatorApplication) String() string

func (OperatorApplication) Type

func (d OperatorApplication) Type() Type

type Real

type Real struct {
	Value float64
}

func (Real) Equals

func (t Real) Equals(b Type) bool

Interface Type comparison

func (Real) IsAlgebraic

func (t Real) IsAlgebraic() bool

Interface Type algebraic predicate

func (Real) Resolve

func (i Real) Resolve(t Type) Type

Resolve composes Integrate with Derive, Should not be used on concrete types

func (Real) String

func (r Real) String() string

String function for interface

func (Real) Type

func (r Real) Type() Type

Type property for interface

func (Real) Width

func (t Real) Width() int

Interface Type width for LLVM codegen

type String

type String struct {
	Value string
}

func (String) Equals

func (t String) Equals(b Type) bool

Interface Type comparison

func (String) IsAlgebraic

func (t String) IsAlgebraic() bool

Interface Type algebraic predicate

func (String) Resolve

func (i String) Resolve(t Type) Type

Resolve composes Integrate with Derive, Should not be used on concrete types

func (String) String

func (s String) String() string

String function for interface

func (String) Type

func (s String) Type() Type

Type property for interface

func (String) Width

func (t String) Width() int64

Interface Type width for LLVM codegen

type StructType

type StructType struct {
	FieldTypes []Type
}

func (StructType) Equals

func (s StructType) Equals(b Type) (acc bool)

Interface Type comparison

func (StructType) IsAlgebraic

func (s StructType) IsAlgebraic() (acc bool)

Interface Type algebraic predicate

func (StructType) Kind

func (s StructType) Kind() int

func (StructType) Realise

func (s StructType) Realise() types.Type

func (StructType) Resolve

func (s StructType) Resolve(t Type) Type

Resolve composes Integrate with Derive, Fills in sum/generic type based on a concrete type

func (StructType) String

func (s StructType) String() (acc string)

String function for interface

func (StructType) Width

func (s StructType) Width() (acc int64)

Interface Type width for LLVM codegen

type Type

type Type interface {
	Kind() int
	Width() int64
	String() string
	Equals(Type) bool
	Realise() types.Type
	Resolve(Type) Type
	IsAlgebraic() bool
}

func Delegate

func Delegate(algebraic, concrete Type) (determined Type, failure *string)

I have no clue what this does

func Derive

func Derive(this, like Type) Type

Derive concrete type based on likeness of generic/sum type

func IncrementType

func IncrementType(t Type) Type

May be used for type sorting in future

func Integrate

func Integrate(this, from Type) Type

Integrate a concrete type into a sum or generic type

func Vec

func Vec(t Type) Type

Vec shorthand

type TypeGroup

type TypeGroup struct {
	Set []Type
}

func (TypeGroup) Equals

func (g TypeGroup) Equals(t Type) bool

func (TypeGroup) Has

func (group TypeGroup) Has(typ Type) bool

func (TypeGroup) Intersection

func (g TypeGroup) Intersection(t Group) Group

func (TypeGroup) IsAlgebraic

func (g TypeGroup) IsAlgebraic() bool

func (TypeGroup) Kind

func (g TypeGroup) Kind() int

func (TypeGroup) Realise

func (g TypeGroup) Realise() types.Type

func (TypeGroup) Resolve

func (s TypeGroup) Resolve(t Type) Type

Resolve composes Integrate with Derive, Fills in sum/generic type based on a concrete type

func (TypeGroup) String

func (g TypeGroup) String() (s string)

func (TypeGroup) Union

func (g TypeGroup) Union(t Group) Group

func (TypeGroup) Universal

func (TypeGroup) Universal() bool

func (TypeGroup) Width

func (g TypeGroup) Width() int64

type Universal

type Universal struct{}

func (Universal) Equals

func (g Universal) Equals(t Type) bool

func (Universal) Has

func (group Universal) Has(typ Type) bool

func (Universal) Intersection

func (g Universal) Intersection(t Group) Group

func (Universal) IsAlgebraic

func (g Universal) IsAlgebraic() bool

func (Universal) Kind

func (g Universal) Kind() int

func (Universal) Realise

func (g Universal) Realise() types.Type

func (Universal) Resolve

func (s Universal) Resolve(t Type) Type

Resolve composes Integrate with Derive, Fills in sum/generic type based on a concrete type

func (Universal) String

func (Universal) String() string

func (Universal) Union

func (g Universal) Union(t Group) Group

func (Universal) Universal

func (Universal) Universal() bool

func (Universal) Width

func (g Universal) Width() int64

type Value

type Value struct {
	Value value.Value
	Type  Type
}

For Apotheosis

func Val

func Val(v value.Value, t Type) Value

type Vector

type Vector struct {
	ElementType VectorType
	Body        *[]Expression
}

func (Vector) String

func (v Vector) String() string

String function for interface

func (Vector) Type

func (v Vector) Type() Type

Type property for interface

type VectorType

type VectorType struct {
	Type
}

func (VectorType) Equals

func (a VectorType) Equals(b Type) bool

Interface prism.Type comparison

func (VectorType) IsAlgebraic

func (a VectorType) IsAlgebraic() bool

Interface prism.Type algebraic predicate

func (VectorType) Kind

func (v VectorType) Kind() int

func (VectorType) Realise

func (v VectorType) Realise() types.Type

func (VectorType) Resolve

func (v VectorType) Resolve(t Type) Type

Resolve composes Integrate with Derive, Fills in sum/generic type based on a concrete type

func (VectorType) String

func (v VectorType) String() string

String function for interface

func (VectorType) SubIsVoid

func (v VectorType) SubIsVoid() bool

func (VectorType) Width

func (v VectorType) Width() int64

Interface prism.Type width for LLVM codegen

type Void

type Void struct{}

func (Void) String

func (Void) String() string

String function for interface

func (Void) Type

func (Void) Type() Type

Type property for interface

Jump to

Keyboard shortcuts

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