forked from lcompilers/lpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into pr_type_comment
- Loading branch information
Showing
141 changed files
with
3,507 additions
and
877 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from ltypes import pointer, i16, Pointer | ||
|
||
def g(x: Pointer[i16[:]], y: i16[:]): | ||
y[0] = 1 | ||
y[1] = 2 | ||
x = pointer(y) | ||
print(x[0], x[1]) | ||
|
||
def check(ptr: Pointer[i16[:]]): | ||
assert ptr[0] == 1 | ||
assert ptr[1] == 2 | ||
|
||
def f(): | ||
yptr1: Pointer[i16[:]] | ||
y: i16[2] | ||
g(yptr1, y) | ||
check(yptr1) | ||
|
||
f() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from ltypes import i32, f64, dataclass | ||
|
||
@dataclass | ||
class A: | ||
y: f64 | ||
x: i32 | ||
|
||
def verify(s: A[:], x1: i32, y1: f64, x2: i32, y2: f64): | ||
eps: f64 = 1e-12 | ||
print(s[0].x, s[0].y) | ||
assert s[0].x == x1 | ||
assert abs(s[0].y - y1) < eps | ||
print(s[1].x, s[1].y) | ||
assert s[1].x == x2 | ||
assert abs(s[1].y - y2) < eps | ||
|
||
def update_1(s: A): | ||
s.x = 2 | ||
s.y = 1.2 | ||
|
||
def update_2(s: A[:]): | ||
s[1].x = 3 | ||
s[1].y = 2.3 | ||
|
||
def g(): | ||
# TODO: Replace y: A[2] with y: A[2] = [None, None] | ||
# TODO: And enable cpython in integration_tests. | ||
y: A[2] | ||
y[0] = A(1.1, 1) | ||
y[1] = A(2.2, 2) | ||
verify(y, 1, 1.1, 2, 2.2) | ||
update_1(y[0]) | ||
update_2(y) | ||
verify(y, 2, 1.2, 3, 2.3) | ||
|
||
g() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.