5
5
using System . Linq ;
6
6
7
7
using Constants ;
8
- using Helpers ;
9
8
using Resources ;
10
9
using Utilities ;
11
10
12
11
/// <summary>
13
12
/// “Edge” JsRT version of Chakra JavaScript engine
14
13
/// </summary>
15
- internal sealed class ChakraEdgeJsRtJsEngine : IInnerJsEngine
14
+ internal sealed class ChakraEdgeJsRtJsEngine : ChakraJsRtJsEngineBase
16
15
{
17
- /// <summary>
18
- /// JavaScript engine mode
19
- /// </summary>
20
- private readonly JsEngineMode _engineMode ;
21
-
22
- /// <summary>
23
- /// Name of JavaScript engine mode
24
- /// </summary>
25
- private readonly string _engineModeName ;
26
-
27
16
/// <summary>
28
17
/// Instance of JavaScript runtime
29
18
/// </summary>
@@ -58,11 +47,10 @@ internal sealed class ChakraEdgeJsRtJsEngine : IInnerJsEngine
58
47
/// <summary>
59
48
/// Constructs instance of the Chakra “Edge” JsRT JavaScript engine
60
49
/// </summary>
61
- public ChakraEdgeJsRtJsEngine ( )
50
+ /// <param name="enableDebugging">Flag for whether to enable script debugging features</param>
51
+ public ChakraEdgeJsRtJsEngine ( bool enableDebugging )
52
+ : base ( JsEngineMode . ChakraEdgeJsRt , enableDebugging )
62
53
{
63
- _engineMode = JsEngineMode . ChakraEdgeJsRt ;
64
- _engineModeName = JsEngineModeHelpers . GetModeName ( _engineMode ) ;
65
-
66
54
try
67
55
{
68
56
_jsRuntime = CreateJsRuntime ( ) ;
@@ -335,11 +323,21 @@ private JsRuntimeException ConvertJsExceptionToJsRuntimeException(
335
323
return jsEngineException ;
336
324
}
337
325
326
+ protected override void InnerStartDebugging ( )
327
+ {
328
+ EdgeJsContext . StartDebugging ( ) ;
329
+ }
330
+
338
331
private void InvokeScript ( Action action )
339
332
{
340
333
lock ( _runSynchronizer )
341
334
using ( new EdgeJsScope ( _jsContext ) )
342
335
{
336
+ if ( _enableDebugging )
337
+ {
338
+ StartDebugging ( ) ;
339
+ }
340
+
343
341
try
344
342
{
345
343
action ( ) ;
@@ -356,6 +354,11 @@ private T InvokeScript<T>(Func<T> func)
356
354
lock ( _runSynchronizer )
357
355
using ( new EdgeJsScope ( _jsContext ) )
358
356
{
357
+ if ( _enableDebugging )
358
+ {
359
+ StartDebugging ( ) ;
360
+ }
361
+
359
362
try
360
363
{
361
364
return func ( ) ;
@@ -387,12 +390,12 @@ private void Dispose(bool disposing)
387
390
388
391
#region IInnerJsEngine implementation
389
392
390
- public string Mode
393
+ public override string Mode
391
394
{
392
395
get { return _engineModeName ; }
393
396
}
394
397
395
- public object Evaluate ( string expression )
398
+ public override object Evaluate ( string expression )
396
399
{
397
400
object result = InvokeScript ( ( ) =>
398
401
{
@@ -404,12 +407,12 @@ public object Evaluate(string expression)
404
407
return result ;
405
408
}
406
409
407
- public void Execute ( string code )
410
+ public override void Execute ( string code )
408
411
{
409
412
InvokeScript ( ( ) => EdgeJsContext . RunScript ( code ) ) ;
410
413
}
411
414
412
- public object CallFunction ( string functionName , params object [ ] args )
415
+ public override object CallFunction ( string functionName , params object [ ] args )
413
416
{
414
417
object result = InvokeScript ( ( ) =>
415
418
{
@@ -435,7 +438,7 @@ public object CallFunction(string functionName, params object[] args)
435
438
return result ;
436
439
}
437
440
438
- public bool HasVariable ( string variableName )
441
+ public override bool HasVariable ( string variableName )
439
442
{
440
443
bool result = InvokeScript ( ( ) =>
441
444
{
@@ -455,7 +458,7 @@ public bool HasVariable(string variableName)
455
458
return result ;
456
459
}
457
460
458
- public object GetVariableValue ( string variableName )
461
+ public override object GetVariableValue ( string variableName )
459
462
{
460
463
object result = InvokeScript ( ( ) =>
461
464
{
@@ -468,7 +471,7 @@ public object GetVariableValue(string variableName)
468
471
return result ;
469
472
}
470
473
471
- public void SetVariableValue ( string variableName , object value )
474
+ public override void SetVariableValue ( string variableName , object value )
472
475
{
473
476
InvokeScript ( ( ) =>
474
477
{
@@ -479,7 +482,7 @@ public void SetVariableValue(string variableName, object value)
479
482
} ) ;
480
483
}
481
484
482
- public void RemoveVariable ( string variableName )
485
+ public override void RemoveVariable ( string variableName )
483
486
{
484
487
InvokeScript ( ( ) =>
485
488
{
@@ -493,7 +496,7 @@ public void RemoveVariable(string variableName)
493
496
} ) ;
494
497
}
495
498
496
- public void EmbedHostObject ( string itemName , object value )
499
+ public override void EmbedHostObject ( string itemName , object value )
497
500
{
498
501
InvokeScript ( ( ) =>
499
502
{
@@ -511,7 +514,7 @@ public void EmbedHostObject(string itemName, object value)
511
514
/// <summary>
512
515
/// Destroys object
513
516
/// </summary>
514
- public void Dispose ( )
517
+ public override void Dispose ( )
515
518
{
516
519
Dispose ( true /* disposing */ ) ;
517
520
GC . SuppressFinalize ( this ) ;
0 commit comments