55 using System . Linq ;
66
77 using Constants ;
8- using Helpers ;
98 using Resources ;
109 using Utilities ;
1110
1211 /// <summary>
1312 /// “Edge” JsRT version of Chakra JavaScript engine
1413 /// </summary>
15- internal sealed class ChakraEdgeJsRtJsEngine : IInnerJsEngine
14+ internal sealed class ChakraEdgeJsRtJsEngine : ChakraJsRtJsEngineBase
1615 {
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-
2716 /// <summary>
2817 /// Instance of JavaScript runtime
2918 /// </summary>
@@ -58,11 +47,10 @@ internal sealed class ChakraEdgeJsRtJsEngine : IInnerJsEngine
5847 /// <summary>
5948 /// Constructs instance of the Chakra “Edge” JsRT JavaScript engine
6049 /// </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 )
6253 {
63- _engineMode = JsEngineMode . ChakraEdgeJsRt ;
64- _engineModeName = JsEngineModeHelpers . GetModeName ( _engineMode ) ;
65-
6654 try
6755 {
6856 _jsRuntime = CreateJsRuntime ( ) ;
@@ -335,11 +323,21 @@ private JsRuntimeException ConvertJsExceptionToJsRuntimeException(
335323 return jsEngineException ;
336324 }
337325
326+ protected override void InnerStartDebugging ( )
327+ {
328+ EdgeJsContext . StartDebugging ( ) ;
329+ }
330+
338331 private void InvokeScript ( Action action )
339332 {
340333 lock ( _runSynchronizer )
341334 using ( new EdgeJsScope ( _jsContext ) )
342335 {
336+ if ( _enableDebugging )
337+ {
338+ StartDebugging ( ) ;
339+ }
340+
343341 try
344342 {
345343 action ( ) ;
@@ -356,6 +354,11 @@ private T InvokeScript<T>(Func<T> func)
356354 lock ( _runSynchronizer )
357355 using ( new EdgeJsScope ( _jsContext ) )
358356 {
357+ if ( _enableDebugging )
358+ {
359+ StartDebugging ( ) ;
360+ }
361+
359362 try
360363 {
361364 return func ( ) ;
@@ -387,12 +390,12 @@ private void Dispose(bool disposing)
387390
388391 #region IInnerJsEngine implementation
389392
390- public string Mode
393+ public override string Mode
391394 {
392395 get { return _engineModeName ; }
393396 }
394397
395- public object Evaluate ( string expression )
398+ public override object Evaluate ( string expression )
396399 {
397400 object result = InvokeScript ( ( ) =>
398401 {
@@ -404,12 +407,12 @@ public object Evaluate(string expression)
404407 return result ;
405408 }
406409
407- public void Execute ( string code )
410+ public override void Execute ( string code )
408411 {
409412 InvokeScript ( ( ) => EdgeJsContext . RunScript ( code ) ) ;
410413 }
411414
412- public object CallFunction ( string functionName , params object [ ] args )
415+ public override object CallFunction ( string functionName , params object [ ] args )
413416 {
414417 object result = InvokeScript ( ( ) =>
415418 {
@@ -435,7 +438,7 @@ public object CallFunction(string functionName, params object[] args)
435438 return result ;
436439 }
437440
438- public bool HasVariable ( string variableName )
441+ public override bool HasVariable ( string variableName )
439442 {
440443 bool result = InvokeScript ( ( ) =>
441444 {
@@ -455,7 +458,7 @@ public bool HasVariable(string variableName)
455458 return result ;
456459 }
457460
458- public object GetVariableValue ( string variableName )
461+ public override object GetVariableValue ( string variableName )
459462 {
460463 object result = InvokeScript ( ( ) =>
461464 {
@@ -468,7 +471,7 @@ public object GetVariableValue(string variableName)
468471 return result ;
469472 }
470473
471- public void SetVariableValue ( string variableName , object value )
474+ public override void SetVariableValue ( string variableName , object value )
472475 {
473476 InvokeScript ( ( ) =>
474477 {
@@ -479,7 +482,7 @@ public void SetVariableValue(string variableName, object value)
479482 } ) ;
480483 }
481484
482- public void RemoveVariable ( string variableName )
485+ public override void RemoveVariable ( string variableName )
483486 {
484487 InvokeScript ( ( ) =>
485488 {
@@ -493,7 +496,7 @@ public void RemoveVariable(string variableName)
493496 } ) ;
494497 }
495498
496- public void EmbedHostObject ( string itemName , object value )
499+ public override void EmbedHostObject ( string itemName , object value )
497500 {
498501 InvokeScript ( ( ) =>
499502 {
@@ -511,7 +514,7 @@ public void EmbedHostObject(string itemName, object value)
511514 /// <summary>
512515 /// Destroys object
513516 /// </summary>
514- public void Dispose ( )
517+ public override void Dispose ( )
515518 {
516519 Dispose ( true /* disposing */ ) ;
517520 GC . SuppressFinalize ( this ) ;
0 commit comments