Changeset 12 for trunk/Compiler
- Timestamp:
- Nov 8, 2010, 10:06:37 AM (14 years ago)
- Location:
- trunk/Compiler
- Files:
-
- 4 added
- 3 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Compiler/Produce/UProducer.pas
r6 r12 2 2 3 3 {$MODE Delphi} 4 {$MACRO ON} 4 5 5 6 interface 6 7 7 8 uses 8 USourceCode, Classes ;9 USourceCode, Classes, SysUtils; 9 10 10 11 type 11 12 TProducer = class 13 Name: string; 12 14 procedure AssignToStringList(Target: TStringList); virtual; abstract; 13 15 procedure Produce(Module: TModule); virtual; abstract; 14 16 end; 15 17 18 // TListProducer = TGObjectList<Integer, TProducer> 19 {$DEFINE TGObjectListIndex := Integer} 20 {$DEFINE TGObjectListItem := TProducer} 21 {$DEFINE TGObjectListList := TObjectListProducer} 22 {$DEFINE TGObjectList := TListProducer} 23 {$DEFINE TGObjectListSortCompare := TObjectListSortCompareProducer} 24 {$DEFINE TGObjectListStringConverter := TObjectListStringConverterProducer} 25 {$DEFINE INTERFACE} 26 {$I 'GenericObjectList.inc'} 27 16 28 implementation 17 29 30 {$DEFINE IMPLEMENTATION_USES} 31 {$I 'GenericObjectList.inc'} 32 33 // TListProducer = TGObjectList<Integer, TProducer> 34 {$DEFINE TGObjectListIndex := Integer} 35 {$DEFINE TGObjectListItem := TProducer} 36 {$DEFINE TGObjectListList := TObjectListProducer} 37 {$DEFINE TGObjectList := TListProducer} 38 {$DEFINE TGObjectListSortCompare := TObjectListSortCompareProducer} 39 {$DEFINE TGObjectListStringConverter := TObjectListStringConverterProducer} 40 {$DEFINE IMPLEMENTATION} 41 {$I 'GenericObjectList.inc'} 42 18 43 end. -
trunk/Compiler/Produce/UProducerAsm8051.pas
r6 r12 108 108 begin 109 109 AssemblyCode := TObjectList.Create; 110 Name := 'ASM 8051'; 110 111 end; 111 112 -
trunk/Compiler/Produce/UProducerDynamicC.pas
r6 r12 56 56 TextSource := TStringList.Create; 57 57 IndentationLength := 2; 58 Name := 'Dynamic C'; 58 59 end; 59 60 -
trunk/Compiler/Produce/UProducerGCCC.pas
r6 r12 56 56 TextSource := TStringList.Create; 57 57 IndentationLength := 2; 58 Name := 'GCC C'; 58 59 end; 59 60 -
trunk/Compiler/Produce/UProducerPascal.pas
r6 r12 52 52 IndentationLength := 2; 53 53 TextSource := TStringList.Create; 54 Name := 'Delphi'; 54 55 end; 55 56 -
trunk/Compiler/TranspascalCompiler.lpk
r3 r12 16 16 </CompilerOptions> 17 17 <Version Minor="1"/> 18 <Files Count="1 1">18 <Files Count="12"> 19 19 <Item1> 20 20 <Filename Value="UCompiler.pas"/> … … 46 46 </Item7> 47 47 <Item8> 48 <Filename Value="Analyze\U Parser.pas"/>49 <UnitName Value="U Parser"/>48 <Filename Value="Analyze\UAnalyzer.pas"/> 49 <UnitName Value="UAnalyzer"/> 50 50 </Item8> 51 51 <Item9> 52 <Filename Value="Analyze\U PascalParser.pas"/>53 <UnitName Value="U PascalParser"/>52 <Filename Value="Analyze\UAnalyzerPascal.pas"/> 53 <UnitName Value="UAnalyzerPascal"/> 54 54 </Item9> 55 55 <Item10> 56 <Filename Value=" Analyze\UGrammer.pas"/>57 <UnitName Value="U Grammer"/>56 <Filename Value="Produce\UProducerGCCC.pas"/> 57 <UnitName Value="UProducerGCCC"/> 58 58 </Item10> 59 59 <Item11> 60 <Filename Value=" Produce\UProducerGCCC.pas"/>61 <UnitName Value="U ProducerGCCC"/>60 <Filename Value="Analyze\UAnalyzers.pas"/> 61 <UnitName Value="UAnalyzers"/> 62 62 </Item11> 63 <Item12> 64 <Filename Value="Produce\UProducers.pas"/> 65 <UnitName Value="UProducers"/> 66 </Item12> 63 67 </Files> 64 68 <Type Value="RunAndDesignTime"/> -
trunk/Compiler/TranspascalCompiler.pas
r2 r12 9 9 uses 10 10 UCompiler, USourceCode, UProducerTreeView, UProducer, UProducerAsm8051, 11 UProducerDynamicC, UProducerPascal, U Parser, UPascalParser, UGrammer,12 UProducerGCCC, LazarusPackageIntf;11 UProducerDynamicC, UProducerPascal, UAnalyzer, UAnalyzerPascal, 12 UProducerGCCC, UAnalyzers, UProducers, LazarusPackageIntf; 13 13 14 14 implementation -
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.