/// <summary>Registers the given script as a top-level script in the debugger.</summary>
/// <remarks>Registers the given script as a top-level script in the debugger.</remarks>
private void RegisterTopScript(DebuggableScript topScript, string source)
{
if (!topScript.IsTopLevel())
{
throw new ArgumentException();
}
string url = GetNormalizedUrl(topScript);
DebuggableScript[] functions = GetAllFunctions(topScript);
if (sourceProvider != null)
{
string providedSource = sourceProvider.GetSource(topScript);
if (providedSource != null)
{
source = providedSource;
}
}
Dim.SourceInfo sourceInfo = new Dim.SourceInfo(source, functions, url);
lock (urlToSourceInfo)
{
Dim.SourceInfo old = urlToSourceInfo.Get(url);
if (old != null)
{
sourceInfo.CopyBreakpointsFrom(old);
}
urlToSourceInfo.Put(url, sourceInfo);
for (int i = 0; i != sourceInfo.FunctionSourcesTop(); ++i)
{
Dim.FunctionSource fsource = sourceInfo.FunctionSource(i);
string name = fsource.Name();
if (name.Length != 0)
{
functionNames.Put(name, fsource);
}
}
}
lock (functionToSource)
{
for (int i = 0; i != functions.Length; ++i)
{
Dim.FunctionSource fsource = sourceInfo.FunctionSource(i);
functionToSource.Put(functions[i], fsource);
}
}
callback.UpdateSourceText(sourceInfo);
}