| 2163 | } |
| 2164 | |
| 2165 | bool CompileHelper::compileClassConstructorDeclaration( |
| 2166 | DesignComponent* component, const FileContent* fC, NodeId nodeId, |
| 2167 | CompileDesign* compileDesign) { |
| 2168 | UHDM::Serializer& s = compileDesign->getSerializer(); |
| 2169 | std::vector<UHDM::task_func*>* task_funcs = component->getTask_funcs(); |
| 2170 | if (task_funcs == nullptr) { |
| 2171 | component->setTask_funcs(s.MakeTask_funcVec()); |
| 2172 | task_funcs = component->getTask_funcs(); |
| 2173 | } |
| 2174 | UHDM::function* func = s.MakeFunction(); |
| 2175 | func->VpiMethod(true); |
| 2176 | task_funcs->push_back(func); |
| 2177 | fC->populateCoreMembers(nodeId, nodeId, func); |
| 2178 | std::string name = "new"; |
| 2179 | std::string className; |
| 2180 | NodeId Tf_port_list; |
| 2181 | Tf_port_list = fC->Child(nodeId); |
| 2182 | if (fC->Type(Tf_port_list) == VObjectType::paClass_scope) { |
| 2183 | NodeId Class_scope = Tf_port_list; |
| 2184 | NodeId Class_type = fC->Child(Class_scope); |
| 2185 | NodeId Class_name = fC->Child(Class_type); |
| 2186 | name = fC->SymName(Class_name); |
| 2187 | className = name; |
| 2188 | name += "::new"; |
| 2189 | Tf_port_list = fC->Sibling(Tf_port_list); |
| 2190 | } |
| 2191 | UHDM::class_var* var = s.MakeClass_var(); |
| 2192 | var->VpiParent(func); |
| 2193 | func->Return(var); |
| 2194 | UHDM::class_typespec* tps = s.MakeClass_typespec(); |
| 2195 | ref_typespec* tpsRef = s.MakeRef_typespec(); |
| 2196 | tpsRef->VpiParent(var); |
| 2197 | tpsRef->Actual_typespec(tps); |
| 2198 | var->Typespec(tpsRef); |
| 2199 | NodeId tf_Port_ItemId = fC->Child(Tf_port_list); |
| 2200 | NodeId data_type_or_implicitId = fC->Child(tf_Port_ItemId); |
| 2201 | NodeId varId = fC->Sibling(data_type_or_implicitId); |
| 2202 | if (varId) fC->populateCoreMembers(varId, varId, var); |
| 2203 | if (ClassDefinition* cdef = |
| 2204 | valuedcomponenti_cast<ClassDefinition*>(component)) { |
| 2205 | tps->Class_defn(cdef->getUhdmDefinition()); |
| 2206 | const std::string_view name = cdef->getUhdmDefinition()->VpiName(); |
| 2207 | tps->VpiName(name); |
| 2208 | } else if (Package* p = valuedcomponenti_cast<Package*>(component)) { |
| 2209 | if (ClassDefinition* cdef = p->getClassDefinition(className)) { |
| 2210 | const std::string_view name = cdef->getUhdmDefinition()->VpiName(); |
| 2211 | tps->Class_defn(cdef->getUhdmDefinition()); |
| 2212 | tps->VpiName(name); |
| 2213 | } |
| 2214 | } |
| 2215 | |
| 2216 | func->VpiName(name); |
| 2217 | func->Io_decls( |
| 2218 | compileTfPortList(component, func, fC, Tf_port_list, compileDesign)); |
| 2219 | |
| 2220 | NodeId Stmt; |
| 2221 | if (fC->Type(Tf_port_list) == VObjectType::paFunction_statement_or_null) { |
| 2222 | Stmt = Tf_port_list; |
no test coverage detected