Irontalk.Compiler.Evaluate C# (CSharp) Method

Evaluate() public method

public Evaluate ( InputSource source, Context context ) : STObject
source InputSource
context Context
return STObject
        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;
            }
        }

Same methods

Compiler::Evaluate ( PerCederberg.Grammatica.Runtime.Node sequence, Context context ) : STObject
Compiler::Evaluate ( string text ) : STObject
Compiler::Evaluate ( string str, Context context ) : STObject

Usage Example

Exemplo n.º 1
0
        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());
        }