void Symtab::AppendSymbolNamesToMap(const IndexCollection &indexes, bool add_demangled, bool add_mangled, NameToIndexMap &name_to_index_map) const { if (add_demangled || add_mangled) { static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); Timer scoped_timer(func_cat, "%s", LLVM_PRETTY_FUNCTION); std::lock_guard<std::recursive_mutex> guard(m_mutex); // Create the name index vector to be able to quickly search by name NameToIndexMap::Entry entry; const size_t num_indexes = indexes.size(); for (size_t i = 0; i < num_indexes; ++i) { entry.value = indexes[i]; assert(i < m_symbols.size()); const Symbol *symbol = &m_symbols[entry.value]; const Mangled &mangled = symbol->GetMangled(); if (add_demangled) { entry.cstring = mangled.GetDemangledName(symbol->GetLanguage()); if (entry.cstring) name_to_index_map.Append(entry); } if (add_mangled) { entry.cstring = mangled.GetMangledName(); if (entry.cstring) name_to_index_map.Append(entry); } } } }
void Symtab::AppendSymbolNamesToMap (const IndexCollection &indexes, bool add_demangled, bool add_mangled, NameToIndexMap &name_to_index_map) const { if (add_demangled || add_mangled) { Timer scoped_timer (__PRETTY_FUNCTION__, "%s", __PRETTY_FUNCTION__); Mutex::Locker locker (m_mutex); // Create the name index vector to be able to quickly search by name NameToIndexMap::Entry entry; const size_t num_indexes = indexes.size(); for (size_t i=0; i<num_indexes; ++i) { entry.value = indexes[i]; assert (i < m_symbols.size()); const Symbol *symbol = &m_symbols[entry.value]; const Mangled &mangled = symbol->GetMangled(); if (add_demangled) { entry.cstring = mangled.GetDemangledName().GetCString(); if (entry.cstring && entry.cstring[0]) name_to_index_map.Append (entry); } if (add_mangled) { entry.cstring = mangled.GetMangledName().GetCString(); if (entry.cstring && entry.cstring[0]) name_to_index_map.Append (entry); } } } }
static void parseImm(CursorState* cursor,CallIndirectImm& outImm) { if(cursor->nextToken->type == t_name || cursor->nextToken->type == t_decimalInt || cursor->nextToken->type == t_hexInt) { // Parse the callee type as a legacy naked name or index referring to a type declaration. outImm.type.index = parseAndResolveNameOrIndexRef( cursor, cursor->moduleState->typeNameToIndexMap, cursor->moduleState->module.types.size(), "type"); } else { // Parse the callee type, as a reference or explicit declaration. const Token* firstTypeToken = cursor->nextToken; std::vector<std::string> paramDisassemblyNames; NameToIndexMap paramNameToIndexMap; const UnresolvedFunctionType unresolvedFunctionType = parseFunctionTypeRefAndOrDecl( cursor, paramNameToIndexMap, paramDisassemblyNames); outImm.type.index = resolveFunctionType(cursor->moduleState,unresolvedFunctionType).index; // Disallow named parameters. if(paramNameToIndexMap.size()) { auto paramNameIt = paramNameToIndexMap.begin(); parseErrorf( cursor->parseState, firstTypeToken, "call_indirect callee type declaration may not declare parameter names ($%s)", paramNameIt->key.getString().c_str()); } } }
static void parseControlImm(CursorState* cursor,Name& outBranchTargetName,ControlStructureImm& imm) { tryParseName(cursor,outBranchTargetName); cursor->functionState->labelDisassemblyNames.push_back(outBranchTargetName.getString()); FunctionType functionType; // For backward compatibility, handle a naked result type. ValueType singleResultType; if(tryParseValueType(cursor, singleResultType)) { functionType = FunctionType(TypeTuple(singleResultType)); } else { // Parse the callee type, as a reference or explicit declaration. const Token* firstTypeToken = cursor->nextToken; std::vector<std::string> paramDisassemblyNames; NameToIndexMap paramNameToIndexMap; const UnresolvedFunctionType unresolvedFunctionType = parseFunctionTypeRefAndOrDecl( cursor, paramNameToIndexMap, paramDisassemblyNames); // Disallow named parameters. if(paramNameToIndexMap.size()) { auto paramNameIt = paramNameToIndexMap.begin(); parseErrorf( cursor->parseState, firstTypeToken, "block type declaration may not declare parameter names ($%s)", paramNameIt->key.getString().c_str()); } if(!unresolvedFunctionType.reference) { // If there wasn't a type reference, just use the inline declared params and results. functionType = unresolvedFunctionType.explicitType; } else { // If there was a type reference, resolve it. This also verifies that if there were also // params and/or results declared inline that they match the resolved type reference. const Uptr referencedFunctionTypeIndex = resolveFunctionType( cursor->moduleState, unresolvedFunctionType ).index; functionType = cursor->moduleState->module.types[referencedFunctionTypeIndex]; } } // Translate the function type into an indexed block type. if(functionType.params().size() == 0 && functionType.results().size() == 0) { imm.type.format = IndexedBlockType::noParametersOrResult; imm.type.resultType = ValueType::any; } else if(functionType.params().size() == 0 && functionType.results().size() == 1) { imm.type.format = IndexedBlockType::oneResult; imm.type.resultType = functionType.results()[0]; } else { imm.type.format = IndexedBlockType::functionType; imm.type.index = getUniqueFunctionTypeIndex(cursor->moduleState, functionType).index; } }