File: condition.py

package info (click to toggle)
pypy 5.6.0%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 97,040 kB
  • ctags: 185,069
  • sloc: python: 1,147,862; ansic: 49,642; cpp: 5,245; asm: 5,169; makefile: 529; sh: 481; xml: 232; lisp: 45
file content (42 lines) | stat: -rw-r--r-- 673 bytes parent folder | download | duplicates (8)
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
EQ = 0
NE = 1
LE = 2
GT = 3
LT = 4
GE = 5
SO = 6
NS = 7
VEQ = 8
VEQI = 9
VNE = 10
VNEI = 11
cond_none = -1    # invalid

def negate(cond):
    return cond ^ 1

assert negate(EQ) == NE
assert negate(NE) == EQ
assert negate(LE) == GT
assert negate(GT) == LE
assert negate(LT) == GE
assert negate(GE) == LT
assert negate(SO) == NS
assert negate(NS) == SO
assert negate(VEQ) == VEQI
assert negate(VNE) == VNEI

encoding = [
    (2, 12),   # EQ
    (2, 4),    # NE
    (1, 4),    # LE
    (1, 12),   # GT
    (0, 12),   # LT
    (0, 4),    # GE
    (3, 12),   # SO
    (3, 4),    # NS
    (24, 12),   # VEQ
    (24, 4),    # VEQI
    (26, 12),    # VNE
    (26, 4),    # VNEI
]