value

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2019 License: Apache-2.0 Imports: 14 Imported by: 7

Documentation

Index

Constants

View Source
const (
	TypeCodeInt       uint8 = 0
	TypeCodeCodePoint       = 1
	TypeCodeHashOnly        = 2
	TypeCodeTuple           = 3
)
View Source
const (
	BytesPerInt = 32
)
View Source
const MaxTupleSize = 8

Variables

This section is empty.

Functions

func Bytes32ArrayEncoded

func Bytes32ArrayEncoded(input [][32]byte) []byte

func Eq

func Eq(x, y Value) bool

func IsValidTupleSize

func IsValidTupleSize(size *big.Int) bool

func IsValidTupleSizeI64

func IsValidTupleSizeI64(size int64) bool

func MarshalOperation

func MarshalOperation(op Operation, wr io.Writer) error

func MarshalOperationProof

func MarshalOperationProof(op Operation, wr io.Writer, includeVal bool) error

func MarshalValue

func MarshalValue(v Value, w io.Writer) error

func NewBigIntFromBuf

func NewBigIntFromBuf(buf *BigIntegerBuf) *big.Int

func NewHashFromBuf

func NewHashFromBuf(buf *HashBuf) [32]byte

func TypeCodeName

func TypeCodeName(code uint8) string

Types

type BasicOperation

type BasicOperation struct {
	Op code.Opcode
}

func NewBasicOperationFromReader

func NewBasicOperationFromReader(rd io.Reader) (BasicOperation, error)

func (BasicOperation) GetOp

func (op BasicOperation) GetOp() code.Opcode

func (BasicOperation) Marshal

func (op BasicOperation) Marshal(wr io.Writer) error

func (BasicOperation) MarshalProof

func (op BasicOperation) MarshalProof(wr io.Writer, includeVal bool) error

func (BasicOperation) String

func (op BasicOperation) String() string

func (BasicOperation) TypeCode

func (op BasicOperation) TypeCode() uint8

type BigIntegerBuf

type BigIntegerBuf struct {
	Value                []byte   `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func NewBigIntBuf

func NewBigIntBuf(buf *big.Int) *BigIntegerBuf

func (*BigIntegerBuf) Descriptor

func (*BigIntegerBuf) Descriptor() ([]byte, []int)

func (*BigIntegerBuf) GetValue

func (m *BigIntegerBuf) GetValue() []byte

func (*BigIntegerBuf) ProtoMessage

func (*BigIntegerBuf) ProtoMessage()

func (*BigIntegerBuf) Reset

func (m *BigIntegerBuf) Reset()

func (*BigIntegerBuf) String

func (m *BigIntegerBuf) String() string

func (*BigIntegerBuf) XXX_DiscardUnknown

func (m *BigIntegerBuf) XXX_DiscardUnknown()

func (*BigIntegerBuf) XXX_Marshal

func (m *BigIntegerBuf) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*BigIntegerBuf) XXX_Merge

func (m *BigIntegerBuf) XXX_Merge(src proto.Message)

func (*BigIntegerBuf) XXX_Size

func (m *BigIntegerBuf) XXX_Size() int

func (*BigIntegerBuf) XXX_Unmarshal

func (m *BigIntegerBuf) XXX_Unmarshal(b []byte) error

type CodePointBuf

type CodePointBuf struct {
	Pc                   int64         `protobuf:"varint,1,opt,name=pc,proto3" json:"pc,omitempty"`
	Op                   *OperationBuf `protobuf:"bytes,2,opt,name=op,proto3" json:"op,omitempty"`
	NextHash             *HashBuf      `protobuf:"bytes,3,opt,name=nextHash,proto3" json:"nextHash,omitempty"`
	XXX_NoUnkeyedLiteral struct{}      `json:"-"`
	XXX_unrecognized     []byte        `json:"-"`
	XXX_sizecache        int32         `json:"-"`
}

func NewCodePointBuf

func NewCodePointBuf(val CodePointValue) *CodePointBuf

func (*CodePointBuf) Descriptor

func (*CodePointBuf) Descriptor() ([]byte, []int)

func (*CodePointBuf) GetNextHash

func (m *CodePointBuf) GetNextHash() *HashBuf

func (*CodePointBuf) GetOp

func (m *CodePointBuf) GetOp() *OperationBuf

func (*CodePointBuf) GetPc

func (m *CodePointBuf) GetPc() int64

func (*CodePointBuf) ProtoMessage

func (*CodePointBuf) ProtoMessage()

func (*CodePointBuf) Reset

func (m *CodePointBuf) Reset()

func (*CodePointBuf) String

func (m *CodePointBuf) String() string

func (*CodePointBuf) XXX_DiscardUnknown

func (m *CodePointBuf) XXX_DiscardUnknown()

func (*CodePointBuf) XXX_Marshal

func (m *CodePointBuf) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*CodePointBuf) XXX_Merge

func (m *CodePointBuf) XXX_Merge(src proto.Message)

func (*CodePointBuf) XXX_Size

func (m *CodePointBuf) XXX_Size() int

func (*CodePointBuf) XXX_Unmarshal

func (m *CodePointBuf) XXX_Unmarshal(b []byte) error

type CodePointValue

type CodePointValue struct {
	InsnNum  int64
	Op       Operation
	NextHash [32]byte
}
var ErrorCodePoint CodePointValue

func NewCodePointForProofFromReader

func NewCodePointForProofFromReader(rd io.Reader) (CodePointValue, error)

func NewCodePointFromBuf

func NewCodePointFromBuf(buf *CodePointBuf) (CodePointValue, error)

func NewCodePointValueFromReader

func NewCodePointValueFromReader(rd io.Reader) (CodePointValue, error)

func (CodePointValue) Clone

func (cv CodePointValue) Clone() Value

func (CodePointValue) CloneShallow

func (cv CodePointValue) CloneShallow() Value

func (CodePointValue) Equal

func (cv CodePointValue) Equal(val Value) bool

func (CodePointValue) Hash

func (cv CodePointValue) Hash() [32]byte

func (CodePointValue) InternalTypeCode

func (cv CodePointValue) InternalTypeCode() uint8

func (CodePointValue) Marshal

func (cv CodePointValue) Marshal(w io.Writer) error

func (CodePointValue) MarshalForProof

func (cv CodePointValue) MarshalForProof(w io.Writer) error

func (CodePointValue) Size

func (cv CodePointValue) Size() int64

func (CodePointValue) String

func (cv CodePointValue) String() string

func (CodePointValue) TypeCode

func (cv CodePointValue) TypeCode() uint8

type HashBuf

type HashBuf struct {
	Value                []byte   `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func NewHashBuf

func NewHashBuf(h [32]byte) *HashBuf

func (*HashBuf) Descriptor

func (*HashBuf) Descriptor() ([]byte, []int)

func (*HashBuf) GetValue

func (m *HashBuf) GetValue() []byte

func (*HashBuf) ProtoMessage

func (*HashBuf) ProtoMessage()

func (*HashBuf) Reset

func (m *HashBuf) Reset()

func (*HashBuf) String

func (m *HashBuf) String() string

func (*HashBuf) XXX_DiscardUnknown

func (m *HashBuf) XXX_DiscardUnknown()

func (*HashBuf) XXX_Marshal

func (m *HashBuf) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*HashBuf) XXX_Merge

func (m *HashBuf) XXX_Merge(src proto.Message)

func (*HashBuf) XXX_Size

func (m *HashBuf) XXX_Size() int

func (*HashBuf) XXX_Unmarshal

func (m *HashBuf) XXX_Unmarshal(b []byte) error

type HashOnlyValue

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

func NewHashOnlyValue

func NewHashOnlyValue(hash [32]byte, size int64) HashOnlyValue

func NewHashOnlyValueFromReader

func NewHashOnlyValueFromReader(rd io.Reader) (HashOnlyValue, error)

func NewHashOnlyValueFromValue

func NewHashOnlyValueFromValue(val Value) HashOnlyValue

func (HashOnlyValue) Clone

func (nv HashOnlyValue) Clone() Value

func (HashOnlyValue) CloneShallow

func (nv HashOnlyValue) CloneShallow() Value

func (HashOnlyValue) Equal

func (nv HashOnlyValue) Equal(val Value) bool

func (HashOnlyValue) Hash

func (nv HashOnlyValue) Hash() [32]byte

func (HashOnlyValue) InternalTypeCode

func (nv HashOnlyValue) InternalTypeCode() byte

func (HashOnlyValue) Marshal

func (nv HashOnlyValue) Marshal(wr io.Writer) error

func (HashOnlyValue) Size

func (nv HashOnlyValue) Size() int64

func (HashOnlyValue) String

func (nv HashOnlyValue) String() string

func (HashOnlyValue) TypeCode

func (nv HashOnlyValue) TypeCode() byte

type ImmediateOperation

type ImmediateOperation struct {
	Op  code.Opcode
	Val Value
}

func NewImmediateOperationFromReader

func NewImmediateOperationFromReader(rd io.Reader) (ImmediateOperation, error)

func (ImmediateOperation) GetOp

func (op ImmediateOperation) GetOp() code.Opcode

func (ImmediateOperation) Marshal

func (op ImmediateOperation) Marshal(wr io.Writer) error

func (ImmediateOperation) MarshalProof

func (op ImmediateOperation) MarshalProof(wr io.Writer, includeVal bool) error

func (ImmediateOperation) String

func (op ImmediateOperation) String() string

func (ImmediateOperation) TypeCode

func (op ImmediateOperation) TypeCode() uint8

type IntValue

type IntValue struct {
	// contains filtered or unexported fields
}
var IntegerZero IntValue

func NewBooleanValue

func NewBooleanValue(val bool) IntValue

func NewInt64Value

func NewInt64Value(x int64) IntValue

func NewIntValue

func NewIntValue(x *big.Int) IntValue

func NewIntValueFromReader

func NewIntValueFromReader(rd io.Reader) (IntValue, error)

func (IntValue) BigInt

func (iv IntValue) BigInt() *big.Int

func (IntValue) Clone

func (iv IntValue) Clone() Value

func (IntValue) CloneShallow

func (iv IntValue) CloneShallow() Value

func (IntValue) Equal

func (iv IntValue) Equal(val Value) bool

func (IntValue) Hash

func (iv IntValue) Hash() [32]byte

func (IntValue) InternalTypeCode

func (iv IntValue) InternalTypeCode() uint8

func (IntValue) Marshal

func (iv IntValue) Marshal(w io.Writer) error

func (IntValue) Size

func (iv IntValue) Size() int64

func (IntValue) String

func (iv IntValue) String() string

func (IntValue) ToBytes

func (iv IntValue) ToBytes() [32]byte

func (IntValue) TypeCode

func (iv IntValue) TypeCode() uint8

type Operation

type Operation interface {
	GetOp() code.Opcode
	TypeCode() uint8
	Marshal(wr io.Writer) error
	MarshalProof(wr io.Writer, includeVal bool) error
}

func NewOperationFromBuf

func NewOperationFromBuf(buf *OperationBuf) (Operation, error)

func NewOperationFromReader

func NewOperationFromReader(rd io.Reader) (Operation, error)

type OperationBuf

type OperationBuf struct {
	OpCode               uint32    `protobuf:"varint,1,opt,name=opCode,proto3" json:"opCode,omitempty"`
	Immediate            *ValueBuf `protobuf:"bytes,2,opt,name=immediate,proto3" json:"immediate,omitempty"`
	XXX_NoUnkeyedLiteral struct{}  `json:"-"`
	XXX_unrecognized     []byte    `json:"-"`
	XXX_sizecache        int32     `json:"-"`
}

func NewOperationBuf

func NewOperationBuf(op Operation) *OperationBuf

func (*OperationBuf) Descriptor

func (*OperationBuf) Descriptor() ([]byte, []int)

func (*OperationBuf) GetImmediate

func (m *OperationBuf) GetImmediate() *ValueBuf

func (*OperationBuf) GetOpCode

func (m *OperationBuf) GetOpCode() uint32

func (*OperationBuf) ProtoMessage

func (*OperationBuf) ProtoMessage()

func (*OperationBuf) Reset

func (m *OperationBuf) Reset()

func (*OperationBuf) String

func (m *OperationBuf) String() string

func (*OperationBuf) XXX_DiscardUnknown

func (m *OperationBuf) XXX_DiscardUnknown()

func (*OperationBuf) XXX_Marshal

func (m *OperationBuf) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*OperationBuf) XXX_Merge

func (m *OperationBuf) XXX_Merge(src proto.Message)

func (*OperationBuf) XXX_Size

func (m *OperationBuf) XXX_Size() int

func (*OperationBuf) XXX_Unmarshal

func (m *OperationBuf) XXX_Unmarshal(b []byte) error

type TupleBuf

type TupleBuf struct {
	Values               []*ValueBuf `protobuf:"bytes,1,rep,name=values,proto3" json:"values,omitempty"`
	XXX_NoUnkeyedLiteral struct{}    `json:"-"`
	XXX_unrecognized     []byte      `json:"-"`
	XXX_sizecache        int32       `json:"-"`
}

func NewTupleBuf

func NewTupleBuf(val TupleValue) *TupleBuf

func (*TupleBuf) Descriptor

func (*TupleBuf) Descriptor() ([]byte, []int)

func (*TupleBuf) GetValues

func (m *TupleBuf) GetValues() []*ValueBuf

func (*TupleBuf) ProtoMessage

func (*TupleBuf) ProtoMessage()

func (*TupleBuf) Reset

func (m *TupleBuf) Reset()

func (*TupleBuf) String

func (m *TupleBuf) String() string

func (*TupleBuf) XXX_DiscardUnknown

func (m *TupleBuf) XXX_DiscardUnknown()

func (*TupleBuf) XXX_Marshal

func (m *TupleBuf) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*TupleBuf) XXX_Merge

func (m *TupleBuf) XXX_Merge(src proto.Message)

func (*TupleBuf) XXX_Size

func (m *TupleBuf) XXX_Size() int

func (*TupleBuf) XXX_Unmarshal

func (m *TupleBuf) XXX_Unmarshal(b []byte) error

type TupleValue

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

func NewEmptyTuple

func NewEmptyTuple() TupleValue

func NewRepeatedTuple

func NewRepeatedTuple(value Value, size int64) (TupleValue, error)

func NewSizedTupleFromReader

func NewSizedTupleFromReader(rd io.Reader, size byte) (TupleValue, error)

func NewTuple2

func NewTuple2(value1 Value, value2 Value) TupleValue

func NewTupleFromBuf

func NewTupleFromBuf(buf *TupleBuf) (TupleValue, error)

func NewTupleFromSlice

func NewTupleFromSlice(slice []Value) (TupleValue, error)

func NewTupleOfSizeWithContents

func NewTupleOfSizeWithContents(contents [MaxTupleSize]Value, size int8) (TupleValue, error)

func (TupleValue) Clone

func (tv TupleValue) Clone() Value

func (TupleValue) CloneShallow

func (tv TupleValue) CloneShallow() Value

func (TupleValue) Contents

func (tv TupleValue) Contents() []Value

func (TupleValue) Equal

func (tv TupleValue) Equal(val Value) bool

func (TupleValue) Get

func (tv TupleValue) Get(idx IntValue) (Value, error)

func (TupleValue) GetByInt64

func (tv TupleValue) GetByInt64(idx int64) (Value, error)

func (TupleValue) Hash

func (tv TupleValue) Hash() [32]byte

func (TupleValue) InternalTypeCode

func (tv TupleValue) InternalTypeCode() uint8

func (TupleValue) IsValidIndex

func (tv TupleValue) IsValidIndex(idx IntValue) bool

func (TupleValue) Len

func (tv TupleValue) Len() int64

func (TupleValue) Marshal

func (tv TupleValue) Marshal(wr io.Writer) error

func (TupleValue) Set

func (tv TupleValue) Set(idx IntValue, val Value) (TupleValue, error)

func (TupleValue) SetByInt64

func (tv TupleValue) SetByInt64(idx int64, val Value) (TupleValue, error)

func (TupleValue) Size

func (tv TupleValue) Size() int64

func (TupleValue) String

func (tv TupleValue) String() string

func (TupleValue) TypeCode

func (tv TupleValue) TypeCode() uint8

type UnmarshalError

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

func (UnmarshalError) Error

func (e UnmarshalError) Error() string

type Value

type Value interface {
	TypeCode() uint8
	InternalTypeCode() uint8
	Clone() Value
	CloneShallow() Value
	Equal(Value) bool
	Hash() [32]byte
	Size() int64
	Marshal(io.Writer) error
}

func NewIntValueFromString

func NewIntValueFromString(str string) Value

func NewValueFromBuf

func NewValueFromBuf(buf *ValueBuf) (Value, error)

func UnmarshalValue

func UnmarshalValue(r io.Reader) (Value, error)

func UnmarshalValueWithType

func UnmarshalValueWithType(tipe byte, r io.Reader) (Value, error)

type ValueBuf

type ValueBuf struct {
	Type uint32 `protobuf:"varint,1,opt,name=type,proto3" json:"type,omitempty"`
	// Types that are valid to be assigned to Value:
	//	*ValueBuf_IntVal
	//	*ValueBuf_TupleVal
	//	*ValueBuf_CodePointVal
	Value                isValueBuf_Value `protobuf_oneof:"value"`
	XXX_NoUnkeyedLiteral struct{}         `json:"-"`
	XXX_unrecognized     []byte           `json:"-"`
	XXX_sizecache        int32            `json:"-"`
}

func NewValueBuf

func NewValueBuf(val Value) *ValueBuf

func (*ValueBuf) Descriptor

func (*ValueBuf) Descriptor() ([]byte, []int)

func (*ValueBuf) GetCodePointVal

func (m *ValueBuf) GetCodePointVal() *CodePointBuf

func (*ValueBuf) GetIntVal

func (m *ValueBuf) GetIntVal() *BigIntegerBuf

func (*ValueBuf) GetTupleVal

func (m *ValueBuf) GetTupleVal() *TupleBuf

func (*ValueBuf) GetType

func (m *ValueBuf) GetType() uint32

func (*ValueBuf) GetValue

func (m *ValueBuf) GetValue() isValueBuf_Value

func (*ValueBuf) ProtoMessage

func (*ValueBuf) ProtoMessage()

func (*ValueBuf) Reset

func (m *ValueBuf) Reset()

func (*ValueBuf) String

func (m *ValueBuf) String() string

func (*ValueBuf) XXX_DiscardUnknown

func (m *ValueBuf) XXX_DiscardUnknown()

func (*ValueBuf) XXX_Marshal

func (m *ValueBuf) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ValueBuf) XXX_Merge

func (m *ValueBuf) XXX_Merge(src proto.Message)

func (*ValueBuf) XXX_OneofWrappers

func (*ValueBuf) XXX_OneofWrappers() []interface{}

XXX_OneofWrappers is for the internal use of the proto package.

func (*ValueBuf) XXX_Size

func (m *ValueBuf) XXX_Size() int

func (*ValueBuf) XXX_Unmarshal

func (m *ValueBuf) XXX_Unmarshal(b []byte) error

type ValueBuf_CodePointVal

type ValueBuf_CodePointVal struct {
	CodePointVal *CodePointBuf `protobuf:"bytes,4,opt,name=codePointVal,proto3,oneof"`
}

type ValueBuf_IntVal

type ValueBuf_IntVal struct {
	IntVal *BigIntegerBuf `protobuf:"bytes,2,opt,name=intVal,proto3,oneof"`
}

type ValueBuf_TupleVal

type ValueBuf_TupleVal struct {
	TupleVal *TupleBuf `protobuf:"bytes,3,opt,name=tupleVal,proto3,oneof"`
}

Jump to

Keyboard shortcuts

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