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
- Variables
- func ClearCompilerCache()
- func DematerializeMeta(s val.Struct) val.Meta
- func MaterializeMeta(m val.Meta) val.Struct
- func UnwrapBucket(model mdl.Model) mdl.Model
- func UnwrapConstant(model mdl.Model) mdl.Model
- type AutoTransformationError
- func (e AutoTransformationError) AppendPath(a err.ErrorPathElement, b ...err.ErrorPathElement) err.PathedError
- func (e AutoTransformationError) Child() err.Error
- func (e AutoTransformationError) Error() string
- func (e AutoTransformationError) ErrorPath() err.ErrorPath
- func (e AutoTransformationError) String() string
- func (e AutoTransformationError) Value() val.Union
- type BucketModel
- type ConstantModel
- type ModelScope
- type Permission
- type Stack
- type TypeCheckingError
- func (e TypeCheckingError) AppendPath(a err.ErrorPathElement, b ...err.ErrorPathElement) err.PathedError
- func (e TypeCheckingError) Child() err.Error
- func (e TypeCheckingError) Error() string
- func (e TypeCheckingError) ErrorPath() err.ErrorPath
- func (e TypeCheckingError) String() string
- func (e TypeCheckingError) Value() val.Union
- func (e TypeCheckingError) Zero() bool
- type TypeInferenceError
- func (e TypeInferenceError) AppendPath(a err.ErrorPathElement, b ...err.ErrorPathElement) err.PathedError
- func (e TypeInferenceError) Child() err.Error
- func (e TypeInferenceError) Error() string
- func (e TypeInferenceError) ErrorPath() err.ErrorPath
- func (e TypeInferenceError) String() string
- func (e TypeInferenceError) Value() val.Union
- func (e TypeInferenceError) Zero() bool
- type ValueScope
- type VirtualMachine
- func (vm *VirtualMachine) CheckPermission(p Permission, v val.Meta) err.Error
- func (vm VirtualMachine) CompileAndExecuteExpression(expression xpr.Expression) (val.Value, mdl.Model, err.Error)
- func (vm VirtualMachine) CompileExpression(typed xpr.TypedExpression, prev inst.Sequence) inst.Sequence
- func (vm VirtualMachine) CompileFunction(f xpr.TypedFunction) inst.Sequence
- func (vm VirtualMachine) Delete(mid, id string) err.Error
- func (vm VirtualMachine) Execute(program inst.Sequence, scope *ValueScope, args ...val.Value) (val.Value, err.Error)
- func (vm *VirtualMachine) ExpressionModelId() string
- func (vm VirtualMachine) Get(mid, oid string) (val.Meta, err.Error)
- func (vm VirtualMachine) InRefs(mid, id string) []val.Ref
- func (vm VirtualMachine) InitDB() error
- func (vm VirtualMachine) MetaModel() mdl.Model
- func (vm *VirtualMachine) MetaModelId() string
- func (vm *VirtualMachine) MigrationModelId() string
- func (vm VirtualMachine) Model(mid string) (BucketModel, err.Error)
- func (vm VirtualMachine) Parse(v val.Value, scope *ModelScope, parameters []mdl.Model, expect mdl.Model) (xpr.TypedFunction, err.Error)
- func (vm VirtualMachine) ParseAndCompile(v val.Value, scope *ModelScope, parameters []mdl.Model, expect mdl.Model) (inst.Sequence, mdl.Model, err.Error)
- func (vm VirtualMachine) ParseCompileAndExecute(v val.Value, scope *ModelScope, parameters []mdl.Model, expect mdl.Model, ...) (val.Value, mdl.Model, err.Error)
- func (vm *VirtualMachine) RoleModelId() string
- func (vm VirtualMachine) RootUserId() string
- func (vm *VirtualMachine) TagModelId() string
- func (vm VirtualMachine) TypeExpression(node xpr.Expression, scope *ModelScope, expected mdl.Model) (xpr.TypedExpression, err.Error)
- func (vm VirtualMachine) TypeFunction(f xpr.Function, scope *ModelScope, expected mdl.Model) (xpr.TypedFunction, err.Error)
- func (vm VirtualMachine) TypeFunctionWithArguments(f xpr.Function, scope *ModelScope, expected mdl.Model, args ...mdl.Model) (xpr.TypedFunction, err.Error)
- func (vm VirtualMachine) UpdateModels() error
- func (vm *VirtualMachine) UserModelId() string
- func (vm VirtualMachine) WrapModelInMeta(mid string, model mdl.Model) mdl.Model
- func (vm VirtualMachine) WrapValueInMeta(value val.Value, id, mid string) val.Meta
- func (vm VirtualMachine) Write(mid string, values map[string]val.Meta) err.Error
Constants ¶
const ModelCacheCapacity = 512
const SeparatorByte = '~'
Variables ¶
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{} )
var ModelCache = cc.NewLru(ModelCacheCapacity)
var ZeroTypedExpression = xpr.TypedExpression{}
var ZeroTypedFunction = xpr.TypedFunction{}
Functions ¶
func DematerializeMeta ¶
turns structs (from persistence) into meta values for vm
func MaterializeMeta ¶
turns meta values into structs for persistence
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 (e AutoTransformationError) AppendPath(a err.ErrorPathElement, b ...err.ErrorPathElement) err.PathedError
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 ¶
convenience adapter for models associated with a bucket (Bucket = model's value collection)
type ConstantModel ¶
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
type Permission ¶
type Permission uint8
const ( InvalidPermission Permission = iota // zero-guard CreatePermission ReadPermission UpdatePermission DeletePermission )
type TypeCheckingError ¶
func (TypeCheckingError) AppendPath ¶
func (e TypeCheckingError) AppendPath(a err.ErrorPathElement, b ...err.ErrorPathElement) err.PathedError
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 ¶
func (TypeInferenceError) AppendPath ¶
func (e TypeInferenceError) AppendPath(a err.ErrorPathElement, b ...err.ErrorPathElement) err.PathedError
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
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) 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) 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 (VirtualMachine) ParseCompileAndExecute ¶
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