glsl

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2021 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NO_ROLE  FunctionArgumentRole = 0
	IN_ROLE                       = 1 << 0
	OUT_ROLE                      = 1 << 1
)

Variables

View Source
var TARGET = "vertex"

Functions

func FillCoreScope

func FillCoreScope(scope Scope)

func FillFragmentShaderScope

func FillFragmentShaderScope(scope Scope)

func FillGlobalScope

func FillGlobalScope(scope Scope)

func FillVertexShaderScope

func FillVertexShaderScope(scope Scope)

func IsLiteralBool

func IsLiteralBool(t Expression) bool

func IsLiteralFloat

func IsLiteralFloat(t Expression) bool

func IsLiteralInt

func IsLiteralInt(t Expression) bool

func IsMacroExpression

func IsMacroExpression(call *Call) bool

func IsMacroStatement

func IsMacroStatement(call *Call) bool

func PrecisionTypeToString

func PrecisionTypeToString(ptype PrecisionType) string

func RoleToString

func RoleToString(role FunctionArgumentRole) string

Types

type AddOp

type AddOp struct {
	BinaryOp
}

func NewAddOp

func NewAddOp(a, b Expression, ctx context.Context) *AddOp

func (*AddOp) EvalExpression

func (t *AddOp) EvalExpression() (values.Value, error)

type AndOp

type AndOp struct {
	LogicalBinaryOp
}

func NewAndOp

func NewAndOp(a, b Expression, ctx context.Context) *AndOp

type Assign

type Assign struct {
	TokenData
	// contains filtered or unexported fields
}

func NewAssign

func NewAssign(lhs Expression, rhs Expression, op string, ctx context.Context) *Assign

func (*Assign) Dump

func (t *Assign) Dump(indent string) string

func (*Assign) EvalStatement

func (t *Assign) EvalStatement() error

func (*Assign) ResolveStatementActivity

func (t *Assign) ResolveStatementActivity(usage Usage) error

func (*Assign) ResolveStatementNames

func (t *Assign) ResolveStatementNames(scope Scope) error

func (*Assign) UniqueStatementNames

func (t *Assign) UniqueStatementNames(ns Namespace) error

func (*Assign) WriteStatement

func (t *Assign) WriteStatement(usage Usage, indent string, nl string, tab string) string

type Attribute

type Attribute struct {
	Pointer
}

func NewAttribute

func NewAttribute(typeExpr *TypeExpression, name string, ctx context.Context) *Attribute

func (*Attribute) Dump

func (t *Attribute) Dump(indent string) string

func (*Attribute) WriteStatement

func (t *Attribute) WriteStatement(usage Usage, indent string, nl string, tab string) string

type BinaryOp

type BinaryOp struct {
	TokenData
	// contains filtered or unexported fields
}

func (*BinaryOp) Dump

func (t *BinaryOp) Dump(indent string) string

dump functions

func (*BinaryOp) ResolveExpressionActivity

func (t *BinaryOp) ResolveExpressionActivity(usage Usage) error

func (*BinaryOp) ResolveExpressionNames

func (t *BinaryOp) ResolveExpressionNames(scope Scope) error

func (*BinaryOp) WriteExpression

func (t *BinaryOp) WriteExpression() string

type Block

type Block struct {
	TokenData
	// contains filtered or unexported fields
}

func NewBlock

func NewBlock(ctx context.Context) *Block

func (*Block) AddStatement

func (t *Block) AddStatement(statement Statement)

func (*Block) Dump

func (t *Block) Dump(indent string) string

func (*Block) ResolveStatementActivity

func (t *Block) ResolveStatementActivity(usage Usage) error

func (*Block) ResolveStatementNames

func (t *Block) ResolveStatementNames(scope Scope) error

func (*Block) UniqueStatementNames

func (t *Block) UniqueStatementNames(ns Namespace) error

type Call

type Call struct {
	TokenData
	// contains filtered or unexported fields
}

func NewCall

func NewCall(lhs Expression, args []Expression, ctx context.Context) *Call

func (*Call) Args

func (t *Call) Args() []Expression

func (*Call) Dump

func (t *Call) Dump(indent string) string

func (*Call) EvalExpression

func (t *Call) EvalExpression() (values.Value, error)

func (*Call) EvalStatement

func (t *Call) EvalStatement() error

func (*Call) Name

func (t *Call) Name() string

returns empty string if lhs is not *VarExpression

func (*Call) ResolveExpressionActivity

func (t *Call) ResolveExpressionActivity(usage Usage) error

func (*Call) ResolveExpressionNames

func (t *Call) ResolveExpressionNames(scope Scope) error

func (*Call) ResolveStatementActivity

func (t *Call) ResolveStatementActivity(usage Usage) error

func (*Call) ResolveStatementNames

func (t *Call) ResolveStatementNames(scope Scope) error

func (*Call) UniqueStatementNames

func (t *Call) UniqueStatementNames(ns Namespace) error

func (*Call) WriteExpression

func (t *Call) WriteExpression() string

func (*Call) WriteStatement

func (t *Call) WriteStatement(usage Usage, indent string, nl string, tab string) string

type Const

type Const struct {
	Pointer
	// contains filtered or unexported fields
}

func NewConst

func NewConst(typeExpr *TypeExpression, name string, n int, rhsExpr Expression, isExport bool, ctx context.Context) *Const

func (*Const) Dump

func (t *Const) Dump(indent string) string

func (*Const) Length

func (t *Const) Length() int

func (*Const) ResolveStatementActivity added in v0.2.0

func (t *Const) ResolveStatementActivity(usage Usage) error

func (*Const) ResolveStatementNames

func (t *Const) ResolveStatementNames(scope Scope) error

func (*Const) SetAltRHS

func (t *Const) SetAltRHS(str string)

func (*Const) TypeName

func (t *Const) TypeName() string

func (*Const) UniqueStatementNames added in v0.2.0

func (t *Const) UniqueStatementNames(ns Namespace) error

func (*Const) WriteStatement

func (t *Const) WriteStatement(usage Usage, indent string, nl string, tab string) string

type DivOp

type DivOp struct {
	BinaryOp
}

func NewDivOp

func NewDivOp(a, b Expression, ctx context.Context) *DivOp

func (*DivOp) EvalExpression

func (t *DivOp) EvalExpression() (values.Value, error)

type DynamicIndexFunction

type DynamicIndexFunction struct {
	MacroFunction
	// contains filtered or unexported fields
}

type EqCompareOp

type EqCompareOp struct {
	BinaryOp
}

func (*EqCompareOp) EvalExpression

func (t *EqCompareOp) EvalExpression() (values.Value, error)

type EqOp

type EqOp struct {
	EqCompareOp
}

func NewEqOp

func NewEqOp(a, b Expression, ctx context.Context) *EqOp

type Export

type Export struct {
	TokenData
	// contains filtered or unexported fields
}

func NewExport

func NewExport(newName *Word, varExpr *VarExpression, ctx context.Context) *Export

func (*Export) Dump

func (t *Export) Dump(indent string) string

func (*Export) EvalStatement

func (t *Export) EvalStatement() error

func (*Export) ResolveStatementActivity

func (t *Export) ResolveStatementActivity(usage Usage) error

func (*Export) ResolveStatementNames

func (t *Export) ResolveStatementNames(scope Scope) error

func (*Export) UniqueStatementNames

func (t *Export) UniqueStatementNames(ns Namespace) error

func (*Export) WriteStatement

func (t *Export) WriteStatement(usage Usage, indent string, nl string, tab string) string

type ExportedVariable

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

type Expression

type Expression interface {
	Token

	WriteExpression() string

	ResolveExpressionNames(scope Scope) error

	EvalExpression() (values.Value, error)

	ResolveExpressionActivity(usage Usage) error
}

func DispatchMacroExpression

func DispatchMacroExpression(call *Call) (Expression, error)

func NewGetDynamicIndex

func NewGetDynamicIndex(args []Expression, ctx context.Context) (Expression, error)

type Extension

type Extension struct {
	PreProc
	// contains filtered or unexported fields
}

func NewExtension

func NewExtension(extension string, behavior string, ctx context.Context) *Extension

func (*Extension) Dump

func (t *Extension) Dump(indent string) string

func (*Extension) WriteStatement

func (t *Extension) WriteStatement(usage Usage, indent string, nl string, tab string) string

TODO: only write when no in library

type For added in v0.2.0

type For struct {
	Block
	// contains filtered or unexported fields
}

func NewFor added in v0.2.0

func NewFor(init Statement, comp Expression, incr Statement, statements []Statement, ctx context.Context) *For

func (*For) Dump added in v0.2.0

func (t *For) Dump(indent string) string

func (*For) EvalStatement added in v0.2.0

func (t *For) EvalStatement() error

func (*For) ResolveStatementActivity added in v0.2.0

func (t *For) ResolveStatementActivity(usage Usage) error

func (*For) ResolveStatementNames added in v0.2.0

func (t *For) ResolveStatementNames(scope Scope) error

func (*For) UniqueStatementNames added in v0.2.0

func (t *For) UniqueStatementNames(ns Namespace) error

func (*For) WriteStatement added in v0.2.0

func (t *For) WriteStatement(usage Usage, indent string, nl string, tab string) string

type Function

type Function struct {
	Block
	// contains filtered or unexported fields
}

func NewFunction

func NewFunction(fi *FunctionInterface, statements []Statement, ctx context.Context) *Function

func (*Function) Dump

func (t *Function) Dump(indent string) string

func (*Function) EvalCall

func (t *Function) EvalCall(args []values.Value, ctx context.Context) (values.Value, error)

args == nil allows the caller to retrieve only the return value

func (*Function) EvalStatement

func (t *Function) EvalStatement() error

func (*Function) GetVariable

func (t *Function) GetVariable() Variable

func (*Function) Name

func (t *Function) Name() string

func (*Function) NewScope

func (t *Function) NewScope(parent Scope) *FunctionScope

func (*Function) RegisterReturn

func (t *Function) RegisterReturn(ret *Return)

func (*Function) ResolveStatementActivity

func (t *Function) ResolveStatementActivity(usage Usage) error

func (*Function) ResolveStatementNames

func (t *Function) ResolveStatementNames(outer Scope) error

func (*Function) UniqueStatementNames

func (t *Function) UniqueStatementNames(ns Namespace) error

func (*Function) WriteStatement

func (t *Function) WriteStatement(usage Usage, indent string, nl string, tab string) string

type FunctionArgument

type FunctionArgument struct {
	TokenData
	// contains filtered or unexported fields
}

func NewFunctionArgument

func NewFunctionArgument(role FunctionArgumentRole, typeExpr *TypeExpression, name string, length int, ctx context.Context) *FunctionArgument

func (*FunctionArgument) Dump

func (fa *FunctionArgument) Dump(indent string) string

func (*FunctionArgument) GetTypeValue

func (fa *FunctionArgument) GetTypeValue() (values.Value, error)

func (*FunctionArgument) Name

func (fa *FunctionArgument) Name() string

func (*FunctionArgument) ResolveNames

func (fa *FunctionArgument) ResolveNames(scope Scope) error

func (*FunctionArgument) UniqueNames

func (fa *FunctionArgument) UniqueNames(ns Namespace) error

func (*FunctionArgument) WriteArgument

func (fa *FunctionArgument) WriteArgument() string

type FunctionArgumentRole

type FunctionArgumentRole int

type FunctionInterface

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

func NewFunctionInterface

func NewFunctionInterface(retTypeExpr *TypeExpression, name string, args []*FunctionArgument, ctx context.Context) *FunctionInterface

func (*FunctionInterface) Context

func (fi *FunctionInterface) Context() context.Context

func (*FunctionInterface) Dump

func (fi *FunctionInterface) Dump(indent string) string

func (*FunctionInterface) EvalCall

func (fi *FunctionInterface) EvalCall(args []values.Value, ctx context.Context) (values.Value, error)

func (*FunctionInterface) GetVariable

func (fi *FunctionInterface) GetVariable() Variable

func (*FunctionInterface) Name

func (fi *FunctionInterface) Name() string

func (*FunctionInterface) ResolveNames

func (fi *FunctionInterface) ResolveNames(scope Scope) error

func (*FunctionInterface) UniqueNames

func (fi *FunctionInterface) UniqueNames(ns Namespace) error

func (*FunctionInterface) WriteInterface

func (fi *FunctionInterface) WriteInterface() string

type FunctionScope

type FunctionScope struct {
	ScopeData
	// contains filtered or unexported fields
}

func NewFunctionScope

func NewFunctionScope(fn *Function, parent Scope) *FunctionScope

func (*FunctionScope) GetFunction

func (fs *FunctionScope) GetFunction() *Function

func (*FunctionScope) SetVariable

func (fs *FunctionScope) SetVariable(name string, v Variable) error

type GEOp

type GEOp struct {
	OrderCompareOp
}

func NewGEOp

func NewGEOp(a, b Expression, ctx context.Context) *GEOp

type GTOp

type GTOp struct {
	OrderCompareOp
}

func NewGTOp

func NewGTOp(a, b Expression, ctx context.Context) *GTOp

type GetDynamicIndex

type GetDynamicIndex struct {
	Index
	// contains filtered or unexported fields
}

func (*GetDynamicIndex) Dump

func (t *GetDynamicIndex) Dump(indent string) string

func (*GetDynamicIndex) EvalExpression

func (t *GetDynamicIndex) EvalExpression() (values.Value, error)

func (*GetDynamicIndex) ResolveExpressionActivity

func (t *GetDynamicIndex) ResolveExpressionActivity(usage Usage) error

func (*GetDynamicIndex) WriteExpression

func (t *GetDynamicIndex) WriteExpression() string

type GetDynamicIndexFunction

type GetDynamicIndexFunction struct {
	DynamicIndexFunction
	// contains filtered or unexported fields
}

func NewGetDynamicIndexFunction

func NewGetDynamicIndexFunction(containerTypeName string, typeName string, length int, ctx context.Context) *GetDynamicIndexFunction

func (*GetDynamicIndexFunction) Dump

func (t *GetDynamicIndexFunction) Dump(indent string) string

func (*GetDynamicIndexFunction) WriteStatement

func (t *GetDynamicIndexFunction) WriteStatement(usage Usage, indent string, nl string, tab string) string

type GlobalScope

type GlobalScope interface {
	Scope
	GetModule(path string) (Module, error)
}

func GetGlobalScope

func GetGlobalScope(s_ Scope) GlobalScope

type GlobalScopeData

type GlobalScopeData struct {
	ScopeData
}

wrapped by BundleScope in order to implement the GlobalScope interface

func NewFilledGlobalScope

func NewFilledGlobalScope() *GlobalScopeData

type If

type If struct {
	TokenData
	// contains filtered or unexported fields
}

func NewIf

func NewIf(ctx context.Context) *If

func (*If) AddCondition

func (t *If) AddCondition(expr Expression) error

func (*If) AddElse

func (t *If) AddElse() error

func (*If) AddStatement

func (t *If) AddStatement(statement Statement)

func (*If) Dump

func (t *If) Dump(indent string) string

func (*If) EvalStatement

func (t *If) EvalStatement() error

func (*If) ResolveStatementActivity

func (t *If) ResolveStatementActivity(usage Usage) error

func (*If) ResolveStatementNames

func (t *If) ResolveStatementNames(scope Scope) error

func (*If) UniqueStatementNames

func (t *If) UniqueStatementNames(ns Namespace) error

func (*If) WriteStatement

func (t *If) WriteStatement(usage Usage, indent string, nl string, tab string) string

type Import

type Import struct {
	TokenData
	// contains filtered or unexported fields
}

func NewImport

func NewImport(newName *Word, varExpr *VarExpression, path_ *LiteralString, ctx context.Context) (*Import, error)

func (*Import) Dump

func (t *Import) Dump(indent string) string

func (*Import) EvalStatement

func (t *Import) EvalStatement() error

func (*Import) Path

func (t *Import) Path() *LiteralString

func (*Import) ResolveStatementActivity

func (t *Import) ResolveStatementActivity(usage Usage) error

func (*Import) ResolveStatementNames

func (t *Import) ResolveStatementNames(scope Scope) error

func (*Import) UniqueStatementNames

func (t *Import) UniqueStatementNames(ns Namespace) error

func (*Import) WriteStatement

func (t *Import) WriteStatement(usage Usage, indent string, nl string, tab string) string

type ImportExport

type ImportExport struct {
	Import
}

func NewImportExport

func NewImportExport(newName *Word, varExpr *VarExpression, path_ *LiteralString, ctx context.Context) (*ImportExport, error)

func (*ImportExport) Dump

func (t *ImportExport) Dump(indent string) string

func (*ImportExport) ResolveStatementNames

func (t *ImportExport) ResolveStatementNames(scope Scope) error

func (*ImportExport) WriteStatement

func (t *ImportExport) WriteStatement(usage Usage, indent string, nl string, tab string) string

type Index

type Index struct {
	TokenData
	// contains filtered or unexported fields
}

func NewIndex

func NewIndex(container Expression, index Expression, ctx context.Context) *Index

func (*Index) Dump

func (t *Index) Dump(indent string) string

func (*Index) EvalExpression

func (t *Index) EvalExpression() (values.Value, error)

func (*Index) EvalSet

func (t *Index) EvalSet(rhsValue values.Value, ctx context.Context) error

func (*Index) ResolveExpressionActivity

func (t *Index) ResolveExpressionActivity(usage Usage) error

func (*Index) ResolveExpressionNames

func (t *Index) ResolveExpressionNames(scope Scope) error

func (*Index) WriteExpression

func (t *Index) WriteExpression() string

type InjectedStatement

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

type LEOp

type LEOp struct {
	OrderCompareOp
}

func NewLEOp

func NewLEOp(a, b Expression, ctx context.Context) *LEOp

type LTOp

type LTOp struct {
	OrderCompareOp
}

func NewLTOp

func NewLTOp(a, b Expression, ctx context.Context) *LTOp

type LiteralBool

type LiteralBool struct {
	LiteralData
	// contains filtered or unexported fields
}

func NewLiteralBool

func NewLiteralBool(value bool, ctx context.Context) *LiteralBool

func (*LiteralBool) Dump

func (t *LiteralBool) Dump(indent string) string

func (*LiteralBool) EvalExpression

func (t *LiteralBool) EvalExpression() (values.Value, error)

func (*LiteralBool) Value

func (t *LiteralBool) Value() bool

func (*LiteralBool) WriteExpression

func (t *LiteralBool) WriteExpression() string

type LiteralData

type LiteralData struct {
	TokenData
}

intended for LiteralInt, LiteralBool, LiteralFloat and LiteralString

func (*LiteralData) ResolveExpressionActivity

func (t *LiteralData) ResolveExpressionActivity(usage Usage) error

func (*LiteralData) ResolveExpressionNames

func (t *LiteralData) ResolveExpressionNames(scope Scope) error

type LiteralFloat

type LiteralFloat struct {
	LiteralData
	// contains filtered or unexported fields
}

func NewLiteralFloat

func NewLiteralFloat(value float64, ctx context.Context) *LiteralFloat

func (*LiteralFloat) Dump

func (t *LiteralFloat) Dump(indent string) string

func (*LiteralFloat) EvalExpression

func (t *LiteralFloat) EvalExpression() (values.Value, error)

func (*LiteralFloat) Value

func (t *LiteralFloat) Value() float64

func (*LiteralFloat) WriteExpression

func (t *LiteralFloat) WriteExpression() string

type LiteralInt

type LiteralInt struct {
	LiteralData
	// contains filtered or unexported fields
}

func NewLiteralInt

func NewLiteralInt(value int, ctx context.Context) *LiteralInt

func (*LiteralInt) Dump

func (t *LiteralInt) Dump(indent string) string

func (*LiteralInt) EvalExpression

func (t *LiteralInt) EvalExpression() (values.Value, error)

func (*LiteralInt) Value

func (t *LiteralInt) Value() int

func (*LiteralInt) WriteExpression

func (t *LiteralInt) WriteExpression() string

type LiteralString

type LiteralString struct {
	LiteralData
	// contains filtered or unexported fields
}

func NewLiteralString

func NewLiteralString(value string, ctx context.Context) *LiteralString

func (*LiteralString) EvalExpression

func (t *LiteralString) EvalExpression() (values.Value, error)

func (*LiteralString) Value

func (t *LiteralString) Value() string

type LogicalBinaryOp

type LogicalBinaryOp struct {
	BinaryOp
}

func (*LogicalBinaryOp) EvalExpression

func (t *LogicalBinaryOp) EvalExpression() (values.Value, error)

type MacroExpression

type MacroExpression func(args []Expression, ctx context.Context) (Expression, error)

type MacroFunction

type MacroFunction struct {
	TokenData
	// contains filtered or unexported fields
}

func (*MacroFunction) EvalStatement

func (t *MacroFunction) EvalStatement() error

func (*MacroFunction) GetVariable

func (t *MacroFunction) GetVariable() Variable

func (*MacroFunction) Name

func (t *MacroFunction) Name() string

func (*MacroFunction) ResolveStatementActivity

func (t *MacroFunction) ResolveStatementActivity(usage Usage) error

func (*MacroFunction) ResolveStatementNames

func (t *MacroFunction) ResolveStatementNames(scope Scope) error

func (*MacroFunction) UniqueStatementNames

func (t *MacroFunction) UniqueStatementNames(ns Namespace) error

type MacroStatement

type MacroStatement func(args []Expression, ctx context.Context) (Statement, error)

type Member

type Member struct {
	TokenData
	// contains filtered or unexported fields
}

func NewMember

func NewMember(object Expression, key *Word, ctx context.Context) *Member

func (*Member) Dump

func (t *Member) Dump(indent string) string

func (*Member) EvalExpression

func (t *Member) EvalExpression() (values.Value, error)

func (*Member) EvalSet

func (t *Member) EvalSet(rhsValue values.Value, ctx context.Context) error

func (*Member) GetPackageMember

func (t *Member) GetPackageMember() (Variable, error)

func (*Member) ResolveExpressionActivity

func (t *Member) ResolveExpressionActivity(usage Usage) error

func (*Member) ResolveExpressionNames

func (t *Member) ResolveExpressionNames(scope Scope) error

func (*Member) WriteExpression

func (t *Member) WriteExpression() string

type Module

type Module interface {
	GetExportedVariable(gs GlobalScope, name string, nameCtx context.Context) (Variable, error)

	Context() context.Context
}

type ModuleData

type ModuleData struct {
	Block
	// contains filtered or unexported fields
}

func GetModule

func GetModule(s_ Scope) *ModuleData

func NewModule

func NewModule(ctx context.Context) *ModuleData

func (*ModuleData) CollectVaryings

func (m *ModuleData) CollectVaryings(varyings map[string]string) error

func (*ModuleData) CollectVersion

func (m *ModuleData) CollectVersion(version *Word) (*Word, error)

func (*ModuleData) Dependencies

func (m *ModuleData) Dependencies() []files.PathLang

func (*ModuleData) EvalTypes

func (m *ModuleData) EvalTypes() error

func (*ModuleData) FinalizeInjected

func (m *ModuleData) FinalizeInjected(usage Usage) error

func (*ModuleData) FindExportedConst

func (m *ModuleData) FindExportedConst(name string) *Const

func (*ModuleData) GetExportedVariable

func (m *ModuleData) GetExportedVariable(gs GlobalScope, name string,
	nameCtx context.Context) (Variable, error)

called from within other module

func (*ModuleData) ResolveActivity

func (m *ModuleData) ResolveActivity(usage Usage) error

func (*ModuleData) ResolveEntryNames

func (m *ModuleData) ResolveEntryNames(gs GlobalScope) (Variable, error)

func (*ModuleData) ResolveNames

func (m *ModuleData) ResolveNames(gs GlobalScope) error

func (*ModuleData) ResolveStatementNames

func (m *ModuleData) ResolveStatementNames(scope Scope) error

func (*ModuleData) SetExportedVariable

func (m *ModuleData) SetExportedVariable(outerName string, v Variable, ctx context.Context) error

func (*ModuleData) UniqueNames

func (m *ModuleData) UniqueNames(ns Namespace) error

func (*ModuleData) Write

func (m *ModuleData) Write(usage Usage, nl string, tab string) (string, error)

type ModuleScope

type ModuleScope struct {
	ScopeData
	// contains filtered or unexported fields
}

type MulOp

type MulOp struct {
	BinaryOp
}

func NewMulOp

func NewMulOp(a, b Expression, ctx context.Context) *MulOp

func (*MulOp) EvalExpression

func (t *MulOp) EvalExpression() (values.Value, error)

type NEOp

type NEOp struct {
	EqCompareOp
}

func NewNEOp

func NewNEOp(a, b Expression, ctx context.Context) *NEOp

type Namespace

type Namespace interface {
	NewBlockNamespace() Namespace
	NewFunctionNamespace() Namespace

	CurrentFunctionNamespace() Namespace

	FunctionName(v Variable)
	ArgName(v Variable)
	VarName(v Variable)
	OrigName(v Variable) error

	HasName(newName string) bool
	HasVar(v Variable) bool
}

func NewNamespace

func NewNamespace(parent Namespace, isFunction bool) Namespace

type NamespaceData

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

func (*NamespaceData) ArgName

func (ns *NamespaceData) ArgName(v Variable)

func (*NamespaceData) CurrentFunctionNamespace

func (ns *NamespaceData) CurrentFunctionNamespace() Namespace

func (*NamespaceData) FunctionName

func (ns *NamespaceData) FunctionName(v Variable)

func (*NamespaceData) HasName

func (ns *NamespaceData) HasName(newName string) bool

func (*NamespaceData) HasVar

func (ns *NamespaceData) HasVar(v Variable) bool

func (*NamespaceData) NewBlockNamespace

func (ns *NamespaceData) NewBlockNamespace() Namespace

func (*NamespaceData) NewFunctionNamespace

func (ns *NamespaceData) NewFunctionNamespace() Namespace

func (*NamespaceData) OrigName

func (ns *NamespaceData) OrigName(v Variable) error

func (*NamespaceData) VarName

func (ns *NamespaceData) VarName(v Variable)

type NegOp

type NegOp struct {
	PreUnaryOp
}

func NewNegOp

func NewNegOp(a Expression, ctx context.Context) *NegOp

func (*NegOp) EvalExpression

func (t *NegOp) EvalExpression() (values.Value, error)

type NotOp

type NotOp struct {
	PreUnaryOp
}

func NewNotOp

func NewNotOp(a Expression, ctx context.Context) *NotOp

func (*NotOp) EvalExpression

func (t *NotOp) EvalExpression() (values.Value, error)

type OrOp

type OrOp struct {
	LogicalBinaryOp
}

func NewOrOp

func NewOrOp(a, b Expression, ctx context.Context) *OrOp

type OrderCompareOp

type OrderCompareOp struct {
	BinaryOp
}

func (*OrderCompareOp) EvalExpression

func (t *OrderCompareOp) EvalExpression() (values.Value, error)

type Package

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

func NewPackage

func NewPackage(path string, ctx context.Context) *Package

user packages start nameless

func (*Package) Constant

func (t *Package) Constant() bool

func (*Package) GetObject

func (t *Package) GetObject() interface{}

func (*Package) GetValue

func (t *Package) GetValue() values.Value

func (*Package) Name

func (t *Package) Name() string

func (*Package) Rename

func (t *Package) Rename(n string)

func (*Package) SetConstant

func (t *Package) SetConstant()

func (*Package) SetObject

func (t *Package) SetObject(obj interface{})

func (*Package) SetValue

func (t *Package) SetValue(v values.Value)

type Parens

type Parens struct {
	TokenData
	// contains filtered or unexported fields
}

func NewParens

func NewParens(expr Expression, ctx context.Context) *Parens

func (*Parens) Dump

func (t *Parens) Dump(indent string) string

func (*Parens) EvalExpression

func (t *Parens) EvalExpression() (values.Value, error)

func (*Parens) ResolveExpressionActivity

func (t *Parens) ResolveExpressionActivity(usage Usage) error

func (*Parens) ResolveExpressionNames

func (t *Parens) ResolveExpressionNames(scope Scope) error

func (*Parens) WriteExpression

func (t *Parens) WriteExpression() string

type Pointer

type Pointer struct {
	TokenData
	// contains filtered or unexported fields
}

func (*Pointer) EvalStatement

func (t *Pointer) EvalStatement() error

func (*Pointer) GetVariable

func (t *Pointer) GetVariable() Variable

func (*Pointer) Name

func (t *Pointer) Name() string

func (*Pointer) ResolveStatementActivity

func (t *Pointer) ResolveStatementActivity(usage Usage) error

func (*Pointer) ResolveStatementNames

func (t *Pointer) ResolveStatementNames(scope Scope) error

func (*Pointer) UniqueStatementNames

func (t *Pointer) UniqueStatementNames(ns Namespace) error

likely exported, so keep original name

type PosOp

type PosOp struct {
	PreUnaryOp
}

func NewPosOp

func NewPosOp(a Expression, ctx context.Context) *PosOp

func (*PosOp) EvalExpression

func (t *PosOp) EvalExpression() (values.Value, error)

type PostDecrOp

type PostDecrOp struct {
	PostUnaryOp
}

func NewPostDecrOp

func NewPostDecrOp(a Expression, ctx context.Context) *PostDecrOp

func (*PostDecrOp) EvalStatement

func (t *PostDecrOp) EvalStatement() error

type PostIncrOp

type PostIncrOp struct {
	PostUnaryOp
}

func NewPostIncrOp

func NewPostIncrOp(a Expression, ctx context.Context) *PostIncrOp

func (*PostIncrOp) EvalStatement

func (t *PostIncrOp) EvalStatement() error

type PostUnaryOp

type PostUnaryOp struct {
	UnaryOp
}

func (*PostUnaryOp) ResolveStatementActivity

func (t *PostUnaryOp) ResolveStatementActivity(usage Usage) error

func (*PostUnaryOp) ResolveStatementNames

func (t *PostUnaryOp) ResolveStatementNames(scope Scope) error

func (*PostUnaryOp) UniqueStatementNames

func (t *PostUnaryOp) UniqueStatementNames(ns Namespace) error

func (*PostUnaryOp) WriteExpression

func (t *PostUnaryOp) WriteExpression() string

func (*PostUnaryOp) WriteStatement

func (t *PostUnaryOp) WriteStatement(usage Usage, indent string, nl string, tab string) string

type PreProc

type PreProc struct {
	TokenData
}

func (*PreProc) EvalStatement

func (t *PreProc) EvalStatement() error

func (*PreProc) ResolveStatementActivity

func (t *PreProc) ResolveStatementActivity(usage Usage) error

func (*PreProc) ResolveStatementNames

func (t *PreProc) ResolveStatementNames(scope Scope) error

func (*PreProc) UniqueStatementNames

func (t *PreProc) UniqueStatementNames(ns Namespace) error

type PreUnaryOp

type PreUnaryOp struct {
	UnaryOp
}

func (*PreUnaryOp) WriteExpression

func (t *PreUnaryOp) WriteExpression() string

type Precision

type Precision struct {
	TokenData
	// contains filtered or unexported fields
}

func NewPrecision

func NewPrecision(precType PrecisionType, typeExpr *TypeExpression, ctx context.Context) *Precision

func (*Precision) Dump

func (t *Precision) Dump(indent string) string

func (*Precision) EvalStatement

func (t *Precision) EvalStatement() error

func (*Precision) ResolveStatementActivity

func (t *Precision) ResolveStatementActivity(usage Usage) error

func (*Precision) ResolveStatementNames

func (t *Precision) ResolveStatementNames(scope Scope) error

func (*Precision) UniqueStatementNames

func (t *Precision) UniqueStatementNames(ns Namespace) error

func (*Precision) WriteStatement

func (t *Precision) WriteStatement(usage Usage, indent string, nl string, tab string) string

type PrecisionType

type PrecisionType int
const (
	DEFAULTP PrecisionType = iota
	LOWP
	MEDIUMP
	HIGHP
)

type Return

type Return struct {
	TokenData
	// contains filtered or unexported fields
}

func NewReturn

func NewReturn(expr Expression, ctx context.Context) *Return

expr can be nil

func (*Return) Dump

func (t *Return) Dump(indent string) string

func (*Return) EvalStatement

func (t *Return) EvalStatement() error

func (*Return) ResolveStatementActivity

func (t *Return) ResolveStatementActivity(usage Usage) error

func (*Return) ResolveStatementNames

func (t *Return) ResolveStatementNames(scope Scope) error

func (*Return) UniqueStatementNames

func (t *Return) UniqueStatementNames(ns Namespace) error

func (*Return) WriteStatement

func (t *Return) WriteStatement(usage Usage, indent string, nl string, tab string) string

type Scope

type Scope interface {
	Parent() Scope

	HasVariable(name string) bool
	GetVariable(name string) (Variable, error)
	SetVariable(name string, v Variable) error

	GetFunction() *Function
}

type ScopeData

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

func NewScope

func NewScope(parent Scope) *ScopeData

func (*ScopeData) GetFunction

func (s *ScopeData) GetFunction() *Function

func (*ScopeData) GetVariable

func (s *ScopeData) GetVariable(name string) (Variable, error)

func (*ScopeData) HasVariable

func (s *ScopeData) HasVariable(name string) bool

func (*ScopeData) Parent

func (s *ScopeData) Parent() Scope

func (*ScopeData) SetVariable

func (s *ScopeData) SetVariable(name string, v Variable) error

type SetDynamicIndex

type SetDynamicIndex struct {
	Index
	// contains filtered or unexported fields
}

func (*SetDynamicIndex) Dump

func (t *SetDynamicIndex) Dump(indent string) string

func (*SetDynamicIndex) EvalStatement

func (t *SetDynamicIndex) EvalStatement() error

func (*SetDynamicIndex) ResolveStatementActivity

func (t *SetDynamicIndex) ResolveStatementActivity(usage Usage) error

func (*SetDynamicIndex) ResolveStatementNames

func (t *SetDynamicIndex) ResolveStatementNames(scope Scope) error

func (*SetDynamicIndex) UniqueStatementNames

func (t *SetDynamicIndex) UniqueStatementNames(ns Namespace) error

func (*SetDynamicIndex) WriteStatement

func (t *SetDynamicIndex) WriteStatement(usage Usage, indent string, nl string, tab string) string

type SetDynamicIndexFunction

type SetDynamicIndexFunction struct {
	DynamicIndexFunction
	// contains filtered or unexported fields
}

func NewSetDynamicIndexFunction

func NewSetDynamicIndexFunction(containerTypeName string, typeName string, length int, ctx context.Context) *SetDynamicIndexFunction

func (*SetDynamicIndexFunction) Dump

func (t *SetDynamicIndexFunction) Dump(indent string) string

func (*SetDynamicIndexFunction) WriteStatement

func (t *SetDynamicIndexFunction) WriteStatement(usage Usage, indent string, nl string, tab string) string

type Statement

type Statement interface {
	Token

	WriteStatement(usage Usage, indent string, nl string, tab string) string

	ResolveStatementNames(scope Scope) error

	EvalStatement() error

	ResolveStatementActivity(usage Usage) error

	UniqueStatementNames(ns Namespace) error
}

func DispatchMacroStatement

func DispatchMacroStatement(call *Call) (Statement, error)

func NewSetDynamicIndex

func NewSetDynamicIndex(args []Expression, ctx context.Context) (Statement, error)

type Struct

type Struct struct {
	TokenData
	// contains filtered or unexported fields
}

func NewStruct

func NewStruct(nameExpr *VarExpression, entries []*StructEntry, ctx context.Context) (*Struct, error)

func (*Struct) CheckConstruction

func (t *Struct) CheckConstruction(args []values.Value, ctx context.Context) error

func (*Struct) Dump

func (t *Struct) Dump(indent string) string

func (*Struct) EvalStatement

func (t *Struct) EvalStatement() error

func (*Struct) GetMember

func (t *Struct) GetMember(key string, ctx context.Context) (values.Value, error)

func (*Struct) GetVariable

func (t *Struct) GetVariable() Variable

func (*Struct) Name

func (t *Struct) Name() string

func (*Struct) ResolveStatementActivity

func (t *Struct) ResolveStatementActivity(usage Usage) error

func (*Struct) ResolveStatementNames

func (t *Struct) ResolveStatementNames(scope Scope) error

func (*Struct) SetMember

func (t *Struct) SetMember(key string, arg values.Value, ctx context.Context) error

func (*Struct) UniqueStatementNames

func (t *Struct) UniqueStatementNames(ns Namespace) error

func (*Struct) WriteStatement

func (t *Struct) WriteStatement(usage Usage, indent string, nl string, tab string) string

type StructEntry

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

func NewStructEntry

func NewStructEntry(typeExpr *TypeExpression, nameExpr *VarExpression, length int, ctx context.Context) *StructEntry

func (*StructEntry) Context

func (se *StructEntry) Context() context.Context

func (*StructEntry) Dump

func (t *StructEntry) Dump(indent string) string

func (*StructEntry) Instantiate

func (se *StructEntry) Instantiate(ctx context.Context) (values.Value, error)

func (*StructEntry) Name

func (se *StructEntry) Name() string

func (*StructEntry) ResolveNames

func (se *StructEntry) ResolveNames(scope Scope) error

type SubOp

type SubOp struct {
	BinaryOp
}

func NewSubOp

func NewSubOp(a, b Expression, ctx context.Context) *SubOp

func (*SubOp) EvalExpression

func (t *SubOp) EvalExpression() (values.Value, error)

type Token

type Token interface {
	Dump(indent string) string
	Context() context.Context
}

type TokenData

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

func (*TokenData) Context

func (t *TokenData) Context() context.Context

type TypeExpression

type TypeExpression struct {
	VarExpression
}

func NewTypeExpression

func NewTypeExpression(name string, ctx context.Context) *TypeExpression

func (*TypeExpression) Dump

func (t *TypeExpression) Dump(indent string) string

func (*TypeExpression) EvalExpression

func (t *TypeExpression) EvalExpression() (values.Value, error)

func (*TypeExpression) Instantiate

func (t *TypeExpression) Instantiate(ctx context.Context) (values.Value, error)

func (*TypeExpression) InstantiateUniform

func (t *TypeExpression) InstantiateUniform(ctx context.Context) (values.Value, error)

func (*TypeExpression) WriteExpression

func (t *TypeExpression) WriteExpression() string

type UnaryOp

type UnaryOp struct {
	TokenData
	// contains filtered or unexported fields
}

func (*UnaryOp) Dump

func (t *UnaryOp) Dump(indent string) string

dump functions

func (*UnaryOp) ResolveExpressionActivity

func (t *UnaryOp) ResolveExpressionActivity(usage Usage) error

func (*UnaryOp) ResolveExpressionNames

func (t *UnaryOp) ResolveExpressionNames(scope Scope) error

type Uniform

type Uniform struct {
	Pointer
}

func NewUniform

func NewUniform(typeExpr *TypeExpression, name string, n int, ctx context.Context) *Uniform

func (*Uniform) Dump

func (t *Uniform) Dump(indent string) string

func (*Uniform) EvalStatement

func (t *Uniform) EvalStatement() error

different from Pointer.EvalStatement(), because different types are allowed

func (*Uniform) WriteStatement

func (t *Uniform) WriteStatement(usage Usage, indent string, nl string, tab string) string

type Usage

type Usage interface {
	Use(v Variable, ctx context.Context) error
	Rereference(v Variable, ctx context.Context) error
	IsUsed(v Variable) bool

	GetInjectedStatements(name string) []InjectedStatement
	InjectStatement(name string, variable Variable, deps []Variable, st Statement)
	PopInjectedStatements(dep Variable) []InjectedStatement

	DetectUnused() error
}

func NewUsage

func NewUsage() Usage

type UsageData

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

func (*UsageData) DetectUnused

func (u *UsageData) DetectUnused() error

func (*UsageData) GetInjectedStatements

func (u *UsageData) GetInjectedStatements(name string) []InjectedStatement

func (*UsageData) InjectStatement

func (u *UsageData) InjectStatement(name string, variable Variable, deps []Variable, st Statement)

func (*UsageData) IsUsed

func (u *UsageData) IsUsed(v Variable) bool

func (*UsageData) PopInjectedStatements

func (u *UsageData) PopInjectedStatements(dep Variable) []InjectedStatement

func (*UsageData) Rereference

func (u *UsageData) Rereference(v Variable, ctx context.Context) error

func (*UsageData) Use

func (u *UsageData) Use(v Variable, ctx context.Context) error

type UsageState

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

type VarExpression

type VarExpression struct {
	TokenData
	// contains filtered or unexported fields
}

func NewVarExpression

func NewVarExpression(name string, ctx context.Context) *VarExpression

func (*VarExpression) Dump

func (t *VarExpression) Dump(indent string) string

func (*VarExpression) EvalExpression

func (t *VarExpression) EvalExpression() (values.Value, error)

func (*VarExpression) EvalSet

func (t *VarExpression) EvalSet(v values.Value, ctx context.Context) error

func (*VarExpression) GetVariable

func (t *VarExpression) GetVariable() Variable

func (*VarExpression) Name

func (t *VarExpression) Name() string

func (*VarExpression) ResolveExpressionActivity

func (t *VarExpression) ResolveExpressionActivity(usage Usage) error

func (*VarExpression) ResolveExpressionNames

func (t *VarExpression) ResolveExpressionNames(scope Scope) error

func (*VarExpression) WriteExpression

func (t *VarExpression) WriteExpression() string

type VarStatement

type VarStatement struct {
	TokenData
	// contains filtered or unexported fields
}

func NewVarStatement

func NewVarStatement(typeExpr *TypeExpression, name string, length int, rhsExpr Expression, ctx context.Context) *VarStatement

func (*VarStatement) Dump

func (t *VarStatement) Dump(indent string) string

func (*VarStatement) EvalStatement

func (t *VarStatement) EvalStatement() error

func (*VarStatement) ResolveStatementActivity

func (t *VarStatement) ResolveStatementActivity(usage Usage) error

func (*VarStatement) ResolveStatementNames

func (t *VarStatement) ResolveStatementNames(scope Scope) error

func (*VarStatement) UniqueStatementNames

func (t *VarStatement) UniqueStatementNames(ns Namespace) error

func (*VarStatement) WriteStatement

func (t *VarStatement) WriteStatement(usage Usage, indent string, nl string, tab string) string

type Variable

type Variable interface {
	Context() context.Context
	Name() string
	Rename(string)

	Constant() bool
	SetConstant()

	GetValue() values.Value
	SetValue(val values.Value)

	GetObject() interface{}
	SetObject(obj interface{})
}

type VariableData

type VariableData struct {
	TokenData
	// contains filtered or unexported fields
}

func NewVariable

func NewVariable(name string, ctx context.Context) *VariableData

func (*VariableData) Constant

func (t *VariableData) Constant() bool

func (*VariableData) GetObject

func (t *VariableData) GetObject() interface{}

func (*VariableData) GetValue

func (t *VariableData) GetValue() values.Value

func (*VariableData) Name

func (v *VariableData) Name() string

func (*VariableData) Rename

func (t *VariableData) Rename(newName string)

func (*VariableData) SetConstant

func (t *VariableData) SetConstant()

func (*VariableData) SetObject

func (t *VariableData) SetObject(obj interface{})

func (*VariableData) SetValue

func (t *VariableData) SetValue(v values.Value)

type Varying

type Varying struct {
	Pointer
	// contains filtered or unexported fields
}

func NewVarying

func NewVarying(precType PrecisionType, typeExpr *TypeExpression, name string, ctx context.Context) *Varying

func (*Varying) Collect

func (t *Varying) Collect(varyings map[string]string) error

func (*Varying) Dump

func (t *Varying) Dump(indent string) string

func (*Varying) EvalStatement

func (t *Varying) EvalStatement() error

func (*Varying) ResolveStatementActivity added in v0.2.0

func (t *Varying) ResolveStatementActivity(usage Usage) error

func (*Varying) WriteStatement

func (t *Varying) WriteStatement(usage Usage, indent string, nl string, tab string) string

type Version

type Version struct {
	PreProc
	// contains filtered or unexported fields
}

func NewVersion

func NewVersion(version int, es string, ctx context.Context) *Version

func (*Version) CollectVersion

func (t *Version) CollectVersion(version *Word) (*Word, error)

func (*Version) Dump

func (t *Version) Dump(indent string) string

func (*Version) WriteStatement

func (t *Version) WriteStatement(usage Usage, indent string, nl string, tab string) string

written by tree/shader/ShaderBundle instead

type Word

type Word struct {
	TokenData
	// contains filtered or unexported fields
}

eg. for key of member essentially a string-context pair

func AssertWord

func AssertWord(t Token) (*Word, error)

func NewWord

func NewWord(value string, ctx context.Context) *Word

func (*Word) Dump

func (t *Word) Dump(indent string) string

func (*Word) Value

func (t *Word) Value() string

type XorOp

type XorOp struct {
	LogicalBinaryOp
}

func NewXorOp

func NewXorOp(a, b Expression, ctx context.Context) *XorOp

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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