langsupport

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlignOffset

func AlignOffset(x, a uint32) uint32

AlignOffset returns the smallest y >= x such that y % a == 0.

Types

type ExecutionPlan

type ExecutionPlan interface {
	FnDefinition() wasm.FunctionDefinition
	FnMetadata() *metadata.Function
	ParamHandlers() []TypeHandler
	ResultHandlers() []TypeHandler
	UseResultIndirection() bool
	HasDefaultParameters() bool
	InvokeFunction(ctx context.Context, wa WasmAdapter, parameters map[string]any) (result any, err error)
}

func NewExecutionPlan

func NewExecutionPlan(fnDef wasm.FunctionDefinition, fnMeta *metadata.Function, paramHandlers, resultHandlers []TypeHandler, indirectResultSize uint32) ExecutionPlan

type Language

type Language interface {
	Name() string
	TypeInfo() LanguageTypeInfo
	NewPlanner(md *metadata.Metadata) Planner
	NewWasmAdapter(mod wasm.Module) WasmAdapter
}

func NewLanguage

func NewLanguage(name string, typeInfo LanguageTypeInfo, plannerFactory func(*metadata.Metadata) Planner, waFactory func(wasm.Module) WasmAdapter) Language

type LanguageTypeInfo

type LanguageTypeInfo interface {
	GetReflectedType(ctx context.Context, typ string) (reflect.Type, error)
	GetSizeOfType(ctx context.Context, typ string) (uint32, error)
	GetAlignmentOfType(ctx context.Context, typ string) (uint32, error)
	GetDataSizeOfType(ctx context.Context, typ string) (uint32, error)
	GetEncodingLengthOfType(ctx context.Context, typ string) (uint32, error)
	ObjectsUseMaxFieldAlignment() bool

	GetListSubtype(typ string) string
	GetMapSubtypes(typ string) (string, string)
	GetNameForType(typ string) string
	GetUnderlyingType(typ string) string

	IsBooleanType(typ string) bool
	IsByteSequenceType(typ string) bool
	IsFloatType(typ string) bool
	IsIntegerType(typ string) bool
	IsListType(typ string) bool
	IsMapType(typ string) bool
	IsObjectType(typ string) bool
	IsNullableType(typ string) bool
	IsPointerType(typ string) bool
	IsPrimitiveType(typ string) bool
	IsSignedIntegerType(typ string) bool
	IsStringType(typ string) bool
	IsTimestampType(typ string) bool
}

type Planner

type Planner interface {
	GetPlan(ctx context.Context, fnMeta *metadata.Function, fnDef wasm.FunctionDefinition) (ExecutionPlan, error)
	GetHandler(ctx context.Context, typ string) (TypeHandler, error)
	AllHandlers() map[string]TypeHandler
}

type TypeHandler

type TypeHandler interface {
	TypeInfo() TypeInfo
	Read(ctx context.Context, wa WasmAdapter, offset uint32) (any, error)
	Write(ctx context.Context, wa WasmAdapter, offset uint32, obj any) (utils.Cleaner, error)
	Decode(ctx context.Context, wa WasmAdapter, vals []uint64) (any, error)
	Encode(ctx context.Context, wa WasmAdapter, obj any) ([]uint64, utils.Cleaner, error)
}

type TypeInfo

type TypeInfo interface {
	Name() string
	ReflectedType() reflect.Type
	ZeroValue() any
	Size() uint32
	Alignment() uint32
	DataSize() uint32
	EncodingLength() uint32

	UnderlyingType() TypeInfo
	ListElementType() TypeInfo
	MapKeyType() TypeInfo
	MapValueType() TypeInfo
	ObjectFieldTypes() []TypeInfo
	ObjectFieldOffsets() []uint32

	IsBoolean() bool
	IsByteSequence() bool
	IsFloat() bool
	IsInteger() bool
	IsList() bool
	IsMap() bool
	IsNullable() bool
	IsObject() bool
	IsPointer() bool
	IsPrimitive() bool
	IsSignedInteger() bool
	IsString() bool
	IsTimestamp() bool
}

func GetTypeInfo

func GetTypeInfo(ctx context.Context, lti LanguageTypeInfo, typeName string, typeCache map[string]TypeInfo) (TypeInfo, error)

type WasmAdapter

type WasmAdapter interface {
	TypeInfo() LanguageTypeInfo
	Memory() wasm.Memory
	AllocateMemory(ctx context.Context, size uint32) (uint32, utils.Cleaner, error)
	GetFunction(name string) wasm.Function
	PreInvoke(ctx context.Context, plan ExecutionPlan) error
}

func GetWasmAdapter

func GetWasmAdapter(ctx context.Context) (WasmAdapter, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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