/
actions.go
66 lines (54 loc) · 898 Bytes
/
actions.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package debugger
import (
"os"
"fmt"
)
type Action interface {
Exec(d *Debugger)
}
type Nop struct{}
type Continue struct{}
type Watch struct{}
type Break struct{}
type Disable struct{}
type Quit struct {}
type Skip struct{
Count int
}
type Err struct {
Msg string
}
func (n Nop) Exec(d *Debugger) {}
func (c Continue) Exec(d *Debugger) {
d.control <- cBreak
}
func (s Skip) Exec(d *Debugger){
d.control <- cBreak
count := s.Count
if count > 100 {
count = 100
}
for i := 0; i < count; i += 1 {
d.control <- cBreak
}
}
func (s Watch) Exec(d *Debugger){
d.Watch <- 1
d.control <- cBreak
}
func (s Disable) Exec(d *Debugger){
d.Enabled = false
d.control <- cBreak
}
func (q Quit) Exec(d *Debugger){
os.Exit(130)
}
func (e Err) Exec(d *Debugger){
fmt.Fprintf(d.Logout, "err: %v", e.Msg)
}
func (b Break) Exec(d *Debugger){
select {
case <-d.Watch:
default:
}
}