- Classes are defined lazily - Member access is via environment - Member access is just a binary expression with a weird environment - Slot loads look like variable loads now - Associativity in the parser (ugh)
76 lines
1.6 KiB
Text
76 lines
1.6 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 { x: 7, y: 23 },
|
|
end: new Point { x: 999, y: 99 },
|
|
};
|
|
|
|
let z = line.start.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 Line (4 args, 0 locals):
|
|
// | strings (1):
|
|
// | 0: Line
|
|
// | 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 (17):
|
|
// | 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: LoadSlot(0)
|
|
// | 14: StoreLocal(1)
|
|
// | 15: LoadLocal(1)
|
|
// | 16: Return
|
|
// |
|