kvm

package
v0.0.0-...-309cb8d Latest Latest
Warning

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

Go to latest
Published: May 26, 2019 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Overview

Copyright 2017 karma.run AG. All rights reserved. Use of this source code is governed by an AGPL license that can be found in the LICENSE file.

Copyright 2017 karma.run AG. All rights reserved. Use of this source code is governed by an AGPL license that can be found in the LICENSE file.

Copyright 2017 karma.run AG. All rights reserved. Use of this source code is governed by an AGPL license that can be found in the LICENSE file.

Copyright 2017 karma.run AG. All rights reserved. Use of this source code is governed by an AGPL license that can be found in the LICENSE file.

Copyright 2017 karma.run AG. All rights reserved. Use of this source code is governed by an AGPL license that can be found in the LICENSE file.

Copyright 2017 karma.run AG. All rights reserved. Use of this source code is governed by an AGPL license that can be found in the LICENSE file.

Index

Constants

View Source
const ModelCacheCapacity = 512
View Source
const SeparatorByte = '~'

Variables

View Source
var (
	AnyModel      = mdl.Any{}
	BoolModel     = mdl.Bool{}
	Int8Model     = mdl.Int8{}
	Int16Model    = mdl.Int16{}
	Int32Model    = mdl.Int32{}
	Int64Model    = mdl.Int64{}
	Uint8Model    = mdl.Uint8{}
	Uint16Model   = mdl.Uint16{}
	Uint32Model   = mdl.Uint32{}
	Uint64Model   = mdl.Uint64{}
	FloatModel    = mdl.Float{}
	StringModel   = mdl.String{}
	DateTimeModel = mdl.DateTime{}
	NullModel     = mdl.Null{}
)
View Source
var ZeroTypedExpression = xpr.TypedExpression{}
View Source
var ZeroTypedFunction = xpr.TypedFunction{}

Functions

func ClearCompilerCache

func ClearCompilerCache()

clears compiler cache (for all databases)

func DematerializeMeta

func DematerializeMeta(s val.Struct) val.Meta

turns structs (from persistence) into meta values for vm

func MaterializeMeta

func MaterializeMeta(m val.Meta) val.Struct

turns meta values into structs for persistence

func UnwrapBucket

func UnwrapBucket(model mdl.Model) mdl.Model

func UnwrapConstant

func UnwrapConstant(model mdl.Model) mdl.Model

Types

type AutoTransformationError

type AutoTransformationError struct {
	Problem string
	Source  mdl.Model
	Target  mdl.Model
	Path    err.ErrorPath
}

func NewAutoTransformationError

func NewAutoTransformationError(problem string, source, target mdl.Model) AutoTransformationError

func (AutoTransformationError) AppendPath

func (AutoTransformationError) Child

func (e AutoTransformationError) Child() err.Error

func (AutoTransformationError) Error

func (e AutoTransformationError) Error() string

func (AutoTransformationError) ErrorPath

func (e AutoTransformationError) ErrorPath() err.ErrorPath

func (AutoTransformationError) String

func (e AutoTransformationError) String() string

func (AutoTransformationError) Value

func (e AutoTransformationError) Value() val.Union

type BucketModel

type BucketModel struct {
	mdl.Model
	Bucket string
}

convenience adapter for models associated with a bucket (Bucket = model's value collection)

type ConstantModel

type ConstantModel struct {
	mdl.Model
	Value val.Value
}

convenience for dynamic compilation of constant values

func (ConstantModel) Zero

func (m ConstantModel) Zero() val.Value

type ModelScope

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

func NewModelScope

func NewModelScope() *ModelScope

func (*ModelScope) Child

func (s *ModelScope) Child() *ModelScope

func (*ModelScope) Flat

func (s *ModelScope) Flat() map[string]mdl.Model

for debugging purposes only

func (*ModelScope) Get

func (s *ModelScope) Get(k string) (mdl.Model, bool)

func (*ModelScope) GetLocal

func (s *ModelScope) GetLocal(k string) (mdl.Model, bool)

func (*ModelScope) Set

func (s *ModelScope) Set(k string, m mdl.Model)

type Permission

type Permission uint8
const (
	InvalidPermission Permission = iota // zero-guard
	CreatePermission
	ReadPermission
	UpdatePermission
	DeletePermission
)

type Stack

type Stack []val.Value

func NewStack

func NewStack(capacity int) *Stack

func (Stack) Len

func (s Stack) Len() int

func (Stack) Peek

func (s Stack) Peek() val.Value

func (*Stack) Pop

func (s *Stack) Pop() val.Value

func (*Stack) Push

func (s *Stack) Push(v val.Value)

type TypeCheckingError

type TypeCheckingError struct {
	Want mdl.Model
	Have mdl.Model
	Path err.ErrorPath
}

func (TypeCheckingError) AppendPath

func (TypeCheckingError) Child

func (e TypeCheckingError) Child() err.Error

func (TypeCheckingError) Error

func (e TypeCheckingError) Error() string

func (TypeCheckingError) ErrorPath

func (e TypeCheckingError) ErrorPath() err.ErrorPath

func (TypeCheckingError) String

func (e TypeCheckingError) String() string

func (TypeCheckingError) Value

func (e TypeCheckingError) Value() val.Union

func (TypeCheckingError) Zero

func (e TypeCheckingError) Zero() bool

type TypeInferenceError

type TypeInferenceError struct {
	Want mdl.Model
	Have val.Value // literal
	Path err.ErrorPath
}

func (TypeInferenceError) AppendPath

func (TypeInferenceError) Child

func (e TypeInferenceError) Child() err.Error

func (TypeInferenceError) Error

func (e TypeInferenceError) Error() string

func (TypeInferenceError) ErrorPath

func (e TypeInferenceError) ErrorPath() err.ErrorPath

func (TypeInferenceError) String

func (e TypeInferenceError) String() string

func (TypeInferenceError) Value

func (e TypeInferenceError) Value() val.Union

func (TypeInferenceError) Zero

func (e TypeInferenceError) Zero() bool

type ValueScope

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

func NewValueScope

func NewValueScope() *ValueScope

func (*ValueScope) Child

func (s *ValueScope) Child() *ValueScope

func (*ValueScope) Get

func (s *ValueScope) Get(k string) (val.Value, bool)

func (*ValueScope) Set

func (s *ValueScope) Set(k string, m val.Value)

type VirtualMachine

type VirtualMachine struct {
	UserID     string
	RootBucket *bolt.Bucket
	// contains filtered or unexported fields
}

func (*VirtualMachine) CheckPermission

func (vm *VirtualMachine) CheckPermission(p Permission, v val.Meta) err.Error

CheckPermissions checks permissions, recursively. The base case is nil / permission granted. This enables the definition of impure permissions, i.e. permissions that depend on data reads.

func (VirtualMachine) CompileAndExecuteExpression

func (vm VirtualMachine) CompileAndExecuteExpression(expression xpr.Expression) (val.Value, mdl.Model, err.Error)

func (VirtualMachine) CompileExpression

func (vm VirtualMachine) CompileExpression(typed xpr.TypedExpression, prev inst.Sequence) inst.Sequence

func (VirtualMachine) CompileFunction

func (vm VirtualMachine) CompileFunction(f xpr.TypedFunction) inst.Sequence

func (VirtualMachine) Delete

func (vm VirtualMachine) Delete(mid, id string) err.Error

func (VirtualMachine) Execute

func (vm VirtualMachine) Execute(program inst.Sequence, scope *ValueScope, args ...val.Value) (val.Value, err.Error)

scope may be nil, that's fine -- will be allocated when needed.

func (*VirtualMachine) ExpressionModelId

func (vm *VirtualMachine) ExpressionModelId() string

func (VirtualMachine) Get

func (vm VirtualMachine) Get(mid, oid string) (val.Meta, err.Error)

func (VirtualMachine) InRefs

func (vm VirtualMachine) InRefs(mid, id string) []val.Ref

func (VirtualMachine) InitDB

func (vm VirtualMachine) InitDB() error

func (VirtualMachine) MetaModel

func (vm VirtualMachine) MetaModel() mdl.Model

func (*VirtualMachine) MetaModelId

func (vm *VirtualMachine) MetaModelId() string

func (*VirtualMachine) MigrationModelId

func (vm *VirtualMachine) MigrationModelId() string

func (VirtualMachine) Model

func (vm VirtualMachine) Model(mid string) (BucketModel, err.Error)

func (VirtualMachine) Parse

func (vm VirtualMachine) Parse(v val.Value, scope *ModelScope, parameters []mdl.Model, expect mdl.Model) (xpr.TypedFunction, err.Error)

NOTE: parameters == nil means don't check argument types. parameters == []mdl.Mode{} means check for niladic function.

func (VirtualMachine) ParseAndCompile

func (vm VirtualMachine) ParseAndCompile(v val.Value, scope *ModelScope, parameters []mdl.Model, expect mdl.Model) (inst.Sequence, mdl.Model, err.Error)

func (VirtualMachine) ParseCompileAndExecute

func (vm VirtualMachine) ParseCompileAndExecute(v val.Value, scope *ModelScope, parameters []mdl.Model, expect mdl.Model, arguments ...val.Value) (val.Value, mdl.Model, err.Error)

func (*VirtualMachine) RoleModelId

func (vm *VirtualMachine) RoleModelId() string

func (VirtualMachine) RootUserId

func (vm VirtualMachine) RootUserId() string

func (*VirtualMachine) TagModelId

func (vm *VirtualMachine) TagModelId() string

func (VirtualMachine) TypeExpression

func (vm VirtualMachine) TypeExpression(node xpr.Expression, scope *ModelScope, expected mdl.Model) (xpr.TypedExpression, err.Error)

VirtualMachine.TypeExpression infers, propagates and checks type information in an xpr.Expression tree. It returns an equivalent tree, where each xpr.Expression is wrapped in an xpr.TypedExpression. Some typing decisions depend on constant expressions. This is why constant values are propagated as well. This is done by wrapping the pertinent types and associated values in ContantModel. Parameter 'expected' indicates the expected return type of the expression.

func (VirtualMachine) TypeFunction

func (vm VirtualMachine) TypeFunction(f xpr.Function, scope *ModelScope, expected mdl.Model) (xpr.TypedFunction, err.Error)

scope may be nil, that's fine, scope.Child() will allocate.

func (VirtualMachine) TypeFunctionWithArguments

func (vm VirtualMachine) TypeFunctionWithArguments(f xpr.Function, scope *ModelScope, expected mdl.Model, args ...mdl.Model) (xpr.TypedFunction, err.Error)

scope may be nil, that's fine, scope.Child() will allocate. nil args will be inferred (as far as possible).

func (VirtualMachine) UpdateModels

func (vm VirtualMachine) UpdateModels() error

func (*VirtualMachine) UserModelId

func (vm *VirtualMachine) UserModelId() string

func (VirtualMachine) WrapModelInMeta

func (vm VirtualMachine) WrapModelInMeta(mid string, model mdl.Model) mdl.Model

func (VirtualMachine) WrapValueInMeta

func (vm VirtualMachine) WrapValueInMeta(value val.Value, id, mid string) val.Meta

func (VirtualMachine) Write

func (vm VirtualMachine) Write(mid string, values map[string]val.Meta) err.Error

Note: Write is idempontent i.e. also serves as update function

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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