当前位置: 首页>>代码示例>>C++>>正文


C++ IdentifierPtr类代码示例

本文整理汇总了C++中IdentifierPtr的典型用法代码示例。如果您正苦于以下问题:C++ IdentifierPtr类的具体用法?C++ IdentifierPtr怎么用?C++ IdentifierPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了IdentifierPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: TEST

TEST(TestDeclaration, testLet)
{
    PARSE_STATEMENT(L"let a : Int[] = [1, 2, 3]");
    ValueBindingsPtr c;
    IdentifierPtr id;
    ValueBindingPtr a;
    ArrayLiteralPtr value;
    ArrayTypePtr type;
    TypeIdentifierPtr Int;
    ASSERT_NOT_NULL(c = std::dynamic_pointer_cast<ValueBindings>(root));
    ASSERT_TRUE(c->isReadOnly());
    ASSERT_EQ(1, c->numBindings());
    ASSERT_NOT_NULL(a = c->get(0));
    ASSERT_NOT_NULL(id = std::dynamic_pointer_cast<Identifier>(a->getName()));
    ASSERT_EQ(L"a", id->getIdentifier());
    ASSERT_NOT_NULL(type = std::dynamic_pointer_cast<ArrayType>(a->getDeclaredType()));
    ASSERT_NOT_NULL(Int = std::dynamic_pointer_cast<TypeIdentifier>(type->getInnerType()));
    ASSERT_EQ(L"Int", Int->getName());

    ASSERT_NOT_NULL(value = std::dynamic_pointer_cast<ArrayLiteral>(c->get(0)->getInitializer()));
    ASSERT_EQ(3, value->numElements());
    ASSERT_EQ(L"1", std::dynamic_pointer_cast<IntegerLiteral>(value->getElement(0))->valueAsString);
    ASSERT_EQ(L"2", std::dynamic_pointer_cast<IntegerLiteral>(value->getElement(1))->valueAsString);
    ASSERT_EQ(L"3", std::dynamic_pointer_cast<IntegerLiteral>(value->getElement(2))->valueAsString);

}
开发者ID:Jornason,项目名称:swallow,代码行数:26,代码来源:TestDeclaration.cpp

示例2: Identifier

	IdentifierPtr CNodeManager::create(const string& name) {
		auto pos = identMap.find(name);
		if(pos != identMap.end()) { return pos->second; }

		IdentifierPtr res = new Identifier(name);
		res->setManager(this);
		identMap.insert(std::make_pair(name, res));
		return res;
	}
开发者ID:insieme,项目名称:insieme,代码行数:9,代码来源:c_ast.cpp

示例3: loadDependent

void loadDependent(ModulePtr m, vector<string> *sourceFiles, ImportPtr dependent, bool verbose) {
    ImportPtr x = dependent;
    x->module = loadModuleByName(x->dottedName, sourceFiles, verbose);
    switch (x->importKind) {
    case IMPORT_MODULE : {
            ImportModule *im = (ImportModule *)x.ptr();
            IdentifierPtr name = NULL;
            if (im->alias.ptr()) {
                name = im->alias;
                m->importedModuleNames[im->alias->str].module = x->module;
            } else {
                llvm::ArrayRef<IdentifierPtr> parts = im->dottedName->parts;
                if (parts.size() == 1)
                    name = parts[0];
                else if (x->visibility == PUBLIC)
                    error(x->location,
                          "public imports of dotted module paths must have an \"as <name>\" alias");
                llvm::StringMap<ModuleLookup> *node = &m->importedModuleNames;
                for (size_t i = parts.size() - 1; i >= 1; --i) {
                    node = &(*node)[parts[i]->str].parents;
                }
                (*node)[parts[0]->str].module = x->module;
            }
            
            if (name.ptr()) {
                string nameStr(name->str.begin(), name->str.end());
                if (m->importedNames.count(nameStr))
                    error(name, "name imported already: " + nameStr);
                m->importedNames.insert(nameStr);
                m->allSymbols[nameStr].insert(x->module.ptr());
                if (x->visibility == PUBLIC)
                    m->publicSymbols[nameStr].insert(x->module.ptr());
            }
            
            break;
        }
    case IMPORT_STAR :
        break;
    case IMPORT_MEMBERS : {
            ImportMembers *y = (ImportMembers *)x.ptr();
            for (unsigned i = 0; i < y->members.size(); ++i) {
                ImportedMember &z = y->members[i];
                IdentifierPtr alias = z.alias.ptr() ? z.alias : z.name;
                string aliasStr(alias->str.begin(), alias->str.end());
                if (m->importedNames.count(aliasStr))
                    error(alias, "name imported already: " + aliasStr);
                assert(y->aliasMap.count(aliasStr) == 0);
                m->importedNames.insert(aliasStr);
                y->aliasMap[aliasStr] = z.name;
            }
            break;
        }
    default :
            assert(false);
}
}
开发者ID:Blei,项目名称:clay,代码行数:56,代码来源:loader.cpp

示例4: type

        void Union::
        type (IdentifierPtr const& id)
        {
          if (ctx.trace ()) cerr << "type " << id << endl;

          type_ = 0;

          Name name (id->lexeme ());
          ScopedName from (ctx.scope ().scoped_name ());

          try
          {
            try
            {
              type_ = &resolve<Type> (from, name);

              if (!(dynamic_cast<Enum*> (type_) ||
                    dynamic_cast<Boolean*> (type_) ||
                    dynamic_cast<Char*> (type_) ||
                    dynamic_cast<Wchar*> (type_) ||
                    dynamic_cast<Short*> (type_) ||
                    dynamic_cast<UnsignedShort*> (type_) ||
                    dynamic_cast<Long*> (type_) ||
                    dynamic_cast<UnsignedLong*> (type_) ||
                    dynamic_cast<LongLong*> (type_) ||
                    dynamic_cast<UnsignedLongLong*> (type_)))
              {
                throw WrongType (type_->scoped_name ());
              }

              ctx.tu ().new_edge<ArgumentsWithType> (*type_, now ());
            }
            catch (Resolve const&)
            {
              cerr << ctx.file () << ":" << id->line () << ": error: "
                   << "invalid union declaration" << endl;
              throw;
            }
          }
          catch (NotFound const&)
          {
            cerr << ctx.file () << ":" << id->line () << ": error: "
                 << "no type with name \'" << name
                 << "\' visible from scope \'" << from << "\'" << endl;
          }
          catch (WrongType const&)
          {
            cerr << ctx.file () << ":" << id->line () << ": error: "
                 << "declaration with name \'" << name
                 << "\' visible from scope \'" << from
                 << "\' is not a valid discriminant type" << endl;
          }
        }
开发者ID:SEDS,项目名称:CUTS,代码行数:53,代码来源:Union.cpp

示例5: begin_unbounded_seq

void Typedef::
begin_unbounded_seq (IdentifierPtr const& id)
{
    if (ctx.trace ())
        cerr << "typedef u-sequence<" << id << ">" << endl;

    define_ = true;
    type_ = 0;
    array_type_ = 0;

    Name name (id->lexeme ());
    ScopedName from (ctx.scope ().scoped_name ());

    try
    {
        try
        {
            Type& t (resolve<Type> (from, name));

            UnboundedSequence& s (
                ctx.tu ().new_node<UnboundedSequence> (
                    ctx.file (), line_));

            ctx.tu ().new_edge<ArgumentsWithType> (t, s);

            type_ = &s;
        }
        catch (Resolve const&)
        {
            cerr << ctx.file () << ":" << id->line () << ": error: "
                 << "invalid sequence declaration" << endl;
            throw;
        }
    }
    catch (NotFound const&)
    {
        cerr << ctx.file () << ":" << id->line () << ": error: "
             << "no type with name \'" << name
             << "\' visible from scope \'" << from << "\'" << endl;
    }
    catch (WrongType const&)
    {
        cerr << ctx.file () << ":" << id->line () << ": error: "
             << "declaration with name \'" << name
             << "\' visible from scope \'" << from
             << "\' is not a type declaration" << endl;

        cerr << ctx.file () << ":" << id->line () << ": error: "
             << "using non-type in sequence specialization is illegal"
             << endl;
    }
}
开发者ID:EnasAlikhashashashneh,项目名称:OASIS,代码行数:52,代码来源:Typedef.cpp

示例6: convertFreeVars

void convertFreeVars(LambdaPtr x, EnvPtr env,
                     const string &closureDataName,
                     vector<string> &freeVars)
{
    EnvPtr env2 = new Env(env);
    for (unsigned i = 0; i < x->formalArgs.size(); ++i) {
        IdentifierPtr name = x->formalArgs[i];
        addLocal(env2, name, name.ptr());
    }
    if (x->formalVarArg.ptr()) {
        addLocal(env2, x->formalVarArg, x->formalVarArg.ptr());
    }
    LambdaContext ctx(x->captureByRef, env, closureDataName, freeVars);
    convertFreeVars(x->body, env2, ctx);
}
开发者ID:ceninan,项目名称:clay,代码行数:15,代码来源:lambdas.cpp

示例7: TEST

TEST(TestFunc, testFunc)
{
    PARSE_STATEMENT(L"func stepForward(input: Int) -> Int {"
                       L"return input + 1"
                       L"}");
    FunctionDefPtr func;
    ParametersNodePtr params;
    ParameterNodePtr param;
    TypeIdentifierPtr type;
    CodeBlockPtr cb;
    ReturnStatementPtr ret;
    BinaryOperatorPtr add;
    IdentifierPtr id;
    IntegerLiteralPtr i;
    ASSERT_NOT_NULL(func = std::dynamic_pointer_cast<FunctionDef>(root));
    ASSERT_EQ(L"stepForward", func->getName());
    ASSERT_EQ(1, func->numParameters());
    ASSERT_NOT_NULL(params = func->getParameters(0));
    ASSERT_EQ(1, params->numParameters());
    ASSERT_NOT_NULL(param = params->getParameter(0));
    ASSERT_EQ(ParameterNode::None, param->getAccessibility());
    ASSERT_FALSE(param->isShorthandExternalName());
    ASSERT_FALSE(param->isInout());
    ASSERT_NULL(param->getDefaultValue());
    ASSERT_EQ(L"", param->getExternalName());
    ASSERT_EQ(L"input", param->getLocalName());
    ASSERT_NOT_NULL(type = std::dynamic_pointer_cast<TypeIdentifier>(param->getDeclaredType()));
    ASSERT_EQ(L"Int", type->getName());

    ASSERT_NOT_NULL(type = std::dynamic_pointer_cast<TypeIdentifier>(func->getReturnType()));
    ASSERT_EQ(L"Int", type->getName());

    ASSERT_NOT_NULL(cb = func->getBody());
    ASSERT_EQ(1, cb->numStatements());

    ASSERT_NOT_NULL(ret = std::dynamic_pointer_cast<ReturnStatement>(cb->getStatement(0)));
    ASSERT_NOT_NULL(add = std::dynamic_pointer_cast<BinaryOperator>(ret->getExpression()));
    ASSERT_EQ(L"+", add->getOperator());

    ASSERT_NOT_NULL(id = std::dynamic_pointer_cast<Identifier>(add->getLHS()));
    ASSERT_NOT_NULL(i = std::dynamic_pointer_cast<IntegerLiteral>(add->getRHS()));

    ASSERT_EQ(L"input", id->getIdentifier());
    ASSERT_EQ(L"1", i->valueAsString);


}
开发者ID:healerkx,项目名称:swallow,代码行数:47,代码来源:TestFunc.cpp

示例8: raises

        void EventTypeFactory::
        raises (IdentifierPtr const& id)
        {
          if (ctx.trace ()) cerr << "raises " << id << endl;

          if (f_ == 0) return;

          Name name (id->lexeme ());
          ScopedName from (ctx.scope ().scoped_name ());

          try
          {
            try
            {
              SemanticGraph::Exception& e (
                resolve<SemanticGraph::Exception> (from, name));

              ctx.tu ().new_edge<Raises> (*f_, e);
            }
            catch (Resolve const&)
            {
              cerr << ctx.file () << ":" << id->line () << ": error: "
                   << "invalid raises declaration" << endl;
              throw;
            }
          }
          catch (NotFound const&)
          {
            cerr << ctx.file () << ":" << id->line () << ": error: "
                 << "no exception with name \'" << name
                 << "\' visible from scope \'" << from << "\'" << endl;
          }
          catch (WrongType const&)
          {
            cerr << ctx.file () << ":" << id->line () << ": error: "
                 << "declaration with name \'" << name
                 << "\' visible from scope \'" << from
                 << "\' is not an exception declaration" << endl;

            cerr << ctx.file () << ":" << id->line () << ": error: "
                 << "using non-exception type in raises declaration is "
                 << "illegal" << endl;
          }
        }
开发者ID:DOCGroup,项目名称:XSC,代码行数:44,代码来源:EventTypeFactory.cpp

示例9: begin

void Typedef::
begin (IdentifierPtr const& id)
{
    if (ctx.trace ())
        cerr << "typedef " << id << endl;

    define_ = false;
    type_ = 0;
    array_type_ = 0;

    Name name (id->lexeme ());
    ScopedName from (ctx.scope ().scoped_name ());

    try
    {
        try
        {
            type_ = &resolve<Type> (from, name);
        }
        catch (Resolve const&)
        {
            cerr << ctx.file () << ":" << id->line () << ": error: "
                 << "invalid typedef declaration" << endl;
            throw;
        }
    }
    catch (NotFound const&)
    {
        cerr << ctx.file () << ":" << id->line () << ": error: "
             << "no type with name \'" << name
             << "\' visible from scope \'" << from << "\'" << endl;
    }
    catch (WrongType const&)
    {
        cerr << ctx.file () << ":" << id->line () << ": error: "
             << "declaration with name \'" << name
             << "\' visible from scope \'" << from
             << "\' is not a type declaration" << endl;

        cerr << ctx.file () << ":" << id->line () << ": error: "
             << "using non-type in typedef is illegal" << endl;
    }
}
开发者ID:EnasAlikhashashashneh,项目名称:OASIS,代码行数:43,代码来源:Typedef.cpp

示例10: supports

        void Component::
        supports (IdentifierPtr const& id)
        {
          if (ctx.trace ()) cerr << " supports " << id << endl;

          Name name (id->lexeme ());
          ScopedName from (ctx.scope ().scoped_name ());

          try
          {
            try
            {
              SemanticGraph::Interface& i (
                resolve<SemanticGraph::Interface> (from, name, Flags::defined));

              check_support (now ().supports_begin (),
                             now ().supports_end (),
                             i);

              ctx.tu ().new_edge<Supports> (now (), i);
              ctx.tu ().new_edge<Extends> (now (), i);
            }
            catch (Resolve const&)
            {
              cerr << ctx.file () << ":" << id->line () << ": error: "
                   << "invalid supports specification" << endl;
              throw;
            }
          }
          catch (NotFound const&)
          {
            cerr << ctx.file () << ":" << id->line () << ": error: "
                 << "no interface with name \'" << name
                 << "\' visible from scope \'" << from << "\'" << endl;
          }
          catch (WrongType const&)
          {
            cerr << ctx.file () << ":" << id->line () << ": error: "
                 << "incompatible type in supports specification" << endl;
          }
          catch (NotDefined const& e)
          {
            cerr << ctx.file () << ":" << id->line () << ": error: "
                 << "attempt to support forward-declared interface "
                 << e.name () << endl;

            cerr << ctx.file () << ":" << id->line () << ": error: "
                 << "support of forward-declared interface is illegal"
                 << endl;
          }
          catch (AlreadySupported const& e)
          {
            cerr << ctx.file () << ":" << id->line () << ": error: "
                 << "directly supporting interface \'" << e.name ()
                 << "\' more than once is illegal" << endl;
          }
        }
开发者ID:DOCGroup,项目名称:XSC,代码行数:57,代码来源:Component.cpp

示例11: type

        void Publishes::
        type (IdentifierPtr const& id)
        {
          if (ctx.trace ()) cerr << "publishes " << id;

          type_ = 0;

          Name name (id->lexeme ());
          ScopedName from (ctx.scope ().scoped_name ());

          try
          {
            try
            {
              type_ = &resolve<EventType> (from, name);
            }
            catch (Resolve const&)
            {
              cerr << ctx.file () << ":" << id->line () << ": error: "
                   << "invalid publishes declaration" << endl;
              throw;
            }
          }
          catch (NotFound const&)
          {
            cerr << ctx.file () << ":" << id->line () << ": error: "
                 << "no eventtype with name \'" << name
                 << "\' visible from scope \'" << from << "\'" << endl;
          }
          catch (WrongType const&)
          {
            cerr << ctx.file () << ":" << id->line () << ": error: "
                 << "declaration with name \'" << name
                 << "\' visible from scope \'" << from
                 << "\' is not an eventtype declaration" << endl;

            cerr << ctx.file () << ":" << id->line () << ": error: "
                 << "using non-eventtype in publishes declaration is illegal"
                 << endl;
          }
        }
开发者ID:DOCGroup,项目名称:XSC,代码行数:41,代码来源:Publishes.cpp

示例12: parameter

        void EventTypeFactory::
        parameter (IdentifierPtr const& type_id,
                   SimpleIdentifierPtr const& name_id)
        {
          if (ctx.trace ()) cerr << "parameter in " << " "
                                 << type_id << " " << name_id << endl;

          if (f_ == 0) return;

          Name name (type_id->lexeme ());
          ScopedName from (ctx.scope ().scoped_name ());

          try
          {
            try
            {
              Type& t (resolve<Type> (from, name, Flags::complete));

              Parameter& p (
                ctx.tu ().new_node<InParameter> (
                  ctx.file (), name_id->line (), name_id->lexeme ()));

              ctx.tu ().new_edge<Belongs> (p, t);
              ctx.tu ().new_edge<Receives> (*f_, p);
            }
            catch (Resolve const&)
            {
              cerr << ctx.file () << ":" << type_id->line () << ": error: "
                   << "invalid parameter declaration" << endl;
              throw;
            }
          }
          catch (NotFound const&)
          {
            cerr << ctx.file () << ":" << type_id->line () << ": error: "
                 << "no type with name \'" << name
                 << "\' visible from scope \'" << from << "\'" << endl;
          }
          catch (WrongType const&)
          {
            cerr << ctx.file () << ":" << type_id->line () << ": error: "
                 << "declaration with name \'" << name
                 << "\' visible from scope \'" << from
                 << "\' is not a type declaration" << endl;

            cerr << ctx.file () << ":" << type_id->line () << ": error: "
                 << "using non-type as an factory parameter type is "
                 << "illegal" << endl;
          }
          catch (NotComplete const& e)
          {
            cerr << ctx.file () << ":" << type_id->line () << ": error: "
                 << "type \'" << e.name () << "\' is not complete" << endl;
          }
        }
开发者ID:DOCGroup,项目名称:XSC,代码行数:55,代码来源:EventTypeFactory.cpp

示例13: type

        void Member::
        type (IdentifierPtr const& id)
        {
          if (ctx.trace ()) cerr << "member " << id << endl;

          type_ = 0;

          Name name (id->lexeme ());
          ScopedName from (ctx.scope ().scoped_name ());

          try
          {
            try
            {
              // With introduction of CORBA 3.1 we have a new beast:
              // struct with incoplete members which itself becomes
              // incomplete.
              //
              type_ = &resolve<Type> (from, name/*, Flags::complete*/);
            }
            catch (Resolve const&)
            {
              cerr << ctx.file () << ":" << id->line () << ": error: "
                   << "invalid member declaration" << endl;
              throw;
            }

            //@@ I am not handling NotUnique here. For example if
            //   I provide module name as type then the compiler
            //   will ICE. Think about other places it may happen
            //   (attribute, value memebr, typeded, others?).
            //
          }
          catch (NotFound const&)
          {
            cerr << ctx.file () << ":" << id->line () << ": error: "
                 << "no type with name \'" << name
                 << "\' visible from scope \'" << from << "\'" << endl;
          }
          catch (WrongType const&)
          {
            cerr << ctx.file () << ":" << id->line () << ": error: "
                 << "declaration with name \'" << name
                 << "\' visible from scope \'" << from
                 << "\' is not a type declaration" << endl;

            cerr << ctx.file () << ":" << id->line () << ": error: "
                 << "using non-type as a member type is illegal" << endl;
          }
          catch (NotComplete const& e)
          {
            cerr << ctx.file () << ":" << id->line () << ": error: "
                 << "type \'" << e.name () << "\' is not complete" << endl;
          }
        }
开发者ID:SEDS,项目名称:CUTS,代码行数:55,代码来源:Member.cpp

示例14: raises

        void Operation::
        raises (IdentifierPtr const& id)
        {
          if (ctx.trace ()) cerr << "raises " << id << endl;

          Name name (id->lexeme ());
          ScopedName from (ctx.scope ().scoped_name ());

          struct OneWay : Resolve {};

          try
          {
            try
            {
              if (one_way_)
                throw OneWay ();

              SemanticGraph::Exception& e (
                resolve<SemanticGraph::Exception> (from, name));

              ctx.tu ().new_edge<Raises> (*op_, e);
            }
            catch (Resolve const&)
            {
              cerr << ctx.file () << ":" << id->line () << ": error: "
                   << "invalid raises declaration" << endl;
              throw;
            }
          }
          catch (NotFound const&)
          {
            cerr << ctx.file () << ":" << id->line () << ": error: "
                 << "no exception with name \'" << name
                 << "\' visible from scope \'" << from << "\'" << endl;
          }
          catch (WrongType const&)
          {
            cerr << ctx.file () << ":" << id->line () << ": error: "
                 << "declaration with name \'" << name
                 << "\' visible from scope \'" << from
                 << "\' is not an exception declaration" << endl;

            cerr << ctx.file () << ":" << id->line () << ": error: "
                 << "using non-exception type in raises declaration is "
                 << "illegal" << endl;
          }
          catch (OneWay const&)
          {
            cerr << ctx.file () << ":" << id->line () << ": error: "
                 << "oneway operation may not raise exceptions" << endl;
          }
        }
开发者ID:EnasAlikhashashashneh,项目名称:OASIS,代码行数:52,代码来源:Operation.cpp

示例15: inherits

        void Component::
        inherits (IdentifierPtr const& id)
        {
          if (ctx.trace ()) cerr << " inherits " << id << endl;

          Name name (id->lexeme ());
          ScopedName from (ctx.scope ().scoped_name ());

          try
          {
            try
            {
              SemanticGraph::Component& c (
                resolve<SemanticGraph::Component> (from, name, Flags::defined));

              ctx.tu ().new_edge<Inherits> (now (), c);
              ctx.tu ().new_edge<Extends> (now (), c);
            }
            catch (Resolve const&)
            {
              cerr << ctx.file () << ":" << id->line () << ": error: "
                   << "invalid inheritance specification" << endl;
              throw;
            }
          }
          catch (NotFound const&)
          {
            cerr << ctx.file () << ":" << id->line () << ": error: "
                 << "no component with name \'" << name
                 << "\' visible from scope \'" << from << "\'" << endl;
          }
          catch (WrongType const&)
          {
            cerr << ctx.file () << ":" << id->line () << ": error: "
                 << "incompatible type in inheritance specification" << endl;
          }
          catch (NotDefined const& e)
          {
            cerr << ctx.file () << ":" << id->line () << ": error: "
                 << "attempt to inherit from forward-declared component "
                 << e.name () << endl;

            cerr << ctx.file () << ":" << id->line () << ": error: "
                 << "inheritance from forward-declared component is illegal"
                 << endl;
          }
        }
开发者ID:DOCGroup,项目名称:XSC,代码行数:47,代码来源:Component.cpp


注:本文中的IdentifierPtr类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。