108 lines
2.3 KiB
Text
108 lines
2.3 KiB
Text
class Point {
|
|
x: f64;
|
|
y: f64;
|
|
|
|
fun something_static() -> f64 {
|
|
12
|
|
}
|
|
|
|
fun square_length(self) -> f64 {
|
|
self.x * self.x + self.y * self.y
|
|
}
|
|
}
|
|
|
|
class Line {
|
|
start: Point;
|
|
end: Point;
|
|
}
|
|
|
|
fun test() -> f64 {
|
|
let line = new Line {
|
|
start: new Point { y: 23, x: 7 },
|
|
end: new Point { x: 999, y: 99 },
|
|
};
|
|
|
|
let pt = line.start;
|
|
let z = line.start.x + pt.square_length() + Point.something_static();
|
|
z
|
|
}
|
|
|
|
// @no-errors
|
|
// @eval: Float(597.0)
|
|
// @compiles-to:
|
|
// | function << module >> (0 args, 0 locals):
|
|
// | strings (0):
|
|
// | code (2):
|
|
// | 0: PushNothing
|
|
// | 1: Return
|
|
// | function Point (6 args, 0 locals):
|
|
// | strings (1):
|
|
// | 0: Point
|
|
// | code (6):
|
|
// | 0: LoadArgument(1)
|
|
// | 1: LoadArgument(0)
|
|
// | 2: PushString(0)
|
|
// | 3: PushInt(37)
|
|
// | 4: NewObject(2)
|
|
// | 5: Return
|
|
// | function Line (4 args, 0 locals):
|
|
// | strings (1):
|
|
// | 0: Line
|
|
// | code (6):
|
|
// | 0: LoadArgument(1)
|
|
// | 1: LoadArgument(0)
|
|
// | 2: PushString(0)
|
|
// | 3: PushInt(44)
|
|
// | 4: NewObject(2)
|
|
// | 5: Return
|
|
// | function test (0 args, 3 locals):
|
|
// | strings (0):
|
|
// | code (27):
|
|
// | 0: PushFloat(99.0)
|
|
// | 1: PushFloat(999.0)
|
|
// | 2: LoadFunction(1)
|
|
// | 3: Call(2)
|
|
// | 4: PushFloat(23.0)
|
|
// | 5: PushFloat(7.0)
|
|
// | 6: LoadFunction(1)
|
|
// | 7: Call(2)
|
|
// | 8: LoadFunction(2)
|
|
// | 9: Call(2)
|
|
// | 10: StoreLocal(0)
|
|
// | 11: LoadLocal(0)
|
|
// | 12: LoadSlot(0)
|
|
// | 13: StoreLocal(1)
|
|
// | 14: LoadLocal(0)
|
|
// | 15: LoadSlot(0)
|
|
// | 16: LoadSlot(0)
|
|
// | 17: LoadLocal(1)
|
|
// | 18: LoadFunction(4)
|
|
// | 19: Call(1)
|
|
// | 20: FloatAdd
|
|
// | 21: LoadFunction(5)
|
|
// | 22: Call(0)
|
|
// | 23: FloatAdd
|
|
// | 24: StoreLocal(2)
|
|
// | 25: LoadLocal(2)
|
|
// | 26: Return
|
|
// | function square_length (1 args, 0 locals):
|
|
// | strings (0):
|
|
// | code (12):
|
|
// | 0: LoadArgument(0)
|
|
// | 1: LoadSlot(0)
|
|
// | 2: LoadArgument(0)
|
|
// | 3: LoadSlot(0)
|
|
// | 4: FloatMultiply
|
|
// | 5: LoadArgument(0)
|
|
// | 6: LoadSlot(1)
|
|
// | 7: LoadArgument(0)
|
|
// | 8: LoadSlot(1)
|
|
// | 9: FloatMultiply
|
|
// | 10: FloatAdd
|
|
// | 11: Return
|
|
// | function something_static (0 args, 0 locals):
|
|
// | strings (0):
|
|
// | code (2):
|
|
// | 0: PushFloat(12.0)
|
|
// | 1: Return
|
|
// |
|