提交 071c2102 编写于 作者: 3 3dgen

优化Tuple结构

上级 5aa6e7ba
...@@ -46,25 +46,27 @@ func (t Tuple) EmitLoadFromAddr(addr Value, offset int) []wat.Inst { ...@@ -46,25 +46,27 @@ func (t Tuple) EmitLoadFromAddr(addr Value, offset int) []wat.Inst {
aTuple: aTuple:
**************************************/ **************************************/
type aTuple struct { type aTuple struct {
aValue aStruct
underlying aStruct typ Tuple
} }
func newValueTuple(name string, kind ValueKind, typ Tuple) *aTuple { func newValueTuple(name string, kind ValueKind, typ Tuple) *aTuple {
var v aTuple var v aTuple
v.aValue = aValue{name: name, kind: kind, typ: typ} v.typ = typ
v.underlying = *newValueStruct(name, kind, typ.Struct) v.aStruct = *newValueStruct(name, kind, typ.Struct)
return &v return &v
} }
func (v *aTuple) raw() []wat.Value { return v.underlying.raw() } func (v *aTuple) Type() ValueType { return v.typ }
func (v *aTuple) EmitInit() []wat.Inst { return v.underlying.EmitInit() }
func (v *aTuple) EmitPush() []wat.Inst { return v.underlying.EmitPush() } func (v *aTuple) raw() []wat.Value { return v.aStruct.raw() }
func (v *aTuple) EmitPop() []wat.Inst { return v.underlying.EmitPop() } func (v *aTuple) EmitInit() []wat.Inst { return v.aStruct.EmitInit() }
func (v *aTuple) EmitRelease() []wat.Inst { return v.underlying.EmitRelease() } func (v *aTuple) EmitPush() []wat.Inst { return v.aStruct.EmitPush() }
func (v *aTuple) EmitPop() []wat.Inst { return v.aStruct.EmitPop() }
func (v *aTuple) EmitRelease() []wat.Inst { return v.aStruct.EmitRelease() }
func (v *aTuple) emitStoreToAddr(addr Value, offset int) []wat.Inst { func (v *aTuple) emitStoreToAddr(addr Value, offset int) []wat.Inst {
return v.underlying.emitStoreToAddr(addr, offset) return v.aStruct.emitStoreToAddr(addr, offset)
} }
func (v *aTuple) Extract(id int) Value { func (v *aTuple) Extract(id int) Value {
...@@ -73,5 +75,5 @@ func (v *aTuple) Extract(id int) Value { ...@@ -73,5 +75,5 @@ func (v *aTuple) Extract(id int) Value {
panic("id >= len(st.Members)") panic("id >= len(st.Members)")
} }
return v.underlying.genSubValue(st.Members[id]) return v.genSubValue(st.Members[id])
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册