1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
4 
5 namespace System.Xml.Xsl.XsltOld
6 {
7     using System;
8     using System.Collections;
9     using System.Xml;
10     using System.Xml.XPath;
11     using System.Xml.Xsl.XsltOld.Debugger;
12     using System.Diagnostics;
13     using System.Runtime.Versioning;
14 
15     internal class DbgData
16     {
17         private XPathNavigator _styleSheet;
18         private VariableAction[] _variables;
19         public XPathNavigator StyleSheet { get { return _styleSheet; } }
20         public VariableAction[] Variables { get { return _variables; } }
DbgData(Compiler compiler)21         public DbgData(Compiler compiler)
22         {
23             DbgCompiler dbgCompiler = (DbgCompiler)compiler;
24             _styleSheet = dbgCompiler.Input.Navigator.Clone();
25             _variables = dbgCompiler.LocalVariables;
26             dbgCompiler.Debugger.OnInstructionCompile(this.StyleSheet);
27         }
ReplaceVariables(VariableAction[] vars)28         internal void ReplaceVariables(VariableAction[] vars) { _variables = vars; }
29 
30         // static Empty:
31         private static DbgData s_nullDbgData = new DbgData();
DbgData()32         private DbgData()
33         {
34             _styleSheet = null;
35             _variables = new VariableAction[0];
36         }
37         public static DbgData Empty { get { return s_nullDbgData; } }
38     }
39 
40     internal class DbgCompiler : Compiler
41     {
42         private IXsltDebugger _debugger;
43 
DbgCompiler(IXsltDebugger debugger)44         public DbgCompiler(IXsltDebugger debugger)
45         {
46             _debugger = debugger;
47         }
48         public override IXsltDebugger Debugger { get { return _debugger; } }
49 
50         // Variables
51         //
52         // In XsltDebugger we have to know variables that are visible from each action.
53         // We keepping two different sets of wariables because global and local variables have different rules of visibility.
54         // Globals: All global variables are visible avryware (uncalucaled will have null value),
55         //          Duplicated globals from different stilesheets are replaced (by import presidence)
56         // Locals:  Visible only in scope and after it was defined.
57         //          No duplicates posible.
58         private ArrayList _globalVars = new ArrayList();
59         private ArrayList _localVars = new ArrayList();
60         private VariableAction[] _globalVarsCache, _localVarsCache;
61 
62         public virtual VariableAction[] GlobalVariables
63         {
64             get
65             {
66                 Debug.Assert(this.Debugger != null);
67                 if (_globalVarsCache == null)
68                 {
69                     _globalVarsCache = (VariableAction[])_globalVars.ToArray(typeof(VariableAction));
70                 }
71                 return _globalVarsCache;
72             }
73         }
74         public virtual VariableAction[] LocalVariables
75         {
76             get
77             {
78                 Debug.Assert(this.Debugger != null);
79                 if (_localVarsCache == null)
80                 {
81                     _localVarsCache = (VariableAction[])_localVars.ToArray(typeof(VariableAction));
82                 }
83                 return _localVarsCache;
84             }
85         }
86 
DefineVariable(VariableAction variable)87         private void DefineVariable(VariableAction variable)
88         {
89             Debug.Assert(this.Debugger != null);
90             if (variable.IsGlobal)
91             {
92                 for (int i = 0; i < _globalVars.Count; i++)
93                 {
94                     VariableAction oldVar = (VariableAction)_globalVars[i];
95                     if (oldVar.Name == variable.Name)
96                     { // Duplicate var definition
97                         if (variable.Stylesheetid < oldVar.Stylesheetid)
98                         {
99                             Debug.Assert(variable.VarKey != -1, "Variable was already placed and it should replace prev var.");
100                             _globalVars[i] = variable;
101                             _globalVarsCache = null;
102                         }
103                         return;
104                     }
105                 }
106                 _globalVars.Add(variable);
107                 _globalVarsCache = null;
108             }
109             else
110             {
111                 // local variables never conflict
112                 _localVars.Add(variable);
113                 _localVarsCache = null;
114             }
115         }
116 
UnDefineVariables(int count)117         private void UnDefineVariables(int count)
118         {
119             Debug.Assert(0 <= count, "This scope can't have more variables than we have in total");
120             Debug.Assert(count <= _localVars.Count, "This scope can't have more variables than we have in total");
121             if (count != 0)
122             {
123                 _localVars.RemoveRange(_localVars.Count - count, count);
124                 _localVarsCache = null;
125             }
126         }
127 
PopScope()128         internal override void PopScope()
129         {
130             this.UnDefineVariables(this.ScopeManager.CurrentScope.GetVeriablesCount());
131             base.PopScope();
132         }
133 
134         // ---------------- Actions: ---------------
135 
CreateApplyImportsAction()136         public override ApplyImportsAction CreateApplyImportsAction()
137         {
138             ApplyImportsAction action = new ApplyImportsActionDbg();
139             action.Compile(this);
140             return action;
141         }
142 
CreateApplyTemplatesAction()143         public override ApplyTemplatesAction CreateApplyTemplatesAction()
144         {
145             ApplyTemplatesAction action = new ApplyTemplatesActionDbg();
146             action.Compile(this);
147             return action;
148         }
149 
CreateAttributeAction()150         public override AttributeAction CreateAttributeAction()
151         {
152             AttributeAction action = new AttributeActionDbg();
153             action.Compile(this);
154             return action;
155         }
156 
CreateAttributeSetAction()157         public override AttributeSetAction CreateAttributeSetAction()
158         {
159             AttributeSetAction action = new AttributeSetActionDbg();
160             action.Compile(this);
161             return action;
162         }
163 
CreateCallTemplateAction()164         public override CallTemplateAction CreateCallTemplateAction()
165         {
166             CallTemplateAction action = new CallTemplateActionDbg();
167             action.Compile(this);
168             return action;
169         }
170 
CreateChooseAction()171         public override ChooseAction CreateChooseAction()
172         {//!!! don't need to be here
173             ChooseAction action = new ChooseAction();
174             action.Compile(this);
175             return action;
176         }
177 
CreateCommentAction()178         public override CommentAction CreateCommentAction()
179         {
180             CommentAction action = new CommentActionDbg();
181             action.Compile(this);
182             return action;
183         }
184 
CreateCopyAction()185         public override CopyAction CreateCopyAction()
186         {
187             CopyAction action = new CopyActionDbg();
188             action.Compile(this);
189             return action;
190         }
191 
CreateCopyOfAction()192         public override CopyOfAction CreateCopyOfAction()
193         {
194             CopyOfAction action = new CopyOfActionDbg();
195             action.Compile(this);
196             return action;
197         }
198 
CreateElementAction()199         public override ElementAction CreateElementAction()
200         {
201             ElementAction action = new ElementActionDbg();
202             action.Compile(this);
203             return action;
204         }
205 
CreateForEachAction()206         public override ForEachAction CreateForEachAction()
207         {
208             ForEachAction action = new ForEachActionDbg();
209             action.Compile(this);
210             return action;
211         }
212 
CreateIfAction(IfAction.ConditionType type)213         public override IfAction CreateIfAction(IfAction.ConditionType type)
214         {
215             IfAction action = new IfActionDbg(type);
216             action.Compile(this);
217             return action;
218         }
219 
CreateMessageAction()220         public override MessageAction CreateMessageAction()
221         {
222             MessageAction action = new MessageActionDbg();
223             action.Compile(this);
224             return action;
225         }
226 
CreateNewInstructionAction()227         public override NewInstructionAction CreateNewInstructionAction()
228         {
229             NewInstructionAction action = new NewInstructionActionDbg();
230             action.Compile(this);
231             return action;
232         }
233 
CreateNumberAction()234         public override NumberAction CreateNumberAction()
235         {
236             NumberAction action = new NumberActionDbg();
237             action.Compile(this);
238             return action;
239         }
240 
CreateProcessingInstructionAction()241         public override ProcessingInstructionAction CreateProcessingInstructionAction()
242         {
243             ProcessingInstructionAction action = new ProcessingInstructionActionDbg();
244             action.Compile(this);
245             return action;
246         }
247 
CreateRootAction()248         public override void CreateRootAction()
249         {
250             this.RootAction = new RootActionDbg();
251             this.RootAction.Compile(this);
252         }
253 
CreateSortAction()254         public override SortAction CreateSortAction()
255         {
256             SortAction action = new SortActionDbg();
257             action.Compile(this);
258             return action;
259         }
260 
CreateTemplateAction()261         public override TemplateAction CreateTemplateAction()
262         {
263             TemplateAction action = new TemplateActionDbg();
264             action.Compile(this);
265             return action;
266         }
267 
CreateSingleTemplateAction()268         public override TemplateAction CreateSingleTemplateAction()
269         {
270             TemplateAction action = new TemplateActionDbg();
271             action.CompileSingle(this);
272             return action;
273         }
274 
CreateTextAction()275         public override TextAction CreateTextAction()
276         {
277             TextAction action = new TextActionDbg();
278             action.Compile(this);
279             return action;
280         }
281 
CreateUseAttributeSetsAction()282         public override UseAttributeSetsAction CreateUseAttributeSetsAction()
283         {
284             UseAttributeSetsAction action = new UseAttributeSetsActionDbg();
285             action.Compile(this);
286             return action;
287         }
288 
CreateValueOfAction()289         public override ValueOfAction CreateValueOfAction()
290         {
291             ValueOfAction action = new ValueOfActionDbg();
292             action.Compile(this);
293             return action;
294         }
295 
CreateVariableAction(VariableType type)296         public override VariableAction CreateVariableAction(VariableType type)
297         {
298             VariableAction action = new VariableActionDbg(type);
299             action.Compile(this);
300             return action;
301         }
302 
CreateWithParamAction()303         public override WithParamAction CreateWithParamAction()
304         {
305             WithParamAction action = new WithParamActionDbg();
306             action.Compile(this);
307             return action;
308         }
309 
310         // ---------------- Events: ---------------
311 
CreateBeginEvent()312         public override BeginEvent CreateBeginEvent()
313         {
314             return new BeginEventDbg(this);
315         }
316 
CreateTextEvent()317         public override TextEvent CreateTextEvent()
318         {
319             return new TextEventDbg(this);
320         }
321 
322         // Debugger enabled implemetation of most compiled actions
323 
324         private class ApplyImportsActionDbg : ApplyImportsAction
325         {
326             private DbgData _dbgData;
GetDbgData(ActionFrame frame)327             internal override DbgData GetDbgData(ActionFrame frame) { return _dbgData; }
328 
Compile(Compiler compiler)329             internal override void Compile(Compiler compiler)
330             {
331                 _dbgData = new DbgData(compiler);
332                 base.Compile(compiler);
333             }
334 
Execute(Processor processor, ActionFrame frame)335             internal override void Execute(Processor processor, ActionFrame frame)
336             {
337                 if (frame.State == Initialized)
338                 {
339                     processor.OnInstructionExecute();
340                 }
341                 base.Execute(processor, frame);
342             }
343         }
344 
345         private class ApplyTemplatesActionDbg : ApplyTemplatesAction
346         {
347             private DbgData _dbgData;
GetDbgData(ActionFrame frame)348             internal override DbgData GetDbgData(ActionFrame frame) { return _dbgData; }
349 
Compile(Compiler compiler)350             internal override void Compile(Compiler compiler)
351             {
352                 _dbgData = new DbgData(compiler);
353                 base.Compile(compiler);
354             }
355 
Execute(Processor processor, ActionFrame frame)356             internal override void Execute(Processor processor, ActionFrame frame)
357             {
358                 if (frame.State == Initialized)
359                 {
360                     processor.OnInstructionExecute();
361                 }
362                 base.Execute(processor, frame);
363             }
364         }
365 
366         private class AttributeActionDbg : AttributeAction
367         {
368             private DbgData _dbgData;
GetDbgData(ActionFrame frame)369             internal override DbgData GetDbgData(ActionFrame frame) { return _dbgData; }
370 
Compile(Compiler compiler)371             internal override void Compile(Compiler compiler)
372             {
373                 _dbgData = new DbgData(compiler);
374                 base.Compile(compiler);
375             }
376 
Execute(Processor processor, ActionFrame frame)377             internal override void Execute(Processor processor, ActionFrame frame)
378             {
379                 if (frame.State == Initialized)
380                 {
381                     processor.OnInstructionExecute();
382                 }
383                 base.Execute(processor, frame);
384             }
385         }
386 
387         private class AttributeSetActionDbg : AttributeSetAction
388         {
389             private DbgData _dbgData;
GetDbgData(ActionFrame frame)390             internal override DbgData GetDbgData(ActionFrame frame) { return _dbgData; }
391 
Compile(Compiler compiler)392             internal override void Compile(Compiler compiler)
393             {
394                 _dbgData = new DbgData(compiler);
395                 base.Compile(compiler);
396             }
397 
Execute(Processor processor, ActionFrame frame)398             internal override void Execute(Processor processor, ActionFrame frame)
399             {
400                 if (frame.State == Initialized)
401                 {
402                     processor.OnInstructionExecute();
403                 }
404                 base.Execute(processor, frame);
405             }
406         }
407 
408         private class CallTemplateActionDbg : CallTemplateAction
409         {
410             private DbgData _dbgData;
GetDbgData(ActionFrame frame)411             internal override DbgData GetDbgData(ActionFrame frame) { return _dbgData; }
412 
Compile(Compiler compiler)413             internal override void Compile(Compiler compiler)
414             {
415                 _dbgData = new DbgData(compiler);
416                 base.Compile(compiler);
417             }
418 
Execute(Processor processor, ActionFrame frame)419             internal override void Execute(Processor processor, ActionFrame frame)
420             {
421                 if (frame.State == Initialized)
422                 {
423                     processor.OnInstructionExecute();
424                 }
425                 base.Execute(processor, frame);
426             }
427         }
428 
429         private class CommentActionDbg : CommentAction
430         {
431             private DbgData _dbgData;
GetDbgData(ActionFrame frame)432             internal override DbgData GetDbgData(ActionFrame frame) { return _dbgData; }
433 
Compile(Compiler compiler)434             internal override void Compile(Compiler compiler)
435             {
436                 _dbgData = new DbgData(compiler);
437                 base.Compile(compiler);
438             }
439 
Execute(Processor processor, ActionFrame frame)440             internal override void Execute(Processor processor, ActionFrame frame)
441             {
442                 if (frame.State == Initialized)
443                 {
444                     processor.OnInstructionExecute();
445                 }
446                 base.Execute(processor, frame);
447             }
448         }
449 
450         private class CopyActionDbg : CopyAction
451         {
452             private DbgData _dbgData;
GetDbgData(ActionFrame frame)453             internal override DbgData GetDbgData(ActionFrame frame) { return _dbgData; }
454 
Compile(Compiler compiler)455             internal override void Compile(Compiler compiler)
456             {
457                 _dbgData = new DbgData(compiler);
458                 base.Compile(compiler);
459             }
460 
Execute(Processor processor, ActionFrame frame)461             internal override void Execute(Processor processor, ActionFrame frame)
462             {
463                 if (frame.State == Initialized)
464                 {
465                     processor.OnInstructionExecute();
466                 }
467                 base.Execute(processor, frame);
468             }
469         }
470 
471         private class CopyOfActionDbg : CopyOfAction
472         {
473             private DbgData _dbgData;
GetDbgData(ActionFrame frame)474             internal override DbgData GetDbgData(ActionFrame frame) { return _dbgData; }
475 
Compile(Compiler compiler)476             internal override void Compile(Compiler compiler)
477             {
478                 _dbgData = new DbgData(compiler);
479                 base.Compile(compiler);
480             }
481 
Execute(Processor processor, ActionFrame frame)482             internal override void Execute(Processor processor, ActionFrame frame)
483             {
484                 if (frame.State == Initialized)
485                 {
486                     processor.OnInstructionExecute();
487                 }
488                 base.Execute(processor, frame);
489             }
490         }
491 
492         private class ElementActionDbg : ElementAction
493         {
494             private DbgData _dbgData;
GetDbgData(ActionFrame frame)495             internal override DbgData GetDbgData(ActionFrame frame) { return _dbgData; }
496 
Compile(Compiler compiler)497             internal override void Compile(Compiler compiler)
498             {
499                 _dbgData = new DbgData(compiler);
500                 base.Compile(compiler);
501             }
502 
Execute(Processor processor, ActionFrame frame)503             internal override void Execute(Processor processor, ActionFrame frame)
504             {
505                 if (frame.State == Initialized)
506                 {
507                     processor.OnInstructionExecute();
508                 }
509                 base.Execute(processor, frame);
510             }
511         }
512 
513         private class ForEachActionDbg : ForEachAction
514         {
515             private DbgData _dbgData;
GetDbgData(ActionFrame frame)516             internal override DbgData GetDbgData(ActionFrame frame) { return _dbgData; }
517 
Compile(Compiler compiler)518             internal override void Compile(Compiler compiler)
519             {
520                 _dbgData = new DbgData(compiler);
521                 base.Compile(compiler);
522             }
523 
Execute(Processor processor, ActionFrame frame)524             internal override void Execute(Processor processor, ActionFrame frame)
525             {
526                 if (frame.State == Initialized)
527                 {
528                     processor.PushDebuggerStack();
529                     processor.OnInstructionExecute();
530                 }
531                 base.Execute(processor, frame);
532                 if (frame.State == Finished)
533                 {
534                     processor.PopDebuggerStack();
535                 }
536             }
537         }
538 
539         private class IfActionDbg : IfAction
540         {
IfActionDbg(ConditionType type)541             internal IfActionDbg(ConditionType type) : base(type) { }
542 
543             private DbgData _dbgData;
GetDbgData(ActionFrame frame)544             internal override DbgData GetDbgData(ActionFrame frame) { return _dbgData; }
545 
Compile(Compiler compiler)546             internal override void Compile(Compiler compiler)
547             {
548                 _dbgData = new DbgData(compiler);
549                 base.Compile(compiler);
550             }
551 
Execute(Processor processor, ActionFrame frame)552             internal override void Execute(Processor processor, ActionFrame frame)
553             {
554                 if (frame.State == Initialized)
555                 {
556                     processor.OnInstructionExecute();
557                 }
558                 base.Execute(processor, frame);
559             }
560         }
561 
562         private class MessageActionDbg : MessageAction
563         {
564             private DbgData _dbgData;
GetDbgData(ActionFrame frame)565             internal override DbgData GetDbgData(ActionFrame frame) { return _dbgData; }
566 
Compile(Compiler compiler)567             internal override void Compile(Compiler compiler)
568             {
569                 _dbgData = new DbgData(compiler);
570                 base.Compile(compiler);
571             }
572 
Execute(Processor processor, ActionFrame frame)573             internal override void Execute(Processor processor, ActionFrame frame)
574             {
575                 if (frame.State == Initialized)
576                 {
577                     processor.OnInstructionExecute();
578                 }
579                 base.Execute(processor, frame);
580             }
581         }
582 
583         private class NewInstructionActionDbg : NewInstructionAction
584         {
585             private DbgData _dbgData;
GetDbgData(ActionFrame frame)586             internal override DbgData GetDbgData(ActionFrame frame) { return _dbgData; }
587 
Compile(Compiler compiler)588             internal override void Compile(Compiler compiler)
589             {
590                 _dbgData = new DbgData(compiler);
591                 base.Compile(compiler);
592             }
593 
Execute(Processor processor, ActionFrame frame)594             internal override void Execute(Processor processor, ActionFrame frame)
595             {
596                 if (frame.State == Initialized)
597                 {
598                     processor.OnInstructionExecute();
599                 }
600                 base.Execute(processor, frame);
601             }
602         }
603 
604         private class NumberActionDbg : NumberAction
605         {
606             private DbgData _dbgData;
GetDbgData(ActionFrame frame)607             internal override DbgData GetDbgData(ActionFrame frame) { return _dbgData; }
608 
Compile(Compiler compiler)609             internal override void Compile(Compiler compiler)
610             {
611                 _dbgData = new DbgData(compiler);
612                 base.Compile(compiler);
613             }
614 
Execute(Processor processor, ActionFrame frame)615             internal override void Execute(Processor processor, ActionFrame frame)
616             {
617                 if (frame.State == Initialized)
618                 {
619                     processor.OnInstructionExecute();
620                 }
621                 base.Execute(processor, frame);
622             }
623         }
624 
625         private class ProcessingInstructionActionDbg : ProcessingInstructionAction
626         {
627             private DbgData _dbgData;
GetDbgData(ActionFrame frame)628             internal override DbgData GetDbgData(ActionFrame frame) { return _dbgData; }
629 
Compile(Compiler compiler)630             internal override void Compile(Compiler compiler)
631             {
632                 _dbgData = new DbgData(compiler);
633                 base.Compile(compiler);
634             }
635 
Execute(Processor processor, ActionFrame frame)636             internal override void Execute(Processor processor, ActionFrame frame)
637             {
638                 if (frame.State == Initialized)
639                 {
640                     processor.OnInstructionExecute();
641                 }
642                 base.Execute(processor, frame);
643             }
644         }
645 
646         private class RootActionDbg : RootAction
647         {
648             private DbgData _dbgData;
GetDbgData(ActionFrame frame)649             internal override DbgData GetDbgData(ActionFrame frame) { return _dbgData; }
650 
651             // SxS: This method does not take any resource name and does not expose any resources to the caller.
652             // It's OK to suppress the SxS warning.
Compile(Compiler compiler)653             internal override void Compile(Compiler compiler)
654             {
655                 _dbgData = new DbgData(compiler);
656                 base.Compile(compiler);
657 
658                 Debug.Assert(compiler.Debugger != null);
659                 string builtIn = compiler.Debugger.GetBuiltInTemplatesUri();
660                 if (builtIn != null && builtIn.Length != 0)
661                 {
662                     compiler.AllowBuiltInMode = true;
663                     builtInSheet = compiler.RootAction.CompileImport(compiler, compiler.ResolveUri(builtIn), int.MaxValue);
664                     compiler.AllowBuiltInMode = false;
665                 }
666 
667                 _dbgData.ReplaceVariables(((DbgCompiler)compiler).GlobalVariables);
668             }
669 
Execute(Processor processor, ActionFrame frame)670             internal override void Execute(Processor processor, ActionFrame frame)
671             {
672                 if (frame.State == Initialized)
673                 {
674                     processor.PushDebuggerStack();
675                     processor.OnInstructionExecute();
676                     processor.PushDebuggerStack();
677                 }
678                 base.Execute(processor, frame);
679                 if (frame.State == Finished)
680                 {
681                     processor.PopDebuggerStack();
682                     processor.PopDebuggerStack();
683                 }
684             }
685         }
686 
687         private class SortActionDbg : SortAction
688         {
689             private DbgData _dbgData;
GetDbgData(ActionFrame frame)690             internal override DbgData GetDbgData(ActionFrame frame) { return _dbgData; }
691 
Compile(Compiler compiler)692             internal override void Compile(Compiler compiler)
693             {
694                 _dbgData = new DbgData(compiler);
695                 base.Compile(compiler);
696             }
697 
Execute(Processor processor, ActionFrame frame)698             internal override void Execute(Processor processor, ActionFrame frame)
699             {
700                 if (frame.State == Initialized)
701                 {
702                     processor.OnInstructionExecute();
703                 }
704                 base.Execute(processor, frame);
705             }
706         }
707 
708         private class TemplateActionDbg : TemplateAction
709         {
710             private DbgData _dbgData;
GetDbgData(ActionFrame frame)711             internal override DbgData GetDbgData(ActionFrame frame) { return _dbgData; }
712 
Compile(Compiler compiler)713             internal override void Compile(Compiler compiler)
714             {
715                 _dbgData = new DbgData(compiler);
716                 base.Compile(compiler);
717             }
718 
Execute(Processor processor, ActionFrame frame)719             internal override void Execute(Processor processor, ActionFrame frame)
720             {
721                 if (frame.State == Initialized)
722                 {
723                     processor.PushDebuggerStack();
724                     processor.OnInstructionExecute();
725                 }
726                 base.Execute(processor, frame);
727                 if (frame.State == Finished)
728                 {
729                     processor.PopDebuggerStack();
730                 }
731             }
732         }
733 
734         private class TextActionDbg : TextAction
735         {
736             private DbgData _dbgData;
GetDbgData(ActionFrame frame)737             internal override DbgData GetDbgData(ActionFrame frame) { return _dbgData; }
738 
Compile(Compiler compiler)739             internal override void Compile(Compiler compiler)
740             {
741                 _dbgData = new DbgData(compiler);
742                 base.Compile(compiler);
743             }
744 
Execute(Processor processor, ActionFrame frame)745             internal override void Execute(Processor processor, ActionFrame frame)
746             {
747                 if (frame.State == Initialized)
748                 {
749                     processor.OnInstructionExecute();
750                 }
751                 base.Execute(processor, frame);
752             }
753         }
754 
755         private class UseAttributeSetsActionDbg : UseAttributeSetsAction
756         {
757             private DbgData _dbgData;
GetDbgData(ActionFrame frame)758             internal override DbgData GetDbgData(ActionFrame frame) { return _dbgData; }
759 
Compile(Compiler compiler)760             internal override void Compile(Compiler compiler)
761             {
762                 _dbgData = new DbgData(compiler);
763                 base.Compile(compiler);
764             }
765 
Execute(Processor processor, ActionFrame frame)766             internal override void Execute(Processor processor, ActionFrame frame)
767             {
768                 if (frame.State == Initialized)
769                 {
770                     processor.OnInstructionExecute();
771                 }
772                 base.Execute(processor, frame);
773             }
774         }
775 
776         private class ValueOfActionDbg : ValueOfAction
777         {
778             private DbgData _dbgData;
GetDbgData(ActionFrame frame)779             internal override DbgData GetDbgData(ActionFrame frame) { return _dbgData; }
780 
Compile(Compiler compiler)781             internal override void Compile(Compiler compiler)
782             {
783                 _dbgData = new DbgData(compiler);
784                 base.Compile(compiler);
785             }
786 
Execute(Processor processor, ActionFrame frame)787             internal override void Execute(Processor processor, ActionFrame frame)
788             {
789                 if (frame.State == Initialized)
790                 {
791                     processor.OnInstructionExecute();
792                 }
793                 base.Execute(processor, frame);
794             }
795         }
796 
797         private class VariableActionDbg : VariableAction
798         {
VariableActionDbg(VariableType type)799             internal VariableActionDbg(VariableType type) : base(type) { }
800             private DbgData _dbgData;
GetDbgData(ActionFrame frame)801             internal override DbgData GetDbgData(ActionFrame frame) { return _dbgData; }
802 
Compile(Compiler compiler)803             internal override void Compile(Compiler compiler)
804             {
805                 _dbgData = new DbgData(compiler);
806                 base.Compile(compiler);
807                 ((DbgCompiler)compiler).DefineVariable(this);
808             }
809 
Execute(Processor processor, ActionFrame frame)810             internal override void Execute(Processor processor, ActionFrame frame)
811             {
812                 if (frame.State == Initialized)
813                 {
814                     processor.OnInstructionExecute();
815                 }
816                 base.Execute(processor, frame);
817             }
818         }
819 
820         private class WithParamActionDbg : WithParamAction
821         {
822             private DbgData _dbgData;
GetDbgData(ActionFrame frame)823             internal override DbgData GetDbgData(ActionFrame frame) { return _dbgData; }
824 
Compile(Compiler compiler)825             internal override void Compile(Compiler compiler)
826             {
827                 _dbgData = new DbgData(compiler);
828                 base.Compile(compiler);
829             }
830 
Execute(Processor processor, ActionFrame frame)831             internal override void Execute(Processor processor, ActionFrame frame)
832             {
833                 if (frame.State == Initialized)
834                 {
835                     processor.OnInstructionExecute();
836                 }
837                 base.Execute(processor, frame);
838             }
839         }
840 
841         // ---------------- Events: ---------------
842 
843         private class BeginEventDbg : BeginEvent
844         {
845             private DbgData _dbgData;
846             internal override DbgData DbgData { get { return _dbgData; } }
847 
BeginEventDbg(Compiler compiler)848             public BeginEventDbg(Compiler compiler) : base(compiler)
849             {
850                 _dbgData = new DbgData(compiler);
851             }
Output(Processor processor, ActionFrame frame)852             public override bool Output(Processor processor, ActionFrame frame)
853             {
854                 this.OnInstructionExecute(processor);
855                 return base.Output(processor, frame);
856             }
857         }
858 
859         private class TextEventDbg : TextEvent
860         {
861             private DbgData _dbgData;
862             internal override DbgData DbgData { get { return _dbgData; } }
863 
TextEventDbg(Compiler compiler)864             public TextEventDbg(Compiler compiler) : base(compiler)
865             {
866                 _dbgData = new DbgData(compiler);
867             }
Output(Processor processor, ActionFrame frame)868             public override bool Output(Processor processor, ActionFrame frame)
869             {
870                 this.OnInstructionExecute(processor);
871                 return base.Output(processor, frame);
872             }
873         }
874     }
875 }
876