ssautil

package
v1.3.0-sp7 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GlobalIndexFetcher

type GlobalIndexFetcher func() int

type IfStmt

type IfStmt[T comparable] struct {
	BodyScopes []*ScopedVersionedTable[T]
	// contains filtered or unexported fields
}

IfStmt represents an if statement.

func NewIfStmt

func NewIfStmt[T comparable](global *ScopedVersionedTable[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(*ScopedVersionedTable[T]) *ScopedVersionedTable[T])

SetElse sets the else function for the IfStmt.

func (*IfStmt[T]) BuildFinish

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

Build builds the IfStmt using the provided mergeHandler function.

func (*IfStmt[T]) BuildItem

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

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

type LabelTarget

type LabelTarget[T comparable] interface {
	Break(from *ScopedVersionedTable[T])
	Continue(from *ScopedVersionedTable[T])
	FallThough(from *ScopedVersionedTable[T])
}

type LoopStmt

type LoopStmt[T comparable] struct {
	MergeToEnd   []*ScopedVersionedTable[T] // break, merge phi in exit
	MergeToLatch []*ScopedVersionedTable[T] // continue, merge phi in latch

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

LoopStmt represents a loop statement.

func NewLoopStmt

func NewLoopStmt[T comparable](global *ScopedVersionedTable[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 *ScopedVersionedTable[T])

func (*LoopStmt[T]) Build

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

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

func (*LoopStmt[T]) Continue

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

func (*LoopStmt[T]) FallThough

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

func (*LoopStmt[T]) SetBody

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

SetBody sets the body function for the LoopStmt.

func (*LoopStmt[T]) SetCondition

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

SetCondition sets the condition function for the LoopStmt.

func (*LoopStmt[T]) SetFirst

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

SetFirst sets the first function for the LoopStmt.

func (*LoopStmt[T]) SetThird

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

SetThird sets the third function for the LoopStmt.

type MergeHandle

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

type ScopedVersionedTable

type ScopedVersionedTable[T comparable] struct {
	CreateEmptyPhi func(string) T
	// contains filtered or unexported fields
}

func BuildSyntaxBlock

func BuildSyntaxBlock[T comparable](
	global *ScopedVersionedTable[T],
	buildBody func(*ScopedVersionedTable[T]) *ScopedVersionedTable[T],
) *ScopedVersionedTable[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

func NewRootVersionedTable

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

func NewScope

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

func (*ScopedVersionedTable[T]) AssignVariable

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

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

func (*ScopedVersionedTable[T]) CoverBy

func (s *ScopedVersionedTable[T]) CoverBy(scope *ScopedVersionedTable[T])

func (*ScopedVersionedTable[T]) CreateSubScope

func (v *ScopedVersionedTable[T]) CreateSubScope() *ScopedVersionedTable[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(base *ScopedVersionedTable[T], handler func(name string, ver VersionedIF[T]))

ForEachCapturedVariable call the handler for each captured by base scope Variable

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]) Merge

func (base *ScopedVersionedTable[T]) Merge(
	hasSelf bool,
	merge MergeHandle[T],
	subScopes ...*ScopedVersionedTable[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]) SetSpin

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

func (*ScopedVersionedTable[T]) Spin

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

this handler merge [origin, last] to phi

type SpinHandle

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

type SwitchStmt

type SwitchStmt[T comparable] struct {
	// contains filtered or unexported fields
}

func NewSwitchStmt

func NewSwitchStmt[T comparable](global *ScopedVersionedTable[T]) *SwitchStmt[T]

func (*SwitchStmt[T]) Break

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

func (*SwitchStmt[T]) Build

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

func (*SwitchStmt[T]) BuildBody

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

func (*SwitchStmt[T]) Continue

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

func (*SwitchStmt[T]) FallThough

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

type TryStmt

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

func NewTryStmt

func NewTryStmt[T comparable](
	global *ScopedVersionedTable[T],
	mergeHandler MergeHandle[T],
) *TryStmt[T]

func (*TryStmt[T]) Build

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

func (*TryStmt[T]) CreateCatch

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

func (*TryStmt[T]) CreateFinally

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

func (*TryStmt[T]) SetCache

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

func (*TryStmt[T]) SetError

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

func (*TryStmt[T]) SetFinal

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

func (*TryStmt[T]) SetTryBody

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

type Versioned

type Versioned[T comparable] 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 *ScopedVersionedTable[T]) bool

func (*Versioned[T]) CaptureInScope

func (v *Versioned[T]) CaptureInScope(base *ScopedVersionedTable[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() *ScopedVersionedTable[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 comparable] func(globalIndex int, name string, local bool, scope *ScopedVersionedTable[T]) VersionedIF[T]

type VersionedIF

type VersionedIF[T comparable] 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(*ScopedVersionedTable[T]) (VersionedIF[T], bool)
	CanCaptureInScope(*ScopedVersionedTable[T]) bool
	// capture variable
	SetCaptured(VersionedIF[T]) // this capture will set self, when variable create.
	GetCaptured() VersionedIF[T]

	// scope
	GetScope() *ScopedVersionedTable[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 comparable](globalIndex int, name string, local bool, scope *ScopedVersionedTable[T]) VersionedIF[T]

Jump to

Keyboard shortcuts

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