MCPcopy Index your code
hub / github.com/gpujs/gpu.js / findLastReturn

Method findLastReturn

src/backend/function-node.js:1411–1439  ·  view source on GitHub ↗
(ast)

Source from the content-addressed store, hash-verified

1409 }
1410
1411 findLastReturn(ast) {
1412 const stack = [ast || this.ast];
1413
1414 while (stack.length > 0) {
1415 const atNode = stack.pop();
1416 if (atNode.type === 'ReturnStatement') {
1417 return atNode;
1418 }
1419 if (atNode.type === 'FunctionDeclaration') {
1420 continue;
1421 }
1422 if (atNode.argument) {
1423 stack.push(atNode.argument);
1424 } else if (atNode.body) {
1425 stack.push(atNode.body);
1426 } else if (atNode.declarations) {
1427 stack.push(atNode.declarations);
1428 } else if (Array.isArray(atNode)) {
1429 for (let i = 0; i < atNode.length; i++) {
1430 stack.push(atNode[i]);
1431 }
1432 } else if (atNode.consequent) {
1433 stack.push(atNode.consequent);
1434 } else if (atNode.cases) {
1435 stack.push(atNode.cases);
1436 }
1437 }
1438 return null;
1439 }
1440
1441 getInternalVariableName(name) {
1442 if (!this._internalVariableNames.hasOwnProperty(name)) {

Callers 2

getTypeMethod · 0.95
astFunctionMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected