- Timestamp:
- Feb 25, 2012, 6:04:21 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Compiler/TranspascalCompiler.lpk
r26 r38 1 1 <?xml version="1.0"?> 2 2 <CONFIG> 3 <Package Version=" 3">3 <Package Version="4"> 4 4 <PathDelim Value="\"/> 5 5 <Name Value="TranspascalCompiler"/> 6 <AddToProjectUsesSection Value="True"/> 6 7 <CompilerOptions> 7 <Version Value=" 9"/>8 <Version Value="11"/> 8 9 <PathDelim Value="\"/> 9 10 <SearchPaths> … … 38 39 </Item4> 39 40 <Item5> 41 <Filename Value="Produce\UProducers.pas"/> 42 <UnitName Value="UProducers"/> 43 </Item5> 44 <Item6> 40 45 <Filename Value="Produce\UProducerAsm8051.pas"/> 41 46 <UnitName Value="UProducerAsm8051"/> 42 </Item 5>43 <Item 6>47 </Item6> 48 <Item7> 44 49 <Filename Value="Produce\UProducerDynamicC.pas"/> 45 50 <UnitName Value="UProducerDynamicC"/> 46 </Item 6>47 <Item 7>51 </Item7> 52 <Item8> 48 53 <Filename Value="Produce\UProducerPascal.pas"/> 49 54 <UnitName Value="UProducerPascal"/> 50 </Item7> 51 <Item8> 55 </Item8> 56 <Item9> 57 <Filename Value="Produce\UProducerGCCC.pas"/> 58 <UnitName Value="UProducerGCCC"/> 59 </Item9> 60 <Item10> 52 61 <Filename Value="Analyze\UAnalyzer.pas"/> 53 62 <UnitName Value="UAnalyzer"/> 54 </Item8>55 <Item9>56 <Filename Value="Analyze\UAnalyzerPascal.pas"/>57 <UnitName Value="UAnalyzerPascal"/>58 </Item9>59 <Item10>60 <Filename Value="Produce\UProducerGCCC.pas"/>61 <UnitName Value="UProducerGCCC"/>62 63 </Item10> 63 64 <Item11> … … 66 67 </Item11> 67 68 <Item12> 68 <Filename Value=" Produce\UProducers.pas"/>69 <UnitName Value="U Producers"/>69 <Filename Value="Analyze\UAnalyzerPascal.pas"/> 70 <UnitName Value="UAnalyzerPascal"/> 70 71 </Item12> 71 72 </Files> -
trunk/Compiler/TranspascalCompiler.pas
r12 r38 3 3 } 4 4 5 unit TranspascalCompiler; 5 unit TranspascalCompiler; 6 6 7 7 interface 8 8 9 9 uses 10 UCompiler, USourceCode, UProducerTreeView, UProducer, UProducerAsm8051,11 UProducer DynamicC, UProducerPascal, UAnalyzer, UAnalyzerPascal,12 U ProducerGCCC, UAnalyzers, UProducers, LazarusPackageIntf;10 UCompiler, USourceCode, UProducerTreeView, UProducer, UProducers, 11 UProducerAsm8051, UProducerDynamicC, UProducerPascal, UProducerGCCC, 12 UAnalyzer, UAnalyzers, UAnalyzerPascal, LazarusPackageIntf; 13 13 14 14 implementation 15 15 16 procedure Register; 16 procedure Register; 17 17 begin 18 end; 18 end; 19 19 20 20 initialization 21 RegisterPackage('TranspascalCompiler', @Register); 21 RegisterPackage('TranspascalCompiler', @Register); 22 22 end. -
trunk/Compiler/UCompiler.pas
r20 r38 6 6 7 7 uses 8 SysUtils, Variants, Classes, Contnrs, UAnalyzers, UProducers, 9 Dialogs, USourceCode, UProducer, UAnalyzer ;8 SysUtils, Variants, Classes, Contnrs, UAnalyzers, UProducers, FileUtil, 9 Dialogs, USourceCode, UProducer, UAnalyzer, SpecializedList; 10 10 11 11 type … … 36 36 FOnErrorMessage: TErrorMessageEvent; 37 37 FProducerType: TProducerType; 38 FProducer: TProducer; 39 function GetSource(Name: string; var SourceCode: string): Boolean; 38 40 procedure ErrorMessage(Text: string; Position: TPoint; FileName: string); 39 41 procedure SetAnalyzer(const AValue: TAnalyzer); 42 procedure SetProducer(AValue: TProducer); 43 procedure AnalyzeAll; 44 procedure ProduceAll; 40 45 public 41 ProgramCode: TProgram; 42 Producer: TProducer; 43 ErrorMessages: TObjectList; 46 AbstractCode: TProgram; 47 ErrorMessages: TListObject; 44 48 CompiledFolder: string; 45 49 SupportedTargets: TCompilerTargetList; … … 48 52 Producers: TListProducer; 49 53 Analyzers: TListAnalyzer; 54 SourceFiles: TListString; 50 55 constructor Create; 51 56 destructor Destroy; override; 52 57 procedure Init; 53 procedure Compile (ModuleName: string; Source: TStringList);58 procedure Compile; 54 59 property OnErrorMessage: TErrorMessageEvent read FOnErrorMessage 55 60 write FOnErrorMessage; 56 61 property Analyzer: TAnalyzer read FAnalyzer write SetAnalyzer; 62 property Producer: TProducer read FProducer write SetProducer; 57 63 end; 58 64 59 65 implementation 60 66 67 resourcestring 68 SNothingToAnalyze = 'Nothing to analyze'; 69 61 70 { TCompiler } 62 71 63 procedure TCompiler.Compile(ModuleName: string; Source: TStringList); 64 var 65 NewModule: TModule; 66 ProducedCode: TStringList; 67 I: Integer; 68 TargetFileName: string; 69 begin 70 try 71 ProducedCode := TStringList.Create; 72 Analyzer.FileName := ModuleName; 73 Analyzer.SourceCode := Source.Text; 74 Analyzer.Process; 75 //ShowMessage(IntToHex(Integer(Addr(Analyzer.OnGetSource)), 8)); 76 Analyzer.ParseModule(ProgramCode); 77 with ProgramCode do 78 for I := 0 to Modules.Count - 1 do begin 79 Producer.Produce(TModule(Modules[I])); 80 Producer.AssignToStringList(ProducedCode); 81 TargetFileName := TargetFolder + DirectorySeparator + 82 CompiledFolder + DirectorySeparator + Producer.Name + 83 DirectorySeparator + TModule(Modules[I]).TargetFile; 84 ForceDirectories(ExtractFileDir(TargetFileName)); 85 ProducedCode.SaveToFile(TargetFileName); 86 end; 87 finally 88 ProducedCode.Free; 89 end; 72 procedure TCompiler.Compile; 73 begin 74 AnalyzeAll; 75 ProduceAll; 90 76 end; 91 77 … … 94 80 Analyzers := TListAnalyzer.Create; 95 81 Producers := TListProducer.Create; 82 SourceFiles := TListString.Create; 96 83 97 84 RegisterAnalyzers(Self); … … 106 93 SupportedTargets.Add('Dallas', 'DS89C450', '8052'); 107 94 108 ProgramCode := TProgram.Create;95 AbstractCode := TProgram.Create; 109 96 Producer := nil; 110 97 Analyzer := nil; 111 ErrorMessages := T ObjectList.Create;98 ErrorMessages := TListObject.Create; 112 99 CompiledFolder := 'Compiled'; 113 100 end; … … 116 103 begin 117 104 ErrorMessages.Clear; 118 ProgramCode.Modules.Clear;105 AbstractCode.Modules.Clear; 119 106 end; 120 107 121 108 destructor TCompiler.Destroy; 122 109 begin 123 ProgramCode.Free;110 AbstractCode.Free; 124 111 Analyzers.Free; 125 112 Producers.Free; 126 113 ErrorMessages.Free; 127 114 SupportedTargets.Free; 115 SourceFiles.Free; 116 end; 117 118 function TCompiler.GetSource(Name: string; var SourceCode: string): Boolean; 119 var 120 I: Integer; 121 F: TFileStream; 122 begin 123 I := 0; 124 while (I < SourceFiles.Count) and (ExtractFileNameOnly(SourceFiles[I]) <> Name) do Inc(I); 125 if I < SourceFiles.Count then begin 126 if FileExistsUTF8(SourceFiles[I]) then 127 try 128 F := TFileStream.Create(UTF8Decode(SourceFiles[I]), fmOpenRead); 129 SetLength(SourceCode, F.Size); 130 if F.Size > 0 then 131 F.Read(SourceCode[1], F.Size); 132 Result := True; 133 finally 134 F.Free; 135 end else Result := False; 136 end else Result := False; 128 137 end; 129 138 … … 144 153 if FAnalyzer = AValue then exit; 145 154 FAnalyzer := AValue; 146 if Assigned(Analyzer) then 155 if Assigned(Analyzer) then begin 147 156 Analyzer.OnErrorMessage := ErrorMessage; 157 Analyzer.OnGetSource := GetSource; 158 end; 159 end; 160 161 procedure TCompiler.SetProducer(AValue: TProducer); 162 begin 163 if FProducer = AValue then Exit; 164 FProducer := AValue; 165 end; 166 167 procedure TCompiler.AnalyzeAll; 168 begin 169 if SourceFiles.Count > 0 then begin 170 Analyzer.FileName := SourceFiles[0]; 171 Analyzer.OnGetSource(ExtractFileNameOnly(Analyzer.FileName), Analyzer.SourceCode); 172 Analyzer.Process; 173 //ShowMessage(IntToHex(Integer(Addr(Analyzer.OnGetSource)), 8)); 174 Analyzer.ParseModule(AbstractCode); 175 end else raise Exception.Create(SNothingToAnalyze); 176 end; 177 178 procedure TCompiler.ProduceAll; 179 var 180 NewModule: TModule; 181 ProducedCode: TStringList; 182 I: Integer; 183 TargetFileName: string; 184 begin 185 try 186 ProducedCode := TStringList.Create; 187 with AbstractCode do 188 for I := 0 to Modules.Count - 1 do begin 189 Producer.Produce(TModule(Modules[I])); 190 Producer.AssignToStringList(ProducedCode); 191 TargetFileName := TargetFolder + DirectorySeparator + 192 CompiledFolder + DirectorySeparator + Producer.Name + 193 DirectorySeparator + TModule(Modules[I]).TargetFile; 194 ForceDirectoriesUTF8(ExtractFileDir(TargetFileName)); 195 ProducedCode.SaveToFile(TargetFileName); 196 end; 197 finally 198 ProducedCode.Free; 199 end; 148 200 end; 149 201 -
trunk/IDE
- Property svn:ignore
-
old new 5 5 Transpascal.exe 6 6 heaptrclog.trc 7 Transpascal
-
- Property svn:ignore
-
trunk/IDE/Forms/UMainForm.lfm
r37 r38 5 5 Width = 695 6 6 Caption = 'Transpascal IDE' 7 ClientHeight = 4 827 ClientHeight = 476 8 8 ClientWidth = 695 9 9 Font.Height = -11 … … 20 20 Left = 0 21 21 Height = 5 22 Top = 47 722 Top = 471 23 23 Width = 695 24 24 Align = alBottom … … 27 27 object DockPanel: TPanel 28 28 Left = 0 29 Height = 3 4529 Height = 339 30 30 Top = 26 31 31 Width = 490 … … 87 87 object Splitter1: TSplitter 88 88 Left = 490 89 Height = 3 4589 Height = 339 90 90 Top = 26 91 91 Width = 5 … … 95 95 object PageControlRight: TPageControl 96 96 Left = 495 97 Height = 3 4597 Height = 339 98 98 Top = 26 99 99 Width = 200 … … 113 113 Left = 0 114 114 Height = 101 115 Top = 37 6115 Top = 370 116 116 Width = 695 117 117 ActivePage = TabSheet4 … … 131 131 Left = 0 132 132 Height = 5 133 Top = 3 71133 Top = 365 134 134 Width = 695 135 135 Align = alBottom -
trunk/IDE/Forms/UMainForm.pas
r37 r38 138 138 LogParsing: Boolean; 139 139 Project: TProject; 140 TargetProject: TProject; 140 141 Compiler: TCustomCompiler; 141 142 function GetSource(Name: string; var SourceCode: string): Boolean; … … 203 204 Compiler.Producer := TProducer(Compiler.Producers[SelectedProducerIndex]); 204 205 Compiler.Analyzer := TAnalyzer(Compiler.Analyzers[SelectedAnalyzerIndex]); 205 Compiler.Analyzer.OnGetSource := GetSource;206 206 Compiler.Init; 207 207 … … 212 212 if Project.Items.Count > 0 then 213 213 with TProjectFile(Project.Items[0]) do begin 214 Compiler.SourceFiles.Clear; 215 Project.DumpFileList(Compiler.SourceFiles); 214 216 Compiler.TargetFolder := Project.RootDir; 215 Compiler.Compile (Parent.GetDir + ExtractFileNameOnly(Name), Source);217 Compiler.Compile; 216 218 end; 217 219 ProjectManager.TreeViewProjectChange(Self, ProjectManager.TreeViewProject.Selected); … … 453 455 Compiler := TCustomCompiler.Create; 454 456 Project := TProject.Create; 457 TargetProject := TProject.Create; 455 458 LastOpenedFiles := TLastOpenedList.Create; 456 459 LastOpenedFiles.MenuItem := MenuItemOpenRecent; … … 461 464 begin 462 465 LastOpenedFiles.Free; 466 TargetProject.Free; 463 467 Project.Free; 464 468 Compiler.Free; -
trunk/IDE/Forms/UProjectManager.pas
r37 r38 29 29 30 30 uses 31 UMainForm, UCodeForm, UCompiledForm, UCodeTreeForm , UProducerTreeView;31 UMainForm, UCodeForm, UCompiledForm, UCodeTreeForm; 32 32 33 33 { TProjectManager } -
trunk/IDE/Transpascal.lpi
r37 r38 89 89 <Item3> 90 90 <PackageName Value="LCLBase"/> 91 <MinVersion Major="1" Valid="True" Release="1"/>91 <MinVersion Major="1" Release="1" Valid="True"/> 92 92 </Item3> 93 93 <Item4> -
trunk/IDE/Transpascal.lpr
r37 r38 9 9 Forms, Interfaces, SysUtils, 10 10 UMainForm in 'UMainForm.pas' {MainForm}, 11 UTextSource, UProject, UApplicationInfo, URegistry, ULastOpenedList, 12 UDebugLog, TranspascalCompiler, UProjectManager, UCodeForm, UMessagesForm, 11 UTextSource, UProject, UApplicationInfo, TranspascalCompiler, UProjectManager, UCodeForm, UMessagesForm, 13 12 UCompiledForm, UCodeTreeForm, TemplateGenerics, Common, CoolTranslator, 14 13 UAboutForm, UFormOptions, UCompilersForm, UCompilerSettingsForm; -
trunk/IDE/UApplicationInfo.pas
r37 r38 55 55 Name := 'Transpascal IDE'; 56 56 Identification := 1; 57 ReleaseDate := EncodeDate(2012, 2, 14);57 ReleaseDate := EncodeDate(2012, 2, 25); 58 58 MajorVersion := 0; 59 59 MinorVersion := 1; -
trunk/IDE/UProject.pas
r37 r38 53 53 TProjectGroup = class(TProjectNode) 54 54 Items: TListProjectNode; 55 procedure DumpFileList(Files: TListString); 55 56 constructor Create; 56 57 destructor Destroy; override; … … 88 89 { TProjectGroup } 89 90 91 procedure TProjectGroup.DumpFileList(Files: TListString); 92 var 93 I: Integer; 94 begin 95 for I := 0 to Items.Count - 1 do 96 if TProjectNode(Items[I]) is TProjectGroup then 97 TProjectGroup(Items[I]).DumpFileList(Files) 98 else Files.Add(GetDir(True) + TProjectFile(Items[I]).Name); 99 end; 100 90 101 constructor TProjectGroup.Create; 91 102 begin … … 230 241 function TProjectNode.GetDir(IncludeRoot: Boolean = False): string; 231 242 begin 232 if Assigned(Parent) then Result := Parent.GetDir(IncludeRoot) + Name + '/'233 else Result := Name + '/';243 if Assigned(Parent) then Result := Parent.GetDir(IncludeRoot) + Name + DirectorySeparator 244 else Result := Name + DirectorySeparator; 234 245 end; 235 246
Note:
See TracChangeset
for help on using the changeset viewer.