public Evaluate ( |
||
source | ||
context | ||
return |
public STObject Evaluate(InputSource source, Context context)
{
Source = source;
try {
Node root = source.Parse(Parser);
if (root == null)
return STUndefinedObject.Instance; // parser found empty string so aborted
if (STDebug.ShowParseTrees) {
var tr = Transcript.Instance;
if (tr != null)
root.PrintTo(tr.Out);
else
root.PrintTo(Console.Out);
}
return Evaluate (root, context);
} finally {
Source = null;
}
}
public static void Evaluate(Compiler interp, string input, Context ctx) { input = input.Trim(' ', '\n', '\t'); if (input == "") return; STClass stringClass = STClass.GetForCLR(typeof(string), "String"); STObject obj = interp.Evaluate (input, ctx); if (obj == null) { Console.WriteLine(" x> null"); return; } STObject display = obj; if (display.Class != stringClass) { try { display = display.Send(STSymbol.Get("asString")); } catch (Exception e) { Console.Error.WriteLine("*** Caught {0} while sending #toString to result", e.GetType().FullName); Console.Error.WriteLine(e); } } Console.WriteLine(" => " + display.Native.ToString()); }