示例#1
0
        BoundExpression BindItemUse(AST.ItemUse x, BoundAccess access)
        {
            if (x.IsMemberOf != null)
            {
                Debug.Assert(x.Array.IsMemberOf == null);
                // fix this phalanger ast weirdness:
                x.Array.IsMemberOf = x.IsMemberOf;
                x.IsMemberOf       = null;
            }

            var arrayAccess = BoundAccess.Read;

            if (access.IsWrite || access.EnsureObject || access.EnsureArray)
            {
                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));
        }
示例#2
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));
        }