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
92b28822
Commit
92b28822
authored
Dec 12, 2016
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decode enum
parent
0eb46f26
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
2 deletions
+17
-2
Enum.js
src/solidity/types/Enum.js
+17
-2
No files found.
src/solidity/types/Enum.js
View file @
92b28822
...
@@ -16,8 +16,23 @@ function Enum (enumDef) {
...
@@ -16,8 +16,23 @@ function Enum (enumDef) {
Enum
.
prototype
.
decodeFromStorage
=
function
(
location
,
storageContent
)
{
Enum
.
prototype
.
decodeFromStorage
=
function
(
location
,
storageContent
)
{
var
value
=
util
.
extractHexValue
(
location
,
storageContent
,
this
.
storageBytes
)
var
value
=
util
.
extractHexValue
(
location
,
storageContent
,
this
.
storageBytes
)
value
=
parseInt
(
value
,
16
)
value
=
parseInt
(
value
,
16
)
if
(
this
.
enumDef
.
children
.
length
>
value
)
{
return
output
(
value
,
this
.
enumDef
)
return
this
.
enumDef
.
children
[
value
].
attributes
.
name
}
Enum
.
prototype
.
decodeLocals
=
function
(
stackHeight
,
stack
,
memory
)
{
var
defaultValue
=
0
if
(
stack
.
length
-
1
<
stackHeight
)
{
defaultValue
=
0
}
else
{
defaultValue
=
util
.
extractHexByteSlice
(
stack
[
stack
.
length
-
1
-
stackHeight
],
this
.
storageBytes
,
0
)
defaultValue
=
parseInt
(
defaultValue
,
16
)
}
return
output
(
defaultValue
,
this
.
enumDef
)
}
function
output
(
value
,
enumDef
)
{
if
(
enumDef
.
children
.
length
>
value
)
{
return
enumDef
.
children
[
value
].
attributes
.
name
}
else
{
}
else
{
return
'INVALID_ENUM<'
+
value
+
'>'
return
'INVALID_ENUM<'
+
value
+
'>'
}
}
...
...
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