- Timestamp:
- Apr 5, 2012, 2:03:52 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 1 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Compiler/Target/Delphi/UTargetDelphi.pas
r42 r50 6 6 7 7 uses 8 Classes, SysUtils, UTarget ;8 Classes, SysUtils, UTarget, UExecutor; 9 9 10 10 type 11 12 { TExecutorDelphi } 13 14 TExecutorDelphi = class(TExecutor) 15 procedure Run; override; 16 end; 11 17 12 18 { TTargetDelphi } … … 22 28 UProducerPascal; 23 29 30 { TExecutorDelphi } 31 32 procedure TExecutorDelphi.Run; 33 begin 34 35 end; 36 24 37 { TTargetDelphi } 25 38 -
trunk/Compiler/Target/Interpretter/UTargetInterpretter.pas
r46 r50 6 6 7 7 uses 8 Classes, SysUtils, UTarget, UExecutor ;8 Classes, SysUtils, UTarget, UExecutor, USourceCode, Dialogs; 9 9 10 10 type 11 12 11 { TTargetInterpretter } 13 12 14 13 TTargetInterpretter = class(TTarget) 15 14 constructor Create; override; 15 destructor Destroy; override; 16 16 end; 17 17 18 { TExecutorInterpretter } 19 18 20 TExecutorInterpretter = class(TExecutor) 19 21 private 22 procedure RunCommand(Command: TCommand); 23 procedure RunBeginEnd(BeginEnd: TBeginEnd); 24 procedure RunWhileDo(WhileDo: TWhileDo); 25 procedure RunRepeatUntil(RepeatUntil: TRepeatUntil); 26 procedure RunIfThenElse(IfThenElse: TIfThenElse); 27 procedure RunAssignment(Assignment: TAssignment); 28 procedure RunCaseOfEnd(CaseOfEnd: TCaseOfEnd); 29 procedure RunFunction(FunctionCall: TFunctionCall); 30 procedure RunForToDo(ForToDo: TForToDo); 31 function Evaluate(Expression: TExpression): Boolean; 32 public 33 procedure Run; override; 20 34 end; 21 35 36 22 37 implementation 38 39 uses 40 UCompiler; 41 42 resourcestring 43 SUnknownCommandType = 'Unknown command type'; 44 45 { TExecutorInterpretter } 46 47 procedure TExecutorInterpretter.RunCommand(Command: TCommand); 48 begin 49 if Command is TBeginEnd then RunBeginEnd(TBeginEnd(Command)) 50 else if Command is TWhileDo then RunWhileDo(TWhileDo(Command)) 51 else if Command is TRepeatUntil then RunRepeatUntil(TRepeatUntil(Command)) 52 else if Command is TIfThenElse then RunIfThenElse(TIfThenElse(Command)) 53 else if Command is TAssignment then RunAssignment(TAssignment(Command)) 54 else if Command is TCaseOfEnd then RunCaseOfEnd(TCaseOfEnd(Command)) 55 else if Command is TFunctionCall then RunFunction(TFunctionCall(Command)) 56 else if Command is TForToDo then RunForToDo(TForToDo(Command)) 57 else raise Exception.Create(SUnknownCommandType); 58 end; 59 60 procedure TExecutorInterpretter.RunBeginEnd(BeginEnd: TBeginEnd); 61 var 62 I: Integer; 63 begin 64 for I := 0 to BeginEnd.Commands.Count - 1 do 65 RunCommand(TCommand(BeginEnd.Commands[I])) 66 end; 67 68 procedure TExecutorInterpretter.RunWhileDo(WhileDo: TWhileDo); 69 begin 70 while Evaluate(WhileDo.Condition) do RunBeginEnd(WhileDo.CommonBlock.Code); 71 end; 72 73 procedure TExecutorInterpretter.RunRepeatUntil(RepeatUntil: TRepeatUntil); 74 begin 75 repeat 76 RunBeginEnd(RepeatUntil.CommonBlock.Code); 77 until Evaluate(RepeatUntil.Condition); 78 end; 79 80 procedure TExecutorInterpretter.RunIfThenElse(IfThenElse: TIfThenElse); 81 begin 82 if Evaluate(IfThenElse.Condition) then RunCommand(IfThenElse.Command) 83 else RunCommand(IfThenElse.ElseCommand); 84 end; 85 86 procedure TExecutorInterpretter.RunAssignment(Assignment: TAssignment); 87 begin 88 //Assignment.Target := Assignment.Source; 89 end; 90 91 procedure TExecutorInterpretter.RunCaseOfEnd(CaseOfEnd: TCaseOfEnd); 92 var 93 I: Integer; 94 begin 95 (* I := 0; 96 while (I < CaseOfEnd.Branches.Count) and 97 if TCaseOfEndBranche(CaseOfEnd.Branches[I]).Constant = 98 Evaluate(CaseOfEnd.Expression) do 99 Inc(I); 100 if (I < CaseOfEnd.Branches.Count) then 101 RunCommand(TCaseOfEndBranche(CaseOfEnd.Branches[I]).Command) 102 else RunCommand(CaseOfEnd.ElseCommand); *) 103 end; 104 105 procedure TExecutorInterpretter.RunFunction(FunctionCall: TFunctionCall); 106 begin 107 RunBeginEnd(FunctionCall.FunctionRef.Code); 108 end; 109 110 procedure TExecutorInterpretter.RunForToDo(ForToDo: TForToDo); 111 var 112 I: Integer; 113 begin 114 (* for I := 0 to ForToDo.Start to ForToDo.Stop do begin 115 ForToDo.ControlVariable.; 116 RunCommand(ForToDo.Command); 117 end; *) 118 end; 119 120 function TExecutorInterpretter.Evaluate(Expression: TExpression): Boolean; 121 begin 122 // case Expression.NodeType of 123 // ntConstant: ; 124 // end; 125 end; 126 127 procedure TExecutorInterpretter.Run; 128 begin 129 ShowMessage(TModuleProgram(TCompiler(TTarget(Target).Compiler).Analyzer.ProgramCode.Modules[0]).Name); 130 with TModuleProgram(TCompiler(TTarget(Target).Compiler).Analyzer.ProgramCode.Modules[0]) do begin 131 RunBeginEnd(Body.Code); 132 end; 133 end; 23 134 24 135 { TTargetInterpretter } … … 30 141 Name := 'Interpretter'; 31 142 Executor := TExecutorInterpretter.Create; 143 Executor.Target := Self; 144 end; 145 146 destructor TTargetInterpretter.Destroy; 147 begin 148 FreeAndNil(Executor); 149 inherited Destroy; 32 150 end; 33 151 -
trunk/Compiler/UCompiler.pas
r49 r50 205 205 if FTarget = AValue then Exit; 206 206 FTarget := AValue; 207 FTarget.Producer.OnWriteTarget := WriteTarget; 207 FTarget.Compiler := Self; 208 if Assigned(FTarget.Producer) then 209 FTarget.Producer.OnWriteTarget := WriteTarget; 208 210 end; 209 211 -
trunk/Compiler/UExecutor.pas
r43 r50 18 18 procedure SetRunState(AValue: TRunState); 19 19 public 20 Target: TObject; // TTarget; 20 21 procedure Run; virtual; abstract; 21 22 procedure Pause; virtual; abstract; -
trunk/Compiler/UTarget.pas
r46 r50 9 9 10 10 type 11 12 11 { TTarget } 13 12 … … 18 17 Producer: TProducer; 19 18 Executor: TExecutor; 19 Compiler: TObject; //TCompiler 20 20 constructor Create; virtual; 21 21 destructor Destroy; override; -
trunk/Demos/Generics/Generics.tppr
r47 r50 2 2 <Project> 3 3 <Name>Generics</Name> 4 <MainSource>Generics.dpr</MainSource> 4 5 <Files> 5 6 <File> 6 <FileName>Generics. pas</FileName>7 <FileName>Generics.dpr</FileName> 7 8 </File> 8 9 <File> -
trunk/IDE/Forms/UFormMain.lfm
r49 r50 5 5 Width = 695 6 6 Caption = 'Transpascal IDE' 7 ClientHeight = 4 767 ClientHeight = 482 8 8 ClientWidth = 695 9 9 Font.Height = -11 10 10 Font.Name = 'Tahoma' 11 Menu = MainMenu 111 Menu = MainMenu 12 12 OnClose = FormClose 13 13 OnCreate = FormCreate … … 20 20 Left = 0 21 21 Height = 5 22 Top = 47 122 Top = 477 23 23 Width = 695 24 24 Align = alBottom … … 88 88 object Splitter1: TSplitter 89 89 Left = 490 90 Height = 3 3990 Height = 345 91 91 Top = 26 92 92 Width = 5 … … 96 96 object PageControlRight: TPageControl 97 97 Left = 495 98 Height = 3 3998 Height = 345 99 99 Top = 26 100 100 Width = 200 … … 117 117 Left = 0 118 118 Height = 101 119 Top = 37 0119 Top = 376 120 120 Width = 695 121 121 ActivePage = TabSheetMessages … … 135 135 Left = 0 136 136 Height = 5 137 Top = 3 65137 Top = 371 138 138 Width = 695 139 139 Align = alBottom … … 142 142 object PageControlMain: TPageControl 143 143 Left = 0 144 Height = 3 39144 Height = 345 145 145 Top = 26 146 146 Width = 490 … … 156 156 end 157 157 end 158 object MainMenu 1: TMainMenu158 object MainMenu: TMainMenu 159 159 Images = ImageList1 160 160 left = 115 … … 491 491 object MenuItem25: TMenuItem 492 492 Action = APause 493 Bitmap.Data = { 494 36040000424D3604000000000000360000002800000010000000100000000100 495 2000000000000004000064000000640000000000000000000000000000000000 496 0000000000000000000000000000000000000000000000000000000000000000 497 0000000000000000000000000000000000000000000000000000000000000000 498 0000000000000000000000000000000000000000000000000000000000000000 499 0000000000000000000000000000000000000000000000000000000000000000 500 0000000000008A2C0FBF842A0EFF7C260BFF7A250AFF00000000000000008A2C 501 0FBF842A0EFF7C260BFF7A250AFF000000000000000000000000000000000000 502 000000000000993414BFCF6F50FFDA886DFF7F270BFF00000000000000009934 503 14BFCF6F50FFDA886DFF7F270BFF000000000000000000000000000000000000 504 000000000000AA3A18BFD37558FFDC8B71FF8A2C0FFF0000000000000000AA3A 505 18BFD37558FFDC8B71FF8A2C0FFF000000000000000000000000000000000000 506 000000000000B5401DBFD57C61FFDE9077FF993414FF0000000000000000B540 507 1DBFD57C61FFDE9077FF993414FF000000000000000000000000000000000000 508 000000000000BF4A27C0D9856BFFDF957EFFAA3A18FF0000000000000000BF4A 509 27C0D9856BFFDF957EFFAA3A18FF000000000000000000000000000000000000 510 000000000000B95435BFE29984FFE29A85FFB5401DFF0000000000000000B954 511 35BFE29984FFE29A85FFB5401DFF000000000000000000000000000000000000 512 000000000000C86A4DBFE7A590FFE5A18BFFBF4A27FF0000000000000000C86A 513 4DBFE7A590FFE5A18BFFBF4A27FF000000000000000000000000000000000000 514 000000000000CD6849BFE19881FFE8A793FFC45432FF0000000000000000CD68 515 49BFE19881FFE8A793FFC45432FF000000000000000000000000000000000000 516 000000000000D27457BFE5A18BFFEBAF9AFFC95E3EFF0000000000000000D274 517 57BFE5A18BFFEBAF9AFFC95E3EFF000000000000000000000000000000000000 518 000000000000D57C61BFE8A793FFEDB6A3FFCD6849FF0000000000000000D57C 519 61BFE8A793FFEDB6A3FFCD6849FF000000000000000000000000000000000000 520 000000000000D9866CBFEBB09DFFF0BBABFFD27457FF0000000000000000D986 521 6CBFEBB09DFFF0BBABFFD27457FF000000000000000000000000000000000000 522 000000000000DE9077BFDA8A70FFD88367FFD57C61FF0000000000000000DE90 523 77BFDA8A70FFD88367FFD57C61FF000000000000000000000000000000000000 524 0000000000000000000000000000000000000000000000000000000000000000 525 0000000000000000000000000000000000000000000000000000000000000000 526 0000000000000000000000000000000000000000000000000000000000000000 527 0000000000000000000000000000000000000000000000000000 528 } 493 529 end 494 530 object MenuItem26: TMenuItem 495 531 Action = AStop 532 Bitmap.Data = { 533 36040000424D3604000000000000360000002800000010000000100000000100 534 2000000000000004000064000000640000000000000000000000000000000000 535 0000000000000000000000000000000000000000000000000000000000000000 536 0000000000000000000000000000000000000000000000000000000000000000 537 0000000000000000000000000000000000000000000000000000000000000000 538 0000000000000000000000000000000000000000000000000000000000000000 539 0000000000000000000000000000000000000000000000000000000000000000 540 0000000000000000000000000000000000000000000000000000000000000000 541 0000000000000000000000000000000000000000000000000000000000000000 542 0000000000000000000000000000000000000000000000000000000000000000 543 000000000000000000000000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000 544 FFFF0000FFFF0000FFFF00000000000000000000000000000000000000000000 545 000000000000000000000000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000 546 FFFF0000FFFF0000FFFF00000000000000000000000000000000000000000000 547 000000000000000000000000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000 548 FFFF0000FFFF0000FFFF00000000000000000000000000000000000000000000 549 000000000000000000000000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000 550 FFFF0000FFFF0000FFFF00000000000000000000000000000000000000000000 551 000000000000000000000000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000 552 FFFF0000FFFF0000FFFF00000000000000000000000000000000000000000000 553 000000000000000000000000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000 554 FFFF0000FFFF0000FFFF00000000000000000000000000000000000000000000 555 000000000000000000000000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000 556 FFFF0000FFFF0000FFFF00000000000000000000000000000000000000000000 557 000000000000000000000000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000 558 FFFF0000FFFF0000FFFF00000000000000000000000000000000000000000000 559 0000000000000000000000000000000000000000000000000000000000000000 560 0000000000000000000000000000000000000000000000000000000000000000 561 0000000000000000000000000000000000000000000000000000000000000000 562 0000000000000000000000000000000000000000000000000000000000000000 563 0000000000000000000000000000000000000000000000000000000000000000 564 0000000000000000000000000000000000000000000000000000000000000000 565 0000000000000000000000000000000000000000000000000000000000000000 566 0000000000000000000000000000000000000000000000000000 567 } 496 568 end 497 569 object MenuItem32: TMenuItem … … 581 653 object MenuItem33: TMenuItem 582 654 Action = AHelp 655 Bitmap.Data = { 656 36040000424D3604000000000000360000002800000010000000100000000100 657 2000000000000004000064000000640000000000000000000000000000000000 658 0000000000000000000000000000000000000000000000000000000000000000 659 0000000000000000000000000000000000000000000000000000000000000000 660 00000000000000000000916429FF855A24FF885015FF824A1DFF7E4719FF7944 661 17FF583C0EFF49340DFF00000000000000000000000000000000000000000000 662 000000000000A1692CFFC08858FFE0C9B4FFF7F1ECFFFEFDFCFFFEFDFCFFF5F0 663 ECFFDCC9B8FF9E7857FF473108FF000000000000000000000000000000000000 664 0000B2702BFFDBAB80FFF8EFE7FFE2BBA6FFCC7E56FFC15823FFC05722FFC97F 665 56FFDEBAA7FFF2EBE7FFB39376FF483108FF000000000000000000000000B677 666 34FFD6996BFFF9F0E7FFDDA488FFC75013FFC04E11FFDCA688FFFFFEFEFFB549 667 11FFB64A10FFD59E82FFF3ECE7FF9A7352FF49340DFF0000000000000000B479 668 3AFFEFD6C1FFEDC5B2FFDD5A1AFFD55617FFD25313FFD87D4DFFE3A686FFBB4C 669 11FFB34A12FFB64A10FFDEB9A6FFDCC9B8FF563C0DFF0000000000000000CD7F 670 45FFFCF4EDFFEC9772FFE86021FFE05A1DFFDB5819FFEDAA89FFFFFEFEFFC84E 671 12FFB94C11FFB34C13FFC77B53FFF6F0ECFF7A4319FF0000000000000000CD81 672 47FFFFFEFEFFF87A46FFF96829FFF66525FFF16020FFF18653FFFFFEFEFFF0BF 673 A8FFC55A24FFB64C15FFB75724FFFEFEFDFF7F481AFF0000000000000000CD84 674 4EFFFFFEFEFFFC814CFFFF7031FFFF6B2CFFFD6928FFF86523FFF49265FFFDF5 675 F1FFF4D4C5FFC65018FFBA5927FFFEFEFDFF834A1CFF0000000000000000D183 676 4CFFFCF7F1FFFAA582FFFF733AFFFF844EFFFFAE8AFFFE6C2DFFF76727FFF192 677 68FFFFFEFEFFE98354FFD78560FFF8F1ECFF81551FFF0000000000000000C483 678 41FFF0DAC3FFFAD1C0FFFF7940FFFF986EFFFFFEFEFFFFC9B2FFFD9164FFFAC6 679 AFFFFEF5F1FFF5773DFFEDC5B2FFE4CBB3FF905D21FF0000000000000000C484 680 45FFDCA277FFFCF4EDFFFABFA6FFFF7A43FFFFBB9EFFFFF6F3FFFFFEFEFFFEED 681 E5FFFA9970FFF3B69CFFF8F0E6FFBB8B56FF986426FF00000000000000000000 682 0000C48443FFE5B999FFFCF4EDFFFBD2C1FFFAA887FFFD8757FFFD8454FFF8A5 683 82FFF7CEBDFFFAF1E7FFD2A77AFFA36A2AFF0000000000000000000000000000 684 000000000000C58442FFDCA277FFF3DAC7FFFCF7F1FFFFFEFEFFFFFEFEFFFCF4 685 EDFFF1D6C0FFC7935DFFA66F33FF000000000000000000000000000000000000 686 00000000000000000000C58444FFC28342FFD89C6DFFD69668FFD49463FFD696 687 68FFB2793CFFB1783BFF00000000000000000000000000000000000000000000 688 0000000000000000000000000000000000000000000000000000000000000000 689 0000000000000000000000000000000000000000000000000000 690 } 583 691 end 584 692 object MenuItem10: TMenuItem … … 648 756 Caption = 'Run' 649 757 ImageIndex = 13 758 OnExecute = ARunExecute 650 759 ShortCut = 120 651 760 end … … 703 812 Caption = 'Stop' 704 813 ImageIndex = 0 814 OnExecute = AStopExecute 705 815 ShortCut = 16497 706 816 end … … 709 819 Caption = 'Pause' 710 820 ImageIndex = 8 821 OnExecute = APauseExecute 711 822 end 712 823 object AReset: TAction 713 824 Category = 'Run' 714 825 Caption = 'Reset' 826 OnExecute = AResetExecute 715 827 end 716 828 object AStepOver: TAction 717 829 Category = 'Run' 718 830 Caption = 'Step over' 831 OnExecute = AStepOverExecute 719 832 ShortCut = 119 720 833 end … … 722 835 Category = 'Run' 723 836 Caption = 'Step in' 837 OnExecute = AStepInExecute 724 838 ShortCut = 118 725 839 end … … 727 841 Category = 'Run' 728 842 Caption = 'Step out' 843 OnExecute = AStepOutExecute 729 844 ShortCut = 8311 730 845 end … … 732 847 Category = 'Run' 733 848 Caption = 'Run to cursor' 849 OnExecute = ARunToCursorExecute 734 850 ShortCut = 115 735 851 end -
trunk/IDE/Forms/UFormMain.pas
r49 r50 57 57 DebugLog1: TDebugLog; 58 58 ImageList1: TImageList; 59 MainMenu 1: TMainMenu;59 MainMenu: TMainMenu; 60 60 MenuItem1: TMenuItem; 61 61 MenuItem10: TMenuItem; … … 122 122 procedure AExitExecute(Sender: TObject); 123 123 procedure AHomepageExecute(Sender: TObject); 124 procedure APauseExecute(Sender: TObject); 124 125 procedure AProjectCloseExecute(Sender: TObject); 125 126 procedure AProjectNewExecute(Sender: TObject); … … 128 129 procedure AProjectSaveExecute(Sender: TObject); 129 130 procedure ABuildExecute(Sender: TObject); 131 procedure AResetExecute(Sender: TObject); 132 procedure ARunExecute(Sender: TObject); 133 procedure ARunToCursorExecute(Sender: TObject); 134 procedure AStepInExecute(Sender: TObject); 135 procedure AStepOutExecute(Sender: TObject); 136 procedure AStepOverExecute(Sender: TObject); 137 procedure AStopExecute(Sender: TObject); 130 138 procedure AViewCodeTreeExecute(Sender: TObject); 131 139 procedure AViewCompiledSoruceExecute(Sender: TObject); … … 254 262 end; 255 263 264 procedure TFormMain.AResetExecute(Sender: TObject); 265 begin 266 Compiler.Target.Executor.Reset; 267 end; 268 269 procedure TFormMain.ARunExecute(Sender: TObject); 270 begin 271 ABuildExecute(Self); 272 Compiler.Target.Executor.Run; 273 end; 274 275 procedure TFormMain.ARunToCursorExecute(Sender: TObject); 276 begin 277 Compiler.Target.Executor.RunToCursor(0); // determine position 278 end; 279 280 procedure TFormMain.AStepInExecute(Sender: TObject); 281 begin 282 Compiler.Target.Executor.StepIn; 283 end; 284 285 procedure TFormMain.AStepOutExecute(Sender: TObject); 286 begin 287 Compiler.Target.Executor.StepOut; 288 end; 289 290 procedure TFormMain.AStepOverExecute(Sender: TObject); 291 begin 292 Compiler.Target.Executor.StepOver; 293 end; 294 295 procedure TFormMain.AStopExecute(Sender: TObject); 296 begin 297 Compiler.Target.Executor.Stop; 298 end; 299 256 300 procedure TFormMain.AViewCodeTreeExecute(Sender: TObject); 257 301 begin … … 591 635 end; 592 636 637 procedure TFormMain.APauseExecute(Sender: TObject); 638 begin 639 Compiler.Target.Executor.Pause; 640 end; 641 593 642 procedure TFormMain.AProjectNewExecute(Sender: TObject); 594 643 var -
trunk/IDE/UProject.pas
r49 r50 83 83 Packages: TProjectPackageList; 84 84 BuildConfigs: TProjectBuildConfigList; 85 MainSource: TProjectFile; 85 86 procedure LoadFromFile(FileName: string); 86 87 procedure SaveToFile(FileName: string); … … 343 344 I: Integer; 344 345 Text: string; 346 MainSourceName: string; 345 347 begin 346 348 try … … 352 354 if Assigned(NewNode) then 353 355 Files.LoadFromXMLNode(NewNode); 356 357 NewNode := Doc.DocumentElement.FindNode('MainSource'); 358 if Assigned(NewNode) then begin 359 MainSourceName := UTF8Encode(NewNode.TextSource); 360 361 end; 362 354 363 NewNode := Doc.DocumentElement.FindNode('Packages'); 355 364 if Assigned(NewNode) then … … 375 384 AppendChild(RootNode); 376 385 with RootNode do begin 386 NewNode := CreateElement('MainSource'); 387 NewNode.TextContent := UTF8Decode(MainSource.FileName); 388 AppendChild(NewNode); 389 377 390 NewNode := CreateElement('Files'); 378 391 Files.SaveToXMLNode(NewNode);
Note:
See TracChangeset
for help on using the changeset viewer.