Documentation ¶
Overview ¶
Package store provides interfaces for a key-value store. Keys are nameable objects, and Values have a unique representation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Const ¶
Const is a known constant.
It's used to track unique symbols of the same constant value.
type IDClashError ¶
type IDClashError struct {
ID Value
}
IDClashError is the error returned if the unique ID of two objects clash.
func (IDClashError) Error ¶
func (e IDClashError) Error() string
type Key ¶
type Key interface { Name() string // (Short) name of key. Pos() token.Pos // Position in program. String() string // Description of key. Type() types.Type // Underlying datatype. }
Key is a nameable key for lookup in storage.
Key represents a variable where its name is unique in the scope. Key may be synthetic, in such case, the position should be set to NoPos to indicate that the Key does not originate from the program.
The string description of the key and the Position is primarily for debugging and locating source of the key. The underlying datatype is needed for compositional datatypes (struct, chan, map, etc.).
type MockKey ¶
type MockKey struct { Typ types.Type SrcPos token.Pos Description string // Description of the key, start with a verb to get a descriptive Name() }
A MockKey is a placeholder for a Key. MockKey requires a type to be specified. A MockKey is a wrapper, and should not be modified after creation, so all methods takes a value receiver.
type MockValue ¶
A MockValue is a placeholder for a Value.
This could mean the value comes from external (C), or is not instantiated in main body of program.
type ObjUndefError ¶
type ObjUndefError struct {
// contains filtered or unexported fields
}
ObjUndefError is the error returned if accessing a non-existent object.
func (ObjUndefError) Error ¶
func (e ObjUndefError) Error() string
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool is key-value store of ssa.Value to store instances.
Pool key has no particular significance, except that it has to be unique within the Pool. Always use AddValue() to add ssa.Value in the Pool, or use AddWrapped() to add a pre-wrapped ssa.Value in the Pool. A new unique key is generated for each call (multiple of the same value is allowed as long as they are added by different NewValue calls).
func (*Pool) AddWrapped ¶
func (p *Pool) AddWrapped(v ValueWrapper) error
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a two-layer key-value storage for ssa.Value.
Effectively the storage is a map[Key]map[Value]ssa.Value, but the second layer is designed to be efficient for name substitution.
func (*Store) Get ¶
Get retrieves the Value in storage give Key k, if k is not found returns a MockValue.
func (*Store) PutObj ¶
PutObj puts a new, fresh ssa.Value v to storage with key k. The new value can be referenced by a centrally generated unqiue ID.
type Unused ¶
type Unused struct {
MockKey
}
Unused is an annotated MockKey indicating the Key (local variable) is unused.
type Value ¶
type Value interface {
UniqName() string
}
A Value represents the (symbolic) value in a storage.
The value could be any symbolic/concrete representation of a variable instance, but is required to be unique so difference instances can be distinguished.
type ValueWrapper ¶
ValueWrapper is a Value that wraps an ssa.Value. It can be used as both key and value of the pool for convenience.