Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
030ac5e8
Commit
030ac5e8
authored
Aug 19, 2016
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
source mapping decoder changes
parent
40f6c637
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
58 deletions
+31
-58
util.js
src/helpers/util.js
+17
-20
index.js
src/index.js
+0
-3
traceManager.js
src/trace/traceManager.js
+5
-10
sourceMappingDecoder.js
src/util/sourceMappingDecoder.js
+9
-25
No files found.
src/helpers/util.js
View file @
030ac5e8
...
@@ -44,34 +44,31 @@ module.exports = {
...
@@ -44,34 +44,31 @@ module.exports = {
/*
/*
Binary Search:
Binary Search:
Assumes that @arg array is sorted increasingly
Assumes that @arg array is sorted increasingly
return
s the smallest i such that target >= changes[i]
return
smallest i such that changes[i] <= target does not hold,
returns arary.length - 1 (if all elements in array are smaller than target)
or changes.length if all elements are < target.
returns 0 (if target is smaller than the first element of array || if array is empty)
It returns the index where target could be inserted to maintain the order of the array
*/
*/
findLowerBound
:
function
(
target
,
array
)
{
findLowerBound
:
function
(
target
,
array
)
{
if
(
array
.
length
===
0
)
{
return
findLowerBoundInternal
(
target
,
array
,
0
,
array
.
length
)
return
0
},
}
return
findLowerBoundInternal
(
target
,
array
,
0
,
array
.
length
-
1
)
findLowerBoundValue
:
function
(
target
,
array
)
{
var
index
=
this
.
findLowerBound
(
target
,
array
)
return
array
[
index
]
}
}
}
}
function
findLowerBoundInternal
(
target
,
array
,
lowerbound
,
higherbound
)
{
function
findLowerBoundInternal
(
target
,
array
,
lowerbound
,
length
)
{
if
(
array
[
higherbound
]
<
target
)
{
while
(
length
>
1
)
{
return
higherbound
var
half
=
length
>>
1
}
else
if
(
array
[
lowerbound
]
>
target
)
{
var
middle
=
lowerbound
+
half
return
lowerbound
if
(
array
[
middle
]
<
target
)
{
}
length
=
length
-
(
middle
-
lowerbound
)
var
middle
while
(
lowerbound
+
1
!==
higherbound
)
{
middle
=
Math
.
floor
((
higherbound
+
lowerbound
)
/
2
)
if
(
array
[
middle
]
>
target
)
{
higherbound
=
middle
}
else
if
(
array
[
middle
]
<
target
)
{
lowerbound
=
middle
lowerbound
=
middle
higherbound
=
array
.
length
-
1
}
else
if
(
array
[
middle
]
===
target
)
{
}
else
if
(
array
[
middle
]
===
target
)
{
return
middle
return
middle
}
else
{
length
=
half
}
}
}
}
return
lowerbound
return
lowerbound
...
...
src/index.js
View file @
030ac5e8
...
@@ -9,9 +9,6 @@ var SourceMappingDecoder = require('./util/sourceMappingDecoder')
...
@@ -9,9 +9,6 @@ var SourceMappingDecoder = require('./util/sourceMappingDecoder')
if
(
typeof
(
module
)
!==
'undefined'
&&
typeof
(
module
.
exports
)
!==
'undefined'
)
{
if
(
typeof
(
module
)
!==
'undefined'
&&
typeof
(
module
.
exports
)
!==
'undefined'
)
{
module
.
exports
=
modules
()
module
.
exports
=
modules
()
}
}
if
(
typeof
(
window
)
!==
'undefined'
)
{
window
.
remix
=
modules
()
}
function
modules
()
{
function
modules
()
{
return
{
return
{
...
...
src/trace/traceManager.js
View file @
030ac5e8
...
@@ -80,8 +80,7 @@ TraceManager.prototype.getStorageAt = function (stepIndex, tx, callback, address
...
@@ -80,8 +80,7 @@ TraceManager.prototype.getStorageAt = function (stepIndex, tx, callback, address
return
callback
(
check
,
null
)
return
callback
(
check
,
null
)
}
}
if
(
!
address
)
{
if
(
!
address
)
{
var
stoChangeIndex
=
util
.
findLowerBound
(
stepIndex
,
this
.
traceCache
.
storageChanges
)
var
stoChange
=
util
.
findLowerBoundValue
(
stepIndex
,
this
.
traceCache
.
storageChanges
)
var
stoChange
=
this
.
traceCache
.
storageChanges
[
stoChangeIndex
]
if
(
stoChange
===
undefined
)
return
callback
(
'no storage found'
,
null
)
if
(
stoChange
===
undefined
)
return
callback
(
'no storage found'
,
null
)
address
=
this
.
traceCache
.
sstore
[
stoChange
].
address
address
=
this
.
traceCache
.
sstore
[
stoChange
].
address
}
}
...
@@ -124,8 +123,7 @@ TraceManager.prototype.getCallDataAt = function (stepIndex, callback) {
...
@@ -124,8 +123,7 @@ TraceManager.prototype.getCallDataAt = function (stepIndex, callback) {
if
(
check
)
{
if
(
check
)
{
return
callback
(
check
,
null
)
return
callback
(
check
,
null
)
}
}
var
callDataChangeIndex
=
util
.
findLowerBound
(
stepIndex
,
this
.
traceCache
.
callDataChanges
)
var
callDataChange
=
util
.
findLowerBoundValue
(
stepIndex
,
this
.
traceCache
.
callDataChanges
)
var
callDataChange
=
this
.
traceCache
.
callDataChanges
[
callDataChangeIndex
]
if
(
callDataChange
===
undefined
)
return
callback
(
'no calldata found'
,
null
)
if
(
callDataChange
===
undefined
)
return
callback
(
'no calldata found'
,
null
)
callback
(
null
,
[
this
.
traceCache
.
callsData
[
callDataChange
]])
callback
(
null
,
[
this
.
traceCache
.
callsData
[
callDataChange
]])
}
}
...
@@ -135,8 +133,7 @@ TraceManager.prototype.getCallStackAt = function (stepIndex, callback) {
...
@@ -135,8 +133,7 @@ TraceManager.prototype.getCallStackAt = function (stepIndex, callback) {
if
(
check
)
{
if
(
check
)
{
return
callback
(
check
,
null
)
return
callback
(
check
,
null
)
}
}
var
callStackChangeIndex
=
util
.
findLowerBound
(
stepIndex
,
this
.
traceCache
.
callChanges
)
var
callStackChange
=
util
.
findLowerBoundValue
(
stepIndex
,
this
.
traceCache
.
callChanges
)
var
callStackChange
=
this
.
traceCache
.
callChanges
[
callStackChangeIndex
]
if
(
callStackChange
===
undefined
)
return
callback
(
'no callstack found'
,
null
)
if
(
callStackChange
===
undefined
)
return
callback
(
'no callstack found'
,
null
)
callback
(
null
,
this
.
traceCache
.
callStack
[
callStackChange
].
callStack
)
callback
(
null
,
this
.
traceCache
.
callStack
[
callStackChange
].
callStack
)
}
}
...
@@ -161,8 +158,7 @@ TraceManager.prototype.getLastCallChangeSince = function (stepIndex, callback) {
...
@@ -161,8 +158,7 @@ TraceManager.prototype.getLastCallChangeSince = function (stepIndex, callback) {
if
(
check
)
{
if
(
check
)
{
return
callback
(
check
,
null
)
return
callback
(
check
,
null
)
}
}
var
callChangeIndex
=
util
.
findLowerBound
(
stepIndex
,
this
.
traceCache
.
callChanges
)
var
callChange
=
util
.
findLowerBoundValue
(
stepIndex
,
this
.
traceCache
.
callChanges
)
var
callChange
=
this
.
traceCache
.
callChanges
[
callChangeIndex
]
if
(
callChange
===
undefined
)
{
if
(
callChange
===
undefined
)
{
callback
(
null
,
0
)
callback
(
null
,
0
)
}
else
{
}
else
{
...
@@ -208,8 +204,7 @@ TraceManager.prototype.getMemoryAt = function (stepIndex, callback) {
...
@@ -208,8 +204,7 @@ TraceManager.prototype.getMemoryAt = function (stepIndex, callback) {
if
(
check
)
{
if
(
check
)
{
return
callback
(
check
,
null
)
return
callback
(
check
,
null
)
}
}
var
lastChangesIndex
=
util
.
findLowerBound
(
stepIndex
,
this
.
traceCache
.
memoryChanges
)
var
lastChanges
=
util
.
findLowerBoundValue
(
stepIndex
,
this
.
traceCache
.
memoryChanges
)
var
lastChanges
=
this
.
traceCache
.
memoryChanges
[
lastChangesIndex
]
if
(
lastChanges
===
undefined
)
return
callback
(
'no memory found'
,
null
)
if
(
lastChanges
===
undefined
)
return
callback
(
'no memory found'
,
null
)
callback
(
null
,
this
.
trace
[
lastChanges
].
memory
)
callback
(
null
,
this
.
trace
[
lastChanges
].
memory
)
}
}
...
...
src/util/sourceMappingDecoder.js
View file @
030ac5e8
...
@@ -77,15 +77,6 @@ SourceMappingDecoder.prototype.getLinebreakPositions = function (source) {
...
@@ -77,15 +77,6 @@ SourceMappingDecoder.prototype.getLinebreakPositions = function (source) {
ret
.
push
(
pos
)
ret
.
push
(
pos
)
}
}
return
ret
return
ret
/*
var lines = source.split('\n')
var currentPos = 0
var ret = []
for (var k in lines) {
ret.push(currentPos + lines[k].length)
currentPos += lines[k].length + 1
}
return ret*/
}
}
/**
/**
...
@@ -93,7 +84,7 @@ SourceMappingDecoder.prototype.getLinebreakPositions = function (source) {
...
@@ -93,7 +84,7 @@ SourceMappingDecoder.prototype.getLinebreakPositions = function (source) {
*
*
* @param {Object} sourceLocation - object containing attributes {source} and {length}
* @param {Object} sourceLocation - object containing attributes {source} and {length}
* @param {Array} lineBreakPositions - array returned by the function 'getLinebreakPositions'
* @param {Array} lineBreakPositions - array returned by the function 'getLinebreakPositions'
* @@return {Object} returns an object {start: {line, column}, end: {line, column}}
* @@return {Object} returns an object {start: {line, column}, end: {line, column}}
(line count start at 0)
*/
*/
SourceMappingDecoder
.
prototype
.
convertOffsetToLineColumn
=
function
(
sourceLocation
,
lineBreakPositions
)
{
SourceMappingDecoder
.
prototype
.
convertOffsetToLineColumn
=
function
(
sourceLocation
,
lineBreakPositions
)
{
if
(
sourceLocation
.
start
>=
0
&&
sourceLocation
.
length
>=
0
)
{
if
(
sourceLocation
.
start
>=
0
&&
sourceLocation
.
length
>=
0
)
{
...
@@ -109,22 +100,15 @@ SourceMappingDecoder.prototype.convertOffsetToLineColumn = function (sourceLocat
...
@@ -109,22 +100,15 @@ SourceMappingDecoder.prototype.convertOffsetToLineColumn = function (sourceLocat
}
}
}
}
function
convertFromCharPosition
(
pos
,
lineColumnLayout
)
{
function
convertFromCharPosition
(
pos
,
lineBreakPositions
)
{
var
lowerBound
=
util
.
findLowerBound
(
pos
,
lineColumnLayout
)
var
line
=
util
.
findLowerBound
(
pos
,
lineBreakPositions
)
var
line
if
(
lowerBound
===
0
)
{
if
(
lineBreakPositions
[
line
]
<
pos
)
{
line
=
0
line
=
line
+
1
}
else
if
(
lowerBound
<
pos
)
{
line
=
lowerBound
+
1
}
else
{
line
=
lowerBound
}
var
column
if
(
lowerBound
===
0
)
{
column
=
pos
}
else
{
column
=
pos
-
1
-
lineColumnLayout
[
line
-
1
]
}
}
var
column
=
lineBreakPositions
[
line
-
1
]
?
(
pos
-
lineBreakPositions
[
line
-
1
]
-
1
)
:
pos
return
{
return
{
line
:
line
,
line
:
line
,
column
:
column
column
:
column
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment