objects

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package objects coordinates lower level memory and typeset models with Go objects.

Builder

The Builder is responsible for implementing the majority of this coordination. It has a few different sets of methods.

The first set supports a way to configure the parameters for the lower level memory representation. These methods set and return the modified builder. They are

  1. Builder.Pos(go/token.Pos)
  2. Builder.Type(go/types.Type)
  3. Builder.Attrs(pal/memory.Attrs)
  4. Builder.Class(pal/memory.Class)

Making a memory location containing objects of type `T` representing code at pos `pos` with attributes `memory.IsOpaque` could for example be done like this:

b.Type(T).Pos(pos).Attrs(memory.IsOpaque).Gen()

The second set of methods relates to creating locations, objects and constraints. These are

  1. Builder.Gen() generate a memory location.
  2. Builder.Add{Load,Store,Transfer,PointsTo}(dst, src)
  3. Builder.{Struct,Array,Slice,Map,Func,Interface,Chan}

The last set of methods gives access to the build results

  1. Builder.Memory() *memory.Model
  2. Builder.TypeSet() *typeset.TypeSet
  3. Builder.Object(m memory.Loc) Object (one of Struct,Array,Slice,Map,...)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Array

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

func (*Array) At added in v0.0.3

func (a *Array) At(i int) memory.Loc

func (*Array) Len added in v0.0.2

func (a *Array) Len() int64

func (*Array) Loc

func (o *Array) Loc() memory.Loc

func (*Array) PlainDecode

func (a *Array) PlainDecode(r io.Reader) error

func (*Array) PlainEncode

func (a *Array) PlainEncode(w io.Writer) error

func (*Array) Type added in v0.0.2

func (o *Array) Type() typeset.Type

type Builder added in v0.0.2

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

Builder is a type which supports coordinating higher level Go objects (funcs, slices, maps, ...) with the lower level memory model and typeset.

func NewBuilder added in v0.0.2

func NewBuilder(pkgPath string, ind indexing.T) *Builder

NewBuilder creates a new builder from a package Path and an indexing.T which manages representing indexing expressiosn.

func (*Builder) AddAddressOf added in v0.0.4

func (b *Builder) AddAddressOf(ptr, obj memory.Loc)

func (*Builder) AddLoad added in v0.0.3

func (b *Builder) AddLoad(dst, src memory.Loc)

func (*Builder) AddSlot added in v0.0.3

func (b *Builder) AddSlot(slice *Slice, i indexing.I)

func (*Builder) AddStore added in v0.0.3

func (b *Builder) AddStore(dst, src memory.Loc)

func (*Builder) AddTransfer added in v0.0.3

func (b *Builder) AddTransfer(dst, src memory.Loc)

func (*Builder) AddTransferIndex added in v0.0.3

func (b *Builder) AddTransferIndex(dst, src memory.Loc, i indexing.I)

func (*Builder) Array added in v0.0.3

func (b *Builder) Array(gty *types.Array) *Array

func (*Builder) Attrs added in v0.0.2

func (b *Builder) Attrs(as memory.Attrs) *Builder

func (*Builder) Chan added in v0.0.6

func (b *Builder) Chan(gty *types.Chan) *Chan

func (*Builder) Class added in v0.0.2

func (b *Builder) Class(c memory.Class) *Builder

func (*Builder) Func added in v0.0.3

func (b *Builder) Func(sig *types.Signature, declName string, opaque memory.Attrs) *Func

Func makes a function object. It is for top level functions which may or may not be declared. `declName` must be empty iff the associated function is not declared.

func (*Builder) Gen added in v0.0.3

func (b *Builder) Gen() memory.Loc

func (*Builder) GoType added in v0.0.2

func (b *Builder) GoType(ty types.Type) *Builder

func (*Builder) Map added in v0.0.3

func (b *Builder) Map(gty *types.Map) *Map

func (*Builder) Memory added in v0.0.3

func (b *Builder) Memory() *memory.Model

func (*Builder) Object added in v0.0.3

func (b *Builder) Object(m memory.Loc) Object

func (*Builder) Pointer added in v0.0.3

func (b *Builder) Pointer(gtype *types.Pointer) *Pointer

func (*Builder) Pos added in v0.0.2

func (b *Builder) Pos(pos token.Pos) *Builder

func (*Builder) Slice added in v0.0.3

func (b *Builder) Slice(gty *types.Slice, length, capacity indexing.I) *Slice

func (*Builder) Struct added in v0.0.3

func (b *Builder) Struct(gty *types.Struct) *Struct

func (*Builder) Tuple added in v0.0.4

func (b *Builder) Tuple(ty *types.Tuple) *Tuple

func (*Builder) Type added in v0.0.2

func (b *Builder) Type(ty typeset.Type) *Builder

func (*Builder) TypeSet added in v0.0.3

func (b *Builder) TypeSet() *typeset.TypeSet

func (*Builder) WithPointer added in v0.0.3

func (b *Builder) WithPointer() (obj, ptr memory.Loc)

type Chan

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

Chan object

c.loc represents pointer c.slot represents things sent to and received from the channel.

func (*Chan) Loc

func (o *Chan) Loc() memory.Loc

func (*Chan) PlainDecode added in v0.0.3

func (c *Chan) PlainDecode(r io.Reader) error

func (*Chan) PlainEncode added in v0.0.3

func (c *Chan) PlainEncode(w io.Writer) error

func (*Chan) Recv added in v0.0.6

func (c *Chan) Recv(dst memory.Loc, mm *memory.Model)

Recv retrieves the data from the c and loads it into dst.

func (*Chan) Send added in v0.0.6

func (c *Chan) Send(src memory.Loc, mm *memory.Model)

Send sends the data at src to the channel c.

Send is modeled as a store.

func (*Chan) Type added in v0.0.2

func (o *Chan) Type() typeset.Type

type Func

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

func (*Func) Declared

func (f *Func) Declared() bool

func (*Func) Loc

func (f *Func) Loc() memory.Loc

func (*Func) Name

func (f *Func) Name() string

func (*Func) NumParams added in v0.0.5

func (f *Func) NumParams() int

func (*Func) NumResults added in v0.0.5

func (f *Func) NumResults() int

func (*Func) ParamLoc

func (f *Func) ParamLoc(i int) memory.Loc

func (*Func) PlainDecode added in v0.0.3

func (f *Func) PlainDecode(r io.Reader) error

func (*Func) PlainEncode added in v0.0.3

func (f *Func) PlainEncode(w io.Writer) error

func (*Func) RecvLoc

func (f *Func) RecvLoc(i int) memory.Loc

func (*Func) ResultLoc

func (f *Func) ResultLoc(i int) memory.Loc

func (*Func) Type added in v0.0.2

func (o *Func) Type() typeset.Type

type Interface

type Interface struct {
	Concrete memory.Loc
	// contains filtered or unexported fields
}

func (*Interface) Loc

func (o *Interface) Loc() memory.Loc

func (*Interface) PlainDecode added in v0.0.3

func (i *Interface) PlainDecode(r io.Reader) error

func (*Interface) PlainEncode added in v0.0.3

func (i *Interface) PlainEncode(w io.Writer) error

func (*Interface) Type added in v0.0.2

func (o *Interface) Type() typeset.Type

type Map

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

func (*Map) Elem

func (m *Map) Elem() memory.Loc

func (*Map) Key

func (m *Map) Key() memory.Loc

func (*Map) Loc

func (o *Map) Loc() memory.Loc

func (*Map) Lookup added in v0.0.6

func (m *Map) Lookup(dst memory.Loc, mm *memory.Model)

func (*Map) PlainDecode added in v0.0.3

func (m *Map) PlainDecode(r io.Reader) error

func (*Map) PlainEncode added in v0.0.3

func (m *Map) PlainEncode(w io.Writer) error

func (*Map) Type added in v0.0.2

func (o *Map) Type() typeset.Type

func (*Map) Update added in v0.0.6

func (m *Map) Update(k, v memory.Loc, mm *memory.Model)

type Object

type Object interface {
	plain.Coder
	Loc() memory.Loc
	Type() typeset.Type
}

type Pointer added in v0.0.2

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

func (*Pointer) Loc added in v0.0.2

func (o *Pointer) Loc() memory.Loc

func (*Pointer) PlainDecode added in v0.0.3

func (p *Pointer) PlainDecode(r io.Reader) error

func (*Pointer) PlainEncode added in v0.0.3

func (p *Pointer) PlainEncode(w io.Writer) error

func (*Pointer) Type added in v0.0.2

func (o *Pointer) Type() typeset.Type

type Slice

type Slice struct {
	Len indexing.I
	Cap indexing.I
	// contains filtered or unexported fields
}

Slices are modelled as follows.

Each slice `s` has a principal pointer `ptr(s)` stored in object.loc, and a Len and a Cap which are of type indexing.I, and a single memory.Loc "elem" representing what is stored in the slice.

Each slice has 0 or more slots. A slot is a triple (p, m, i) such that

  1. p = &m
  2. p = ptr(s) + i

For the moment, we set ptr(s) == &nil to guarantee that nil derefs are considered possible. When indexing gets richer, perhaps we can do more.

func (*Slice) Loc

func (o *Slice) Loc() memory.Loc

func (*Slice) NumSlots added in v0.0.3

func (slice *Slice) NumSlots() int

func (*Slice) PlainDecode added in v0.0.3

func (slice *Slice) PlainDecode(r io.Reader) error

func (*Slice) PlainEncode added in v0.0.3

func (slice *Slice) PlainEncode(w io.Writer) error

func (*Slice) Ptr added in v0.0.8

func (slice *Slice) Ptr() memory.Loc

func (*Slice) Slot added in v0.0.3

func (slice *Slice) Slot(i int) Slot

func (*Slice) Type added in v0.0.2

func (o *Slice) Type() typeset.Type

type Slot

type Slot struct {
	I   indexing.I
	Ptr memory.Loc
	Obj memory.Loc
}

func (*Slot) PlainDecode added in v0.0.3

func (slot *Slot) PlainDecode(r io.Reader) error

func (*Slot) PlainEncode added in v0.0.3

func (slot *Slot) PlainEncode(w io.Writer) error

type Struct

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

func (*Struct) Field added in v0.0.3

func (s *Struct) Field(i int) memory.Loc

func (*Struct) Loc

func (o *Struct) Loc() memory.Loc

func (*Struct) NumFields added in v0.0.3

func (s *Struct) NumFields(i int) int

func (*Struct) PlainDecode added in v0.0.3

func (s *Struct) PlainDecode(r io.Reader) error

func (*Struct) PlainEncode added in v0.0.3

func (s *Struct) PlainEncode(w io.Writer) error

func (*Struct) Type added in v0.0.2

func (o *Struct) Type() typeset.Type

type Tuple added in v0.0.4

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

func (*Tuple) At added in v0.0.5

func (t *Tuple) At(i int) memory.Loc

func (*Tuple) Loc added in v0.0.4

func (o *Tuple) Loc() memory.Loc

func (*Tuple) NumFields added in v0.0.4

func (t *Tuple) NumFields(i int) int

func (*Tuple) PlainDecode added in v0.0.4

func (tuple *Tuple) PlainDecode(r io.Reader) error

func (*Tuple) PlainEncode added in v0.0.4

func (tuple *Tuple) PlainEncode(w io.Writer) error

func (*Tuple) Type added in v0.0.4

func (o *Tuple) Type() typeset.Type

Jump to

Keyboard shortcuts

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