diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-08-09 02:26:07 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-08-09 02:26:07 +0300 |
| commit | 92db2f2431bb58a84dc4d476b889fee1de0143e9 (patch) | |
| tree | 26e8880e86091b08064a3b20b2862d83ed726ab6 /Software/Visual_Studio/Scripting/Tango.Scripting.Basic/Project.cs | |
| parent | 255a47cf96e83e8d11befa9180dc4458f6767188 (diff) | |
| download | Tango-92db2f2431bb58a84dc4d476b889fee1de0143e9.tar.gz Tango-92db2f2431bb58a84dc4d476b889fee1de0143e9.zip | |
Procedure runtime debugging and exceptions.
Diffstat (limited to 'Software/Visual_Studio/Scripting/Tango.Scripting.Basic/Project.cs')
| -rw-r--r-- | Software/Visual_Studio/Scripting/Tango.Scripting.Basic/Project.cs | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.Basic/Project.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.Basic/Project.cs index 2a1a7b7fc..2bd438ff8 100644 --- a/Software/Visual_Studio/Scripting/Tango.Scripting.Basic/Project.cs +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.Basic/Project.cs @@ -52,6 +52,8 @@ namespace Tango.Scripting.Basic } } + public List<ScriptBreakPoint> BreakPoints { get; set; } + public Project() { ID = Guid.NewGuid().ToString(); @@ -62,6 +64,8 @@ namespace Tango.Scripting.Basic Scripts = new ObservableCollection<Script>(); Scripts.CollectionChanged += (x, e) => { RaisePropertyChanged(nameof(AdditionalScripts)); }; + + BreakPoints = new List<ScriptBreakPoint>(); } public Task<CompilationResult> Compile() @@ -93,25 +97,28 @@ namespace Tango.Scripting.Basic code = loadingString + code; - if (!script.IsEntryPoint) + int debugLinesLength = 0; + + foreach (var breakPoint in BreakPoints.Where(x => x.Script == script).OrderBy(x => x.LineNumber)) { - //In case we use #load - //foreach (var match in Regex.Matches(code, "#load \".+\"").OfType<Match>()) - //{ - // String line = match.ToString(); - // var pathMatch = Regex.Match(line, "(?<=\")(.*?)(?=\")"); - // if (pathMatch.Success) - // { - // String path = pathMatch.ToString(); + var debugLine = $"context.BreakPoint(\"{script.Name}\",{breakPoint.LineNumber}"; + + foreach (var symbol in breakPoint.ContextSymbols) + { + debugLine += $",\"{symbol.Name}\",{symbol.Offset},{symbol.Length},{symbol.Name}"; + } + + debugLine += ");"; - // if (!System.IO.Path.IsPathRooted(path)) - // { - // StringBuilder builder = new StringBuilder(code); - // builder.Insert(match.Index + pathMatch.Index, System.IO.Path.GetFullPath(tempFolder + "\\")); - // code = builder.ToString(); - // } - // } - //} + StringBuilder builder = new StringBuilder(code); + builder.Insert(breakPoint.LineStartOffset + loadingString.Length + debugLinesLength, debugLine); + code = builder.ToString(); + + debugLinesLength += debugLine.Length; + } + + if (!script.IsEntryPoint) + { File.WriteAllText(codeFile, code); } else @@ -188,6 +195,7 @@ namespace Tango.Scripting.Basic } finally { + BreakPoints.Clear(); GC.Collect(); } }); |
