예제 #1
0
LRESULT CLabelListCtrl::OnP4EndSpecEdit( WPARAM wParam, LPARAM lParam )
{
	CCmd_EditSpec *pCmd= (CCmd_EditSpec *) wParam;
	int index;

	if (lParam != IDCANCEL && lParam != IDABORT)
	{
		if (m_UpdateState == LIST_UPDATED)
		{
			if(m_NewLabel && FindInList(m_pNewSpec->GetLabelName()) == -1)
			{
				InsertLabel(m_pNewSpec, GetItemCount());
				ReSort();
				index= FindInList(m_pNewSpec->GetLabelName());
			}
			else
			{
				index= FindInList(m_pNewSpec->GetLabelName());
				UpdateLabel(m_pNewSpec, index);
			}
			EnsureVisible(index, TRUE );
			SetItemState(index, LVIS_SELECTED|LVIS_FOCUSED, LVIS_DROPHILITED|LVIS_SELECTED|LVIS_FOCUSED );
		}
		else
			if ( m_pNewSpec ) delete m_pNewSpec;
	}
	else
		if ( m_pNewSpec ) delete m_pNewSpec;

	if (lParam != IDABORT)
	{
		MainFrame()->ClearStatus();
		if (pCmd->HaveServerLock())
			pCmd->ReleaseServerLock();
		CDialog *dlg = (CDialog *)pCmd->GetSpecSheet();
		dlg->DestroyWindow();
	}
	delete pCmd;
	m_EditInProgress = FALSE;
	return 0;
}
예제 #2
0
TargetPhraseCollection &
RuleTrieScope3::Node::GetOrCreateTargetPhraseCollection(
  const TargetPhrase &target)
{
  const AlignmentInfo &alignmentInfo = target.GetAlignNonTerm();
  const std::size_t rank = alignmentInfo.GetSize();

  std::vector<int> vec;
  vec.reserve(rank);

  m_labelTable.resize(rank);

  int i = 0;
  for (AlignmentInfo::const_iterator p = alignmentInfo.begin();
       p != alignmentInfo.end(); ++p) {
    std::size_t targetNonTermIndex = p->second;
    const Word &targetNonTerm = target.GetWord(targetNonTermIndex);
    vec.push_back(InsertLabel(i++, targetNonTerm));
  }

  return m_labelMap[vec];
}
예제 #3
0
파일: iflow.c 프로젝트: jossk/OrangeC
static void MoveBlockTo(BLOCK *b)
{
    BLOCK *prev = b->pred->block;
    BLOCK *succ = b->succ->block;
    QUAD *head;
    QUAD *tail = prev->tail;
    QUAD *jmp = Alloc(sizeof(QUAD));
    QUAD *insert = b->tail;
    int label = nextLabel++;
    if (b->tail->dc.opcode == i_blockend)
        RemoveInstruction(b->tail);
    // insert a jump at the end of the block
    jmp->dc.opcode = i_goto;
    jmp->block = b;
    jmp->dc.v.label = label;
    jmp->fwd = b->tail->fwd;
    jmp->back = b->tail;
    if (jmp->fwd)
        jmp->fwd->back = jmp;
    jmp->back->fwd = jmp;
    b->tail = jmp;
    
    InsertLabel(succ, label);
    
    // unlink
    if (b->head == criticalThunks)
        criticalThunks = b->tail->fwd;
    if (b->head->back)
        b->head->back->fwd = b->tail->fwd;
    if (b->tail->fwd)
        b->tail->fwd->back = b->head->back;
    
    // relink
    prev->tail->fwd->back = b->tail;
    b->tail->fwd = prev->tail->fwd;
    prev->tail->fwd = b->head;
    b->head->back = prev->tail;
}
예제 #4
0
TargetPhraseCollection::shared_ptr
UTrieNode::
GetOrCreateTargetPhraseCollection(const TargetPhrase &target)
{
  const AlignmentInfo &alignmentInfo = target.GetAlignNonTerm();
  const size_t rank = alignmentInfo.GetSize();

  std::vector<int> vec;
  vec.reserve(rank);

  m_labelTable.resize(rank);

  int i = 0;
  for (AlignmentInfo::const_iterator p = alignmentInfo.begin();
       p != alignmentInfo.end(); ++p) {
    size_t targetNonTermIndex = p->second;
    const Word &targetNonTerm = target.GetWord(targetNonTermIndex);
    vec.push_back(InsertLabel(i++, targetNonTerm));
  }
  TargetPhraseCollection::shared_ptr& ret = m_labelMap[vec];
  if (ret == NULL) ret.reset(new TargetPhraseCollection);
  return ret;
}
예제 #5
0
파일: iflow.c 프로젝트: jossk/OrangeC
void RemoveCriticalThunks(void)
{
    int i;
    for (i=0; i < blockCount; i++)
    {
        BLOCK *b = blockArray[i];
        if (b && i != exitBlock && !b->critical && !b->dead)
        {
            QUAD *bjmp = beforeJmp(b->tail, FALSE);
            if (bjmp->dc.opcode == i_coswitch)
            {
                
                QUAD *i = bjmp;
                BLOCKLIST *sl = b->succ;
                while (sl)
                {
                    BLOCK *s = sl->block;
                    if (s->critical)
                    {
                        s->critical = FALSE;
                        if (s->head->fwd != s->tail)
                        {
                            int lbl = nextLabel++;
                            MoveBlockTo(s);
                            InsertLabel(s, lbl);
                            i->dc.v.label = lbl;
                        }
                        else
                        {
                            UnlinkCritical(s);
                        }
                    }
                    i = i->fwd;
                    sl = sl->next;
                }
            }
            else if (bjmp->dc.opcode >= i_jne && bjmp->dc.opcode <= i_jge)
            {
                BLOCK *s = b->succ->block;
                BLOCK *n = b->succ->next->block;
                if (s->critical)
                {
                    s->critical = FALSE;
                    if (s->head->fwd != s->tail)
                    {
                        MoveBlockTo(s);
                        if (n->critical)
                        {
                            n->critical = FALSE;
                            if (n->head->fwd != n->tail)
                            {
                                int lbl = nextLabel++;
                                InsertLabel(b->succ->block, lbl);
                                bjmp->dc.v.label = lbl;
                                SwapBranchSense(bjmp);
                                MoveBlockTo(n);
                            }
                            else
                            {
                                UnlinkCritical(n);
                            }
                        }
                    }
                    else 
                    {
                        UnlinkCritical(s);
                        if (n->critical)
                        {
                            n->critical = FALSE;
                            if (n->head->fwd != n->tail)
                            {
                                int lbl = nextLabel ++;
                                bjmp->dc.v.label = lbl;
                                InsertLabel(b->succ->block, lbl);			
                                SwapBranchSense(bjmp);
                                MoveBlockTo(n);
                            }
                            else
                            {
                                UnlinkCritical(n);
                            }
                        }
                    }
                }
                else if (n->critical)
                {
                    n->critical = FALSE;
                    if (n->head->fwd != n->tail)
                    {
                        int lbl = nextLabel ++;
                        bjmp->dc.v.label = lbl;
                        InsertLabel(b->succ->block, lbl);			
                        SwapBranchSense(bjmp);
                        MoveBlockTo(n);
                    }
                    else
                    {
                        UnlinkCritical(n);
                    }
                }
            }
            else if (b->succ->block->critical)
            {
                BLOCK *s = b->succ->block;
                s->critical = FALSE;
                if (b->succ->next)
                    diag("RemoveCritical - invalid flow");
                if (s->head->fwd != s->tail)
                {
                    MoveBlockTo(s);
                    if (bjmp->dc.opcode == i_goto)
                    {
                        RemoveInstruction(bjmp);
                    }
                }
                else
                {
                    UnlinkCritical(s);
                }
            }
        }
    }
}
예제 #6
0
LRESULT CLabelListCtrl::OnP4LabelList(WPARAM wParam, LPARAM lParam)
{
	CCmd_Labels *pCmd= (CCmd_Labels *) wParam;

	m_AnyBlankOwner = FALSE;
	if(!pCmd->GetError())
	{
		CString msg;
		CString filterowner;
    	CObList const *labels = pCmd->GetList();
		int count = labels->GetCount();

        SetRedraw(FALSE);
    	int index = 0;
		if (m_FilterOwnerFlag)	// are we filtering by owner?
			filterowner = m_FilterOwnerFlag & 0x10 ? m_User : m_FilterOwner;
		for(POSITION pos= labels->GetHeadPosition(); pos != NULL; index++)
		{
        	CP4Label *label = (CP4Label *) labels->GetNext(pos);
			CString owner = label->GetOwner();
			if (owner.IsEmpty())
				m_AnyBlankOwner = TRUE;
			if (m_FilterOwnerFlag)	// are we filtering by owner?
			{
				if (owner.IsEmpty() && m_FilterIncBlank)
					;
				else if (filterowner != owner)
				{
					delete label;
					continue;
				}
			}
			InsertLabel(label, index);
			if ((index & 0x1FFF) == 0)
			{
				msg.FormatMessage(IDS_INSERTING_LABELS, count - index);
				MainFrame()->UpdateStatus(msg);
			}
		}
        SetRedraw(TRUE);

		msg.FormatMessage(IDS_NUMBER_OF_LABELS_n, index );
		AddToStatus( msg, SV_COMPLETION );

		// Make sure first item selected
		ReSort();
		if(labels->GetCount() > 0)
		{
			int i = FindInList(m_Active.IsEmpty() ? GET_P4REGPTR()->GetLastLabel() : m_Active);
			if (i < 0)	i=0;
			SetItemState(i, LVIS_SELECTED|LVIS_FOCUSED, LVIS_DROPHILITED|LVIS_SELECTED|LVIS_FOCUSED);
			EnsureVisible(i, FALSE);
			m_Active=GetSelectedItemText();
		}
	
		CP4ListCtrl::SetUpdateDone();
		if (m_Need2DoNew)
			OnLabelNew();
		else
		{
			// Notify the mainframe that we have finished getting the labels,
			// hence the entire set of async command have finished.
			MainFrame()->ExpandDepotIfNeedBe();
		}
		if (m_PostViewUpdateMsg)
			PostMessage(m_PostViewUpdateMsg, m_PostViewUpdateWParam, m_PostViewUpdateLParam);
	}
	else
	{
		CP4ListCtrl::SetUpdateFailed();
		m_Need2DoNew = FALSE;
	}
	
	delete pCmd;
	m_PostViewUpdateMsg = 0;
	MainFrame()->ClearStatus();
	return 0;
}