Skip to content

Commit

Permalink
Fix bug with function name and fix other
Browse files Browse the repository at this point in the history
  • Loading branch information
snaulX committed Sep 22, 2019
1 parent 416f311 commit 07a1423
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 22 deletions.
19 changes: 9 additions & 10 deletions wolvm/Stack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1188,6 +1188,7 @@ public static Stack Parse(string stack_code)
func.body = buffer.ToString();
stack.functions.Add(func_name, func);
current = stack_code[++position]; //skip ']' (peek next char)
buffer.Clear();
if (current == ',')
{
current = stack_code[++position]; //skip ','
Expand Down Expand Up @@ -1216,7 +1217,6 @@ public static Stack Parse(string stack_code)
{
VirtualMachine.ThrowVMException("Functions`s start not found", VirtualMachine.position - stack_code.Length + position, ExceptionType.BLDSyntaxException);
}
buffer.Clear();
}
else if (buffer.ToString() == "var")
{
Expand Down Expand Up @@ -1597,21 +1597,20 @@ public void Dispose()

public override string ToString()
{
string classes_str = "", func_str = "", var_str = "";
if (classes.Count != 0)
string str = "";
foreach (KeyValuePair<string, Value> keyValuePair in values)
{
classes_str += "class {\n\t";
classes_str += "}";
str += keyValuePair.Key + ' ' + keyValuePair.Value + '\n';
}
if (functions.Count != 0)
foreach (KeyValuePair<string, wolClass> keyValuePair in classes)
{
func_str += "func {\n";
str += keyValuePair.Key + ' ' + keyValuePair.Value + '\n';
}
if (values.Count != 0)
foreach (KeyValuePair<string, wolFunction> keyValuePair in functions)
{
var_str += "var {\n";
str += keyValuePair.Key + ' ' + keyValuePair.Value + '\n';
}
return " {\n\t" + classes_str + func_str + var_str + "\n};";
return str;
}

public static Stack operator +(Stack right, Stack left)
Expand Down
14 changes: 2 additions & 12 deletions wolvm/VirtualMachine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -318,18 +318,8 @@ public static void Run(string input)
if (test)
{
//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("Info about program in the end.\nMain stack:");
Console.Write(mainstack.ToString());
Console.WriteLine($"Time of program: {Environment.TickCount - time}");
}
return;
Expand Down

0 comments on commit 07a1423

Please sign in to comment.