Skip to content

Commit 1d7fe9d

Browse files
committed
Using basic_new_heap for assigning elements of symbolic list
1 parent 693afee commit 1d7fe9d

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

integration_tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,7 @@ RUN(NAME symbolics_12 LABELS cpython_sym c_sym llvm_sym NOFAST)
720720
RUN(NAME symbolics_13 LABELS cpython_sym c_sym llvm_sym NOFAST)
721721
RUN(NAME symbolics_14 LABELS cpython_sym llvm_sym NOFAST)
722722
RUN(NAME test_gruntz LABELS cpython_sym c_sym llvm_sym NOFAST)
723+
RUN(NAME symbolics_15 LABELS c_sym llvm_sym NOFAST)
723724

724725
RUN(NAME sizeof_01 LABELS llvm c
725726
EXTRAFILES sizeof_01b.c)

integration_tests/symbolics_15.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
from lpython import ccall, CPtr, p_c_pointer, pointer, i64, empty_c_void_p, Out
2+
import os
3+
4+
@ccall(header="symengine/cwrapper.h", c_shared_lib="symengine", c_shared_lib_path=f"{os.environ['CONDA_PREFIX']}/lib")
5+
def basic_new_stack(x: CPtr) -> None:
6+
pass
7+
8+
@ccall(header="symengine/cwrapper.h", c_shared_lib="symengine", c_shared_lib_path=f"{os.environ['CONDA_PREFIX']}/lib")
9+
def basic_new_heap() -> CPtr:
10+
pass
11+
12+
@ccall(header="symengine/cwrapper.h", c_shared_lib="symengine", c_shared_lib_path=f"{os.environ['CONDA_PREFIX']}/lib")
13+
def basic_const_pi(x: CPtr) -> None:
14+
pass
15+
16+
@ccall(header="symengine/cwrapper.h", c_shared_lib="symengine", c_shared_lib_path=f"{os.environ['CONDA_PREFIX']}/lib")
17+
def basic_assign(x: CPtr, y:CPtr) -> None:
18+
pass
19+
20+
@ccall(header="symengine/cwrapper.h", c_shared_lib="symengine", c_shared_lib_path=f"{os.environ['CONDA_PREFIX']}/lib")
21+
def basic_str(x: CPtr) -> str:
22+
pass
23+
24+
def mmrv(r: Out[list[CPtr]]) -> None:
25+
# x: S = pi
26+
x: CPtr = basic_new_heap()
27+
basic_const_pi(x)
28+
29+
# l1: list[S]
30+
l1: list[CPtr] = []
31+
32+
# l1 = [x]
33+
i: i32 = 0
34+
Len: i32 = 1
35+
for i in range(Len):
36+
tmp: CPtr = basic_new_heap()
37+
l1.append(tmp)
38+
basic_assign(l1[0], x)
39+
40+
# print(l1[0])
41+
s1: str = basic_str(l1[0])
42+
print(s1)
43+
assert s1 == "pi"
44+
45+
# r = l1
46+
r = l1
47+
48+
def test_mrv():
49+
# ans : list[S]
50+
# temp : list[S]
51+
ans: list[CPtr] = []
52+
temp: list[CPtr] = []
53+
54+
# mmrv(ans)
55+
# temp = ans
56+
mmrv(ans)
57+
temp = ans
58+
59+
# print(temp[0])
60+
s2: str = basic_str(temp[0])
61+
print(s2)
62+
assert s2 == "pi"
63+
64+
test_mrv()

0 commit comments

Comments
 (0)