forked from johnkerl/miller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mlrval_constants.go
81 lines (68 loc) · 1.82 KB
/
mlrval_constants.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
75
76
77
78
79
80
81
// ================================================================
// Constants/singletons of various types
// ================================================================
package mlrval
// MlrvalFromPending is designed solely for the JSON API, for something
// intended to be mutated after construction once its type is (later) known.
// Whereas ERROR, ABSENT, etc are all singletons, this one
// must be mutable and therefore non-singleton.
func MlrvalFromPending() Mlrval {
return Mlrval{
mvtype: MT_PENDING,
printrep: "(bug-if-you-see-this:case-3)", // INVALID_PRINTREP,
}
}
// These are made singletons as part of a copy-reduction effort. They're not
// marked const (I haven't figured out the right way to get that to compile;
// just using `const` isn't enough) but the gentelpersons' agreement is that
// the caller should never modify these.
var TRUE = &Mlrval{
mvtype: MT_BOOL,
printrep: "true",
printrepValid: true,
boolval: true,
}
var FALSE = &Mlrval{
mvtype: MT_BOOL,
printrep: "false",
printrepValid: true,
}
var VOID = &Mlrval{
mvtype: MT_VOID,
printrep: "",
printrepValid: true,
}
var ERROR = &Mlrval{
mvtype: MT_ERROR,
printrep: ERROR_PRINTREP,
printrepValid: true,
}
var NULL = &Mlrval{
mvtype: MT_NULL,
printrep: "null",
printrepValid: true,
}
var ABSENT = &Mlrval{
mvtype: MT_ABSENT,
printrep: ABSENT_PRINTREP,
printrepValid: true,
}
// For malloc-avoidance in the spaceship operator
var MINUS_ONE = &Mlrval{
mvtype: MT_INT,
printrep: "-1",
printrepValid: true,
intval: -1,
}
var ZERO = &Mlrval{
mvtype: MT_INT,
printrep: "0",
printrepValid: true,
intval: 0,
}
var ONE = &Mlrval{
mvtype: MT_INT,
printrep: "1",
printrepValid: true,
intval: 1,
}