decoder

package
v0.1.15 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxField  = 65536
	MaxBitmap = MaxField / 64
)
View Source
const (
	ETAG   = -1
	EEOF   = -2
	ESTACK = -3
)
View Source
const (
	NbOffset = int64(unsafe.Offsetof(StateItem{}.Nb))
	MpOffset = int64(unsafe.Offsetof(StateItem{}.Mp))
	WpOffset = int64(unsafe.Offsetof(StateItem{}.Wp))
	FmOffset = int64(unsafe.Offsetof(StateItem{}.Fm))
)
View Source
const (
	SkOffset = int64(unsafe.Offsetof(RuntimeState{}.Sk))
	PrOffset = int64(unsafe.Offsetof(RuntimeState{}.Pr))
	IvOffset = int64(unsafe.Offsetof(RuntimeState{}.Iv))
)
View Source
const (
	StateMax  = (defs.StackSize - 1) * StateSize
	StateSize = int64(unsafe.Sizeof(StateItem{}))
)
View Source
const (
	ARG_buf = 0
	ARG_nb  = 1
	ARG_i   = 2
	ARG_p   = 3
	ARG_rs  = 4
	ARG_st  = 5
)
View Source
const (
	WP = hir.P1
	IP = hir.P2
	RS = hir.P3
	ET = hir.P4 // may also be used as a temporary pointer register
	EP = hir.P5 // may also be used as a temporary pointer register
)
View Source
const (
	IC = hir.R2
	ST = hir.R3
	TG = hir.R4
)
View Source
const (
	TP = hir.P0
	TR = hir.R0
	UR = hir.R1
)
View Source
const (
	LB_eof      = "_eof"
	LB_halt     = "_halt"
	LB_type     = "_type"
	LB_skip     = "_skip"
	LB_error    = "_error"
	LB_missing  = "_missing"
	LB_overflow = "_overflow"
)

Variables

View Source
var (
	F_makemap  = hir.RegisterGCall(makemap, emu_gcall_makemap)
	F_mallocgc = hir.RegisterGCall(mallocgc, emu_gcall_mallocgc)
)
View Source
var (
	F_newFieldBitmap   = hir.RegisterGCall(newFieldBitmap, emu_gcall_newFieldBitmap)
	F_FieldBitmap_Free = hir.RegisterGCall((*FieldBitmap).Free, emu_gcall_FieldBitmap_Free)
)
View Source
var (
	HitCount  uint64 = 0
	MissCount uint64 = 0
	TypeCount uint64 = 0
)
View Source
var (
	F_error_eof     = hir.RegisterGCall(error_eof, emu_gcall_error_eof)
	F_error_skip    = hir.RegisterGCall(error_skip, emu_gcall_error_skip)
	F_error_type    = hir.RegisterGCall(error_type, emu_gcall_error_type)
	F_error_missing = hir.RegisterGCall(error_missing, emu_gcall_error_missing)
)
View Source
var (
	F_mapassign           = hir.RegisterGCall(mapassign, emu_gcall_mapassign)
	F_mapassign_fast32    = hir.RegisterGCall(mapassign_fast32, emu_gcall_mapassign_fast32)
	F_mapassign_fast64    = hir.RegisterGCall(mapassign_fast64, emu_gcall_mapassign_fast64)
	F_mapassign_faststr   = hir.RegisterGCall(mapassign_faststr, emu_gcall_mapassign_faststr)
	F_mapassign_fast64ptr = hir.RegisterGCall(mapassign_fast64ptr, emu_gcall_mapassign_fast64ptr)
)
View Source
var (
	C_skip = hir.RegisterCCall(archSkippingFn(), emu_ccall_skip)
)
View Source
var (
	F_decode *hir.CallHandle
)
View Source
var (
	F_slicebytetostring = hir.RegisterGCall(slicebytetostring, emu_gcall_slicebytetostring)
)

Functions

func DecodeObject

func DecodeObject(buf []byte, val interface{}) (ret int, err error)

func Pretouch added in v0.1.4

func Pretouch(vt *rt.GoType, opts opts.Options) (map[reflect.Type]struct{}, error)

func SetLinker

func SetLinker(v Linker)

func Translate

func Translate(s Program) hir.Program

Types

type BasicBlock added in v0.1.2

type BasicBlock struct {
	P    Program
	Src  int
	End  int
	Link []*BasicBlock
}

func (*BasicBlock) Free added in v0.1.2

func (self *BasicBlock) Free()

func (*BasicBlock) Len added in v0.1.2

func (self *BasicBlock) Len() int

func (*BasicBlock) String added in v0.1.2

func (self *BasicBlock) String() string

type Compiler

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

func CreateCompiler

func CreateCompiler() *Compiler

func (*Compiler) Apply added in v0.1.4

func (self *Compiler) Apply(o opts.Options) *Compiler

func (*Compiler) Compile

func (self *Compiler) Compile(vt reflect.Type) (_ Program, err error)

func (*Compiler) CompileAndFree

func (self *Compiler) CompileAndFree(vt reflect.Type) (ret Program, err error)

func (*Compiler) Free

func (self *Compiler) Free()

type DecodeError

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

func (DecodeError) Error

func (self DecodeError) Error() string

type Decoder

type Decoder func(
	buf unsafe.Pointer,
	nb int,
	i int,
	p unsafe.Pointer,
	rs *RuntimeState,
	st int,
) (int, error)
func Link(p hir.Program) Decoder

type FieldBitmap

type FieldBitmap [MaxBitmap]int64

func (*FieldBitmap) Append

func (self *FieldBitmap) Append(i int)

func (*FieldBitmap) Clear

func (self *FieldBitmap) Clear()

func (*FieldBitmap) Free

func (self *FieldBitmap) Free()

type GraphBuilder added in v0.1.2

type GraphBuilder struct {
	Pin   map[int]bool
	Graph map[int]*BasicBlock
}

func (*GraphBuilder) Build added in v0.1.2

func (self *GraphBuilder) Build(p Program) *BasicBlock

func (*GraphBuilder) BuildAndFree added in v0.1.2

func (self *GraphBuilder) BuildAndFree(p Program) (bb *BasicBlock)

func (*GraphBuilder) Free added in v0.1.2

func (self *GraphBuilder) Free()

type Instr

type Instr struct {
	Op OpCode
	Tx defs.Tag
	Id uint16
	To int
	Iv int64
	Sw *int
	Vt *rt.GoType
	Fn unsafe.Pointer
}

func (Instr) Disassemble

func (self Instr) Disassemble() string

func (Instr) IntSeq added in v0.1.2

func (self Instr) IntSeq() (p []int)

type Linker

type Linker interface {
	Link(p hir.Program) Decoder
}

type LinkerAMD64

type LinkerAMD64 struct{}
func (LinkerAMD64) Link(p hir.Program) Decoder

type OpCode

type OpCode uint8
const (
	OP_int OpCode = iota
	OP_str
	OP_str_nocopy
	OP_bin
	OP_bin_nocopy
	OP_enum
	OP_size
	OP_type
	OP_seek
	OP_deref
	OP_ctr_load
	OP_ctr_decr
	OP_ctr_is_zero
	OP_map_alloc
	OP_map_close
	OP_map_set_i8
	OP_map_set_i16
	OP_map_set_i32
	OP_map_set_i64
	OP_map_set_str
	OP_map_set_enum
	OP_map_set_pointer
	OP_list_alloc
	OP_struct_skip
	OP_struct_ignore
	OP_struct_bitmap
	OP_struct_switch
	OP_struct_require
	OP_struct_is_stop
	OP_struct_mark_tag
	OP_struct_read_type
	OP_struct_check_type
	OP_make_state
	OP_drop_state
	OP_construct
	OP_initialize
	OP_defer
	OP_goto
	OP_halt
)

func (OpCode) String

func (self OpCode) String() string

type Program

type Program []Instr

func Optimize added in v0.1.2

func Optimize(p Program) Program

func (Program) Disassemble

func (self Program) Disassemble() string

func (Program) Free

func (self Program) Free()

type RuntimeState

type RuntimeState struct {
	St [defs.StackSize]StateItem // Must be the first field.
	Sk [defs.StackSize]SkipItem  // Skip buffer, used for non-recursive skipping
	Pr unsafe.Pointer            // Pointer spill space, used for non-fast string or pointer map access.
	Iv uint64                    // Integer spill space, used for non-fast string map access.
}

type SkipItem

type SkipItem struct {
	T defs.Tag
	K defs.Tag
	V defs.Tag
	N uint32
}

type StateItem

type StateItem struct {
	Nb uint64
	Mp *rt.GoMap
	Wp unsafe.Pointer
	Fm *FieldBitmap
}

Jump to

Keyboard shortcuts

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