-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathtrapid.go
72 lines (54 loc) · 1.34 KB
/
trapid.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
67
68
69
70
71
72
// Copyright (c) 2016 Timo Savola. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package trap enumerates trap identifiers.
package trap
import (
"fmt"
)
type ID int
const (
Exit = ID(iota)
NoFunction // Recoverable (nonportable).
Suspended // Recoverable (portable).
Unreachable
CallStackExhausted // Recoverable (portable).
MemoryAccessOutOfBounds
IndirectCallIndexOutOfBounds
IndirectCallSignatureMismatch
IntegerDivideByZero
IntegerOverflow
Breakpoint // Recoverable (portable).
NumTraps
)
func (id ID) String() string {
switch id {
case Exit:
return "exit"
case NoFunction:
return "no function"
case Suspended:
return "suspended"
case Unreachable:
return "unreachable"
case CallStackExhausted:
return "call stack exhausted"
case MemoryAccessOutOfBounds:
return "memory access out of bounds"
case IndirectCallIndexOutOfBounds:
return "indirect call index out of bounds"
case IndirectCallSignatureMismatch:
return "indirect call signature mismatch"
case IntegerDivideByZero:
return "integer divide by zero"
case IntegerOverflow:
return "integer overflow"
case Breakpoint:
return "breakpoint"
default:
return fmt.Sprintf("unknown trap %d", id)
}
}
func (id ID) Error() string {
return "trap: " + id.String()
}