oden/fine/tests/expression/class.fine

51 lines
1 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
}
}
fun test() -> f64 {
let pt = new Point { x: 7, y: 23 };
let z = pt.x + pt.square_length() + Point::something_static();
z
}
// @ignore WIP: Methods
// @no-errors
// @eval: Float(7.0)
// @compiles-to:
// | function << module >> (0 args, 0 locals):
// | strings (0):
// | code (2):
// | 0: PushNothing
// | 1: Return
// | function Point (4 args, 0 locals):
// | strings (1):
// | 0: Point
// | code (5):
// | 0: LoadArgument(1)
// | 1: LoadArgument(0)
// | 2: PushString(0)
// | 3: NewObject(2)
// | 4: Return
// | function test (0 args, 2 locals):
// | strings (0):
// | code (10):
// | 0: PushFloat(23.0)
// | 1: PushFloat(7.0)
// | 2: LoadFunction(1)
// | 3: Call(2)
// | 4: StoreLocal(0)
// | 5: LoadLocal(0)
// | 6: LoadSlot(0)
// | 7: StoreLocal(1)
// | 8: LoadLocal(1)
// | 9: Return
// |