package rrdbinary // RPNToken is one of the things that can be stored in a Unival; used // by DST_CDEF. type RPNToken struct { Op uint8 // rpn operator type Val int32 // used by OP_NUMBER (0), OP_VARIABLE (1), and OP_PREV_OTHER (36) } // AsRPNTokens returns 1 or 2 RPNTokens (depending on the // Architecture.ShortSize). func (u Unival) AsRPNTokens() []RPNToken { var ret []RPNToken data := u.data for len(data) > 0 { rpnpData := data[:u.arch.ShortAlign+u.arch.ShortWidth] var rpnp RPNToken rpnp.Op = rpnpData[0] switch u.arch.ShortWidth { case 2: rpnp.Val = int32(int16(u.arch.ByteOrder.Uint16(rpnpData[u.arch.ShortAlign:]))) case 4: rpnp.Val = int32(u.arch.ByteOrder.Uint32(rpnpData[u.arch.ShortAlign:])) } ret = append(ret, rpnp) data = data[len(rpnpData):] } return ret }