Пример #1
0
Condition*
Control::GetDomainConstraints(int stmt)
{
Condition*   result;
if((IsLoop( ) || IsIf( )))
   {
   if( (stmt >= first_assign) && (stmt <= last_assign))
      {
      if(IsForLoop( ))
         {
         Inequation* ineq1=new Inequation ( new Expression(GetLoopCounter( )),FADA_GREATER_EQ,GetForLowerBound( ));
         Inequation* ineq2=new Inequation ( new Expression(GetLoopCounter( )),FADA_LESS_EQ,GetForUpperBound( ));
         return new Condition( new Condition(ineq1), FADA_AND , new Condition(ineq2));
         }
      else
         return GetCondition( );
      }
   else
      return new Condition(new Inequation (true));
   }
if(IsIfElse( ))
   {
   if( (stmt >= first_assign) && (stmt <= last_assign))
      return GetCondition( );
   else
      {
      if( (stmt >= else_first_assign) && (stmt <= else_last_assign))
         return GetCondition( )->FastNegation( );
      else
         return new Condition(new Inequation (true));
      }
   }
}
Пример #2
0
	bool CDuiTimerBase::FinshTimered()
	{
		if(!IsLoop() && GetInterval() < GetTotalTimer()){
			if(!IsRevers())
				return GetCurTimer() > GetTotalTimer();
			else if(IsRevers())
				return GetCurTimer() < 0;
		}
		else if(IsLoop() && GetInterval() < GetTotalTimer()){
			if(!IsRevers() && GetCurTimer() > GetTotalTimer())
				m_iCurTimer = 0;
			else if(IsRevers() && GetCurTimer() < 0)
				m_iCurTimer = GetTotalTimer();
		}
		if(GetInterval() >= GetTotalTimer())
			m_iCurTimer += GetInterval();

		return false;
	}
Пример #3
0
String Capstone::OperandText(int opindex) const
{
    if(opindex >= mInstr->detail->x86.op_count)
        return "";
    const auto & op = mInstr->detail->x86.operands[opindex];
    String result;
    char temp[32] = "";
    switch(op.type)
    {
    case X86_OP_REG:
    {
        result = RegName(x86_reg(op.reg));
    }
    break;

    case X86_OP_IMM:
    {
        if(InGroup(CS_GRP_JUMP) || InGroup(CS_GRP_CALL) || IsLoop())
            sprintf_s(temp, "%" fext "X", op.imm + mInstr->size);
        else
            sprintf_s(temp, "%" fext "X", op.imm);
        result = temp;
    }
    break;

    case X86_OP_MEM:
    {
        const auto & mem = op.mem;
        if(op.mem.base == X86_REG_RIP)  //rip-relative
        {
            sprintf_s(temp, "%" fext "X", mInstr->address + op.mem.disp + mInstr->size);
            result += temp;
        }
        else //normal
        {
            bool prependPlus = false;
            if(mem.base)
            {
                result += RegName(x86_reg(mem.base));
                prependPlus = true;
            }
            if(mem.index)
            {
                if(prependPlus)
                    result += "+";
                result += RegName(x86_reg(mem.index));
                sprintf_s(temp, "*%X", mem.scale);
                result += temp;
                prependPlus = true;
            }
            if(mem.disp)
            {
                char operatorText = '+';
                if(mem.disp < 0)
                {
                    operatorText = '-';
                    sprintf_s(temp, "%" fext "X", mem.disp * -1);
                }
                else
                    sprintf_s(temp, "%" fext "X", mem.disp);
                if(prependPlus)
                    result += operatorText;
                result += temp;
            }
        }
    }
    break;

    case X86_OP_FP:
    case X86_OP_INVALID:
    {
    }
    break;
    }
    return result;
}
Пример #4
0
Condition*
Control::GetRegularDomain(int __id, vector<string>* __loop_counters, vector<string>* __param,LDemonstrator* __loop_ppts){
vector<string> variables=*__loop_counters;
if(IsLoop())
   variables.push_back(GetLoopCounter());
NormalizeConditions(__id,&variables,__param);
switch(GetNonAffineDomain()->size()){
   case 0:   goto simple_case;
      
   case 1:   {
      vector<Inequation*> v=*GetNonAffineDomain()->begin();
      if(v.size() <= 1)
         goto simple_case;
      }
   default:
      goto complicated_case;
   }

simple_case:
cout<<"\nSimple case";
exit(0);

if(IsIf() || IsIfElse() || IsWhileLoop())
   {
   if(IsWhileLoop()){
      cout<<"\nComplicated domain";
      exit(0);

      Inequation* ineq=new Inequation(new Expression(GetCounter()),FADA_GREATER_EQ,new Expression(0));
      Condition* count_ge_0 = new Condition (ineq);
      return new Condition(GetCondition(),FADA_AND,count_ge_0);
      }

   return GetCondition();
   }

if(IsForLoop()){
   Inequation* ineq1=new Inequation ( new Expression(GetLoopCounter( )),FADA_GREATER_EQ,GetForLowerBound( ));
   Inequation* ineq2=new Inequation ( new Expression(GetLoopCounter( )),FADA_LESS_EQ,GetForUpperBound( ));
   return new Condition( new Condition(ineq1), FADA_AND , new Condition(ineq2));
   }

cout<<"\nControl::GetRegularDomain ... inappropriate case 1";
exit(0);

complicated_case:
      cout<<"\nComplicated domain";
      exit(0);
Condition* result=new Condition(new Inequation(true));
for(vector<vector<Inequation*> >::iterator it=GetAffineDomain()->begin(); it != GetAffineDomain()->end(); ++it){
   result=new Condition(ToDNFTerm(&(*it)),FADA_AND,result);
   }
if(IsWhileLoop()){
   Inequation* ineq=new Inequation(new Expression(GetCounter()),FADA_GREATER_EQ,new Expression(1));
   Condition* count_ge_0 = new Condition (ineq);
   result=new Condition(count_ge_0,FADA_AND,result);
   }
ostringstream ch;
ch<<"domain_"<<__id;
Expression* non_affine=new Expression(ch.str());
for(vector<string>::iterator it=__loop_counters->begin(); it != __loop_counters->end();++it)
   non_affine->AddArgument(new Expression(*it));
if(IsLoop())
   non_affine->AddArgument(new Expression(GetLoopCounter()));
if(non_affine->IsVariable())
   __param->push_back(non_affine->GetVariableName());
return new Condition(new Condition(new Inequation(non_affine,FADA_NEQ,new Expression(0))),FADA_AND,result);
}
void SAnimMontageSectionsPanel::Update()
{
	int32 ColorIdx=0;
	FLinearColor Colors[] = { FLinearColor(0.9f, 0.9f, 0.9f, 0.9f), FLinearColor(0.5f, 0.5f, 0.5f) };
	FLinearColor NodeColor = FLinearColor(0.f, 0.5f, 0.0f, 0.5f);
	FLinearColor SelectedColor = FLinearColor(1.0f,0.65,0.0f);
	FLinearColor LoopColor = FLinearColor(0.0f, 0.25f, 0.25f, 0.5f);

	
	if ( Montage != NULL )
	{
		TSharedPtr<STrack> Track;
		TSharedPtr<SVerticalBox> MontageSlots;
		PanelArea->SetContent(
			SAssignNew( MontageSlots, SVerticalBox )
			);

		SectionMap.Empty();
		TopSelectionSet.Empty();
		SelectionSet.Empty();
		MontageSlots->ClearChildren();

		SMontageEditor * Editor = MontageEditor.Pin().Get();
		
		TArray<bool>	Used;
		Used.AddZeroed(Montage->CompositeSections.Num());

		int RowIdx=0;

		/** Create Buttons for reseting/creating default section ordering */
		MontageSlots->AddSlot()
			.AutoHeight()
			.VAlign(VAlign_Center)
			.Padding( FMargin(0.5f, 0.5f) )
			[
				SNew(SHorizontalBox)
				+ SHorizontalBox::Slot()
				.AutoWidth()
				.VAlign(VAlign_Center)
				[				
					SNew(SButton)
					.IsEnabled(!bChildAnimMontage)
					.Visibility( EVisibility::Visible )
					.Text( LOCTEXT("CreateDefault", "Create Default") )
					.ToolTipText( LOCTEXT("CreateDefaultToolTip", "Reconstructs section ordering based on start time") )
					.OnClicked(this, &SAnimMontageSectionsPanel::MakeDefaultSequence)
					.HAlign(HAlign_Center)
					.VAlign(VAlign_Center)
				]

				+ SHorizontalBox::Slot()
				.AutoWidth()
				.VAlign(VAlign_Center)
				[				
					SNew(SButton)
					.IsEnabled(!bChildAnimMontage)
					.Visibility( EVisibility::Visible )
					.Text( LOCTEXT("Clear", "Clear") )
					.ToolTipText( LOCTEXT("ClearToolTip", "Resets section orderings") )
					.OnClicked(this, &SAnimMontageSectionsPanel::ClearSequence)
					.HAlign(HAlign_Center)
					.VAlign(VAlign_Center)
				]
			];


		/** Create top track of section nodes */
		MontageSlots->AddSlot()
			.AutoHeight()
			.VAlign(VAlign_Center)
			.Padding( FMargin(0.5f, 20.0f) )
			[
				SAssignNew(Track, STrack)
				.IsEnabled(!bChildAnimMontage)
				.ViewInputMin(0)
				.ViewInputMax(100)
				.TrackColor( FLinearColor(0.0f, 0.0f, 0.0f, 0.0f))
				.TrackMaxValue(100)
				
			];

		for(int32 SectionIdx=0; SectionIdx < Montage->CompositeSections.Num(); SectionIdx++)
		{
			const float NodeLength = 100.f / static_cast<float>(Montage->CompositeSections.Num()+1);
			const float NodeSpacing = 100.f / static_cast<float>(Montage->CompositeSections.Num());

			Track->AddTrackNode(
				SNew(STrackNode)
				.ViewInputMax(100)
				.ViewInputMin(0)
				.NodeColor(NodeColor)
				.SelectedNodeColor(SelectedColor)
				.DataLength(NodeLength)
				.DataStartPos(NodeSpacing * SectionIdx)
				.NodeName(Montage->CompositeSections[SectionIdx].SectionName.ToString())
				.NodeSelectionSet(&TopSelectionSet)
				.OnTrackNodeClicked( this, &SAnimMontageSectionsPanel::TopSectionClicked, SectionIdx)
				.AllowDrag(false)
				);
		}

		MontageSlots->AddSlot()
			.AutoHeight()
			.VAlign(VAlign_Center)
			.Padding( FMargin(0.5f, 0.0f) )
			[
				SNew(SHorizontalBox)
				+ SHorizontalBox::Slot()
				.AutoWidth()
				.VAlign(VAlign_Center)
				[				
					SNew(SButton)
					.Visibility( EVisibility::Visible )
					.Text( LOCTEXT("PreviewAll", "Preview All Sections") )
					.ToolTipText( LOCTEXT("PreviewAllToolTip", "Preview all sections in order they are") )
					.OnClicked(this, &SAnimMontageSectionsPanel::PreviewAllSectionsClicked)
					.HAlign(HAlign_Center)
					.VAlign(VAlign_Center)
				]
			];

		/** Create as many tracks as necessary to show each section at least once
		  * -Each track represents one chain of sections (section->next->next)
		  */

		while(true)
		{
			int32 SectionIdx = 0;
			TArray<bool>	UsedInThisRow;
			UsedInThisRow.AddZeroed(Montage->CompositeSections.Num());
			
			/** Find first section we haven't shown yet */
			for(;SectionIdx < Montage->CompositeSections.Num(); SectionIdx++)
			{
				if(!Used[SectionIdx])
					break;
			}

			if(SectionIdx >= Montage->CompositeSections.Num())
			{
				// Ran out of stuff to show - done
				break;
			}

			/** Create new track */
			SectionMap.Add( TArray<int32>() );
			MontageSlots->AddSlot()
				.AutoHeight()
				.VAlign(VAlign_Center)
				.Padding( FMargin(0.5f, 0.5f) )
				[
					SNew(SHorizontalBox)
					+ SHorizontalBox::Slot()
					.AutoWidth()
					.VAlign(VAlign_Center)
					[				
						SNew(SButton)
						.Visibility( EVisibility::Visible )
						.Text( LOCTEXT("Preview", "Preview") )
						.ToolTipText( LOCTEXT("PreviewToolTip", "Preview this track") )
						.OnClicked(this, &SAnimMontageSectionsPanel::PreviewSectionClicked, SectionIdx)
						.HAlign(HAlign_Center)
						.VAlign(VAlign_Center)
					]

					+ SHorizontalBox::Slot()
					.FillWidth(1.0f)
					.VAlign(VAlign_Center)
					[
						SAssignNew(Track, STrack)
						.ViewInputMin(0)
						.ViewInputMax(100)
						.TrackColor( Colors[ColorIdx++ & 1])
						.TrackMaxValue(100)
					]
				];
			
			/** Add each track in this chain to the track we just created */
			int count =0;
			float TrackPos = 0;
			const float BarLength = 8;
			const float XLength = 1;
			while(true)
			{
				/** Add section if it hasn't already been used in this row (if its used in another row, thats ok) */
				if(Montage->IsValidSectionIndex(SectionIdx) && UsedInThisRow[SectionIdx]==false)
				{
					UsedInThisRow[SectionIdx] = true;
					Used[SectionIdx] = true;

					SectionMap[RowIdx].Add(SectionIdx);
				
					Track->AddTrackNode(
						SNew(STrackNode)
						.IsEnabled(!bChildAnimMontage)
						.ViewInputMax(100)
						.ViewInputMin(0)
						.NodeColor( IsLoop(SectionIdx) ? LoopColor : NodeColor)
						.SelectedNodeColor(SelectedColor)
						.DataLength(BarLength)
						.DataStartPos(TrackPos)
						.NodeName(Montage->CompositeSections[SectionIdx].SectionName.ToString())
						.OnTrackNodeDragged( this, &SAnimMontageSectionsPanel::SetSectionPos, SectionIdx, RowIdx)
						.OnTrackNodeDropped( this, &SAnimMontageSectionsPanel::OnSectionDrop)
						.OnTrackNodeClicked( this, &SAnimMontageSectionsPanel::SectionClicked, SectionIdx)
						.NodeSelectionSet(&SelectionSet)
						.AllowDrag(false)
					);
					TrackPos += BarLength + 0.25f;

					/** If this has a next section, create an X to delete that link */
					if(Montage->CompositeSections[SectionIdx].NextSectionName != NAME_None)
					{
						Track->AddTrackNode(
							SNew(STrackNode)
							.IsEnabled(!bChildAnimMontage)
							.ViewInputMax(100)
							.ViewInputMin(0)
							.NodeColor(IsLoop(SectionIdx) ? LoopColor : NodeColor)
							.SelectedNodeColor(SelectedColor)
							.DataStartPos(TrackPos)
							.NodeName(TEXT("x"))
							.OnTrackNodeDropped( this, &SAnimMontageSectionsPanel::OnSectionDrop)
							.OnTrackNodeClicked( this, &SAnimMontageSectionsPanel::RemoveLink, SectionIdx)
							.NodeSelectionSet(&SelectionSet)
							.AllowDrag(false)
							);

						TrackPos += XLength + 0.25;
					}

					count++;
					SectionIdx = Montage->GetSectionIndex( Montage->CompositeSections[SectionIdx].NextSectionName );

					continue;
				} else
				{
					break;
				}
			}

		}

		RowIdx++;

	}
	SelectedCompositeSection = INDEX_NONE;
}
Пример #6
0
void CEditorCondition::Render(CRect &Pos, CDC &dc, bool EventSelected, CChronoEventEditor& Ed, bool bBookmarked, bool bEnabled)
{
	COLORREF BG;
	BG = m_select(&Ed)? CONDITION_BG_SEL : (EventSelected? CONDITION_BG_EVSEL : CONDITION_BG);
	if(IsTrigger(NULL))
	{
		BG = m_select(&Ed)? CONDITION_BG_SEL : (EventSelected? CONDITION_BG_EVSEL : EVENT_BG);	
	}

	// Animating
	if(m_Anim.m_bDestroyed)
	{
		CRect Calc = Pos;
		Pos.OffsetRect(0,m_Anim.Space);
		Calc.bottom = Pos.bottom;
		dc.FillSolidRect(Calc,BG);
		return;
	}

	CRect Box = Pos;

	Box.bottom+= m_rect(&Ed).Height();

	CRect Calc = Pos;
	Calc.bottom = Box.bottom;

	CHTMLFont f;
	f.SetBold(false);
	f.SetSize(8);
	f.SetName("Segoe UI");
	f.SetImage(false);

	// Is it enabled?
	if (!bEnabled)
		f.SetStrike(true);

	CString Out;
	Out.Format("%s", m_Text);
	g_HTMLDraw.DrawText(&dc, Out, f, Calc, 0, &Ed, &m_imgs,&params);
	m_Readable.Format("%s", Out);

	dc.FillSolidRect(Calc,BG);
	{
		CRect Calc2 = Calc;
		CRect Calc = Pos;
		Calc.bottom = Box.bottom;

		//We may be hovering over something.
		CPoint mouse;
		GetCursorPos(&mouse);
		Ed.ScreenToClient(&mouse);

		if(Calc2.PtInRect(mouse) && m_select(&Ed))
		{
			for(int p = 0; p < params.size(); p++)
				for(int d = 0; d < params[p]->displayrects.size(); d++)
					if(params[p]->displayrects[d].PtInRect(mouse))
					{
						for(int a = 0; a < params[p]->displayrects.size(); a++)
							dc.FillSolidRect(params[p]->displayrects[a], RGB(100,255,100));
						continue;
					}
		}

		// End hover
		CString Out;

		bool show_quotes = true;
		if (m_Text.Find("#noquotes") != -1) show_quotes = false;

		CString display_text = m_Text;
		display_text.Replace("#noquotes", "");
		if (!show_quotes) display_text.Replace("\"", "");

		Out.Format("%s", display_text);
		g_HTMLDraw.DrawText(&dc, Out, f, Calc, 0, &Ed, &m_imgs,&params);
		m_Readable.Format("%s", Out);

		if(m_select(&Ed))
			dc.Draw3dRect(Calc2,CONDITION_BG_SEL2,CONDITION_BG_SEL2);
	}


	m_rect(&Ed) = Calc;
	
	Pos.OffsetRect(CPoint(0,Calc.Height()));
	m_Anim.Space = Calc.Height();

	if(IsLoop(NULL))
	{
		Pos.left += 10;
	}
}