op: change CallOp to be a return value from MacroOp.Stop

Converting

	macro := op.Record(ops)
	...
	macro.Stop()

	macro.Add()

to

	macro := op.Record(ops)
	...
	call := macro.Stop()

	call.Add(ops)

Which is more general (call.Add can take a different ops than the op.Record
that started it), and enforced the order between Stop and the subsequent Add.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2020-06-02 12:07:20 +02:00
parent ce0cc706ad
commit c19ed05342
10 changed files with 69 additions and 110 deletions
+4 -7
View File
@@ -8,8 +8,8 @@ type OpType byte
const firstOpIndex = 200
const (
TypeMacroDef OpType = iota + firstOpIndex
TypeMacro
TypeMacro OpType = iota + firstOpIndex
TypeCall
TypeTransform
TypeLayer
TypeInvalidate
@@ -26,12 +26,11 @@ const (
TypeAux
TypeClip
TypeProfile
TypeCall
)
const (
TypeMacroDefLen = 1 + 4 + 4
TypeMacroLen = 1 + 4 + 4
TypeCallLen = 1 + 4 + 4
TypeTransformLen = 1 + 4*2
TypeLayerLen = 1
TypeRedrawLen = 1 + 8
@@ -48,13 +47,12 @@ const (
TypeAuxLen = 1
TypeClipLen = 1 + 4*4
TypeProfileLen = 1
TypeCallLen = 1
)
func (t OpType) Size() int {
return [...]int{
TypeMacroDefLen,
TypeMacroLen,
TypeCallLen,
TypeTransformLen,
TypeLayerLen,
TypeRedrawLen,
@@ -71,7 +69,6 @@ func (t OpType) Size() int {
TypeAuxLen,
TypeClipLen,
TypeProfileLen,
TypeCallLen,
}[t-firstOpIndex]
}