Exemplo n.º 1
0
 /// <summary>
 /// Extends this chain with a <see cref="RuntimeChainElement"/>.
 /// </summary>
 /// <param name="element">The element.</param>
 public void Add(RuntimeChainElement element)
 {
     if (lastElement != null)
     {
         lastElement.Next = element;
         lastElement      = element;
     }
     else
     {
         Chain = lastElement = element;
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Evaluates this chain as if it had the <see cref="PHP.Core.AST.AccessType.ReadRef"/> access type.
        /// </summary>
        /// <param name="context">Current script context.</param>
        /// <returns>The result of chain evaluation.</returns>
        public PhpReference GetReference(ScriptContext context)
        {
            PhpReference reference;

            RuntimeChainElement element = Chain;

            if (element == null)
            {
                // if we are just wrapping the variable with a PhpReference, make a copy
                reference = Variable as PhpReference;
                if (reference == null)
                {
                    reference = new PhpReference(PhpVariable.Copy(Variable, CopyReason.Unknown));
                }

                return(reference);
            }

            // make sure that we have a PhpReference
            reference = PhpVariable.MakeReference(Variable);

            if (element == lastElement)
            {
                // GetPropertyRef/GetItemRef
                return(element.GetRef(ref reference.value, context, Caller));
            }

            // EnsureVariableIsObject/EnsureVariableIsArray
            object var = element.EnsureVariable(ref reference.value, context, Caller);

            if (var == null)
            {
                return(new PhpReference());
            }

            while (element.Next != null)
            {
                // Ensure{Field,Item}Is{Object,Array}
                var = element.Ensure(var, context, Caller);
                if (var == null)
                {
                    return(new PhpReference());
                }

                element = element.Next;
            }

            // GetObjectPropertyRef/GetArrayItemRef
            return(element.GetEnsuredRef(var, context, Caller));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Evaluates this chain as if it had the <see cref="PHP.Core.AST.AccessType.Read"/> access type.
        /// </summary>
        /// <param name="context">Current script context.</param>
        /// <returns>The result of chain evaluation.</returns>
        public object GetValue(ScriptContext context)
        {
            // dereference the PhpReference
            object var = PhpVariable.Dereference(Variable);

            RuntimeChainElement element = Chain;

            while (element != null)
            {
                // GetProperty/GetItem
                var     = element.Get(var, context, Caller);
                element = element.Next;
            }
            return(var);
        }
Exemplo n.º 4
0
		/// <summary>
		/// Extends this chain with a <see cref="RuntimeChainElement"/>.
		/// </summary>
		/// <param name="element">The element.</param>
		public void Add(RuntimeChainElement element)
		{
			if (lastElement != null)
			{
				lastElement.Next = element;
				lastElement = element;
			}
			else Chain = lastElement = element;
		}