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
3a62b5d9
Commit
3a62b5d9
authored
Sep 26, 2017
by
yann300
Committed by
GitHub
Sep 26, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #578 from ethereum/fixbytedecoding
add new api function to source mapping decoder
parents
f05d3bc0
6866d265
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
0 deletions
+49
-0
sourceMappingDecoder.js
src/util/sourceMappingDecoder.js
+49
-0
No files found.
src/util/sourceMappingDecoder.js
View file @
3a62b5d9
...
@@ -10,6 +10,15 @@ function SourceMappingDecoder () {
...
@@ -10,6 +10,15 @@ function SourceMappingDecoder () {
}
}
/**
/**
* get a list of nodes that are at the given @arg position
*
* @param {String} astNodeType - type of node to return
* @param {Int} position - cursor position
* @return {Object} ast object given by the compiler
*/
SourceMappingDecoder
.
prototype
.
nodesAtPosition
=
nodesAtPosition
/**
* Decode the source mapping for the given @arg index
* Decode the source mapping for the given @arg index
*
*
* @param {Integer} index - source mapping index to decode
* @param {Integer} index - source mapping index to decode
...
@@ -19,6 +28,23 @@ function SourceMappingDecoder () {
...
@@ -19,6 +28,23 @@ function SourceMappingDecoder () {
SourceMappingDecoder
.
prototype
.
atIndex
=
atIndex
SourceMappingDecoder
.
prototype
.
atIndex
=
atIndex
/**
/**
* Decode the given @arg value
*
* @param {string} value - source location to decode ( should be start:length:file )
* @return {Object} returns the decompressed source mapping {start, length, file}
*/
SourceMappingDecoder
.
prototype
.
decode
=
function
(
value
)
{
if
(
value
)
{
value
=
value
.
split
(
':'
)
return
{
start
:
parseInt
(
value
[
0
]),
length
:
parseInt
(
value
[
1
]),
file
:
parseInt
(
value
[
2
])
}
}
}
/**
* Decode the source mapping for the given compressed mapping
* Decode the source mapping for the given compressed mapping
*
*
* @param {String} mapping - compressed source mapping given by solc-bin
* @param {String} mapping - compressed source mapping given by solc-bin
...
@@ -139,6 +165,29 @@ function findNodeAtSourceLocation (astNodeType, sourceLocation, ast) {
...
@@ -139,6 +165,29 @@ function findNodeAtSourceLocation (astNodeType, sourceLocation, ast) {
return
found
return
found
}
}
function
nodesAtPosition
(
astNodeType
,
position
,
ast
)
{
var
astWalker
=
new
AstWalker
()
var
callback
=
{}
var
found
=
[]
callback
[
'*'
]
=
function
(
node
)
{
var
nodeLocation
=
sourceLocationFromAstNode
(
node
)
if
(
!
nodeLocation
)
{
return
}
if
(
nodeLocation
.
start
<=
position
&&
nodeLocation
.
start
+
nodeLocation
.
length
>=
position
)
{
if
(
!
astNodeType
||
astNodeType
===
node
.
name
)
{
found
.
push
(
node
)
if
(
astNodeType
)
return
false
}
return
true
}
else
{
return
false
}
}
astWalker
.
walk
(
ast
.
AST
,
callback
)
return
found
}
function
atIndex
(
index
,
mapping
)
{
function
atIndex
(
index
,
mapping
)
{
var
ret
=
{}
var
ret
=
{}
var
map
=
mapping
.
split
(
';'
)
var
map
=
mapping
.
split
(
';'
)
...
...
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