| 148 | } |
| 149 | |
| 150 | StructInfo * DebugInfoHelper::makeStructureDebugInfo ( const Structure & st ) { |
| 151 | DAS_VERIFYF(!st.isTemplate,"cannot make debug info for template structure %s", st.name.c_str()); |
| 152 | string mangledName = st.getMangledName(); |
| 153 | auto it = smn2s.find(mangledName); |
| 154 | if ( it!=smn2s.end() ) return it->second; |
| 155 | StructInfo * sti = debugInfo->makeNode<StructInfo>(); |
| 156 | smn2s[mangledName] = sti; |
| 157 | sti->name = debugInfo->allocateCachedName(st.name); |
| 158 | sti->flags = 0; |
| 159 | if ( st.isClass ) sti->flags |= StructInfo::flag_class; |
| 160 | if ( st.isLambda ) sti->flags |= StructInfo::flag_lambda; |
| 161 | gc_local<TypeDecl> tdecl(new TypeDecl((Structure *)&st)); |
| 162 | auto gcf = tdecl->gcFlags(); |
| 163 | if ( gcf & TypeDecl::gcFlag_heap ) sti->flags |= StructInfo::flag_heapGC; |
| 164 | if ( gcf & TypeDecl::gcFlag_stringHeap ) sti->flags |= StructInfo::flag_stringHeapGC; |
| 165 | sti->count = (uint32_t) st.fields.size(); |
| 166 | sti->size = st.getSizeOf(); |
| 167 | s2cppTypeName[sti] = describeCppType(tdecl, CpptSubstitureRef::no,CpptSkipRef::yes, CpptSkipConst::yes); |
| 168 | sti->fields = (VarInfo **) debugInfo->allocate( sizeof(VarInfo *) * sti->count ); |
| 169 | for ( uint32_t i=0, is=sti->count; i!=is; ++i ) { |
| 170 | auto & var = st.fields[i]; |
| 171 | VarInfo * vi = makeVariableDebugInfo(st, var); |
| 172 | if (var.privateField) { |
| 173 | vi->flags |= TypeInfo::flag_private; |
| 174 | } |
| 175 | sti->fields[i] = vi; |
| 176 | } |
| 177 | sti->firstGcField = sti->count; |
| 178 | if ( sti->count && (sti->flags & (StructInfo::flag_heapGC | StructInfo::flag_stringHeapGC))) { |
| 179 | int32_t prev = -1; |
| 180 | for ( uint32_t i=0, is=sti->count; i!=is; ++i ) { |
| 181 | das::VarInfo * var = sti->fields[i]; |
| 182 | if (var->flags & (TypeInfo::flag_heapGC | TypeInfo::flag_stringHeapGC)) { |
| 183 | if ( prev == -1 ) { |
| 184 | sti->firstGcField = i; |
| 185 | } else { |
| 186 | sti->fields[prev]->nextGcField = i; |
| 187 | } |
| 188 | prev = i; |
| 189 | } |
| 190 | } |
| 191 | if (prev != -1) |
| 192 | sti->fields[prev]->nextGcField = sti->count; |
| 193 | } |
| 194 | sti->init_mnh = 0; |
| 195 | if ( st.module ) { |
| 196 | sti->module_name = debugInfo->allocateCachedName(st.module->name); |
| 197 | if ( auto fn = st.module->findFunction(st.name) ) { |
| 198 | sti->init_mnh = fn->getMangledNameHash(); |
| 199 | } |
| 200 | } |
| 201 | if ( rtti ) { |
| 202 | sti->annotation_list = (void *) &st.annotations; |
| 203 | } else { |
| 204 | sti->annotation_list = nullptr; |
| 205 | } |
| 206 | sti->hash = hash_blockz64((uint8_t *)mangledName.c_str()); |
| 207 | return sti; |
no test coverage detected