64 class ContextCode (ReferenceCode) :
66 ReferenceCode.__init__(self, ref)
67 self.data_code_list = []
68 self.graph_code_list = []
69 self.node_code_list = []
70 for data
in self.ref.data_list :
71 self.data_code_list.append( ContextCode.get_data_code_obj(data) )
72 for graph
in self.ref.graph_list :
73 self.graph_code_list.append( GraphCode(graph) )
74 for node
in self.ref.node_list :
75 self.node_code_list.append( NodeCode(node) )
77 def get_data_code_obj(ref) :
78 if ref.type == Type.IMAGE :
80 if ref.type == Type.LUT :
82 if ref.type == Type.CONVOLUTION :
83 return ConvolutionCode(ref)
84 if ref.type == Type.DISTRIBUTION :
85 return DistributionCode(ref)
86 if ref.type == Type.MATRIX :
87 return MatrixCode(ref)
88 if ref.type == Type.REMAP :
90 if ref.type == Type.THRESHOLD :
91 return ThresholdCode(ref)
92 if ref.type == Type.PYRAMID :
93 return PyramidCode(ref)
94 if ref.type == Type.OBJECT_ARRAY :
95 return ObjectArrayCode(ref)
96 if ref.type == Type.TENSOR :
97 return TensorCode(ref)
98 if ref.type == Type.USER_DATA_OBJECT :
99 return UserDataObjectCode(ref)
100 if ref.type == Type.SCALAR :
101 return ScalarCode(ref)
102 if ref.type == Type.GRAPH :
103 return GraphCode(ref)
104 if ref.type == Type.NODE :
106 if ref.type == Type.ARRAY :
107 return ArrayCode(ref)
108 if ref.type == Type.NULL :
112 def declare_var(self, code_gen) :
113 code_gen.write_line(
'vx_context context;')
114 code_gen.write_newline()
115 for graph_code
in self.graph_code_list :
116 graph_code.declare_var(code_gen)
117 code_gen.write_newline()
118 for data_code
in self.data_code_list :
119 data_code.declare_var(code_gen)
120 code_gen.write_newline()
121 for node_code
in self.node_code_list :
122 node_code.declare_var(code_gen)
123 code_gen.write_newline()
def __init__(self, name="default")
Constructor used to create this object.