public override object VisitPrintStatement([NotNull] TinyScriptParser.PrintStatementContext context)
        {
            var ret = (Type)VisitExpression(context.expression());
            var b   = OpBuilder.GetOpBuilder(ret, context, _builder);

            b.CallToString();
            _builder.EmitPrint();
            return(null);
        }
        public override object VisitUnaryExpression([NotNull] TinyScriptParser.UnaryExpressionContext context)
        {
            if (context.ChildCount == 1)
            {
                return(VisitPrimaryExpression(context.primaryExpression()));
            }
            var ret = (Type)VisitUnaryExpression(context.unaryExpression());
            var op  = context.GetChild(0).GetText();
            var b   = OpBuilder.GetOpBuilder(ret, context, _builder);

            b.ProcessUnary(op);
            return(ret);
        }
        public override object VisitCmpExpression([NotNull] TinyScriptParser.CmpExpressionContext context)
        {
            var ret = (Type)VisitAddExpression(context.addExpression(0));

            if (context.ChildCount > 1)
            {
                var t2      = (Type)VisitAddExpression(context.addExpression(1));
                var op      = context.GetChild(1).GetText();
                var cmpType = GetOpType(context, ret, t2);
                var b       = OpBuilder.GetOpBuilder(cmpType, context, _builder);
                b.ProcessCmp(op);
                return(typeof(bool));
            }
            return(ret);
        }
 public override object VisitPrimaryExpression([NotNull] TinyScriptParser.PrimaryExpressionContext context)
 {
     if (context.ChildCount == 1)
     {
         var c = context.GetChild(0);
         if (c is TinyScriptParser.VariableExpressionContext)
         {
             return(VisitVariableExpression(context.variableExpression()));
         }
         var num = context.numericLiteral().GetText().Replace("_", "");
         var b   = OpBuilder.GetOpBuilder(typeof(decimal), context, _builder);
         b.LoadNum(num);
         return(typeof(decimal));
     }
     return(VisitExpression(context.expression()));
 }
        public override object VisitMulExpression([NotNull] TinyScriptParser.MulExpressionContext context)
        {
            var ret = (Type)VisitUnaryExpression(context.unaryExpression(0));

            if (context.ChildCount > 1)
            {
                Type typeAdd = null;
                for (int i = 1; i < context.ChildCount; i += 2)
                {
                    var op = context.GetChild(i).GetText();
                    var t2 = (Type)VisitUnaryExpression((TinyScriptParser.UnaryExpressionContext)context.GetChild(i + 1));
                    typeAdd = GetOpType(context, ret, t2);
                    var b = OpBuilder.GetOpBuilder(typeAdd, context, _builder);
                    b.ProcessMul(op);
                }
                return(typeAdd);
            }
            return(ret);
        }
        public override object VisitAddExpression([NotNull] TinyScriptParser.AddExpressionContext context)
        {
            var ret = (Type)VisitMulExpression(context.mulExpression(0));

            if (context.ChildCount > 1)
            {
                Type typeAdd = null;
                for (int i = 1; i < context.ChildCount; i += 2)
                {
                    var op = context.GetChild(i).GetText();
                    var t2 = (Type)VisitMulExpression((TinyScriptParser.MulExpressionContext)context.GetChild(i + 1));
                    typeAdd = ret == typeof(string) ? ret : GetOpType(context, ret, t2);
                    if (ret == typeof(string) && t2.IsValueType)
                    {
                        _builder.Box(t2);
                    }
                    var b = OpBuilder.GetOpBuilder(typeAdd, context, _builder);
                    b.ProcessAdd(op);
                }
                return(typeAdd);
            }
            return(ret);
        }