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.
- Loading branch information
Showing
44 changed files
with
498 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from ltypes import c_p_pointer, CPtr, pointer, i16, i32, Pointer, ccall, p_c_pointer | ||
|
||
@ccall | ||
def g(a: CPtr, value: i32) -> None: | ||
pass | ||
|
||
@ccall | ||
def get_array(size: i32) -> CPtr: | ||
pass | ||
|
||
@ccallable | ||
def f(q_void: CPtr) -> None: | ||
i: i32 | ||
el: i32 | ||
q: Pointer[i32[:]] | ||
c_p_pointer(q_void, q) | ||
for i in range(10): | ||
q2: CPtr | ||
p_c_pointer(pointer(q[i]), q2) | ||
g(q2, i * i) | ||
# TODO: Use q[i] directly in the assert. | ||
el = q[i] | ||
print(el) | ||
assert el == i * i | ||
|
||
def run(): | ||
a: CPtr | ||
size: i32 | ||
size = 10 | ||
a = get_array(size) | ||
f(a) | ||
|
||
run() |
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,10 @@ | ||
#include "bindc_03b.h" | ||
#include <stdlib.h> | ||
|
||
void g(int32_t* x, int32_t value) { | ||
*x = value; | ||
} | ||
|
||
void* get_array(int32_t size) { | ||
return malloc(size * sizeof(int32_t)); | ||
} |
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,10 @@ | ||
#ifndef BINDC_03B | ||
#define BINDC_03B | ||
|
||
#include <stdint.h> | ||
|
||
void g(int32_t* x, int32_t value); | ||
|
||
void* get_array(int32_t size); | ||
|
||
#endif // BINDC_03B |
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,21 @@ | ||
from ltypes import pointer, i16, Pointer | ||
|
||
# Testing Global Pointers | ||
x: Pointer[i16[:]] | ||
|
||
def f(): | ||
yptr1: Pointer[i16[:]] | ||
y: i16[2] | ||
y[0] = 1 | ||
y[1] = 2 | ||
yptr1 = pointer(y) | ||
assert yptr1[0] == 1 | ||
assert yptr1[1] == 2 | ||
x = pointer(y) | ||
|
||
def check(): | ||
f() | ||
assert x[0] == 1 | ||
assert x[1] == 2 | ||
|
||
check() |
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,9 @@ | ||
from platform import python_implementation | ||
|
||
def test_platform1(): | ||
s: str | ||
s = python_implementation() | ||
print("Python Implementation:", s) | ||
assert s == "CPython" or s == "LPython" | ||
|
||
test_platform1() |
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,10 @@ | ||
from ltypes import i32 | ||
|
||
def f(): | ||
i: i32 | ||
i = int("314") | ||
assert i == 314 | ||
i = int("-314") | ||
assert i == -314 | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from test_vars_01b import test_name_other_module | ||
|
||
def test_name(): | ||
print(__name__) | ||
assert __name__ == "__main__" | ||
|
||
test_name() | ||
test_name_other_module() |
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,3 @@ | ||
def test_name_other_module(): | ||
print(__name__) | ||
assert __name__ != "__main__" |
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.