Example #1
0
 public VarDeclarationArray(SourceCodePosition pos, BTypeArray t, string id)
     : base(pos, t, id, null)
 {
     if (Size < 2)
     {
         throw new ArrayTooSmallException(Position);
     }
 }
Example #2
0
        public VarDeclarationArray(SourceCodePosition pos, BTypeArray t, string id, LiteralArray v)
            : base(pos, t, id, v)
        {
            int literalSize = ((LiteralArray)Initial).Count;

            if (!v.GetBType().IsImplicitCastableTo(t))
            {
                throw new ImplicitCastException(pos, v.GetBType(), t);
            }

            if (literalSize > t.ArraySize)
            {
                throw new ArrayLiteralTooBigException(pos);
            }
            else if (literalSize < t.ArraySize)
            {
                ((LiteralArray)Initial).AppendDefaultValues(t.ArraySize - literalSize);
                HasCompleteUserDefiniedInitialValue = false;
            }
        }
Example #3
0
        public override CodePiece GenerateCodeAssignment(CodeGenEnvironment env, SourceCodePosition pos, Expression source, ExpressionValuePointer target, bool reversed)
        {
            CodePiece p = new CodePiece();

            BTypeArray type = target.GetResultType() as BTypeArray;
            ExpressionDirectValuePointer vPointer = target as ExpressionDirectValuePointer;

            if (reversed)
            {
                p.AppendLeft(source.GenerateCode(env, reversed));
                p.AppendLeft(CodePieceStore.WriteArrayFromStack(env, vPointer.Target.CodeDeclarationPos, reversed));

                p.NormalizeX();
            }
            else
            {
                p.AppendRight(source.GenerateCode(env, reversed));
                p.AppendRight(CodePieceStore.WriteArrayFromStack(env, vPointer.Target.CodeDeclarationPos, reversed));

                p.NormalizeX();
            }

            return(p);
        }