/
or.go
46 lines (38 loc) · 875 Bytes
/
or.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package intermediate
import (
"aletheiaware.com/flamego"
"aletheiaware.com/flamego/isa"
"encoding/binary"
)
var _ Addressable = (*Or)(nil)
var _ Emittable = (*Or)(nil)
type Or struct {
Statement
source1 flamego.Register
source2 flamego.Register
destination flamego.Register
}
func NewOr(s1, s2, d flamego.Register, c string) *Or {
return &Or{
Statement: Statement{
comment: c,
},
source1: s1,
source2: s2,
destination: d,
}
}
func (a *Or) String() string {
return a.Instruction().String() + a.Statement.String()
}
func (a *Or) Emit() []byte {
buffer := make([]byte, 4)
binary.BigEndian.PutUint32(buffer, isa.Encode(a.Instruction()))
return buffer
}
func (a *Or) EmittedSize() uint32 {
return flamego.InstructionSize
}
func (a *Or) Instruction() flamego.Instruction {
return isa.NewOr(a.source1, a.source2, a.destination)
}