Skip to content

Commit

Permalink
Don't debug undefined stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
yazz committed Jul 21, 2023
1 parent b3dcd23 commit 744848b
Showing 1 changed file with 31 additions and 33 deletions.
64 changes: 31 additions & 33 deletions public/go.html
Original file line number Diff line number Diff line change
Expand Up @@ -3360,7 +3360,6 @@
}
}
if (debugFromHere) {

var index = trcode2.indexOf("let debug_from_here = true;");
var tempString = trcode2.substring(0, index);
var lineNumber = tempString.split('\n').length;
Expand Down Expand Up @@ -3405,10 +3404,7 @@
if (node.declarations[0].init) {
//alert(`let ${node.declarations[0].id.name} = ${node.declarations[0].init.value}`)
let varNameToUse = node.declarations[0].id.name
if (debugFromHere) {
if (varNameToUse == "debug_from_here") {
debugFromHere = false
}
if ((!isValidObject(varNameToUse)) || varNameToUse.indexOf("undefined" != -1)) {
} else {

if (node.kind == "var") {
Expand Down Expand Up @@ -3458,47 +3454,49 @@
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)) {
} else {
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 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 newLineAfter = "logVarAfter('" + blockName + "', " + node.loc.start.line + ",'" +
varName + "', " + varName + ");"
let newNodeAfter = esprima.parse(newLineAfter)

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 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);
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 744848b

Please sign in to comment.