enhance dis output to print line numbers

This commit is contained in:
Jeong YunWon 2022-08-11 01:00:46 +09:00
parent 1a09ba0ede
commit 75b886bcd6
4 changed files with 111 additions and 98 deletions

View file

@ -2,12 +2,13 @@
source: compiler/src/compile.rs source: compiler/src/compile.rs
expression: "compile_exec(\"\\\nif True and False and False:\n pass\n\")" expression: "compile_exec(\"\\\nif True and False and False:\n pass\n\")"
--- ---
0 LoadConst (True) 1 0 LoadConst (True)
1 JumpIfFalse (6) 1 JumpIfFalse (6)
2 LoadConst (False) 2 LoadConst (False)
3 JumpIfFalse (6) 3 JumpIfFalse (6)
4 LoadConst (False) 4 LoadConst (False)
5 JumpIfFalse (6) 5 JumpIfFalse (6)
>> 6 LoadConst (None)
7 ReturnValue 2 >> 6 LoadConst (None)
7 ReturnValue

View file

@ -2,14 +2,15 @@
source: compiler/src/compile.rs source: compiler/src/compile.rs
expression: "compile_exec(\"\\\nif (True and False) or (False and True):\n pass\n\")" expression: "compile_exec(\"\\\nif (True and False) or (False and True):\n pass\n\")"
--- ---
0 LoadConst (True) 1 0 LoadConst (True)
1 JumpIfFalse (4) 1 JumpIfFalse (4)
2 LoadConst (False) 2 LoadConst (False)
3 JumpIfTrue (8) 3 JumpIfTrue (8)
>> 4 LoadConst (False) >> 4 LoadConst (False)
5 JumpIfFalse (8) 5 JumpIfFalse (8)
6 LoadConst (True) 6 LoadConst (True)
7 JumpIfFalse (8) 7 JumpIfFalse (8)
>> 8 LoadConst (None)
9 ReturnValue 2 >> 8 LoadConst (None)
9 ReturnValue

View file

@ -2,12 +2,13 @@
source: compiler/src/compile.rs source: compiler/src/compile.rs
expression: "compile_exec(\"\\\nif True or False or False:\n pass\n\")" expression: "compile_exec(\"\\\nif True or False or False:\n pass\n\")"
--- ---
0 LoadConst (True) 1 0 LoadConst (True)
1 JumpIfTrue (6) 1 JumpIfTrue (6)
2 LoadConst (False) 2 LoadConst (False)
3 JumpIfTrue (6) 3 JumpIfTrue (6)
4 LoadConst (False) 4 LoadConst (False)
5 JumpIfFalse (6) 5 JumpIfFalse (6)
>> 6 LoadConst (None)
7 ReturnValue 2 >> 6 LoadConst (None)
7 ReturnValue

View file

@ -1,77 +1,87 @@
--- ---
source: compiler/src/compile.rs source: compiler/src/compile.rs
expression: "compile_exec(\"\\\nfor stop_exc in (StopIteration('spam'), StopAsyncIteration('ham')):\n with self.subTest(type=type(stop_exc)):\n try:\n async with woohoo():\n raise stop_exc\n except Exception as ex:\n self.assertIs(ex, stop_exc)\n else:\n self.fail(f'{stop_exc} was suppressed')\n\")" expression: "compile_exec(\"\\\nfor stop_exc in (StopIteration('spam'), StopAsyncIteration('ham')):\n with self.subTest(type=type(stop_exc)):\n try:\n async with woohoo():\n raise stop_exc\n except Exception as ex:\n self.assertIs(ex, stop_exc)\n else:\n self.fail(f'{stop_exc} was suppressed')\n\")"
--- ---
0 SetupLoop (69) 1 0 SetupLoop (69)
1 LoadNameAny (0, StopIteration) 1 LoadNameAny (0, StopIteration)
2 LoadConst ("spam") 2 LoadConst ("spam")
3 CallFunctionPositional (1) 3 CallFunctionPositional (1)
4 LoadNameAny (1, StopAsyncIteration) 4 LoadNameAny (1, StopAsyncIteration)
5 LoadConst ("ham") 5 LoadConst ("ham")
6 CallFunctionPositional (1) 6 CallFunctionPositional (1)
7 BuildTuple (2, false) 7 BuildTuple (2, false)
8 GetIter 8 GetIter
>> 9 ForIter (68) >> 9 ForIter (68)
10 StoreLocal (2, stop_exc) 10 StoreLocal (2, stop_exc)
11 LoadNameAny (3, self)
12 LoadMethod (subTest) 2 11 LoadNameAny (3, self)
13 LoadNameAny (5, type) 12 LoadMethod (subTest)
14 LoadNameAny (2, stop_exc) 13 LoadNameAny (5, type)
15 CallFunctionPositional (1) 14 LoadNameAny (2, stop_exc)
16 LoadConst (("type")) 15 CallFunctionPositional (1)
17 CallMethodKeyword (1) 16 LoadConst (("type"))
18 SetupWith (65) 17 CallMethodKeyword (1)
19 Pop 18 SetupWith (65)
20 SetupExcept (40) 19 Pop
21 LoadNameAny (6, woohoo)
22 CallFunctionPositional (0) 3 20 SetupExcept (40)
23 BeforeAsyncWith
24 GetAwaitable 4 21 LoadNameAny (6, woohoo)
25 LoadConst (None) 22 CallFunctionPositional (0)
26 YieldFrom 23 BeforeAsyncWith
27 SetupAsyncWith (33) 24 GetAwaitable
28 Pop 25 LoadConst (None)
29 LoadNameAny (2, stop_exc) 26 YieldFrom
30 Raise (Raise) 27 SetupAsyncWith (33)
31 PopBlock 28 Pop
32 EnterFinally
>> 33 WithCleanupStart 5 29 LoadNameAny (2, stop_exc)
34 GetAwaitable 30 Raise (Raise)
35 LoadConst (None)
36 YieldFrom 4 31 PopBlock
37 WithCleanupFinish 32 EnterFinally
38 PopBlock >> 33 WithCleanupStart
39 Jump (54) 34 GetAwaitable
>> 40 Duplicate 35 LoadConst (None)
41 LoadNameAny (7, Exception) 36 YieldFrom
42 TestOperation (ExceptionMatch) 37 WithCleanupFinish
43 JumpIfFalse (53) 38 PopBlock
44 StoreLocal (8, ex) 39 Jump (54)
45 LoadNameAny (3, self) >> 40 Duplicate
46 LoadMethod (assertIs)
47 LoadNameAny (8, ex) 6 41 LoadNameAny (7, Exception)
48 LoadNameAny (2, stop_exc) 42 TestOperation (ExceptionMatch)
49 CallMethodPositional (2) 43 JumpIfFalse (53)
50 Pop 44 StoreLocal (8, ex)
51 PopException
52 Jump (63) 7 45 LoadNameAny (3, self)
>> 53 Raise (Reraise) 46 LoadMethod (assertIs)
>> 54 LoadNameAny (3, self) 47 LoadNameAny (8, ex)
55 LoadMethod (fail) 48 LoadNameAny (2, stop_exc)
56 LoadConst ("") 49 CallMethodPositional (2)
57 LoadNameAny (2, stop_exc) 50 Pop
58 FormatValue (None) 51 PopException
59 LoadConst (" was suppressed") 52 Jump (63)
60 BuildString (2) >> 53 Raise (Reraise)
61 CallMethodPositional (1)
62 Pop 9 >> 54 LoadNameAny (3, self)
>> 63 PopBlock 55 LoadMethod (fail)
64 EnterFinally 56 LoadConst ("")
>> 65 WithCleanupStart
66 WithCleanupFinish 1 57 LoadNameAny (2, stop_exc)
67 Jump (9) 58 FormatValue (None)
>> 68 PopBlock
>> 69 LoadConst (None) 9 59 LoadConst (" was suppressed")
70 ReturnValue 60 BuildString (2)
61 CallMethodPositional (1)
62 Pop
2 >> 63 PopBlock
64 EnterFinally
>> 65 WithCleanupStart
66 WithCleanupFinish
67 Jump (9)
>> 68 PopBlock
>> 69 LoadConst (None)
70 ReturnValue