products/Sources/formale Sprachen/C/Firefox/xpcom/base/   (Gnome Linux Desktop Version 4.23.2©)  Datei vom 27.6.2026 mit Größe 8 kB image not shown  

Quelle  Source-reparse.js   Sprache: JAVA

 

// reparsing a source should produce equivalent scripts and avoid invoking the
// onNewScript hook.

const g = newGlobal({newCompartment: true});
const dbg = new Debugger;
dbg.addDebuggee(g);

let globalScript;
dbg.onNewScript = script => { globalScript = script };

// Leave `g()` on the first line so we can check that `columnNumber` is passed to the
// reparsed script (`columnNumber` is only used to offset breakpoint column on the first
// line of the script).
g.evaluate(`g();
function f() {
  for (var i = 0; i < 10; i++) {
    g();
  }
}

function g() {
  return 3;
}

f();
`, {
  fileName: "foobar.js",
  lineNumber: 3,
  columnNumber: 42,
});

let onNewScriptCalls = 0;
dbg.onNewScript = script => { onNewScriptCalls++; };

const reparsedScript = globalScript.source.reparse();

assertEq(onNewScriptCalls, 0);

assertEq(reparsedScript.url, "foobar.js");
assertEq(reparsedScript.startLine, 3);
assertEq(reparsedScript.startColumn, 42);

// Test for the same breakpoint positions in the original and reparsed script.
function getBreakpointPositions(script) {
  const offsets = script.getPossibleBreakpoints();
  const str = offsets.map(({ lineNumber, columnNumber }) => `${lineNumber}:${columnNumber}`).toString();
  const childPositions = script.getChildScripts().map(getBreakpointPositions);
  return str + ";" + childPositions.toString();
}
assertEq(getBreakpointPositions(globalScript), getBreakpointPositions(reparsedScript));

// reparse new Function succeeds
dbg.onNewScript = script => { globalScript = script; };
g.evaluate(`bar = new Function("return 5;");`);

const reparsedScript2 = globalScript.source.reparse();

// reparse eval succeeds
g.evaluate(`rv = eval("a = 3; b = 4; a + b;")`);

const reparsedScript3 = globalScript.source.reparse();

Messung V0.5 in Prozent
C=80 H=92 G=86

¤ Dauer der Verarbeitung: 0.10 Sekunden  (vorverarbeitet am  2026-09-27) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.