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
5508a81b
Commit
5508a81b
authored
Feb 15, 2017
by
yann300
Committed by
GitHub
Feb 15, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #200 from ethereum/fixState
Fix solidity state / locals
parents
e13c8fe7
588f9622
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
15 deletions
+23
-15
astHelper.js
src/solidity/astHelper.js
+15
-7
decodeInfo.js
test/solidity/decodeInfo.js
+8
-8
No files found.
src/solidity/astHelper.js
View file @
5508a81b
...
@@ -10,14 +10,18 @@ var AstWalker = require('../util/astWalker')
...
@@ -10,14 +10,18 @@ var AstWalker = require('../util/astWalker')
function
extractContractDefinitions
(
sourcesList
)
{
function
extractContractDefinitions
(
sourcesList
)
{
var
ret
=
{
var
ret
=
{
contractsById
:
{},
contractsById
:
{},
contractsByName
:
{}
contractsByName
:
{},
sourcesByContract
:
{}
}
}
var
walker
=
new
AstWalker
()
var
walker
=
new
AstWalker
()
walker
.
walkAstList
(
sourcesList
,
{
'ContractDefinition'
:
function
(
node
)
{
for
(
var
k
in
sourcesList
)
{
ret
.
contractsById
[
node
.
id
]
=
node
walker
.
walk
(
sourcesList
[
k
].
AST
,
{
'ContractDefinition'
:
function
(
node
)
{
ret
.
contractsByName
[
node
.
attributes
.
name
]
=
node
ret
.
contractsById
[
node
.
id
]
=
node
return
false
ret
.
sourcesByContract
[
node
.
id
]
=
k
}})
ret
.
contractsByName
[
k
+
':'
+
node
.
attributes
.
name
]
=
node
return
false
}})
}
return
ret
return
ret
}
}
...
@@ -83,7 +87,11 @@ function extractStatesDefinitions (sourcesList, contracts) {
...
@@ -83,7 +87,11 @@ function extractStatesDefinitions (sourcesList, contracts) {
var
ret
=
{}
var
ret
=
{}
for
(
var
contract
in
contracts
.
contractsById
)
{
for
(
var
contract
in
contracts
.
contractsById
)
{
var
name
=
contracts
.
contractsById
[
contract
].
attributes
.
name
var
name
=
contracts
.
contractsById
[
contract
].
attributes
.
name
ret
[
name
]
=
extractStateDefinitions
(
name
,
sourcesList
,
contracts
)
var
source
=
contracts
.
sourcesByContract
[
contract
]
var
fullName
=
source
+
':'
+
name
var
state
=
extractStateDefinitions
(
fullName
,
sourcesList
,
contracts
)
ret
[
fullName
]
=
state
ret
[
name
]
=
state
// solc < 0.4.9
}
}
return
ret
return
ret
}
}
...
...
test/solidity/decodeInfo.js
View file @
5508a81b
...
@@ -9,7 +9,7 @@ tape('solidity', function (t) {
...
@@ -9,7 +9,7 @@ tape('solidity', function (t) {
t
.
test
(
'astHelper, decodeInfo'
,
function
(
st
)
{
t
.
test
(
'astHelper, decodeInfo'
,
function
(
st
)
{
var
output
=
compiler
.
compile
(
contracts
,
0
)
var
output
=
compiler
.
compile
(
contracts
,
0
)
var
state
=
index
.
solidity
.
astHelper
.
extractStateDefinitions
(
'contractUint'
,
output
.
sources
)
var
state
=
index
.
solidity
.
astHelper
.
extractStateDefinitions
(
'
:
contractUint'
,
output
.
sources
)
var
states
=
index
.
solidity
.
astHelper
.
extractStatesDefinitions
(
output
.
sources
)
var
states
=
index
.
solidity
.
astHelper
.
extractStatesDefinitions
(
output
.
sources
)
var
stateDef
=
state
.
stateDefinitions
var
stateDef
=
state
.
stateDefinitions
var
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseType
(
stateDef
[
0
].
attributes
.
type
,
states
,
'contractUint'
)
var
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseType
(
stateDef
[
0
].
attributes
.
type
,
states
,
'contractUint'
)
...
@@ -21,7 +21,7 @@ tape('solidity', function (t) {
...
@@ -21,7 +21,7 @@ tape('solidity', function (t) {
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseType
(
stateDef
[
4
].
attributes
.
type
,
states
,
'contractUint'
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseType
(
stateDef
[
4
].
attributes
.
type
,
states
,
'contractUint'
)
checkDecodeInfo
(
st
,
decodeInfo
,
1
,
16
,
'bytes16'
)
checkDecodeInfo
(
st
,
decodeInfo
,
1
,
16
,
'bytes16'
)
state
=
index
.
solidity
.
astHelper
.
extractStateDefinitions
(
'contractStructAndArray'
,
output
.
sources
)
state
=
index
.
solidity
.
astHelper
.
extractStateDefinitions
(
'
:
contractStructAndArray'
,
output
.
sources
)
stateDef
=
state
.
stateDefinitions
stateDef
=
state
.
stateDefinitions
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseType
(
stateDef
[
1
].
attributes
.
type
,
states
,
'contractStructAndArray'
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseType
(
stateDef
[
1
].
attributes
.
type
,
states
,
'contractStructAndArray'
)
checkDecodeInfo
(
st
,
decodeInfo
,
2
,
32
,
'struct contractStructAndArray.structDef'
)
checkDecodeInfo
(
st
,
decodeInfo
,
2
,
32
,
'struct contractStructAndArray.structDef'
)
...
@@ -30,7 +30,7 @@ tape('solidity', function (t) {
...
@@ -30,7 +30,7 @@ tape('solidity', function (t) {
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseType
(
stateDef
[
3
].
attributes
.
type
,
states
,
'contractStructAndArray'
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseType
(
stateDef
[
3
].
attributes
.
type
,
states
,
'contractStructAndArray'
)
checkDecodeInfo
(
st
,
decodeInfo
,
2
,
32
,
'bytes12[4]'
)
checkDecodeInfo
(
st
,
decodeInfo
,
2
,
32
,
'bytes12[4]'
)
state
=
index
.
solidity
.
astHelper
.
extractStateDefinitions
(
'contractArray'
,
output
.
sources
)
state
=
index
.
solidity
.
astHelper
.
extractStateDefinitions
(
'
:
contractArray'
,
output
.
sources
)
stateDef
=
state
.
stateDefinitions
stateDef
=
state
.
stateDefinitions
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseType
(
stateDef
[
0
].
attributes
.
type
,
states
,
'contractArray'
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseType
(
stateDef
[
0
].
attributes
.
type
,
states
,
'contractArray'
)
checkDecodeInfo
(
st
,
decodeInfo
,
1
,
32
,
'uint32[5]'
)
checkDecodeInfo
(
st
,
decodeInfo
,
1
,
32
,
'uint32[5]'
)
...
@@ -39,12 +39,12 @@ tape('solidity', function (t) {
...
@@ -39,12 +39,12 @@ tape('solidity', function (t) {
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseType
(
stateDef
[
2
].
attributes
.
type
,
states
,
'contractArray'
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseType
(
stateDef
[
2
].
attributes
.
type
,
states
,
'contractArray'
)
checkDecodeInfo
(
st
,
decodeInfo
,
4
,
32
,
'int16[][3][][4]'
)
checkDecodeInfo
(
st
,
decodeInfo
,
4
,
32
,
'int16[][3][][4]'
)
state
=
index
.
solidity
.
astHelper
.
extractStateDefinitions
(
'contractEnum'
,
output
.
sources
)
state
=
index
.
solidity
.
astHelper
.
extractStateDefinitions
(
'
:
contractEnum'
,
output
.
sources
)
stateDef
=
state
.
stateDefinitions
stateDef
=
state
.
stateDefinitions
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseType
(
stateDef
[
1
].
attributes
.
type
,
states
,
'contractEnum'
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseType
(
stateDef
[
1
].
attributes
.
type
,
states
,
'contractEnum'
)
checkDecodeInfo
(
st
,
decodeInfo
,
1
,
2
,
'enum'
)
checkDecodeInfo
(
st
,
decodeInfo
,
1
,
2
,
'enum'
)
state
=
index
.
solidity
.
astHelper
.
extractStateDefinitions
(
'contractSmallVariable'
,
output
.
sources
)
state
=
index
.
solidity
.
astHelper
.
extractStateDefinitions
(
'
:
contractSmallVariable'
,
output
.
sources
)
stateDef
=
state
.
stateDefinitions
stateDef
=
state
.
stateDefinitions
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseType
(
stateDef
[
0
].
attributes
.
type
,
states
,
'contractSmallVariable'
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseType
(
stateDef
[
0
].
attributes
.
type
,
states
,
'contractSmallVariable'
)
checkDecodeInfo
(
st
,
decodeInfo
,
1
,
1
,
'int8'
)
checkDecodeInfo
(
st
,
decodeInfo
,
1
,
1
,
'int8'
)
...
@@ -61,7 +61,7 @@ tape('solidity', function (t) {
...
@@ -61,7 +61,7 @@ tape('solidity', function (t) {
output
=
compiler
.
compile
(
simplecontracts
,
0
)
output
=
compiler
.
compile
(
simplecontracts
,
0
)
state
=
index
.
solidity
.
astHelper
.
extractStateDefinitions
(
'simpleContract'
,
output
.
sources
)
state
=
index
.
solidity
.
astHelper
.
extractStateDefinitions
(
'
:
simpleContract'
,
output
.
sources
)
states
=
index
.
solidity
.
astHelper
.
extractStatesDefinitions
(
output
.
sources
)
states
=
index
.
solidity
.
astHelper
.
extractStatesDefinitions
(
output
.
sources
)
stateDef
=
state
.
stateDefinitions
stateDef
=
state
.
stateDefinitions
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseType
(
stateDef
[
2
].
attributes
.
type
,
states
,
'simpleContract'
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseType
(
stateDef
[
2
].
attributes
.
type
,
states
,
'simpleContract'
)
...
@@ -71,12 +71,12 @@ tape('solidity', function (t) {
...
@@ -71,12 +71,12 @@ tape('solidity', function (t) {
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseType
(
stateDef
[
4
].
attributes
.
type
,
states
,
'simpleContract'
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseType
(
stateDef
[
4
].
attributes
.
type
,
states
,
'simpleContract'
)
checkDecodeInfo
(
st
,
decodeInfo
,
1
,
1
,
'enum'
)
checkDecodeInfo
(
st
,
decodeInfo
,
1
,
1
,
'enum'
)
state
=
index
.
solidity
.
astHelper
.
extractStateDefinitions
(
'test2'
,
output
.
sources
)
state
=
index
.
solidity
.
astHelper
.
extractStateDefinitions
(
'
:
test2'
,
output
.
sources
)
stateDef
=
state
.
stateDefinitions
stateDef
=
state
.
stateDefinitions
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseType
(
stateDef
[
0
].
attributes
.
type
,
states
,
'test1'
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseType
(
stateDef
[
0
].
attributes
.
type
,
states
,
'test1'
)
checkDecodeInfo
(
st
,
decodeInfo
,
0
,
32
,
'struct test1.str'
)
checkDecodeInfo
(
st
,
decodeInfo
,
0
,
32
,
'struct test1.str'
)
state
=
index
.
solidity
.
stateDecoder
.
extractStateVariables
(
'test2'
,
output
.
sources
)
state
=
index
.
solidity
.
stateDecoder
.
extractStateVariables
(
'
:
test2'
,
output
.
sources
)
checkDecodeInfo
(
st
,
decodeInfo
,
0
,
32
,
'struct test1.str'
)
checkDecodeInfo
(
st
,
decodeInfo
,
0
,
32
,
'struct test1.str'
)
st
.
end
()
st
.
end
()
...
...
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