本文整理汇总了C++中SymbolPtr::hasFlags方法的典型用法代码示例。如果您正苦于以下问题:C++ SymbolPtr::hasFlags方法的具体用法?C++ SymbolPtr::hasFlags怎么用?C++ SymbolPtr::hasFlags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SymbolPtr
的用法示例。
在下文中一共展示了SymbolPtr::hasFlags方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: verifyProtocolConform
void DeclarationAnalyzer::verifyProtocolConform(const TypePtr& type, const TypePtr& protocol)
{
for(auto entry : protocol->getDeclaredMembers())
{
SymbolPtr requirement = entry.second;
if(FunctionOverloadedSymbolPtr funcs = std::dynamic_pointer_cast<FunctionOverloadedSymbol>(requirement))
{
//verify function
for(auto func : *funcs)
{
verifyProtocolFunction(type, protocol, func);
}
}
else if(FunctionSymbolPtr func = std::dynamic_pointer_cast<FunctionSymbol>(requirement))
{
//verify function
verifyProtocolFunction(type, protocol, func);
}
/*
else if(requirement == Type::getPlaceHolder())
{
//verify inner type
SymbolPtr sym = type->getAssociatedType(entry.first);
if(!(std::dynamic_pointer_cast<Type>(sym)))
{
//Type %0 does not conform to protocol %1, unimplemented type %2
error(type->getReference(), Errors::E_TYPE_DOES_NOT_CONFORM_TO_PROTOCOL_UNIMPLEMENTED_TYPE_3, type->getName(), protocol->getName(), entry.first);
}
}*/
else if(TypePtr t = std::dynamic_pointer_cast<Type>(requirement))
{
//type can be ignored
}
else if(dynamic_pointer_cast<ComputedPropertySymbol>(requirement) || dynamic_pointer_cast<SymbolPlaceHolder>(requirement))
{
//verify computed properties
SymbolPtr sym = type->getMember(entry.first);
//ComputedPropertySymbolPtr sp = std::dynamic_pointer_cast<ComputedPropertySymbol>(sym);
if(!sym)
{
error(type->getReference(), Errors::E_TYPE_DOES_NOT_CONFORM_TO_PROTOCOL_UNIMPLEMENTED_PROPERTY_3, type->getName(), protocol->getName(), entry.first);
}
bool expectedSetter = requirement->hasFlags(SymbolFlagWritable);
bool actualSetter = sym->hasFlags(SymbolFlagWritable);
if(expectedSetter && !actualSetter)
{
error(type->getReference(), Errors::E_TYPE_DOES_NOT_CONFORM_TO_PROTOCOL_UNWRITABLE_PROPERTY_3, type->getName(), protocol->getName(), entry.first);
}
}
}
}
示例2: verifyProtocolConform
bool DeclarationAnalyzer::verifyProtocolConform(const TypePtr& type, const TypePtr& protocol, bool supressError)
{
for(auto entry : protocol->getDeclaredMembers())
{
SymbolPtr requirement = entry.second;
if(FunctionOverloadedSymbolPtr funcs = std::dynamic_pointer_cast<FunctionOverloadedSymbol>(requirement))
{
//verify function
for(auto func : *funcs)
{
bool success = verifyProtocolFunction(type, protocol, func, supressError);
if(!success)
return false;
}
}
else if(FunctionSymbolPtr func = std::dynamic_pointer_cast<FunctionSymbol>(requirement))
{
//verify function
bool success = verifyProtocolFunction(type, protocol, func, supressError);
if(!success)
return false;
}
/*
else if(requirement == Type::getPlaceHolder())
{
//verify inner type
SymbolPtr sym = type->getAssociatedType(entry.first);
if(!(std::dynamic_pointer_cast<Type>(sym)))
{
//Type %0 does not conform to protocol %1, unimplemented type %2
error(type->getReference(), Errors::E_TYPE_DOES_NOT_CONFORM_TO_PROTOCOL_UNIMPLEMENTED_TYPE_3, type->getName(), protocol->getName(), entry.first);
}
}*/
else if(TypePtr t = std::dynamic_pointer_cast<Type>(requirement))
{
//if type doesn't declare a type alias but the protocol has defined it with a full definition, then we will implicitly declare it
wstring name = t->getName();
TypePtr originalType = t->resolveAlias();
if(type->getAssociatedType(name) == nullptr && originalType != nullptr && originalType->getCategory() != Type::Alias)
{
TypeBuilderPtr builder = static_pointer_cast<TypeBuilder>(type);
builder->addMember(name, originalType);
}
//typealias checking is moved to second stage, when all other members verified
continue;
}
else if(dynamic_pointer_cast<ComputedPropertySymbol>(requirement) || dynamic_pointer_cast<SymbolPlaceHolder>(requirement))
{
//verify computed properties
SymbolPtr sym = type->getMember(entry.first);
//ComputedPropertySymbolPtr sp = std::dynamic_pointer_cast<ComputedPropertySymbol>(sym);
if(!sym || !checkTypeConform(type, requirement->getType(), sym->getType()))
{
if(!supressError)
{
error(type->getReference(), Errors::E_TYPE_DOES_NOT_CONFORM_TO_PROTOCOL_UNIMPLEMENTED_PROPERTY_3, type->getName(), protocol->getName(), entry.first);
}
return false;
}
bool expectedSetter = requirement->hasFlags(SymbolFlagWritable);
bool actualSetter = sym->hasFlags(SymbolFlagWritable);
if(expectedSetter && !actualSetter)
{
if(!supressError)
{
error(type->getReference(), Errors::E_TYPE_DOES_NOT_CONFORM_TO_PROTOCOL_UNWRITABLE_PROPERTY_3, type->getName(), protocol->getName(), entry.first);
}
return false;
}
}
}
//check again for associated types
for(auto entry : protocol->getAssociatedTypes())
{
if(entry.second->resolveAlias() != nullptr)
continue;
TypePtr t = type->getAssociatedType(entry.first);
if(t == nullptr)
{
//undefined type alias
if(!supressError)
{
error(type->getReference(), Errors::E_TYPE_DOES_NOT_CONFORM_TO_PROTOCOL_2_, type->getName(), protocol->getName());
}
return false;
}
}
return true;
}