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
1cadc1c0
Commit
1cadc1c0
authored
Dec 08, 2016
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add solidity locals panel
parent
12f18f86
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
64 deletions
+52
-64
localDecoder.js
src/solidity/localDecoder.js
+8
-64
SolidityLocals.js
src/ui/SolidityLocals.js
+44
-0
No files found.
src/solidity/localDecoder.js
View file @
1cadc1c0
'use strict'
var
SourceLocationTracker
=
require
(
'../code/sourceLocationTracker'
)
var
AstWalker
=
require
(
'../util/astWalker'
)
var
decodeInfo
=
require
(
'../solidity/decodeInfo'
)
class
LocalDecoder
{
constructor
(
codeManager
,
traceAnalyserEvent
,
solidityProxy
)
{
this
.
astWalker
=
new
AstWalker
()
this
.
sourceLocationTracker
=
new
SourceLocationTracker
(
codeManager
)
this
.
solidityProxy
=
solidityProxy
this
.
locals
=
{}
var
self
=
this
traceAnalyserEvent
.
register
(
'startAnalysing'
,
function
(
step
)
{
self
.
clear
()
})
traceAnalyserEvent
.
register
(
'onOp'
,
function
(
index
,
step
,
callStack
,
cache
)
{
self
.
push
(
index
,
step
,
callStack
,
cache
)
})
traceAnalyserEvent
.
register
(
'finishAnalysing'
,
function
(
index
,
step
)
{})
this
.
variableDeclarationByFile
=
{}
}
push
(
index
,
step
,
callStack
,
cache
)
{
if
(
!
this
.
solidityProxy
.
loaded
())
return
if
(
step
.
op
.
indexOf
(
'PUSH'
)
===
0
)
{
var
address
=
callStack
[
callStack
.
length
-
1
]
this
.
sourceLocationTracker
.
getSourceLocationFromVMTraceIndex
(
address
,
index
,
this
.
solidityProxy
.
contracts
,
(
error
,
result
)
=>
{
if
(
error
)
{
console
.
log
(
error
)
}
else
{
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
{
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
}
}
}
}
})
}
})
solidityLocals
(
vmtraceIndex
,
internalTreeCall
,
stack
,
memory
)
{
var
scope
=
this
.
internalTreeCall
.
findScope
(
vmtraceIndex
)
var
locals
=
{}
for
(
var
local
of
scope
.
locals
)
{
if
(
local
.
type
.
decodeLocals
)
{
locals
[
local
.
name
]
=
local
.
type
.
decodeLocals
(
local
.
stackHeight
,
stack
,
memory
)
}
}
return
locals
}
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
src/ui/SolidityLocals.js
0 → 100644
View file @
1cadc1c0
'use strict'
var
DropdownPanel
=
require
(
'./DropdownPanel'
)
var
localDecoder
=
require
(
'../solidity/localDecoder'
)
var
yo
=
require
(
'yo-yo'
)
class
SolidityLocals
{
constructor
(
_parent
,
_traceManager
,
internalTreeCall
)
{
this
.
parent
=
_parent
this
.
internalTreeCall
=
internalTreeCall
this
.
traceManager
=
_traceManager
this
.
basicPanel
=
new
DropdownPanel
(
'Solidity Locals'
)
this
.
init
()
}
render
()
{
return
yo
`<div id='soliditylocals' >
${
this
.
basicPanel
.
render
()}
</div>`
}
init
()
{
this
.
parent
.
event
.
register
(
'indexChanged'
,
this
,
(
index
)
=>
{
if
(
index
<
0
)
{
this
.
basicPanel
.
update
({
info
:
'invalid step index'
})
return
}
if
(
this
.
parent
.
currentStepIndex
!==
index
)
return
this
.
traceManager
.
waterfall
([
this
.
traceManager
.
getStackAt
,
this
.
traceManager
.
getMemoryAt
],
index
,
function
(
error
,
result
)
{
if
(
!
error
)
{
var
stack
=
result
[
0
].
value
var
memory
=
result
[
1
].
value
var
locals
=
localDecoder
.
soliditylocals
(
index
,
this
.
internalTreeCall
,
stack
,
memory
)
this
.
basicPanel
.
update
(
locals
)
}
})
})
}
}
module
.
exports
=
SolidityLocals
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