This repository has been archived by the owner on Jul 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenums.go
74 lines (60 loc) · 1.46 KB
/
enums.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
73
74
package wrengo
import "errors"
type InterpretResult int
const (
RESULT_SUCCESS InterpretResult = iota
RESULT_COMPILE_ERROR
RESULT_RUNTIME_ERROR
)
func (i InterpretResult) String() string {
return [...]string{"RESULT_SUCCESS", "RESULT_COMPILE_ERROR", "RESULT_RUNTIME_ERROR"}[i]
}
func (i InterpretResult) Error() error {
switch i {
case RESULT_SUCCESS:
return nil
case RESULT_COMPILE_ERROR:
return errors.New("COMPILE_ERROR")
case RESULT_RUNTIME_ERROR:
return errors.New("RUNTIME_ERROR")
default:
panic("unreachable")
}
}
type ErrorType int
const (
// A syntax or resolution error detected at compile time.
ERROR_COMPILE ErrorType = iota
// The error message for a runtime error.
ERROR_RUNTIME
// One entry of a runtime error's stack trace.
ERROR_STACK_TRACE
)
func (i ErrorType) String() string {
return [...]string{"ERROR_COMPILE", "ERROR_RUNTIME", "ERROR_STACK_TRACE"}[i]
}
// The type of an object stored in a slot.
//
// This is not necessarily the object's *class*, but instead its low level
// representation type.
type WrenType int
const (
WREN_TYPE_BOOL WrenType = iota
WREN_TYPE_NUM
WREN_TYPE_FOREIGN
WREN_TYPE_LIST
WREN_TYPE_NULL
WREN_TYPE_STRING
// The object is of a type that isn't accessible by the API.
WREN_TYPE_UNKNOWN
)
func (i WrenType) String() string {
return [...]string{
"WREN_TYPE_BOOL",
"WREN_TYPE_NUM",
"WREN_TYPE_FOREIGN",
"WREN_TYPE_LIST",
"WREN_TYPE_NULL",
"WREN_TYPE_STRING",
"WREN_TYPE_UNKNOWN"}[i]
}