lib/standard: Remove lshift and rshift from Int and Byte
[nit.git] / contrib / pep8analysis / src / ast / suffixed_instructions.nit
1 # Pep/8 instructions are not reserved as keywords. It is common
2 # that the identifier of an instruction will be used for a label.
3 # For this reason, we cannot create precise instruction nodes with
4 # the parser.
5 #
6 # This module manually creates the expected subclass with an additionnal
7 # OOP hiearchy.
8
9 module suffixed_instructions
10
11 import rich_instructions
12
13 #
14 # Support classes
15 #
16 abstract class ARegisterSuffixed
17 super AInstruction
18
19 fun register : Char do return n_id.text.to_upper.last
20 end
21
22 abstract class ADigitSuffixed
23 super AInstruction
24
25 fun digit : Int do return n_id.text.last.to_i
26 fun digit_max : Int is abstract
27 end
28
29
30 #
31 # Other classification
32 #
33 redef class AUnaryNopInstruction
34 super ADigitSuffixed
35 redef fun digit_max do return (1 << 2)-1
36 end
37
38 redef class ANotInstruction
39 super ARegisterSuffixed
40 end
41
42 redef class ANegInstruction
43 super ARegisterSuffixed
44 end
45
46 redef class AShiftInstruction
47 super ARegisterSuffixed
48 end
49
50 redef class ARetInstruction
51 super ADigitSuffixed
52 redef fun digit_max do return (1 << 3)-1
53 end
54
55 redef abstract class AArithmeticInstruction
56 super ARegisterSuffixed
57 end
58
59 redef abstract class ALoadInstruction
60 super ARegisterSuffixed
61 end
62
63 redef abstract class AStoreInstruction
64 super ARegisterSuffixed
65 end