ssautil

package
v1.3.2-sp1 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ForEachCapturedVariable

func ForEachCapturedVariable[T versionedValue](
	scope ScopedVersionedTableIF[T],
	base ScopedVersionedTableIF[T],
	handler CaptureVariableHandler[T],
)

ForEachCapturedVariable call the handler for each captured by base scope Variable

Types

type CaptureVariableHandler

type CaptureVariableHandler[T versionedValue] func(string, VersionedIF[T])

capture variable

type FileDescriptor added in v1.3.3

type FileDescriptor struct {
	PathName string
	Info     os.FileInfo
	Data     []byte
}

type GlobalIndexFetcher

type GlobalIndexFetcher func() int

for builder

type IfStmt

type IfStmt[T versionedValue] struct {
	BodyScopes []ScopedVersionedTableIF[T]
	// contains filtered or unexported fields
}

IfStmt represents an if statement.

func NewIfStmt

func NewIfStmt[T versionedValue](global ScopedVersionedTableIF[T]) *IfStmt[T]

NewIfStmt creates a new IfStmt with the given global scope.

IfStmt will handle if-stmt scope.
API:
	* BuildItem(condition fun(scope), body func(scope)):
		build if item using the provided Condition and Body functions.
	* BuildElse(elseBody func(scope)):
		set the else function for the IfStmt.
	* BuildFinish(mergeHandler func(name string, t []T) T):
		build the IfStmt finish, using the provided mergeHandler function create Phi.
IfStmt will build this scope when this method call

func (*IfStmt[T]) BuildElse

func (i *IfStmt[T]) BuildElse(elseBody func(ScopedVersionedTableIF[T]) ScopedVersionedTableIF[T])

SetElse sets the else function for the IfStmt.

func (*IfStmt[T]) BuildFinish

func (i *IfStmt[T]) BuildFinish(
	mergeHandler MergeHandle[T],
) ScopedVersionedTableIF[T]

Build builds the IfStmt using the provided mergeHandler function.

func (*IfStmt[T]) BuildItem

func (i *IfStmt[T]) BuildItem(Condition func(ScopedVersionedTableIF[T]), Body func(ScopedVersionedTableIF[T]) ScopedVersionedTableIF[T])

BuildItem build the if item using the provided Condition and Body functions.

type LabelTarget

type LabelTarget[T versionedValue] interface {
	Break(from ScopedVersionedTableIF[T])
	Continue(from ScopedVersionedTableIF[T])
	FallThough(from ScopedVersionedTableIF[T])
}

type LoopStmt

type LoopStmt[T versionedValue] struct {
	MergeToEnd   []ScopedVersionedTableIF[T] // break, merge phi in exit
	MergeToLatch []ScopedVersionedTableIF[T] // continue, merge phi in latch

	ThirdBuilder func(ScopedVersionedTableIF[T]) // third
	// contains filtered or unexported fields
}

LoopStmt represents a loop statement.

func NewLoopStmt

func NewLoopStmt[T versionedValue](global ScopedVersionedTableIF[T], NewPhi func(string) T) *LoopStmt[T]

NewLoopStmt creates a new LoopStmt with the given global scope.

func (*LoopStmt[T]) Break

func (l *LoopStmt[T]) Break(from ScopedVersionedTableIF[T])

func (*LoopStmt[T]) Build

func (l *LoopStmt[T]) Build(
	SpinHandler SpinHandle[T],
	mergeLatch MergeHandle[T],
	mergeEnd MergeHandle[T],
) ScopedVersionedTableIF[T]

Build builds the LoopStmt using the provided NewPhi and SpinHandler functions.

func (*LoopStmt[T]) Continue

func (l *LoopStmt[T]) Continue(from ScopedVersionedTableIF[T])

func (*LoopStmt[T]) FallThough

func (l *LoopStmt[T]) FallThough(from ScopedVersionedTableIF[T])

func (*LoopStmt[T]) SetBody

func (l *LoopStmt[T]) SetBody(f func(ScopedVersionedTableIF[T]) ScopedVersionedTableIF[T])

SetBody sets the body function for the LoopStmt.

func (*LoopStmt[T]) SetCondition

func (l *LoopStmt[T]) SetCondition(f func(ScopedVersionedTableIF[T]))

SetCondition sets the condition function for the LoopStmt.

func (*LoopStmt[T]) SetFirst

func (l *LoopStmt[T]) SetFirst(f func(ScopedVersionedTableIF[T]))

SetFirst sets the first function for the LoopStmt.

func (*LoopStmt[T]) SetThird

func (l *LoopStmt[T]) SetThird(f func(ScopedVersionedTableIF[T]))

SetThird sets the third function for the LoopStmt.

type MergeHandle

type MergeHandle[T comparable] func(string, []T) T

MergeHandle handler Merge Value generate Phi

type PackageLoader added in v1.3.3

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

func NewPackageLoader added in v1.3.3

func NewPackageLoader(opts ...PackageLoaderOption) *PackageLoader

func (*PackageLoader) AddIncludePath added in v1.3.3

func (p *PackageLoader) AddIncludePath(s ...string)

func (*PackageLoader) DirPath added in v1.3.3

func (p *PackageLoader) DirPath(wantPath string, once bool) (string, error)

func (*PackageLoader) FilePath added in v1.3.3

func (p *PackageLoader) FilePath(wantPath string, once bool) (string, error)

func (*PackageLoader) GetCurrentPath added in v1.3.3

func (p *PackageLoader) GetCurrentPath() string

func (*PackageLoader) LoadDirectoryPackage added in v1.3.3

func (p *PackageLoader) LoadDirectoryPackage(packageName string, once bool) (chan FileDescriptor, error)

func (*PackageLoader) LoadFilePackage added in v1.3.3

func (p *PackageLoader) LoadFilePackage(packageName string, once bool) (string, []byte, error)

func (*PackageLoader) SetCurrentPath added in v1.3.3

func (p *PackageLoader) SetCurrentPath(currentPath string)

type PackageLoaderOption added in v1.3.3

type PackageLoaderOption func(*PackageLoader)

func WithCurrentPath added in v1.3.3

func WithCurrentPath(path string) PackageLoaderOption

func WithEmbedFS

func WithEmbedFS(fs embed.FS) PackageLoaderOption

func WithIncludePath added in v1.3.3

func WithIncludePath(paths ...string) PackageLoaderOption

type SSAValue

type SSAValue interface {
	IsUndefined() bool
	SelfDelete()
}

type ScopedVersionedTable

type ScopedVersionedTable[T versionedValue] struct {
	// contains filtered or unexported fields
}

func NewRootVersionedTable

func NewRootVersionedTable[T versionedValue](
	newVersioned VersionedBuilder[T],
	fetcher ...func() int,
) *ScopedVersionedTable[T]

func NewScope

func NewScope[T versionedValue](
	fetcher func() int,
	newVersioned VersionedBuilder[T],
	table map[int]VersionedIF[T],
	parent ScopedVersionedTableIF[T],
) *ScopedVersionedTable[T]

func (*ScopedVersionedTable[T]) AssignVariable

func (scope *ScopedVersionedTable[T]) AssignVariable(variable VersionedIF[T], value T)

---------------- Assign

func (*ScopedVersionedTable[T]) Compare

func (s *ScopedVersionedTable[T]) Compare(other ScopedVersionedTableIF[T]) bool

func (*ScopedVersionedTable[T]) CoverBy

func (base *ScopedVersionedTable[T]) CoverBy(scope ScopedVersionedTableIF[T])

func (*ScopedVersionedTable[T]) CreateSubScope

func (v *ScopedVersionedTable[T]) CreateSubScope() ScopedVersionedTableIF[T]

func (*ScopedVersionedTable[T]) CreateVariable

func (v *ScopedVersionedTable[T]) CreateVariable(name string, isLocal bool) VersionedIF[T]

func (*ScopedVersionedTable[T]) ForEachCapturedVariable

func (ps *ScopedVersionedTable[T]) ForEachCapturedVariable(handler CaptureVariableHandler[T])

func (*ScopedVersionedTable[T]) GetParent

func (v *ScopedVersionedTable[T]) GetParent() ScopedVersionedTableIF[T]

func (*ScopedVersionedTable[T]) GetScopeLevel

func (s *ScopedVersionedTable[T]) GetScopeLevel() int

use for up lever

func (*ScopedVersionedTable[T]) GetThis

func (v *ScopedVersionedTable[T]) GetThis() ScopedVersionedTableIF[T]

func (*ScopedVersionedTable[T]) GetVariableFromValue

func (scope *ScopedVersionedTable[T]) GetVariableFromValue(value T) VersionedIF[T]

func (*ScopedVersionedTable[T]) IsRoot

func (v *ScopedVersionedTable[T]) IsRoot() bool

func (*ScopedVersionedTable[T]) IsSameOrSubScope

func (s *ScopedVersionedTable[T]) IsSameOrSubScope(other ScopedVersionedTableIF[T]) bool

IsSubScope check if the scope is sub scope of the other

func (*ScopedVersionedTable[T]) Merge

func (base *ScopedVersionedTable[T]) Merge(
	hasSelf bool,
	merge MergeHandle[T],
	subScopes ...ScopedVersionedTableIF[T],
)

Merge merge the sub-scope to current scope, if hasSelf is true: the current scope will be merged to the result

func (*ScopedVersionedTable[T]) ReadValue

func (v *ScopedVersionedTable[T]) ReadValue(name string) (t T)

func (*ScopedVersionedTable[T]) ReadVariable

func (scope *ScopedVersionedTable[T]) ReadVariable(name string) VersionedIF[T]

func (*ScopedVersionedTable[T]) SetCapturedVariable

func (scope *ScopedVersionedTable[T]) SetCapturedVariable(name string, ver VersionedIF[T])

func (*ScopedVersionedTable[T]) SetSpin

func (s *ScopedVersionedTable[T]) SetSpin(create func(string) T)

func (*ScopedVersionedTable[T]) SetThis

func (v *ScopedVersionedTable[T]) SetThis(scope ScopedVersionedTableIF[T])

func (*ScopedVersionedTable[T]) Spin

func (s *ScopedVersionedTable[T]) Spin(
	header, latch ScopedVersionedTableIF[T],
	handler SpinHandle[T],
)

this handler merge [origin, last] to phi

type ScopedVersionedTableIF

type ScopedVersionedTableIF[T versionedValue] interface {
	// Read Variable by name
	ReadVariable(name string) VersionedIF[T]
	// read value by name
	ReadValue(name string) T

	// create variable, if isLocal is true, the variable is local
	CreateVariable(name string, isLocal bool) VersionedIF[T]

	// assign a value to the variable
	AssignVariable(VersionedIF[T], T)

	GetVariableFromValue(T) VersionedIF[T]

	// this scope
	SetThis(ScopedVersionedTableIF[T])
	GetThis() ScopedVersionedTableIF[T]

	// create sub scope
	CreateSubScope() ScopedVersionedTableIF[T]
	// get scope level, each scope has a level, the root scope is 0, the sub scope is {parent-scope.level + 1}
	GetScopeLevel() int
	GetParent() ScopedVersionedTableIF[T]

	IsSameOrSubScope(ScopedVersionedTableIF[T]) bool
	Compare(ScopedVersionedTableIF[T]) bool

	// use in ssautil, handle inner member
	ForEachCapturedVariable(CaptureVariableHandler[T])
	SetCapturedVariable(string, VersionedIF[T])

	// use in phi
	CoverBy(ScopedVersionedTableIF[T])
	Merge(bool, MergeHandle[T], ...ScopedVersionedTableIF[T])
	Spin(ScopedVersionedTableIF[T], ScopedVersionedTableIF[T], SpinHandle[T])
	SetSpin(func(string) T)
}

ScopedVersionedTableIF is the interface for scope versioned table

func BuildSyntaxBlock

func BuildSyntaxBlock[T versionedValue](
	global ScopedVersionedTableIF[T],
	buildBody func(ScopedVersionedTableIF[T]) ScopedVersionedTableIF[T],
) ScopedVersionedTableIF[T]

BuildSyntaxBlock builds a syntax block using the provided scope and buildBody function.

if this scope finish this program

* BuildBody should return true

* this function will return true

type SpinHandle

type SpinHandle[T comparable] func(string, T, T, T) map[string]T

SpinHandle for Loop Spin Phi

type SwitchStmt

type SwitchStmt[T versionedValue] struct {
	AutoBreak bool
	// contains filtered or unexported fields
}

func NewSwitchStmt

func NewSwitchStmt[T versionedValue](global ScopedVersionedTableIF[T], AutoBreak bool) *SwitchStmt[T]

func (*SwitchStmt[T]) Break

func (s *SwitchStmt[T]) Break(from ScopedVersionedTableIF[T])

func (*SwitchStmt[T]) Build

func (s *SwitchStmt[T]) Build(merge func(string, []T) T) ScopedVersionedTableIF[T]

func (*SwitchStmt[T]) BuildBody

func (s *SwitchStmt[T]) BuildBody(
	body func(ScopedVersionedTableIF[T]) ScopedVersionedTableIF[T],
	merge func(string, []T) T,
)

func (*SwitchStmt[T]) Continue

func (s *SwitchStmt[T]) Continue(from ScopedVersionedTableIF[T])

func (*SwitchStmt[T]) FallThough

func (s *SwitchStmt[T]) FallThough(from ScopedVersionedTableIF[T])

type TryStmt

type TryStmt[T versionedValue] struct {
	ErrorName string
	// contains filtered or unexported fields
}

func NewTryStmt

func NewTryStmt[T versionedValue](
	global ScopedVersionedTableIF[T],
	mergeHandler MergeHandle[T],
) *TryStmt[T]

func (*TryStmt[T]) Build

func (t *TryStmt[T]) Build() ScopedVersionedTableIF[T]

func (*TryStmt[T]) CreateCatch

func (t *TryStmt[T]) CreateCatch() ScopedVersionedTableIF[T]

func (*TryStmt[T]) CreateFinally

func (t *TryStmt[T]) CreateFinally() ScopedVersionedTableIF[T]

func (*TryStmt[T]) SetCache

func (t *TryStmt[T]) SetCache(build func() ScopedVersionedTableIF[T])

func (*TryStmt[T]) SetError

func (t *TryStmt[T]) SetError(name string)

func (*TryStmt[T]) SetFinal

func (t *TryStmt[T]) SetFinal(build func() ScopedVersionedTableIF[T])

func (*TryStmt[T]) SetTryBody

func (t *TryStmt[T]) SetTryBody(body func(ScopedVersionedTableIF[T]) ScopedVersionedTableIF[T])

type Versioned

type Versioned[T versionedValue] struct {
	Value T
	// contains filtered or unexported fields
}

func (*Versioned[T]) Assign

func (v *Versioned[T]) Assign(val T) error

func (*Versioned[T]) CanCaptureInScope

func (v *Versioned[T]) CanCaptureInScope(base ScopedVersionedTableIF[T]) bool

func (*Versioned[T]) CaptureInScope

func (v *Versioned[T]) CaptureInScope(base ScopedVersionedTableIF[T]) (VersionedIF[T], bool)

func (*Versioned[T]) GetCaptured

func (v *Versioned[T]) GetCaptured() VersionedIF[T]

func (*Versioned[T]) GetGlobalIndex

func (v *Versioned[T]) GetGlobalIndex() int

func (*Versioned[T]) GetLocal

func (v *Versioned[T]) GetLocal() bool

func (*Versioned[T]) GetName

func (v *Versioned[T]) GetName() string

func (*Versioned[T]) GetRootVersion

func (v *Versioned[T]) GetRootVersion() VersionedIF[T]

func (*Versioned[T]) GetScope

func (v *Versioned[T]) GetScope() ScopedVersionedTableIF[T]

func (*Versioned[T]) GetValue

func (v *Versioned[T]) GetValue() (ret T)

func (*Versioned[T]) GetVersion

func (v *Versioned[T]) GetVersion() int

func (*Versioned[T]) IsNil

func (v *Versioned[T]) IsNil() bool

func (*Versioned[T]) IsRoot

func (v *Versioned[T]) IsRoot() bool

func (*Versioned[T]) Replace

func (v *Versioned[T]) Replace(val, to T)

func (*Versioned[T]) SetCaptured

func (v *Versioned[T]) SetCaptured(capture VersionedIF[T])

func (*Versioned[T]) SetVersion

func (v *Versioned[T]) SetVersion(version int)

func (*Versioned[T]) String

func (v *Versioned[T]) String() string

type VersionedBuilder

type VersionedBuilder[T versionedValue] func(globalIndex int, name string, local bool, scope ScopedVersionedTableIF[T]) VersionedIF[T]

type VersionedIF

type VersionedIF[T versionedValue] interface {
	// value
	// IsNil return true if the variable is nil
	IsNil() bool
	GetValue() T

	// Replace
	Replace(T, T)
	// Assign assign a value to the variable
	Assign(T) error

	// show, string and name
	String() string
	GetName() string

	// version
	SetVersion(int)
	GetVersion() int

	// local
	GetLocal() bool

	// capture
	CaptureInScope(ScopedVersionedTableIF[T]) (VersionedIF[T], bool)
	CanCaptureInScope(ScopedVersionedTableIF[T]) bool
	// capture variable
	SetCaptured(VersionedIF[T]) // this capture will set self, when variable create.
	GetCaptured() VersionedIF[T]

	// scope
	GetScope() ScopedVersionedTableIF[T]

	// version and root
	GetGlobalIndex() int // global id
	GetRootVersion() VersionedIF[T]
	IsRoot() bool
}

VersionedIF is an interface for versioned variable, scope will use this interface

func NewVersioned

func NewVersioned[T versionedValue](globalIndex int, name string, local bool, scope ScopedVersionedTableIF[T]) VersionedIF[T]

Jump to

Keyboard shortcuts

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