本文整理汇总了C++中TypePtr::conformTo方法的典型用法代码示例。如果您正苦于以下问题:C++ TypePtr::conformTo方法的具体用法?C++ TypePtr::conformTo怎么用?C++ TypePtr::conformTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TypePtr
的用法示例。
在下文中一共展示了TypePtr::conformTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: visitForLoop
void SemanticAnalyzer::visitForLoop(const ForLoopPtr& node)
{
ScopedCodeBlockPtr codeBlock = static_pointer_cast<ScopedCodeBlock>(node->getCodeBlock());
if(node->getInitializer())
{
ScopeGuard guard(codeBlock.get(), this);
node->getInitializer()->accept(this);
}
else
{
for(int i = 0; i < node->numInit(); i++)
{
node->getInit(i)->accept(this);
}
}
{
//condition and step expression should be evaluated under for statement's scope
ScopeGuard guard(codeBlock.get(), this);
//check condition
node->getCondition()->accept(this);
GlobalScope *global = symbolRegistry->getGlobalScope();
TypePtr conditionType = node->getCondition()->getType();
if (!conditionType->conformTo(global->BooleanType()))
{
error(node->getCondition(), Errors::E_TYPE_DOES_NOT_CONFORM_TO_PROTOCOL_2_, conditionType->toString(), L"BooleanType");
return;
}
//visit step expressions
node->getStep()->accept(this);
}
//visit code block
node->getCodeBlock()->accept(this);
}
示例2: visitWhileLoop
void SemanticAnalyzer::visitWhileLoop(const WhileLoopPtr& node)
{
node->getCondition()->accept(this);
GlobalScope* global = symbolRegistry->getGlobalScope();
TypePtr conditionType = node->getCondition()->getType();
if(!conditionType->conformTo(global->BooleanType()))
{
error(node->getCondition(), Errors::E_TYPE_DOES_NOT_CONFORM_TO_PROTOCOL_2_, conditionType->toString(), L"BooleanType");
return;
}
node->getCodeBlock()->accept(this);
}
示例3: visitForIn
void SemanticAnalyzer::visitForIn(const ForInLoopPtr& node)
{
ScopedCodeBlockPtr codeBlock = static_pointer_cast<ScopedCodeBlock>(node->getCodeBlock());
SCOPED_SET(ctx.contextualType, nullptr);
if(node->getDeclaredType())
ctx.contextualType = lookupType(node->getDeclaredType());
node->getContainer()->accept(this);
TypePtr sequenceType = node->getContainer()->getType();
GlobalScope* global = symbolRegistry->getGlobalScope();
if(!sequenceType->conformTo(global->SequenceType()))
{
error(node->getContainer(), Errors::E_TYPE_DOES_NOT_CONFORM_TO_PROTOCOL_2_, sequenceType->toString(), L"SequenceType");
return;
}
}