From 2d6e3335aad52dd1b5e6b4ad9cc9621e4319adda Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sun, 9 Dec 2018 13:01:03 +0100 Subject: [PATCH] Adds print basic command --- Upsilon/ScriptOptions.cs | 2 ++ Upsilon/StandardLibraries/BasicFunctions.cs | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/Upsilon/ScriptOptions.cs b/Upsilon/ScriptOptions.cs index ab7ec83..0f3b77f 100644 --- a/Upsilon/ScriptOptions.cs +++ b/Upsilon/ScriptOptions.cs @@ -1,3 +1,4 @@ +using System; using Upsilon.Binder; using Upsilon.Evaluator; @@ -22,5 +23,6 @@ namespace Upsilon public EvaluationScope OverrideStaticScope { get; set; } = null; public ScriptLoader ScriptLoader { get; set; } = new ScriptLoader(); public ModuleHandler ModuleHandler { get; set; } = new ModuleHandler(); + public Action PrintResult { get; set; } = Console.WriteLine; } } \ No newline at end of file diff --git a/Upsilon/StandardLibraries/BasicFunctions.cs b/Upsilon/StandardLibraries/BasicFunctions.cs index 82437d1..3eff75a 100644 --- a/Upsilon/StandardLibraries/BasicFunctions.cs +++ b/Upsilon/StandardLibraries/BasicFunctions.cs @@ -52,6 +52,13 @@ namespace Upsilon.StandardLibraries return new PairsScriptIterator(table); } + [ScriptFunction("print", "Prints a message to the action given in the script options", passScriptReference: true, + directScriptManipulation: true)] + public void Print(Script script, ScriptType message) + { + script.Options.PrintResult.Invoke(message.ToCSharpObject().ToString()); + } + [ScriptFunction("require", "Loads a module from the module path, using the given script loader.", true, true)] public ScriptType Require(Script script, ScriptString fileName)