Example #1
0
        /// <summary>
        /// Visit item use index (if not null) and array.
        /// </summary>
        /// <param name="x"></param>
        virtual public void VisitItemUse(ItemUse x) 
        {
            VisitElement(x.Index);
            VisitElement(x.Array);

            //VisitVarLikeConstructUse(x);
        }
Example #2
0
		/// <summary>
		/// Emits IL instructions that add an array item access to the current <see cref="PhpRuntimeChain"/>.
		/// </summary>
		/// <param name="itemUse">AST node representing the item access.</param>
		/// <remarks>
		/// A reference to <see cref="PhpRuntimeChain"/> is expected and left on the evaluation stack.
		/// </remarks>
		public void EmitRTChainAddItem(ItemUse itemUse)
		{
			PhpTypeCode res = itemUse.Array.Emit(codeGenerator);

			// create the runtime chain if it has not been done so
			if (res != PhpTypeCode.PhpRuntimeChain)
			{
				codeGenerator.EmitBoxing(res);
				EmitCreateRTChain();
			}

			codeGenerator.IL.Emit(OpCodes.Dup);

			if (itemUse.Index != null)
			{
				// [x]
				Create();
				codeGenerator.EmitBoxing(itemUse.Index.Emit(codeGenerator));
				End();
				codeGenerator.IL.EmitCall(OpCodes.Call, Methods.PhpRuntimeChain.AddItem_Object, null);
			}
			else
			{
				// []
				codeGenerator.IL.EmitCall(OpCodes.Call, Methods.PhpRuntimeChain.AddItem_Void, null);
			}
		}