void EntryDetails(GptEntry *entry, uint32_t index, int raw) { char contents[256]; // scratch buffer for formatting output uint8_t label[GPT_PARTNAME_LEN]; char type[GUID_STRLEN], unique[GUID_STRLEN]; UTF16ToUTF8(entry->name, sizeof(entry->name) / sizeof(entry->name[0]), label, sizeof(label)); require(snprintf(contents, sizeof(contents), "Label: \"%s\"", label) < sizeof(contents)); printf(PARTITION_FMT, (int)entry->starting_lba, (int)(entry->ending_lba - entry->starting_lba + 1), index+1, contents); if (!raw && CGPT_OK == ResolveType(&entry->type, type)) { printf(PARTITION_MORE, "Type: ", type); } else { GuidToStr(&entry->type, type, GUID_STRLEN); printf(PARTITION_MORE, "Type: ", type); } GuidToStr(&entry->unique, unique, GUID_STRLEN); printf(PARTITION_MORE, "UUID: ", unique); if (!raw) { if (GuidEqual(&guid_chromeos_kernel, &entry->type)) { int tries = (entry->attrs.fields.gpt_att & CGPT_ATTRIBUTE_TRIES_MASK) >> CGPT_ATTRIBUTE_TRIES_OFFSET; int successful = (entry->attrs.fields.gpt_att & CGPT_ATTRIBUTE_SUCCESSFUL_MASK) >> CGPT_ATTRIBUTE_SUCCESSFUL_OFFSET; int priority = (entry->attrs.fields.gpt_att & CGPT_ATTRIBUTE_PRIORITY_MASK) >> CGPT_ATTRIBUTE_PRIORITY_OFFSET; require(snprintf(contents, sizeof(contents), "priority=%d tries=%d successful=%d", priority, tries, successful) < sizeof(contents)); printf(PARTITION_MORE, "Attr: ", contents); } } else {
void MtdEntryDetails(MtdDiskPartition *entry, uint32_t index, int raw) { const Guid *guid = LookupGuidForMtdType(MtdGetEntryType(entry)); char type[256]; char contents[256]; char name[sizeof(entry->label) + 1]; uint64_t start, size; if (guid) { ResolveType(guid, type); } else { snprintf(type, sizeof(type), "MTD partition type %d", MtdGetEntryType(entry)); } MtdGetPartitionSizeInSectors(entry, &start, NULL, &size); // Provide a NUL if we are at maximum size. name[sizeof(name)-1] = '\0'; memcpy(name, entry->label, sizeof(entry->label)); require(snprintf(contents, sizeof(contents), "Label: \"%s\"", name) < sizeof(contents)); printf(PARTITION_FMT, (int)start, (int)size, index+1, contents); printf(PARTITION_MORE, "Type: ", type); if (raw && MtdGetEntryType(entry) == MTD_PARTITION_TYPE_CHROMEOS_KERNEL) { int tries = MtdGetEntryTries(entry); int successful = MtdGetEntrySuccessful(entry); int priority = MtdGetEntryPriority(entry); require(snprintf(contents, sizeof(contents), "priority=%d tries=%d successful=%d", priority, tries, successful) < sizeof(contents)); printf(PARTITION_MORE, "Attr: ", contents); } else { require(snprintf(contents, sizeof(contents), "[%x]", entry->flags) < sizeof(contents)); printf(PARTITION_MORE, "Attr: ", contents); } }
void BindClass(Cm::Sym::SymbolTable& symbolTable, Cm::Sym::ContainerScope* containerScope, const std::vector<std::unique_ptr<Cm::Sym::FileScope>>& fileScopes, Cm::Core::ClassTemplateRepository& classTemplateRepository, Cm::BoundTree::BoundCompileUnit& boundCompileUnit, Cm::Ast::ClassNode* classNode, Cm::Sym::ClassTypeSymbol* classTypeSymbol) { if (classTypeSymbol->Bound()) return; if (classNode->GetCompileUnit()) { classTypeSymbol->SetSourceFilePath(classNode->GetCompileUnit()->FilePath()); } Cm::Ast::Specifiers specifiers = classNode->GetSpecifiers(); bool isClassMember = classNode->Parent()->IsClassNode(); SetAccess(classTypeSymbol, specifiers, isClassMember); if ((specifiers & Cm::Ast::Specifiers::static_) != Cm::Ast::Specifiers::none) { classTypeSymbol->SetStatic(); } if ((specifiers & Cm::Ast::Specifiers::abstract_) != Cm::Ast::Specifiers::none) { classTypeSymbol->SetAbstract(); } if ((specifiers & Cm::Ast::Specifiers::virtual_) != Cm::Ast::Specifiers::none) { throw Cm::Core::Exception("class cannnot be virtual", classTypeSymbol->GetSpan()); } if ((specifiers & Cm::Ast::Specifiers::override_) != Cm::Ast::Specifiers::none) { throw Cm::Core::Exception("class cannnot be override", classTypeSymbol->GetSpan()); } if ((specifiers & Cm::Ast::Specifiers::explicit_) != Cm::Ast::Specifiers::none) { throw Cm::Core::Exception("class cannnot be explicit", classTypeSymbol->GetSpan()); } if ((specifiers & Cm::Ast::Specifiers::external) != Cm::Ast::Specifiers::none) { throw Cm::Core::Exception("class cannnot be external", classTypeSymbol->GetSpan()); } if ((specifiers & Cm::Ast::Specifiers::suppress) != Cm::Ast::Specifiers::none) { throw Cm::Core::Exception("class cannnot be suppressed", classTypeSymbol->GetSpan()); } if ((specifiers & Cm::Ast::Specifiers::default_) != Cm::Ast::Specifiers::none) { throw Cm::Core::Exception("class cannnot be default", classTypeSymbol->GetSpan()); } if ((specifiers & Cm::Ast::Specifiers::inline_) != Cm::Ast::Specifiers::none) { throw Cm::Core::Exception("class cannnot be inline", classTypeSymbol->GetSpan()); } if ((specifiers & Cm::Ast::Specifiers::constexpr_) != Cm::Ast::Specifiers::none) { throw Cm::Core::Exception("class cannnot be constexpr", classTypeSymbol->GetSpan()); } if ((specifiers & Cm::Ast::Specifiers::cdecl_) != Cm::Ast::Specifiers::none) { throw Cm::Core::Exception("class cannnot be cdecl", classTypeSymbol->GetSpan()); } if ((specifiers & Cm::Ast::Specifiers::nothrow_) != Cm::Ast::Specifiers::none) { throw Cm::Core::Exception("class cannnot be nothrow", classTypeSymbol->GetSpan()); } if ((specifiers & Cm::Ast::Specifiers::throw_) != Cm::Ast::Specifiers::none) { throw Cm::Core::Exception("class cannnot be throw", classTypeSymbol->GetSpan()); } if ((specifiers & Cm::Ast::Specifiers::new_) != Cm::Ast::Specifiers::none) { throw Cm::Core::Exception("class cannnot be new", classTypeSymbol->GetSpan()); } if (classNode->TemplateParameters().Count() > 0) { classTypeSymbol->SetBound(); return; } for (const std::unique_ptr<Cm::Ast::Node>& baseClassOrImplIntf : classNode->BaseClassOrImplIntfTypeExprs()) { Cm::Sym::TypeSymbol* type = ResolveType(symbolTable, classTypeSymbol->GetContainerScope(), fileScopes, classTemplateRepository, boundCompileUnit, baseClassOrImplIntf.get()); if (type) { if (type->IsClassTypeSymbol()) { Cm::Sym::ClassTypeSymbol* baseClassType = static_cast<Cm::Sym::ClassTypeSymbol*>(type); if (Cm::Sym::TypesEqual(classTypeSymbol, baseClassType)) { Cm::Core::Exception("class cannot derive from itself", classTypeSymbol->GetSpan()); } else { if (!classTypeSymbol->BaseClassSet() && classTypeSymbol->BaseClass()) { throw Cm::Core::Exception("class cannot have more than one base class", classTypeSymbol->GetSpan(), baseClassType->GetSpan()); } Cm::Ast::Node* node = symbolTable.GetNode(baseClassType, false); if (node) { if (node->IsClassNode()) { Cm::Ast::ClassNode* baseClassNode = static_cast<Cm::Ast::ClassNode*>(node); Cm::Sym::ContainerScope* baseClassContainerScope = symbolTable.GetContainerScope(baseClassNode); BindClass(symbolTable, baseClassContainerScope, fileScopes, classTemplateRepository, boundCompileUnit, baseClassNode, baseClassType); } else { throw std::runtime_error("class node expected"); } } if (baseClassType->Access() < classTypeSymbol->Access()) { throw Cm::Core::Exception("base class type must be at least as accessible as the class type itself", baseClassType->GetSpan(), classTypeSymbol->GetSpan()); } classTypeSymbol->SetBaseClass(baseClassType); classTypeSymbol->GetContainerScope()->SetBase(baseClassType->GetContainerScope()); } } else if (type->IsInterfaceTypeSymbol()) { Cm::Sym::InterfaceTypeSymbol* interfaceType = static_cast<Cm::Sym::InterfaceTypeSymbol*>(type); Cm::Ast::Node* node = symbolTable.GetNode(interfaceType, false); if (node) { if (node->IsInterfaceNode()) { Cm::Ast::InterfaceNode* interfaceNode = static_cast<Cm::Ast::InterfaceNode*>(node); Cm::Sym::ContainerScope* interfaceContainerScope = symbolTable.GetContainerScope(interfaceNode); BindInterface(symbolTable, interfaceContainerScope, fileScopes, interfaceNode); } else { throw std::runtime_error("interface node expected"); } } if (!classTypeSymbol->ImplementedInterfacesSet()) { for (Cm::Sym::InterfaceTypeSymbol* implementedInterface : classTypeSymbol->ImplementedInterfaces()) { if (Cm::Sym::TypesEqual(interfaceType, implementedInterface)) { throw Cm::Core::Exception("class already implements interface '" + implementedInterface->FullName() + "'", interfaceType->GetSpan()); } } classTypeSymbol->AddImplementedInterface(interfaceType); } } else { throw Cm::Core::Exception("type expression does not denote a class type or interface type", baseClassOrImplIntf->GetSpan()); } } else { throw Cm::Core::Exception("type expression does not denote a type", baseClassOrImplIntf->GetSpan()); } } if (!classTypeSymbol->IrTypeMade()) { classTypeSymbol->SetIrType(Cm::IrIntf::CreateClassTypeName(classTypeSymbol->FullName())); } classTypeSymbol->SetBaseClassSet(); classTypeSymbol->SetImplementedInterfacesSet(); classTypeSymbol->SetBound(); }