Skip to content

Commit

Permalink
Add '-test' cmd argument
Browse files Browse the repository at this point in the history
  • Loading branch information
snaulX committed Sep 22, 2019
1 parent 5af4081 commit 97c31ee
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions wolvm/VirtualMachine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public static class VirtualMachine
{ "ParseDouble", new ParseDoubleExpression() },
{ "System.input", new InputExpression() }
};
private static bool test = false;

static void Main(string[] args)
{
Expand All @@ -49,14 +50,18 @@ static void Main(string[] args)
Console.WriteLine($"-help ; call World of Legends Virtual Machine v{version} Helper");
Console.WriteLine("-info ; print info about this vm");
Console.WriteLine("-encode <full file name> ; encode and run build-file");
Console.WriteLine("-test <full file name> ; run build-file and in the end print main stack (last in the end) and time of program run");
Console.WriteLine("<full file name> ; run build-file");
break;
case "-encode":
Run(Encoding.UTF8.GetString(File.ReadAllBytes(args[1])));
break;
case "-test":
test = true;
Run(new StreamReader(File.OpenRead(args[0])).ReadToEnd());
break;
default:
TextReader text_reader = new StreamReader(File.OpenRead(args[0]));
Run(text_reader.ReadToEnd());
Run(new StreamReader(File.OpenRead(args[0])).ReadToEnd());
break;
}
}
Expand Down Expand Up @@ -310,20 +315,23 @@ public static void Run(string input)
}
else if (buffer.ToString() == "end")
{
//test stack
foreach (KeyValuePair<string, Value> keyValuePair in mainstack.values)
{
Console.WriteLine(keyValuePair.Key + ' ' + keyValuePair.Value);
}
foreach (KeyValuePair<string, wolClass> keyValuePair in mainstack.classes)
if (test)
{
Console.WriteLine(keyValuePair.Key + ' ' + keyValuePair.Value);
}
foreach (KeyValuePair<string, wolFunction> keyValuePair in mainstack.functions)
{
Console.WriteLine(keyValuePair.Key + ' ' + keyValuePair.Value);
//test stack
foreach (KeyValuePair<string, Value> keyValuePair in mainstack.values)
{
Console.WriteLine(keyValuePair.Key + ' ' + keyValuePair.Value);
}
foreach (KeyValuePair<string, wolClass> keyValuePair in mainstack.classes)
{
Console.WriteLine(keyValuePair.Key + ' ' + keyValuePair.Value);
}
foreach (KeyValuePair<string, wolFunction> keyValuePair in mainstack.functions)
{
Console.WriteLine(keyValuePair.Key + ' ' + keyValuePair.Value);
}
Console.WriteLine($"Time of program: {Environment.TickCount - time}");
}
Console.WriteLine($"Time of program: {Environment.TickCount - time}");
return;
}
else if (buffer.ToString() == "}")
Expand Down

0 comments on commit 97c31ee

Please sign in to comment.