public override object VisitVariableExpression([NotNull] TinyScriptParser.VariableExpressionContext context)
        {
            var c    = context.GetChild(0);
            var text = c.GetText();

            switch (text)
            {
            case "true": _builder.LoadInt(1); return(typeof(bool));

            case "false": _builder.LoadInt(0); return(typeof(bool));
            }
            if (text.StartsWith("\""))
            {
                var str = text.Substring(1, text.Length - 2);
                _builder.LoadString(str);
                return(typeof(string));
            }
            Variable variable;

            if (_variables.TryGetValue(text, out variable))
            {
                _builder.LoadLocal(variable.Value);
                return(variable.Type);
            }
            throw context.Exception("Use of undeclared identifier [{0}].", text);
        }
        public override object VisitVariableExpression([NotNull] TinyScriptParser.VariableExpressionContext context)
        {
            var n = context.GetText();

            if (n == "true")
            {
                return(true);
            }
            else if (n == "false")
            {
                return(false);
            }
            else if (n.StartsWith("\""))
            {
                return(n.Substring(1, n.Length - 2));
            }
            VarValue obj;

            if (!Variables.TryGetValue(n, out obj))
            {
                throw context.Exception("Use of undeclared identifier [{0}].", n);
            }
            return(obj.Value);
        }
 /// <summary>
 /// Visit a parse tree produced by <see cref="TinyScriptParser.variableExpression"/>.
 /// <para>
 /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
 /// on <paramref name="context"/>.
 /// </para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 /// <return>The visitor result.</return>
 public virtual Result VisitVariableExpression([NotNull] TinyScriptParser.VariableExpressionContext context)
 {
     return(VisitChildren(context));
 }