Beispiel #1
0
void FunctionAnalyzer::visitSubscript(const SubscriptDefPtr &node)
{
    //TypeInference
    ParametersNodePtr parameters = node->getParameters();
    TypePtr retType = declarationAnalyzer->resolveType(node->getReturnType(), true);

    TypePtr type = declarationAnalyzer->resolveType(node->getReturnType(), true);
    assert(type != nullptr);
    std::vector<Parameter> params;
    for (const ParameterNodePtr &param : *node->getParameters())
    {
        wstring name = param->isShorthandExternalName() ? param->getLocalName() : param->getExternalName();
        TypePtr paramType = declarationAnalyzer->resolveType(param->getDeclaredType(), true);
        params.push_back(Parameter(name, param->isInout(), paramType));
        //verify index's access level
        declarationAnalyzer->verifyAccessLevel(node, paramType, DeclarationTypeSubscript, ComponentTypeIndex);
    }
    //verify element type's access level
    declarationAnalyzer->verifyAccessLevel(node, type, DeclarationTypeSubscript, ComponentTypeType);


    //process getter
    visitAccessor(node->getGetter(), parameters, nullptr, node->getModifiers());
    //process setter
    wstring setterName = L"newValue";
    if (!node->getSetterName().empty())
        setterName = node->getSetterName();
    SymbolPlaceHolderPtr setter(new SymbolPlaceHolder(setterName, retType, SymbolPlaceHolder::R_PARAMETER, SymbolFlagReadable | SymbolFlagInitialized));
    visitAccessor(node->getSetter(), parameters, setter, node->getModifiers());
}
Beispiel #2
0
void NodeVisitor::visitSubscript(const SubscriptDefPtr& node)
{
    ACCEPT(node->getGetter());
    ACCEPT(node->getSetter());
}