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
2962f1d2
Commit
2962f1d2
authored
Dec 07, 2016
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cache variableDeclaration
parent
ed5c07c6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
11 deletions
+24
-11
localDecoder.js
src/solidity/localDecoder.js
+24
-11
No files found.
src/solidity/localDecoder.js
View file @
2962f1d2
...
...
@@ -16,8 +16,8 @@ class LocalDecoder {
traceAnalyserEvent
.
register
(
'onOp'
,
function
(
index
,
step
,
callStack
,
cache
)
{
self
.
push
(
index
,
step
,
callStack
,
cache
)
})
traceAnalyserEvent
.
register
(
'finishAnalysing'
,
function
(
index
,
step
)
{
})
traceAnalyserEvent
.
register
(
'finishAnalysing'
,
function
(
index
,
step
)
{
})
this
.
variableDeclarationByFile
=
{}
}
push
(
index
,
step
,
callStack
,
cache
)
{
...
...
@@ -28,22 +28,23 @@ class LocalDecoder {
if
(
error
)
{
console
.
log
(
error
)
}
else
{
var
ast
=
this
.
solidityProxy
.
ast
(
result
)
if
(
!
this
.
variableDeclarationByFile
[
result
.
file
])
{
var
ast
=
this
.
solidityProxy
.
ast
(
result
)
this
.
variableDeclarationByFile
[
result
.
file
]
=
extractVariableDeclarations
(
ast
,
this
.
astWalker
)
}
var
variableDeclarations
=
this
.
variableDeclarationByFile
[
result
.
file
]
this
.
solidityProxy
.
extractStateVariablesAt
(
index
,
(
error
,
stateVars
)
=>
{
// cached
if
(
error
)
{
console
.
log
(
error
)
}
else
{
this
.
astWalker
.
walk
(
ast
,
(
node
)
=>
{
if
(
node
.
name
===
'VariableDeclaration'
&&
node
.
src
.
indexOf
(
result
.
start
+
':'
+
result
.
length
)
===
0
)
{
this
.
locals
[
node
.
attributes
.
name
]
=
{
type
:
decodeInfo
.
parseType
(
node
.
attributes
.
type
,
stateVars
),
for
(
var
dec
of
variableDeclarations
)
{
if
(
dec
.
src
.
indexOf
(
result
.
start
+
':'
+
result
.
length
)
===
0
)
{
this
.
locals
[
dec
.
attributes
.
name
]
=
{
type
:
decodeInfo
.
parseType
(
dec
.
attributes
.
type
,
stateVars
),
stack
:
step
.
stack
}
return
false
}
else
{
return
true
}
}
)
}
}
})
}
...
...
@@ -53,7 +54,19 @@ class LocalDecoder {
clear
()
{
this
.
locals
=
{}
this
.
variableDeclarationByFile
=
{}
}
}
function
extractVariableDeclarations
(
ast
,
astWalker
)
{
var
ret
=
[]
astWalker
.
walk
(
ast
,
(
node
)
=>
{
if
(
node
.
name
===
'VariableDeclaration'
)
{
ret
.
push
(
node
)
}
return
true
})
return
ret
}
module
.
exports
=
LocalDecoder
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