Skip to content

Commit 601ead9

Browse files
committed
fix: when compiling code for the debugger, set is_result_unused to true
1 parent 1a1594f commit 601ead9

File tree

6 files changed

+5
-14
lines changed

6 files changed

+5
-14
lines changed

src/arkreactor/Compiler/Lowerer/ASTLowerer.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ namespace Ark::internal
3737
// gather symbols, values, and start to create code segments
3838
compileExpression(
3939
ast,
40-
/* current_page */ global,
41-
/* is_result_unused */ false,
42-
/* is_terminal */ false);
40+
/* current_page= */ global,
41+
// the offset is non-zero when coming from the debugger, and setting is_result_unused to
42+
// true will avoid adding a LOAD_FAST/LOAD_FAST_FROM_INDEX after a let/mut/set
43+
/* is_result_unused= */ m_start_page_at_offset != 0,
44+
/* is_terminal= */ false);
4345
m_logger.traceEnd();
4446
}
4547

tests/unittests/resources/DebuggerSuite/basic.expected

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ In file tests/unittests/resources/DebuggerSuite/basic.ark:3
77
5 |
88

99
dbg[pp:0,ip:3]:000> (let c (+ a b))
10-
11
1110
dbg[pp:0,ip:3]:001> (prn c)
1211
11
1312
dbg[pp:0,ip:3]:002> c
@@ -25,7 +24,6 @@ In file tests/unittests/resources/DebuggerSuite/basic.ark:7
2524

2625
dbg[pp:1,ip:5]:000> (prn x y z)
2726
567
28-
nil
2927
dbg[pp:1,ip:5]:001> help
3028
Available commands:
3129
help -- display this message

tests/unittests/resources/DebuggerSuite/debugger_quit.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ In file tests/unittests/resources/DebuggerSuite/debugger_quit.ark:3
77
5 |
88

99
dbg[pp:0,ip:3]:000> (let c (+ a b))
10-
11
1110
dbg[pp:0,ip:3]:001> (prn c)
1211
11
1312
dbg[pp:0,ip:3]:002> q

tests/unittests/resources/DebuggerSuite/loop.expected

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ In file tests/unittests/resources/DebuggerSuite/loop.ark:3
1515

1616
dbg[pp:0,ip:8]:000> (prn i)
1717
6
18-
nil
1918
dbg[pp:0,ip:8]:001> c
2019
dbg: continue
2120
ark: i=6
@@ -30,7 +29,6 @@ In file tests/unittests/resources/DebuggerSuite/loop.ark:3
3029

3130
dbg[pp:0,ip:8]:000> (prn i)
3231
7
33-
nil
3432
dbg[pp:0,ip:8]:001> c
3533
dbg: continue
3634
ark: i=7
@@ -45,7 +43,6 @@ In file tests/unittests/resources/DebuggerSuite/loop.ark:3
4543

4644
dbg[pp:0,ip:8]:000> (prn i)
4745
8
48-
nil
4946
dbg[pp:0,ip:8]:001> c
5047
dbg: continue
5148
ark: i=8
@@ -60,7 +57,6 @@ In file tests/unittests/resources/DebuggerSuite/loop.ark:3
6057

6158
dbg[pp:0,ip:8]:000> (prn i)
6259
9
63-
nil
6460
dbg[pp:0,ip:8]:001> c
6561
dbg: continue
6662
ark: i=9

tests/unittests/resources/DebuggerSuite/modify_program_state.expected

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ In file tests/unittests/resources/DebuggerSuite/modify_program_state.ark:3
1515

1616
dbg[pp:0,ip:8]:000> (prn i)
1717
6
18-
nil
1918
dbg[pp:0,ip:8]:001> c
2019
dbg: continue
2120
ark: i=6
@@ -29,7 +28,6 @@ In file tests/unittests/resources/DebuggerSuite/modify_program_state.ark:3
2928
5 | (set i (+ 1 i)) })
3029

3130
dbg[pp:0,ip:8]:000> (set i 20)
32-
20
3331
dbg[pp:0,ip:8]:001> c
3432
dbg: continue
3533
ark: i=20
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
dbg[pp:0,ip:3]:000> (prn a)
22
5
3-
nil
43
dbg[pp:0,ip:3]:001> (prn (type a))
54
Number
6-
nil
75
dbg[pp:0,ip:3]:002> c
86
dbg: continue

0 commit comments

Comments
 (0)