-- Compiled with roblox-ts v1.2.7 -- * @internal local ZirconDebug local ZirconDebug = {} do local _container = ZirconDebug -- * @internal local function IsParserError(err) return err.code >= 1000 end _container.IsParserError = IsParserError -- * @internal local function GetDebugInformationForNode(source, node) local _condition = node.startPos if _condition == nil then _condition = 0 end local startPos = _condition local _condition_1 = node.endPos if _condition_1 == nil then _condition_1 = startPos end local endPos = _condition_1 local col = 0 local row = 1 local lineStart = 0 local lineEnd = #source local reachedToken = false local reachedEndToken = false do local i = 0 local _shouldIncrement = false while true do if _shouldIncrement then i += 1 else _shouldIncrement = true end if not (i < #source) then break end local _arg0 = i + 1 local _arg1 = i + 1 local char = string.sub(source, _arg0, _arg1) if i == startPos then reachedToken = true end if i == endPos then reachedEndToken = true end if char == "\n" then lineEnd = i if not reachedToken then lineStart = i + 1 elseif reachedEndToken then break end row += 1 col = 1 else col += 1 end end end if reachedToken then local _object = { LineAndColumn = { row, col }, CodeLine = { lineStart, lineEnd }, TokenPosition = { startPos, endPos }, TokenLinePosition = { startPos - lineStart, endPos - lineStart }, } local _left = "Line" local _arg0 = lineStart + 1 local _arg1 = lineEnd + 1 _object[_left] = string.sub(source, _arg0, _arg1) return _object end end _container.GetDebugInformationForNode = GetDebugInformationForNode -- * @internal local function GetDebugInformationForToken(source, token) local col = 0 local row = 1 local lineStart = 0 local lineEnd = #source local reachedToken = false do local i = 0 local _shouldIncrement = false while true do if _shouldIncrement then i += 1 else _shouldIncrement = true end if not (i < #source) then break end local _arg0 = i + 1 local _arg1 = i + 1 local char = string.sub(source, _arg0, _arg1) if i == token.startPos then reachedToken = true end if char == "\n" then lineEnd = i if reachedToken then break end lineStart = i + 1 row += 1 col = 1 else col += 1 end end end if reachedToken then local _object = { LineAndColumn = { row, col }, CodeLine = { lineStart, lineEnd }, TokenPosition = { token.startPos, token.endPos }, TokenLinePosition = { token.startPos - lineStart, token.endPos - lineStart }, } local _left = "Line" local _arg0 = lineStart + 1 local _arg1 = lineEnd + 1 _object[_left] = string.sub(source, _arg0, _arg1) return _object end end _container.GetDebugInformationForToken = GetDebugInformationForToken -- * @internal local function GetMessageForError(source, zrError) if ZirconDebug.IsParserError(zrError) then local _result if zrError.token then _result = ZirconDebug.GetDebugInformationForToken(source, zrError.token) else _result = nil end local debug = _result return { type = "ZrParserError", script = "zr", time = DateTime.now().UnixTimestamp, source = debug and debug.LineAndColumn or nil, debug = debug, message = zrError.message, code = zrError.code, } else local _result if zrError.node then _result = ZirconDebug.GetDebugInformationForNode(source, zrError.node) else _result = nil end local debug = _result return { type = "ZrRuntimeError", time = DateTime.now().UnixTimestamp, debug = debug, script = "zr", message = zrError.message, code = zrError.code, } end end _container.GetMessageForError = GetMessageForError end return { ZirconDebug = ZirconDebug, }