Changeset 12 for trunk/Compiler/UCompiler.pas
- Timestamp:
- Nov 8, 2010, 10:06:37 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Compiler/UCompiler.pas
r6 r12 6 6 7 7 uses 8 SysUtils, Variants, Classes, 9 Dialogs, USourceCode, UProducer, UPascalParser, UParser, 10 UProducerDynamicC, Contnrs, UProducerTreeView, UProducerASM8051, 11 UProducerPascal, UProducerGCCC; 8 SysUtils, Variants, Classes, Contnrs, UAnalyzers, UProducers, 9 Dialogs, USourceCode, UProducer, UAnalyzer; 12 10 13 11 type … … 35 33 TCompiler = class 36 34 private 35 FAnalyzer: TAnalyzer; 37 36 FOnErrorMessage: TErrorMessageEvent; 38 37 FProducerType: TProducerType; 39 38 procedure ErrorMessage(Text: string; Position: TPoint; FileName: string); 40 procedure Set ProducerType(const AValue: TProducerType);39 procedure SetAnalyzer(const AValue: TAnalyzer); 41 40 public 42 41 ProgramCode: TProgram; 43 Parser: TPascalParser;44 42 Producer: TProducer; 45 43 ErrorMessages: TObjectList; … … 48 46 Target: TCompilerTarget; 49 47 TargetFolder: string; 48 Producers: TListProducer; 49 Analyzers: TListAnalyzer; 50 50 constructor Create; 51 51 destructor Destroy; override; … … 54 54 property OnErrorMessage: TErrorMessageEvent read FOnErrorMessage 55 55 write FOnErrorMessage; 56 property ProducerType: TProducerType read FProducerType 57 write SetProducerType; 56 property Analyzer: TAnalyzer read FAnalyzer write SetAnalyzer; 58 57 end; 59 60 const61 ProducerTypeName: array[TProducerType] of string = (62 'GCC C', 'Rabbit Dynamic C', 'Generic Pascal', 'Assembler', 'XML');63 AnalyzerTypeName: array[TAnalyzerType] of string = (64 'Custom pascal', 'Delphi');65 58 66 59 implementation … … 77 70 try 78 71 ProducedCode := TStringList.Create; 79 Parser.FileName := ModuleName;80 Parser.SourceCodeText := Source;81 Parser.Process;82 //ShowMessage(IntToHex(Integer(Addr( Parser.OnGetSource)), 8));83 Parser.ParseModule(ProgramCode);72 Analyzer.FileName := ModuleName; 73 Analyzer.SourceCodeText := Source; 74 Analyzer.Process; 75 //ShowMessage(IntToHex(Integer(Addr(Analyzer.OnGetSource)), 8)); 76 Analyzer.ParseModule(ProgramCode); 84 77 with ProgramCode do 85 78 for I := 0 to Modules.Count - 1 do begin … … 99 92 constructor TCompiler.Create; 100 93 begin 94 Analyzers := TListAnalyzer.Create; 95 Producers := TListProducer.Create; 96 97 RegisterAnalyzers(Self); 98 RegisterProducers(Self); 99 101 100 SupportedTargets := TCompilerTargetList.Create; 102 101 SupportedTargets.Add('AMD', 'Athlon II', 'amd64'); … … 108 107 109 108 ProgramCode := TProgram.Create; 110 Producer := TProducerGCCC.Create; 111 Parser := TPascalParser.Create; 112 Parser.OnErrorMessage := ErrorMessage; 109 Producer := nil; 110 Analyzer := nil; 113 111 ErrorMessages := TObjectList.Create; 114 112 CompiledFolder := 'Compiled'; … … 124 122 begin 125 123 ProgramCode.Free; 126 Parser.Free;127 Producer .Free;124 Analyzers.Free; 125 Producers.Free; 128 126 ErrorMessages.Free; 129 127 SupportedTargets.Free; … … 142 140 end; 143 141 144 procedure TCompiler.Set ProducerType(const AValue: TProducerType);142 procedure TCompiler.SetAnalyzer(const AValue: TAnalyzer); 145 143 begin 146 if FProducerType = AValue then Exit; 147 FProducerType := AValue; 148 Producer.Free; 149 case AValue of 150 ptGCCC: Producer := TProducerGCCC.Create; 151 ptDynamicC: Producer := TProducerDynamicC.Create; 152 ptPascal: Producer := TProducerPascal.Create; 153 ptAssembler: Producer := TProducerGCCC.Create; 154 ptXML: Producer := TProducerTreeView.Create; 155 end; 144 if FAnalyzer = AValue then exit; 145 FAnalyzer := AValue; 146 if Assigned(Analyzer) then 147 Analyzer.OnErrorMessage := ErrorMessage; 156 148 end; 157 149
Note:
See TracChangeset
for help on using the changeset viewer.