Exemplo n.º 1
0
        /// <summary>
        /// Converts this instance to its <see cref="String"/> representation.
        /// </summary>
        /// <returns>The converted value.</returns>
        string IPhpConvertible.ToString()
        {
            switch (state)
            {
            case State.UnboundFunction: return(targetName);

            case State.UnboundStaticMethod: return(String.Format("{0}::{1}", className, targetName));

            case State.UnboundInstanceMethod: return(String.Format("{0}::{1}", instance.TypeName, targetName));

            case State.Bound:
            {
                if (instance == null)
                {
                    return(String.Format("{0}::{1}", routineDesc.DeclaringType.MakeFullName(), routineDesc.MakeFullName()));
                }
                return(String.Format("{0}::{1}", instance.TypeName, routineDesc.MakeFullName()));
            }

            case State.BoundToCaller:
            {
                if (instance == null)
                {
                    return(String.Format("{0}::{1}", routineDesc.DeclaringType.MakeFullName(), targetName));
                }
                return(String.Format("{0}::{1}", instance.TypeName, targetName));
            }

            default:
                Debug.Fail(); return(null);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Generates Expression that throws a 'Protected method called' or 'Private method called' <see cref="PhpException"/>.
        /// </summary>
        /// <param name="method">The <see cref="DRoutineDesc"/>.</param>
        /// <param name="callerContext">The caller that was passed to method lookup or <B>null</B>
        /// if it should be determined by this method (by tracing the stack).</param>
        /// <remarks>
        /// This method is intended to be called after <see cref="DTypeDesc.GetMethod"/> has returned
        /// <see cref="GetMemberResult.BadVisibility"/> while performing a method lookup.
        /// </remarks>
        public static Expression /*!*/ ThrowVisibilityError(DRoutineDesc /*!*/ method, DTypeDesc /*!*/ callerContext)
        {
            if (method.IsProtected)
            {
                return(ThrowError("protected_method_called",
                                  method.DeclaringType.MakeFullName(),
                                  method.MakeFullName(),
                                  callerContext == null ? String.Empty : callerContext.MakeFullName()));
            }
            else if (method.IsPrivate)
            {
                return(ThrowError("private_method_called",
                                  method.DeclaringType.MakeFullName(),
                                  method.MakeFullName(),
                                  callerContext == null ? String.Empty : callerContext.MakeFullName()));
            }

            throw new NotImplementedException();
        }
Exemplo n.º 3
0
 public virtual object /*bool*/ isDestructor(ScriptContext context)
 {
     return(method != null && Name.SpecialMethodNames.Destruct.Value.EqualsOrdinalIgnoreCase(method.MakeFullName()));
 }