Exemple #1
0
ChainList<int> *ListView::getSelectedParams()
{
	static ChainList<int> list;
	LVITEM item;
	item.iItem=-1; item.iSubItem=0;
	item.mask=LVIF_PARAM; item.lParam=-1;
	list.clear();
	while((item.iItem=ListView_GetNextItem(hwndList,item.iItem,LVNI_SELECTED))!=-1){
		ListView_GetItem(hwndList,&item);
		list.put(-1,item.lParam);
	}
	return &list;
}
Exemple #2
0
//------------------------------add_chain_rule_entry--------------------------
void ArchDesc::add_chain_rule_entry(const char *src, const char *cost,
                                    const char *result) {
  // Look-up the operation in chain rule table
  ChainList *lst = (ChainList *)_chainRules[src];
  if (lst == NULL) {
    lst = new ChainList();
    _chainRules.Insert(src, lst);
  }
  if (!lst->search(result)) {
    if (cost == NULL) {
      cost = ((AttributeForm*)_globalNames[AttributeForm::_op_cost])->_attrdef;
    }
    lst->insert(result, cost, result);
  }
}
Exemple #3
0
//---------------------------chain_rule----------------------------------------
// Starting at 'operand', check if we know how to automatically generate other results
void ArchDesc::chain_rule(FILE *fp, const char *indent, const char *operand,
                          const Expr *icost, const char *irule, Dict &operands_chained_from,  ProductionState &status) {

    // Check if we have already generated chains from this starting point
    if( operands_chained_from[operand] != NULL ) {
        return;
    } else {
        operands_chained_from.Insert( operand, operand);
    }
    if( debug_output ) {
        fprintf(fp, "// chain rules starting from: %s  and  %s \n", (char *)operand, (char *)irule);    // %%%%% Explanation
    }

    ChainList *lst = (ChainList *)_chainRules[operand];
    if (lst) {
        // printf("\nChain from <%s> at cost #%s\n",operand, icost ? icost : "_");
        const char *result, *cost, *rule;
        for(lst->reset(); (lst->iter(result,cost,rule)) == true; ) {
            // Do not generate operands that are already available
            if( operands_chained_from[result] != NULL ) {
                continue;
            } else {
                // Compute the cost for previous match + chain_rule_cost
                // total_cost = icost + cost;
                Expr *total_cost = icost->clone();  // icost + cost
                total_cost->add(cost, *this);

                // Check for transitive chain rules
                Form *form = (Form *)_globalNames[rule];
                if ( ! form->is_instruction()) {
                    // printf("   result=%s cost=%s rule=%s\n", result, total_cost, rule);
                    // Check against other match costs, and update cost & rule vectors
                    const char *reduce_rule = strcmp(irule,"Invalid") ? irule : rule;
                    cost_check(fp, indent, ArchDesc::getMachOperEnum(result), total_cost, reduce_rule, status);
                    chain_rule(fp, indent, result, total_cost, irule, operands_chained_from, status);
                } else {
                    // printf("   result=%s cost=%s rule=%s\n", result, total_cost, rule);
                    // Check against other match costs, and update cost & rule vectors
                    cost_check(fp, indent, ArchDesc::getMachOperEnum(result), total_cost, rule, status);
                    chain_rule(fp, indent, result, total_cost, rule, operands_chained_from, status);
                }

                // If this is a member of an operand class, update class cost & rule
                expand_opclass( fp, indent, total_cost, result, status );
            }
        }
    }
}
Exemple #4
0
	ChainList chains(const AtomContainer& fragment, bool selected_only)
	{
    // iterate over all chains
    AtomContainerConstIterator it = fragment.beginAtomContainer();
		ChainList result;
    for (; +it; ++it)
    {
      const Chain* chain = dynamic_cast<const Chain*>(&*it);
      if ((chain != 0) && (it->isSelected() || !selected_only))
      {
        // store the chain pointer in the list
        result.push_back(const_cast<Chain*>(chain));
			}
		}
		return result;
	}
Exemple #5
0
static void processCompoundPattern( const PatternMatchState & state, TransitionList & newTransitions ) {
	const Node & currentNode = state.getCurrentNode();

	if ( state.isComplete() ) { // Сопоставление завершено
		Match::AttributesMap attributes;

		state.context.addAttributes( attributes, state.getAlternative().getBindings() ); // Строим набор аттрибутов

		for ( uint i = 0; i < newTransitions.size(); ++ i ) {
			Match & match = static_cast<Match&>( *newTransitions[i] );

			if ( match.equals( state.getAlternative().getPattern(), state.startNode, currentNode, attributes ) ) {
				match.addVariant( state.releaseVariant() );
				return; // Если сопоставление уже было найдено
			}
		}

		newTransitions.push_back( new Match( state.startNode, currentNode, state.getAlternative().getPattern(), state.releaseVariant(), attributes ) ); // TODO Optimize

		return;
	}

	ChainList chains;

	if ( const AnnotationMatcher * curMatcher = dynamic_cast<const AnnotationMatcher *>( &state.getCurrentMatcher() ) ) {
		TransitionList nextTransitions = curMatcher->buildTransitions( currentNode, state.context );

		for ( uint i = 0, sz = nextTransitions.size(); i < sz; ++ i ) {
			PatternMatchState temp_state( state, nextTransitions[ i ], i == sz );
			processCompoundPattern( temp_state, newTransitions );
		}
	} else {
		const AnnotationChainMatcher & chainMatcher = static_cast<const AnnotationChainMatcher &>( state.getCurrentMatcher() );

		chains.clear();
		chainMatcher.buildChains( state.getCurrentNode(), state.context, chains );

		for ( uint i = 0, sz = chains.size(); i < sz; ++ i ) {
			PatternMatchState temp_state( state, chains[i].first, chains[i].second, i == sz - 1  );
			processCompoundPattern( temp_state, newTransitions);
		}
	}
}
Exemple #6
0
void
family::Release()
{
	if (atomic_add(&ref_count, -1) > 1)
		return;

	TRACE(("family %d unused, uninit chains\n", type));
	MutexLocker _(sChainLock);

	ChainList::Iterator iterator = chains.GetIterator();
	while (struct chain* chain = iterator.Next()) {
		chain->Uninitialize();
	}
}
Exemple #7
0
void PatternMatcher::buildTransitions( const text::Transition & transition, const patterns::Pattern & pattern, const patterns::Alternative & alt, const Context & context, TransitionList & results ) const {
	if ( const AnnotationMatcher * curMatcher = dynamic_cast<const AnnotationMatcher *>( &alt.getMatcher( 0 ) ) ) {
		if ( !curMatcher->matchTransition( transition, Context() ) )
			return;

		PatternMatchState s0( pattern, alt, transition.start );
		PatternMatchState state( s0, const_cast<text::Transition*>( &transition ), true );

		processCompoundPattern( state, results );
	} else {
		PatternMatchState s0( pattern, alt, transition.start );
		const AnnotationChainMatcher & chainMatcher = dynamic_cast<const AnnotationChainMatcher &>( alt.getMatcher( 0 ) );

		ChainList chains; // Список цепочек

		chainMatcher.buildChains( transition, s0.context, chains ); // Заполняем список цепочек

		// TODO Optimize: Необходимо отдельно рассмотреть случай пустой цепи
		for ( uint i = 0, sz = chains.size(); i < sz; ++ i ) {
			PatternMatchState state( s0, chains[i].first, chains[i].second, i == sz - 1 );
			processCompoundPattern( state, results );
		}
	}
}