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


C++ ObjectList::contains方法代码示例

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


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

示例1: convert_vla

        static void convert_vla(Symbol sym, ObjectList<Symbol>& converted_vlas, ScopeLink sl)
        {
            if (converted_vlas.contains(sym))
                return;

            ObjectList<Source> dim_decls;
            ObjectList<Source> dim_names;

            dimensional_replacements_of_variable_type_aux(sym.get_type(),
                    sym, dim_names, dim_decls);

            Source new_decls;
            for (ObjectList<Source>::iterator it = dim_decls.begin();
                    it != dim_decls.end();
                    it++)
            {
                new_decls << *it << ";"
                    ;
            }

            AST_t point_of_decl = sym.get_point_of_declaration();
            AST_t enclosing_stmt_tree;
            if (sym.is_parameter())
            {
                FunctionDefinition 
                    funct_def(point_of_decl.get_enclosing_function_definition(), sl);

                enclosing_stmt_tree = funct_def.get_function_body().get_inner_statements()[0].get_ast();
            }
            else
            {
                enclosing_stmt_tree = point_of_decl.get_enclosing_statement();
            }

            AST_t statement_seq 
                = new_decls.parse_statement(enclosing_stmt_tree, sl);
            enclosing_stmt_tree.prepend(statement_seq);

            if (!sym.is_parameter())
            {
                // If this is not a parameter, we'll want to rewrite the declaration itself
                Type new_type_spawn = compute_replacement_type_for_vla(sym.get_type(), dim_names.begin(), dim_names.end());

                // Now redeclare
                Source redeclaration, initializer;
                redeclaration
                    << new_type_spawn.get_declaration(sym.get_scope(), sym.get_name())
                    << initializer
                    << ";"
                    ;

                if (sym.has_initialization()) 
                {
                    initializer << sym.get_initialization().prettyprint()
                        ;
                }

                AST_t redeclaration_tree = redeclaration.parse_statement(enclosing_stmt_tree,
                        sl, Source::ALLOW_REDECLARATION);

                enclosing_stmt_tree.prepend(redeclaration_tree);

                // Now remove the declarator of the declaration
                Declaration decl(point_of_decl, sl);

                if (decl.get_declared_entities().size() == 1)
                {
                    // We have to remove all the whole declaration
                    enclosing_stmt_tree.remove_in_list();
                }
                else
                {
                    // Remove only this entity
                    ObjectList<DeclaredEntity> entities = decl.get_declared_entities();
                    for (ObjectList<DeclaredEntity>::iterator it = entities.begin();
                            it != entities.end();
                            it++)
                    {
                        if (it->get_declared_symbol() == sym)
                        {
                            it->get_ast().remove_in_list();
                        }
                    }
                }
            }

            ObjectList<Source>* new_dim_ptr = new ObjectList<Source>(dim_names);

            RefPtr<ObjectList<Source> > dim_names_ref(new_dim_ptr);
            sym.set_attribute(OMP_NANOX_VLA_DIMS, dim_names_ref);

            converted_vlas.insert(sym);
        }
开发者ID:sdruix,项目名称:AutomaticParallelization,代码行数:93,代码来源:tl-data-env.cpp


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