예제 #1
0
    ObjectList<AST_t> AST_t::children() const
    {
        ObjectList<AST_t> result;

        result.append(AST_t(ASTSon0(_ast)));
        result.append(AST_t(ASTSon1(_ast)));
        result.append(AST_t(ASTSon2(_ast)));
        result.append(AST_t(ASTSon3(_ast)));

        return result;
    }
예제 #2
0
        static Expression compute_bounds_of_sectioned_expression(Expression expr, 
                ObjectList<Expression>& lower_bounds, ObjectList<Expression>& upper_bounds)
        {
            if (expr.is_array_section_range())
            {
                Expression result 
                    = compute_bounds_of_sectioned_expression(expr.array_section_item(), lower_bounds, upper_bounds);
                lower_bounds.append(expr.array_section_lower());
                upper_bounds.append(expr.array_section_upper());

                return result;
            }
            return expr;
        }
예제 #3
0
        void fill_guard_tasks_basic(Statement stmt) 
        {
			struct IsOmpTask : public Predicate<AST_t>
			{
				ScopeLink _sl;
				IsOmpTask(ScopeLink sl)
					:_sl(sl)
					{
					}

				bool do_(IsOmpTask::ArgType a) const
				{
					return is_pragma_custom_construct("omp", "task", a, _sl);
				}
			};

            ObjectList<AST_t> tasks = stmt.get_ast().depth_subtrees(IsOmpTask(stmt.get_scope_link()));

            for (ObjectList<AST_t>::iterator it = tasks.begin();
                    it != tasks.end();
                    it++)
            {
                PragmaCustomConstruct task_construct(*it, stmt.get_scope_link());

                GuardedTask guarded_task(task_construct);
                _guarded_task_list.append(guarded_task);
                _num_tasks++;
            }
        }
예제 #4
0
파일: document.cpp 프로젝트: jmlee4301/kst
/** return a list of data objects where all dependencies appear earlier in the list */
ObjectList<DataObject> Document::sortedDataObjectList() {
  ObjectList<DataObject> sorted;
  ObjectList<DataObject> raw = objectStore()->getObjects<DataObject>();

  sorted.clear();


  // set the flag for all primitives: not strictly necessary
  // since it should have been done in the constructor, but...
  PrimitiveList all_primitives = objectStore()->getObjects<Primitive>();
  int n = all_primitives.size();
  for (int i=0; i<n; i++) {
    all_primitives[i]->setFlag(true);
  }

  // now unset the flags of all output primitives to indicate their parents haven't been
  // put in the sorted list yet
  n = raw.size();
  for (int i=0; i<n; i++) {
    raw[i]->setOutputFlags(false);
  }

  // now place into the sorted list all data objects whose inputs haven't got parents
  // or whose inputs have parents which are already in the sorted list.
  // do this at most n^2 times, which is worse than worse case.
  int i=0;
  while (!raw.isEmpty() && (++i <= n*n)) {
    DataObjectPtr D = raw.takeFirst();
    if (D->inputFlagsSet()) {
      D->setOutputFlags(true);
      sorted.append(D);
    } else {
      raw.append(D); // try again later
    }
  }

  if ((i== n*n) && (n>1)) {
    qDebug() << "Warning: loop detected, File will not be able to be loaded correctly!";
    while (!raw.isEmpty()) {
      DataObjectPtr D = raw.takeFirst();
      sorted.append(D);
    }
  }

  return sorted;
}
예제 #5
0
 ObjectList<MSAttribute> Symbol::get_ms_attributes() const
 {
     ObjectList<MSAttribute> result;
     for (int i = 0; i < _symbol->entity_specs.num_ms_attributes; i++)
     {
         result.append(_symbol->entity_specs.ms_attributes[i]);
     }
     return result;
 }
예제 #6
0
파일: tl-symbol.cpp 프로젝트: bsc-pm/mcxx
 ObjectList<Symbol> Symbol::get_related_symbols() const
 {
     ObjectList<Symbol> result;
     for (int i = 0; i < symbol_entity_specs_get_num_related_symbols(_symbol); i++)
     {
         result.append(symbol_entity_specs_get_related_symbols_num(_symbol, i));
     }
     return result;
 }
예제 #7
0
파일: tl-symbol.cpp 프로젝트: bsc-pm/mcxx
 ObjectList<MSAttribute> Symbol::get_ms_attributes() const
 {
     ObjectList<MSAttribute> result;
     for (int i = 0; i < symbol_entity_specs_get_num_ms_attributes(_symbol); i++)
     {
         result.append(symbol_entity_specs_get_ms_attributes_num(_symbol, i));
     }
     return result;
 }
예제 #8
0
 ObjectList<Symbol> Symbol::get_related_symbols() const
 {
     ObjectList<Symbol> result;
     for (int i = 0; i < _symbol->entity_specs.num_related_symbols; i++)
     {
         result.append(_symbol->entity_specs.related_symbols[i]);
     }
     return result;
 }
    std::string Type::get_declaration_with_parameters(Scope sc, const std::string& symbol_name,
            ObjectList<std::string>& parameters, ObjectList<std::string>& parameter_attributes, TypeDeclFlags flags) const
    {
        int num_parameters = this->parameters().size();

        const char** parameter_names  = new const char*[num_parameters + 1];
        const char** param_attributes = new const char*[num_parameters + 1];

        for (int i = 0; i < num_parameters; i++)
        {
            parameter_names[i] = NULL;
            param_attributes[i] = NULL;
        }

        int orig_size = parameters.size();
        for (int i = 0; i < orig_size; i++)
        {
            parameter_names[i] = uniquestr(parameters[i].c_str());
            param_attributes[i] = uniquestr(parameter_attributes[i].c_str());
        }

        const char* result = get_declaration_string(_type_info, sc._decl_context, symbol_name.c_str(),
                "", 0, num_parameters, parameter_names, param_attributes, flags == PARAMETER_DECLARATION);

        for (int i = 0; i < num_parameters; i++)
        {
            if (i < orig_size)
            {
                parameters[i] = parameter_names[i];
            }
            else
            {
                if (parameter_names[i] != NULL)
                    parameters.append(parameter_names[i]);
                else
                    parameters.append("");
            }
        }

        delete[] parameter_names;
        delete[] param_attributes;

        return result;
    }
void ExportVectorsDialog::updateVectorList() {
  VectorList allVectors = _store->getObjects<Vector>();

  QStringList vectorNameList;

  ObjectList<Vector> vectors;

  foreach (VectorPtr P, allVectors) {
    vectors.append(P);
    vectorNameList.append(P->Name());
  }
TL::ObjectList<TL::ForStatement> TL::HLT::get_all_sibling_for_statements(TL::Statement st)
{
    ObjectList<ForStatement> result;
    if (ForStatement::predicate(st.get_ast()))
    {
        result.append(ForStatement(st.get_ast(), st.get_scope_link()));
    }
    else if (st.is_compound_statement())
    {
        ObjectList<Statement> inner_stmt = st.get_inner_statements();
        for (ObjectList<Statement>::iterator it = inner_stmt.begin();
                it != inner_stmt.end();
                it++)
        {
            result.append(get_all_sibling_for_statements(*it));
        }
    }

    return result;
}
예제 #12
0
    ObjectList<TL::Type> Symbol::get_thrown_exceptions() const
    {
        ObjectList<TL::Type> result;

        for (int i = 0; i < _symbol->entity_specs.num_exceptions; i++)
        {
            result.append(_symbol->entity_specs.exceptions[i]);
        }

        return result;
    }
예제 #13
0
파일: tl-symbol.cpp 프로젝트: bsc-pm/mcxx
    ObjectList<TL::Type> Symbol::get_thrown_exceptions() const
    {
        ObjectList<TL::Type> result;

        for (int i = 0; i < symbol_entity_specs_get_num_exceptions(_symbol); i++)
        {
            result.append(symbol_entity_specs_get_exceptions_num(_symbol, i));
        }

        return result;
    }
예제 #14
0
 ObjectList<TL::Symbol> Symbol::get_function_parameters() const
 {
     ObjectList<Symbol> result;
     if ( is_function( ) )
     {
         for (int i = 0; i < _symbol->entity_specs.num_related_symbols; i++)
         {
             result.append(_symbol->entity_specs.related_symbols[i]);
         }
     }
     return result;
 }
예제 #15
0
파일: tl-symbol.cpp 프로젝트: bsc-pm/mcxx
 ObjectList<TL::Symbol> Symbol::get_function_parameters() const
 {
     ObjectList<Symbol> result;
     if ( is_function( ) )
     {
         for (int i = 0; i < symbol_entity_specs_get_num_related_symbols(_symbol); i++)
         {
             result.append(symbol_entity_specs_get_related_symbols_num(_symbol, i));
         }
     }
     return result;
 }
/**
 *
 * @param param_symbols List of symbols inside the body
 * @param funct_scopeB  Body Scope
 */
void InlinePhase::getParamSymbols(ObjectList<Symbol> &param_symbols, Scope& funct_scopeB) {
    ObjectList<Symbol> possible_params = funct_scopeB.get_all_symbols(0);
    int j = 0;
    for (ObjectList<Symbol>::iterator itu = possible_params.begin();
            itu != possible_params.end();
            itu++, j++) {
        if (itu->is_parameter() == 1) {
            param_symbols.append(possible_params[j]);
        }
    }

}
        /*!
         * \param t The element to be matched
         * \return A new list with all the elements of the original one
         * that are equals (according to 'operator==' of T) to \a t
         *
         * This function requires 'operator==' be defined for the type T
         */
        ObjectList<T> find(const T& t) const
        {
            ObjectList<T> result;

            for (typename ObjectList<T>::const_iterator it = std::find(this->begin(), this->end(), t);
                    it != this->end();
                    it++)
            {
                result.append(*it);
            }

            return result;
        }
    ObjectList<Symbol> Type::enum_get_enumerators()
    {
        ObjectList<Symbol> enumerators;

        int i;
        for (i = 0; i < enum_type_get_num_enumerators(this->_type_info); i++)
        {
            scope_entry_t* enumerator = enum_type_get_enumerator_num(this->_type_info, i);
            enumerators.append(enumerator);
        };

        return enumerators;
    }
    ObjectList<Type> Type::get_specializations() const
    {
        ObjectList<Type> result;

        int n = template_type_get_num_specializations(_type_info);

        for (int i = 0; i < n; i++)
        {
            result.append(template_type_get_specialization_num(_type_info, i));
        }

        return result;
    }
예제 #20
0
TL::Source LoopBlocking::do_blocking()
{
    ObjectList<ForStatement> nest_loops = _for_nest_info.get_nest_list();

    _nesting = std::min(_nest_factors.size(), nest_loops.size());

    for (int current_nest = _nesting - 1;
            current_nest >= 0;
            current_nest--)
    {
        ForStatement& for_statement = nest_loops[current_nest];
        Expression& amount = _nest_factors[current_nest];

        Source src = TL::HLT::stripmine_loop(for_statement, amount.prettyprint());

        TL::AST_t tree = src.parse_statement(for_statement.get_ast(), for_statement.get_scope_link());

        // This works because in the next iteration this tree will not be used anymore
        for_statement.get_ast().replace(tree);
    }

    // Now perform interchange
    // If the original nest was N long, the stripmined version will have 2*N
    // loops, so the permutation is {1, i+2, i+4, ..., 2, i+2, i+2, .., 2*N}
    // The following two loops create the permutation itself
    ObjectList<int> permutation;
    for (int i = 1; i <= (int)_nesting; i++)
    {
        permutation.append(2*i-1);
    }
    for (int i = 1; i <= (int)_nesting; i++)
    {
        permutation.append(2*i);
    }

    Source loop_interchange = TL::HLT::loop_interchange(nest_loops[0], permutation);
    return loop_interchange;
}
예제 #21
0
ObjectList<TaskPart> TaskAggregation::get_task_parts(Statement stmt)
{
    ObjectList<TaskPart> result;
    ObjectList<Statement> prologue;

    get_task_parts_aux(result, prologue, stmt);

    if (!prologue.empty())
    {
        TaskPart last_part(prologue);
        result.append(last_part);
    }

    return result;
}
예제 #22
0
void TaskAggregation::get_task_parts_aux(ObjectList<TaskPart>& result, ObjectList<Statement> &current_prologue, Statement stmt)
{
    if (is_pragma_custom_construct("omp", "task", stmt.get_ast(), stmt.get_scope_link()))
    {
        PragmaCustomConstruct task_construct(stmt.get_ast(), stmt.get_scope_link());
        TaskPart new_task_part(current_prologue, task_construct);
        result.append(new_task_part);
        current_prologue.clear();
    }
    else if (stmt.is_compound_statement())
    {
        ObjectList<Statement> stmt_list = stmt.get_inner_statements();
        for (ObjectList<Statement>::iterator it = stmt_list.begin();
                it != stmt_list.end();
                it++)
        {
            get_task_parts_aux(result, current_prologue, *it);
        }
    }
    else
    {
        current_prologue.append(stmt);
    }
}
        ObjectList<T> not_find(const Functor<S, T>& f, const S& s) const
        {
            ObjectList<T> result;

            for (typename ObjectList<T>::const_iterator it = this->begin();
                    it != this->end();
                    it++)
            {
                if (!(f(*it) == s))
                {
                    result.append(*it);
                }
            }

            return result;
        }
        /*!
         * \param t The element to be matched
         * \return A new list with all the elements of the original one
         * that are different (according to 'operator==' of T) to \a t
         *
         * This function requires 'operator==' be defined for the type T
         */
        ObjectList<T> not_find(const T& t) const
        {
            ObjectList<T> result;

            for (typename ObjectList<T>::const_iterator it = this->begin();
                    it != this->end();
                    it++)
            {
                if (!((*it) == t))
                {
                    result.append(*it);
                }
            }

            return result;
        }
        ObjectList<T> find(const T& t, const Functor<S, T>& f) const
        {
            ObjectList<T> result;

            for (typename ObjectList<T>::const_iterator it = this->begin();
                    it != this->end();
                    it++)
            {
                if (f(*it) == f(t))
                {
                    result.append(*it);
                }
            }

            return result;
        }
예제 #26
0
        static ObjectList<AST_t> compute_array_dimensions_of_type(Type t)
        {
            ObjectList<AST_t> result;

            if (t.is_array())
            {
                ObjectList<AST_t> previous_dim = compute_array_dimensions_of_type(t.array_element());

                if (!t.array_has_size())
                {
                    return result;
                }

                result = previous_dim;
                result.append(t.array_get_size());
            }

            return result;
        }
예제 #27
0
void RKVarSlot::listSelectionChanged () {
	RK_TRACE (PLUGIN);

	bool selection = false;

	ObjectList sellist;
	QListViewItem *item = list->firstChild ();
	while (item) {
		if (item->isSelected ()) {
			selection = true;
			RObject *robj = item_map[item];
			RK_ASSERT (robj);
			sellist.append (robj);
		}
		item = item->nextSibling ();
	}
	selected->setObjectList (sellist);

	setSelectButton (((!multi) || (!selection)) && (!available->atMaxLength ()));
}
        void OpenMP_PreTransform::add_local_symbol(function_sym_list_t& sym_list, Symbol function_sym, Symbol local)
        {
            bool found = false;
            for (function_sym_list_t::iterator it = sym_list.begin();
                    it != sym_list.end() && !found;
                    it++)
            {
                if (it->first == function_sym)
                {
                    it->second.insert(local);
                    found = true;
                }
            }

            if (!found)
            {
                ObjectList<Symbol> singleton;
                singleton.append(local);
                sym_list.append(function_symbols_pair_t(function_sym, singleton));
            }
        }
    ObjectList<Type::BaseInfo> Type::get_bases()
    {
        ObjectList<Type::BaseInfo> result;

        int n = class_type_get_num_bases(_type_info);
        for (int i = 0; i < n; i++)
        {
            scope_entry_t* symbol = NULL;
            char is_virtual = 0, is_dependent = 0, is_expansion = 0;
            access_specifier_t as = AS_UNKNOWN;

            symbol = class_type_get_base_num(_type_info, i,
                    &is_virtual,
                    &is_dependent,
                    &is_expansion,
                    &as);

            result.append(BaseInfo(symbol, is_virtual, is_dependent, is_expansion, as));
        }

        return result;
    }
    Symbol Overload::solve(
            ObjectList<Symbol> candidate_functions,
            Type implicit_argument_type,
            ObjectList<Type> argument_types, 
            const std::string filename,
            int line,
            bool &valid, 
            ObjectList<Symbol>& viable_functions,
            ObjectList<Symbol>& argument_conversor)
    {
        valid = false;

        // Try hard to not to do useless work
        if (candidate_functions.empty())
        {
            return Symbol(NULL);
        }

        scope_entry_list_t* first_candidate_list = NULL;
        
        // Build the candidates list
        for (ObjectList<Symbol>::iterator it = candidate_functions.begin();
                it != candidate_functions.end();
                it++)
        {
            Symbol sym(*it);
            first_candidate_list = entry_list_add(first_candidate_list, sym.get_internal_symbol());
        }

        // Build the type array
        unsigned int i = argument_types.size();
        type_t** argument_types_array = new type_t*[argument_types.size() + 1];
        argument_types_array[0] = implicit_argument_type.get_internal_type();
        for (i = 0; i < argument_types.size(); i++)
        {
            argument_types_array[i+1] = argument_types[i].get_internal_type();
        }

        // Now we need a decl_context_t but we were not given any explicitly,
        // use the one of the first candidate
        decl_context_t decl_context = candidate_functions[0].get_scope().get_decl_context();

        // Unfold and mix!
        scope_entry_list_t* candidate_list = NULL;
        candidate_list = unfold_and_mix_candidate_functions(first_candidate_list,
                NULL /* builtins */,
                &argument_types_array[1], argument_types.size(),
                decl_context,
                uniquestr(filename.c_str()), line,
                NULL /* explicit template arguments */);

        {
            ObjectList<Symbol> list;
            Scope::convert_to_vector(candidate_list, list);
            viable_functions.append(list);
        }

        candidate_t* candidate_set = NULL;

        scope_entry_list_iterator_t* it = NULL;
        for (it = entry_list_iterator_begin(candidate_list);
                !entry_list_iterator_end(it);
                entry_list_iterator_next(it))
        {
            scope_entry_t* entry = entry_list_iterator_current(it);
            if (entry->entity_specs.is_member)
            {
                candidate_set = add_to_candidate_set(candidate_set,
                        entry,
                        argument_types.size() + 1,
                        argument_types_array);
            }
            else
            {
                candidate_set = add_to_candidate_set(candidate_set,
                        entry,
                        argument_types.size(),
                        argument_types_array + 1);
            }
        }
        entry_list_iterator_free(it);

        // We also need a scope_entry_t** for holding the conversor argument
        scope_entry_t** conversor_per_argument = new scope_entry_t*[argument_types.size() + 1];

        // Now invoke all the machinery
        scope_entry_t* entry_result =
        solve_overload(candidate_set,
                decl_context,
                uniquestr(filename.c_str()), line,
                conversor_per_argument);

        if (entry_result != NULL)
        {
            valid = true;
            // Store the arguments
            argument_conversor.clear();
            for (i = 0; i < argument_types.size(); i++)
            {
                argument_conversor.append(Symbol(conversor_per_argument[i]));
            }
        }

        // Free the conversor per argument
        delete[] conversor_per_argument;

        // Free the type array
        delete[] argument_types_array;

        // Free the scope entry list
        free_scope_entry_list(candidate_list);

        // This one has been allocated above
        free_scope_entry_list(first_candidate_list);

        return Symbol(entry_result);
    }