Skip to content
Prev Previous commit
fixup! lib: modify NativeModule to use compileFunction
  • Loading branch information
ryzokuken committed Oct 29, 2018
commit d2dcd54dea3b200d577ff28c2e490b002ace5003
30 changes: 18 additions & 12 deletions lib/internal/bootstrap/loaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,14 @@
undefined;
};

NativeModule.parameters = Object.freeze([
'exports',
'require',
'module',
'process',
'internalBinding'
]);

NativeModule.prototype.compile = function() {
const id = this.id;
const source = NativeModule.getSource(id);
Expand Down Expand Up @@ -259,19 +267,17 @@
const cache = codeCacheHash[id] &&
(codeCacheHash[id] === sourceHash[id]) ? codeCache[id] : undefined;

Comment thread
ryzokuken marked this conversation as resolved.
const params = ['exports', 'require', 'module', 'process', 'internalBinding'];

// TODO(@joyeecheung): figure out way to expose wrapped source for code cache
// TODO(@joyee): figure out way to expose wrapped source for code cache
const fn = compileFunction(
source, // source code
this.filename, // filename
0, // line offset
0, // column offset
cache, // cached data
false, // produce cached data
undefined, // parsing context
undefined, // context extensions
params // arguments to the function
source, // source code
this.filename, // filename
0, // line offset
0, // column offset
cache, // cached data
false, // produce cached data
undefined, // parsing context
undefined, // context extensions
NativeModule.parameters // arguments to the function
);

// One of these conditions may be false when any of the inputs
Expand Down