/// <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); } }
/// <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(); }
public virtual object /*bool*/ isDestructor(ScriptContext context) { return(method != null && Name.SpecialMethodNames.Destruct.Value.EqualsOrdinalIgnoreCase(method.MakeFullName())); }