public NodejsModuleBuilder(string filename, JsAnalyzer analyzer) { _all = _serializer.DeserializeObject(File.ReadAllText(filename)); _analyzer = analyzer; _readableStream = new LazyPropertyFunctionValue(_analyzer._builtinEntry, "readable", "stream"); _writableStream = new LazyPropertyFunctionValue(_analyzer._builtinEntry, "writable", "stream"); }
internal ProjectEntry(JsAnalyzer analyzer, string filePath, IAnalysisCookie cookie, bool isBuiltin = false) { _analyzer = analyzer; _filePath = filePath; _cookie = cookie; _moduleRecord = new ModuleEnvironmentRecord(this); _isBuiltin = isBuiltin; }
/// <summary> /// Marks the current VariableDef as exceeding the limit and not to be /// added to in future. It is virtual to allow subclasses to try and /// 'rescue' the VariableDef, for example, by combining types. /// </summary> protected virtual void ExceedsTypeLimit() { object dummy; var uc = _emptySet.Comparer as UnionComparer; if (uc == null) { MakeUnion(0); } else if (uc.Strength < UnionComparer.MAX_STRENGTH) { MakeUnion(uc.Strength + 1); } else if (!LockedVariableDefs.TryGetValue(this, out dummy)) { Debug.Fail("locking variable defs"); LockedVariableDefs.Add(this, LockedVariableDefsValue); #if DEBUG // The remainder of this block logs diagnostic information to // allow the VariableDef to be identified. int total = 0; var typeCounts = new Dictionary <string, int>(); JsAnalyzer analyzer = null; foreach (var type in TypesNoCopy) { if (type.Value == null) { continue; } if (analyzer == null && type.Value.DeclaringModule != null) { analyzer = type.Value.DeclaringModule.Analysis.ProjectState; } var str = type.ToString(); int count; if (!typeCounts.TryGetValue(str, out count)) { count = 0; } typeCounts[str] = count + 1; total += 1; } var typeCountList = typeCounts.OrderByDescending(kv => kv.Value).Select(kv => string.Format("{0}x {1}", kv.Value, kv.Key)).ToList(); Debug.Write(string.Format("{0} exceeded type limit.\nStack trace:\n{1}\nContents:\n Count = {2}\n {3}\n", GetType().Name, new StackTrace(true), total, string.Join("\n ", typeCountList))); if (analyzer != null) { analyzer.Log.ExceedsTypeLimit(GetType().Name, total, string.Join(", ", typeCountList)); } #endif } }
public MemberResult[] GetModuleMembers(string[] names, bool includeMembers = false) { var res = new List <MemberResult>(ProjectState.GetModuleMembers(names, includeMembers)); var children = GlobalScope.GetChildrenPackages(); foreach (var child in children) { var mod = (ModuleInfo)child.Value; var childName = mod.Name.Substring(this.GlobalScope.Name.Length + 1); if (childName.StartsWith(names[0])) { res.AddRange(JsAnalyzer.GetModuleMembers(names, includeMembers, mod as IModule)); } } return(res.ToArray()); }
public static void Build(string filename, JsAnalyzer analyzer) { new NodejsModuleBuilder(filename, analyzer).Build(); }
public override IAnalysisSet GetReturnValue(JsAnalyzer analyzer) { return(analyzer._trueInst.SelfSet); }
public override IAnalysisSet GetReturnValue(JsAnalyzer analyzer) { return(analyzer._emptyStringValue.SelfSet); }
public abstract IAnalysisSet GetReturnValue(JsAnalyzer analyzer);