public static string GetFormattedCompileErrors(this CFlat self) { var sb = new StringBuilder(); for (var i = 0; i < self.compileErrors.count; i++) { var e = self.compileErrors.buffer[i]; sb.Append(e.message); if (e.slice.index > 0 || e.slice.length > 0) { var source = self.compiler.compiledSources.buffer[e.sourceIndex]; FormattingHelper.AddHighlightSlice(source.uri.value, source.content, e.slice, sb); } } return(sb.ToString()); }
public static string GetFormattedRuntimeError(this CFlat self) { if (!self.vm.error.isSome) { return(""); } var error = self.vm.error.value; var sb = new StringBuilder(); sb.Append(error.message); if (error.instructionIndex < 0) { return(sb.ToString()); } var source = self.compiler.compiledSources.buffer[self.vm.chunk.FindSourceIndex(error.instructionIndex)]; FormattingHelper.AddHighlightSlice(source.uri.value, source.content, error.slice, sb); return(sb.ToString()); }