mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-01-14 17:27:59 -05:00
@@ -233,9 +233,13 @@
|
||||
var answer, sourceMap;
|
||||
sourceMap = mainModule._sourceMaps[filename];
|
||||
if (sourceMap) {
|
||||
answer = sourceMap.getSourcePosition([line, column]);
|
||||
answer = sourceMap.getSourcePosition([line - 1, column - 1]);
|
||||
}
|
||||
if (answer) {
|
||||
return [answer[0] + 1, answer[1] + 1];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return answer;
|
||||
};
|
||||
frames = (function() {
|
||||
var _j, _len1, _results;
|
||||
|
||||
@@ -193,18 +193,12 @@ parser.yy.parseError = (message, {token}) ->
|
||||
# sourceMap, so we must monkey-patch Error to display CoffeeScript source
|
||||
# positions.
|
||||
|
||||
# Ideally, this would happen in a way that is scalable to multiple compile-to-
|
||||
# JS languages trying to do the same thing in the same NodeJS process. We can
|
||||
# implement it as if there were an API, and then patch in support for that
|
||||
# API. The following maybe should be in its own npm module that multiple
|
||||
# compilers can include.
|
||||
|
||||
patched = false
|
||||
patchStackTrace = ->
|
||||
return if patched
|
||||
patched = true
|
||||
mainModule = require.main
|
||||
# Map of filenames -> functions that return a sourceMap string.
|
||||
# Map of filenames -> sourceMap object.
|
||||
mainModule._sourceMaps = {}
|
||||
|
||||
# (Assigning to a property of the Module object in the normal module cache is
|
||||
@@ -216,8 +210,8 @@ patchStackTrace = ->
|
||||
|
||||
getSourceMapping = (filename, line, column) ->
|
||||
sourceMap = mainModule._sourceMaps[filename]
|
||||
answer = sourceMap.getSourcePosition [line, column] if sourceMap
|
||||
answer
|
||||
answer = sourceMap.getSourcePosition [line-1, column-1] if sourceMap
|
||||
if answer then [answer[0]+1, answer[1]+1] else null
|
||||
|
||||
frames = for frame in stack
|
||||
break if frame.getFunction() is exports.run
|
||||
|
||||
Reference in New Issue
Block a user