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
11dd6c80
Commit
11dd6c80
authored
Sep 02, 2020
by
aniket-engg
Committed by
Aniket
Sep 09, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
legacyAST removal
parent
84d4f276
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
44 additions
and
44 deletions
+44
-44
VmDebugger.js
.../remix-ide/src/app/tabs/debugger/debuggerUI/VmDebugger.js
+1
-1
astHelper.js
libs/remix-debug/src/solidity-decoder/astHelper.js
+7
-7
decodeInfo.js
libs/remix-debug/src/solidity-decoder/decodeInfo.js
+10
-10
internalCallTree.js
libs/remix-debug/src/solidity-decoder/internalCallTree.js
+16
-16
solidityProxy.js
libs/remix-debug/src/solidity-decoder/solidityProxy.js
+1
-1
util.js
libs/remix-debug/src/solidity-decoder/types/util.js
+3
-3
astWalker.js
libs/remix-debug/src/source/astWalker.js
+6
-6
No files found.
apps/remix-ide/src/app/tabs/debugger/debuggerUI/VmDebugger.js
View file @
11dd6c80
...
...
@@ -41,7 +41,7 @@ function VmDebugger (vmDebuggerLogic) {
if
(
stack
===
null
)
return
let
functions
=
[]
for
(
let
func
of
stack
)
{
functions
.
push
(
func
.
functionDefinition
.
attributes
.
name
+
'('
+
func
.
inputs
.
join
(
', '
)
+
')'
)
functions
.
push
(
func
.
functionDefinition
.
name
+
'('
+
func
.
inputs
.
join
(
', '
)
+
')'
)
}
this
.
functionPanel
.
update
(
functions
)
})
...
...
libs/remix-debug/src/solidity-decoder/astHelper.js
View file @
11dd6c80
...
...
@@ -15,10 +15,10 @@ function extractContractDefinitions (sourcesList) {
}
const
walker
=
new
AstWalker
()
for
(
let
k
in
sourcesList
)
{
walker
.
walk
(
sourcesList
[
k
].
legacyAST
,
{
'ContractDefinition'
:
(
node
)
=>
{
walker
.
walk
(
sourcesList
[
k
].
ast
,
{
'ContractDefinition'
:
(
node
)
=>
{
ret
.
contractsById
[
node
.
id
]
=
node
ret
.
sourcesByContract
[
node
.
id
]
=
k
ret
.
contractsByName
[
k
+
':'
+
node
.
attributes
.
name
]
=
node
ret
.
contractsByName
[
k
+
':'
+
node
.
name
]
=
node
return
false
}})
}
...
...
@@ -33,7 +33,7 @@ function extractContractDefinitions (sourcesList) {
* @return {Array} - array of base contracts in derived to base order as AST nodes.
*/
function
getLinearizedBaseContracts
(
id
,
contractsById
)
{
return
contractsById
[
id
].
attributes
.
linearizedBaseContracts
.
map
(
function
(
id
)
{
return
contractsById
[
id
]
})
return
contractsById
[
id
].
linearizedBaseContracts
.
map
(
function
(
id
)
{
return
contractsById
[
id
]
})
}
/**
...
...
@@ -59,10 +59,10 @@ function extractStateDefinitions (contractName, sourcesList, contracts) {
baseContracts
.
reverse
()
for
(
let
k
in
baseContracts
)
{
const
ctr
=
baseContracts
[
k
]
for
(
let
i
in
ctr
.
children
)
{
const
item
=
ctr
.
children
[
i
]
for
(
let
i
in
ctr
.
nodes
)
{
const
item
=
ctr
.
nodes
[
i
]
stateItems
.
push
(
item
)
if
(
item
.
n
am
e
===
'VariableDeclaration'
)
{
if
(
item
.
n
odeTyp
e
===
'VariableDeclaration'
)
{
stateVar
.
push
(
item
)
}
}
...
...
@@ -83,7 +83,7 @@ function extractStatesDefinitions (sourcesList, contracts) {
}
const
ret
=
{}
for
(
let
contract
in
contracts
.
contractsById
)
{
const
name
=
contracts
.
contractsById
[
contract
].
attributes
.
name
const
name
=
contracts
.
contractsById
[
contract
].
name
const
source
=
contracts
.
sourcesByContract
[
contract
]
const
fullName
=
source
+
':'
+
name
const
state
=
extractStateDefinitions
(
fullName
,
sourcesList
,
contracts
)
...
...
libs/remix-debug/src/solidity-decoder/decodeInfo.js
View file @
11dd6c80
...
...
@@ -216,7 +216,7 @@ function getEnum (type, stateDefinitions, contractName) {
const
state
=
stateDefinitions
[
contractName
]
if
(
state
)
{
for
(
let
dec
of
state
.
stateDefinitions
)
{
if
(
dec
.
attributes
&&
dec
.
attributes
.
name
&&
type
===
contractName
+
'.'
+
dec
.
attributes
.
name
)
{
if
(
dec
&&
dec
.
name
&&
type
===
contractName
+
'.'
+
dec
.
name
)
{
return
dec
}
}
...
...
@@ -243,7 +243,7 @@ function getStructMembers (type, stateDefinitions, contractName, location) {
const
state
=
stateDefinitions
[
contractName
]
if
(
state
)
{
for
(
let
dec
of
state
.
stateDefinitions
)
{
if
(
dec
.
n
ame
===
'StructDefinition'
&&
type
===
contractName
+
'.'
+
dec
.
attributes
.
name
)
{
if
(
dec
.
n
odeType
===
'StructDefinition'
&&
type
===
contractName
+
'.'
+
dec
.
name
)
{
const
offsets
=
computeOffsets
(
dec
.
children
,
stateDefinitions
,
contractName
,
location
)
if
(
!
offsets
)
{
return
null
...
...
@@ -332,25 +332,25 @@ function computeOffsets (types, stateDefinitions, contractName, location) {
}
for
(
var
i
in
types
)
{
var
variable
=
types
[
i
]
var
type
=
parseType
(
variable
.
attributes
.
type
,
stateDefinitions
,
contractName
,
location
)
var
type
=
parseType
(
variable
.
typeDescriptions
.
typeString
,
stateDefinitions
,
contractName
,
location
)
if
(
!
type
)
{
console
.
log
(
'unable to retrieve decode info of '
+
variable
.
attributes
.
type
)
console
.
log
(
'unable to retrieve decode info of '
+
variable
.
typeDescriptions
.
typeString
)
return
null
}
if
(
!
variable
.
attributes
.
constant
&&
storagelocation
.
offset
+
type
.
storageBytes
>
32
)
{
if
(
!
variable
.
constant
&&
storagelocation
.
offset
+
type
.
storageBytes
>
32
)
{
storagelocation
.
slot
++
storagelocation
.
offset
=
0
}
ret
.
push
({
name
:
variable
.
attributes
.
name
,
name
:
variable
.
name
,
type
:
type
,
constant
:
variable
.
attributes
.
constant
,
constant
:
variable
.
constant
,
storagelocation
:
{
offset
:
variable
.
attributes
.
constant
?
0
:
storagelocation
.
offset
,
slot
:
variable
.
attributes
.
constant
?
0
:
storagelocation
.
slot
offset
:
variable
.
constant
?
0
:
storagelocation
.
offset
,
slot
:
variable
.
constant
?
0
:
storagelocation
.
slot
}
})
if
(
!
variable
.
attributes
.
constant
)
{
if
(
!
variable
.
constant
)
{
if
(
type
.
storageSlots
===
1
&&
storagelocation
.
offset
+
type
.
storageBytes
<=
32
)
{
storagelocation
.
offset
+=
type
.
storageBytes
}
else
{
...
...
libs/remix-debug/src/solidity-decoder/internalCallTree.js
View file @
11dd6c80
...
...
@@ -216,20 +216,20 @@ function includeVariableDeclaration (tree, step, sourceLocation, scopeId, newLoc
// using the vm trace step, the current source location and the ast,
// we check if the current vm trace step target a new ast node of type VariableDeclaration
// that way we know that there is a new local variable from here.
if
(
variableDeclaration
&&
!
tree
.
scopes
[
scopeId
].
locals
[
variableDeclaration
.
attributes
.
name
])
{
if
(
variableDeclaration
&&
!
tree
.
scopes
[
scopeId
].
locals
[
variableDeclaration
.
name
])
{
try
{
const
stack
=
tree
.
traceManager
.
getStackAt
(
step
)
// the stack length at this point is where the value of the new local variable will be stored.
// so, either this is the direct value, or the offset in memory. That depends on the type.
tree
.
solidityProxy
.
contractNameAt
(
step
).
then
((
contractName
)
=>
{
if
(
variableDeclaration
.
attributes
.
name
!==
''
)
{
if
(
variableDeclaration
.
name
!==
''
)
{
var
states
=
tree
.
solidityProxy
.
extractStatesDefinitions
()
var
location
=
typesUtil
.
extractLocationFromAstVariable
(
variableDeclaration
)
location
=
location
===
'default'
?
'storage'
:
location
// we push the new local variable in our tree
tree
.
scopes
[
scopeId
].
locals
[
variableDeclaration
.
attributes
.
name
]
=
{
name
:
variableDeclaration
.
attributes
.
name
,
type
:
decodeInfo
.
parseType
(
variableDeclaration
.
attributes
.
type
,
states
,
contractName
,
location
),
tree
.
scopes
[
scopeId
].
locals
[
variableDeclaration
.
name
]
=
{
name
:
variableDeclaration
.
name
,
type
:
decodeInfo
.
parseType
(
variableDeclaration
.
typeDescriptions
.
typeString
,
states
,
contractName
,
location
),
stackDepth
:
stack
.
length
,
sourceLocation
:
sourceLocation
}
...
...
@@ -242,7 +242,7 @@ function includeVariableDeclaration (tree, step, sourceLocation, scopeId, newLoc
// we check here if we are at the beginning inside a new function.
// if that is the case, we have to add to locals tree the inputs and output params
const
functionDefinition
=
resolveFunctionDefinition
(
tree
,
step
,
previousSourceLocation
)
if
(
functionDefinition
&&
(
newLocation
&&
traceHelper
.
isJumpDestInstruction
(
tree
.
traceManager
.
trace
[
step
-
1
])
||
functionDefinition
.
attributes
.
isConstructor
))
{
if
(
functionDefinition
&&
(
newLocation
&&
traceHelper
.
isJumpDestInstruction
(
tree
.
traceManager
.
trace
[
step
-
1
])
||
functionDefinition
.
kind
===
'constructor'
))
{
tree
.
functionCallStack
.
push
(
step
)
const
functionDefinitionAndInputs
=
{
functionDefinition
,
inputs
:
[]}
// means: the previous location was a function definition && JUMPDEST
...
...
@@ -252,11 +252,11 @@ function includeVariableDeclaration (tree, step, sourceLocation, scopeId, newLoc
try
{
const
stack
=
tree
.
traceManager
.
getStackAt
(
step
)
var
states
=
tree
.
solidityProxy
.
extractStatesDefinitions
()
if
(
functionDefinition
.
children
&&
functionDefinition
.
children
.
length
)
{
if
(
functionDefinition
.
parameters
&&
functionDefinition
.
parameters
.
length
)
{
let
inputs
let
outputs
for
(
const
element
of
functionDefinition
.
children
)
{
if
(
element
.
n
am
e
===
'ParameterList'
)
{
for
(
const
element
of
functionDefinition
.
parameters
)
{
if
(
element
.
n
odeTyp
e
===
'ParameterList'
)
{
if
(
!
inputs
)
inputs
=
element
else
{
outputs
=
element
...
...
@@ -266,7 +266,7 @@ function includeVariableDeclaration (tree, step, sourceLocation, scopeId, newLoc
}
// input params
if
(
inputs
)
{
functionDefinitionAndInputs
.
inputs
=
addParams
(
inputs
,
tree
,
scopeId
,
states
,
contractName
,
previousSourceLocation
,
stack
.
length
,
inputs
.
children
.
length
,
-
1
)
functionDefinitionAndInputs
.
inputs
=
addParams
(
inputs
,
tree
,
scopeId
,
states
,
contractName
,
previousSourceLocation
,
stack
.
length
,
inputs
.
parameters
.
length
,
-
1
)
}
// output params
if
(
outputs
)
addParams
(
outputs
,
tree
,
scopeId
,
states
,
contractName
,
previousSourceLocation
,
stack
.
length
,
0
,
1
)
...
...
@@ -313,7 +313,7 @@ function resolveFunctionDefinition (tree, step, sourceLocation) {
function
extractVariableDeclarations
(
ast
,
astWalker
)
{
const
ret
=
{}
astWalker
.
walk
(
ast
,
(
node
)
=>
{
if
(
node
.
n
am
e
===
'VariableDeclaration'
)
{
if
(
node
.
n
odeTyp
e
===
'VariableDeclaration'
)
{
ret
[
node
.
src
]
=
node
}
return
true
...
...
@@ -324,7 +324,7 @@ function extractVariableDeclarations (ast, astWalker) {
function
extractFunctionDefinitions
(
ast
,
astWalker
)
{
const
ret
=
{}
astWalker
.
walk
(
ast
,
(
node
)
=>
{
if
(
node
.
n
am
e
===
'FunctionDefinition'
)
{
if
(
node
.
n
odeTyp
e
===
'FunctionDefinition'
)
{
ret
[
node
.
src
]
=
node
}
return
true
...
...
@@ -334,16 +334,16 @@ function extractFunctionDefinitions (ast, astWalker) {
function
addParams
(
parameterList
,
tree
,
scopeId
,
states
,
contractName
,
sourceLocation
,
stackLength
,
stackPosition
,
dir
)
{
let
params
=
[]
for
(
let
inputParam
in
parameterList
.
children
)
{
const
param
=
parameterList
.
children
[
inputParam
]
for
(
let
inputParam
in
parameterList
.
parameters
)
{
const
param
=
parameterList
.
parameters
[
inputParam
]
const
stackDepth
=
stackLength
+
(
dir
*
stackPosition
)
if
(
stackDepth
>=
0
)
{
let
location
=
typesUtil
.
extractLocationFromAstVariable
(
param
)
location
=
location
===
'default'
?
'memory'
:
location
const
attributesName
=
param
.
attributes
.
name
===
''
?
`$
${
inputParam
}
`
:
param
.
attributes
.
name
const
attributesName
=
param
.
name
===
''
?
`$
${
inputParam
}
`
:
param
.
name
tree
.
scopes
[
scopeId
].
locals
[
attributesName
]
=
{
name
:
attributesName
,
type
:
decodeInfo
.
parseType
(
param
.
attributes
.
type
,
states
,
contractName
,
location
),
type
:
decodeInfo
.
parseType
(
param
.
typeDescriptions
.
typeString
,
states
,
contractName
,
location
),
stackDepth
:
stackDepth
,
sourceLocation
:
sourceLocation
}
...
...
libs/remix-debug/src/solidity-decoder/solidityProxy.js
View file @
11dd6c80
...
...
@@ -99,7 +99,7 @@ class SolidityProxy {
ast
(
sourceLocation
)
{
const
file
=
this
.
fileNameFromIndex
(
sourceLocation
.
file
)
if
(
this
.
sources
[
file
])
{
return
this
.
sources
[
file
].
legacyAST
return
this
.
sources
[
file
].
ast
}
return
null
}
...
...
libs/remix-debug/src/solidity-decoder/types/util.js
View file @
11dd6c80
...
...
@@ -105,9 +105,9 @@ function extractLocation (type) {
}
function
extractLocationFromAstVariable
(
node
)
{
if
(
node
.
attributes
.
storageLocation
!==
'default'
)
{
return
node
.
attributes
.
storageLocation
}
else
if
(
node
.
attributes
.
stateVariable
)
{
if
(
node
.
storageLocation
!==
'default'
)
{
return
node
.
storageLocation
}
else
if
(
node
.
stateVariable
)
{
return
'storage'
}
return
'default'
// local variables => storage, function parameters & return values => memory, state => storage
...
...
libs/remix-debug/src/source/astWalker.js
View file @
11dd6c80
...
...
@@ -21,9 +21,9 @@ AstWalker.prototype.walk = function (ast, callback) {
if
(
!
(
'*'
in
callback
))
{
callback
[
'*'
]
=
function
()
{
return
true
}
}
if
(
manageCallBack
(
ast
,
callback
)
&&
ast
.
children
&&
ast
.
children
.
length
>
0
)
{
for
(
let
k
in
ast
.
children
)
{
const
child
=
ast
.
children
[
k
]
if
(
manageCallBack
(
ast
,
callback
)
&&
ast
.
nodes
&&
ast
.
nodes
.
length
>
0
)
{
for
(
let
k
in
ast
.
nodes
)
{
const
child
=
ast
.
nodes
[
k
]
this
.
walk
(
child
,
callback
)
}
}
...
...
@@ -38,13 +38,13 @@ AstWalker.prototype.walk = function (ast, callback) {
AstWalker
.
prototype
.
walkAstList
=
function
(
sourcesList
,
callback
)
{
const
walker
=
new
AstWalker
()
for
(
let
k
in
sourcesList
)
{
walker
.
walk
(
sourcesList
[
k
].
legacyAST
,
callback
)
walker
.
walk
(
sourcesList
[
k
].
ast
,
callback
)
}
}
function
manageCallBack
(
node
,
callback
)
{
if
(
node
.
n
am
e
in
callback
)
{
return
callback
[
node
.
n
am
e
](
node
)
if
(
node
.
n
odeTyp
e
in
callback
)
{
return
callback
[
node
.
n
odeTyp
e
](
node
)
}
else
{
return
callback
[
'*'
](
node
)
}
...
...
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