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
080dc332
Commit
080dc332
authored
Aug 11, 2016
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code manager refacto
parent
cc7f3cc1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
48 deletions
+35
-48
codeManager.js
src/code/codeManager.js
+23
-35
codeResolver.js
src/code/codeResolver.js
+1
-1
ASMCode.js
src/ui/ASMCode.js
+9
-9
codeManager.js
test/codeManager.js
+2
-3
No files found.
src/code/codeManager.js
View file @
080dc332
...
@@ -17,7 +17,6 @@ function CodeManager (_traceManager) {
...
@@ -17,7 +17,6 @@ function CodeManager (_traceManager) {
util
.
extend
(
this
,
new
EventManager
())
util
.
extend
(
this
,
new
EventManager
())
this
.
isLoading
=
false
this
.
isLoading
=
false
this
.
traceManager
=
_traceManager
this
.
traceManager
=
_traceManager
this
.
currentAddress
=
''
this
.
codeResolver
=
codeResolver
this
.
codeResolver
=
codeResolver
}
}
...
@@ -26,65 +25,54 @@ CodeManager.prototype.resolveStep = function (stepIndex, tx) {
...
@@ -26,65 +25,54 @@ CodeManager.prototype.resolveStep = function (stepIndex, tx) {
this
.
trigger
(
'resolvingStep'
)
this
.
trigger
(
'resolvingStep'
)
var
self
=
this
var
self
=
this
if
(
stepIndex
===
0
)
{
if
(
stepIndex
===
0
)
{
self
.
ensureCodeLoaded
(
tx
.
to
,
stepIndex
,
tx
)
self
.
getCode
(
tx
.
to
,
stepIndex
,
tx
)
}
else
{
}
else
{
this
.
traceManager
.
getCurrentCalledAddressAt
(
stepIndex
,
function
(
error
,
address
)
{
this
.
traceManager
.
getCurrentCalledAddressAt
(
stepIndex
,
function
(
error
,
address
)
{
if
(
error
)
{
if
(
error
)
{
console
.
log
(
error
)
console
.
log
(
error
)
}
else
{
}
else
{
self
.
ensureCodeLoaded
(
address
,
stepIndex
,
tx
)
self
.
getCode
(
address
,
stepIndex
,
tx
)
}
}
})
})
}
}
}
}
CodeManager
.
prototype
.
ensureCodeLoaded
=
function
(
address
,
currentStep
,
tx
)
{
CodeManager
.
prototype
.
getCode
=
function
(
address
,
currentStep
,
tx
)
{
var
self
=
this
var
self
=
this
if
(
address
!==
this
.
currentAddress
)
{
if
(
traceHelper
.
isContractCreation
(
address
))
{
if
(
traceHelper
.
isContractCreation
(
address
))
{
var
codes
=
codeResolver
.
getExecutingCodeFromCache
(
address
)
if
(
!
codes
)
{
this
.
traceManager
.
getContractCreationCode
(
address
,
function
(
error
,
hexCode
)
{
this
.
traceManager
.
getContractCreationCode
(
address
,
function
(
error
,
hexCode
)
{
// contract creation
// contract creation
if
(
error
)
{
if
(
error
)
{
console
.
log
(
error
)
console
.
log
(
error
)
}
else
{
}
else
{
var
codes
=
codeResolver
.
cacheExecutingCode
(
address
,
hexCode
)
codes
=
codeResolver
.
cacheExecutingCode
(
address
,
hexCode
)
self
.
trigger
(
'loadingCode'
,
[
address
])
self
.
retrieveIndexAndTrigger
(
address
,
currentStep
,
codes
.
code
)
self
.
getInstructionIndex
(
address
,
currentStep
,
function
(
error
,
result
)
{
if
(
!
error
)
{
self
.
trigger
(
'codeChanged'
,
[
codes
.
code
,
address
,
result
])
self
.
trigger
(
'indexChanged'
,
[
result
])
self
.
currentAddress
=
address
}
else
{
console
.
log
(
error
)
}
})
}
}
})
})
}
else
{
}
else
{
codeResolver
.
resolveCode
(
address
,
currentStep
,
tx
,
function
(
address
,
code
)
{
self
.
retrieveIndexAndTrigger
(
address
,
currentStep
,
codes
.
code
)
// resoling code from stack
self
.
trigger
(
'loadingCode'
,
[
address
])
self
.
getInstructionIndex
(
address
,
currentStep
,
function
(
error
,
result
)
{
if
(
!
error
)
{
self
.
trigger
(
'codeChanged'
,
[
code
,
address
,
result
])
self
.
trigger
(
'indexChanged'
,
[
result
])
self
.
currentAddress
=
address
}
else
{
console
.
log
(
error
)
}
})
})
}
}
}
else
{
}
else
{
// only set selected item
codeResolver
.
resolveCode
(
address
,
function
(
address
,
code
)
{
this
.
getInstructionIndex
(
this
.
currentAddress
,
currentStep
,
function
(
error
,
result
)
{
// resoling code from stack
if
(
!
error
)
{
self
.
retrieveIndexAndTrigger
(
address
,
currentStep
,
code
)
self
.
trigger
(
'indexChanged'
,
[
result
])
}
})
})
}
}
}
}
CodeManager
.
prototype
.
retrieveIndexAndTrigger
=
function
(
address
,
step
,
code
)
{
var
self
=
this
this
.
getInstructionIndex
(
address
,
step
,
function
(
error
,
result
)
{
if
(
!
error
)
{
self
.
trigger
(
'changed'
,
[
code
,
address
,
result
])
}
else
{
console
.
log
(
error
)
}
})
}
CodeManager
.
prototype
.
getInstructionIndex
=
function
(
address
,
step
,
callback
)
{
CodeManager
.
prototype
.
getInstructionIndex
=
function
(
address
,
step
,
callback
)
{
this
.
traceManager
.
getCurrentPC
(
step
,
function
(
error
,
instIndex
)
{
this
.
traceManager
.
getCurrentPC
(
step
,
function
(
error
,
instIndex
)
{
if
(
error
)
{
if
(
error
)
{
...
...
src/code/codeResolver.js
View file @
080dc332
...
@@ -6,7 +6,7 @@ module.exports = {
...
@@ -6,7 +6,7 @@ module.exports = {
codes
:
{},
// assembly items instructions list by contract addesses
codes
:
{},
// assembly items instructions list by contract addesses
instructionsIndexByBytesOffset
:
{},
// mapping between bytes offset and instructions index.
instructionsIndexByBytesOffset
:
{},
// mapping between bytes offset and instructions index.
resolveCode
:
function
(
address
,
vmTraceIndex
,
transaction
,
callBack
)
{
resolveCode
:
function
(
address
,
callBack
)
{
var
cache
=
this
.
getExecutingCodeFromCache
(
address
)
var
cache
=
this
.
getExecutingCodeFromCache
(
address
)
if
(
cache
)
{
if
(
cache
)
{
callBack
(
address
,
cache
.
code
)
callBack
(
address
,
cache
.
code
)
...
...
src/ui/ASMCode.js
View file @
080dc332
...
@@ -26,21 +26,21 @@ ASMCode.prototype.render = function () {
...
@@ -26,21 +26,21 @@ ASMCode.prototype.render = function () {
}
}
ASMCode
.
prototype
.
init
=
function
()
{
ASMCode
.
prototype
.
init
=
function
()
{
this
.
codeManager
.
register
(
'indexChanged'
,
this
,
this
.
indexChanged
)
this
.
codeManager
.
register
(
'changed'
,
this
,
this
.
changed
)
this
.
codeManager
.
register
(
'codeChanged'
,
this
,
this
.
codeChanged
)
this
.
codeManager
.
register
(
'loadingCode'
,
this
,
function
(
address
)
{})
}
}
ASMCode
.
prototype
.
indexChanged
=
function
(
index
)
{
ASMCode
.
prototype
.
indexChanged
=
function
(
index
)
{
document
.
getElementById
(
'asmitems'
).
value
=
index
document
.
getElementById
(
'asmitems'
).
value
=
index
}
}
ASMCode
.
prototype
.
codeChanged
=
function
(
code
,
address
,
index
)
{
ASMCode
.
prototype
.
changed
=
function
(
code
,
address
,
index
)
{
this
.
code
=
code
if
(
this
.
address
!==
address
)
{
this
.
address
=
address
this
.
code
=
code
this
.
renderAssemblyItems
()
this
.
address
=
address
yo
.
update
(
this
.
view
,
this
.
render
())
this
.
renderAssemblyItems
()
document
.
getElementById
(
'asmitems'
).
value
=
index
yo
.
update
(
this
.
view
,
this
.
render
())
}
this
.
indexChanged
(
index
)
}
}
ASMCode
.
prototype
.
renderAssemblyItems
=
function
()
{
ASMCode
.
prototype
.
renderAssemblyItems
=
function
()
{
...
...
test/codeManager.js
View file @
080dc332
...
@@ -40,7 +40,7 @@ function continueTesting (t, codeManager) {
...
@@ -40,7 +40,7 @@ function continueTesting (t, codeManager) {
t
.
test
(
'CodeManager.resolveStep'
,
function
(
st
)
{
t
.
test
(
'CodeManager.resolveStep'
,
function
(
st
)
{
st
.
plan
(
6
)
st
.
plan
(
6
)
codeManager
.
register
(
'
indexChanged'
,
this
,
function
(
index
)
{
codeManager
.
register
(
'
changed'
,
this
,
function
(
code
,
address
,
index
)
{
if
(
index
===
undefined
||
index
===
null
)
{
if
(
index
===
undefined
||
index
===
null
)
{
st
.
fail
(
index
)
st
.
fail
(
index
)
}
else
{
}
else
{
...
@@ -48,8 +48,7 @@ function continueTesting (t, codeManager) {
...
@@ -48,8 +48,7 @@ function continueTesting (t, codeManager) {
}
}
})
})
codeManager
.
register
(
'codeChanged'
,
this
,
function
(
code
,
address
,
index
)
{
codeManager
.
register
(
'changed'
,
this
,
function
(
code
,
address
,
index
)
{
console
.
log
(
address
+
' '
+
index
+
' '
+
code
)
if
(
!
code
)
{
if
(
!
code
)
{
st
.
fail
(
'no codes'
)
st
.
fail
(
'no codes'
)
}
else
{
}
else
{
...
...
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