Skip to content

Commit

Permalink
Add maximum loop output
Browse files Browse the repository at this point in the history
  • Loading branch information
ermau committed Apr 18, 2012
1 parent ed4b4e1 commit 77a3eac
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Prototype/MainWindow.xaml
Expand Up @@ -37,6 +37,8 @@
<StackPanel Grid.Row="1" Orientation="Horizontal">
<Label Target="{Binding ElementName=timeout}">Time_out (ms):</Label>
<TextBox Name="timeout" Margin="4" Text="{Binding ExecutionTimeout}" Width="50" />
<Label Target="{Binding ElementName=loops}">_Max Loops:</Label>
<TextBox Name="loops" Margin="4" Text="{Binding MaximumLoops}" Width="40" />
<CheckBox IsChecked="{Binding DebugTree}">Show _Tree</CheckBox>
<CheckBox IsChecked="{Binding ShowCompilerErrors}">Show Compiler _Errors</CheckBox>
</StackPanel>
Expand Down
16 changes: 15 additions & 1 deletion Prototype/MainWindowViewModel.cs
Expand Up @@ -111,6 +111,19 @@ public bool ShowCompilerErrors
}
}

public int MaximumLoops
{
get { return this.maxLoops; }
set
{
if (this.maxLoops == value)
return;

this.maxLoops = value;
OnPropertyChanged ("MaximumLoops");
}
}

public int ExecutionTimeout
{
get { return this.timeout; }
Expand All @@ -124,7 +137,7 @@ public int ExecutionTimeout
}
}

private int timeout = 5000;
private int timeout = 5000, maxLoops = 100;
private bool showDebugTree, showCompilerErrors;
private string input, output, debug = "Initializing";

Expand Down Expand Up @@ -181,6 +194,7 @@ private void ProcessInput()
}

StringObjectLogger logger = new StringObjectLogger (this.cancelSource.Token);
logger.MaximumLoops = MaximumLoops;

new Timer (o =>
{
Expand Down
12 changes: 12 additions & 0 deletions Prototype/StringObjectLogger.cs
Expand Up @@ -30,6 +30,12 @@ public StringObjectLogger (CancellationToken cancelToken)
CancelToken = cancelToken;
}

public int MaximumLoops
{
get;
set;
}

public readonly CancellationToken CancelToken;

private int loopLevel;
Expand Down Expand Up @@ -94,6 +100,12 @@ public void EndLoop()
int lcount = valueLists.Max (l => l.Count);
for (int i = 0; i < lcount; ++i)
{
if (i == MaximumLoops && i != 0)
{
this.builder.AppendLine (String.Format ("{0:N0} loops not shown", lcount - MaximumLoops));
break;
}

object[] vs = new object[valueLists.Length];
for (int n = 0; n < valueLists.Length; ++n)
{
Expand Down

0 comments on commit 77a3eac

Please sign in to comment.