diff options
Diffstat (limited to 'vendor/github.com/bytedance/sonic/internal/encoder/ir')
| -rw-r--r-- | vendor/github.com/bytedance/sonic/internal/encoder/ir/op.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/vendor/github.com/bytedance/sonic/internal/encoder/ir/op.go b/vendor/github.com/bytedance/sonic/internal/encoder/ir/op.go index a0c693f00..fe5a4ebe7 100644 --- a/vendor/github.com/bytedance/sonic/internal/encoder/ir/op.go +++ b/vendor/github.com/bytedance/sonic/internal/encoder/ir/op.go @@ -24,6 +24,7 @@ import ( "unsafe" "github.com/bytedance/sonic/internal/encoder/vars" + "github.com/bytedance/sonic/internal/resolver" "github.com/bytedance/sonic/internal/rt" ) @@ -80,6 +81,8 @@ const ( OP_marshal_text_p OP_cond_set OP_cond_testc + OP_unsupported + OP_is_zero ) const ( @@ -141,6 +144,7 @@ var OpNames = [256]string{ OP_marshal_text_p: "marshal_text_p", OP_cond_set: "cond_set", OP_cond_testc: "cond_testc", + OP_unsupported: "unsupported type", } func (self Op) String() string { @@ -229,6 +233,11 @@ type typAndTab struct { itab *rt.GoItab } +type typAndField struct { + vt reflect.Type + fv *resolver.FieldMeta +} + func NewInsVtab(op Op, vt reflect.Type, itab *rt.GoItab) Instr { return Instr{ o: op, @@ -239,6 +248,13 @@ func NewInsVtab(op Op, vt reflect.Type, itab *rt.GoItab) Instr { } } +func NewInsField(op Op, fv *resolver.FieldMeta) Instr { + return Instr{ + o: op, + p: unsafe.Pointer(fv), + } +} + func NewInsVp(op Op, vt reflect.Type, pv bool) Instr { i := 0 if pv { @@ -263,6 +279,10 @@ func (self Instr) Vf() uint8 { return (*rt.GoType)(self.p).KindFlags } +func (self Instr) VField() (*resolver.FieldMeta) { + return (*resolver.FieldMeta)(self.p) +} + func (self Instr) Vs() (v string) { (*rt.GoString)(unsafe.Pointer(&v)).Ptr = self.p (*rt.GoString)(unsafe.Pointer(&v)).Len = self.Vi() @@ -273,6 +293,10 @@ func (self Instr) Vk() reflect.Kind { return (*rt.GoType)(self.p).Kind() } +func (self Instr) GoType() *rt.GoType { + return (*rt.GoType)(self.p) +} + func (self Instr) Vt() reflect.Type { return (*rt.GoType)(self.p).Pack() } @@ -442,6 +466,10 @@ func (self *Program) Vtab(op Op, vt reflect.Type, itab *rt.GoItab) { *self = append(*self, NewInsVtab(op, vt, itab)) } +func (self *Program) VField(op Op, fv *resolver.FieldMeta) { + *self = append(*self, NewInsField(op, fv)) +} + func (self Program) Disassemble() string { nb := len(self) tab := make([]bool, nb+1) |
