Skip to content

Commit 1a05484

Browse files
authored
1.9.2 - added 2 functions
1 parent 4df5b5d commit 1a05484

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

SourceCode/ast/lib/Functions.cs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using Gtk;
33
using System.Collections.Generic;
44
using System.IO;
@@ -41,6 +41,7 @@ static Functions()
4141
functions.Add("get_arg", new ForGetConsoleArg());
4242
functions.Add("exec_st", new AstStatementExec());
4343
functions.Add("byte", new ToByteArray());
44+
functions.Add("to_obj", new ForToObject());
4445
}
4546

4647
public void getModule(string name)
@@ -411,6 +412,7 @@ public void getModule(string name)
411412
functions.Add("new_dictionary", new ForDictionary());
412413
functions.Add("add", new ForDictionaryAppend());
413414
functions.Add("get_arr", new ForArrayGet());
415+
functions.Add("get_barr", new ForGetByteArray());
414416
functions.Add("to_bool", new ForToBool());
415417
functions.Add("exit", new ForExit());
416418
functions.Add("sleep", new ForSleep());
@@ -424,6 +426,7 @@ public void getModule(string name)
424426
}
425427
catch
426428
{
429+
functions.Remove("get_barr");
427430
functions.Remove("print");
428431
functions.Remove("input");
429432
functions.Remove("to_int");
@@ -450,6 +453,7 @@ public void getModule(string name)
450453
functions.Remove("add");
451454
functions.Remove("to_bool");
452455

456+
functions.Add("get_barr", new ForGetByteArray());
453457
functions.Add("to_bool", new ForToBool());
454458
functions.Add("as_var", new ForAsVar());
455459
functions.Add("get_var_by_name", new ForGetVarByName());
@@ -514,6 +518,22 @@ public static void set(string key, Function function)
514518
}
515519
}
516520

521+
public class ForToObject : Function
522+
{
523+
public Value execute(Value[] args)
524+
{
525+
return new ObjectValue(args[0].asObject());
526+
}
527+
}
528+
529+
public class ForGetByteArray : Function
530+
{
531+
public Value execute(Value[] args)
532+
{
533+
return ((ByteValue)args[0]).asArray();
534+
}
535+
}
536+
517537
public class ForSocketSend : Function
518538
{
519539
public Value execute(Value[] args)
@@ -773,7 +793,7 @@ public class AstDdotOp : Function
773793
{
774794
public Value execute(Value[] args)
775795
{
776-
return new ObjectValue(new DdotExpression(args[0].asString(), (StringValue)args[1]));
796+
return new ObjectValue(new DdotExpression(args[0].asString(), args[1].asString()));
777797
}
778798
}
779799

@@ -1913,4 +1933,4 @@ This is the multiline comment.
19131933
Why?
19141934
IDK.
19151935
1916-
*/
1936+
*/

0 commit comments

Comments
 (0)