예제 #1
0
        BoundExpression BindItemUse(AST.ItemUse x, BoundAccess access)
        {
            AstUtils.PatchItemUse(x);

            var arrayAccess = BoundAccess.Read;

            if (x.Index == null && (!access.IsEnsure && !access.IsWrite))   // READ variable[]
            {
                access = access.WithReadRef();                              // -> READREF variable[] // the only way new item will be ensured
            }
            if (access.IsWrite || access.IsEnsure)
            {
                arrayAccess = arrayAccess.WithEnsureArray();
            }
            if (access.IsQuiet)
            {
                arrayAccess = arrayAccess.WithQuiet();
            }

            var boundArray = BindExpression(x.Array, arrayAccess);

            // boundArray.Access = boundArray.Access.WithRead(typeof(PhpArray))

            return(new BoundArrayItemEx(
                       boundArray, (x.Index != null) ? BindExpression(x.Index, BoundAccess.Read) : null)
                   .WithAccess(access));
        }