-
Notifications
You must be signed in to change notification settings - Fork 0
/
core-boolean.boba
66 lines (57 loc) · 2 KB
/
core-boolean.boba
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
import { * } "core-kinds" as kinds
about :
/// The native Boolean data type which contains just two values, `True` and `False`.
type Bool
about :
/// A core function which pushes the value `True` onto the top of the value stack.
native true-bool
: z... ===[ e... ][ p... ][ True ]==> z... Bool^s
=
# fiber.PushValue(true)
about :
/// A core function which pushes the value `False` onto the top of the value stack.
native false-bool
: z... ===[ e... ][ p... ][ True ]==> z... Bool^s
=
# fiber.PushValue(false)
about:
/// Inverts the Boolean value on top the of the value stack. So `True` becomes `False`,
/// and `False` becomes `True`.
native not-bool
: z... Bool^s ===[ e... ][ p... ][ True ]==> z... Bool^r
=
# b := fiber.PopOneValue()
# fiber.PushValue(!(b.(bool)))
about :
/// Performs the logical Boolean AND operation with the two Boolean values at the top
/// of the stack as input, pushing the result.
native and-bool
: z... Bool^s1 Bool^s2 ===[ e... ][ p... ][ True ]==> z... Bool^r
=
# l, r := fiber.PopTwoValues()
# fiber.PushValue(l.(bool) && r.(bool))
about :
/// Performs the logical Boolean OR operation with the two Boolean values at the top
/// of the stack as input, pushing the result.
native or-bool
: z... Bool^s1 Bool^s2 ===[ e... ][ p... ][ True ]==> z... Bool^r
=
# l, r := fiber.PopTwoValues()
# fiber.PushValue(l.(bool) || r.(bool))
about :
/// Compares whether the two Boolean values at the top of the stack are equal, and pushes
/// the result as a Boolean.
native eq-bool
: z... Bool^s1 Bool^s2 ===[ e... ][ p... ][ True ]==> z... Bool^r
=
# l, r := fiber.PopTwoValues()
# fiber.PushValue(l.(bool) == r.(bool))
about :
/// Compares whether the two Boolean values at the top of the stack are not equal, and pushes
/// the result as a Boolean.
native neq-bool
: z... Bool^s1 Bool^s2 ===[ e... ][ p... ][ True ]==> z... Bool^r
=
# l, r := fiber.PopTwoValues()
# fiber.PushValue(l.(bool) != r.(bool))
export { * }