basic structures work in the jit
This commit is contained in:
27
examples/basic/struct0001.ngr
Normal file
27
examples/basic/struct0001.ngr
Normal file
@@ -0,0 +1,27 @@
|
||||
struct Point {
|
||||
x: u64;
|
||||
y: u64;
|
||||
}
|
||||
|
||||
v = 1u64;
|
||||
|
||||
function getX(p: Point) -> u64
|
||||
p.x;
|
||||
|
||||
function getY(p: Point) -> u64
|
||||
p.y;
|
||||
|
||||
function newPoint(x, y) -> Point
|
||||
Point {
|
||||
x: x;
|
||||
y: y;
|
||||
};
|
||||
|
||||
function slope(p1, p2) -> u64
|
||||
(getY(p2) - p1.y) / (getX(p2) - p1.x);
|
||||
|
||||
origin = newPoint(0, 0);
|
||||
farther = newPoint(2, 4);
|
||||
|
||||
mySlope = slope(origin, farther);
|
||||
print mySlope;
|
||||
Reference in New Issue
Block a user