Save module dependencies in script, so we can easily read these

This commit is contained in:
Deukhoofd 2018-12-14 18:48:53 +01:00
parent e78ad21d0e
commit 11092c11ff
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
3 changed files with 9 additions and 2 deletions

View File

@ -69,7 +69,7 @@ namespace Upsilon.Binder
variable.ResultType = resultType; variable.ResultType = resultType;
} }
_unboundFunctions = new Dictionary<string, UnboundFunctionExpression>(); _unboundFunctions = new Dictionary<string, UnboundFunctionExpression>();
return new BoundScript((BoundBlockStatement) bound, e.Span, Scope, fileName); return new BoundScript((BoundBlockStatement) bound, e.Span, Scope, fileName, _script);
} }
private BoundStatement BindStatement(StatementSyntax s) private BoundStatement BindStatement(StatementSyntax s)
@ -256,6 +256,8 @@ namespace Upsilon.Binder
{ {
var moduleName = be.Value.ToString(); var moduleName = be.Value.ToString();
var module = _script.Options.ModuleHandler.GetModule(_script, moduleName); var module = _script.Options.ModuleHandler.GetModule(_script, moduleName);
if (!_script.ModuleDependencies.Contains(moduleName))
_script.ModuleDependencies.Add(moduleName);
if (module == null) if (module == null)
{ {
var fullPath = Path.GetFullPath(_script.Options.ScriptLoader.ModulesPath); var fullPath = Path.GetFullPath(_script.Options.ScriptLoader.ModulesPath);

View File

@ -1,15 +1,19 @@
using System.Collections.Generic; using System.Collections.Generic;
using Upsilon.Evaluator;
using Upsilon.Text; using Upsilon.Text;
namespace Upsilon.Binder namespace Upsilon.Binder
{ {
public class BoundScript : BoundStatement public class BoundScript : BoundStatement
{ {
public BoundScript(BoundBlockStatement statement, TextSpan span, BoundScope scope, string fileName) : base(span) public Script Script { get; }
public BoundScript(BoundBlockStatement statement, TextSpan span, BoundScope scope, string fileName, Script script) : base(span)
{ {
Statement = statement; Statement = statement;
Scope = scope; Scope = scope;
FileName = fileName; FileName = fileName;
Script = script;
} }
public string FileName { get; set; } public string FileName { get; set; }

View File

@ -25,6 +25,7 @@ namespace Upsilon.Evaluator
public Diagnostics Diagnostics { get; } public Diagnostics Diagnostics { get; }
private Binder.Binder Binder { get; } private Binder.Binder Binder { get; }
private EvaluationScope Scope { get; } private EvaluationScope Scope { get; }
public List<string> ModuleDependencies { get; } = new List<string>();
internal Script(string scriptString, string fileName, ScriptOptions options ) internal Script(string scriptString, string fileName, ScriptOptions options )
{ {