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
31ba1e8f
Commit
31ba1e8f
authored
Jul 24, 2020
by
Iuri Matias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor GetInstructionIndex
parent
245c48d2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
32 deletions
+34
-32
codeManager.js
libs/remix-lib/src/code/codeManager.js
+18
-6
sourceLocationTracker.js
libs/remix-lib/src/sourceLocationTracker.js
+4
-12
codeManager.js
libs/remix-lib/test/codeManager.js
+12
-14
No files found.
libs/remix-lib/src/code/codeManager.js
View file @
31ba1e8f
...
@@ -104,6 +104,17 @@ CodeManager.prototype.getInstructionIndex = function (address, step, callback) {
...
@@ -104,6 +104,17 @@ CodeManager.prototype.getInstructionIndex = function (address, step, callback) {
}
}
}
}
CodeManager
.
prototype
.
newGetInstructionIndex
=
function
(
address
,
step
)
{
try
{
const
pc
=
this
.
traceManager
.
getCurrentPC
(
step
)
const
itemIndex
=
this
.
codeResolver
.
getInstructionIndex
(
address
,
pc
)
return
itemIndex
}
catch
(
error
)
{
console
.
log
(
error
)
throw
new
Error
(
'Cannot retrieve current PC for '
+
step
)
}
}
/**
/**
* Retrieve the called function for the given @arg pc and @arg address
* Retrieve the called function for the given @arg pc and @arg address
*
*
...
@@ -127,12 +138,13 @@ function retrieveCodeAndTrigger (codeMananger, address, stepIndex, tx) {
...
@@ -127,12 +138,13 @@ function retrieveCodeAndTrigger (codeMananger, address, stepIndex, tx) {
}
}
function
retrieveIndexAndTrigger
(
codeMananger
,
address
,
step
,
code
)
{
function
retrieveIndexAndTrigger
(
codeMananger
,
address
,
step
,
code
)
{
codeMananger
.
getInstructionIndex
(
address
,
step
,
(
error
,
result
)
=>
{
let
result
if
(
error
)
{
try
{
return
console
.
log
(
error
)
result
=
codeMananger
.
newGetInstructionIndex
(
address
,
step
)
}
}
catch
(
error
)
{
codeMananger
.
event
.
trigger
(
'changed'
,
[
code
,
address
,
result
])
return
console
.
log
(
error
)
})
}
codeMananger
.
event
.
trigger
(
'changed'
,
[
code
,
address
,
result
])
}
}
module
.
exports
=
CodeManager
module
.
exports
=
CodeManager
libs/remix-lib/src/sourceLocationTracker.js
View file @
31ba1e8f
...
@@ -35,18 +35,10 @@ SourceLocationTracker.prototype.getSourceLocationFromInstructionIndex = async fu
...
@@ -35,18 +35,10 @@ SourceLocationTracker.prototype.getSourceLocationFromInstructionIndex = async fu
* @param {Object} contractDetails - AST of compiled contracts
* @param {Object} contractDetails - AST of compiled contracts
* @param {Function} cb - callback function
* @param {Function} cb - callback function
*/
*/
SourceLocationTracker
.
prototype
.
getSourceLocationFromVMTraceIndex
=
function
(
address
,
vmtraceStepIndex
,
contracts
)
{
SourceLocationTracker
.
prototype
.
getSourceLocationFromVMTraceIndex
=
async
function
(
address
,
vmtraceStepIndex
,
contracts
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
sourceMap
=
await
extractSourceMap
(
this
,
this
.
codeManager
,
address
,
contracts
)
extractSourceMap
(
this
,
this
.
codeManager
,
address
,
contracts
).
then
((
sourceMap
)
=>
{
const
index
=
this
.
codeManager
.
newGetInstructionIndex
(
address
,
vmtraceStepIndex
)
this
.
codeManager
.
getInstructionIndex
(
address
,
vmtraceStepIndex
,
(
error
,
index
)
=>
{
return
this
.
sourceMappingDecoder
.
atIndex
(
index
,
sourceMap
)
if
(
error
)
{
reject
(
error
)
}
else
{
resolve
(
this
.
sourceMappingDecoder
.
atIndex
(
index
,
sourceMap
))
}
})
}).
catch
(
reject
)
})
}
}
SourceLocationTracker
.
prototype
.
clearCache
=
function
()
{
SourceLocationTracker
.
prototype
.
clearCache
=
function
()
{
...
...
libs/remix-lib/test/codeManager.js
View file @
31ba1e8f
...
@@ -68,22 +68,20 @@ function continueTesting (t, codeManager) {
...
@@ -68,22 +68,20 @@ function continueTesting (t, codeManager) {
t
.
test
(
'CodeManager.getInstructionIndex'
,
function
(
st
)
{
t
.
test
(
'CodeManager.getInstructionIndex'
,
function
(
st
)
{
st
.
plan
(
2
)
st
.
plan
(
2
)
codeManager
.
getInstructionIndex
(
'0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5'
,
16
,
function
(
error
,
result
)
{
try
{
const
result
=
codeManager
.
newGetInstructionIndex
(
'0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5'
,
16
)
console
.
log
(
result
)
console
.
log
(
result
)
if
(
error
)
{
st
.
ok
(
result
===
25
)
st
.
fail
(
error
)
}
catch
(
error
)
{
}
else
{
st
.
fail
(
error
)
st
.
ok
(
result
===
25
)
}
}
})
codeManager
.
getInstructionIndex
(
'(Contract Creation - Step 63)'
,
70
,
function
(
error
,
result
)
{
try
{
const
result
=
codeManager
.
newGetInstructionIndex
(
'(Contract Creation - Step 63)'
,
70
)
console
.
log
(
result
)
console
.
log
(
result
)
if
(
error
)
{
st
.
ok
(
result
===
6
)
st
.
fail
(
error
)
}
catch
(
error
)
{
}
else
{
st
.
fail
(
error
)
st
.
ok
(
result
===
6
)
}
}
})
})
})
}
}
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