UNPKG

pxt-core

Version:

Microsoft MakeCode provides Blocks / JavaScript / Python tools and editors

35 lines (34 loc) 1.22 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.startAsync = void 0; const hid = require("./hid"); const fs = require("fs"); var U = pxt.Util; var D = pxt.HWDBG; function startAsync(compileRes) { return hid.initAsync() .then(d => { hid.connectSerial(d); D.postMessage = msg => { if (msg.subtype != "breakpoint") { console.log(msg); return; } let bmsg = msg; console.log("GLOBALS", bmsg.globals); for (let s of bmsg.stackframes) console.log(s.funcInfo.functionName, s.locals); let brkMatch = compileRes.breakpoints.filter(b => b.id == bmsg.breakpointId)[0]; if (!brkMatch) { console.log("Invalid breakpoint ID", msg); return; } let lines = fs.readFileSync(brkMatch.fileName, "utf8").split(/\n/); console.log(">>>", lines.slice(brkMatch.line, brkMatch.endLine + 1).join(" ;; ")); U.delay(500) .then(() => D.resumeAsync(false)); }; return D.startDebugAsync(compileRes, d); }); } exports.startAsync = startAsync;