2021-10-08 23:41:41 +08:00
|
|
|
from min_artiq import *
|
2024-08-29 17:47:52 +08:00
|
|
|
from numpy import int32
|
2022-02-21 17:52:34 +08:00
|
|
|
|
|
|
|
|
2024-08-29 17:47:52 +08:00
|
|
|
# @nac3
|
|
|
|
# class A:
|
|
|
|
# a: int32
|
|
|
|
# core: KernelInvariant[Core]
|
|
|
|
|
|
|
|
# def __init__(self, a: int32):
|
|
|
|
# self.core = Core()
|
|
|
|
# self.a = a
|
|
|
|
|
|
|
|
# @kernel
|
|
|
|
# def output_all_fields(self):
|
|
|
|
# #print(self.a)
|
|
|
|
# pass
|
|
|
|
|
|
|
|
# @kernel
|
|
|
|
# def set_a(self, a: int32):
|
|
|
|
# self.a = a
|
|
|
|
|
|
|
|
# @nac3
|
|
|
|
# class B(A):
|
|
|
|
# b: int32
|
|
|
|
|
|
|
|
# def __init__(self, b: int32):
|
|
|
|
# # A.__init__(self, b + 1)
|
|
|
|
# self.core = Core()
|
|
|
|
# self.a = b
|
|
|
|
# self.b = b
|
|
|
|
# self.set_b(b)
|
|
|
|
|
|
|
|
# @kernel
|
|
|
|
# def output_parent_fields(self):
|
|
|
|
# # A.output_all_fields(self)
|
|
|
|
# pass
|
|
|
|
|
|
|
|
# @kernel
|
|
|
|
# def output_all_fields(self):
|
|
|
|
# # A.output_all_fields(self)
|
|
|
|
# pass
|
|
|
|
# #print(self.b)
|
|
|
|
|
|
|
|
# @kernel
|
|
|
|
# def set_b(self, b: int32):
|
|
|
|
# self.b = b
|
|
|
|
|
2021-11-05 18:07:43 +08:00
|
|
|
@nac3
|
2024-08-29 17:47:52 +08:00
|
|
|
class C:
|
|
|
|
c: Kernel[int32]
|
|
|
|
a: Kernel[int32]
|
|
|
|
b: Kernel[int32]
|
2021-11-06 22:50:28 +08:00
|
|
|
core: KernelInvariant[Core]
|
2021-09-25 14:17:11 +08:00
|
|
|
|
2024-08-29 17:47:52 +08:00
|
|
|
def __init__(self, c: int32):
|
|
|
|
# B.__init__(self, c + 1)
|
2021-10-08 23:41:41 +08:00
|
|
|
self.core = Core()
|
2024-08-29 17:47:52 +08:00
|
|
|
self.a = c
|
|
|
|
self.b = c
|
|
|
|
self.c = c
|
|
|
|
|
|
|
|
@kernel
|
|
|
|
def output_parent_fields(self):
|
|
|
|
# B.output_all_fields(self)
|
|
|
|
pass
|
2020-12-18 23:44:45 +08:00
|
|
|
|
|
|
|
@kernel
|
2024-08-29 17:47:52 +08:00
|
|
|
def output_all_fields(self):
|
|
|
|
# B.output_all_fields(self)
|
|
|
|
#print(self.c)
|
|
|
|
pass
|
2020-12-18 23:44:45 +08:00
|
|
|
|
2024-08-29 17:47:52 +08:00
|
|
|
@kernel
|
|
|
|
def set_c(self, c: int32):
|
|
|
|
self.c = c
|
|
|
|
|
|
|
|
@kernel
|
|
|
|
def run(self):
|
|
|
|
self.output_all_fields()
|
|
|
|
# self.set_a(1)
|
|
|
|
# self.set_b(2)
|
|
|
|
self.set_c(3)
|
|
|
|
self.output_all_fields()
|
2020-12-18 23:44:45 +08:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2024-08-29 17:47:52 +08:00
|
|
|
C(10).run()
|