[fine] Static methods I guess
This commit is contained in:
parent
bc57978dda
commit
19e57db724
6 changed files with 111 additions and 51 deletions
|
|
@ -2,9 +2,9 @@ class Point {
|
|||
x: f64;
|
||||
y: f64;
|
||||
|
||||
// fun something_static() -> f64 {
|
||||
// 12
|
||||
// }
|
||||
fun something_static() -> f64 {
|
||||
12
|
||||
}
|
||||
|
||||
fun square_length(self) -> f64 {
|
||||
self.x * self.x + self.y * self.y
|
||||
|
|
@ -23,19 +23,19 @@ fun test() -> f64 {
|
|||
};
|
||||
|
||||
let pt = line.start;
|
||||
let z = line.start.x + pt.square_length();// + Point::something_static();
|
||||
let z = line.start.x + pt.square_length() + Point.something_static();
|
||||
z
|
||||
}
|
||||
|
||||
// @no-errors
|
||||
// @eval: Float(585.0)
|
||||
// @eval: Float(597.0)
|
||||
// @compiles-to:
|
||||
// | function << module >> (0 args, 0 locals):
|
||||
// | strings (0):
|
||||
// | code (2):
|
||||
// | 0: PushNothing
|
||||
// | 1: Return
|
||||
// | function Point (5 args, 0 locals):
|
||||
// | function Point (6 args, 0 locals):
|
||||
// | strings (1):
|
||||
// | 0: Point
|
||||
// | code (5):
|
||||
|
|
@ -55,7 +55,7 @@ fun test() -> f64 {
|
|||
// | 4: Return
|
||||
// | function test (0 args, 3 locals):
|
||||
// | strings (0):
|
||||
// | code (24):
|
||||
// | code (27):
|
||||
// | 0: PushFloat(99.0)
|
||||
// | 1: PushFloat(999.0)
|
||||
// | 2: LoadFunction(1)
|
||||
|
|
@ -77,9 +77,12 @@ fun test() -> f64 {
|
|||
// | 18: LoadFunction(4)
|
||||
// | 19: Call(1)
|
||||
// | 20: FloatAdd
|
||||
// | 21: StoreLocal(2)
|
||||
// | 22: LoadLocal(2)
|
||||
// | 23: Return
|
||||
// | 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):
|
||||
|
|
@ -95,4 +98,9 @@ fun test() -> f64 {
|
|||
// | 9: FloatMultiply
|
||||
// | 10: FloatAdd
|
||||
// | 11: Return
|
||||
// | function something_static (0 args, 0 locals):
|
||||
// | strings (0):
|
||||
// | code (2):
|
||||
// | 0: PushFloat(12.0)
|
||||
// | 1: Return
|
||||
// |
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue