types

package
v0.0.0-...-8a4e258 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const ByteBits = 8

ByteBits defines the byte size in bits.

Variables

View Source
var Bool = Info{
	Type:       TBool,
	IsConcrete: true,
	Bits:       1,
	MinBits:    1,
}

Bool defines type info for boolean values.

View Source
var Byte = Info{
	Type:       TUint,
	IsConcrete: true,
	Bits:       8,
	MinBits:    8,
}

Byte defines type info for byte values.

View Source
var Int32 = Info{
	Type:       TInt,
	IsConcrete: true,
	Bits:       32,
	MinBits:    32,
}

Int32 defines type info for signed 32bit integers.

View Source
var Nil = Info{
	Type:       TNil,
	IsConcrete: true,
}

Nil defines type info for the nil value.

View Source
var Rune = Info{
	Type:       TInt,
	IsConcrete: true,
	Bits:       32,
	MinBits:    32,
}

Rune defines type info for rune values.

View Source
var Types = map[string]Type{
	"<Undefined>": TUndefined,
	"bool":        TBool,
	"int":         TInt,
	"uint":        TUint,
	"float":       TFloat,
	"string":      TString,
	"struct":      TStruct,
	"array":       TArray,
	"slice":       TSlice,
	"ptr":         TPtr,
	"nil":         TNil,
}

Types define MPCL types and their names.

View Source
var Uint32 = Info{
	Type:       TUint,
	IsConcrete: true,
	Bits:       32,
	MinBits:    32,
}

Uint32 defines type info for unsigned 32bit integers.

View Source
var Uint64 = Info{
	Type:       TUint,
	IsConcrete: true,
	Bits:       64,
	MinBits:    64,
}

Uint64 defines type info for unsigned 64bit integers.

View Source
var Undefined = Info{
	Type:       TUndefined,
	IsConcrete: true,
}

Undefined defines type info for undefined types.

Functions

This section is empty.

Types

type ID

type ID int32

ID specifies an unique ID for named types.

type Info

type Info struct {
	ID          ID
	Type        Type
	IsConcrete  bool
	Bits        Size
	MinBits     Size
	Struct      []StructField
	ElementType *Info
	ArraySize   Size
	Offset      Size
}

Info specifies information about a type.

func Parse

func Parse(val string) (info Info, err error)

Parse parses type definition and returns its type information.

func (Info) CanAssignConst

func (i Info) CanAssignConst(o Info) bool

CanAssignConst tests if the argument const type can be assigned to this type.

func (Info) Concrete

func (i Info) Concrete() bool

Concrete tests if the type is concrete.

func (Info) Equal

func (i Info) Equal(o Info) bool

Equal tests if the argument type is equal to this type info.

func (*Info) Instantiate

func (i *Info) Instantiate(o Info) bool

Instantiate instantiates template type to match parameter type.

func (*Info) InstantiateWithSizes

func (i *Info) InstantiateWithSizes(sizes []int) error

InstantiateWithSizes creates a concrete type of the unspecified type with given element sizes.

func (*Info) SetConcrete

func (i *Info) SetConcrete(c bool)

SetConcrete sets the type concrete status.

func (Info) ShortString

func (i Info) ShortString() string

ShortString returns a short string name for the type info.

func (Info) Specializable

func (i Info) Specializable(o Info) bool

Specializable tests if this type can be specialized with the argument type.

func (Info) String

func (i Info) String() string

func (Info) Undefined

func (i Info) Undefined() bool

Undefined tests if type is undefined.

type Size

type Size int32

Size specify sizes and bit counts in circuits.

type StructField

type StructField struct {
	Name string
	Type Info
}

StructField defines a structure field name and type.

func (StructField) String

func (f StructField) String() string

type Type

type Type int8

Type specifies an MPCL type.

const (
	TUndefined Type = iota
	TBool
	TInt
	TUint
	TFloat
	TString
	TStruct
	TArray
	TSlice
	TPtr
	TNil
)

MPCL types.

func (Type) Array

func (t Type) Array() bool

Array tests if the type is an Array or a Slice.

func (Type) ShortString

func (t Type) ShortString() string

ShortString returns a short string name for the type.

func (Type) String

func (t Type) String() string

Jump to

Keyboard shortcuts

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