本文整理汇总了C++中SourceFile::supportsNamedSections方法的典型用法代码示例。如果您正苦于以下问题:C++ SourceFile::supportsNamedSections方法的具体用法?C++ SourceFile::supportsNamedSections怎么用?C++ SourceFile::supportsNamedSections使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SourceFile
的用法示例。
在下文中一共展示了SourceFile::supportsNamedSections方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//! Takes an AST node that is one of the following subclasses and creates the corresponding
//! type of DataSource object from it.
//! - StringConstASTNode
//! - ExprASTNode
//! - SourceASTNode
//! - SectionASTNode
//! - SectionMatchListASTNode
//! - BlobConstASTNode
//! - IVTConstASTNode
//!
//! \exception elftosb::semantic_error Thrown if a semantic problem is found with
//! the data node.
//! \exception std::runtime_error Thrown if an error occurs that shouldn't be possible
//! based on the grammar.
DataSource * ConversionController::createSourceFromNode(ASTNode * dataNode)
{
assert(dataNode);
DataSource * source = NULL;
StringConstASTNode * stringNode;
BlobConstASTNode * blobNode;
ExprASTNode * exprNode;
SourceASTNode * sourceNode;
SectionASTNode * sectionNode;
SectionMatchListASTNode * matchListNode;
IVTConstASTNode * ivtNode;
if (stringNode = dynamic_cast<StringConstASTNode*>(dataNode))
{
// create a data source with the string contents
std::string * stringData = stringNode->getString();
const uint8_t * stringContents = reinterpret_cast<const uint8_t *>(stringData->c_str());
source = new UnmappedDataSource(stringContents, static_cast<unsigned>(stringData->size()));
}
else if (blobNode = dynamic_cast<BlobConstASTNode*>(dataNode))
{
// create a data source with the raw binary data
Blob * blob = blobNode->getBlob();
source = new UnmappedDataSource(blob->getData(), blob->getLength());
}
else if (exprNode = dynamic_cast<ExprASTNode*>(dataNode))
{
// reduce the expression first
exprNode = exprNode->reduce(m_context);
IntConstExprASTNode * intNode = dynamic_cast<IntConstExprASTNode*>(exprNode);
if (!intNode)
{
throw semantic_error("load pattern expression did not evaluate to an integer");
}
SizedIntegerValue intValue(intNode->getValue(), intNode->getSize());
source = new PatternSource(intValue);
}
else if (sourceNode = dynamic_cast<SourceASTNode*>(dataNode))
{
// load the entire source contents
SourceFile * sourceFile = getSourceFromName(sourceNode->getSourceName(), sourceNode->getFirstLine());
source = sourceFile->createDataSource();
}
else if (sectionNode = dynamic_cast<SectionASTNode*>(dataNode))
{
// load some subset of the source
SourceFile * sourceFile = getSourceFromName(sectionNode->getSourceName(), sectionNode->getFirstLine());
if (!sourceFile->supportsNamedSections())
{
throw semantic_error(format_string("line %d: source does not support sections", sectionNode->getFirstLine()));
}
// create data source from the section name
std::string * sectionName = sectionNode->getSectionName();
GlobMatcher globber(*sectionName);
source = sourceFile->createDataSource(globber);
if (!source)
{
throw semantic_error(format_string("line %d: no sections match the pattern", sectionNode->getFirstLine()));
}
}
else if (matchListNode = dynamic_cast<SectionMatchListASTNode*>(dataNode))
{
SourceFile * sourceFile = getSourceFromName(matchListNode->getSourceName(), matchListNode->getFirstLine());
if (!sourceFile->supportsNamedSections())
{
throw semantic_error(format_string("line %d: source type does not support sections", matchListNode->getFirstLine()));
}
// create string matcher
ExcludesListMatcher matcher;
// add each pattern to the matcher
ListASTNode * matchList = matchListNode->getSections();
ListASTNode::iterator it = matchList->begin();
for (; it != matchList->end(); ++it)
{
ASTNode * node = *it;
sectionNode = dynamic_cast<SectionASTNode*>(node);
if (!sectionNode)
{
throw std::runtime_error(format_string("line %d: unexpected node type in section pattern list", (*it)->getFirstLine()));
}
bool isInclude = sectionNode->getAction() == SectionASTNode::kInclude;
//.........这里部分代码省略.........