Adds print basic command

This commit is contained in:
Deukhoofd 2018-12-09 13:01:03 +01:00
parent fb2af879c9
commit 2d6e3335aa
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
2 changed files with 9 additions and 0 deletions

View File

@ -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<string> PrintResult { get; set; } = Console.WriteLine;
}
}

View File

@ -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)