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