forked from ariya/esmorph
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for inserting trace markers at end of functions.
Created two new methods on the esmorph.Tracer object: `.traceFunctionExit` Insert marker at end of function bodies. `.traceFunctionEntranceAndExit` Insert marker at beginning and end of function bodies. Temporarily disabled trace on non-function declaration nodes. Also added unit tests, written using Mocha.
- Loading branch information
Showing
9 changed files
with
349 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.swo | ||
*.swp | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
function helloWorld() { | ||
var a = 3 * 5; | ||
|
||
console.log('hi'); | ||
|
||
return 'hello world!'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
function helloWorld() { | ||
myTrace({ name: 'helloWorld', lineNumber: 1, range: [0, 50] }); | ||
return 'hello world!'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
function helloWorld() { | ||
myTrace({ name: 'helloWorld', lineNumber: 1, range: [0, 50] }); | ||
return 'hello world!'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
function helloWorld() { | ||
var a = 3 * 5; | ||
|
||
console.log('hi'); | ||
|
||
return 'hello world!'; | ||
} | ||
|
||
function goodbye() { | ||
var a = 3 * 5; | ||
|
||
console.log('hi'); | ||
|
||
return 'hello world!'; | ||
} | ||
|
||
function setValue( name ) { | ||
window.foo.name = name; | ||
return 'hello world!'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* Some simple test helpers used in unit tests for esmorph | ||
* @author Seth McLaughlin <s@sethmcl.com> | ||
*/ | ||
'use strict'; | ||
|
||
// dependencies | ||
var fs = require('fs'), | ||
path = require('path'); | ||
|
||
// locals | ||
var sourceCode = {}; | ||
|
||
/** | ||
* Load sample source code | ||
* @param {String} codeFile the file name. Will be resolved relative | ||
* to the /test/data/sample_source_code/ directory | ||
* @return {String} contents of codeFile | ||
*/ | ||
module.exports.loadSampleCode = function( codeFile ) { | ||
var code, | ||
codeRoot = path.resolve( __dirname, '..', 'data', 'sample_source_code' ); | ||
|
||
// check if we have already cached the file contents | ||
if(sourceCode[codeFile]) { | ||
code = sourceCode[codeFile]; | ||
} else { | ||
try { | ||
code = sourceCode[codeFile] = fs.readFileSync( path.resolve( codeRoot, codeFile + '.js' ) ).toString(); | ||
} catch(e) { | ||
throw Error('Could not load codeFile "' + codeFile + '": ' + e.message); | ||
} | ||
} | ||
|
||
return code; | ||
}; | ||
|
||
/** | ||
* Build string of source code from array | ||
* @param {Array} lines code | ||
* @return {String} source code | ||
*/ | ||
module.exports.buildSrc = function( lines ) { | ||
return lines.join(''); | ||
}; | ||
|
Oops, something went wrong.