Skip to content

Commit

Permalink
Instrument: Remove unnecessary function param [refactor]
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed Dec 3, 2023
1 parent 3c45b5b commit 8400838
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions lib/instrument/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,10 @@ function activateBlock(block, state) {
* Activate binding.
* Called when a binding is accessed from within a function.
* @param {Object} binding - Binding object
* @param {string} varName - Var name
* @returns {undefined}
*/
function activateBinding(binding, varName) {
if (!binding.varNode) binding.varNode = t.identifier(varName);
function activateBinding(binding) {
if (!binding.varNode) binding.varNode = t.identifier(binding.name);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/instrument/visitors/eval.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ function instrumentEvalCall(callNode, block, fn, isStrict, canUseSuper, superIsP
// Ignore `new.target` and `super` as they're not possible to recreate.
// https://github.com/overlookmotel/livepack/issues/448
if (isExternalToFunction && varName !== 'new.target' && varName !== 'super') {
activateBinding(binding, varName);
activateBinding(binding);
const externalVar = getOrCreateExternalVar(fn, block, varName, binding);
externalVar.isReadFrom = true;
if (!isConst) externalVar.isAssignedTo = true;
Expand Down
2 changes: 1 addition & 1 deletion lib/instrument/visitors/identifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ function resolveIdentifier(node, block, varName, fn, trail, isReadFrom, isAssign
*/
function recordExternalVar(binding, block, varName, fn, trail, isReadFrom, isAssignedTo, state) {
activateBlock(block, state);
activateBinding(binding, varName);
activateBinding(binding);
const externalVar = getOrCreateExternalVar(fn, block, varName, binding);
if (isReadFrom) externalVar.isReadFrom = true;
if (isAssignedTo) externalVar.isAssignedTo = true;
Expand Down

0 comments on commit 8400838

Please sign in to comment.