Changeset 49
- Timestamp:
- Mar 4, 2012, 5:26:20 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Compiler/UCompiler.pas
r47 r49 21 21 private 22 22 FAnalyzer: TAnalyzer; 23 FTarget: TTarget; 23 24 FOnErrorMessage: TErrorMessageEvent; 24 25 function GetSource(Name: string; var SourceCode: string): Boolean; 26 function WriteTarget(Name: string; TargetCode: string): Boolean; 25 27 procedure ErrorMessage(Text: string; Position: TPoint; FileName: string); 26 28 procedure SetAnalyzer(const AValue: TAnalyzer); 27 29 procedure AnalyzeAll; 28 30 procedure ProduceAll; 31 procedure SetTarget(AValue: TTarget); 29 32 public 30 33 AbstractCode: TProgram; 31 34 ErrorMessages: TListObject; 32 35 CompiledFolder: string; 33 Target: TTarget; 36 34 37 TargetFolder: string; 35 38 Targets: TListTarget; … … 43 46 write FOnErrorMessage; 44 47 property Analyzer: TAnalyzer read FAnalyzer write SetAnalyzer; 48 property Target: TTarget read FTarget write SetTarget; 45 49 end; 46 50 … … 53 57 resourcestring 54 58 SNothingToAnalyze = 'Nothing to analyze'; 59 SRewritingExistedTarget = 'Reqriting existing target file %s'; 55 60 56 61 { TCompiler } … … 113 118 end; 114 119 120 function TCompiler.WriteTarget(Name: string; TargetCode: string): Boolean; 121 var 122 I: Integer; 123 F: TFileStream; 124 begin 125 I := 0; 126 while (I < TargetFiles.Count) and (ExtractFileNameOnly(TargetFiles[I]) <> Name) do Inc(I); 127 if I >= TargetFiles.Count then begin 128 try 129 ForceDirectoriesUTF8(ExtractFileDir(Name)); 130 if FileExistsUTF8(Name) then 131 F := TFileStream.Create(UTF8Decode(Name), fmOpenWrite) 132 else F := TFileStream.Create(UTF8Decode(Name), fmCreate); 133 F.Size := 0; 134 if Length(TargetCode) > 0 then 135 F.Write(TargetCode[1], Length(TargetCode)); 136 Result := True; 137 TargetFiles.Add(Name); 138 finally 139 F.Free; 140 end; 141 end else begin 142 Result := False; 143 ErrorMessage(Format(SRewritingExistedTarget, [Name]), Point(0, 0), ''); 144 end; 145 end; 146 115 147 procedure TCompiler.ErrorMessage(Text: string; Position: TPoint; FileName: string); 116 148 var … … 160 192 Target.Producer.Produce(TModule(Modules[I])); 161 193 Target.Producer.AssignToStringList(ProducedCode); 162 TargetFileName := TargetFolder + DirectorySeparator + 163 CompiledFolder + DirectorySeparator + Target.Name + 164 DirectorySeparator + TModule(Modules[I]).TargetFile; 165 ForceDirectoriesUTF8(ExtractFileDir(TargetFileName)); 166 ProducedCode.SaveToFile(TargetFileName); 194 TargetFileName := TargetFolder + DirectorySeparator + TModule(Modules[I]).TargetFile; 195 if Assigned(Target.Producer.OnWriteTarget) then 196 Target.Producer.OnWriteTarget(TargetFileName, ProducedCode.Text); 167 197 end; 168 198 finally … … 171 201 end; 172 202 203 procedure TCompiler.SetTarget(AValue: TTarget); 204 begin 205 if FTarget = AValue then Exit; 206 FTarget := AValue; 207 FTarget.Producer.OnWriteTarget := WriteTarget; 208 end; 209 173 210 end. -
trunk/Compiler/UProducer.pas
r44 r49 10 10 type 11 11 12 TWriteTargetEvent = function (Name: string; Code: string): Boolean of object; 13 12 14 { TProducer } 13 15 14 16 TProducer = class 17 private 18 FOnWriteTarget: TWriteTargetEvent; 19 public 15 20 TextSource: TStringList; 16 21 IndentationLength: Integer; … … 23 28 constructor Create; 24 29 destructor Destroy; override; 30 property OnWriteTarget: TWriteTargetEvent read FOnWriteTarget write FOnWriteTarget; 25 31 end; 26 32 -
trunk/IDE/Forms/UFormMain.lfm
r48 r49 99 99 Top = 26 100 100 Width = 200 101 ActivePage = TabSheet CompiledProject101 ActivePage = TabSheetTargetProject 102 102 Align = alRight 103 103 TabIndex = 2 … … 110 110 Caption = 'Code Tree' 111 111 end 112 object TabSheet CompiledProject: TTabSheet112 object TabSheetTargetProject: TTabSheet 113 113 Caption = 'Target project' 114 114 end … … 579 579 object MenuItem9: TMenuItem 580 580 Caption = 'Help' 581 object MenuItem33: TMenuItem 582 Action = AHelp 583 end 581 584 object MenuItem10: TMenuItem 582 585 Action = AHomepage … … 584 587 object MenuItem11: TMenuItem 585 588 Action = AAbout 586 Bitmap.Data = {587 36040000424D3604000000000000360000002800000010000000100000000100588 2000000000000004000064000000640000000000000000000000000000000000589 0000000000000000000000000000000000000000000000000000000000000000590 0000000000000000000000000000000000000000000000000000000000000000591 00000000000000000000916429FF855A24FF885015FF824A1DFF7E4719FF7944592 17FF583C0EFF49340DFF00000000000000000000000000000000000000000000593 000000000000A1692CFFC08858FFE0C9B4FFF7F1ECFFFEFDFCFFFEFDFCFFF5F0594 ECFFDCC9B8FF9E7857FF473108FF000000000000000000000000000000000000595 0000B2702BFFDBAB80FFF8EFE7FFE2BBA6FFCC7E56FFC15823FFC05722FFC97F596 56FFDEBAA7FFF2EBE7FFB39376FF483108FF000000000000000000000000B677597 34FFD6996BFFF9F0E7FFDDA488FFC75013FFC04E11FFDCA688FFFFFEFEFFB549598 11FFB64A10FFD59E82FFF3ECE7FF9A7352FF49340DFF0000000000000000B479599 3AFFEFD6C1FFEDC5B2FFDD5A1AFFD55617FFD25313FFD87D4DFFE3A686FFBB4C600 11FFB34A12FFB64A10FFDEB9A6FFDCC9B8FF563C0DFF0000000000000000CD7F601 45FFFCF4EDFFEC9772FFE86021FFE05A1DFFDB5819FFEDAA89FFFFFEFEFFC84E602 12FFB94C11FFB34C13FFC77B53FFF6F0ECFF7A4319FF0000000000000000CD81603 47FFFFFEFEFFF87A46FFF96829FFF66525FFF16020FFF18653FFFFFEFEFFF0BF604 A8FFC55A24FFB64C15FFB75724FFFEFEFDFF7F481AFF0000000000000000CD84605 4EFFFFFEFEFFFC814CFFFF7031FFFF6B2CFFFD6928FFF86523FFF49265FFFDF5606 F1FFF4D4C5FFC65018FFBA5927FFFEFEFDFF834A1CFF0000000000000000D183607 4CFFFCF7F1FFFAA582FFFF733AFFFF844EFFFFAE8AFFFE6C2DFFF76727FFF192608 68FFFFFEFEFFE98354FFD78560FFF8F1ECFF81551FFF0000000000000000C483609 41FFF0DAC3FFFAD1C0FFFF7940FFFF986EFFFFFEFEFFFFC9B2FFFD9164FFFAC6610 AFFFFEF5F1FFF5773DFFEDC5B2FFE4CBB3FF905D21FF0000000000000000C484611 45FFDCA277FFFCF4EDFFFABFA6FFFF7A43FFFFBB9EFFFFF6F3FFFFFEFEFFFEED612 E5FFFA9970FFF3B69CFFF8F0E6FFBB8B56FF986426FF00000000000000000000613 0000C48443FFE5B999FFFCF4EDFFFBD2C1FFFAA887FFFD8757FFFD8454FFF8A5614 82FFF7CEBDFFFAF1E7FFD2A77AFFA36A2AFF0000000000000000000000000000615 000000000000C58442FFDCA277FFF3DAC7FFFCF7F1FFFFFEFEFFFFFEFEFFFCF4616 EDFFF1D6C0FFC7935DFFA66F33FF000000000000000000000000000000000000617 00000000000000000000C58444FFC28342FFD89C6DFFD69668FFD49463FFD696618 68FFB2793CFFB1783BFF00000000000000000000000000000000000000000000619 0000000000000000000000000000000000000000000000000000000000000000620 0000000000000000000000000000000000000000000000000000621 }622 589 end 623 590 end … … 633 600 ImageIndex = 10 634 601 OnExecute = AProjectNewExecute 602 ShortCut = 16462 635 603 end 636 604 object AProjectOpen: TAction … … 640 608 ImageIndex = 7 641 609 OnExecute = AProjectOpenExecute 610 ShortCut = 16463 642 611 end 643 612 object AProjectSave: TAction … … 673 642 ImageIndex = 4 674 643 OnExecute = AExitExecute 644 ShortCut = 16499 675 645 end 676 646 object ARun: TAction … … 682 652 object AAbout: TAction 683 653 Caption = 'About...' 684 ImageIndex = 5685 654 OnExecute = AAboutExecute 686 655 end … … 697 666 Category = 'View' 698 667 Caption = 'Object inspector' 668 ShortCut = 122 699 669 end 700 670 object AViewSourceEditor: TAction … … 732 702 Category = 'Run' 733 703 Caption = 'Stop' 704 ImageIndex = 0 734 705 ShortCut = 16497 735 706 end … … 737 708 Category = 'Run' 738 709 Caption = 'Pause' 710 ImageIndex = 8 739 711 end 740 712 object AReset: TAction … … 761 733 Caption = 'Run to cursor' 762 734 ShortCut = 115 735 end 736 object AHelp: TAction 737 Caption = 'Help' 738 ImageIndex = 5 739 ShortCut = 112 763 740 end 764 741 end -
trunk/IDE/Forms/UFormMain.lrt
r48 r49 2 2 TFORMMAIN.TABSHEETPROJECT.CAPTION=Project 3 3 TFORMMAIN.TABSHEETCODETREE.CAPTION=Code Tree 4 TFORMMAIN.TABSHEET COMPILEDPROJECT.CAPTION=Target project4 TFORMMAIN.TABSHEETTARGETPROJECT.CAPTION=Target project 5 5 TFORMMAIN.TABSHEETMESSAGES.CAPTION=Messages 6 6 TFORMMAIN.TABSHEETBREAKPOINTS.CAPTION=Breakpoints … … 45 45 TFORMMAIN.ASTEPOUT.CAPTION=Step out 46 46 TFORMMAIN.ARUNTOCURSOR.CAPTION=Run to cursor 47 TFORMMAIN.AHELP.CAPTION=Help -
trunk/IDE/Forms/UFormMain.pas
r48 r49 28 28 TFormMain = class(TForm) 29 29 ABuild: TAction; 30 AHelp: TAction; 30 31 ARunToCursor: TAction; 31 32 AStepOut: TAction; … … 82 83 MenuItem31: TMenuItem; 83 84 MenuItem32: TMenuItem; 85 MenuItem33: TMenuItem; 84 86 MenuItemProducer: TMenuItem; 85 87 MenuItem3: TMenuItem; … … 103 105 TabSheetMessages: TTabSheet; 104 106 TabSheetBreakpoints: TTabSheet; 105 TabSheet CompiledProject: TTabSheet;107 TabSheetTargetProject: TTabSheet; 106 108 TabSheetSource: TTabSheet; 107 109 TabSheetTarget: TTabSheet; … … 150 152 procedure ProjectOpen(FileName: string); 151 153 procedure UpdateMenu; 154 procedure UpdateToolbar; 152 155 public 153 156 ReopenLastOpenedFile: Boolean; … … 172 175 UFormMessages, UFormSourceCode, UFormProject, UCommon, UFormAbout, UFormOptions, 173 176 UFormTargets, UTarget, UAnalyzer, UProducer, UExecutor, UFormProjectNew, 174 UProjectTemplates ;177 UProjectTemplates, UFormTargetProject; 175 178 176 179 resourcestring … … 239 242 Compiler.SourceFiles.Clear; 240 243 Project.Files.DumpFileList(Compiler.SourceFiles); 241 Compiler.TargetFolder := ExtractFileDir(Project.FileName); 244 TargetProject.FileName := ExtractFileDir(Project.FileName) + DirectorySeparator + 245 Compiler.CompiledFolder + DirectorySeparator + Compiler.Target.Name + 246 DirectorySeparator + 'Target.tppr'; 247 Compiler.TargetFolder := ExtractFileDir(TargetProject.FileName); 242 248 Compiler.Compile; 249 TargetProject.Files.LoadFromList(Compiler.TargetFiles); 250 FormTargetProject.UpdateInterface; 243 251 end; 244 252 FormProject.TreeViewProjectChange(Self, FormProject.TreeViewProject.Selected); … … 332 340 333 341 UpdateMenu; 342 UpdateToolbar; 334 343 FormSourceCode.UpdateInterface; 344 FormTargetCode.UpdateInterface; 335 345 FormProject.UpdateInterface; 336 346 end; … … 350 360 FormProject.Align := alClient; 351 361 FormProject.Show; 362 FormTargetProject.ManualDock(TabSheetTargetProject, nil, alClient); 363 FormTargetProject.Align := alClient; 364 FormTargetProject.Show; 352 365 FormCodeTree.ManualDock(TabSheetCodeTree, nil, alClient); 353 366 FormCodeTree.Align := alClient; … … 473 486 end; 474 487 488 procedure TFormMain.UpdateToolbar; 489 var 490 I: Integer; 491 begin 492 for I := 0 to ToolBar1.ButtonCount - 1 do 493 TToolButton(ToolBar1.Buttons[I]).Hint := TToolButton(ToolBar1.Buttons[I]).Caption; 494 end; 495 475 496 procedure TFormMain.FormClose(Sender: TObject; var Action: TCloseAction); 476 497 begin -
trunk/IDE/Forms/UFormTargetCode.pas
r46 r49 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, SynEdit, 9 9 SynHighlighterMulti, SynHighlighterVB, SynHighlighterPas, SynHighlighterCpp, 10 SynHighlighterXML ;10 SynHighlighterXML, UProject; 11 11 12 12 type … … 20 20 SynXMLSyn1: TSynXMLSyn; 21 21 private 22 { private declarations } 22 FProjectFile: TProjectFile; 23 procedure SetProjectFile(AValue: TProjectFile); 23 24 public 24 { public declarations } 25 end; 25 procedure UpdateInterface; 26 property ProjectFile: TProjectFile read FProjectFile write SetProjectFile; 27 end; 26 28 27 29 var … … 32 34 {$R *.lfm} 33 35 36 uses 37 UFormMain; 38 39 procedure TFormTargetCode.SetProjectFile(AValue: TProjectFile); 40 begin 41 if FProjectFile = AValue then Exit; 42 FProjectFile := AValue; 43 if Assigned(AValue) then 44 SynEdit1.Lines.Assign(FProjectFile.Source) 45 else SynEdit1.ClearAll; 46 end; 47 48 procedure TFormTargetCode.UpdateInterface; 49 begin 50 SynEdit1.Enabled := FormMain.Project.Active; 51 if not FormMain.Project.Active then SynEdit1.ClearAll; 52 end; 53 54 34 55 end. 35 56 -
trunk/IDE/Languages/Transpascal.cs.po
r48 r49 123 123 msgstr "Ukončit" 124 124 125 #: tformmain.ahelp.caption 126 msgctxt "tformmain.ahelp.caption" 127 msgid "Help" 128 msgstr "Nápověda" 129 125 130 #: tformmain.ahomepage.caption 126 131 msgctxt "tformmain.ahomepage.caption" … … 314 319 msgstr "Strom kódu" 315 320 316 #: tformmain.tabsheetcompiledproject.caption317 msgctxt "tformmain.tabsheetcompiledproject.caption"318 msgid "Target project"319 msgstr "Cílový projekt"320 321 321 #: tformmain.tabsheetmessages.caption 322 322 msgctxt "tformmain.tabsheetmessages.caption" … … 339 339 msgstr "Cílový kód" 340 340 341 #: tformmain.tabsheettargetproject.caption 342 msgctxt "tformmain.tabsheettargetproject.caption" 343 msgid "Target project" 344 msgstr "Cílový projekt" 345 341 346 #: tformmessages.caption 342 347 msgctxt "tformmessages.caption" … … 425 430 msgid "Target code" 426 431 msgstr "Cílový kód" 432 433 #: tformtargetproject.caption 434 msgid "FormTargetProject" 435 msgstr "" 427 436 428 437 #: tformtargets.caption -
trunk/IDE/Languages/Transpascal.po
r48 r49 115 115 msgstr "" 116 116 117 #: tformmain.ahelp.caption 118 msgctxt "TFORMMAIN.AHELP.CAPTION" 119 msgid "Help" 120 msgstr "" 121 117 122 #: tformmain.ahomepage.caption 118 123 msgctxt "TFORMMAIN.AHOMEPAGE.CAPTION" … … 305 310 msgstr "" 306 311 307 #: tformmain.tabsheetcompiledproject.caption308 msgctxt "TFORMMAIN.TABSHEETCOMPILEDPROJECT.CAPTION"309 msgid "Target project"310 msgstr ""311 312 312 #: tformmain.tabsheetmessages.caption 313 313 msgctxt "TFORMMAIN.TABSHEETMESSAGES.CAPTION" … … 330 330 msgstr "" 331 331 332 #: tformmain.tabsheettargetproject.caption 333 msgctxt "TFORMMAIN.TABSHEETTARGETPROJECT.CAPTION" 334 msgid "Target project" 335 msgstr "" 336 332 337 #: tformmessages.caption 333 338 msgctxt "TFORMMESSAGES.CAPTION" … … 417 422 msgstr "" 418 423 424 #: tformtargetproject.caption 425 msgid "FormTargetProject" 426 msgstr "" 427 419 428 #: tformtargets.caption 420 429 msgctxt "tformtargets.caption" -
trunk/IDE/Transpascal.lpi
r48 r49 106 106 </Item7> 107 107 </RequiredPackages> 108 <Units Count="1 6">108 <Units Count="17"> 109 109 <Unit0> 110 110 <Filename Value="Transpascal.lpr"/> … … 213 213 <UnitName Value="UProjectTemplates"/> 214 214 </Unit15> 215 <Unit16> 216 <Filename Value="Forms\UFormTargetProject.pas"/> 217 <IsPartOfProject Value="True"/> 218 <ComponentName Value="FormTargetProject"/> 219 <ResourceBaseClass Value="Form"/> 220 <UnitName Value="UFormTargetProject"/> 221 </Unit16> 215 222 </Units> 216 223 </ProjectOptions> -
trunk/IDE/Transpascal.lpr
r48 r49 13 13 UFormTargetCode, UFormCodeTree, TemplateGenerics, CoolTranslator, Common, 14 14 UFormAbout, UFormOptions, UFormTargets, UFormCompilerSettings, 15 UFormProjectNew, UProjectTemplates ;15 UFormProjectNew, UProjectTemplates, UFormTargetProject; 16 16 17 17 {$R *.res} … … 42 42 Application.CreateForm(TFormTargets, FormTargets); 43 43 Application.CreateForm(TFormProjectNew, FormProjectNew); 44 Application.CreateForm(TFormTargetProject, FormTargetProject); 44 45 Application.Run; 45 46 end. -
trunk/IDE/UProject.pas
r48 r49 41 41 private 42 42 FModified: Boolean; 43 function GetAbsoluteFileName: string; 43 44 procedure SetModified(const AValue: Boolean); 44 45 public … … 53 54 procedure Save; 54 55 property Modified: Boolean read FModified write SetModified; 56 property AbsoluteFileName: string read GetAbsoluteFileName; 55 57 end; 56 58 … … 60 62 Parent: TProject; 61 63 procedure DumpFileList(Files: TListString); 64 procedure LoadFromList(Files: TListString); 62 65 procedure Load; 63 66 procedure Save; … … 170 173 Files.Clear; 171 174 for I := 0 to Count - 1 do 172 Files.Add(TProjectFile(Items[I]).FileName); 175 Files.Add(TProjectFile(Items[I]).AbsoluteFileName); 176 end; 177 178 procedure TProjectFileList.LoadFromList(Files: TListString); 179 var 180 I: Integer; 181 NewFile: TProjectFile; 182 FileName: string; 183 begin 184 Clear; 185 for I := 0 to Files.Count - 1 do begin 186 FileName := Files[I]; 187 if Copy(FileName, 1, Length(ExtractFileDir(Parent.FileName))) = 188 ExtractFileDir(Parent.FileName) then 189 System.Delete(FileName, 1, Length(ExtractFileDir(Parent.FileName)) + 1); 190 NewFile := AddFile(FileName); 191 NewFile.Load; 192 end; 173 193 end; 174 194 … … 245 265 end; 246 266 267 function TProjectFile.GetAbsoluteFileName: string; 268 begin 269 Result := ExtractFileDir(Parent.FileName) + DirectorySeparator + FileName; 270 end; 271 247 272 constructor TProjectFile.Create; 248 273 begin … … 277 302 FileName := UTF8Encode(NewNode.TextContent); 278 303 end; 279 if FileExistsUTF8( ExtractFileDir(Parent.FileName) + DirectorySeparator +FileName) then Load;304 if FileExistsUTF8(AbsoluteFileName) then Load; 280 305 end; 281 306 282 307 procedure TProjectFile.Load; 283 308 begin 284 Source.LoadFromFile( ExtractFileDir(Parent.FileName) + DirectorySeparator +FileName);309 Source.LoadFromFile(AbsoluteFileName); 285 310 end; 286 311
Note:
See TracChangeset
for help on using the changeset viewer.