diff options
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(); } }); |
