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
55490eae
Commit
55490eae
authored
Feb 06, 2017
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add comment
parent
80b1017c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
6 deletions
+45
-6
breakpointManager.js
src/code/breakpointManager.js
+45
-6
No files found.
src/code/breakpointManager.js
View file @
55490eae
'use strict'
var
EventManager
=
require
(
'../lib/eventManager'
)
/**
* allow to manage breakpoint
*
* Trigger events: breakpointHit, breakpointAdded, breakpointRemoved
*/
class
breakpointManager
{
/**
* constructor
*
* @param {Object} _debugger - type of EthDebugger
* @return {Function} _locationToRowConverter - function implemented by editor which return a column/line position for a char source location
*/
constructor
(
_debugger
,
_locationToRowConverter
)
{
this
.
event
=
new
EventManager
()
this
.
debugger
=
_debugger
...
...
@@ -11,6 +22,10 @@ class breakpointManager {
this
.
currentLine
}
/**
* start looking for the next breakpoint
*
*/
async
play
()
{
this
.
isPlaying
=
true
var
sourceLocation
...
...
@@ -27,7 +42,7 @@ class breakpointManager {
}
this
.
currentLine
=
lineColumn
.
start
.
line
}
if
(
this
.
checkSourceLocation
(
sourceLocation
,
currentStep
,
this
.
currentLine
))
{
if
(
this
.
checkSourceLocation
(
sourceLocation
.
file
,
this
.
currentLine
))
{
this
.
debugger
.
stepManager
.
jumpTo
(
currentStep
)
this
.
event
.
trigger
(
'breakpointHit'
,
[
sourceLocation
])
break
...
...
@@ -35,12 +50,19 @@ class breakpointManager {
}
}
checkSourceLocation
(
sourceLocation
,
currentStep
,
currentLine
)
{
if
(
this
.
breakpoints
[
sourceLocation
.
file
])
{
var
sources
=
this
.
breakpoints
[
sourceLocation
.
file
]
/**
* check the given pair fileIndex/line against registered breakpoints
*
* @param {Int} fileIndex - index of the file content (from the compilation result)
* @param {Int} line - line number where looking for breakpoint
* @return {Bool} return true if the given @arg fileIndex @arg line refers to a breakpoint
*/
checkSourceLocation
(
fileIndex
,
line
)
{
if
(
this
.
breakpoints
[
fileIndex
])
{
var
sources
=
this
.
breakpoints
[
fileIndex
]
for
(
var
k
in
sources
)
{
var
source
=
sources
[
k
]
if
(
currentL
ine
===
source
.
row
)
{
if
(
l
ine
===
source
.
row
)
{
return
true
}
}
...
...
@@ -48,6 +70,11 @@ class breakpointManager {
return
false
}
/**
* return true if current manager has breakpoint
*
* @return {Bool} true if breapoint registered
*/
hasBreakpoint
()
{
for
(
var
k
in
this
.
breakpoints
)
{
if
(
this
.
breakpoints
[
k
].
length
)
{
...
...
@@ -57,20 +84,32 @@ class breakpointManager {
return
false
}
/**
* add a new breakpoint to the manager
*
* @param {Object} sourceLocation - position of the breakpoint { file: '<file index>', row: '<line number' }
*/
add
(
sourceLocation
)
{
if
(
!
this
.
breakpoints
[
sourceLocation
.
file
])
{
this
.
breakpoints
[
sourceLocation
.
file
]
=
[]
}
this
.
breakpoints
[
sourceLocation
.
file
].
push
(
sourceLocation
)
this
.
event
.
trigger
(
'breakpointAdded'
,
[
sourceLocation
])
}
/**
* remove a breakpoint from the manager
*
* @param {Object} sourceLocation - position of the breakpoint { file: '<file index>', row: '<line number' }
*/
remove
(
sourceLocation
)
{
if
(
this
.
breakpoints
[
sourceLocation
.
file
])
{
var
sources
=
this
.
breakpoints
[
sourceLocation
.
file
]
for
(
var
k
in
sources
)
{
var
source
=
sources
[
k
]
if
(
sourceLocation
.
start
===
source
.
start
&&
sourceLocation
.
length
===
source
.
length
)
{
if
(
sourceLocation
.
row
===
source
.
row
)
{
sources
.
splice
(
k
,
1
)
this
.
event
.
trigger
(
'breakpointRemoved'
,
[
sourceLocation
])
break
}
}
...
...
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