Changeset 75 for trunk/Compiler/Modules
- Timestamp:
- Jun 4, 2024, 12:22:49 AM (6 months ago)
- Location:
- trunk/Compiler/Modules
- Files:
-
- 4 added
- 12 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Compiler/Modules/ASM8051/ProducerASM8051.pas
r74 r75 1 unit UProducerASM8051; 2 3 {$MODE Delphi} 1 unit ProducerASM8051; 4 2 5 3 interface … … 7 5 uses 8 6 SysUtils, Variants, Classes, Graphics, Controls, Forms, 9 Dialogs, USourceCodePascal, UProducer, Contnrs;7 Dialogs, SourceCodePascal, Producer, Generics.Collections; 10 8 11 9 type … … 37 35 procedure GenerateModule(Module: TSourceModule); 38 36 public 39 AssemblyCode: TObjectList ; // TList<TAssemblerLine>37 AssemblyCode: TObjectList<TAssemblerLine>; 40 38 procedure AssignToStringList(Target: TStringList); override; 41 39 procedure Produce(Module: TSourceModule); override; … … 107 105 constructor TProducerAsm8051.Create; 108 106 begin 109 AssemblyCode := TObjectList .Create;107 AssemblyCode := TObjectList<TAssemblerLine>.Create; 110 108 {$IFDEF Windows} 111 109 CompilerPath := 'c:\ASM8051\ASM51.EXE'; -
trunk/Compiler/Modules/ASM8051/TargetASM8051.pas
r74 r75 1 unit UTargetASM8051; 2 3 {$mode Delphi}{$H+} 1 unit TargetASM8051; 4 2 5 3 interface 6 4 7 5 uses 8 Classes, SysUtils, UTarget;6 Classes, SysUtils, Target; 9 7 10 8 type … … 16 14 end; 17 15 16 18 17 implementation 19 18 … … 22 21 constructor TTargetASM8051.Create; 23 22 begin 24 inherited Create;23 inherited; 25 24 SysName := 'ASM8051'; 26 25 Name := 'ASM8051'; -
trunk/Compiler/Modules/Brainfuck/ModuleBrainfuck.pas
r74 r75 1 unit UModuleBrainfuck; 2 3 {$mode delphi}{$H+} 1 unit ModuleBrainfuck; 4 2 5 3 interface 6 4 7 5 uses 8 Classes, SysUtils, UModularSystem, USourceConvertor;6 Classes, SysUtils, ModularSystem, SourceConvertor; 9 7 10 8 type … … 42 40 43 41 uses 44 UCompilerAPI, USourceCodePascal;42 CompilerAPI, SourceCodePascal; 45 43 46 44 resourcestring … … 56 54 constructor TConvertorBFToPascal.Create; 57 55 begin 58 inherited Create;56 inherited; 59 57 Name := 'BFToPascal'; 60 58 InputType := TSourceBrainfuck; … … 71 69 constructor TConvertorTextToBF.Create; 72 70 begin 73 inherited Create;71 inherited; 74 72 Name := 'TextToBF'; 75 73 InputType := TSourceFileLink; -
trunk/Compiler/Modules/Delphi/ModuleDelphi.pas
r74 r75 1 unit UModuleDelphi; 2 3 {$mode Delphi}{$H+} 1 unit ModuleDelphi; 4 2 5 3 interface 6 4 7 5 uses 8 Classes, SysUtils, UTarget, UExecutor, UModularSystem;6 Classes, SysUtils, Target, Executor, ModularSystem; 9 7 10 8 type … … 28 26 29 27 uses 30 UProducerDelphi, UCompilerAPI;28 ProducerDelphi, CompilerAPI; 31 29 32 30 resourcestring … … 38 36 begin 39 37 inherited; 40 Name:= 'Delphi';38 Identification := 'Delphi'; 41 39 Title := SDelphi; 42 40 end; -
trunk/Compiler/Modules/Delphi/ProducerDelphi.pas
r74 r75 1 unit UProducerDelphi; 2 3 {$MODE Delphi} 1 unit ProducerDelphi; 4 2 5 3 interface … … 7 5 uses 8 6 SysUtils, Variants, Classes, Graphics, Controls, Forms, 9 Dialogs, USourceCodePascal, UProducer, StrUtils, USourceConvertor;7 Dialogs, SourceCodePascal, Producer, StrUtils, SourceConvertor; 10 8 11 9 type … … 16 14 private 17 15 Producer: TProducer; 18 procedure GenerateUses(UsedModules: TUsedModule List);16 procedure GenerateUses(UsedModules: TUsedModules); 19 17 procedure GenerateModule(Module: TSourceModule); 20 18 procedure GenerateUnit(Module: TSourceModule); … … 22 20 procedure GeneratePackage(Module: TSourceModule); 23 21 procedure GenerateType(AType: TType; AssignSymbol: Char = ':'); 24 procedure GenerateTypes(Types: TType List);22 procedure GenerateTypes(Types: TTypes); 25 23 procedure GenerateCommonBlockInterface(CommonBlock: TCommonBlock; 26 24 LabelPrefix: string); 27 25 procedure GenerateCommonBlockImplementation(CommonBlock: TCommonBlock; 28 26 LabelPrefix: string); 29 procedure GenerateFunctions(Functions: TFunction List);27 procedure GenerateFunctions(Functions: TFunctions); 30 28 procedure GenerateFunction(AFunction: TFunction); 31 29 procedure GenerateFunctionHead(AFunction: TFunction); 32 procedure GenerateConstants(Constants: TConstant List);30 procedure GenerateConstants(Constants: TConstants); 33 31 procedure GenerateConstant(Constant: TConstant); 34 32 procedure GenerateBeginEnd(BeginEnd: TBeginEnd); 35 procedure GenerateVariableList(Variables: TVariable List);33 procedure GenerateVariableList(Variables: TVariables); 36 34 procedure GenerateVariable(Variable: TVariable); 37 35 procedure GenerateCommand(Command: TCommand); … … 49 47 end; 50 48 49 51 50 implementation 52 51 … … 72 71 destructor TProducerPascal.Destroy; 73 72 begin 74 Producer.Free;73 FreeAndNil(Producer); 75 74 inherited; 76 75 end; 77 76 78 procedure TProducerPascal.GenerateUses(UsedModules: TUsedModule List);77 procedure TProducerPascal.GenerateUses(UsedModules: TUsedModules); 79 78 var 80 79 I: Integer; … … 142 141 procedure TProducerPascal.GenerateLibrary(Module: TSourceModule); 143 142 begin 144 145 143 end; 146 144 147 145 procedure TProducerPascal.GeneratePackage(Module: TSourceModule); 148 146 begin 149 150 147 end; 151 148 … … 192 189 end; 193 190 194 procedure TProducerPascal.GenerateTypes(Types: TType List);191 procedure TProducerPascal.GenerateTypes(Types: TTypes); 195 192 var 196 193 I: Integer; … … 231 228 end; 232 229 233 procedure TProducerPascal.GenerateFunctions(Functions: TFunction List);230 procedure TProducerPascal.GenerateFunctions(Functions: TFunctions); 234 231 var 235 232 I: Integer; … … 280 277 end; 281 278 282 procedure TProducerPascal.GenerateConstants(Constants: TConstant List);279 procedure TProducerPascal.GenerateConstants(Constants: TConstants); 283 280 var 284 281 I: Integer; … … 322 319 end; 323 320 324 procedure TProducerPascal.GenerateVariableList(Variables: TVariable List);321 procedure TProducerPascal.GenerateVariableList(Variables: TVariables); 325 322 var 326 323 I: Integer; -
trunk/Compiler/Modules/GCC/ModuleGCC.pas
r74 r75 1 unit UModuleGCC; 2 3 {$mode delphi}{$H+} 1 unit ModuleGCC; 4 2 5 3 interface 6 4 7 5 uses 8 Classes, SysUtils, UModularSystem, UProducerGCC, UTargetGCC, UCompilerAPI;6 Classes, SysUtils, ModularSystem, ProducerGCC, TargetGCC, CompilerAPI; 9 7 10 8 type … … 13 11 14 12 TModuleGCC = class(TModule) 13 public 15 14 Target: TTargetGCC; 16 15 constructor Create(AOwner: TComponent); override; … … 31 30 begin 32 31 inherited; 33 Name:= 'GCC';32 Identification := 'GCC'; 34 33 Title := SGCC; 35 34 end; -
trunk/Compiler/Modules/GCC/ProducerGCC.pas
r74 r75 1 unit UProducerGCC; 2 3 {$MODE Delphi} 1 unit ProducerGCC; 4 2 5 3 interface … … 7 5 uses 8 6 SysUtils, Variants, Classes, Graphics, Controls, Forms, 9 Dialogs, StdCtrls, USourceCode, UProducer, StrUtils;7 Dialogs, StdCtrls, SourceCodePascal, Producer, StrUtils; 10 8 11 9 type … … 19 17 procedure Emit(AText: string); 20 18 procedure EmitLn(AText: string = ''); 21 procedure GenerateUses(UsedModules: TUsedModule List);19 procedure GenerateUses(UsedModules: TUsedModules); 22 20 procedure GenerateModule(Module: TSourceModule); 23 21 procedure GenerateCommonBlock(CommonBlock: TCommonBlock; 24 22 LabelPrefix: string); 25 23 procedure GenerateType(AType: TType); 26 procedure GenerateTypes(Types: TType List);24 procedure GenerateTypes(Types: TTypes); 27 25 procedure GenerateProgram(ProgramBlock: TProgram); 28 procedure GenerateFunctions(Functions: TFunction List;26 procedure GenerateFunctions(Functions: TFunctions; 29 27 Prefix: string = ''); 30 28 procedure GenerateBeginEnd(BeginEnd: TBeginEnd); 31 procedure GenerateVariableList(VariableList: TVariable List);29 procedure GenerateVariableList(VariableList: TVariables); 32 30 procedure GenerateVariable(Variable: TVariable); 33 31 procedure GenerateCommand(Command: TCommand); … … 113 111 end; 114 112 115 procedure TProducerGCCC.GenerateUses(UsedModules: TUsedModule List);113 procedure TProducerGCCC.GenerateUses(UsedModules: TUsedModules); 116 114 var 117 115 I: Integer; … … 155 153 end; 156 154 157 procedure TProducerGCCC.GenerateFunctions(Functions: TFunction List;158 Prefix: string = '');155 procedure TProducerGCCC.GenerateFunctions(Functions: TFunctions; Prefix: string 156 ); 159 157 var 160 158 I: Integer; … … 202 200 end; 203 201 204 procedure TProducerGCCC.GenerateVariableList(VariableList: TVariable List);202 procedure TProducerGCCC.GenerateVariableList(VariableList: TVariables); 205 203 var 206 204 I: Integer; … … 361 359 end; 362 360 363 procedure TProducerGCCC.GenerateTypes(Types: TType List);361 procedure TProducerGCCC.GenerateTypes(Types: TTypes); 364 362 var 365 363 I: Integer; -
trunk/Compiler/Modules/GCC/TargetGCC.pas
r74 r75 1 unit UTargetGCC; 2 3 {$mode Delphi}{$H+} 1 unit TargetGCC; 4 2 5 3 interface 6 4 7 5 uses 8 Classes, SysUtils, UTarget;6 Classes, SysUtils, Target; 9 7 10 8 type … … 22 20 constructor TTargetGCC.Create; 23 21 begin 24 inherited Create;22 inherited; 25 23 SysName := 'GCC'; 26 24 Name := 'GCC'; -
trunk/Compiler/Modules/Interpretter/ModuleInterpretter.pas
r74 r75 1 unit UModuleInterpretter; 2 3 {$mode Delphi}{$H+} 1 unit ModuleInterpretter; 4 2 5 3 interface 6 4 7 5 uses 8 Classes, SysUtils, UTarget, UExecutor, USourceCodePascal, Dialogs,9 SpecializedList, UModularSystem;6 Classes, SysUtils, Target, Executor, SourceCodePascal, Dialogs, 7 Generics.Collections, ModularSystem; 10 8 11 9 type … … 30 28 function Evaluate(Expression: TExpression): TValue; 31 29 public 32 Variables: T ListObject;30 Variables: TObjectList<TVariable>; 33 31 procedure Run; override; 34 32 constructor Create; … … 47 45 48 46 uses 49 UCompiler, UCompilerAPI;47 Compiler, CompilerAPI; 50 48 51 49 resourcestring … … 58 56 begin 59 57 inherited; 60 Name:= 'Interpretter';58 Identification := 'Interpretter'; 61 59 Title := 'Interpretter'; 62 60 Version := '0.1'; … … 187 185 constructor TExecutorInterpretter.Create; 188 186 begin 189 Variables := T ListObject.Create;187 Variables := TVariables.Create; 190 188 end; 191 189 192 190 destructor TExecutorInterpretter.Destroy; 193 191 begin 194 Variables.Free;195 inherited Destroy;192 FreeAndnil(Variables); 193 inherited; 196 194 end; 197 195 -
trunk/Compiler/Modules/Pascal/AnalyzerPascal.pas
r74 r75 1 unit UAnalyzerPascal; 2 3 {$mode delphi} 1 unit AnalyzerPascal; 4 2 5 3 interface 6 4 7 5 uses 8 Classes, SysUtils, UAnalyzer, USourceCodePascal, Dialogs, USourceConvertor;6 Classes, SysUtils, Analyzer, SourceCodePascal, Dialogs, SourceConvertor; 9 7 10 8 type … … 16 14 public 17 15 Parser: TAnalyzer; 18 function DebugExpressions(List: T ListExpression): string;16 function DebugExpressions(List: TExpressions): string; 19 17 function ParseFile(Name: string): Boolean; 20 18 function ParseWhileDo(var WhileDo: TWhileDo; SourceCode: TCommonBlock): Boolean; 21 19 function ParseExpression(SourceCode: TExpression): Boolean; 22 20 function ParseExpressionParenthases(SourceCode: TExpression; 23 Expressions: T ListExpression): Boolean;21 Expressions: TExpressions): Boolean; 24 22 function ParseExpressionOperator(SourceCode: TExpression; 25 Expressions: T ListExpression): Boolean;23 Expressions: TExpressions): Boolean; 26 24 function ParseExpressionRightValue(SourceCode: TExpression; 27 Expressions: T ListExpression): Boolean;25 Expressions: TExpressions): Boolean; 28 26 function ParseExpressionFunctionCall(SourceCode: TExpression; 29 Expressions: T ListExpression; var Func: TFunctionCall): Boolean;30 function ParseUses(SourceCode: TUsedModule List; AExported: Boolean): Boolean;31 function ParseUsesItem(SourceCode: TUsedModule List; AExported: Boolean): Boolean;27 Expressions: TExpressions; var Func: TFunctionCall): Boolean; 28 function ParseUses(SourceCode: TUsedModules; AExported: Boolean): Boolean; 29 function ParseUsesItem(SourceCode: TUsedModules; AExported: Boolean): Boolean; 32 30 function ParseModule(ProgramCode: TProgram): TSourceModule; 33 31 function ParseUnit(var SourceCode: TModuleUnit; ProgramCode: TProgram): Boolean; … … 40 38 function ParseCommand(SourceCode: TCommonBlock): TCommand; 41 39 function ParseBeginEnd(var BeginEnd: TBeginEnd; SourceCode: TCommonBlock): Boolean; 42 function ParseFunction(SourceCode: TFunction List; Exported: Boolean = False): Boolean;40 function ParseFunction(SourceCode: TFunctions; Exported: Boolean = False): Boolean; 43 41 procedure ParseFunctionParameters(SourceCode: TFunction; ValidateParams: Boolean = False); 44 42 function ParseIfThenElse(var IfThenElse: TIfThenElse; SourceCode: TCommonBlock): Boolean; … … 46 44 function ParseAssigment(var Assignment: TAssignment; SourceCode: TCommonBlock): Boolean; 47 45 function ParseFunctionCall(var Call: TFunctionCall; SourceCode: TCommonBlock): Boolean; 48 function ParseVariableList(SourceCode: TVariable List; Exported: Boolean = False): Boolean;49 procedure ParseVariable(SourceCode: TVariable List; Exported: Boolean = False);50 function ParseConstantList(SourceCode: TConstant List; Exported: Boolean = False): Boolean;51 function ParseConstant(SourceCode: TConstant List; Exported: Boolean = False): Boolean;52 function ParseType(TypeList: TType List; var NewType: TType; ExpectName: Boolean = True;46 function ParseVariableList(SourceCode: TVariables; Exported: Boolean = False): Boolean; 47 procedure ParseVariable(SourceCode: TVariables; Exported: Boolean = False); 48 function ParseConstantList(SourceCode: TConstants; Exported: Boolean = False): Boolean; 49 function ParseConstant(SourceCode: TConstants; Exported: Boolean = False): Boolean; 50 function ParseType(TypeList: TTypes; var NewType: TType; ExpectName: Boolean = True; 53 51 AssignSymbol: string = '='; ForwardDeclaration: Boolean = False): Boolean; 54 52 function ParseTypeParameters(var NewType: TType): Boolean; … … 86 84 SNotRecordOrClass = '"%s" not record or class'; 87 85 86 88 87 implementation 89 88 90 89 { TAnalyzerPascal } 91 90 92 function TAnalyzerPascal.DebugExpressions(List: T ListExpression): string;91 function TAnalyzerPascal.DebugExpressions(List: TExpressions): string; 93 92 var 94 93 I: Integer; … … 152 151 function TAnalyzerPascal.ParseExpression(SourceCode: TExpression): Boolean; 153 152 var 154 Expressions: T ListExpression;153 Expressions: TExpressions; 155 154 I: Integer; 156 155 II: Integer; … … 158 157 (* with Parser do 159 158 try 160 Expressions := T ListExpression.Create;159 Expressions := TExpressions.Create; 161 160 Expressions.Add(TExpression.Create); 162 161 with SourceCode do begin … … 206 205 207 206 function TAnalyzerPascal.ParseExpressionParenthases(SourceCode: TExpression; 208 Expressions: T ListExpression): Boolean;207 Expressions: TExpressions): Boolean; 209 208 var 210 209 NewExpression: TExpression; … … 230 229 231 230 function TAnalyzerPascal.ParseExpressionOperator(SourceCode: TExpression; 232 Expressions: T ListExpression): Boolean;231 Expressions: TExpressions): Boolean; 233 232 begin 234 233 (*if IsOperator(NextToken) then begin … … 241 240 242 241 function TAnalyzerPascal.ParseExpressionRightValue(SourceCode: TExpression; 243 Expressions: T ListExpression): Boolean;242 Expressions: TExpressions): Boolean; 244 243 var 245 244 UseType: TType; … … 348 347 end; 349 348 if Assigned(NewExpression) then begin 350 TExpression(Expressions.Last).SubItems .Last:= NewExpression;349 TExpression(Expressions.Last).SubItems[TExpression(Expressions.Last).SubItems.Count - 1] := NewExpression; 351 350 with TExpression(Expressions.Items[Expressions.Add(TExpression.Create)]) do 352 351 begin 353 352 CommonBlock := SourceCode.CommonBlock; 354 SubItems .First:= NewExpression;353 SubItems[0] := NewExpression; 355 354 end; 356 355 Result := True; … … 364 363 365 364 function TAnalyzerPascal.ParseExpressionFunctionCall(SourceCode: TExpression; 366 Expressions: T ListExpression; var Func: TFunctionCall): Boolean;365 Expressions: TExpressions; var Func: TFunctionCall): Boolean; 367 366 var 368 367 UseFunction: TFunction; … … 666 665 { TParserParseFunctionList } 667 666 668 function TAnalyzerPascal.ParseFunction(SourceCode: TFunction List;667 function TAnalyzerPascal.ParseFunction(SourceCode: TFunctions; 669 668 Exported: Boolean = False): Boolean; 670 669 var … … 796 795 while (NextToken <> ')') and (NextTokenType <> ttEndOfFile) do begin 797 796 // while IsIdentificator(NextCode) do begin 798 with TParameter List(Parameters) do begin797 with TParameters(Parameters) do begin 799 798 VariableName := ReadToken; 800 799 if VariableName = 'var' then begin … … 948 947 { TParserVariableList } 949 948 950 function TAnalyzerPascal.ParseVariableList(SourceCode: TVariable List; Exported: Boolean = False): Boolean;949 function TAnalyzerPascal.ParseVariableList(SourceCode: TVariables; Exported: Boolean = False): Boolean; 951 950 var 952 951 NewValueType: TType; … … 968 967 { TParserVariable } 969 968 970 procedure TAnalyzerPascal.ParseVariable(SourceCode: TVariable List; Exported: Boolean = False);969 procedure TAnalyzerPascal.ParseVariable(SourceCode: TVariables; Exported: Boolean = False); 971 970 var 972 971 VariableName: string; … … 1016 1015 { TParserConstantList } 1017 1016 1018 function TAnalyzerPascal.ParseConstantList(SourceCode: TConstant List; Exported: Boolean = False): Boolean;1017 function TAnalyzerPascal.ParseConstantList(SourceCode: TConstants; Exported: Boolean = False): Boolean; 1019 1018 begin 1020 1019 with Parser do … … 1030 1029 end; 1031 1030 1032 function TAnalyzerPascal.ParseConstant(SourceCode: TConstant List;1031 function TAnalyzerPascal.ParseConstant(SourceCode: TConstants; 1033 1032 Exported: Boolean): Boolean; 1034 1033 var … … 1082 1081 { TParserType } 1083 1082 1084 function TAnalyzerPascal.ParseType(TypeList: TType List; var NewType: TType; ExpectName: Boolean = True;1083 function TAnalyzerPascal.ParseType(TypeList: TTypes; var NewType: TType; ExpectName: Boolean = True; 1085 1084 AssignSymbol: string = '='; ForwardDeclaration: Boolean = False): Boolean; 1086 1085 begin … … 1471 1470 { TParserUsedModuleList } 1472 1471 1473 function TAnalyzerPascal.ParseUses(SourceCode: TUsedModule List; AExported: Boolean): Boolean;1472 function TAnalyzerPascal.ParseUses(SourceCode: TUsedModules; AExported: Boolean): Boolean; 1474 1473 var 1475 1474 NewUsedModule: TUsedModule; … … 1488 1487 end; 1489 1488 1490 function TAnalyzerPascal.ParseUsesItem(SourceCode: TUsedModule List;1489 function TAnalyzerPascal.ParseUsesItem(SourceCode: TUsedModules; 1491 1490 AExported: Boolean): Boolean; 1492 1491 begin -
trunk/Compiler/Modules/Pascal/ModulePascal.pas
r74 r75 1 unit UModulePascal; 2 3 {$mode delphi}{$H+} 1 unit ModulePascal; 4 2 5 3 interface 6 4 7 5 uses 8 Classes, SysUtils, UModularSystem, UAnalyzerPascal;6 Classes, SysUtils, ModularSystem, AnalyzerPascal; 9 7 10 8 type … … 24 22 25 23 uses 26 UCompilerAPI;24 CompilerAPI; 27 25 28 26 { TModulePascal } … … 31 29 begin 32 30 inherited; 33 Name:= 'Pascal';31 Identification := 'Pascal'; 34 32 Title := 'Pascal'; 35 33 Version := '0.1'; … … 38 36 destructor TModulePascal.Destroy; 39 37 begin 40 inherited Destroy;38 inherited; 41 39 end; 42 40 -
trunk/Compiler/Modules/Pascal/SourceCodePascal.pas
r74 r75 1 unit USourceCodePascal; 2 3 {$MODE Delphi} 4 {$MACRO ON} 1 unit SourceCodePascal; 5 2 6 3 interface 7 4 8 5 uses 9 SysUtils, Variants, Classes, Dialogs, SpecializedList, USourceConvertor;6 SysUtils, Variants, Classes, Dialogs, Generics.Collections, SourceConvertor; 10 7 11 8 type … … 22 19 23 20 TCommonBlock = class; 24 TType List= class;25 TConstant List= class;26 TVariable List= class;27 TFunction List= class;28 T ListExpression= class;21 TTypes = class; 22 TConstants = class; 23 TVariables = class; 24 TFunctions = class; 25 TExpressions = class; 29 26 TExpression = class; 30 27 TFunction = class; … … 40 37 41 38 TContext = class 42 43 end; 44 45 TCommandList = class; 39 end; 40 41 TCommands = class; 46 42 47 43 TCommand = class … … 57 53 end; 58 54 59 // TListExpression = TGObjectList<Integer, TExpression> 60 TListExpression = class(TListObject); 55 { TExpressions } 56 57 TExpressions = class(TObjectList<TExpression>) 58 procedure Assign(Source: TExpressions); 59 end; 61 60 62 61 { TFunctionCall } … … 64 63 TFunctionCall = class(TCommand) 65 64 FunctionRef: TFunction; 66 ParameterExpression: T ListExpression;65 ParameterExpression: TExpressions; 67 66 constructor Create; 68 67 destructor Destroy; override; … … 70 69 71 70 TBeginEnd = class(TCommand) 72 Commands: TCommand List;71 Commands: TCommands; 73 72 CommonBlock: TCommonBlock; 74 73 procedure Clear; … … 90 89 91 90 TRepeatUntil = class(TCommand) 92 Block: TCommand List;91 Block: TCommands; 93 92 Condition: TExpression; 94 93 end; … … 120 119 end; 121 120 122 // TListCaseOfEndBranche = TGObjectList<Integer, TCaseOfEndBranche> 123 TListCaseOfEndBranche = class(TListObject); 121 TListCaseOfEndBranche = class(TObjectList<TCaseOfEndBranche>); 124 122 125 123 TCaseOfEnd = class(TCommand) … … 132 130 133 131 TTryFinally = class(TCommand) 134 Block: TCommand List;135 FinallyBlock: TCommand List;132 Block: TCommands; 133 FinallyBlock: TCommands; 136 134 end; 137 135 138 136 TTryExcept = class(TCommand) 139 Block: TCommandList; 140 ExceptBlock: TCommandList; 141 end; 142 143 // TCommandList = TGObjectList<Integer, TCommand> 144 TCommandList = class(TListObject); 137 Block: TCommands; 138 ExceptBlock: TCommands; 139 end; 140 141 TCommands = class(TObjectList<TCommand>); 145 142 146 143 TCommonBlockSection = (cbsVariable, cbsType, cbsConstant); … … 150 147 Parent: TCommonBlock; 151 148 ParentModule: TSourceModule; 152 Constants: TConstant List;153 Types: TType List;154 Variables: TVariable List;155 Functions: TFunction List;156 Order: T ListObject;149 Constants: TConstants; 150 Types: TTypes; 151 Variables: TVariables; 152 Functions: TFunctions; 153 Order: TObjectList<TObject>; 157 154 Code: TBeginEnd; 158 155 constructor Create; virtual; … … 166 163 ForwardDeclared: Boolean; 167 164 Internal: Boolean; 168 Parent: TType List;165 Parent: TTypes; 169 166 Name: string; 170 167 Size: Integer; … … 172 169 Exported: Boolean; 173 170 Visibility: TTypeVisibility; 174 Parameters: TType List;171 Parameters: TTypes; 175 172 procedure Assign(Source: TType); 176 173 constructor Create; … … 178 175 end; 179 176 180 // TListType = TGObjectList<Integer, TType> 181 TListType = class(TListObject); 182 183 TTypeList = class(TListType) 177 { TTypes } 178 179 TTypes = class(TObjectList<TType>) 184 180 Parent: TCommonBlock; 185 181 function Search(Name: string; Exported: Boolean = False): TType; 186 182 destructor Destroy; override; 183 function AddNew: TType; 187 184 end; 188 185 … … 214 211 end; 215 212 216 // TListEnumItem = TGObjectList<Integer, TEnumItem> 217 TListEnumItem = class(TListObject); 213 TEnumItems = class(TObjectList<TEnumItem>); 218 214 219 215 TTypeEnumeration = class(TType) 220 Items: T ListEnumItem;216 Items: TEnumItems; 221 217 constructor Create; 222 218 destructor Destroy; override; … … 239 235 end; 240 236 241 // TListConstant = TGObjectList<Integer, TConstant> 242 TListConstant = class(TListObject); 243 244 TConstantList = class(TListConstant) 237 TConstants = class(TObjectList<TConstant>) 245 238 Parent: TCommonBlock; 246 239 function Search(Name: string): TConstant; … … 256 249 end; 257 250 258 // TListVariable = TGObjectList<Integer, TVariable> 259 TListVariable = class(TListObject); 260 261 TVariableList = class(TListVariable) 251 TVariables = class(TObjectList<TVariable>) 262 252 Parent: TCommonBlock; 263 253 function Search(Name: string; Exported: Boolean = False): TVariable; … … 268 258 end; 269 259 270 // TListParameter = TGObjectList<Integer, TParameter> 271 TListParameter = class(TListObject); 272 273 TParameterList = class(TListParameter) 260 TParameters = class(TObjectList<TParameter>) 274 261 Parent: TFunction; 275 262 function Search(Name: string): TParameter; … … 288 275 Value: TValue; 289 276 OperatorName: string; 290 SubItems: T ListExpression;277 SubItems: TExpressions; 291 278 Associated: Boolean; 292 279 Braces: Boolean; … … 302 289 Internal: Boolean; 303 290 FunctionType: TFunctionType; 304 Parameters: TParameter List;291 Parameters: TParameters; 305 292 ResultType: TType; 306 293 Exported: Boolean; … … 310 297 end; 311 298 312 // TListFunction = TGObjectList<Integer, TFunction> 313 TListFunction = class(TListObject); 314 315 TFunctionList = class(TListFunction) 299 { TFunctions } 300 301 TFunctions = class(TObjectList<TFunction>) 316 302 Parent: TCommonBlock; 317 303 function Search(Name: string; Exported: Boolean = False): TFunction; 318 304 destructor Destroy; override; 305 function AddNew: TFunction; 319 306 end; 320 307 … … 326 313 end; 327 314 328 // TListUsedModule = TGObjectList<Integer, TUsedModule> 329 TListUsedModule = class(TListObject); 330 331 TUsedModuleList = class(TListUsedModule) 315 TUsedModules = class(TObjectList<TUsedModule>) 332 316 ParentModule: TSourceModule; 333 317 end; … … 340 324 Name: string; 341 325 TargetFile: string; 342 UsedModules: TUsedModule List;326 UsedModules: TUsedModules; 343 327 Body: TCommonBlock; 344 328 Internal: Boolean; … … 374 358 end; 375 359 376 // TListModule = TGObjectList<Integer, TModule> 377 TListModule = class(TListObject); 378 379 { TModuleList } 380 381 TModuleList = class(TListModule) 360 { TModules } 361 362 TModules = class(TObjectList<TSourceModule>) 382 363 function Search(Name: string): TSourceModule; 383 364 end; … … 387 368 TProgram = class(TSource) 388 369 Device: TDevice; 389 Modules: TModule List;370 Modules: TModules; 390 371 MainModule: TSourceModule; 391 372 procedure Clear; … … 408 389 SAssignmentError = 'Assignment error'; 409 390 391 410 392 implementation 411 393 … … 415 397 begin 416 398 inherited; 417 Parameters := TParameter List.Create;399 Parameters := TParameters.Create; 418 400 Parameters.Parent := Self; 419 401 //ResultType := TType.Create; … … 422 404 destructor TFunction.Destroy; 423 405 begin 424 Parameters.Free;425 // ResultType.Free;406 FreeAndNil(Parameters); 407 // FreeAndNil(ResultType); 426 408 inherited; 427 409 end; … … 438 420 begin 439 421 Device := TDevice.Create; 440 Modules := TModule List.Create;422 Modules := TModules.Create; 441 423 end; 442 424 443 425 destructor TProgram.Destroy; 444 426 begin 445 Modules.Free; 446 Device.Free; 447 end; 448 449 { TConstant } 450 451 452 { TConstantList } 453 454 destructor TConstantList.Destroy; 455 begin 456 inherited; 457 end; 458 459 function TConstantList.Search(Name: string): TConstant; 427 FreeAndNil(Modules); 428 FreeAndNil(Device); 429 end; 430 431 { TConstants } 432 433 destructor TConstants.Destroy; 434 begin 435 inherited; 436 end; 437 438 function TConstants.Search(Name: string): TConstant; 460 439 var 461 440 I: Integer; … … 476 455 begin 477 456 inherited; 478 UsedModules := TUsedModule List.Create;457 UsedModules := TUsedModules.Create; 479 458 UsedModules.ParentModule := Self; 480 459 Body := TCommonBlock.Create; … … 484 463 destructor TSourceModule.Destroy; 485 464 begin 486 Body.Free;487 UsedModules.Free;465 FreeAndNil(Body); 466 FreeAndNil(UsedModules); 488 467 inherited; 489 468 end; … … 504 483 constructor TCommonBlock.Create; 505 484 begin 506 Constants := TConstant List.Create;485 Constants := TConstants.Create; 507 486 Constants.Parent := Self; 508 Types := TType List.Create;487 Types := TTypes.Create; 509 488 Types.Parent := Self; 510 Variables := TVariable List.Create;489 Variables := TVariables.Create; 511 490 Variables.Parent := Self; 512 Functions := TFunction List.Create;491 Functions := TFunctions.Create; 513 492 Functions.Parent := Self; 514 493 Code := TBeginEnd.Create; 515 494 Code.Parent := Self; 516 495 Code.CommonBlock := Self; 517 Order := T ListObject.Create;496 Order := TObjectList<TObject>.Create; 518 497 Order.OwnsObjects := False; 519 498 end; … … 521 500 destructor TCommonBlock.Destroy; 522 501 begin 523 Constants.Free; 524 Types.Free; 525 Variables.Free; 526 Functions.Free; 527 Code.Free; 528 Order.Free; 529 inherited; 530 end; 531 532 { TTypeList } 533 534 destructor TTypeList.Destroy; 535 begin 536 inherited; 537 end; 538 539 function TTypeList.Search(Name: string; Exported: Boolean = False): TType; 502 FreeAndNil(Constants); 503 FreeAndNil(Types); 504 FreeAndNil(Variables); 505 FreeAndNil(Functions); 506 FreeAndNil(Code); 507 FreeAndNil(Order); 508 inherited; 509 end; 510 511 { TTypes } 512 513 destructor TTypes.Destroy; 514 begin 515 inherited; 516 end; 517 518 function TTypes.AddNew: TType; 519 begin 520 Result := TType.Create; 521 Add(Result); 522 end; 523 524 function TTypes.Search(Name: string; Exported: Boolean = False): TType; 540 525 var 541 526 I: Integer; … … 557 542 end; 558 543 559 { TVariable List}560 561 destructor TVariable List.Destroy;562 begin 563 inherited; 564 end; 565 566 function TVariable List.Search(Name: string; Exported: Boolean = False): TVariable;544 { TVariables } 545 546 destructor TVariables.Destroy; 547 begin 548 inherited; 549 end; 550 551 function TVariables.Search(Name: string; Exported: Boolean = False): TVariable; 567 552 var 568 553 I: Integer; … … 602 587 end; 603 588 604 { TFunctionList } 605 606 destructor TFunctionList.Destroy; 607 begin 608 inherited; 609 end; 610 611 function TFunctionList.Search(Name: string; Exported: Boolean): TFunction; 589 { TFunctions } 590 591 destructor TFunctions.Destroy; 592 begin 593 inherited; 594 end; 595 596 function TFunctions.AddNew: TFunction; 597 begin 598 Result := TFunction.Create; 599 Add(Result); 600 end; 601 602 function TFunctions.Search(Name: string; Exported: Boolean): TFunction; 612 603 var 613 604 I: Integer; … … 631 622 constructor TExpression.Create; 632 623 begin 633 SubItems := T ListExpression.Create;624 SubItems := TExpressions.Create; 634 625 SubItems.Count := 2; 635 626 SubItems.OwnsObjects := False; … … 638 629 destructor TExpression.Destroy; 639 630 begin 640 SubItems.Free;631 FreeAndNil(SubItems); 641 632 inherited; 642 633 end; … … 654 645 end; 655 646 656 { TParameter List}657 658 destructor TParameter List.Destroy;659 begin 660 inherited; 661 end; 662 663 function TParameter List.Search(Name: string): TParameter;647 { TParameters } 648 649 destructor TParameters.Destroy; 650 begin 651 inherited; 652 end; 653 654 function TParameters.Search(Name: string): TParameter; 664 655 var 665 656 I: Integer; … … 675 666 procedure TBeginEnd.Clear; 676 667 begin 677 678 668 end; 679 669 … … 681 671 begin 682 672 inherited; 683 Commands := TCommand List.Create;673 Commands := TCommands.Create; 684 674 end; 685 675 686 676 destructor TBeginEnd.Destroy; 687 677 begin 688 Commands.Free;678 FreeAndNil(Commands); 689 679 inherited; 690 680 end; … … 699 689 destructor TAssignment.Destroy; 700 690 begin 701 Source.Free; 702 inherited; 691 FreeAndNil(Source); 692 inherited; 693 end; 694 695 { TExpressions } 696 697 procedure TExpressions.Assign(Source: TExpressions); 698 var 699 I: Integer; 700 begin 701 while Count > Source.Count do Delete(Count - 1); 702 while Count < Source.Count do Add(TExpression.Create); 703 for I := 0 to Count - 1 do 704 Items[I].Assign(Source[I]); 703 705 end; 704 706 … … 713 715 destructor TWhileDo.Destroy; 714 716 begin 715 Condition.Free;716 Command.Free;717 FreeAndNil(Condition); 718 FreeAndNil(Command); 717 719 inherited; 718 720 end; … … 728 730 destructor TCaseOfEnd.Destroy; 729 731 begin 730 Branches.Free;732 FreeAndNil(Branches); 731 733 inherited; 732 734 end; … … 741 743 destructor TIfThenElse.Destroy; 742 744 begin 743 Condition.Free;744 inherited Destroy;745 FreeAndNil(Condition); 746 inherited; 745 747 end; 746 748 … … 750 752 begin 751 753 inherited; 752 ParameterExpression := T ListExpression.Create;754 ParameterExpression := TExpressions.Create; 753 755 end; 754 756 755 757 destructor TFunctionCall.Destroy; 756 758 begin 757 ParameterExpression.Free;758 inherited Destroy;759 FreeAndNil(ParameterExpression); 760 inherited; 759 761 end; 760 762 … … 770 772 destructor TForToDo.Destroy; 771 773 begin 772 Start.Free;773 Stop.Free;;774 inherited Destroy;774 FreeAndNil(Start); 775 FreeAndNil(Stop); 776 inherited; 775 777 end; 776 778 … … 785 787 destructor TTypeRecord.Destroy; 786 788 begin 787 CommonBlock.Free;788 inherited Destroy;789 end; 790 791 { TModule List}792 793 function TModule List.Search(Name: string): TSourceModule;789 FreeAndNil(CommonBlock); 790 inherited; 791 end; 792 793 { TModules } 794 795 function TModules.Search(Name: string): TSourceModule; 794 796 var 795 797 I: Integer; … … 820 822 function TSourceModule.SearchConstant(Name: string; Outside: Boolean): TConstant; 821 823 begin 822 823 824 end; 824 825 … … 864 865 destructor TModuleProgram.Destroy; 865 866 begin 866 inherited Destroy;867 inherited; 867 868 end; 868 869 … … 881 882 destructor TModuleUnit.Destroy; 882 883 begin 883 InititializeSection.Free;884 F inalalizeSection.Free;885 inherited Destroy;884 FreeAndNil(InititializeSection); 885 FreeAndNil(FinalalizeSection); 886 inherited; 886 887 end; 887 888 … … 891 892 begin 892 893 inherited; 893 Items := T ListEnumItem.Create;894 Items := TEnumItems.Create; 894 895 end; 895 896 896 897 destructor TTypeEnumeration.Destroy; 897 898 begin 898 Items.Free;899 inherited Destroy;899 FreeAndNil(Items); 900 inherited; 900 901 end; 901 902 … … 910 911 destructor TTypeClass.Destroy; 911 912 begin 912 CommonBlock.Free;913 inherited Destroy;913 FreeAndNil(CommonBlock); 914 inherited; 914 915 end; 915 916 … … 942 943 constructor TType.Create; 943 944 begin 944 Parameters := TType List.Create;945 Parameters := TTypes.Create; 945 946 //Parameters.Parent := Parent.Parent; 946 947 end; … … 948 949 destructor TType.Destroy; 949 950 begin 950 Parameters.Free;951 inherited Destroy;951 FreeAndNil(Parameters); 952 inherited; 952 953 end; 953 954
Note:
See TracChangeset
for help on using the changeset viewer.