本文整理汇总了C++中TypePtr::getAccessLevel方法的典型用法代码示例。如果您正苦于以下问题:C++ TypePtr::getAccessLevel方法的具体用法?C++ TypePtr::getAccessLevel怎么用?C++ TypePtr::getAccessLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TypePtr
的用法示例。
在下文中一共展示了TypePtr::getAccessLevel方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: visitClass
void DeclarationAnalyzer::visitClass(const ClassDefPtr& node)
{
TypePtr type = defineType(node);
SCOPED_SET(ctx->currentType, type);
assert(type->getAccessLevel() != AccessLevelUndefined);
if(type->getParentType() != nullptr)
verifyAccessLevel(node, type->getParentType(), D_CLASS, C_SUPERCLASS);
visitDeclaration(node);
verifyProtocolConform(type);
prepareDefaultInitializers(type);
validateDeclarationModifiers(node);
visitImplementation(node);
}
示例2: visitClass
void DeclarationAnalyzer::visitClass(const ClassDefPtr& node)
{
if(isLazyDeclared(node))
return;
TypePtr type = getOrDefineType(node);
ScopeGuard scope(symbolRegistry, type->getScope());
SCOPED_SET(ctx->currentType, type);
SCOPED_SET(ctx->currentExtension, nullptr);
SCOPED_SET(ctx->currentFunction, nullptr);
assert(type->getAccessLevel() != AccessLevelUndefined);
if(type->getParentType() != nullptr)
verifyAccessLevel(node, type->getParentType(), DeclarationTypeClass, ComponentTypeSuperclass);
visitDeclaration(node);
prepareDefaultInitializers(type);
validateDeclarationModifiers(node);
//visitImplementation(node);
}
示例3: defineType
//.........这里部分代码省略.........
assert(type != nullptr);
assert(type->getCategory() == category);
//prepare for generic
if(!type->getGenericDefinition() && node->getGenericParametersDef())
{
GenericParametersDefPtr genericParams = node->getGenericParametersDef();
GenericDefinitionPtr generic = prepareGenericTypes(genericParams);
generic->registerTo(type->getScope());
type->setGenericDefinition(generic);
}
if(node->hasModifier(DeclarationModifiers::Final))
type->setFlags(SymbolFlagFinal, true);
static_pointer_cast<TypeBuilder>(type)->setModuleName(ctx->currentModule->getName());
ctx->allTypes.push_back(type);
//check inheritance clause
{
TypePtr parent = nullptr;
bool first = true;
ScopeGuard scope(symbolRegistry, type->getScope());
SCOPED_SET(ctx->currentType, type);
for(const TypeIdentifierPtr& parentType : node->getParents())
{
parentType->accept(this);
if(first)
declareImmediately(parentType->getName());
TypePtr ptr = resolveType(parentType, true);
Type::Category pcategory = ptr->getCategory();
if(pcategory == Type::Specialized)
pcategory = ptr->getInnerType()->getCategory();
if(pcategory == Type::Class && category == Type::Class)
{
if(!first)
{
//only the first type can be class type
error(parentType, Errors::E_SUPERCLASS_MUST_APPEAR_FIRST_IN_INHERITANCE_CLAUSE_1, toString(parentType));
return nullptr;
}
parent = ptr;
if(parent->hasFlags(SymbolFlagFinal))
{
error(parentType, Errors::E_INHERITANCE_FROM_A_FINAL_CLASS_A_1, parentType->getName());
return nullptr;
}
}
else if(category == Type::Enum && pcategory != Type::Protocol)
{
if(parent)//already has a raw type
{
error(parentType, Errors::E_MULTIPLE_ENUM_RAW_TYPES_A_AND_B_2, parent->toString(), ptr->toString());
return nullptr;
}
if(!first)
{
error(parentType, Errors::E_RAW_TYPE_A_MUST_APPEAR_FIRST_IN_THE_ENUM_INHERITANCE_CLAUSE_1, ptr->toString());
return nullptr;
}
//check if the raw type is literal convertible
if(!isLiteralTypeForEnum(symbolRegistry->getGlobalScope(), ptr))
{
error(parentType, Errors::E_RAW_TYPE_A_IS_NOT_CONVERTIBLE_FROM_ANY_LITERAL_1, ptr->toString());
return nullptr;
}
if(!ptr->canAssignTo(symbolRegistry->getGlobalScope()->Equatable()))
{
error(parentType, Errors::E_RAWREPRESENTABLE_INIT_CANNOT_BE_SYNTHESIZED_BECAUSE_RAW_TYPE_A_IS_NOT_EQUATABLE_1, ptr->toString());
return nullptr;
}
parent = ptr;
}
else if(pcategory == Type::Protocol)
{
type->addProtocol(ptr);
}
else
{
if(category == Type::Class)
error(parentType, Errors::E_INHERITANCE_FROM_NONE_PROTOCOL_NON_CLASS_TYPE_1, toString(parentType));
else
error(parentType, Errors::E_INHERITANCE_FROM_NONE_PROTOCOL_TYPE_1, toString(parentType));
return nullptr;
}
first = false;
}
type->setParentType(parent);
if(parent && parent->getAccessLevel() == AccessLevelPublic && (node->getModifiers() & DeclarationModifiers::AccessModifiers) == 0)
type->setAccessLevel(AccessLevelPublic);//when access level is undefined, try to inherit base's access level
else
type->setAccessLevel(parseAccessLevel(node->getModifiers()));
}
declarationFinished(type->getName(), type, node);
return type;
}
示例4: defineType
//.........这里部分代码省略.........
//check if it's defined as a nested type
if(ctx->currentType)
{
if(genericParams)
{
error(node, Errors::E_GENERIC_TYPE_A_NESTED_IN_TYPE_B_IS_NOT_ALLOWED_2, id->getName(), ctx->currentType->getName());
return nullptr;
}
if(ctx->currentType->isGenericType())
{
error(node, Errors::E_TYPE_A_NESTED_IN_GENERIC_TYPE_B_IS_NOT_ALLOWED_2, id->getName(), ctx->currentType->getName());
return nullptr;
}
}
if(genericParams)
{
generic = prepareGenericTypes(genericParams);
generic->registerTo(typeScope);
}
//check inheritance clause
TypePtr parent = nullptr;
std::vector<TypePtr> protocols;
bool first = true;
for(const TypeIdentifierPtr& parentType : node->getParents())
{
parentType->accept(semanticAnalyzer);
TypePtr ptr = this->lookupType(parentType);
if(ptr->getCategory() == Type::Class && category == Type::Class)
{
if(!first)
{
//only the first type can be class type
error(parentType, Errors::E_SUPERCLASS_MUST_APPEAR_FIRST_IN_INHERITANCE_CLAUSE_1, toString(parentType));
return nullptr;
}
parent = ptr;
if(parent->hasFlags(SymbolFlagFinal))
{
error(parentType, Errors::E_INHERITANCE_FROM_A_FINAL_CLASS_A_1, parentType->getName());
return nullptr;
}
}
else if(category == Type::Enum && ptr->getCategory() != Type::Protocol)
{
if(parent)//already has a raw type
{
error(parentType, Errors::E_MULTIPLE_ENUM_RAW_TYPES_A_AND_B_2, parent->toString(), ptr->toString());
return nullptr;
}
if(!first)
{
error(parentType, Errors::E_RAW_TYPE_A_MUST_APPEAR_FIRST_IN_THE_ENUM_INHERITANCE_CLAUSE_1, ptr->toString());
return nullptr;
}
//check if the raw type is literal convertible
if(!isLiteralTypeForEnum(symbolRegistry->getGlobalScope(), ptr))
{
error(parentType, Errors::E_RAW_TYPE_A_IS_NOT_CONVERTIBLE_FROM_ANY_LITERAL_1, ptr->toString());
return nullptr;
}
if(!ptr->canAssignTo(symbolRegistry->getGlobalScope()->Equatable()))
{
error(parentType, Errors::E_RAWREPRESENTABLE_INIT_CANNOT_BE_SYNTHESIZED_BECAUSE_RAW_TYPE_A_IS_NOT_EQUATABLE_1, ptr->toString());
return nullptr;
}
parent = ptr;
}
else if(ptr->getCategory() == Type::Protocol)
{
protocols.push_back(ptr);
}
else
{
if(category == Type::Class)
error(parentType, Errors::E_INHERITANCE_FROM_NONE_PROTOCOL_NON_CLASS_TYPE_1, toString(parentType));
else
error(parentType, Errors::E_INHERITANCE_FROM_NONE_PROTOCOL_TYPE_1, toString(parentType));
return nullptr;
}
first = false;
}
//register this type
type = Type::newType(node->getIdentifier()->getName(), category, node, parent, protocols, generic);
node->setType(type);
if(parent && parent->getAccessLevel() == AccessLevelPublic && (node->getModifiers() & DeclarationModifiers::AccessModifiers) == 0)
type->setAccessLevel(AccessLevelPublic);//when access level is undefined, try to inherit base's access level
else
type->setAccessLevel(parseAccessLevel(node->getModifiers()));
currentScope->addSymbol(type);
if(node->hasModifier(DeclarationModifiers::Final))
type->setFlags(SymbolFlagFinal, true);
declarationFinished(type->getName(), type, node);
return type;
}