1 | transform compare_ints(a, b) = struct {
|
---|
2 | .l <- (a < b);
|
---|
3 | .g <- (a > b);
|
---|
4 | .ge <- (a >= b);
|
---|
5 | .le <- (a <= b);
|
---|
6 | .eq <- (a == b);
|
---|
7 | .ne <- (a != b);
|
---|
8 | };
|
---|
9 |
|
---|
10 | transform arithmetic(a, b) = struct {
|
---|
11 | .sum <- (a + b);
|
---|
12 | .difference <- (a - b);
|
---|
13 | .product <- (a * b);
|
---|
14 | if (b > 0) {
|
---|
15 | .quotient <- (a // b);
|
---|
16 | .remainder <- (a % b);
|
---|
17 | }
|
---|
18 | };
|
---|
19 |
|
---|
20 | transform concat_bits(a, b) = uint_le(24) <- (in.concat_bits) <- struct {
|
---|
21 | .bits0 <- bits_le <- (a);
|
---|
22 | .bits1 <- bits_be <- (b);
|
---|
23 | .concat_bits <- (.bits0 ++ (.bits1 ++ .bits0));
|
---|
24 | };
|
---|
25 |
|
---|
26 | transform equality(bytes0, bytes1, str0, str1) = struct {
|
---|
27 | .neqs <- ((0 != 1) != (2 != 3));
|
---|
28 | .bytes0_eq_bytes1 <- (bytes0 == bytes1);
|
---|
29 | .bytes0_ne_bytes0 <- (bytes0 != bytes0);
|
---|
30 | .str0_ne_str1 <- (str0 != str1);
|
---|
31 | .str1_eq_str1 <- (str1 == str1);
|
---|
32 | .bytes1_eq_1 <- (bytes1 == 1);
|
---|
33 | };
|
---|
34 |
|
---|
35 | transform subblob(bytes0) = struct {
|
---|
36 | .subblob <- (bytes0[0:][0,1][0:1]);
|
---|
37 | };
|
---|
38 |
|
---|
39 | transform main = struct {
|
---|
40 | .bytes0 <- known_length(1);
|
---|
41 | .bytes1 <- known_length(1);
|
---|
42 | .str0 <- ascii <- (.bytes0);
|
---|
43 | .str1 <- ascii <- (.bytes1);
|
---|
44 | .compare_ints_0_1 <- compare_ints(0, 1);
|
---|
45 | .compare_ints_0_0 <- compare_ints(0, 0);
|
---|
46 | .compare_ints_1_0 <- compare_ints(1, 0);
|
---|
47 | .arithmetic_0_1 <- arithmetic(0, 1);
|
---|
48 | .arithmetic_17_n3 <- arithmetic(17, 0 - 3);
|
---|
49 | .arithmetic_n17_3 <- arithmetic(0 - 17, 3);
|
---|
50 | .concat_bytes <- (.bytes0 ++ (.bytes1 ++ .bytes0));
|
---|
51 | .concat_bits <- concat_bits(.bytes0, .bytes1);
|
---|
52 | .equality <- equality(.bytes0, .bytes1, .str0, .str1);
|
---|
53 | .subblob <- subblob(.bytes0);
|
---|
54 | };
|
---|