Repository navigation
ASR: Support param access in, out, inout - #1820
Conversation
certik
left a comment
There was a problem hiding this comment.
Otherwise I think this looks good, thanks!
|
We should also add regular integration tests and CPython tests for this. |
9402ab1 to
e35f45e
Compare
Done. |
|
I am adding this to auto-merge as it seems approved. I will work on further modications (if any) in another PR. |
| class Intent: | ||
| def __init__(self, type): | ||
| self._type = type | ||
|
|
||
| def __getitem__(self, params): | ||
| return params | ||
|
|
||
| In = Intent("In") | ||
| Out = Intent("Out") | ||
| InOut = Intent("InOut") |
There was a problem hiding this comment.
I disabled the auto-merge. I think/guess this needs a review. I would like to know if this approach is fine for supporting In, Out, InOut in CPython.
|
Ready. |
|
|
||
| print(a, b, c, d.p) | ||
|
|
||
| f(a, b, c, d) |
There was a problem hiding this comment.
How about testing In[list[u32]], In[Foo]?
There was a problem hiding this comment.
$ cat examples/expr2.py
from lpython import i32, u32, f64, dataclass, In, Out, InOut
@dataclass
class Foo:
p: i32
def f(z: In[list[u32]], w: In[Foo]):
print(z, w.p)
def main0():
c: list[u32] = [u32(1), u32(2), u32(3), u32(4)]
d: Foo = Foo(25)
f(c, d)
assert c[-1] == u32(4)
assert d.p == 25
main0()
$ python examples/expr2.py
[1, 2, 3, 4] 25
$ lpython examples/expr2.py
[1, 2, 3, 4] 25It seems to work locally. Shall I add this as an integration_test?
Do you mean about printing errors when there is assignment/modification to In variables? I am hoping to handle printing errors in PR #1803 after completion/merging of this PR.
certik
left a comment
There was a problem hiding this comment.
I think this looks good, thanks @Shaikh-Ubaid !
towards #1807.