Skip to content

Commit 3f65b8b

Browse files
committed
Add GotoTarget, skip do loops and update tests
1 parent 468ff6d commit 3f65b8b

File tree

4 files changed

+25
-21
lines changed

4 files changed

+25
-21
lines changed

src/libasr/codegen/asr_to_c_cpp.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1927,9 +1927,8 @@ R"(#include <stdio.h>
19271927
gotoid2name[x.m_target_id] = std::string(x.m_name);
19281928
}
19291929

1930-
void visit_GoToTarget(const ASR::GoToTarget_t & /* x */) {
1931-
// Ignore for now
1932-
src = "";
1930+
void visit_GoToTarget(const ASR::GoToTarget_t &x) {
1931+
src = std::string(x.m_name) + ":\n";
19331932
}
19341933

19351934
void visit_Stop(const ASR::Stop_t &x) {

src/libasr/pass/pass_manager.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ namespace LCompilers {
200200
// appropriately in C backend.
201201
_c_skip_passes = {
202202
"pass_list_expr",
203-
"print_list_tuple"
203+
"print_list_tuple",
204+
"do_loops"
204205
};
205206
_user_defined_passes.clear();
206207
}

tests/reference/c-expr_01-28f449f.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"outfile": null,
77
"outfile_hash": null,
88
"stdout": "c-expr_01-28f449f.stdout",
9-
"stdout_hash": "0225fdec50673f9edc47db50d6269f15ccdc41d87057ba70c89a6748",
9+
"stdout_hash": "d7b5564f134e5f2ffaa2a3c502198f6270739d1e30d7a781862b09a5",
1010
"stderr": null,
1111
"stderr_hash": null,
1212
"returncode": 0

tests/reference/c-expr_01-28f449f.stdout

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,30 +36,34 @@ struct dimension_descriptor
3636
};
3737

3838
// Implementations
39-
inline __attribute__((always_inline)) int32_t add(int32_t x, int32_t y)
40-
{
41-
int32_t _lpython_return_variable;
42-
_lpython_return_variable = x + y;
43-
return _lpython_return_variable;
44-
}
45-
46-
inline __attribute__((always_inline)) int32_t and_op(int32_t x, int32_t y)
47-
{
48-
int32_t _lpython_return_variable;
49-
_lpython_return_variable = x&y;
50-
return _lpython_return_variable;
51-
}
52-
5339
void main0()
5440
{
41+
int32_t _lpython_return_variable_add;
42+
int32_t _lpython_return_variable_and_op;
5543
int32_t x;
44+
int32_t x_add;
45+
int32_t x_and_op;
5646
int32_t y;
47+
int32_t y_add;
48+
int32_t y_and_op;
5749
int32_t z;
5850
x = (2 + 3)*5;
59-
y = add(x, 2)*2;
51+
x_add = x;
52+
y_add = 2;
53+
_lpython_return_variable_add = x_add + y_add;
54+
goto __1;
55+
__1: {
56+
}
57+
y = _lpython_return_variable_add*2;
6058
ASSERT(x == 25);
6159
ASSERT(y == 54);
62-
z = and_op(x, y);
60+
x_and_op = x;
61+
y_and_op = y;
62+
_lpython_return_variable_and_op = x_and_op&y_and_op;
63+
goto __2;
64+
__2: {
65+
}
66+
z = _lpython_return_variable_and_op;
6367
ASSERT(z == 16);
6468
}
6569

0 commit comments

Comments
 (0)