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
1926227b
Commit
1926227b
authored
Jan 11, 2017
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add comments
parent
39d7b2f0
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
0 deletions
+44
-0
RefType.js
src/solidity/types/RefType.js
+15
-0
ValueType.js
src/solidity/types/ValueType.js
+29
-0
No files found.
src/solidity/types/RefType.js
View file @
1926227b
...
@@ -10,6 +10,14 @@ class RefType {
...
@@ -10,6 +10,14 @@ class RefType {
this
.
basicType
=
'RefType'
this
.
basicType
=
'RefType'
}
}
/**
* decode the type from the stack
*
* @param {Int} stackDepth - position of the type in the stack
* @param {Array} stack - stack
* @return {String} - memory
* @return {Object} - storage
*/
decodeFromStack
(
stackDepth
,
stack
,
memory
,
storage
)
{
decodeFromStack
(
stackDepth
,
stack
,
memory
,
storage
)
{
if
(
stack
.
length
-
1
<
stackDepth
)
{
if
(
stack
.
length
-
1
<
stackDepth
)
{
return
{
error
:
'<decoding failed - stack underflow '
+
stackDepth
+
'>'
}
return
{
error
:
'<decoding failed - stack underflow '
+
stackDepth
+
'>'
}
...
@@ -19,6 +27,13 @@ class RefType {
...
@@ -19,6 +27,13 @@ class RefType {
return
decodeInternal
(
this
,
offset
,
memory
,
storage
)
return
decodeInternal
(
this
,
offset
,
memory
,
storage
)
}
}
/**
* decode the type with the @arg offset location from the memory or storage
*
* @param {Int} offset - position of the type in the memory
* @return {String} - memory
* @return {Object} - storage
*/
decode
(
offset
,
memory
,
storage
)
{
decode
(
offset
,
memory
,
storage
)
{
offset
=
memory
.
substr
(
2
*
offset
,
64
)
offset
=
memory
.
substr
(
2
*
offset
,
64
)
offset
=
parseInt
(
offset
,
16
)
offset
=
parseInt
(
offset
,
16
)
...
...
src/solidity/types/ValueType.js
View file @
1926227b
...
@@ -9,11 +9,26 @@ class ValueType {
...
@@ -9,11 +9,26 @@ class ValueType {
this
.
basicType
=
'ValueType'
this
.
basicType
=
'ValueType'
}
}
/**
* decode the type with the @arg location from the storage
*
* @param {Object} location - containing offset and slot
* @param {Object} storageContent - storageContent (storage)
* @return {Object} - decoded value
*/
decodeFromStorage
(
location
,
storageContent
)
{
decodeFromStorage
(
location
,
storageContent
)
{
var
value
=
util
.
extractHexValue
(
location
,
storageContent
,
this
.
storageBytes
)
var
value
=
util
.
extractHexValue
(
location
,
storageContent
,
this
.
storageBytes
)
return
this
.
decodeValue
(
value
)
return
this
.
decodeValue
(
value
)
}
}
/**
* decode the type from the stack
*
* @param {Int} stackDepth - position of the type in the stack
* @param {Array} stack - stack
* @param {String} - memory
* @return {Object} - decoded value
*/
decodeFromStack
(
stackDepth
,
stack
,
memory
)
{
decodeFromStack
(
stackDepth
,
stack
,
memory
)
{
if
(
stackDepth
>=
stack
.
length
)
{
if
(
stackDepth
>=
stack
.
length
)
{
return
this
.
decodeValue
(
''
)
return
this
.
decodeValue
(
''
)
...
@@ -22,11 +37,25 @@ class ValueType {
...
@@ -22,11 +37,25 @@ class ValueType {
}
}
}
}
/**
* decode the type with the @arg offset location from the memory
*
* @param {Int} stackDepth - position of the type in the stack
* @return {String} - memory
* @return {Object} - decoded value
*/
decodeFromMemory
(
offset
,
memory
)
{
decodeFromMemory
(
offset
,
memory
)
{
var
value
=
memory
.
substr
(
2
*
offset
,
64
)
var
value
=
memory
.
substr
(
2
*
offset
,
64
)
return
this
.
decodeValue
(
util
.
extractHexByteSlice
(
value
,
this
.
storageBytes
,
0
))
return
this
.
decodeValue
(
util
.
extractHexByteSlice
(
value
,
this
.
storageBytes
,
0
))
}
}
/**
* decode the type with the @arg offset location from the memory
*
* @param {Int} offset - position of the type in the memory
* @return {String} - memory
* @return {Object} - storage
*/
decode
(
offset
,
memory
)
{
decode
(
offset
,
memory
)
{
return
this
.
decodeFromMemory
(
offset
,
memory
)
return
this
.
decodeFromMemory
(
offset
,
memory
)
}
}
...
...
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