Beispiel #1
0
        private void UpdateIncludePathExpression()
        {
            if (_assemblyInfo == null)
            {
                PhpIncludePathExpression = null;
                return;
            }
            var pathItems = new List <IPhpValue>();

            {
                var assemblyPath = _assemblyInfo.PhpIncludePathExpression;
                if (assemblyPath != null)
                {
                    pathItems.Add(assemblyPath);
                }
            }
            if (_optionalIncludePathPrefix != null && _optionalIncludePathPrefix.Any())
            {
                foreach (var n in _optionalIncludePathPrefix)
                {
                    if (n.StartsWith("$"))
                    {
                        pathItems.Add(new PhpVariableExpression(n, PhpVariableKind.Global));
                    }
                    else
                    {
                        pathItems.Add(new PhpDefinedConstExpression(n, null));
                    }
                }
            }
            pathItems.Add(new PhpConstValue(_name + Extension));
            PhpIncludePathExpression = PhpBinaryOperatorExpression.ConcatStrings(pathItems.ToArray());
        }
Beispiel #2
0
 public IPhpValue MakeIncludePath(PhpCodeModuleName relatedTo)
 {
     if (relatedTo.Library == Library)
     {
         var knownPath = ProcessPath(_name + _extension, relatedTo._name + _extension);
         //dirname(__FILE__)
         var __FILE__ = new PhpDefinedConstExpression("__FILE__", null);
         var dirname  = new PhpMethodCallExpression("dirname", __FILE__);
         var path     = new PhpConstValue(PathUtil.MakeUnixPath(PathUtil.UNIX_SEP + knownPath));
         var result   = PhpBinaryOperatorExpression.ConcatStrings(dirname, path);
         return(result);
     }
     else
     {
         string path      = null;
         string pathRelTo = null;
         if (_phpIncludePathExpression is PhpConstValue)
         {
             path = (_phpIncludePathExpression as PhpConstValue).Value as string;
             if (path == null)
             {
                 throw new NotSupportedException();
             }
         }
         else
         {
             return(_phpIncludePathExpression); // assume expression like MPDF_LIB_PATH . 'lib/mpdf/mpdf.php'
         }
         if (relatedTo._phpIncludePathExpression is PhpConstValue)
         {
             pathRelTo = (relatedTo._phpIncludePathExpression as PhpConstValue).Value as string;
             if (pathRelTo == null)
             {
                 throw new NotSupportedException();
             }
         }
         if (!string.IsNullOrEmpty(path) && !string.IsNullOrEmpty(path))
         {
             var knownPath = ProcessPath(path, pathRelTo);
             return(new PhpConstValue(knownPath));
         }
         throw new NotSupportedException();
         //var aaaa = "/" + name + extension;
         //if (phpIncludePathExpression == null)
         //    return null;
         //if (phpIncludePathExpression is PhpConstValue)
         //{
         //    aaaa = ((phpIncludePathExpression as PhpConstValue).Value ?? "").ToString() + aaaa;
         //    return ProcessPath(aaaa, relatedTo.emitPath);
         //    // return new PhpConstValue(aaaa, true);
         //}
         //var a = new PhpConstValue(aaaa, true);
         //var g = new PhpBinaryOperatorExpression(".", phpIncludePathExpression, a);
         //return g;
     }
     throw new NotSupportedException();
 }