Exemple #1
0
        protected override IPhpValue VisitPhpMethodInvokeValue(PhpMethodInvokeValue node)
        {
            var nv = strip(node.Expression);

            if (PhpSourceBase.EqualCode(nv, node.Expression))
            {
                return(node);
            }
            return(new PhpMethodInvokeValue(nv)
            {
                ByRef = node.ByRef
            });
        }
Exemple #2
0
 protected override IPhpValue VisitPhpMethodCallExpression(PhpMethodCallExpression node)
 {
     if (node.Name == "_urlencode_" || node.Name == "_htmlspecialchars_")
     {
         if (node.Arguments[0].Expression is PhpConstValue)
         {
             var cv = (node.Arguments[0].Expression as PhpConstValue).Value;
             if (cv == null)
             {
                 return(Simplify(node.Arguments[0].Expression));
             }
             if (cv is int)
             {
                 cv = cv.ToString();
             }
             else if (cv is string)
             {
                 if (node.Name == "_urlencode_")
                 {
                     cv = HttpUtility.UrlEncode(cv as string);
                 }
                 else
                 {
                     cv = HttpUtility.HtmlEncode(cv as string);
                 }
             }
             else
             {
                 throw new NotSupportedException();
             }
             return(Simplify(new PhpConstValue(cv)));
         }
     }
     {
         var list1 = node.Arguments.Select(Simplify).Cast <PhpMethodInvokeValue>().ToList();
         var to    = node.TargetObject == null ? null : Simplify(node.TargetObject);
         if (PhpSourceBase.EqualCode_List(list1, node.Arguments) && PhpSourceBase.EqualCode(to, node.TargetObject))
         {
             return(node);
         }
         var xx = new PhpMethodCallExpression(node.Name)
         {
             Arguments        = list1,
             DontIncludeClass = node.DontIncludeClass,
             TargetObject     = to
         };
         xx.SetClassName(node.ClassName, node.TranslationInfo);
         return(xx);
     }
     return(node);
 }