mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
update snapshot
This commit is contained in:
1 file changed
+144
-37
+144
-37
@@ -1,53 +1,160 @@
|
||||
---
|
||||
source: compiler/codegen/src/compile.rs
|
||||
expression: "compile_exec(\"\\\nclass Test:\n pass\n\nt = Test()\nmatch t:\n case Test():\n assert True\n case _:\n assert False\n\")"
|
||||
expression: "compile_exec(r#\"\\\nclass Shape:\n pass\n\nclass Circle(Shape):\n def __init__(self, radius):\n self.radius = radius\n\nclass Rectangle(Shape):\n def __init__(self, width, height):\n self.width = width\n self.height = height\n\ndef describe_shape(shape):\n match shape:\n case Circle(radius=r):\n return f\"A circle with radius {r}\"\n case Rectangle(width=w, height=h):\n return f\"A rectangle {w} by {h}\"\n case _:\n return \"Unknown shape\"\n\n# Test it out\nshapes = [Circle(5), Rectangle(4, 6), \"not a shape\"]\nfor s in shapes:\n print(describe_shape(s))\n\"#)"
|
||||
---
|
||||
2 0 LoadBuildClass
|
||||
1 LoadConst (<code object Test at ??? file "source_path", line 1>): 1 0 LoadGlobal (0, __name__)
|
||||
3 0 LoadBuildClass
|
||||
1 LoadConst (<code object Shape at ??? file "source_path", line 2>): 2 0 LoadGlobal (0, __name__)
|
||||
1 StoreLocal (1, __module__)
|
||||
2 LoadConst ("Test")
|
||||
2 LoadConst ("Shape")
|
||||
3 StoreLocal (2, __qualname__)
|
||||
4 LoadConst (None)
|
||||
5 StoreLocal (3, __doc__)
|
||||
|
||||
2 6 ReturnConst (None)
|
||||
3 6 ReturnConst (None)
|
||||
|
||||
2 LoadConst ("Test")
|
||||
2 LoadConst ("Shape")
|
||||
3 MakeFunction (MakeFunctionFlags(0x0))
|
||||
4 LoadConst ("Test")
|
||||
4 LoadConst ("Shape")
|
||||
5 CallFunctionPositional(2)
|
||||
6 StoreLocal (0, Test)
|
||||
6 StoreLocal (0, Shape)
|
||||
|
||||
4 7 LoadNameAny (0, Test)
|
||||
8 CallFunctionPositional(0)
|
||||
9 StoreLocal (1, t)
|
||||
7 7 LoadBuildClass
|
||||
8 LoadConst (<code object Circle at ??? file "source_path", line 5>): 5 0 LoadGlobal (0, __name__)
|
||||
1 StoreLocal (1, __module__)
|
||||
2 LoadConst ("Circle")
|
||||
3 StoreLocal (2, __qualname__)
|
||||
4 LoadConst (None)
|
||||
5 StoreLocal (3, __doc__)
|
||||
|
||||
5 10 LoadNameAny (1, t)
|
||||
11 CopyItem (1)
|
||||
7 6 LoadConst (<code object __init__ at ??? file "source_path", line 6>): 7 0 LoadFast (1, radius)
|
||||
1 LoadFast (0, self)
|
||||
2 StoreAttr (0, radius)
|
||||
3 ReturnConst (None)
|
||||
|
||||
6 12 LoadNameAny (0, Test)
|
||||
13 LoadConst (())
|
||||
14 MatchClass (0)
|
||||
15 CopyItem (1)
|
||||
16 LoadConst (None)
|
||||
17 TestOperation (IsNot)
|
||||
18 JumpIfFalse (27)
|
||||
19 UnpackSequence (0)
|
||||
20 Pop
|
||||
7 LoadConst ("Circle.__init__")
|
||||
8 MakeFunction (MakeFunctionFlags(0x0))
|
||||
9 StoreLocal (4, __init__)
|
||||
10 ReturnConst (None)
|
||||
|
||||
7 21 LoadConst (True)
|
||||
22 JumpIfTrue (26)
|
||||
23 LoadGlobal (2, AssertionError)
|
||||
24 CallFunctionPositional(0)
|
||||
25 Raise (Raise)
|
||||
>> 26 Jump (35)
|
||||
>> 27 Pop
|
||||
28 Pop
|
||||
9 LoadConst ("Circle")
|
||||
10 MakeFunction (MakeFunctionFlags(0x0))
|
||||
11 LoadConst ("Circle")
|
||||
|
||||
9 29 LoadConst (False)
|
||||
30 JumpIfTrue (34)
|
||||
31 LoadGlobal (2, AssertionError)
|
||||
32 CallFunctionPositional(0)
|
||||
33 Raise (Raise)
|
||||
>> 34 Jump (35)
|
||||
>> 35 ReturnConst (None)
|
||||
5 12 LoadNameAny (0, Shape)
|
||||
13 CallFunctionPositional(3)
|
||||
14 StoreLocal (1, Circle)
|
||||
|
||||
12 15 LoadBuildClass
|
||||
16 LoadConst (<code object Rectangle at ??? file "source_path", line 9>): 9 0 LoadGlobal (0, __name__)
|
||||
1 StoreLocal (1, __module__)
|
||||
2 LoadConst ("Rectangle")
|
||||
3 StoreLocal (2, __qualname__)
|
||||
4 LoadConst (None)
|
||||
5 StoreLocal (3, __doc__)
|
||||
|
||||
12 6 LoadConst (<code object __init__ at ??? file "source_path", line 10>): 11 0 LoadFast (1, width)
|
||||
1 LoadFast (0, self)
|
||||
2 StoreAttr (0, width)
|
||||
|
||||
12 3 LoadFast (2, height)
|
||||
4 LoadFast (0, self)
|
||||
5 StoreAttr (1, height)
|
||||
6 ReturnConst (None)
|
||||
|
||||
7 LoadConst ("Rectangle.__init__")
|
||||
8 MakeFunction (MakeFunctionFlags(0x0))
|
||||
9 StoreLocal (4, __init__)
|
||||
10 ReturnConst (None)
|
||||
|
||||
17 LoadConst ("Rectangle")
|
||||
18 MakeFunction (MakeFunctionFlags(0x0))
|
||||
19 LoadConst ("Rectangle")
|
||||
|
||||
9 20 LoadNameAny (0, Shape)
|
||||
21 CallFunctionPositional(3)
|
||||
22 StoreLocal (2, Rectangle)
|
||||
|
||||
21 23 LoadConst (<code object describe_shape at ??? file "source_path", line 14>): 15 0 LoadFast (0, shape)
|
||||
1 CopyItem (1)
|
||||
|
||||
16 2 LoadGlobal (0, Circle)
|
||||
3 LoadConst (("radius"))
|
||||
4 MatchClass (0)
|
||||
5 CopyItem (1)
|
||||
6 LoadConst (None)
|
||||
7 TestOperation (IsNot)
|
||||
8 JumpIfFalse (19)
|
||||
9 UnpackSequence (1)
|
||||
10 Pop
|
||||
11 Pop
|
||||
|
||||
17 12 LoadConst ("A circle with radius ")
|
||||
13 LoadConst ("")
|
||||
14 LoadFast (1, r)
|
||||
15 FormatValue (None)
|
||||
16 BuildString (2)
|
||||
17 ReturnValue
|
||||
18 Jump (47)
|
||||
>> 19 Pop
|
||||
20 CopyItem (1)
|
||||
|
||||
18 21 LoadGlobal (1, Rectangle)
|
||||
22 LoadConst (("width", "height"))
|
||||
23 MatchClass (0)
|
||||
24 CopyItem (1)
|
||||
25 LoadConst (None)
|
||||
26 TestOperation (IsNot)
|
||||
27 JumpIfFalse (43)
|
||||
28 UnpackSequence (2)
|
||||
29 Pop
|
||||
30 Pop
|
||||
31 Pop
|
||||
|
||||
19 32 LoadConst ("A rectangle ")
|
||||
33 LoadConst ("")
|
||||
34 LoadFast (2, w)
|
||||
35 FormatValue (None)
|
||||
36 LoadConst (" by ")
|
||||
37 LoadConst ("")
|
||||
38 LoadFast (3, h)
|
||||
39 FormatValue (None)
|
||||
40 BuildString (4)
|
||||
41 ReturnValue
|
||||
42 Jump (47)
|
||||
>> 43 Pop
|
||||
44 Pop
|
||||
|
||||
21 45 ReturnConst ("Unknown shape")
|
||||
46 Jump (47)
|
||||
>> 47 ReturnConst (None)
|
||||
|
||||
24 LoadConst ("describe_shape")
|
||||
25 MakeFunction (MakeFunctionFlags(0x0))
|
||||
26 StoreLocal (3, describe_shape)
|
||||
|
||||
24 27 LoadNameAny (1, Circle)
|
||||
28 LoadConst (5)
|
||||
29 CallFunctionPositional(1)
|
||||
30 LoadNameAny (2, Rectangle)
|
||||
31 LoadConst (4)
|
||||
32 LoadConst (6)
|
||||
33 CallFunctionPositional(2)
|
||||
34 LoadConst ("not a shape")
|
||||
35 BuildList (3)
|
||||
36 StoreLocal (4, shapes)
|
||||
|
||||
25 37 SetupLoop
|
||||
38 LoadNameAny (4, shapes)
|
||||
39 GetIter
|
||||
>> 40 ForIter (49)
|
||||
41 StoreLocal (5, s)
|
||||
|
||||
26 42 LoadNameAny (6, print)
|
||||
43 LoadNameAny (3, describe_shape)
|
||||
44 LoadNameAny (5, s)
|
||||
45 CallFunctionPositional(1)
|
||||
46 CallFunctionPositional(1)
|
||||
47 Pop
|
||||
48 Jump (40)
|
||||
>> 49 PopBlock
|
||||
50 ReturnConst (None)
|
||||
Reference in new issue
Block a user