Changeset 41 for trunk/Compiler/UCompiler.pas
- Timestamp:
- Feb 28, 2012, 8:34:31 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Compiler/UCompiler.pas
r38 r41 6 6 7 7 uses 8 SysUtils, Variants, Classes, Contnrs, UAnalyzers, UProducers,FileUtil,9 Dialogs, USourceCode, UProducer, UAnalyzer, SpecializedList ;8 SysUtils, Variants, Classes, Contnrs, FileUtil, 9 Dialogs, USourceCode, UProducer, UAnalyzer, SpecializedList, UTarget; 10 10 11 11 type 12 TProducerType = (ptGCCC, ptDynamicC, ptPascal, ptAssembler, ptXML);13 TAnalyzerType = (ptCustomPascal, ptDelphi);14 15 12 TErrorMessage = class 16 13 Text: string; … … 19 16 end; 20 17 21 TCompilerTarget = class22 Vendor: string;23 Model: string;24 Architecture: string;25 end;26 27 18 { TCompilerList } 28 29 TCompilerTargetList = class(TObjectList)30 procedure Add(Vendor, Model, Architecture: string);31 end;32 19 33 20 TCompiler = class … … 35 22 FAnalyzer: TAnalyzer; 36 23 FOnErrorMessage: TErrorMessageEvent; 37 FProducerType: TProducerType;38 FProducer: TProducer;39 24 function GetSource(Name: string; var SourceCode: string): Boolean; 40 25 procedure ErrorMessage(Text: string; Position: TPoint; FileName: string); 41 26 procedure SetAnalyzer(const AValue: TAnalyzer); 42 procedure SetProducer(AValue: TProducer);43 27 procedure AnalyzeAll; 44 28 procedure ProduceAll; … … 47 31 ErrorMessages: TListObject; 48 32 CompiledFolder: string; 49 SupportedTargets: TCompilerTargetList; 50 Target: TCompilerTarget; 33 Target: TTarget; 51 34 TargetFolder: string; 52 Producers: TListProducer; 53 Analyzers: TListAnalyzer; 35 Targets: TListTarget; 54 36 SourceFiles: TListString; 55 37 constructor Create; … … 60 42 write FOnErrorMessage; 61 43 property Analyzer: TAnalyzer read FAnalyzer write SetAnalyzer; 62 property Producer: TProducer read FProducer write SetProducer;63 44 end; 64 45 46 65 47 implementation 48 49 uses 50 UTargets; 66 51 67 52 resourcestring … … 78 63 constructor TCompiler.Create; 79 64 begin 80 Analyzers := TListAnalyzer.Create; 81 Producers := TListProducer.Create; 65 Targets := TListTarget.Create; 82 66 SourceFiles := TListString.Create; 83 67 84 RegisterAnalyzers(Self); 85 RegisterProducers(Self); 86 87 SupportedTargets := TCompilerTargetList.Create; 88 SupportedTargets.Add('AMD', 'Athlon II', 'amd64'); 89 SupportedTargets.Add('Zilog', 'Z80', 'Z80'); 90 SupportedTargets.Add('Rabbit', 'RC3000', 'Z180'); 91 SupportedTargets.Add('Atmel', 'ATmega8', 'AVR'); 92 SupportedTargets.Add('Atmel', 'UC3B0256', 'AVR32'); 93 SupportedTargets.Add('Dallas', 'DS89C450', '8052'); 68 RegisterTargets(Self); 94 69 95 70 AbstractCode := TProgram.Create; 96 Producer := nil;97 Analyzer := nil;98 71 ErrorMessages := TListObject.Create; 99 72 CompiledFolder := 'Compiled'; … … 109 82 begin 110 83 AbstractCode.Free; 111 Analyzers.Free; 112 Producers.Free; 84 Targets.Free; 113 85 ErrorMessages.Free; 114 SupportedTargets.Free;115 86 SourceFiles.Free; 116 87 end; … … 159 130 end; 160 131 161 procedure TCompiler.SetProducer(AValue: TProducer);162 begin163 if FProducer = AValue then Exit;164 FProducer := AValue;165 end;166 167 132 procedure TCompiler.AnalyzeAll; 168 133 begin … … 187 152 with AbstractCode do 188 153 for I := 0 to Modules.Count - 1 do begin 189 Producer.Produce(TModule(Modules[I]));190 Producer.AssignToStringList(ProducedCode);154 Target.Producer.Produce(TModule(Modules[I])); 155 Target.Producer.AssignToStringList(ProducedCode); 191 156 TargetFileName := TargetFolder + DirectorySeparator + 192 CompiledFolder + DirectorySeparator + Producer.Name +157 CompiledFolder + DirectorySeparator + Target.Producer.Name + 193 158 DirectorySeparator + TModule(Modules[I]).TargetFile; 194 159 ForceDirectoriesUTF8(ExtractFileDir(TargetFileName)); … … 200 165 end; 201 166 202 { TCompilerTargetList }203 204 procedure TCompilerTargetList.Add(Vendor, Model, Architecture: string);205 var206 NewItem: TCompilerTarget;207 begin208 NewItem := TCompilerTarget.Create;209 NewItem.Vendor := Vendor;210 NewItem.Model := Model;211 NewItem.Architecture := Architecture;212 inherited Add(NewItem);213 end;214 215 167 end.
Note:
See TracChangeset
for help on using the changeset viewer.