Documentation ¶
Index ¶
- Constants
- Variables
- func DeserializeMapPattern(ctx *core.Context, it *jsoniter.Iterator, pattern core.Pattern, try bool) (_ core.Pattern, finalErr error)
- type Map
- func (m *Map) Contains(ctx *core.Context, value core.Serializable) bool
- func (m *Map) Equal(ctx *core.Context, other core.Value, alreadyCompared map[uintptr]uintptr, ...) bool
- func (m *Map) Get(ctx *core.Context, keyVal core.Serializable) (core.Value, core.Bool)
- func (m *Map) GetElementByKey(ctx *core.Context, pathKey core.ElementKey) (core.Serializable, error)
- func (m *Map) GetGoMethod(name string) (*core.GoFunction, bool)
- func (m *Map) Has(ctx *core.Context, keyVal core.Serializable) core.Bool
- func (m *Map) Insert(ctx *core.Context, key, value core.Serializable) error
- func (m *Map) IsEmpty(ctx *core.Context) bool
- func (m *Map) IsMutable() bool
- func (m *Map) IsSharable(originState *core.GlobalState) (bool, string)
- func (m *Map) IsShared() bool
- func (s *Map) Iterator(ctx *core.Context, config core.IteratorConfiguration) core.Iterator
- func (m *Map) Migrate(ctx *core.Context, key core.Path, migration *core.FreeEntityMigrationArgs) (core.Value, error)
- func (m *Map) PrettyPrint(w *bufio.Writer, config *core.PrettyPrintConfig, depth int, ...)
- func (m *Map) Prop(ctx *core.Context, name string) core.Value
- func (*Map) PropertyNames(ctx *core.Context) []string
- func (m *Map) Remove(ctx *core.Context, key core.Serializable)
- func (m *Map) Set(ctx *core.Context, key, value core.Serializable)
- func (*Map) SetProp(ctx *core.Context, name string, value core.Value) error
- func (m *Map) SetURLOnce(ctx *core.Context, url core.URL) error
- func (m *Map) Share(originState *core.GlobalState)
- func (m *Map) SmartLock(state *core.GlobalState)
- func (m *Map) SmartUnlock(state *core.GlobalState)
- func (m *Map) ToSymbolicValue(ctx *core.Context, encountered map[uintptr]symbolic.Value) (symbolic.Value, error)
- func (m *Map) URL() (core.URL, bool)
- func (m *Map) WriteJSONRepresentation(ctx *core.Context, w *jsoniter.Stream, config core.JSONSerializationConfig, ...) error
- type MapConfig
- type MapPattern
- func (p *MapPattern) DefaultValue(ctx *core.Context) (core.Value, error)
- func (p *MapPattern) Equal(ctx *core.Context, other core.Value, alreadyCompared map[uintptr]uintptr, ...) bool
- func (p *MapPattern) GetMigrationOperations(ctx *core.Context, next core.Pattern, pseudoPath string) ([]core.MigrationOp, error)
- func (p *MapPattern) IsMutable() bool
- func (p *MapPattern) Iterator(ctx *core.Context, config core.IteratorConfiguration) core.Iterator
- func (p *MapPattern) PrettyPrint(w *bufio.Writer, config *core.PrettyPrintConfig, depth int, ...)
- func (p *MapPattern) Random(ctx *core.Context, options ...core.Option) core.Value
- func (p *MapPattern) StringPattern() (core.StringPattern, bool)
- func (patt *MapPattern) Test(ctx *core.Context, v core.Value) bool
- func (p *MapPattern) ToSymbolicValue(ctx *core.Context, encountered map[uintptr]symbolic.Value) (symbolic.Value, error)
- func (p *MapPattern) WriteJSONRepresentation(ctx *core.Context, w *jsoniter.Stream, config core.JSONSerializationConfig, ...) error
Constants ¶
View Source
const ( SERIALIZED_MAP_PATTERN_KEY_KEY = "key" SERIALIZED_MAP_PATTERN_VAL_KEY = "value" )
View Source
const (
INITIAL_MAP_KEY_BUF = 2000
)
Variables ¶
View Source
var ( ErrMapEntryListShouldHaveEvenLength = errors.New(`flat map entry list should have an even length: ["k1", 1, "k2", 2]`) ErrMapCanOnlyContainKeysWithFastId = errors.New("a Map can only contain keys having a fast id") ErrSetCanOnlyContainRepresentableValues = errors.New("a Map can only contain representable values") ErrKeysShouldBeImmutable = errors.New("keys should be immutable") ErrKeyDoesMatchKeyPattern = errors.New("provided key does not match the key pattern") ErrValueDoesMatchValuePattern = errors.New("provided value does not match the value pattern") ErrEntryAlreadyExists = errors.New("entry already exists") ErrValueWithSameKeyAlreadyPresent = errors.New("provided value has the same key as an already present element") )
View Source
var ( MAP_PATTERN = &core.TypePattern{ Name: "Map", Type: reflect.TypeOf((*Map)(nil)), SymbolicValue: coll_symbolic.ANY_MAP, CallImpl: func(typePattern *core.TypePattern, values []core.Serializable) (core.Pattern, error) { switch len(values) { case 0: return nil, commonfmt.FmtMissingArgument("key pattern and value pattern") case 1: return nil, commonfmt.FmtMissingArgument("value pattern") } keyPattern, ok := values[0].(core.Pattern) if !ok { return nil, core.FmtErrInvalidArgumentAtPos(keyPattern, 0) } valuePattern, ok := values[1].(core.Pattern) if !ok { return nil, core.FmtErrInvalidArgumentAtPos(keyPattern, 1) } return NewMapPattern(MapConfig{ Key: keyPattern, Value: valuePattern, }), nil }, SymbolicCallImpl: func(ctx *symbolic.Context, values []symbolic.Value) (symbolic.Pattern, error) { switch len(values) { case 0: return nil, commonfmt.FmtMissingArgument("key pattern and value pattern") case 1: return nil, commonfmt.FmtMissingArgument("value pattern") } keyPattern, ok := values[0].(symbolic.Pattern) key := symbolic.AsSerializable(keyPattern.SymbolicValue()) if !ok || !utils.Implements[symbolic.Serializable](key) { return nil, commonfmt.FmtErrInvalidArgumentAtPos(1, "key pattern should not match values that are not serializable") } if key.IsMutable() { return nil, commonfmt.FmtErrInvalidArgumentAtPos(1, "key pattern should not match values that are not mutable") } valuePattern, ok := values[1].(symbolic.Pattern) if !ok || !utils.Implements[symbolic.Serializable](symbolic.AsSerializable(valuePattern.SymbolicValue())) { return nil, commonfmt.FmtErrInvalidArgumentAtPos(1, "value pattern cannot match values that are not serializable") } return coll_symbolic.NewMapPattern(keyPattern, valuePattern), nil }, } MAP_PATTERN_PATTERN = &core.TypePattern{ Name: "map-pattern", Type: reflect.TypeOf((*MapPattern)(nil)), SymbolicValue: coll_symbolic.ANY_MAP_PATTERN, } )
Functions ¶
Types ¶
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
func NewMapWithConfig ¶
func (*Map) GetElementByKey ¶
func (m *Map) GetElementByKey(ctx *core.Context, pathKey core.ElementKey) (core.Serializable, error)
func (*Map) GetGoMethod ¶
func (m *Map) GetGoMethod(name string) (*core.GoFunction, bool)
func (*Map) IsSharable ¶
func (m *Map) IsSharable(originState *core.GlobalState) (bool, string)
func (*Map) PrettyPrint ¶
func (*Map) Share ¶
func (m *Map) Share(originState *core.GlobalState)
func (*Map) SmartLock ¶
func (m *Map) SmartLock(state *core.GlobalState)
func (*Map) SmartUnlock ¶
func (m *Map) SmartUnlock(state *core.GlobalState)
func (*Map) ToSymbolicValue ¶
type MapPattern ¶
type MapPattern struct { core.NotCallablePatternMixin // contains filtered or unexported fields }
func NewMapPattern ¶
func NewMapPattern(config MapConfig) *MapPattern
func (*MapPattern) DefaultValue ¶
func (*MapPattern) GetMigrationOperations ¶
func (p *MapPattern) GetMigrationOperations(ctx *core.Context, next core.Pattern, pseudoPath string) ([]core.MigrationOp, error)
func (*MapPattern) IsMutable ¶
func (p *MapPattern) IsMutable() bool
func (*MapPattern) Iterator ¶
func (p *MapPattern) Iterator(ctx *core.Context, config core.IteratorConfiguration) core.Iterator
func (*MapPattern) PrettyPrint ¶
func (p *MapPattern) PrettyPrint(w *bufio.Writer, config *core.PrettyPrintConfig, depth int, parentIndentCount int)
func (*MapPattern) StringPattern ¶
func (p *MapPattern) StringPattern() (core.StringPattern, bool)
func (*MapPattern) ToSymbolicValue ¶
func (*MapPattern) WriteJSONRepresentation ¶
func (p *MapPattern) WriteJSONRepresentation(ctx *core.Context, w *jsoniter.Stream, config core.JSONSerializationConfig, depth int) error
Click to show internal directories.
Click to hide internal directories.