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
ac741534
Commit
ac741534
authored
Dec 12, 2017
by
ninabreznik
Browse files
Options
Browse Files
Download
Plain Diff
Refactoring
parents
bdbc21ac
aeea0069
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
12 deletions
+27
-12
contextualListener.js
src/app/editor/contextualListener.js
+27
-12
No files found.
src/app/editor/contextualListener.js
View file @
ac741534
...
...
@@ -64,6 +64,7 @@ class ContextualListener {
this
.
currentFile
=
file
if
(
compilationResult
&&
compilationResult
.
data
&&
compilationResult
.
data
.
sources
[
file
])
{
var
nodes
=
this
.
sourceMappingDecoder
.
nodesAtPosition
(
null
,
cursorPosition
,
compilationResult
.
data
.
sources
[
file
])
this
.
nodes
=
nodes
if
(
nodes
&&
nodes
.
length
&&
nodes
[
nodes
.
length
-
1
])
{
this
.
_highlightExpressions
(
nodes
[
nodes
.
length
-
1
],
compilationResult
)
}
...
...
@@ -91,10 +92,8 @@ class ContextualListener {
}
}
_getGasEstimation
(
results
)
{
this
.
contractName
=
Object
.
keys
(
results
.
data
.
contracts
[
results
.
source
.
target
])[
0
]
this
.
target
=
results
.
data
.
contracts
[
results
.
source
.
target
]
this
.
contract
=
this
.
target
[
this
.
contractName
]
_getGasEstimation
(
contract
)
{
this
.
contract
=
this
.
results
.
data
.
contracts
[
this
.
results
.
source
.
target
][
contract
.
attributes
.
name
]
this
.
estimationObj
=
this
.
contract
.
evm
.
gasEstimates
if
(
this
.
estimationObj
.
external
)
this
.
externalFunctions
=
Object
.
keys
(
this
.
estimationObj
.
external
)
if
(
this
.
estimationObj
.
internal
)
this
.
internalFunctions
=
Object
.
keys
(
this
.
estimationObj
.
internal
)
...
...
@@ -102,25 +101,41 @@ class ContextualListener {
this
.
codeDepositCost
=
this
.
estimationObj
.
creation
.
codeDepositCost
}
_getContract
(
node
)
{
for
(
var
i
in
this
.
nodes
)
{
if
(
this
.
nodes
[
i
].
id
===
node
.
attributes
.
scope
)
{
var
contract
=
this
.
_getGasEstimation
(
this
.
nodes
[
i
])
break
}
}
return
contract
}
gasEstimation
(
node
)
{
this
.
_getContract
(
node
)
var
executionCost
var
codeDepositCost
if
(
node
.
name
===
'FunctionDefinition'
)
{
if
(
!
node
.
attributes
.
isConstructor
)
{
var
functionName
=
node
.
attributes
.
name
if
(
this
.
externalFunctions
)
{
return
{
executionCost
:
this
.
estimationObj
.
external
[
this
.
_getFn
(
this
.
externalFunctions
,
functionName
)]}
}
if
(
this
.
internalFunctions
)
{
return
{
executionCost
:
this
.
estimationObj
.
internal
[
this
.
_getFn
(
this
.
internalFunctions
,
functionName
)]}
if
(
node
.
attributes
.
visibility
===
'public'
)
{
executionCost
=
this
.
estimationObj
.
external
[
this
.
_getFn
(
this
.
externalFunctions
,
functionName
)]
}
else
if
(
node
.
attributes
.
visibility
===
'internal'
)
{
executionCost
=
this
.
estimationObj
.
internal
[
this
.
_getFn
(
this
.
internalFunctions
,
functionName
)]
}
}
else
{
return
{
executionCost
:
this
.
creationCost
,
codeDepositCost
:
this
.
codeDepositCost
}
executionCost
=
this
.
creationCost
codeDepositCost
=
this
.
codeDepositCost
}
}
else
{
executionCost
=
'-'
}
return
{
executionCost
,
codeDepositCost
}
}
_getFn
(
functions
,
name
)
{
for
(
var
x
in
functions
)
{
if
(
!!
~
functions
[
x
].
indexOf
(
name
))
{
if
(
~
functions
[
x
].
indexOf
(
name
))
{
var
fn
=
functions
[
x
]
break
}
...
...
@@ -156,7 +171,7 @@ class ContextualListener {
highlights
(
node
.
id
)
this
.
_highlight
(
node
,
compilationResult
)
}
this
.
_getGasEstimation
(
compilationResult
)
this
.
results
=
compilationResult
}
_stopHighlighting
()
{
...
...
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