internal DyCodeException(DyVariant err, CallStackTrace cs, Exception?innerException) : base(null !, innerException) => (Error, CallTrace) = (err, cs);
//TODO: Debug Execution //public ExecutionResult Execute(IDebugObserver observer) //{ // var monitor = new DebuggerMonitor(new Debugger(Composition, ModuleHandle), observer); // var vm = new DysMachine(Composition, monitor); // return vm.Execute(); //} public CallStackTrace BuildCallStack(Stack <StackPoint> callChain) { var frames = new List <CallFrame>(); var retval = new CallStackTrace(frames); if (callChain is null || callChain.Count == 0) { return(retval); } do { var mem = callChain.Pop(); if (mem.IsExternal) { frames.Add(CallFrame.External); continue; } var offset = mem.Offset - 1; var unit = Composition.Units[mem.UnitId]; if (unit.Symbols is null) { frames.Add(new( moduleName: unit.FileName, codeBlockName: Unknown, offset: offset, lineSym: new(offset))); continue; } var funSym = unit.Symbols.FindFunSym(offset); var line = unit.Symbols.FindLineSym(offset); string?codeBlockName = null; if (funSym != null) { codeBlockName = funSym.Name ?? DefaultName; if (funSym.TypeName is not null) { codeBlockName = funSym.TypeName + "." + codeBlockName; } if (funSym.Parameters is not null) { codeBlockName += "(" + string.Join(",", funSym.Parameters) + ")"; } else { codeBlockName += "(...)"; } } frames.Add(new( moduleName: unit.FileName, codeBlockName: codeBlockName ?? Global, offset: offset, lineSym: line ?? new LineSym(offset))); }while (callChain.Count > 0); return(retval); }