Changeset 75 for trunk/Compiler


Ignore:
Timestamp:
Jun 4, 2024, 12:22:49 AM (6 months ago)
Author:
chronos
Message:
  • Modified: Removed U prefix from unit names.
  • Modified: Updated Common package.
Location:
trunk/Compiler
Files:
4 added
2 edited
25 moved

Legend:

Unmodified
Added
Removed
  • trunk/Compiler/Analyzer.pas

    r74 r75  
    1 unit UAnalyzer;
    2 
    3 {$MODE Delphi}
    4 {$MACRO ON}
     1unit Analyzer;
    52
    63interface
    74
    85uses
    9   SysUtils, Variants, Classes, Contnrs,
    10   Dialogs, USourceCodePascal, FileUtil, SpecializedList;
     6  SysUtils, Variants, Classes, Dialogs, SourceCodePascal, FileUtil,
     7  Generics.Collections;
    118
    129type
     
    5451    CodePosition: TPoint;
    5552    SourceCode2: string;
    56     Tokens: TObjectList; // TObjectList<TToken>
     53    Tokens: TObjectList<TToken>;
    5754    TokenIndex: Integer;
    5855    constructor Create;
     
    8380  end;
    8481
    85   { TListAnalyzer }
    86 
    87   TListAnalyzer = class(TListObject)
     82  { TAnalyzers }
     83
     84  TAnalyzers = class(TObjectList<TAnalyzer>)
    8885    function SearchBySysName(Name: string): TAnalyzer;
    8986    procedure LoadToStrings(Strings: TStrings);
     
    9390  SExpectedButFound = 'Expected "%s" but "%s" found.';
    9491
     92
    9593implementation
    9694
    97 { TListAnalyzer }
    98 
    99 function TListAnalyzer.SearchBySysName(Name: string): TAnalyzer;
     95{ TAnalyzers }
     96
     97function TAnalyzers.SearchBySysName(Name: string): TAnalyzer;
    10098var
    10199  I: Integer;
     
    107105end;
    108106
    109 procedure TListAnalyzer.LoadToStrings(Strings: TStrings);
     107procedure TAnalyzers.LoadToStrings(Strings: TStrings);
    110108var
    111109  I: Integer;
     
    154152constructor TAnalyzer.Create;
    155153begin
    156   Tokens := TObjectList.Create;
     154  Tokens := TObjectList<TToken>.Create;
    157155  {$IFDEF windows}
    158156  LineEndingChar := LineEnding[1];
     
    164162destructor TAnalyzer.Destroy;
    165163begin
    166   Tokens.Free;
    167   inherited Destroy;
     164  FreeAndNil(Tokens);
     165  inherited;
    168166end;
    169167
  • trunk/Compiler/Compiler.pas

    r74 r75  
    1 unit UCompiler;
    2 
    3 {$MODE Delphi}
     1unit Compiler;
    42
    53interface
    64
    75uses
    8   SysUtils, Variants, Classes, Contnrs, FileUtil, UModularSystem, UCompilerAPI,
    9   Dialogs, USourceCodePascal, UProducer, UAnalyzer, SpecializedList, UTarget,
    10   fgl;
     6  SysUtils, Variants, Classes, FileUtil, ModularSystem, CompilerAPI,
     7  Dialogs, SourceCodePascal, Producer, Analyzer, Generics.Collections, Target;
    118
    129type
     
    2017
    2118  TSourceFileManager = class
    22     Files: TListString;
     19    Files: TStringList;
    2320    function LoadStringFromFile(FileName: string): string;
    2421    procedure SaveStringToFile(FileName: string; Content: string);
     
    4542  public
    4643    AbstractCode: TProgram;
    47     ErrorMessages: TFPGObjectList<TErrorMessage>;
     44    ErrorMessages: TObjectList<TErrorMessage>;
    4845    CompiledFolder: string;
    4946
    50     Targets: TListTarget;
    51     Analyzers: TListAnalyzer;
    52     Convertors: TListObject;
    53     Executors: TListObject;
     47    Targets: TTargets;
     48    Analyzers: TAnalyzers;
     49    Convertors: TObjectList<TObject>;
     50    Executors: TObjectList<TObject>;
    5451    API: TCompilerAPI;
    5552    TargetFolder: string;
     
    7370
    7471uses
    75   UAnalyzerPascal;
     72  AnalyzerPascal;
    7673
    7774resourcestring
     
    146143constructor TSourceFileManager.Create;
    147144begin
    148   Files := TListString.Create;
     145  Files := TStringList.Create;
    149146end;
    150147
    151148destructor TSourceFileManager.Destroy;
    152149begin
    153   Files.Free;
    154   inherited Destroy;
     150  FreeAndNil(Files);
     151  inherited;
    155152end;
    156153
     
    168165constructor TCompiler.Create;
    169166begin
    170   Targets := TListTarget.Create;
    171   Analyzers := TListAnalyzer.Create;
    172   Convertors := TListObject.Create;
    173   Executors := TListObject.Create;
     167  Targets := TTargets.Create;
     168  Analyzers := TAnalyzers.Create;
     169  Convertors := TObjectList<TObject>.Create;
     170  Executors := TObjectList<TObject>.Create;
    174171  API := TCompilerAPI.Create;
    175172  API.Compiler := Self;
    176173  AbstractCode := TProgram.Create;
    177   ErrorMessages := TFPGObjectList<TErrorMessage>.Create;
     174  ErrorMessages := TObjectList<TErrorMessage>.Create;
    178175  CompiledFolder := 'Compiled';
    179176  ModuleManager := TModuleManager.Create(nil);
  • trunk/Compiler/CompilerAPI.pas

    r74 r75  
    1 unit UCompilerAPI;
    2 
    3 {$mode delphi}{$H+}
     1unit CompilerAPI;
    42
    53interface
    64
    75uses
    8   Classes, SysUtils, UModularSystem, UAnalyzer, UTarget, USourceConvertor,
    9   SpecializedList, UExecutor;
     6  Classes, SysUtils, ModularSystem, Analyzer, Target, SourceConvertor,
     7  Generics.Collections, Executor;
    108
    119type
     
    2523  end;
    2624
     25
    2726implementation
    2827
    2928uses
    30   UCompiler;
     29  Compiler;
    3130
    3231
     
    4039procedure TCompilerAPI.UnregisterTarget(AClass: TTargetClass);
    4140begin
    42   TCompiler(Compiler).Targets.Remove(TObject(AClass));
     41  //TCompiler(Compiler).Targets.Remove(TObject(AClass));
    4342end;
    4443
     
    6968destructor TCompilerAPI.Destroy;
    7069begin
    71   inherited Destroy;
     70  inherited;
    7271end;
    7372
  • trunk/Compiler/Executor.pas

    r74 r75  
    1 unit UExecutor;
    2 
    3 {$mode Delphi}{$H+}
     1unit Executor;
    42
    53interface
     
    3331  TExecutorClass = class of TExecutor;
    3432
     33
    3534implementation
    3635
     
    3938procedure TExecutor.SetRunState(AValue: TRunState);
    4039begin
    41   if FRunState=AValue then Exit;
    42   FRunState:=AValue;
     40  if FRunState = AValue then Exit;
     41  FRunState := AValue;
    4342end;
    4443
  • trunk/Compiler/Modules/ASM8051/ProducerASM8051.pas

    r74 r75  
    1 unit UProducerASM8051;
    2 
    3 {$MODE Delphi}
     1unit ProducerASM8051;
    42
    53interface
     
    75uses
    86  SysUtils, Variants, Classes, Graphics, Controls, Forms,
    9   Dialogs, USourceCodePascal, UProducer, Contnrs;
     7  Dialogs, SourceCodePascal, Producer, Generics.Collections;
    108
    119type
     
    3735    procedure GenerateModule(Module: TSourceModule);
    3836  public
    39     AssemblyCode: TObjectList; // TList<TAssemblerLine>
     37    AssemblyCode: TObjectList<TAssemblerLine>;
    4038    procedure AssignToStringList(Target: TStringList); override;
    4139    procedure Produce(Module: TSourceModule); override;
     
    107105constructor TProducerAsm8051.Create;
    108106begin
    109   AssemblyCode := TObjectList.Create;
     107  AssemblyCode := TObjectList<TAssemblerLine>.Create;
    110108  {$IFDEF Windows}
    111109  CompilerPath := 'c:\ASM8051\ASM51.EXE';
  • trunk/Compiler/Modules/ASM8051/TargetASM8051.pas

    r74 r75  
    1 unit UTargetASM8051;
    2 
    3 {$mode Delphi}{$H+}
     1unit TargetASM8051;
    42
    53interface
    64
    75uses
    8   Classes, SysUtils, UTarget;
     6  Classes, SysUtils, Target;
    97
    108type
     
    1614  end;
    1715
     16
    1817implementation
    1918
     
    2221constructor TTargetASM8051.Create;
    2322begin
    24   inherited Create;
     23  inherited;
    2524  SysName := 'ASM8051';
    2625  Name := 'ASM8051';
  • trunk/Compiler/Modules/Brainfuck/ModuleBrainfuck.pas

    r74 r75  
    1 unit UModuleBrainfuck;
    2 
    3 {$mode delphi}{$H+}
     1unit ModuleBrainfuck;
    42
    53interface
    64
    75uses
    8   Classes, SysUtils, UModularSystem, USourceConvertor;
     6  Classes, SysUtils, ModularSystem, SourceConvertor;
    97
    108type
     
    4240
    4341uses
    44   UCompilerAPI, USourceCodePascal;
     42  CompilerAPI, SourceCodePascal;
    4543
    4644resourcestring
     
    5654constructor TConvertorBFToPascal.Create;
    5755begin
    58   inherited Create;
     56  inherited;
    5957  Name := 'BFToPascal';
    6058  InputType := TSourceBrainfuck;
     
    7169constructor TConvertorTextToBF.Create;
    7270begin
    73   inherited Create;
     71  inherited;
    7472  Name := 'TextToBF';
    7573  InputType := TSourceFileLink;
  • trunk/Compiler/Modules/Delphi/ModuleDelphi.pas

    r74 r75  
    1 unit UModuleDelphi;
    2 
    3 {$mode Delphi}{$H+}
     1unit ModuleDelphi;
    42
    53interface
    64
    75uses
    8   Classes, SysUtils, UTarget, UExecutor, UModularSystem;
     6  Classes, SysUtils, Target, Executor, ModularSystem;
    97
    108type
     
    2826
    2927uses
    30   UProducerDelphi, UCompilerAPI;
     28  ProducerDelphi, CompilerAPI;
    3129
    3230resourcestring
     
    3836begin
    3937  inherited;
    40   Name := 'Delphi';
     38  Identification := 'Delphi';
    4139  Title := SDelphi;
    4240end;
  • trunk/Compiler/Modules/Delphi/ProducerDelphi.pas

    r74 r75  
    1 unit UProducerDelphi;
    2 
    3 {$MODE Delphi}
     1unit ProducerDelphi;
    42
    53interface
     
    75uses
    86  SysUtils, Variants, Classes, Graphics, Controls, Forms,
    9   Dialogs, USourceCodePascal, UProducer, StrUtils, USourceConvertor;
     7  Dialogs, SourceCodePascal, Producer, StrUtils, SourceConvertor;
    108
    119type
     
    1614  private
    1715    Producer: TProducer;
    18     procedure GenerateUses(UsedModules: TUsedModuleList);
     16    procedure GenerateUses(UsedModules: TUsedModules);
    1917    procedure GenerateModule(Module: TSourceModule);
    2018    procedure GenerateUnit(Module: TSourceModule);
     
    2220    procedure GeneratePackage(Module: TSourceModule);
    2321    procedure GenerateType(AType: TType; AssignSymbol: Char = ':');
    24     procedure GenerateTypes(Types: TTypeList);
     22    procedure GenerateTypes(Types: TTypes);
    2523    procedure GenerateCommonBlockInterface(CommonBlock: TCommonBlock;
    2624      LabelPrefix: string);
    2725    procedure GenerateCommonBlockImplementation(CommonBlock: TCommonBlock;
    2826      LabelPrefix: string);
    29     procedure GenerateFunctions(Functions: TFunctionList);
     27    procedure GenerateFunctions(Functions: TFunctions);
    3028    procedure GenerateFunction(AFunction: TFunction);
    3129    procedure GenerateFunctionHead(AFunction: TFunction);
    32     procedure GenerateConstants(Constants: TConstantList);
     30    procedure GenerateConstants(Constants: TConstants);
    3331    procedure GenerateConstant(Constant: TConstant);
    3432    procedure GenerateBeginEnd(BeginEnd: TBeginEnd);
    35     procedure GenerateVariableList(Variables: TVariableList);
     33    procedure GenerateVariableList(Variables: TVariables);
    3634    procedure GenerateVariable(Variable: TVariable);
    3735    procedure GenerateCommand(Command: TCommand);
     
    4947  end;
    5048
     49
    5150implementation
    5251
     
    7271destructor TProducerPascal.Destroy;
    7372begin
    74   Producer.Free;
     73  FreeAndNil(Producer);
    7574  inherited;
    7675end;
    7776
    78 procedure TProducerPascal.GenerateUses(UsedModules: TUsedModuleList);
     77procedure TProducerPascal.GenerateUses(UsedModules: TUsedModules);
    7978var
    8079  I: Integer;
     
    142141procedure TProducerPascal.GenerateLibrary(Module: TSourceModule);
    143142begin
    144 
    145143end;
    146144
    147145procedure TProducerPascal.GeneratePackage(Module: TSourceModule);
    148146begin
    149 
    150147end;
    151148
     
    192189end;
    193190
    194 procedure TProducerPascal.GenerateTypes(Types: TTypeList);
     191procedure TProducerPascal.GenerateTypes(Types: TTypes);
    195192var
    196193  I: Integer;
     
    231228end;
    232229
    233 procedure TProducerPascal.GenerateFunctions(Functions: TFunctionList);
     230procedure TProducerPascal.GenerateFunctions(Functions: TFunctions);
    234231var
    235232  I: Integer;
     
    280277end;
    281278
    282 procedure TProducerPascal.GenerateConstants(Constants: TConstantList);
     279procedure TProducerPascal.GenerateConstants(Constants: TConstants);
    283280var
    284281  I: Integer;
     
    322319end;
    323320
    324 procedure TProducerPascal.GenerateVariableList(Variables: TVariableList);
     321procedure TProducerPascal.GenerateVariableList(Variables: TVariables);
    325322var
    326323  I: Integer;
  • trunk/Compiler/Modules/GCC/ModuleGCC.pas

    r74 r75  
    1 unit UModuleGCC;
    2 
    3 {$mode delphi}{$H+}
     1unit ModuleGCC;
    42
    53interface
    64
    75uses
    8   Classes, SysUtils, UModularSystem, UProducerGCC, UTargetGCC, UCompilerAPI;
     6  Classes, SysUtils, ModularSystem, ProducerGCC, TargetGCC, CompilerAPI;
    97
    108type
     
    1311
    1412  TModuleGCC = class(TModule)
     13  public
    1514    Target: TTargetGCC;
    1615    constructor Create(AOwner: TComponent); override;
     
    3130begin
    3231  inherited;
    33   Name := 'GCC';
     32  Identification := 'GCC';
    3433  Title := SGCC;
    3534end;
  • trunk/Compiler/Modules/GCC/ProducerGCC.pas

    r74 r75  
    1 unit UProducerGCC;
    2 
    3 {$MODE Delphi}
     1unit ProducerGCC;
    42
    53interface
     
    75uses
    86  SysUtils, Variants, Classes, Graphics, Controls, Forms,
    9   Dialogs, StdCtrls, USourceCode, UProducer, StrUtils;
     7  Dialogs, StdCtrls, SourceCodePascal, Producer, StrUtils;
    108
    119type
     
    1917    procedure Emit(AText: string);
    2018    procedure EmitLn(AText: string = '');
    21     procedure GenerateUses(UsedModules: TUsedModuleList);
     19    procedure GenerateUses(UsedModules: TUsedModules);
    2220    procedure GenerateModule(Module: TSourceModule);
    2321    procedure GenerateCommonBlock(CommonBlock: TCommonBlock;
    2422      LabelPrefix: string);
    2523    procedure GenerateType(AType: TType);
    26     procedure GenerateTypes(Types: TTypeList);
     24    procedure GenerateTypes(Types: TTypes);
    2725    procedure GenerateProgram(ProgramBlock: TProgram);
    28     procedure GenerateFunctions(Functions: TFunctionList;
     26    procedure GenerateFunctions(Functions: TFunctions;
    2927      Prefix: string = '');
    3028    procedure GenerateBeginEnd(BeginEnd: TBeginEnd);
    31     procedure GenerateVariableList(VariableList: TVariableList);
     29    procedure GenerateVariableList(VariableList: TVariables);
    3230    procedure GenerateVariable(Variable: TVariable);
    3331    procedure GenerateCommand(Command: TCommand);
     
    113111end;
    114112
    115 procedure TProducerGCCC.GenerateUses(UsedModules: TUsedModuleList);
     113procedure TProducerGCCC.GenerateUses(UsedModules: TUsedModules);
    116114var
    117115  I: Integer;
     
    155153end;
    156154
    157 procedure TProducerGCCC.GenerateFunctions(Functions: TFunctionList;
    158   Prefix: string = '');
     155procedure TProducerGCCC.GenerateFunctions(Functions: TFunctions; Prefix: string
     156  );
    159157var
    160158  I: Integer;
     
    202200end;
    203201
    204 procedure TProducerGCCC.GenerateVariableList(VariableList: TVariableList);
     202procedure TProducerGCCC.GenerateVariableList(VariableList: TVariables);
    205203var
    206204  I: Integer;
     
    361359end;
    362360
    363 procedure TProducerGCCC.GenerateTypes(Types: TTypeList);
     361procedure TProducerGCCC.GenerateTypes(Types: TTypes);
    364362var
    365363  I: Integer;
  • trunk/Compiler/Modules/GCC/TargetGCC.pas

    r74 r75  
    1 unit UTargetGCC;
    2 
    3 {$mode Delphi}{$H+}
     1unit TargetGCC;
    42
    53interface
    64
    75uses
    8   Classes, SysUtils, UTarget;
     6  Classes, SysUtils, Target;
    97
    108type
     
    2220constructor TTargetGCC.Create;
    2321begin
    24   inherited Create;
     22  inherited;
    2523  SysName := 'GCC';
    2624  Name := 'GCC';
  • trunk/Compiler/Modules/Interpretter/ModuleInterpretter.pas

    r74 r75  
    1 unit UModuleInterpretter;
    2 
    3 {$mode Delphi}{$H+}
     1unit ModuleInterpretter;
    42
    53interface
    64
    75uses
    8   Classes, SysUtils, UTarget, UExecutor, USourceCodePascal, Dialogs,
    9   SpecializedList, UModularSystem;
     6  Classes, SysUtils, Target, Executor, SourceCodePascal, Dialogs,
     7  Generics.Collections, ModularSystem;
    108
    119type
     
    3028    function Evaluate(Expression: TExpression): TValue;
    3129  public
    32     Variables: TListObject;
     30    Variables: TObjectList<TVariable>;
    3331    procedure Run; override;
    3432    constructor Create;
     
    4745
    4846uses
    49   UCompiler, UCompilerAPI;
     47  Compiler, CompilerAPI;
    5048
    5149resourcestring
     
    5856begin
    5957  inherited;
    60   Name := 'Interpretter';
     58  Identification := 'Interpretter';
    6159  Title := 'Interpretter';
    6260  Version := '0.1';
     
    187185constructor TExecutorInterpretter.Create;
    188186begin
    189   Variables := TListObject.Create;
     187  Variables := TVariables.Create;
    190188end;
    191189
    192190destructor TExecutorInterpretter.Destroy;
    193191begin
    194   Variables.Free;
    195   inherited Destroy;
     192  FreeAndnil(Variables);
     193  inherited;
    196194end;
    197195
  • trunk/Compiler/Modules/Pascal/AnalyzerPascal.pas

    r74 r75  
    1 unit UAnalyzerPascal;
    2 
    3 {$mode delphi}
     1unit AnalyzerPascal;
    42
    53interface
    64
    75uses
    8   Classes, SysUtils, UAnalyzer, USourceCodePascal, Dialogs, USourceConvertor;
     6  Classes, SysUtils, Analyzer, SourceCodePascal, Dialogs, SourceConvertor;
    97
    108type
     
    1614  public
    1715    Parser: TAnalyzer;
    18     function DebugExpressions(List: TListExpression): string;
     16    function DebugExpressions(List: TExpressions): string;
    1917    function ParseFile(Name: string): Boolean;
    2018    function ParseWhileDo(var WhileDo: TWhileDo; SourceCode: TCommonBlock): Boolean;
    2119    function ParseExpression(SourceCode: TExpression): Boolean;
    2220    function ParseExpressionParenthases(SourceCode: TExpression;
    23       Expressions: TListExpression): Boolean;
     21      Expressions: TExpressions): Boolean;
    2422    function ParseExpressionOperator(SourceCode: TExpression;
    25       Expressions: TListExpression): Boolean;
     23      Expressions: TExpressions): Boolean;
    2624    function ParseExpressionRightValue(SourceCode: TExpression;
    27       Expressions: TListExpression): Boolean;
     25      Expressions: TExpressions): Boolean;
    2826    function ParseExpressionFunctionCall(SourceCode: TExpression;
    29       Expressions: TListExpression; var Func: TFunctionCall): Boolean;
    30     function ParseUses(SourceCode: TUsedModuleList; AExported: Boolean): Boolean;
    31     function ParseUsesItem(SourceCode: TUsedModuleList; 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;
    3230    function ParseModule(ProgramCode: TProgram): TSourceModule;
    3331    function ParseUnit(var SourceCode: TModuleUnit; ProgramCode: TProgram): Boolean;
     
    4038    function ParseCommand(SourceCode: TCommonBlock): TCommand;
    4139    function ParseBeginEnd(var BeginEnd: TBeginEnd; SourceCode: TCommonBlock): Boolean;
    42     function ParseFunction(SourceCode: TFunctionList; Exported: Boolean = False): Boolean;
     40    function ParseFunction(SourceCode: TFunctions; Exported: Boolean = False): Boolean;
    4341    procedure ParseFunctionParameters(SourceCode: TFunction; ValidateParams: Boolean = False);
    4442    function ParseIfThenElse(var IfThenElse: TIfThenElse; SourceCode: TCommonBlock): Boolean;
     
    4644    function ParseAssigment(var Assignment: TAssignment; SourceCode: TCommonBlock): Boolean;
    4745    function ParseFunctionCall(var Call: TFunctionCall; SourceCode: TCommonBlock): Boolean;
    48     function ParseVariableList(SourceCode: TVariableList; Exported: Boolean = False): Boolean;
    49     procedure ParseVariable(SourceCode: TVariableList; Exported: Boolean = False);
    50     function ParseConstantList(SourceCode: TConstantList; Exported: Boolean = False): Boolean;
    51     function ParseConstant(SourceCode: TConstantList; Exported: Boolean = False): Boolean;
    52     function ParseType(TypeList: TTypeList; 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;
    5351      AssignSymbol: string = '='; ForwardDeclaration: Boolean = False): Boolean;
    5452    function ParseTypeParameters(var NewType: TType): Boolean;
     
    8684  SNotRecordOrClass = '"%s" not record or class';
    8785
     86
    8887implementation
    8988
    9089{ TAnalyzerPascal }
    9190
    92 function TAnalyzerPascal.DebugExpressions(List: TListExpression): string;
     91function TAnalyzerPascal.DebugExpressions(List: TExpressions): string;
    9392var
    9493  I: Integer;
     
    152151function TAnalyzerPascal.ParseExpression(SourceCode: TExpression): Boolean;
    153152var
    154   Expressions: TListExpression;
     153  Expressions: TExpressions;
    155154  I: Integer;
    156155  II: Integer;
     
    158157(*  with Parser do
    159158  try
    160     Expressions := TListExpression.Create;
     159    Expressions := TExpressions.Create;
    161160    Expressions.Add(TExpression.Create);
    162161    with SourceCode do begin
     
    206205
    207206function TAnalyzerPascal.ParseExpressionParenthases(SourceCode: TExpression;
    208   Expressions: TListExpression): Boolean;
     207  Expressions: TExpressions): Boolean;
    209208var
    210209  NewExpression: TExpression;
     
    230229
    231230function TAnalyzerPascal.ParseExpressionOperator(SourceCode: TExpression;
    232   Expressions: TListExpression): Boolean;
     231  Expressions: TExpressions): Boolean;
    233232begin
    234233  (*if IsOperator(NextToken) then begin
     
    241240
    242241function TAnalyzerPascal.ParseExpressionRightValue(SourceCode: TExpression;
    243   Expressions: TListExpression): Boolean;
     242  Expressions: TExpressions): Boolean;
    244243var
    245244  UseType: TType;
     
    348347    end;
    349348    if Assigned(NewExpression) then begin
    350       TExpression(Expressions.Last).SubItems.Last := NewExpression;
     349      TExpression(Expressions.Last).SubItems[TExpression(Expressions.Last).SubItems.Count - 1] := NewExpression;
    351350      with TExpression(Expressions.Items[Expressions.Add(TExpression.Create)]) do
    352351      begin
    353352        CommonBlock := SourceCode.CommonBlock;
    354         SubItems.First := NewExpression;
     353        SubItems[0] := NewExpression;
    355354      end;
    356355      Result := True;
     
    364363
    365364function TAnalyzerPascal.ParseExpressionFunctionCall(SourceCode: TExpression;
    366   Expressions: TListExpression; var Func: TFunctionCall): Boolean;
     365  Expressions: TExpressions; var Func: TFunctionCall): Boolean;
    367366var
    368367  UseFunction: TFunction;
     
    666665{ TParserParseFunctionList }
    667666
    668 function TAnalyzerPascal.ParseFunction(SourceCode: TFunctionList;
     667function TAnalyzerPascal.ParseFunction(SourceCode: TFunctions;
    669668  Exported: Boolean = False): Boolean;
    670669var
     
    796795        while (NextToken <> ')') and (NextTokenType <> ttEndOfFile) do begin
    797796          // while IsIdentificator(NextCode) do begin
    798           with TParameterList(Parameters) do begin
     797          with TParameters(Parameters) do begin
    799798            VariableName := ReadToken;
    800799            if VariableName = 'var' then begin
     
    948947{ TParserVariableList }
    949948
    950 function TAnalyzerPascal.ParseVariableList(SourceCode: TVariableList; Exported: Boolean = False): Boolean;
     949function TAnalyzerPascal.ParseVariableList(SourceCode: TVariables; Exported: Boolean = False): Boolean;
    951950var
    952951  NewValueType: TType;
     
    968967{ TParserVariable }
    969968
    970 procedure TAnalyzerPascal.ParseVariable(SourceCode: TVariableList; Exported: Boolean = False);
     969procedure TAnalyzerPascal.ParseVariable(SourceCode: TVariables; Exported: Boolean = False);
    971970var
    972971  VariableName: string;
     
    10161015{ TParserConstantList }
    10171016
    1018 function TAnalyzerPascal.ParseConstantList(SourceCode: TConstantList; Exported: Boolean = False): Boolean;
     1017function TAnalyzerPascal.ParseConstantList(SourceCode: TConstants; Exported: Boolean = False): Boolean;
    10191018begin
    10201019  with Parser do
     
    10301029end;
    10311030
    1032 function TAnalyzerPascal.ParseConstant(SourceCode: TConstantList;
     1031function TAnalyzerPascal.ParseConstant(SourceCode: TConstants;
    10331032  Exported: Boolean): Boolean;
    10341033var
     
    10821081{ TParserType }
    10831082
    1084 function TAnalyzerPascal.ParseType(TypeList: TTypeList; var NewType: TType; ExpectName: Boolean = True;
     1083function TAnalyzerPascal.ParseType(TypeList: TTypes; var NewType: TType; ExpectName: Boolean = True;
    10851084  AssignSymbol: string = '='; ForwardDeclaration: Boolean = False): Boolean;
    10861085begin
     
    14711470{ TParserUsedModuleList }
    14721471
    1473 function TAnalyzerPascal.ParseUses(SourceCode: TUsedModuleList; AExported: Boolean): Boolean;
     1472function TAnalyzerPascal.ParseUses(SourceCode: TUsedModules; AExported: Boolean): Boolean;
    14741473var
    14751474  NewUsedModule: TUsedModule;
     
    14881487end;
    14891488
    1490 function TAnalyzerPascal.ParseUsesItem(SourceCode: TUsedModuleList;
     1489function TAnalyzerPascal.ParseUsesItem(SourceCode: TUsedModules;
    14911490  AExported: Boolean): Boolean;
    14921491begin
  • trunk/Compiler/Modules/Pascal/ModulePascal.pas

    r74 r75  
    1 unit UModulePascal;
    2 
    3 {$mode delphi}{$H+}
     1unit ModulePascal;
    42
    53interface
    64
    75uses
    8   Classes, SysUtils, UModularSystem, UAnalyzerPascal;
     6  Classes, SysUtils, ModularSystem, AnalyzerPascal;
    97
    108type
     
    2422
    2523uses
    26   UCompilerAPI;
     24  CompilerAPI;
    2725
    2826{ TModulePascal }
     
    3129begin
    3230  inherited;
    33   Name := 'Pascal';
     31  Identification := 'Pascal';
    3432  Title := 'Pascal';
    3533  Version := '0.1';
     
    3836destructor TModulePascal.Destroy;
    3937begin
    40   inherited Destroy;
     38  inherited;
    4139end;
    4240
  • trunk/Compiler/Modules/Pascal/SourceCodePascal.pas

    r74 r75  
    1 unit USourceCodePascal;
    2 
    3 {$MODE Delphi}
    4 {$MACRO ON}
     1unit SourceCodePascal;
    52
    63interface
    74
    85uses
    9   SysUtils, Variants, Classes, Dialogs, SpecializedList, USourceConvertor;
     6  SysUtils, Variants, Classes, Dialogs, Generics.Collections, SourceConvertor;
    107
    118type
     
    2219
    2320  TCommonBlock = class;
    24   TTypeList = class;
    25   TConstantList = class;
    26   TVariableList = class;
    27   TFunctionList = class;
    28   TListExpression = class;
     21  TTypes = class;
     22  TConstants = class;
     23  TVariables = class;
     24  TFunctions = class;
     25  TExpressions = class;
    2926  TExpression = class;
    3027  TFunction = class;
     
    4037
    4138  TContext = class
    42 
    43   end;
    44 
    45   TCommandList = class;
     39  end;
     40
     41  TCommands = class;
    4642
    4743  TCommand = class
     
    5753  end;
    5854
    59   // TListExpression = TGObjectList<Integer, TExpression>
    60   TListExpression = class(TListObject);
     55  { TExpressions }
     56
     57  TExpressions = class(TObjectList<TExpression>)
     58    procedure Assign(Source: TExpressions);
     59  end;
    6160
    6261  { TFunctionCall }
     
    6463  TFunctionCall = class(TCommand)
    6564    FunctionRef: TFunction;
    66     ParameterExpression: TListExpression;
     65    ParameterExpression: TExpressions;
    6766    constructor Create;
    6867    destructor Destroy; override;
     
    7069
    7170  TBeginEnd = class(TCommand)
    72     Commands: TCommandList;
     71    Commands: TCommands;
    7372    CommonBlock: TCommonBlock;
    7473    procedure Clear;
     
    9089
    9190  TRepeatUntil = class(TCommand)
    92     Block: TCommandList;
     91    Block: TCommands;
    9392    Condition: TExpression;
    9493  end;
     
    120119  end;
    121120
    122   // TListCaseOfEndBranche = TGObjectList<Integer, TCaseOfEndBranche>
    123   TListCaseOfEndBranche = class(TListObject);
     121  TListCaseOfEndBranche = class(TObjectList<TCaseOfEndBranche>);
    124122
    125123  TCaseOfEnd = class(TCommand)
     
    132130
    133131  TTryFinally = class(TCommand)
    134     Block: TCommandList;
    135     FinallyBlock: TCommandList;
     132    Block: TCommands;
     133    FinallyBlock: TCommands;
    136134  end;
    137135
    138136  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>);
    145142
    146143  TCommonBlockSection = (cbsVariable, cbsType, cbsConstant);
     
    150147    Parent: TCommonBlock;
    151148    ParentModule: TSourceModule;
    152     Constants: TConstantList;
    153     Types: TTypeList;
    154     Variables: TVariableList;
    155     Functions: TFunctionList;
    156     Order: TListObject;
     149    Constants: TConstants;
     150    Types: TTypes;
     151    Variables: TVariables;
     152    Functions: TFunctions;
     153    Order: TObjectList<TObject>;
    157154    Code: TBeginEnd;
    158155    constructor Create; virtual;
     
    166163    ForwardDeclared: Boolean;
    167164    Internal: Boolean;
    168     Parent: TTypeList;
     165    Parent: TTypes;
    169166    Name: string;
    170167    Size: Integer;
     
    172169    Exported: Boolean;
    173170    Visibility: TTypeVisibility;
    174     Parameters: TTypeList;
     171    Parameters: TTypes;
    175172    procedure Assign(Source: TType);
    176173    constructor Create;
     
    178175  end;
    179176
    180   // TListType = TGObjectList<Integer, TType>
    181   TListType = class(TListObject);
    182 
    183   TTypeList = class(TListType)
     177  { TTypes }
     178
     179  TTypes = class(TObjectList<TType>)
    184180    Parent: TCommonBlock;
    185181    function Search(Name: string; Exported: Boolean = False): TType;
    186182    destructor Destroy; override;
     183    function AddNew: TType;
    187184  end;
    188185
     
    214211  end;
    215212
    216   // TListEnumItem = TGObjectList<Integer, TEnumItem>
    217   TListEnumItem = class(TListObject);
     213  TEnumItems = class(TObjectList<TEnumItem>);
    218214
    219215  TTypeEnumeration = class(TType)
    220     Items: TListEnumItem;
     216    Items: TEnumItems;
    221217    constructor Create;
    222218    destructor Destroy; override;
     
    239235  end;
    240236
    241   // TListConstant = TGObjectList<Integer, TConstant>
    242   TListConstant = class(TListObject);
    243 
    244   TConstantList = class(TListConstant)
     237  TConstants = class(TObjectList<TConstant>)
    245238    Parent: TCommonBlock;
    246239    function Search(Name: string): TConstant;
     
    256249  end;
    257250
    258   // TListVariable = TGObjectList<Integer, TVariable>
    259   TListVariable = class(TListObject);
    260 
    261   TVariableList = class(TListVariable)
     251  TVariables = class(TObjectList<TVariable>)
    262252    Parent: TCommonBlock;
    263253    function Search(Name: string; Exported: Boolean = False): TVariable;
     
    268258  end;
    269259
    270   // TListParameter = TGObjectList<Integer, TParameter>
    271   TListParameter = class(TListObject);
    272 
    273   TParameterList = class(TListParameter)
     260  TParameters = class(TObjectList<TParameter>)
    274261    Parent: TFunction;
    275262    function Search(Name: string): TParameter;
     
    288275    Value: TValue;
    289276    OperatorName: string;
    290     SubItems: TListExpression;
     277    SubItems: TExpressions;
    291278    Associated: Boolean;
    292279    Braces: Boolean;
     
    302289    Internal: Boolean;
    303290    FunctionType: TFunctionType;
    304     Parameters: TParameterList;
     291    Parameters: TParameters;
    305292    ResultType: TType;
    306293    Exported: Boolean;
     
    310297  end;
    311298
    312   // TListFunction = TGObjectList<Integer, TFunction>
    313   TListFunction = class(TListObject);
    314 
    315   TFunctionList = class(TListFunction)
     299  { TFunctions }
     300
     301  TFunctions = class(TObjectList<TFunction>)
    316302    Parent: TCommonBlock;
    317303    function Search(Name: string; Exported: Boolean = False): TFunction;
    318304    destructor Destroy; override;
     305    function AddNew: TFunction;
    319306  end;
    320307
     
    326313  end;
    327314
    328   // TListUsedModule = TGObjectList<Integer, TUsedModule>
    329   TListUsedModule = class(TListObject);
    330 
    331   TUsedModuleList = class(TListUsedModule)
     315  TUsedModules = class(TObjectList<TUsedModule>)
    332316    ParentModule: TSourceModule;
    333317  end;
     
    340324    Name: string;
    341325    TargetFile: string;
    342     UsedModules: TUsedModuleList;
     326    UsedModules: TUsedModules;
    343327    Body: TCommonBlock;
    344328    Internal: Boolean;
     
    374358  end;
    375359
    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>)
    382363    function Search(Name: string): TSourceModule;
    383364  end;
     
    387368  TProgram = class(TSource)
    388369    Device: TDevice;
    389     Modules: TModuleList;
     370    Modules: TModules;
    390371    MainModule: TSourceModule;
    391372    procedure Clear;
     
    408389  SAssignmentError = 'Assignment error';
    409390
     391
    410392implementation
    411393
     
    415397begin
    416398  inherited;
    417   Parameters := TParameterList.Create;
     399  Parameters := TParameters.Create;
    418400  Parameters.Parent := Self;
    419401  //ResultType := TType.Create;
     
    422404destructor TFunction.Destroy;
    423405begin
    424   Parameters.Free;
    425 //  ResultType.Free;
     406  FreeAndNil(Parameters);
     407//  FreeAndNil(ResultType);
    426408  inherited;
    427409end;
     
    438420begin
    439421  Device := TDevice.Create;
    440   Modules := TModuleList.Create;
     422  Modules := TModules.Create;
    441423end;
    442424
    443425destructor TProgram.Destroy;
    444426begin
    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);
     429end;
     430
     431{ TConstants }
     432
     433destructor TConstants.Destroy;
     434begin
     435  inherited;
     436end;
     437
     438function TConstants.Search(Name: string): TConstant;
    460439var
    461440  I: Integer;
     
    476455begin
    477456  inherited;
    478   UsedModules := TUsedModuleList.Create;
     457  UsedModules := TUsedModules.Create;
    479458  UsedModules.ParentModule := Self;
    480459  Body := TCommonBlock.Create;
     
    484463destructor TSourceModule.Destroy;
    485464begin
    486   Body.Free;
    487   UsedModules.Free;
     465  FreeAndNil(Body);
     466  FreeAndNil(UsedModules);
    488467  inherited;
    489468end;
     
    504483constructor TCommonBlock.Create;
    505484begin
    506   Constants := TConstantList.Create;
     485  Constants := TConstants.Create;
    507486  Constants.Parent := Self;
    508   Types := TTypeList.Create;
     487  Types := TTypes.Create;
    509488  Types.Parent := Self;
    510   Variables := TVariableList.Create;
     489  Variables := TVariables.Create;
    511490  Variables.Parent := Self;
    512   Functions := TFunctionList.Create;
     491  Functions := TFunctions.Create;
    513492  Functions.Parent := Self;
    514493  Code := TBeginEnd.Create;
    515494  Code.Parent := Self;
    516495  Code.CommonBlock := Self;
    517   Order := TListObject.Create;
     496  Order := TObjectList<TObject>.Create;
    518497  Order.OwnsObjects := False;
    519498end;
     
    521500destructor TCommonBlock.Destroy;
    522501begin
    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;
     509end;
     510
     511{ TTypes }
     512
     513destructor TTypes.Destroy;
     514begin
     515  inherited;
     516end;
     517
     518function TTypes.AddNew: TType;
     519begin
     520  Result := TType.Create;
     521  Add(Result);
     522end;
     523
     524function TTypes.Search(Name: string; Exported: Boolean = False): TType;
    540525var
    541526  I: Integer;
     
    557542end;
    558543
    559 { TVariableList }
    560 
    561 destructor TVariableList.Destroy;
    562 begin
    563   inherited;
    564 end;
    565 
    566 function TVariableList.Search(Name: string; Exported: Boolean = False): TVariable;
     544{ TVariables }
     545
     546destructor TVariables.Destroy;
     547begin
     548  inherited;
     549end;
     550
     551function TVariables.Search(Name: string; Exported: Boolean = False): TVariable;
    567552var
    568553  I: Integer;
     
    602587end;
    603588
    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
     591destructor TFunctions.Destroy;
     592begin
     593  inherited;
     594end;
     595
     596function TFunctions.AddNew: TFunction;
     597begin
     598  Result := TFunction.Create;
     599  Add(Result);
     600end;
     601
     602function TFunctions.Search(Name: string; Exported: Boolean): TFunction;
    612603var
    613604  I: Integer;
     
    631622constructor TExpression.Create;
    632623begin
    633   SubItems := TListExpression.Create;
     624  SubItems := TExpressions.Create;
    634625  SubItems.Count := 2;
    635626  SubItems.OwnsObjects := False;
     
    638629destructor TExpression.Destroy;
    639630begin
    640   SubItems.Free;
     631  FreeAndNil(SubItems);
    641632  inherited;
    642633end;
     
    654645end;
    655646
    656 { TParameterList }
    657 
    658 destructor TParameterList.Destroy;
    659 begin
    660   inherited;
    661 end;
    662 
    663 function TParameterList.Search(Name: string): TParameter;
     647{ TParameters }
     648
     649destructor TParameters.Destroy;
     650begin
     651  inherited;
     652end;
     653
     654function TParameters.Search(Name: string): TParameter;
    664655var
    665656  I: Integer;
     
    675666procedure TBeginEnd.Clear;
    676667begin
    677 
    678668end;
    679669
     
    681671begin
    682672  inherited;
    683   Commands := TCommandList.Create;
     673  Commands := TCommands.Create;
    684674end;
    685675
    686676destructor TBeginEnd.Destroy;
    687677begin
    688   Commands.Free;
     678  FreeAndNil(Commands);
    689679  inherited;
    690680end;
     
    699689destructor TAssignment.Destroy;
    700690begin
    701   Source.Free;
    702   inherited;
     691  FreeAndNil(Source);
     692  inherited;
     693end;
     694
     695{ TExpressions }
     696
     697procedure TExpressions.Assign(Source: TExpressions);
     698var
     699  I: Integer;
     700begin
     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]);
    703705end;
    704706
     
    713715destructor TWhileDo.Destroy;
    714716begin
    715   Condition.Free;
    716   Command.Free;
     717  FreeAndNil(Condition);
     718  FreeAndNil(Command);
    717719  inherited;
    718720end;
     
    728730destructor TCaseOfEnd.Destroy;
    729731begin
    730   Branches.Free;
     732  FreeAndNil(Branches);
    731733  inherited;
    732734end;
     
    741743destructor TIfThenElse.Destroy;
    742744begin
    743   Condition.Free;
    744   inherited Destroy;
     745  FreeAndNil(Condition);
     746  inherited;
    745747end;
    746748
     
    750752begin
    751753  inherited;
    752   ParameterExpression := TListExpression.Create;
     754  ParameterExpression := TExpressions.Create;
    753755end;
    754756
    755757destructor TFunctionCall.Destroy;
    756758begin
    757   ParameterExpression.Free;
    758   inherited Destroy;
     759  FreeAndNil(ParameterExpression);
     760  inherited;
    759761end;
    760762
     
    770772destructor TForToDo.Destroy;
    771773begin
    772   Start.Free;
    773   Stop.Free;;
    774   inherited Destroy;
     774  FreeAndNil(Start);
     775  FreeAndNil(Stop);
     776  inherited;
    775777end;
    776778
     
    785787destructor TTypeRecord.Destroy;
    786788begin
    787   CommonBlock.Free;
    788   inherited Destroy;
    789 end;
    790 
    791 { TModuleList }
    792 
    793 function TModuleList.Search(Name: string): TSourceModule;
     789  FreeAndNil(CommonBlock);
     790  inherited;
     791end;
     792
     793{ TModules }
     794
     795function TModules.Search(Name: string): TSourceModule;
    794796var
    795797  I: Integer;
     
    820822function TSourceModule.SearchConstant(Name: string; Outside: Boolean): TConstant;
    821823begin
    822 
    823824end;
    824825
     
    864865destructor TModuleProgram.Destroy;
    865866begin
    866   inherited Destroy;
     867  inherited;
    867868end;
    868869
     
    881882destructor TModuleUnit.Destroy;
    882883begin
    883   InititializeSection.Free;
    884   FinalalizeSection.Free;
    885   inherited Destroy;
     884  FreeAndNil(InititializeSection);
     885  FreeAndNil(FinalalizeSection);
     886  inherited;
    886887end;
    887888
     
    891892begin
    892893  inherited;
    893   Items := TListEnumItem.Create;
     894  Items := TEnumItems.Create;
    894895end;
    895896
    896897destructor TTypeEnumeration.Destroy;
    897898begin
    898   Items.Free;
    899   inherited Destroy;
     899  FreeAndNil(Items);
     900  inherited;
    900901end;
    901902
     
    910911destructor TTypeClass.Destroy;
    911912begin
    912   CommonBlock.Free;
    913   inherited Destroy;
     913  FreeAndNil(CommonBlock);
     914  inherited;
    914915end;
    915916
     
    942943constructor TType.Create;
    943944begin
    944   Parameters := TTypeList.Create;
     945  Parameters := TTypes.Create;
    945946  //Parameters.Parent := Parent.Parent;
    946947end;
     
    948949destructor TType.Destroy;
    949950begin
    950   Parameters.Free;
    951   inherited Destroy;
     951  FreeAndNil(Parameters);
     952  inherited;
    952953end;
    953954
  • trunk/Compiler/Producer.pas

    r74 r75  
    1 unit UProducer;
    2 
    3 {$MODE Delphi}
     1unit Producer;
    42
    53interface
    64
    75uses
    8   USourceCodePascal, Classes, SysUtils, StrUtils, SpecializedList, Process,
     6  SourceCodePascal, Classes, SysUtils, StrUtils, Generics.Collections, Process,
    97  FileUtil, Forms;
    108
  • trunk/Compiler/SourceConvertor.pas

    r74 r75  
    1 unit USourceConvertor;
    2 
    3 {$mode delphi}{$H+}
     1unit SourceConvertor;
    42
    53interface
    64
    75uses
    8   Classes, SysUtils, SpecializedList;
     6  Classes, SysUtils, Generics.Collections;
    97
    108type
     
    2220
    2321  TSourceText = class(TSource)
    24     Code: TListString;
     22    Code: TStringList;
    2523    constructor Create;
    2624    destructor Destroy; override;
     
    2826
    2927  TSourceList = class
    30     Items: TListObject; // TListObject<TSource>
     28    Items: TObjectList<TSource>;
    3129  end;
    3230
     
    5755procedure TConvertor.Convert(Input, Output: TSourceList);
    5856begin
    59 
    6057end;
    6158
     
    7471constructor TSourceText.Create;
    7572begin
    76   Code := TListString.Create;
     73  Code := TStringList.Create;
    7774end;
    7875
    7976destructor TSourceText.Destroy;
    8077begin
    81   Code.Free;
    82   inherited Destroy;
     78  FreeAndNil(Code);
     79  inherited;
    8380end;
    8481
  • trunk/Compiler/Target.pas

    r74 r75  
    1 unit UTarget;
    2 
    3 {$mode Delphi}{$H+}
     1unit Target;
    42
    53interface
    64
    75uses
    8   Classes, SysUtils, UProducer, UExecutor, SpecializedList;
     6  Classes, SysUtils, Producer, Executor, Generics.Collections;
    97
    108type
     
    1715    Producer: TProducer;
    1816    Executor: TExecutor;
    19     Compiler: TObject; //TCompiler
     17    Compiler: TObject; // TCompiler
    2018    constructor Create; virtual;
    2119    destructor Destroy; override;
     
    2422  TTargetClass = class of TTarget;
    2523
    26   { TListTarget }
     24  { TTargets }
    2725
    28   TListTarget = class(TListObject)
     26  TTargets = class(TObjectList<TTarget>)
    2927    function SearchBySysName(Name: string): TTarget;
    3028    procedure LoadToStrings(Strings: TStrings);
     
    4341destructor TTarget.Destroy;
    4442begin
    45   Producer.Free;
    46   Executor.Free;
    47   inherited Destroy;
     43  FreeAndNil(Producer);
     44  FreeAndNil(Executor);
     45  inherited;
    4846end;
    4947
    50 { TListTarget }
     48{ TTargets }
    5149
    52 function TListTarget.SearchBySysName(Name: string): TTarget;
     50function TTargets.SearchBySysName(Name: string): TTarget;
    5351var
    5452  I: Integer;
     
    6058end;
    6159
    62 procedure TListTarget.LoadToStrings(Strings: TStrings);
     60procedure TTargets.LoadToStrings(Strings: TStrings);
    6361var
    6462  I: Integer;
  • trunk/Compiler/Target/Dynamic C/ProducerDynamicC.pas

    r74 r75  
    1 unit UProducerDynamicc;
    2 
    3 {$MODE Delphi}
     1unit ProducerDynamicC;
    42
    53interface
     
    75uses
    86  SysUtils, Variants, Classes, Graphics, Controls, Forms,
    9   Dialogs, StdCtrls, USourceCodePascal, UProducer, StrUtils;
     7  Dialogs, StdCtrls, SourceCodePascal, Producer, StrUtils;
    108
    119type
     
    1715    function TranslateType(Name: string): string;
    1816    function TranslateOperator(Name: string): string;
    19     procedure GenerateUses(UsedModules: TUsedModuleList);
     17    procedure GenerateUses(UsedModules: TUsedModules);
    2018    procedure GenerateModule(Module: TSourceModule);
    2119    procedure GenerateCommonBlock(CommonBlock: TCommonBlock;
    2220      LabelPrefix: string);
    2321    procedure GenerateType(AType: TType);
    24     procedure GenerateTypes(Types: TTypeList);
     22    procedure GenerateTypes(Types: TTypes);
    2523    procedure GenerateProgram(ProgramBlock: TProgram);
    26     procedure GenerateFunctions(Functions: TFunctionList;
     24    procedure GenerateFunctions(Functions: TFunctions;
    2725      Prefix: string = ''; HeaderOnly: Boolean = False);
    2826    procedure GenerateBeginEnd(BeginEnd: TBeginEnd);
    29     procedure GenerateVariableList(VariableList: TVariableList);
     27    procedure GenerateVariableList(VariableList: TVariables);
    3028    procedure GenerateVariable(Variable: TVariable);
    3129    procedure GenerateCommand(Command: TCommand);
     
    4341  end;
    4442
     43
    4544implementation
    4645
     
    5655destructor TProducerDynamicC.Destroy;
    5756begin
    58   TextSource.Free;
     57  FreeAndNil(TextSource);
    5958  inherited;
    6059end;
     
    8786end;
    8887
    89 procedure TProducerDynamicC.GenerateUses(UsedModules: TUsedModuleList);
     88procedure TProducerDynamicC.GenerateUses(UsedModules: TUsedModules);
    9089var
    9190  I: Integer;
     
    150149end;
    151150
    152 procedure TProducerDynamicC.GenerateFunctions(Functions: TFunctionList;
     151procedure TProducerDynamicC.GenerateFunctions(Functions: TFunctions;
    153152  Prefix: string = ''; HeaderOnly: Boolean = False);
    154153var
     
    197196end;
    198197
    199 procedure TProducerDynamicC.GenerateVariableList(VariableList: TVariableList);
     198procedure TProducerDynamicC.GenerateVariableList(VariableList: TVariables);
    200199var
    201200  I: Integer;
     
    360359end;
    361360
    362 procedure TProducerDynamicC.GenerateTypes(Types: TTypeList);
     361procedure TProducerDynamicC.GenerateTypes(Types: TTypes);
    363362var
    364363  I: Integer;
  • trunk/Compiler/Target/GCC/ProducerGCC.pas

    r74 r75  
    1 unit UProducerGCC;
    2 
    3 {$MODE Delphi}
     1unit ProducerGCC;
    42
    53interface
    64
    75uses
    8   SysUtils, Variants, Classes, Graphics, Controls, Forms,
    9   Dialogs, StdCtrls, USourceCodePascal, UProducer, StrUtils;
     6  SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls,
     7  SourceCodePascal, Producer, StrUtils;
    108
    119type
     
    1917    procedure Emit(AText: string);
    2018    procedure EmitLn(AText: string = '');
    21     procedure GenerateUses(UsedModules: TUsedModuleList);
     19    procedure GenerateUses(UsedModules: TUsedModules);
    2220    procedure GenerateModule(Module: TSourceModule);
    2321    procedure GenerateCommonBlock(CommonBlock: TCommonBlock;
    2422      LabelPrefix: string);
    2523    procedure GenerateType(AType: TType);
    26     procedure GenerateTypes(Types: TTypeList);
     24    procedure GenerateTypes(Types: TTypes);
    2725    procedure GenerateProgram(ProgramBlock: TProgram);
    28     procedure GenerateFunctions(Functions: TFunctionList;
     26    procedure GenerateFunctions(Functions: TFunctions;
    2927      Prefix: string = '');
    3028    procedure GenerateBeginEnd(BeginEnd: TBeginEnd);
    31     procedure GenerateVariableList(VariableList: TVariableList);
     29    procedure GenerateVariableList(VariableList: TVariables);
    3230    procedure GenerateVariable(Variable: TVariable);
    3331    procedure GenerateCommand(Command: TCommand);
     
    4846  end;
    4947
     48
    5049implementation
    5150
     
    6665destructor TProducerGCCC.Destroy;
    6766begin
    68   TextSource.Free;
     67  FreeAndNil(TextSource);
    6968  inherited;
    7069end;
     
    113112end;
    114113
    115 procedure TProducerGCCC.GenerateUses(UsedModules: TUsedModuleList);
     114procedure TProducerGCCC.GenerateUses(UsedModules: TUsedModules);
    116115var
    117116  I: Integer;
     
    155154end;
    156155
    157 procedure TProducerGCCC.GenerateFunctions(Functions: TFunctionList;
     156procedure TProducerGCCC.GenerateFunctions(Functions: TFunctions;
    158157  Prefix: string = '');
    159158var
     
    202201end;
    203202
    204 procedure TProducerGCCC.GenerateVariableList(VariableList: TVariableList);
     203procedure TProducerGCCC.GenerateVariableList(VariableList: TVariables);
    205204var
    206205  I: Integer;
     
    361360end;
    362361
    363 procedure TProducerGCCC.GenerateTypes(Types: TTypeList);
     362procedure TProducerGCCC.GenerateTypes(Types: TTypes);
    364363var
    365364  I: Integer;
  • trunk/Compiler/Target/Java/TargetJava.pas

    r74 r75  
    1 unit UTargetJava;
    2 
    3 {$mode Delphi}{$H+}
     1unit TargetJava;
    42
    53interface
    64
    75uses
    8   Classes, SysUtils, UTarget;
     6  Classes, SysUtils, Target;
    97
    108type
     
    2220constructor TTargetJava.Create;
    2321begin
    24   inherited Create;
     22  inherited;
    2523  SysName := 'Java';
    2624  Name := 'Java';
  • trunk/Compiler/Target/NASM/TargetNASM.pas

    r74 r75  
    1 unit UTargetNASM;
    2 
    3 {$mode Delphi}{$H+}
     1unit TargetNASM;
    42
    53interface
    64
    75uses
    8   Classes, SysUtils, UTarget;
     6  Classes, SysUtils, Target;
    97
    108type
     
    2321constructor TTargetNASM.Create;
    2422begin
    25   inherited Create;
     23  inherited;
    2624  Name := 'NASM';
    2725  SysName := 'NASM';
  • trunk/Compiler/Target/PHP/TargetPHP.pas

    r74 r75  
    1 unit UTargetPHP;
    2 
    3 {$mode Delphi}{$H+}
     1unit TargetPHP;
    42
    53interface
    64
    75uses
    8   Classes, SysUtils, UTarget;
     6  Classes, SysUtils, Target;
    97
    108type
     
    1614  end;
    1715
     16
    1817implementation
    1918
     
    2221constructor TTargetPHP.Create;
    2322begin
    24   inherited Create;
     23  inherited;
    2524  SysName := 'PHP';
    2625  Name := 'PHP';
  • trunk/Compiler/Target/XML/TargetXML.pas

    r74 r75  
    1 unit UTargetXML;
    2 
    3 {$mode Delphi}{$H+}
     1unit TargetXML;
    42
    53interface
    64
    75uses
    8   Classes, SysUtils, UTarget, UProducer, USourceCodePascal;
     6  Classes, SysUtils, Target, Producer, SourceCodePascal;
    97
    108type
     
    9189constructor TTargetXML.Create;
    9290begin
    93   inherited Create;
     91  inherited;
    9492  SysName := 'XML';
    9593  Name := 'XML';
  • trunk/Compiler/TranspascalCompiler.lpk

    r74 r75  
    11<?xml version="1.0" encoding="UTF-8"?>
    22<CONFIG>
    3   <Package Version="4">
     3  <Package Version="5">
    44    <PathDelim Value="\"/>
    55    <Name Value="TranspascalCompiler"/>
     
    2525    </CompilerOptions>
    2626    <Version Minor="1"/>
    27     <Files Count="27">
     27    <Files Count="28">
    2828      <Item1>
    29         <Filename Value="UCompiler.pas"/>
    30         <UnitName Value="UCompiler"/>
     29        <Filename Value="Compiler.pas"/>
     30        <UnitName Value="Compiler"/>
    3131      </Item1>
    3232      <Item2>
    33         <Filename Value="Modules\Pascal\USourceCodePascal.pas"/>
    34         <UnitName Value="USourceCodePascal"/>
     33        <Filename Value="Modules\Pascal\SourceCodePascal.pas"/>
     34        <UnitName Value="SourceCodePascal"/>
    3535      </Item2>
    3636      <Item3>
    37         <Filename Value="UProducer.pas"/>
    38         <UnitName Value="UProducer"/>
     37        <Filename Value="Producer.pas"/>
     38        <UnitName Value="Producer"/>
    3939      </Item3>
    4040      <Item4>
    41         <Filename Value="UAnalyzer.pas"/>
    42         <UnitName Value="UAnalyzer"/>
     41        <Filename Value="Analyzer.pas"/>
     42        <UnitName Value="Analyzer"/>
    4343      </Item4>
    4444      <Item5>
    45         <Filename Value="UTarget.pas"/>
    46         <UnitName Value="UTarget"/>
     45        <Filename Value="Target.pas"/>
     46        <UnitName Value="Target"/>
    4747      </Item5>
    4848      <Item6>
    49         <Filename Value="UExecutor.pas"/>
    50         <UnitName Value="UExecutor"/>
     49        <Filename Value="Executor.pas"/>
     50        <UnitName Value="Executor"/>
    5151      </Item6>
    5252      <Item7>
    53         <Filename Value="Modules\Pascal\UAnalyzerPascal.pas"/>
    54         <UnitName Value="UAnalyzerPascal"/>
     53        <Filename Value="Modules\Pascal\AnalyzerPascal.pas"/>
     54        <UnitName Value="AnalyzerPascal"/>
    5555      </Item7>
    5656      <Item8>
    57         <Filename Value="Target\Dynamic C\UProducerDynamicc.pas"/>
    58         <UnitName Value="UProducerDynamicC"/>
     57        <Filename Value="Target\Dynamic C\ProducerDynamicC.pas"/>
     58        <UnitName Value="ProducerDynamicC"/>
    5959      </Item8>
    6060      <Item9>
    61         <Filename Value="Modules\ASM8051\UProducerASM8051.pas"/>
    62         <UnitName Value="UProducerAsm8051"/>
     61        <Filename Value="Modules\ASM8051\ProducerASM8051.pas"/>
     62        <UnitName Value="ProducerASM8051"/>
    6363      </Item9>
    6464      <Item10>
    65         <Filename Value="Modules\ASM8051\UTargetASM8051.pas"/>
    66         <UnitName Value="UTargetASM8051"/>
     65        <Filename Value="Modules\ASM8051\TargetASM8051.pas"/>
     66        <UnitName Value="TargetASM8051"/>
    6767      </Item10>
    6868      <Item11>
    69         <Filename Value="Modules\GCC\UTargetGCC.pas"/>
    70         <UnitName Value="UTargetGCC"/>
     69        <Filename Value="Modules\GCC\TargetGCC.pas"/>
     70        <UnitName Value="TargetGCC"/>
    7171      </Item11>
    7272      <Item12>
    73         <Filename Value="Modules\GCC\UProducerGCC.pas"/>
    74         <UnitName Value="UProducerGCC"/>
     73        <Filename Value="Modules\GCC\ProducerGCC.pas"/>
     74        <UnitName Value="ProducerGCC"/>
    7575      </Item12>
    7676      <Item13>
    77         <Filename Value="Modules\Delphi\UProducerDelphi.pas"/>
    78         <UnitName Value="UProducerDelphi"/>
     77        <Filename Value="Modules\Delphi\ProducerDelphi.pas"/>
     78        <UnitName Value="ProducerDelphi"/>
    7979      </Item13>
    8080      <Item14>
    81         <Filename Value="Modules\Delphi\UModuleDelphi.pas"/>
    82         <UnitName Value="UModuleDelphi"/>
     81        <Filename Value="Modules\Delphi\ModuleDelphi.pas"/>
     82        <UnitName Value="ModuleDelphi"/>
    8383      </Item14>
    8484      <Item15>
    85         <Filename Value="Target\PHP\UTargetPHP.pas"/>
    86         <UnitName Value="UTargetPHP"/>
     85        <Filename Value="Target\PHP\TargetPHP.pas"/>
     86        <UnitName Value="TargetPHP"/>
    8787      </Item15>
    8888      <Item16>
    89         <Filename Value="Target\Java\UTargetJava.pas"/>
    90         <UnitName Value="UTargetJava"/>
     89        <Filename Value="Target\Java\TargetJava.pas"/>
     90        <UnitName Value="TargetJava"/>
    9191      </Item16>
    9292      <Item17>
    93         <Filename Value="Target\XML\UTargetXML.pas"/>
    94         <UnitName Value="UTargetXML"/>
     93        <Filename Value="Target\XML\TargetXML.pas"/>
     94        <UnitName Value="TargetXML"/>
    9595      </Item17>
    9696      <Item18>
    97         <Filename Value="Modules\Interpretter\UModuleInterpretter.pas"/>
    98         <UnitName Value="UModuleInterpretter"/>
     97        <Filename Value="Modules\Interpretter\ModuleInterpretter.pas"/>
     98        <UnitName Value="ModuleInterpretter"/>
    9999      </Item18>
    100100      <Item19>
    101         <Filename Value="Target\NASM\UTargetNASM.pas"/>
    102         <UnitName Value="UTargetNASM"/>
     101        <Filename Value="Target\NASM\TargetNASM.pas"/>
     102        <UnitName Value="TargetNASM"/>
    103103      </Item19>
    104104      <Item20>
    105         <Filename Value="Modules\Pascal\UModulePascal.pas"/>
    106         <UnitName Value="UModulePascal"/>
     105        <Filename Value="Modules\Pascal\ModulePascal.pas"/>
     106        <UnitName Value="ModulePascal"/>
    107107      </Item20>
    108108      <Item21>
    109         <Filename Value="UCompilerAPI.pas"/>
    110         <UnitName Value="UCompilerAPI"/>
     109        <Filename Value="CompilerAPI.pas"/>
     110        <UnitName Value="CompilerAPI"/>
    111111      </Item21>
    112112      <Item22>
    113         <Filename Value="Modules\GCC\UModuleGCC.pas"/>
    114         <UnitName Value="UModuleGCC"/>
     113        <Filename Value="Modules\GCC\ModuleGCC.pas"/>
     114        <UnitName Value="ModuleGCC"/>
    115115      </Item22>
    116116      <Item23>
    117         <Filename Value="USourceConvertor.pas"/>
    118         <UnitName Value="USourceConvertor"/>
     117        <Filename Value="SourceConvertor.pas"/>
     118        <UnitName Value="SourceConvertor"/>
    119119      </Item23>
    120120      <Item24>
    121         <Filename Value="Modules\Brainfuck\UModuleBrainfuck.pas"/>
    122         <UnitName Value="UModuleBrainfuck"/>
     121        <Filename Value="Modules\Brainfuck\ModuleBrainfuck.pas"/>
     122        <UnitName Value="ModuleBrainfuck"/>
    123123      </Item24>
    124124      <Item25>
    125         <Filename Value="Modules\PHP\UModulePHP.pas"/>
    126         <UnitName Value="UModulePHP"/>
     125        <Filename Value="Modules\PHP\ModulePHP.pas"/>
     126        <UnitName Value="ModulePHP"/>
    127127      </Item25>
    128128      <Item26>
    129         <Filename Value="Modules\Java\UModuleJava.pas"/>
    130         <UnitName Value="UModuleJava"/>
     129        <Filename Value="Modules\Java\ModuleJava.pas"/>
     130        <UnitName Value="ModuleJava"/>
    131131      </Item26>
    132132      <Item27>
    133         <Filename Value="Modules\ASM8051\UModuleASM8051.pas"/>
    134         <UnitName Value="UModuleASM8051"/>
     133        <Filename Value="Modules\ASM8051\ModuleASM8051.pas"/>
     134        <UnitName Value="ModuleASM8051"/>
    135135      </Item27>
     136      <Item28>
     137        <Filename Value="Target\GCC\ProducerGCC.pas"/>
     138        <UnitName Value="ProducerGCC"/>
     139      </Item28>
    136140    </Files>
    137     <RequiredPkgs Count="4">
     141    <CompatibilityMode Value="True"/>
     142    <RequiredPkgs Count="3">
    138143      <Item1>
    139144        <PackageName Value="ModularSystem"/>
     
    141146      </Item1>
    142147      <Item2>
    143         <PackageName Value="TemplateGenerics"/>
     148        <PackageName Value="LCL"/>
    144149      </Item2>
    145150      <Item3>
    146         <PackageName Value="LCL"/>
    147       </Item3>
    148       <Item4>
    149151        <PackageName Value="FCL"/>
    150152        <MinVersion Major="1" Valid="True"/>
    151       </Item4>
     153      </Item3>
    152154    </RequiredPkgs>
    153155    <UsageOptions>
  • trunk/Compiler/TranspascalCompiler.pas

    r74 r75  
    99
    1010uses
    11   UCompiler, USourceCodePascal, UProducer, UAnalyzer, UTarget, UExecutor,
    12   UAnalyzerPascal, UProducerDynamicc, UProducerASM8051, UTargetASM8051,
    13   UTargetGCC, UProducerGCC, UProducerDelphi, UModuleDelphi, UTargetPHP,
    14   UTargetJava, UTargetXML, UModuleInterpretter, UTargetNASM, UModulePascal,
    15   UCompilerAPI, UModuleGCC, USourceConvertor, UModuleBrainfuck, UModulePHP,
    16   UModuleJava, UModuleASM8051, LazarusPackageIntf;
     11  Compiler, SourceCodePascal, Producer, Analyzer, Target, Executor,
     12  AnalyzerPascal, ProducerDynamicC, ProducerASM8051, TargetASM8051, TargetGCC,
     13  ProducerGCC, ProducerDelphi, ModuleDelphi, TargetPHP, TargetJava, TargetXML,
     14  ModuleInterpretter, TargetNASM, ModulePascal, CompilerAPI, ModuleGCC,
     15  SourceConvertor, ModuleBrainfuck, ModulePHP, ModuleJava, ModuleASM8051,
     16  LazarusPackageIntf;
    1717
    1818implementation
Note: See TracChangeset for help on using the changeset viewer.