Skip to content

Commit dce819f

Browse files
authored
Merge pull request #1292 from czgdp1807/struct_ref
Fixes for `Struct` and `StructInstanceMember` use cases
2 parents ce4612d + e35af7d commit dce819f

13 files changed

+118
-18
lines changed

integration_tests/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,9 @@ RUN(NAME structs_07 LABELS llvm c
312312
RUN(NAME structs_08 LABELS cpython llvm c)
313313
RUN(NAME structs_09 LABELS cpython llvm c)
314314
RUN(NAME structs_10 LABELS cpython llvm c)
315+
RUN(NAME structs_12 LABELS cpython llvm c)
316+
RUN(NAME structs_13 LABELS llvm c
317+
EXTRAFILES structs_13b.c)
315318
RUN(NAME sizeof_01 LABELS llvm c
316319
EXTRAFILES sizeof_01b.c)
317320
RUN(NAME enum_01 LABELS cpython llvm c)

integration_tests/structs_12.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from ltypes import i32, i16, dataclass
2+
3+
@dataclass
4+
class A:
5+
x: i32
6+
y: i16
7+
8+
def add_A_members(Ax: i32, Ay: i16) -> i32:
9+
return Ax + i32(Ay)
10+
11+
def test_A_member_passing():
12+
a: A = A(0, i16(1))
13+
sum_A_members: i32 = add_A_members(a.x, a.y)
14+
print(sum_A_members)
15+
assert sum_A_members == 1
16+
17+
test_A_member_passing()

integration_tests/structs_13.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from ltypes import i32, i16, i64, CPtr, dataclass, ccall, Pointer, c_p_pointer
2+
3+
@dataclass
4+
class A:
5+
x: i32
6+
y: i16
7+
8+
@ccall
9+
def cmalloc(size: i64) -> CPtr:
10+
pass
11+
12+
@ccall
13+
def is_null(ptr: CPtr) -> i32:
14+
pass
15+
16+
def add_A_members(Ax: i32, Ay: i16) -> i32:
17+
return Ax + i32(Ay)
18+
19+
def test_A_member_passing():
20+
array_cptr: CPtr = cmalloc(sizeof(A) * i64(10))
21+
assert not bool(is_null(array_cptr)), "Failed to allocate array on memory"
22+
array_ptr: Pointer[A[:]]
23+
c_p_pointer(array_cptr, array_ptr)
24+
i: i32; sum_A_members: i32
25+
for i in range(10):
26+
array_ptr[i] = A(i, i16(i + 1))
27+
28+
for i in range(5):
29+
a: A = array_ptr[i]
30+
sum_A_members = add_A_members(a.x, a.y)
31+
assert a.x == i
32+
assert a.y == i16(i + 1)
33+
print(sum_A_members)
34+
assert sum_A_members == 2*i + 1
35+
36+
for i in range(6, 10):
37+
sum_A_members = add_A_members(array_ptr[i].x, array_ptr[i].y)
38+
assert array_ptr[i].x == i
39+
assert array_ptr[i].y == i16(i + 1)
40+
print(sum_A_members)
41+
assert sum_A_members == 2*i + 1
42+
43+
test_A_member_passing()

integration_tests/structs_13b.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include <stdlib.h>
2+
3+
void* cmalloc(int64_t size) {
4+
return malloc(size);
5+
}
6+
7+
int32_t is_null(void* ptr) {
8+
return ptr == NULL;
9+
}

integration_tests/structs_13b.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#include <inttypes.h>
2+
3+
void* cmalloc(int64_t size);
4+
int32_t is_null(void* ptr);

src/libasr/codegen/asr_to_c.cpp

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,14 @@ class ASRToCVisitor : public BaseCCPPVisitor<ASRToCVisitor>
205205
ASR::ttype_t* element_type, bool& is_fixed_size,
206206
bool convert_to_1d=false)
207207
{
208-
std::string dims;
208+
std::string dims = "";
209209
size_t size = 1;
210210
std::string array_size = "";
211211
for (size_t i=0; i<n_dims; i++) {
212212
ASR::expr_t *length = m_dims[i].m_length;
213213
if (!length) {
214-
dims += "*";
214+
is_fixed_size = false;
215+
return dims;
215216
} else {
216217
visit_expr(*length);
217218
array_size += "*" + src;
@@ -285,7 +286,11 @@ class ASRToCVisitor : public BaseCCPPVisitor<ASRToCVisitor>
285286
if( !is_fixed_size ) {
286287
sub += indent + format_type_c("*", type_name_copy, std::string(v_m_name) + "_data",
287288
use_ref, dummy);
288-
sub += " = " + dims + ";\n";
289+
if( dims.size() > 0 ) {
290+
sub += " = " + dims + ";\n";
291+
} else {
292+
sub += ";\n";
293+
}
289294
} else {
290295
sub += indent + format_type_c(dims, type_name_copy, std::string(v_m_name) + "_data",
291296
use_ref, dummy) + ";\n";
@@ -360,14 +365,25 @@ class ASRToCVisitor : public BaseCCPPVisitor<ASRToCVisitor>
360365
} else if(ASR::is_a<ASR::Struct_t>(*t2)) {
361366
ASR::Struct_t *t = ASR::down_cast<ASR::Struct_t>(t2);
362367
std::string der_type_name = ASRUtils::symbol_name(t->m_derived_type);
363-
bool is_fixed_size = true;
364-
std::string dims = convert_dims_c(t->n_dims, t->m_dims, v_m_type, is_fixed_size);
365-
std::string ptr_char = "*";
366-
if( !use_ptr_for_derived_type ) {
367-
ptr_char.clear();
368+
if( is_array ) {
369+
bool is_fixed_size = true;
370+
std::string dims = convert_dims_c(t->n_dims, t->m_dims, v_m_type, is_fixed_size, true);
371+
std::string encoded_type_name = "x" + der_type_name;
372+
std::string type_name = std::string("struct ") + der_type_name;
373+
generate_array_decl(sub, std::string(v.m_name), type_name, dims,
374+
encoded_type_name, t->m_dims, t->n_dims,
375+
use_ref, dummy,
376+
v.m_intent != ASRUtils::intent_in &&
377+
v.m_intent != ASRUtils::intent_inout,
378+
is_fixed_size);
379+
} else {
380+
std::string ptr_char = "*";
381+
if( !use_ptr_for_derived_type ) {
382+
ptr_char.clear();
383+
}
384+
sub = format_type_c("", "struct " + der_type_name + ptr_char,
385+
v.m_name, use_ref, dummy);
368386
}
369-
sub = format_type_c(dims, "struct " + der_type_name + ptr_char,
370-
v.m_name, use_ref, dummy);
371387
} else if(ASR::is_a<ASR::CPtr_t>(*t2)) {
372388
sub = format_type_c("", "void**", v.m_name, false, false);
373389
} else {

src/libasr/codegen/asr_to_llvm.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,8 +1685,9 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
16851685
llvm::Value* array = nullptr;
16861686
if( ASR::is_a<ASR::Var_t>(*x.m_v) ) {
16871687
ASR::Variable_t *v = ASRUtils::EXPR2VAR(x.m_v);
1688-
if( ASR::is_a<ASR::Struct_t>(*v->m_type) ) {
1689-
ASR::Struct_t* der_type = ASR::down_cast<ASR::Struct_t>(v->m_type);
1688+
if( ASR::is_a<ASR::Struct_t>(*ASRUtils::get_contained_type(v->m_type)) ) {
1689+
ASR::Struct_t* der_type = ASR::down_cast<ASR::Struct_t>(
1690+
ASRUtils::get_contained_type(v->m_type));
16901691
der_type_name = ASRUtils::symbol_name(ASRUtils::symbol_get_past_external(der_type->m_derived_type));
16911692
}
16921693
uint32_t v_h = get_hash((ASR::asr_t*)v);
@@ -5968,7 +5969,8 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
59685969
builder0.SetInsertPoint(&entry_block, entry_block.getFirstInsertionPt());
59695970
llvm::AllocaInst *target = builder0.CreateAlloca(
59705971
target_type, nullptr, "call_arg_value");
5971-
if( ASR::is_a<ASR::ArrayItem_t>(*x.m_args[i].m_value) ) {
5972+
if( ASR::is_a<ASR::ArrayItem_t>(*x.m_args[i].m_value) ||
5973+
ASR::is_a<ASR::StructInstanceMember_t>(*x.m_args[i].m_value) ) {
59725974
value = CreateLoad(value);
59735975
}
59745976
if( ASR::is_a<ASR::Tuple_t>(*arg_type) ||

src/libasr/pass/pass_utils.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,12 @@ namespace LFortran {
180180
}
181181
}
182182

183+
void visit_DoLoop(const ASR::DoLoop_t& x) {
184+
self().visit_do_loop_head(x.m_head);
185+
ASR::DoLoop_t& xx = const_cast<ASR::DoLoop_t&>(x);
186+
transform_stmts(xx.m_body, xx.n_body);
187+
}
188+
183189
};
184190

185191
template <class Struct>

src/lpython/semantics/python_ast_to_asr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3082,7 +3082,7 @@ class CommonVisitor : public AST::BaseVisitor<Struct> {
30823082
if( is_item ) {
30833083
Vec<ASR::dimension_t> empty_dims;
30843084
empty_dims.reserve(al, 1);
3085-
type = ASRUtils::duplicate_type(al, type, &empty_dims);
3085+
type = ASRUtils::duplicate_type(al, ASRUtils::type_get_past_pointer(type), &empty_dims);
30863086
tmp = ASR::make_ArrayItem_t(al, x.base.base.loc, v_Var, args.p,
30873087
args.size(), type, ASR::arraystorageType::RowMajor, nullptr);
30883088
} else {

tests/reference/asr-bindc_02-bc1a7ea.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": "asr-bindc_02-bc1a7ea.stdout",
9-
"stdout_hash": "cb68f1c64e50e326c38c102f0dc26a26274be2f4f9d1423658fa0ad4",
9+
"stdout_hash": "3165b2da8871ec50f1243662d58fe93d7b92c3166ef180eca07d2152",
1010
"stderr": null,
1111
"stderr_hash": null,
1212
"returncode": 0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
(TranslationUnit (SymbolTable 1 {_lpython_main_program: (Function (SymbolTable 4 {}) _lpython_main_program [f] [] [(CPtrToPointer (Var 1 queries) (Var 1 x) ()) (Print () [(Var 1 queries) (Var 1 x)] () ()) (SubroutineCall 1 f () [] ())] () Source Public Implementation () .false. .false. .false. .false. .false. [] [] .false.), f: (Function (SymbolTable 2 {y: (Variable 2 y Local () () Default (Integer 2 [((IntegerConstant 0 (Integer 4 [])) (IntegerConstant 2 (Integer 4 [])))]) Source Public Required .false.), yptr1: (Variable 2 yptr1 Local () () Default (Pointer (Integer 2 [(() ())])) Source Public Required .false.), yq: (Variable 2 yq Local () () Default (CPtr) Source Public Required .false.)}) f [] [] [(= (ArrayItem (Var 2 y) [(() (IntegerConstant 0 (Integer 4 [])) ())] (Integer 2 []) RowMajor ()) (Cast (IntegerConstant 1 (Integer 4 [])) IntegerToInteger (Integer 2 []) (IntegerConstant 1 (Integer 2 []))) ()) (= (ArrayItem (Var 2 y) [(() (IntegerConstant 1 (Integer 4 [])) ())] (Integer 2 []) RowMajor ()) (Cast (IntegerConstant 2 (Integer 4 [])) IntegerToInteger (Integer 2 []) (IntegerConstant 2 (Integer 2 []))) ()) (= (Var 2 yptr1) (GetPointer (Var 2 y) (Pointer (Integer 2 [((IntegerConstant 0 (Integer 4 [])) (IntegerConstant 2 (Integer 4 [])))])) ()) ()) (Print () [(GetPointer (Var 2 y) (Pointer (Integer 2 [((IntegerConstant 0 (Integer 4 [])) (IntegerConstant 2 (Integer 4 [])))])) ()) (Var 2 yptr1)] () ()) (Print () [(ArrayItem (Var 2 yptr1) [(() (IntegerConstant 0 (Integer 4 [])) ())] (Pointer (Integer 2 [])) RowMajor ()) (ArrayItem (Var 2 yptr1) [(() (IntegerConstant 1 (Integer 4 [])) ())] (Pointer (Integer 2 [])) RowMajor ())] () ()) (Assert (IntegerCompare (ArrayItem (Var 2 yptr1) [(() (IntegerConstant 0 (Integer 4 [])) ())] (Pointer (Integer 2 [])) RowMajor ()) Eq (Cast (IntegerConstant 1 (Integer 4 [])) IntegerToInteger (Integer 2 []) (IntegerConstant 1 (Integer 2 []))) (Logical 4 []) ()) ()) (Assert (IntegerCompare (ArrayItem (Var 2 yptr1) [(() (IntegerConstant 1 (Integer 4 [])) ())] (Pointer (Integer 2 [])) RowMajor ()) Eq (Cast (IntegerConstant 2 (Integer 4 [])) IntegerToInteger (Integer 2 []) (IntegerConstant 2 (Integer 2 []))) (Logical 4 []) ()) ()) (CPtrToPointer (Var 2 yq) (Var 2 yptr1) ()) (Print () [(Var 2 yq) (Var 2 yptr1)] () ())] () Source Public Implementation () .false. .false. .false. .false. .false. [] [] .false.), main_program: (Program (SymbolTable 3 {}) main_program [] [(SubroutineCall 1 _lpython_main_program () [] ())]), queries: (Variable 1 queries Local () () Default (CPtr) Source Public Required .false.), x: (Variable 1 x Local () () Default (Pointer (Integer 2 [(() ())])) Source Public Required .false.)}) [])
1+
(TranslationUnit (SymbolTable 1 {_lpython_main_program: (Function (SymbolTable 4 {}) _lpython_main_program [f] [] [(CPtrToPointer (Var 1 queries) (Var 1 x) ()) (Print () [(Var 1 queries) (Var 1 x)] () ()) (SubroutineCall 1 f () [] ())] () Source Public Implementation () .false. .false. .false. .false. .false. [] [] .false.), f: (Function (SymbolTable 2 {y: (Variable 2 y Local () () Default (Integer 2 [((IntegerConstant 0 (Integer 4 [])) (IntegerConstant 2 (Integer 4 [])))]) Source Public Required .false.), yptr1: (Variable 2 yptr1 Local () () Default (Pointer (Integer 2 [(() ())])) Source Public Required .false.), yq: (Variable 2 yq Local () () Default (CPtr) Source Public Required .false.)}) f [] [] [(= (ArrayItem (Var 2 y) [(() (IntegerConstant 0 (Integer 4 [])) ())] (Integer 2 []) RowMajor ()) (Cast (IntegerConstant 1 (Integer 4 [])) IntegerToInteger (Integer 2 []) (IntegerConstant 1 (Integer 2 []))) ()) (= (ArrayItem (Var 2 y) [(() (IntegerConstant 1 (Integer 4 [])) ())] (Integer 2 []) RowMajor ()) (Cast (IntegerConstant 2 (Integer 4 [])) IntegerToInteger (Integer 2 []) (IntegerConstant 2 (Integer 2 []))) ()) (= (Var 2 yptr1) (GetPointer (Var 2 y) (Pointer (Integer 2 [((IntegerConstant 0 (Integer 4 [])) (IntegerConstant 2 (Integer 4 [])))])) ()) ()) (Print () [(GetPointer (Var 2 y) (Pointer (Integer 2 [((IntegerConstant 0 (Integer 4 [])) (IntegerConstant 2 (Integer 4 [])))])) ()) (Var 2 yptr1)] () ()) (Print () [(ArrayItem (Var 2 yptr1) [(() (IntegerConstant 0 (Integer 4 [])) ())] (Integer 2 []) RowMajor ()) (ArrayItem (Var 2 yptr1) [(() (IntegerConstant 1 (Integer 4 [])) ())] (Integer 2 []) RowMajor ())] () ()) (Assert (IntegerCompare (ArrayItem (Var 2 yptr1) [(() (IntegerConstant 0 (Integer 4 [])) ())] (Integer 2 []) RowMajor ()) Eq (Cast (IntegerConstant 1 (Integer 4 [])) IntegerToInteger (Integer 2 []) (IntegerConstant 1 (Integer 2 []))) (Logical 4 []) ()) ()) (Assert (IntegerCompare (ArrayItem (Var 2 yptr1) [(() (IntegerConstant 1 (Integer 4 [])) ())] (Integer 2 []) RowMajor ()) Eq (Cast (IntegerConstant 2 (Integer 4 [])) IntegerToInteger (Integer 2 []) (IntegerConstant 2 (Integer 2 []))) (Logical 4 []) ()) ()) (CPtrToPointer (Var 2 yq) (Var 2 yptr1) ()) (Print () [(Var 2 yq) (Var 2 yptr1)] () ())] () Source Public Implementation () .false. .false. .false. .false. .false. [] [] .false.), main_program: (Program (SymbolTable 3 {}) main_program [] [(SubroutineCall 1 _lpython_main_program () [] ())]), queries: (Variable 1 queries Local () () Default (CPtr) Source Public Required .false.), x: (Variable 1 x Local () () Default (Pointer (Integer 2 [(() ())])) Source Public Required .false.)}) [])

tests/reference/asr-expr_12-6769be0.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": "asr-expr_12-6769be0.stdout",
9-
"stdout_hash": "6a3e6336c777defb05cb3c6c244ed20468ea29c584a8bf5c9f311122",
9+
"stdout_hash": "90152a321955a2c86da3e2036530feea66c16f9c4057cfcd8c92113e",
1010
"stderr": null,
1111
"stderr_hash": null,
1212
"returncode": 0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
(TranslationUnit (SymbolTable 1 {_lpython_main_program: (Function (SymbolTable 6 {}) _lpython_main_program [f] [] [(SubroutineCall 1 f () [] ())] () Source Public Implementation () .false. .false. .false. .false. .false. [] [] .false.), check: (Function (SymbolTable 3 {ptr: (Variable 3 ptr InOut () () Default (Pointer (Integer 2 [(() ())])) Source Public Required .false.)}) check [] [(Var 3 ptr)] [(Assert (IntegerCompare (ArrayItem (Var 3 ptr) [(() (IntegerConstant 0 (Integer 4 [])) ())] (Pointer (Integer 2 [])) RowMajor ()) Eq (Cast (IntegerConstant 1 (Integer 4 [])) IntegerToInteger (Integer 2 []) (IntegerConstant 1 (Integer 2 []))) (Logical 4 []) ()) ()) (Assert (IntegerCompare (ArrayItem (Var 3 ptr) [(() (IntegerConstant 1 (Integer 4 [])) ())] (Pointer (Integer 2 [])) RowMajor ()) Eq (Cast (IntegerConstant 2 (Integer 4 [])) IntegerToInteger (Integer 2 []) (IntegerConstant 2 (Integer 2 []))) (Logical 4 []) ()) ())] () Source Public Implementation () .false. .false. .false. .false. .false. [] [] .false.), f: (Function (SymbolTable 4 {y: (Variable 4 y Local () () Default (Integer 2 [((IntegerConstant 0 (Integer 4 [])) (IntegerConstant 2 (Integer 4 [])))]) Source Public Required .false.), yptr1: (Variable 4 yptr1 Local () () Default (Pointer (Integer 2 [(() ())])) Source Public Required .false.)}) f [g check] [] [(SubroutineCall 1 g () [((Var 4 yptr1)) ((Var 4 y))] ()) (SubroutineCall 1 check () [((Var 4 yptr1))] ())] () Source Public Implementation () .false. .false. .false. .false. .false. [] [] .false.), g: (Function (SymbolTable 2 {x: (Variable 2 x InOut () () Default (Pointer (Integer 2 [(() ())])) Source Public Required .false.), y: (Variable 2 y InOut () () Default (Integer 2 [(() ())]) Source Public Required .false.)}) g [] [(Var 2 x) (Var 2 y)] [(= (ArrayItem (Var 2 y) [(() (IntegerConstant 0 (Integer 4 [])) ())] (Integer 2 []) RowMajor ()) (Cast (IntegerConstant 1 (Integer 4 [])) IntegerToInteger (Integer 2 []) (IntegerConstant 1 (Integer 2 []))) ()) (= (ArrayItem (Var 2 y) [(() (IntegerConstant 1 (Integer 4 [])) ())] (Integer 2 []) RowMajor ()) (Cast (IntegerConstant 2 (Integer 4 [])) IntegerToInteger (Integer 2 []) (IntegerConstant 2 (Integer 2 []))) ()) (= (Var 2 x) (GetPointer (Var 2 y) (Pointer (Integer 2 [(() ())])) ()) ()) (Print () [(ArrayItem (Var 2 x) [(() (IntegerConstant 0 (Integer 4 [])) ())] (Pointer (Integer 2 [])) RowMajor ()) (ArrayItem (Var 2 x) [(() (IntegerConstant 1 (Integer 4 [])) ())] (Pointer (Integer 2 [])) RowMajor ())] () ())] () Source Public Implementation () .false. .false. .false. .false. .false. [] [] .false.), main_program: (Program (SymbolTable 5 {}) main_program [] [(SubroutineCall 1 _lpython_main_program () [] ())])}) [])
1+
(TranslationUnit (SymbolTable 1 {_lpython_main_program: (Function (SymbolTable 6 {}) _lpython_main_program [f] [] [(SubroutineCall 1 f () [] ())] () Source Public Implementation () .false. .false. .false. .false. .false. [] [] .false.), check: (Function (SymbolTable 3 {ptr: (Variable 3 ptr InOut () () Default (Pointer (Integer 2 [(() ())])) Source Public Required .false.)}) check [] [(Var 3 ptr)] [(Assert (IntegerCompare (ArrayItem (Var 3 ptr) [(() (IntegerConstant 0 (Integer 4 [])) ())] (Integer 2 []) RowMajor ()) Eq (Cast (IntegerConstant 1 (Integer 4 [])) IntegerToInteger (Integer 2 []) (IntegerConstant 1 (Integer 2 []))) (Logical 4 []) ()) ()) (Assert (IntegerCompare (ArrayItem (Var 3 ptr) [(() (IntegerConstant 1 (Integer 4 [])) ())] (Integer 2 []) RowMajor ()) Eq (Cast (IntegerConstant 2 (Integer 4 [])) IntegerToInteger (Integer 2 []) (IntegerConstant 2 (Integer 2 []))) (Logical 4 []) ()) ())] () Source Public Implementation () .false. .false. .false. .false. .false. [] [] .false.), f: (Function (SymbolTable 4 {y: (Variable 4 y Local () () Default (Integer 2 [((IntegerConstant 0 (Integer 4 [])) (IntegerConstant 2 (Integer 4 [])))]) Source Public Required .false.), yptr1: (Variable 4 yptr1 Local () () Default (Pointer (Integer 2 [(() ())])) Source Public Required .false.)}) f [g check] [] [(SubroutineCall 1 g () [((Var 4 yptr1)) ((Var 4 y))] ()) (SubroutineCall 1 check () [((Var 4 yptr1))] ())] () Source Public Implementation () .false. .false. .false. .false. .false. [] [] .false.), g: (Function (SymbolTable 2 {x: (Variable 2 x InOut () () Default (Pointer (Integer 2 [(() ())])) Source Public Required .false.), y: (Variable 2 y InOut () () Default (Integer 2 [(() ())]) Source Public Required .false.)}) g [] [(Var 2 x) (Var 2 y)] [(= (ArrayItem (Var 2 y) [(() (IntegerConstant 0 (Integer 4 [])) ())] (Integer 2 []) RowMajor ()) (Cast (IntegerConstant 1 (Integer 4 [])) IntegerToInteger (Integer 2 []) (IntegerConstant 1 (Integer 2 []))) ()) (= (ArrayItem (Var 2 y) [(() (IntegerConstant 1 (Integer 4 [])) ())] (Integer 2 []) RowMajor ()) (Cast (IntegerConstant 2 (Integer 4 [])) IntegerToInteger (Integer 2 []) (IntegerConstant 2 (Integer 2 []))) ()) (= (Var 2 x) (GetPointer (Var 2 y) (Pointer (Integer 2 [(() ())])) ()) ()) (Print () [(ArrayItem (Var 2 x) [(() (IntegerConstant 0 (Integer 4 [])) ())] (Integer 2 []) RowMajor ()) (ArrayItem (Var 2 x) [(() (IntegerConstant 1 (Integer 4 [])) ())] (Integer 2 []) RowMajor ())] () ())] () Source Public Implementation () .false. .false. .false. .false. .false. [] [] .false.), main_program: (Program (SymbolTable 5 {}) main_program [] [(SubroutineCall 1 _lpython_main_program () [] ())])}) [])

0 commit comments

Comments
 (0)