Skip to content

Commit 883f0fc

Browse files
without tasks
1 parent 72a1146 commit 883f0fc

2 files changed

Lines changed: 75 additions & 110 deletions

File tree

EZCode/EZHelp.cs

Lines changed: 13 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -13,39 +13,9 @@ public EZHelp(Interpreter interpreter)
1313
Interpreter = interpreter;
1414
}
1515
public EZHelp() { }
16-
public async Task Await(object val)
16+
public void Print(string text)
1717
{
18-
try
19-
{
20-
string wait = StringParse(val);
21-
if (bool.TryParse(wait, out bool res))
22-
{
23-
while (res)
24-
{
25-
res = bool.Parse(ObjectParse(val, "bool").ToString());
26-
}
27-
}
28-
else if (int.TryParse(wait, out int num))
29-
{
30-
await WaitForMiliseconds(num);
31-
}
32-
}
33-
catch (Exception e)
34-
{
35-
Error = e.ToString();
36-
throw;
37-
}
38-
}
39-
internal static async Task WaitForMiliseconds(int mililseconds)
40-
{
41-
for (int i = 0; i < mililseconds; i++)
42-
{
43-
await Task.Delay(1);
44-
}
45-
}
46-
public async void Print(string text)
47-
{
48-
text = await Format(text.ToString());
18+
text = Format(text.ToString());
4919
Interpreter.Output = [.. Interpreter.Output, text.ToString()];
5020
Console.WriteLine(text);
5121
}
@@ -59,13 +29,13 @@ public string Input()
5929
string input = Interpreter.ConsoleInput();
6030
return input;
6131
}
62-
public async Task<string> Format(object _text) => await Format(_text, "'");
63-
public async Task<string> Format(object _text, object _char)
32+
public string Format(object _text) => Format(_text, "'");
33+
public string Format(object _text, object _char)
6434
{
6535
try
6636
{
6737
char c = char.Parse(_char.ToString());
68-
string text = (await ObjectParse(_text.ToString(), "str", true)).ToString();
38+
string text = ObjectParse(_text.ToString(), "str", true).ToString();
6939
string format = "";
7040
char[] chars = text.ToCharArray();
7141
bool open = true, backslash = false;
@@ -144,14 +114,14 @@ public async Task<string> Format(object _text, object _char)
144114
}
145115
if (Interpreter.Vars.Any(x => x.Name == instance_name))
146116
{
147-
format = format.Remove(range.Start, range.Count).Insert(range.Start, (await Interpreter.GetValue(name, DataType.GetType("str", Interpreter.Classes))).ToString());
117+
format = format.Remove(range.Start, range.Count).Insert(range.Start, Interpreter.GetValue(name, DataType.GetType("str", Interpreter.Classes)).ToString());
148118
}
149119
else
150120
{
151121
Interpreter.parser.WatchIsFound([name], 0, out ExplicitWatch watch, out _);
152122

153-
object val = await Interpreter.GetValue(watch != null ? watch.Runs : name, DataType.GetType("str", Interpreter.Classes));
154-
format = format.Remove(range.Start, range.Count).Insert(range.Start, (await Interpreter.GetValue(val, new DataType(DataType.Types._string, null))).ToString());
123+
object val = Interpreter.GetValue(watch != null ? watch.Runs : name, DataType.GetType("str", Interpreter.Classes));
124+
format = format.Remove(range.Start, range.Count).Insert(range.Start, Interpreter.GetValue(val, new DataType(DataType.Types._string, null)).ToString());
155125
}
156126
}
157127

@@ -172,8 +142,8 @@ public string StringEmpty()
172142
{
173143
return string.Empty;
174144
}
175-
public async Task<object> ObjectParse(object obj, object type) => await ObjectParse(obj, type, false);
176-
public async Task<object> ObjectParse(object obj, object type, bool to_string, string arraySeperator = " ", bool returnNull = false)
145+
public object ObjectParse(object obj, object type) => ObjectParse(obj, type, false);
146+
public object ObjectParse(object obj, object type, bool to_string, string arraySeperator = " ", bool returnNull = false)
177147
{
178148
try
179149
{
@@ -190,7 +160,7 @@ public async Task<object> ObjectParse(object obj, object type, bool to_string, s
190160
o = obj;
191161
DataType data = DataType.GetType(type.ToString(), Interpreter.Classes);
192162
if (Interpreter.Vars.Any(x => x.Name == n)) Interpreter.Vars.FirstOrDefault(x => x.Name == n).DataType = data;
193-
obj = await Interpreter.GetValue(n, data, arraySeperator);
163+
obj = Interpreter.GetValue(n, data, arraySeperator);
194164
} while (obj != o);
195165
}
196166
catch when(returnNull) { return null; }
@@ -492,15 +462,15 @@ public bool SameType(object a, object b)
492462
}
493463
}
494464
public int StringLength(object str) => StringParse(str).Length;
495-
public void RunEZCode(string code)
465+
public int RunEZCode(string code)
496466
{
497467
try
498468
{
499469
code = ObjectParse(code, "str").ToString();
500470
Parser parser = new Parser(string.Join(" ", code), "(instance running from inside file)");
501471
parser.Parse();
502472
Interpreter interpreter = new Interpreter(parser);
503-
interpreter.Interperate();
473+
return interpreter.Interperate();
504474
}
505475
catch (Exception e)
506476
{

0 commit comments

Comments
 (0)