Changeset 51 for trunk/Compiler


Ignore:
Timestamp:
Apr 6, 2012, 9:43:56 AM (13 years ago)
Author:
chronos
Message:
  • Added: Project determines which source file is main program source.
Location:
trunk/Compiler
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Compiler/Analyze/UAnalyzerPascal.pas

    r26 r51  
    424424    ParseCommonBlock(Body, '.');
    425425    SourceCode.ParentProgram.Modules.Add(SourceCode);
     426    ProgramCode.MainModule := SourceCode;
    426427    Result := True;
    427428  end;
  • trunk/Compiler/Target/Interpretter/UTargetInterpretter.pas

    r50 r51  
    127127procedure TExecutorInterpretter.Run;
    128128begin
    129   ShowMessage(TModuleProgram(TCompiler(TTarget(Target).Compiler).Analyzer.ProgramCode.Modules[0]).Name);
    130   with TModuleProgram(TCompiler(TTarget(Target).Compiler).Analyzer.ProgramCode.Modules[0]) do begin
     129  ShowMessage(TModuleProgram(TCompiler(TTarget(Target).Compiler).Analyzer.ProgramCode.MainModule).Name);
     130  with TModuleProgram(TCompiler(TTarget(Target).Compiler).Analyzer.ProgramCode.MainModule) do begin
    131131    RunBeginEnd(Body.Code);
    132132  end;
  • trunk/Compiler/UCompiler.pas

    r50 r51  
    3737    TargetFolder: string;
    3838    Targets: TListTarget;
     39    MainSource: string;
    3940    SourceFiles: TListString;
    4041    TargetFiles: TListString;
     
    8485begin
    8586  ErrorMessages.Clear;
    86   AbstractCode.Modules.Clear;
     87  AbstractCode.Clear;
    8788end;
    8889
     
    169170procedure TCompiler.AnalyzeAll;
    170171begin
    171   if SourceFiles.Count > 0 then begin
    172     Analyzer.FileName := SourceFiles[0];
     172  if (SourceFiles.Count > 0) then begin
     173    Analyzer.FileName := MainSource;
    173174    Analyzer.OnGetSource(ExtractFileNameOnly(Analyzer.FileName), Analyzer.SourceCode);
    174175    Analyzer.Process;
  • trunk/Compiler/USourceCode.pas

    r30 r51  
    380380  end;
    381381
     382  { TProgram }
     383
    382384  TProgram = class
    383385    Device: TDevice;
    384386    Modules: TModuleList;
     387    MainModule: TModule;
     388    procedure Clear;
    385389    constructor Create;
    386390    destructor Destroy; override;
     
    421425
    422426{ TProgram }
     427
     428procedure TProgram.Clear;
     429begin
     430  Modules.Clear;
     431  MainModule := nil;
     432end;
    423433
    424434constructor TProgram.Create;
Note: See TracChangeset for help on using the changeset viewer.