Skip to content

Commit c6626b4

Browse files
authored
Merge pull request #1134 from czgdp1807/enum03
Support automatic value assignment to Enum members Improve compile time value creation for casting
2 parents fae10c3 + f5ab8a5 commit c6626b4

File tree

54 files changed

+196
-87
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+196
-87
lines changed

integration_tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ RUN(NAME structs_05 LABELS llvm c)
252252
RUN(NAME enum_01 LABELS cpython llvm c)
253253
RUN(NAME enum_02 LABELS cpython llvm)
254254
RUN(NAME enum_03 LABELS cpython llvm c)
255+
RUN(NAME enum_04 LABELS cpython llvm c)
255256
RUN(NAME union_01 LABELS cpython llvm c)
256257
RUN(NAME union_02 LABELS llvm c)
257258
RUN(NAME union_03 LABELS cpython llvm c)

integration_tests/enum_04.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
from ltypes import i32
2+
from enum import Enum, auto
3+
4+
class Color(Enum):
5+
RED: i32 = auto()
6+
GREEN: i32 = auto()
7+
BLUE: i32 = 7
8+
YELLOW: i32 = auto()
9+
WHITE: i32 = auto()
10+
PINK: i32 = 15
11+
GREY: i32 = auto()
12+
13+
class Integers(Enum):
14+
a: i32 = -5
15+
b: i32 = auto()
16+
c: i32 = auto()
17+
d: i32 = 0
18+
e: i32 = auto()
19+
f: i32 = 7
20+
g: i32 = auto()
21+
22+
def test_color_enum():
23+
print(Color.RED.value, Color.RED.name)
24+
print(Color.GREEN.value, Color.GREEN.name)
25+
print(Color.BLUE.value, Color.BLUE.name)
26+
print(Color.YELLOW.value, Color.YELLOW.name)
27+
print(Color.WHITE.value, Color.WHITE.name)
28+
print(Color.PINK.value, Color.PINK.name)
29+
print(Color.GREY.value, Color.GREY.name)
30+
assert Color.RED.value == 1
31+
assert Color.GREEN.value == 2
32+
assert Color.BLUE.value == 7
33+
assert Color.YELLOW.value == 8
34+
assert Color.WHITE.value == 9
35+
assert Color.PINK.value == 15
36+
assert Color.GREY.value == 16
37+
38+
def test_selected_color(selected_color: Color):
39+
color: Color
40+
color = Color(selected_color)
41+
assert color == Color.YELLOW
42+
print(color.name, color.value)
43+
44+
def test_integer(integer: Integers, value: i32):
45+
assert integer.value == value
46+
47+
def test_integers():
48+
print(Integers.a.name, Integers.a.value)
49+
test_integer(Integers.a, -5)
50+
51+
print(Integers.b.name, Integers.b.value)
52+
test_integer(Integers.b, -4)
53+
54+
print(Integers.c.name, Integers.c.value)
55+
test_integer(Integers.c, -3)
56+
57+
print(Integers.d.name, Integers.d.value)
58+
test_integer(Integers.d, 0)
59+
60+
print(Integers.e.name, Integers.e.value)
61+
test_integer(Integers.e, 1)
62+
63+
print(Integers.f.name, Integers.f.value)
64+
test_integer(Integers.f, 7)
65+
66+
print(Integers.g.name, Integers.g.value)
67+
test_integer(Integers.g, 8)
68+
69+
test_color_enum()
70+
test_selected_color(Color.YELLOW)
71+
test_integers()

src/libasr/asr_utils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -892,9 +892,9 @@ ASR::asr_t* make_Cast_t_value(Allocator &al, const Location &a_loc,
892892
value = ASR::down_cast<ASR::expr_t>(ASR::make_ComplexConstant_t(al, a_loc,
893893
(double)int_value, 0, a_type));
894894
} else if (a_kind == ASR::cast_kindType::IntegerToInteger) {
895-
// TODO: implement
896-
// int64_t v = ASR::down_cast<ASR::ConstantInteger_t>(ASRUtils::expr_value(a_arg))->m_n;
897-
// value = ASR::down_cast<ASR::expr_t>(ASR::make_ConstantInteger_t(al, a_loc, v, a_type));
895+
int64_t int_value = ASR::down_cast<ASR::IntegerConstant_t>(
896+
ASRUtils::expr_value(a_arg))->m_n;
897+
value = ASR::down_cast<ASR::expr_t>(ASR::make_IntegerConstant_t(al, a_loc, int_value, a_type));
898898
} else if (a_kind == ASR::cast_kindType::IntegerToLogical) {
899899
// TODO: implement
900900
} else if (a_kind == ASR::cast_kindType::ComplexToComplex) {

src/libasr/codegen/asr_to_c.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ R"(
634634
ASR::EnumType_t* enum_type = ASRUtils::get_EnumType_from_symbol(x.m_v);
635635
for( auto itr: enum_type->m_symtab->get_scope() ) {
636636
ASR::Variable_t* itr_var = ASR::down_cast<ASR::Variable_t>(itr.second);
637-
ASR::expr_t* value = itr_var->m_symbolic_value;
637+
ASR::expr_t* value = ASRUtils::expr_value(itr_var->m_symbolic_value);
638638
int64_t value_int64 = -1;
639639
ASRUtils::extract_value(value, value_int64);
640640
min_value = std::min(value_int64, min_value);

src/libasr/codegen/asr_to_llvm.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1737,7 +1737,7 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
17371737

17381738
for( auto itr: enum_type->m_symtab->get_scope() ) {
17391739
ASR::Variable_t* itr_var = ASR::down_cast<ASR::Variable_t>(itr.second);
1740-
ASR::expr_t* value = itr_var->m_symbolic_value;
1740+
ASR::expr_t* value = ASRUtils::expr_value(itr_var->m_symbolic_value);
17411741
int64_t value_int64 = -1;
17421742
ASRUtils::extract_value(value, value_int64);
17431743
min_value = std::min(value_int64, min_value);
@@ -4442,6 +4442,14 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
44424442
int a_kind = ((ASR::Integer_t*)(&(x.m_type->base)))->m_kind;
44434443
switch( a_kind ) {
44444444

4445+
case 1: {
4446+
tmp = llvm::ConstantInt::get(context, llvm::APInt(8, val, true));
4447+
break ;
4448+
}
4449+
case 2: {
4450+
tmp = llvm::ConstantInt::get(context, llvm::APInt(16, val, true));
4451+
break ;
4452+
}
44454453
case 4 : {
44464454
tmp = llvm::ConstantInt::get(context, llvm::APInt(32, static_cast<int32_t>(val), true));
44474455
break;
@@ -4451,7 +4459,8 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
44514459
break;
44524460
}
44534461
default : {
4454-
break;
4462+
throw CodeGenError("Constant integers of " + std::to_string(a_kind)
4463+
+ " bytes aren't supported yet.");
44554464
}
44564465

44574466
}

src/lpython/semantics/python_ast_to_asr.cpp

Lines changed: 60 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1888,7 +1888,8 @@ class CommonVisitor : public AST::BaseVisitor<Derived> {
18881888
}
18891889

18901890
void visit_AnnAssignUtil(const AST::AnnAssign_t& x, std::string& var_name,
1891-
bool wrap_derived_type_in_pointer=false) {
1891+
bool wrap_derived_type_in_pointer=false,
1892+
ASR::expr_t* init_expr=nullptr) {
18921893
ASR::ttype_t *type = ast_expr_to_asr_type(x.base.base.loc, *x.m_annotation);
18931894
ASR::ttype_t* ann_assign_target_type_copy = ann_assign_target_type;
18941895
ann_assign_target_type = type;
@@ -1898,33 +1899,36 @@ class CommonVisitor : public AST::BaseVisitor<Derived> {
18981899
}
18991900

19001901
ASR::expr_t *value = nullptr;
1901-
ASR::expr_t *init_expr = nullptr;
1902-
tmp = nullptr;
1903-
if (x.m_value) {
1904-
this->visit_expr(*x.m_value);
1905-
}
1906-
if (tmp) {
1907-
value = ASRUtils::EXPR(tmp);
1908-
cast_helper(type, value);
1909-
if (!ASRUtils::check_equal_type(type, ASRUtils::expr_type(value))) {
1910-
std::string ltype = ASRUtils::type_to_str_python(type);
1911-
std::string rtype = ASRUtils::type_to_str_python(ASRUtils::expr_type(value));
1912-
diag.add(diag::Diagnostic(
1913-
"Type mismatch in annotation-assignment, the types must be compatible",
1914-
diag::Level::Error, diag::Stage::Semantic, {
1915-
diag::Label("type mismatch ('" + ltype + "' and '" + rtype + "')",
1916-
{x.m_target->base.loc, value->base.loc})
1917-
})
1918-
);
1919-
throw SemanticAbort();
1902+
if( !init_expr ) {
1903+
tmp = nullptr;
1904+
if (x.m_value) {
1905+
this->visit_expr(*x.m_value);
1906+
}
1907+
if (tmp) {
1908+
value = ASRUtils::EXPR(tmp);
1909+
cast_helper(type, value);
1910+
if (!ASRUtils::check_equal_type(type, ASRUtils::expr_type(value))) {
1911+
std::string ltype = ASRUtils::type_to_str_python(type);
1912+
std::string rtype = ASRUtils::type_to_str_python(ASRUtils::expr_type(value));
1913+
diag.add(diag::Diagnostic(
1914+
"Type mismatch in annotation-assignment, the types must be compatible",
1915+
diag::Level::Error, diag::Stage::Semantic, {
1916+
diag::Label("type mismatch ('" + ltype + "' and '" + rtype + "')",
1917+
{x.m_target->base.loc, value->base.loc})
1918+
})
1919+
);
1920+
throw SemanticAbort();
1921+
}
1922+
init_expr = value;
1923+
// Set compile time to value to nullptr
1924+
// Once constant variables are supported
1925+
// in LPython set value according to the
1926+
// nature of the variable (nullptr if non-constant,
1927+
// otherwise ASRUtils::expr_value(init_expr).
1928+
value = nullptr;
19201929
}
1921-
init_expr = value;
1922-
// Set compile time to value to nullptr
1923-
// Once constant variables are supported
1924-
// in LPython set value according to the
1925-
// nature of the variable (nullptr if non-constant,
1926-
// otherwise ASRUtils::expr_value(init_expr).
1927-
value = nullptr;
1930+
} else {
1931+
cast_helper(type, init_expr);
19281932
}
19291933
create_add_variable_to_scope(var_name, init_expr, value, type,
19301934
x.base.base.loc);
@@ -1933,14 +1937,40 @@ class CommonVisitor : public AST::BaseVisitor<Derived> {
19331937
ann_assign_target_type = ann_assign_target_type_copy;
19341938
}
19351939

1936-
void visit_ClassMembers(const AST::ClassDef_t& x, Vec<char*>& member_names) {
1940+
void visit_ClassMembers(const AST::ClassDef_t& x,
1941+
Vec<char*>& member_names, bool is_enum_scope=false) {
1942+
int64_t prev_value = 1;
19371943
for( size_t i = 0; i < x.n_body; i++ ) {
19381944
LFORTRAN_ASSERT(AST::is_a<AST::AnnAssign_t>(*x.m_body[i]));
19391945
AST::AnnAssign_t* ann_assign = AST::down_cast<AST::AnnAssign_t>(x.m_body[i]);
19401946
LFORTRAN_ASSERT(AST::is_a<AST::Name_t>(*ann_assign->m_target));
19411947
AST::Name_t *n = AST::down_cast<AST::Name_t>(ann_assign->m_target);
19421948
std::string var_name = n->m_id;
1943-
visit_AnnAssignUtil(*ann_assign, var_name, true);
1949+
ASR::expr_t* init_expr = nullptr;
1950+
if( is_enum_scope ) {
1951+
if( AST::is_a<AST::Call_t>(*ann_assign->m_value) ) {
1952+
AST::Call_t* auto_call_cand = AST::down_cast<AST::Call_t>(ann_assign->m_value);
1953+
if( AST::is_a<AST::Name_t>(*auto_call_cand->m_func) ) {
1954+
AST::Name_t* func = AST::down_cast<AST::Name_t>(auto_call_cand->m_func);
1955+
std::string func_name = func->m_id;
1956+
if( func_name == "auto" ) {
1957+
ASR::ttype_t* i64_type = ASRUtils::TYPE(ASR::make_Integer_t(al,
1958+
auto_call_cand->base.base.loc, 8, nullptr, 0));
1959+
init_expr = ASRUtils::EXPR(ASR::make_IntegerConstant_t(al,
1960+
auto_call_cand->base.base.loc, prev_value, i64_type));
1961+
prev_value += 1;
1962+
}
1963+
}
1964+
} else {
1965+
this->visit_expr(*ann_assign->m_value);
1966+
ASR::expr_t* enum_value = ASRUtils::expr_value(ASRUtils::EXPR(tmp));
1967+
LFORTRAN_ASSERT(ASRUtils::is_value_constant(enum_value));
1968+
ASRUtils::extract_value(enum_value, prev_value);
1969+
prev_value += 1;
1970+
init_expr = enum_value;
1971+
}
1972+
}
1973+
visit_AnnAssignUtil(*ann_assign, var_name, true, init_expr);
19441974
member_names.push_back(al, n->m_id);
19451975
}
19461976
}
@@ -1957,7 +1987,7 @@ class CommonVisitor : public AST::BaseVisitor<Derived> {
19571987
member_names.reserve(al, x.n_body);
19581988
Vec<ASR::stmt_t*>* current_body_copy = current_body;
19591989
current_body = nullptr;
1960-
visit_ClassMembers(x, member_names);
1990+
visit_ClassMembers(x, member_names, true);
19611991
current_body = current_body_copy;
19621992
ASR::ttype_t* common_type = nullptr;
19631993
for( auto sym: current_scope->get_scope() ) {

tests/reference/asr-array_01_decl-39cf894.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-array_01_decl-39cf894.stdout",
9-
"stdout_hash": "d1f77e5bef8795bf92a5c4c165376a842450b6ea54080d3c3cb79a4c",
9+
"stdout_hash": "8378aa9234240987eb055e7898f852ed53642e956e9e6a488914fdf2",
1010
"stderr": null,
1111
"stderr_hash": null,
1212
"returncode": 0

tests/reference/asr-array_01_decl-39cf894.stdout

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

tests/reference/asr-array_02_decl-e8f6874.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-array_02_decl-e8f6874.stdout",
9-
"stdout_hash": "583481e0d85588a96f414b6e9dc04533305b8a5500eb0338e9793aac",
9+
"stdout_hash": "bb54e34a2cc77e2c4804c8af2e9e3da6cc41e7a67ec376272f3c1bd5",
1010
"stderr": null,
1111
"stderr_hash": null,
1212
"returncode": 0

tests/reference/asr-array_02_decl-e8f6874.stdout

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

tests/reference/asr-assign2-8d1a2ee.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-assign2-8d1a2ee.stdout",
9-
"stdout_hash": "d7ee39d0d69330a2ce552b3644cac2a5ffb81a240357a948fa90100a",
9+
"stdout_hash": "aee9fc40178cade8234390602acf5453fd24b1820567aadb1c2fbfb2",
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 {f: (Variable 1 f Local (Cast (RealConstant 1.234568 (Real 8 [])) RealToReal (Real 4 []) (RealConstant 1.234568 (Real 4 []))) () Default (Real 4 []) Source Public Required .false.), f2: (Variable 1 f2 Local (RealConstant 1.234568 (Real 8 [])) () Default (Real 8 []) Source Public Required .false.), i: (Variable 1 i Local (IntegerConstant 5 (Integer 4 [])) () Default (Integer 4 []) Source Public Required .false.), i2: (Variable 1 i2 Local (Cast (IntegerConstant 53430903434 (Integer 4 [])) IntegerToInteger (Integer 8 []) ()) () Default (Integer 8 []) Source Public Required .false.), main_program: (Program (SymbolTable 2 {}) main_program [] [])}) [])
1+
(TranslationUnit (SymbolTable 1 {f: (Variable 1 f Local (Cast (RealConstant 1.234568 (Real 8 [])) RealToReal (Real 4 []) (RealConstant 1.234568 (Real 4 []))) () Default (Real 4 []) Source Public Required .false.), f2: (Variable 1 f2 Local (RealConstant 1.234568 (Real 8 [])) () Default (Real 8 []) Source Public Required .false.), i: (Variable 1 i Local (IntegerConstant 5 (Integer 4 [])) () Default (Integer 4 []) Source Public Required .false.), i2: (Variable 1 i2 Local (Cast (IntegerConstant 53430903434 (Integer 4 [])) IntegerToInteger (Integer 8 []) (IntegerConstant 53430903434 (Integer 8 []))) () Default (Integer 8 []) Source Public Required .false.), main_program: (Program (SymbolTable 2 {}) main_program [] [])}) [])

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": "afe649bda32b72684d798daa0af4b72e3633cf0a93ef0b27870c6329",
9+
"stdout_hash": "c2ef3b7dc7709e9b3aa3cc7e9557bd946cb810d123e7e3f46faa84fe",
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 [] [(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.), 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 []) ()) (Cast (IntegerConstant 1 (Integer 4 [])) IntegerToInteger (Integer 2 []) ()) ()) (= (ArrayItem (Var 2 y) [(() (IntegerConstant 1 (Integer 4 [])) ())] (Integer 2 []) ()) (Cast (IntegerConstant 2 (Integer 4 [])) IntegerToInteger (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 [])) ()) (ArrayItem (Var 2 yptr1) [(() (IntegerConstant 1 (Integer 4 [])) ())] (Pointer (Integer 2 [])) ())] () ()) (Assert (IntegerCompare (Cast (ArrayItem (Var 2 yptr1) [(() (IntegerConstant 0 (Integer 4 [])) ())] (Pointer (Integer 2 [])) ()) IntegerToInteger (Integer 4 []) ()) Eq (IntegerConstant 1 (Integer 4 [])) (Logical 4 []) ()) ()) (Assert (IntegerCompare (Cast (ArrayItem (Var 2 yptr1) [(() (IntegerConstant 1 (Integer 4 [])) ())] (Pointer (Integer 2 [])) ()) IntegerToInteger (Integer 4 []) ()) Eq (IntegerConstant 2 (Integer 4 [])) (Logical 4 []) ()) ()) (CPtrToPointer (Var 2 yq) (Var 2 yptr1) ()) (Print () [(Var 2 yq) (Var 2 yptr1)] () ())] () Source Public Implementation () .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 [] [(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.), 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 []) ()) (Cast (IntegerConstant 1 (Integer 4 [])) IntegerToInteger (Integer 2 []) (IntegerConstant 1 (Integer 2 []))) ()) (= (ArrayItem (Var 2 y) [(() (IntegerConstant 1 (Integer 4 [])) ())] (Integer 2 []) ()) (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 [])) ()) (ArrayItem (Var 2 yptr1) [(() (IntegerConstant 1 (Integer 4 [])) ())] (Pointer (Integer 2 [])) ())] () ()) (Assert (IntegerCompare (Cast (ArrayItem (Var 2 yptr1) [(() (IntegerConstant 0 (Integer 4 [])) ())] (Pointer (Integer 2 [])) ()) IntegerToInteger (Integer 4 []) ()) Eq (IntegerConstant 1 (Integer 4 [])) (Logical 4 []) ()) ()) (Assert (IntegerCompare (Cast (ArrayItem (Var 2 yptr1) [(() (IntegerConstant 1 (Integer 4 [])) ())] (Pointer (Integer 2 [])) ()) IntegerToInteger (Integer 4 []) ()) Eq (IntegerConstant 2 (Integer 4 [])) (Logical 4 []) ()) ()) (CPtrToPointer (Var 2 yq) (Var 2 yptr1) ()) (Print () [(Var 2 yq) (Var 2 yptr1)] () ())] () Source Public Implementation () .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-c_interop1-cf2e9b4.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-c_interop1-cf2e9b4.stdout",
9-
"stdout_hash": "eb4596e075f615a27690dc1f5077395cdbecdfdc498ef8c63579ec09",
9+
"stdout_hash": "da6db735e79e5693cf50c3abedc3042964453d4e789db5514c710f9c",
1010
"stderr": null,
1111
"stderr_hash": null,
1212
"returncode": 0

0 commit comments

Comments
 (0)