Files
ivy/doc/sample/Person.iasm

197 lines
2.9 KiB
Plaintext

@use std.io
@lambda (Person_exampleProperty_get)
ldr x0, [self, #2]
ret
@end
@lambda (Person_exampleProperty_set)
ldr x0, [bp, #-1]
str x0, [self, #2]
ret
@end
@lambda (Person_exampleProperty3_get)
ldr x0, [self, #3]
ret
@end
@lambda (Person_exampleProperty3_set)
ldr x0, [bp, #-1]
str x0, [self, #3]
ret
@end
@lambda (Person_exampleProperty4_get)
ldr x0, [self, #4]
ret
@end
@constpool
#0: "Received "
#1: ", "
#2: @ident[cout]
#3: @selector[-put:]
#4: @atom[years]
#5: @atom[months]
#6: @atom[days]
@end
@class (net.doorstuck.test.Person)
$ exampleProperty (
get:Person_exampleProperty_get
set:Person_exampleProperty_set
)
$ exampleProperty2 (get:#42)
$ exampleProperty3 (
get:Person_exampleProperty3_get
set:Person_exampleProperty3_set
)
$ exampleProperty4 (get:Person_exampleProperty4_get)
#0: name
#1: age
#2: val
#3: __exampleProperty3
#4: __exampleProperty4
@end
@msgh (net.doorstuck.test.Person) [-init(name:age:)]
ldr x0, [bp, #-1]
str x0, [self, #0]
ldr x0, [bp, #-2]
str x0, [self, #1]
ret.n
@end
@msgh (net.doorstuck.test.Person) [-test(param:_:)]
ldr x0, [pool, #0]
ldr x1, [bp, #-1]
add x0, x1, x0
ldr x1, [pool, #1]
add x0, x1, x0
ldr x1, [bp, #-2]
add x0, x1, x0
push x0
ldr x1, [pool, #2]
ldr x2, [pool, #3]
msg x1, x2, #1
ret.n
@end
@msgh (net.doorstuck.test.Person) [-name]
ldr x0, [self, #0]
ret
@end
@msgh (net.doorstuck.test.Person) [-age]
ldr x0, [self, #1]
ret
@end
@msgh (net.doorstuck.test.Person) [-ageInMonths]
ldr x0, [self, #1]
ldr x1, #12
mul x0, x1, x0
ret
@end
@msgh (net.doorstuck.test.Person) [-setName:]
ldr x0, [bp, #-1]
str x0, [self, #0]
ret.n
@end
@msgh (net.doorstuck.test.Person) [-setAge:]
ldr x0, [bp, #-1]
str x0, [self, #1]
ret.n
@end
@msgh (net.doorstuck.test.Person) [-setAge:inUnits:]
ldr x0, [bp, #-1]
ldr x1, [bp, #-2]
ldr x2, [pool, #4]
cmp x1, x2
b.eq L0001
ldr x2, [pool, #5]
cmp x1, x2
b.eq L0002
ldr x2, [pool, #6]
cmp x1, x2
b.eq L0003
ldr x0, #0
str x0, [self, #1]
br L0004
L0001: str x0, [self, #2]
br L0004
L0002: ldr x3, #12
div x3, x0, x3
str x3, [self, #2]
br L0004
L0003: ldr x3, #365
div x3, x0, x3
str x3, [self, #2]
br L0004
L0004:
ret.n
@end
@msgh (net.doorstuck.test.Person) [-getAgeInUnits:]
ldr x1, [bp, #-1] ; x1 = units
ldr x2, [pool, #4] ; x2 = #years
cmp x1, x2
b.eq L0001 ; [jump] if units == #years
ldr x2, [pool, #5] ; x2 = #months
cmp x1, x2
b.eq L0002 ; [jump] if units == #years
ldr x2, [pool, #6] ; x2 = #days
cmp x1, x2
b.eq L0003 ; [jump] if units == #days
ldr x0, #0 ; else
ret ; return 0
L0001: ldr x0, [self, #1] ; [code] if units == #years
ret ; return self.age
L0002: ldr x0, [self, #1] ; [code] if units == #months
ldr x1, #12
div x0, x1, x0
ret ; return self.age / 12
L0003: ldr x0, [self, #1] ; [code] if units == #months
ldr x1, #365
div x0, x1, x0
ret ; return self.age / 365
@end