Beispiel #1
0
        public override void VisitInstantiateArray(ASTInstantiateArray n)
        {
            //push number of elements
            n.Upper.Visit(this);
            Type elementType = _typeManager.LookupCilType(n.Type);

            _gen.Emit(OpCodes.Newarr, elementType);
            _lastWalkedType = elementType.MakeArrayType();
        }
Beispiel #2
0
        /// <summary>
        /// Checks to make sure that both the upper and lower bounds are integers
        /// </summary>
        /// <param name="n"></param>
        public override void VisitInstantiateArray(ASTInstantiateArray n)
        {
            n.Lower.CFlatType = CheckSubTree(n.Lower);
            n.Upper.CFlatType = CheckSubTree(n.Upper);

            if ((n.Lower.CFlatType is TypeInt) && (n.Upper.CFlatType is TypeInt))
            {
                CFlatType elementType = CheckSubTree(n.Type);

                TypeArray arrType = new TypeArray(elementType);
                _lastSeenType = arrType;
                n.CFlatType   = arrType;
            }
            else
            {
                ReportError(n.Location, "Bounds of an array must be integers.");
            }
        }