示例#1
0
        private object Filter(object instance, PhpStack/*!*/ stack)
		{
            StringBuilder result = new StringBuilder();

			Debug.Assert(stack.ArgCount >= 1, "Called by output buffering, so should be ok");

            string data = PhpVariable.AsString(stack.PeekValueUnchecked(1));

			stack.RemoveFrame();

            // parse the text
            if (parser == null)
                parser = new TagsUrlRewriter(this);

            return parser.ParseHtml(parserState, data);
		}
示例#2
0
		/// <summary>
		/// Default callback for <see cref="Map"/>.
		/// </summary>
		/// <param name="instance">Unused.</param>
		/// <param name="stack">A PHP stack.</param>
		/// <returns>A <see cref="PhpArray"/> containing items on the stack (passed as arguments).</returns>
		private static object MapIdentity(object instance, PhpStack stack)
		{
			PhpArray result = new PhpArray(stack.ArgCount, 0);

			for (int i = 1; i <= stack.ArgCount; i++)
			{
				result.Add(PhpVariable.Copy(stack.PeekValueUnchecked(i), CopyReason.PassedByCopy));
			}
			stack.RemoveFrame();

			return result;
		}
示例#3
0
        public static object InvokeMethodDynamic(string moduleName, string className, string methodName, PhpObject self,
            PhpStack stack, int[] refInfo)
        {
            int arg_count = stack.ArgCount;
            object[] args = new object[arg_count];
            PhpReference[] references = new PhpReference[arg_count];

            // convert arguments on calling stack into the args array
            stack.CalleeName = methodName;
            int ref_ptr = (refInfo != null && refInfo.Length > 0 ? 0 : -1);
            for (int i = 0; i < arg_count; i++)
            {
                if (ref_ptr >= 0)
                {
                    if (i == refInfo[ref_ptr])
                    {
                        args[i] = references[i] = stack.PeekReferenceUnchecked(i + 1);
                        if (++ref_ptr >= refInfo.Length) ref_ptr = -1;
                        continue;
                    }
                    else if (refInfo[ref_ptr] == -1)
                    {
                        args[i] = references[i] = stack.PeekReferenceUnchecked(i + 1);
                        continue;
                    }
                }
                args[i] = stack.PeekValueUnchecked(i + 1);
            }
            stack.RemoveFrame();

            if (refInfo == null || refInfo.Length == 0)
            {
                return InvokeMethod(moduleName, className, methodName, self, stack.Context, ref args, null);
            }
            else
            {
                object ret_val = InvokeMethod(moduleName, className, methodName, self, stack.Context, ref args, refInfo);

                // propagate back byref parameters
                for (int i = 0; i < arg_count; i++)
                {
                    if (references[i] != null) references[i].Value = args[i];
                }

                return ret_val;
            }
        }