Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  Debugger-onNativeCall-06.js

  Sprache: JAVA
 

// Test that the onNativeCall hook is called when native function is
// called inside self-hosted JS.

load(libdir + 'eqArrayHelper.js');

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

let rv = [];
dbg.onNativeCall = (callee, reason) => {
  rv.push(callee.name);
};

gdbg.executeInGlobal(`
// Built-in native function.
[123].map(Array.prototype.push, Array.prototype);

// Built-in native function with non-optimized species lookup in 'map'.
var arr = [123];
Object.setPrototypeOf(arr, Object.create(Array.prototype));
arr.map(Array.prototype.push, Array.prototype);

// Self-hosted function.
[123].map(String.prototype.padStart, "");

// Other native function.
[123].map(dateNow);
`);
assertEqArray(rv, [
  "map""push""push""push",
  "create""setPrototypeOf""map""get [Symbol.species]""push""push""push",
  "map""padStart""padStart""padStart",
  "map""dateNow""dateNow""dateNow",
]);
rv = [];
gdbg.executeInGlobal(`
  // Optimized 'match' (no callContentFunction).
  var re = /a./;
  "abc".match(re);

  // Non-optimized 'match'. This calls RegExp.prototype[@@match] and getters on
  // RegExp.prototype.
  Object.setPrototypeOf(re, Object.create(RegExp.prototype));
  "abc".match(re);
`);
assertEqArray(rv, [
  "match",
  "create""setPrototypeOf",
  "match""[Symbol.match]",
  "get flags""get hasIndices""get global""get ignoreCase""get multiline",
  "get dotAll""get unicode""get unicodeSets""get sticky",
]);
rv = [];
gdbg.executeInGlobal(`
// Nested getters called internally inside self-hosted.
const r = /a./;
r.foo = 10;
"abc".match(r);

// Setter inside self-hosted JS.
// Hook "A.length = k" in Array.from.
var ctor = function() {
  let obj = {};
  Object.defineProperty(obj, "length", { set: Array.prototype.join });
  return obj;
};
var a = [123];
a[Symbol.iterator] = null;
void Array.from.call(ctor, a);
`);
assertEqArray(rv, [ 
  "match""[Symbol.match]",
  "get flags",
  "get hasIndices""get global""get ignoreCase""get multiline",
  "get dotAll""get unicode""get unicodeSets""get sticky",
  "call""from""defineProperty""join",
]);

rv = [];
gdbg.executeInGlobal(`
var origExec = RegExp.prototype.exec;
RegExp.prototype.exec = dateNow;
try {
  (/a.b/).test("abc");
catch (e) {} // Throws not-object-or-null.
RegExp.prototype.exec = origExec;
`);
assertEqArray(rv, ["test""dateNow"]);

Messung V0.5 in Prozent
C=93 H=94 G=93

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© 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.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Statistik
#Sources=277311
#Domains=752002