예제 #1
0
        public override void VisitConcatenate(ASTConcatenate n)
        {
            //push left and right
            n.Left.Visit(this);
            BoxIfNeeded(n.Left.CFlatType);
            n.Right.Visit(this);
            BoxIfNeeded(n.Right.CFlatType);

            //now call String.Concat
            _gen.Emit(OpCodes.Call, typeof(String).GetMethod("Concat", BindingFlags.Public | BindingFlags.Static,
                                                             null, new Type[] { typeof(object), typeof(object) }, null));

            _lastWalkedType = typeof(string);
        }
예제 #2
0
파일: ThirdPass.cs 프로젝트: goric/cflat
        public override void VisitConcatenate(ASTConcatenate n)
        {
            CFlatType lhs = CheckSubTree(n.Left);
            CFlatType rhs = CheckSubTree(n.Right);

            // we'll allow for implicit conversion from numeric types to strings for concat purposes
            if ((lhs.IsConcatenatable) && (rhs.IsConcatenatable))
            {
                _lastSeenType = n.CFlatType = new TypeString();
            }
            else
            {
                ReportError(n.Location, "Operands for concatenation must be strings, characters, or integers.");
            }
        }