Skip to content

Commit

Permalink
dont debug undefined vars
Browse files Browse the repository at this point in the history
  • Loading branch information
yazz committed Jul 22, 2023
1 parent 1d1e81b commit 1bed09d
Showing 1 changed file with 34 additions and 29 deletions.
63 changes: 34 additions & 29 deletions public/go.html
Original file line number Diff line number Diff line change
Expand Up @@ -3393,9 +3393,11 @@
//alert(`let ${node.declarations[0].id.name} = ${node.declarations[0].init.value}`)
let varNameToUse = node.declarations[0].id.name
if (node.kind == "var") {
let newLine = "logVarBefore('" + blockName + "', " + node.loc.start.line + ",'" +
varNameToUse + "', " + varNameToUse + ");"
let newNode = esprima.parse(newLine)
if (isValidObject(varNameToUse) && varNameToUse.indexOf("undefined")==-1){
let newLine = "logVarBefore('" + blockName + "', " + node.loc.start.line + ",'" +
varNameToUse + "', " + varNameToUse + ");"
let newNode = esprima.parse(newLine)
}
}
varsToAdd[varNameToUse] = {}

Expand Down Expand Up @@ -3438,39 +3440,42 @@
if ((node.expression.type == "AssignmentExpression") &&
(node.expression.operator == "=")) {
let varName = node.expression.left.name
if (!isValidObject(varName)) {
if (node.expression.left.object.type == "ThisExpression") {
varName = "this." + node.expression.left.property.name
} else if (node.expression.left.type == "MemberExpression") {
varName = node.expression.left.object.name
if (node.expression.left.property.type == "Identifier") {
varName += "." + node.expression.left.property.name
if (isValidObject(varName) && varName.indexOf("undefined") == -1) {
if (!isValidObject(varName)) {
if (node.expression.left.object.type == "ThisExpression") {
varName = "this." + node.expression.left.property.name
} else if (node.expression.left.type == "MemberExpression") {
varName = node.expression.left.object.name
if (node.expression.left.property.type == "Identifier") {
varName += "." + node.expression.left.property.name
}
}
}
}
varsToAdd[varName] = {}
varsToAdd[varName] = {}

let newLine = "logVarBefore('" + blockName + "', " + node.loc.start.line + ",'" +
varName + "', " + varName + ");"
let newNode = esprima.parse(newLine)

let newLineAfter = "logVarAfter('" + blockName + "', " + node.loc.start.line + ",'" +
varName + "', " + varName + ");"
let newNodeAfter = esprima.parse(newLineAfter)
let newLine = "logVarBefore('" + blockName + "', " + node.loc.start.line + ",'" +
varName + "', " + varName + ");"
let newNode = esprima.parse(newLine)

let logWatchVarsCode = `for (let _uu=0; _uu<Object.keys(globalWatchList).length; _uu++){try { let _vName = Object.keys(globalWatchList)[_uu];if (isValidObject(_vName)){ addWatchPoint(_vName, eval(_vName) ) }} catch(_err){}}`
let logWatchVarsNode = esprima.parse(logWatchVarsCode)
let newLineAfter = "logVarAfter('" + blockName + "', " + node.loc.start.line + ",'" +
varName + "', " + varName + ");"
let newNodeAfter = esprima.parse(newLineAfter)

for (let rr = 0; rr < parent.body.length; rr++) {
if (parent.body[rr] == node) {
if (logWatchVarsNode) {
parent.body.splice(rr + 1, 0, logWatchVarsNode);
}
if (newNodeAfter) {
parent.body.splice(rr + 1, 0, newNodeAfter);
let logWatchVarsCode = `for (let _uu=0; _uu<Object.keys(globalWatchList).length; _uu++){try { let _vName = Object.keys(globalWatchList)[_uu];if (isValidObject(_vName)){ addWatchPoint(_vName, eval(_vName) ) }} catch(_err){}}`
let logWatchVarsNode = esprima.parse(logWatchVarsCode)

for (let rr = 0; rr < parent.body.length; rr++) {
if (parent.body[rr] == node) {
if (logWatchVarsNode) {
parent.body.splice(rr + 1, 0, logWatchVarsNode);
}
if (newNodeAfter) {
parent.body.splice(rr + 1, 0, newNodeAfter);
}
parent.body.splice(rr, 0, newNode);
break;
}
parent.body.splice(rr, 0, newNode);
break;
}
}
}
Expand Down

0 comments on commit 1bed09d

Please sign in to comment.