Changeset 51 for trunk


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
Files:
7 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;
  • trunk/IDE/Forms/UFormMain.pas

    r50 r51  
    250250      Compiler.SourceFiles.Clear;
    251251      Project.Files.DumpFileList(Compiler.SourceFiles);
     252      Compiler.MainSource := Project.MainSource.AbsoluteFileName;
    252253      TargetProject.FileName := ExtractFileDir(Project.FileName) + DirectorySeparator +
    253254        Compiler.CompiledFolder + DirectorySeparator + Compiler.Target.Name +
  • trunk/IDE/UProject.pas

    r50 r51  
    357357    NewNode := Doc.DocumentElement.FindNode('MainSource');
    358358    if Assigned(NewNode) then begin
    359       MainSourceName := UTF8Encode(NewNode.TextSource);
    360 
     359      MainSourceName := UTF8Encode(NewNode.TextContent);
     360      MainSource := Files.SearchFile(MainSourceName);
    361361    end;
    362362
     
    385385    with RootNode do begin
    386386      NewNode := CreateElement('MainSource');
    387       NewNode.TextContent := UTF8Decode(MainSource.FileName);
     387      if Assigned(MainSource) then
     388        NewNode.TextContent := UTF8Decode(MainSource.FileName);
    388389      AppendChild(NewNode);
    389390
     
    419420  Files.Clear;
    420421  Packages.Clear;
     422  MainSource := nil;
    421423end;
    422424
  • trunk/IDE/UProjectTemplates.pas

    r48 r51  
    6464    Add('end.');
    6565  end;
     66  Project.MainSource := NewFile;
    6667end;
    6768
     
    8889    Add('end.');
    8990  end;
     91  Project.MainSource := NewFile;
    9092end;
    9193
     
    118120    Add('end.');
    119121  end;
     122  Project.MainSource := NewFile;
    120123end;
    121124
     
    140143    Add('end.');
    141144  end;
     145  Project.MainSource := NewFile;
    142146end;
    143147
Note: See TracChangeset for help on using the changeset viewer.