public object ConstValue(IConstEvalCtx ctx, JsModule module, object export)
 {
     if (JustModuleExports)
     {
         return(null);
     }
     if (!(export is string))
     {
         return(null);
     }
     var(fileName, content) = _resolver.ResolveAndLoad(module);
     if (fileName == null || content == null)
     {
         return(null);
     }
     try
     {
         var ctx2       = ctx.CreateForSourceName(fileName);
         var treeWalker = new ExportFinder((string)export, ctx2);
         treeWalker.Walk(content);
         if (treeWalker.Result == null)
         {
             return(null);
         }
         var result = treeWalker.Result.ConstValue(ctx2);
         if (result == null)
         {
             return(null);
         }
         if (treeWalker.CompleteResult)
         {
             if (result is IReadOnlyDictionary <object, object> dict)
             {
                 if (dict.TryGetValue((string)export, out result))
                 {
                     return(result);
                 }
                 return(AstUndefined.Instance);
             }
             return(null);
         }
         return(result);
     }
     catch
     {
         return(null);
     }
 }
示例#2
0
 virtual public IConstEvalCtx CreateForSourceName(string sourceName)
 {
     return(new BobrilSpecialEval(_ctx.CreateForSourceName(sourceName)));
 }