nac3/nac3standalone/demo/classes.py

37 lines
544 B
Python
Raw Normal View History

@extern
def output_int(x: int32):
...
2021-09-19 22:54:06 +08:00
class A:
a: int32
b: B
2021-09-19 22:54:06 +08:00
def __init__(self, a: int32):
self.a = a
self.b = B(a + 1)
2021-09-19 17:50:01 +08:00
2021-09-19 22:54:06 +08:00
def get_a(self) -> int32:
return self.a
2021-09-19 17:50:01 +08:00
2021-09-19 22:54:06 +08:00
def get_self(self) -> A:
return self
def get_b(self) -> B:
return self.b
class B:
b: int32
def __init__(self, a: int32):
self.b = a
2021-09-19 17:50:01 +08:00
def run() -> int32:
2021-09-19 22:54:06 +08:00
a = A(10)
2021-09-22 14:33:47 +08:00
output_int(a.a)
2021-09-19 17:50:01 +08:00
2021-09-19 22:54:06 +08:00
a = A(20)
2021-09-22 14:33:47 +08:00
output_int(a.a)
output_int(a.get_a())
output_int(a.get_b().b)
2020-03-30 22:47:45 +08:00
return 0