mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
op: assume aux ops are always wrapped by a macro
Shaves off a length, and prepares for further simplification. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -44,7 +44,7 @@ const (
|
||||
TypeHideInputLen = 1
|
||||
TypePushLen = 1
|
||||
TypePopLen = 1
|
||||
TypeAuxLen = 1 + 4
|
||||
TypeAuxLen = 1
|
||||
TypeClipLen = 1 + 4*4
|
||||
TypeProfileLen = 1
|
||||
)
|
||||
|
||||
+4
-17
@@ -53,10 +53,6 @@ type opMacroDef struct {
|
||||
endpc pc
|
||||
}
|
||||
|
||||
type opAux struct {
|
||||
len int
|
||||
}
|
||||
|
||||
// Reset start reading from the op list.
|
||||
func (r *Reader) Reset(ops *op.Ops) {
|
||||
r.stack = r.stack[:0]
|
||||
@@ -93,9 +89,10 @@ func (r *Reader) Decode() (EncodedOp, bool) {
|
||||
refs = refs[:nrefs]
|
||||
switch t {
|
||||
case opconst.TypeAux:
|
||||
var op opAux
|
||||
op.decode(data)
|
||||
n += op.len
|
||||
// An Aux operations is always wrapped in a macro, and
|
||||
// its length is the remaining space.
|
||||
block := r.stack[len(r.stack)-1]
|
||||
n += block.endPC.data - r.pc.data - opconst.TypeAuxLen
|
||||
data = data[:n]
|
||||
case opconst.TypeMacro:
|
||||
var op macroOp
|
||||
@@ -151,16 +148,6 @@ func (op *opMacroDef) decode(data []byte) {
|
||||
}
|
||||
}
|
||||
|
||||
func (op *opAux) decode(data []byte) {
|
||||
if opconst.OpType(data[0]) != opconst.TypeAux {
|
||||
panic("invalid op")
|
||||
}
|
||||
bo := binary.LittleEndian
|
||||
*op = opAux{
|
||||
len: int(int32(bo.Uint32(data[1:]))),
|
||||
}
|
||||
}
|
||||
|
||||
func (m *macroOp) decode(data []byte, refs []interface{}) {
|
||||
if opconst.OpType(data[0]) != opconst.TypeMacro {
|
||||
panic("invalid op")
|
||||
|
||||
Reference in New Issue
Block a user