@@ -329,10 +329,12 @@ package body Ghdlcomp is
329
329
procedure Common_Compile_Init (Analyze_Only : Boolean) is
330
330
begin
331
331
if Analyze_Only then
332
+ -- Initialize library path and load std+work libraries.
332
333
if not Setup_Libraries (True) then
333
334
raise Option_Error;
334
335
end if ;
335
336
else
337
+ -- Initialize library path and load std library.
336
338
if not Setup_Libraries (False)
337
339
or else not Libraries.Load_Std_Library
338
340
then
@@ -487,99 +489,107 @@ package body Ghdlcomp is
487
489
& ASCII.LF & " aliases: -a, analyse" ;
488
490
end Get_Short_Help ;
489
491
490
- procedure Perform_Action (Cmd : in out Command_Analyze;
491
- Args : String_Acc_Array;
492
- Success : out Boolean)
492
+ function Analyze_File (Id : Name_Id) return Boolean
493
493
is
494
- pragma Unreferenced (Cmd);
495
- Id : Name_Id;
496
494
Design_File : Iir_Design_File;
497
495
New_Design_File : Iir_Design_File;
498
496
Unit : Iir;
499
497
Next_Unit : Iir;
500
498
begin
501
- Success := False;
499
+ -- Parse file.
500
+ Design_File := Load_File_Name (Id);
501
+ if Errorout.Nbr_Errors > 0
502
+ and then not Flags.Flag_Force_Analysis
503
+ then
504
+ return False;
505
+ end if ;
502
506
503
- if Args'Length = 0 then
504
- Error (" no file to analyze" );
505
- return ;
507
+ New_Design_File := Null_Iir;
508
+
509
+ if False then
510
+ -- Speed up analysis: remove all previous designs.
511
+ -- However, this is not in the LRM...
512
+ Libraries.Purge_Design_File (Design_File);
506
513
end if ;
507
514
508
- Expect_Filenames (Args);
515
+ if Design_File /= Null_Iir then
516
+ Unit := Get_First_Design_Unit (Design_File);
517
+ while Unit /= Null_Iir loop
518
+ -- Analyze unit.
519
+ Finish_Compilation (Unit, True);
509
520
510
- Hooks.Compile_Init. all (True );
521
+ Next_Unit := Get_Chain (Unit );
511
522
512
- -- Parse all files.
513
- for I in Args'Range loop
514
- Id := Name_Table.Get_Identifier (Args (I).all );
523
+ if Errorout.Nbr_Errors = 0
524
+ or else (Flags.Flag_Force_Analysis
525
+ and then Get_Library_Unit (Unit) /= Null_Iir)
526
+ then
527
+ Set_Chain (Unit, Null_Iir);
528
+ Libraries.Add_Design_Unit_Into_Library (Unit);
529
+ New_Design_File := Get_Design_File (Unit);
530
+ end if ;
531
+
532
+ Unit := Next_Unit;
533
+ end loop ;
515
534
516
- -- Parse file.
517
- Design_File := Load_File_Name (Id);
518
535
if Errorout.Nbr_Errors > 0
519
536
and then not Flags.Flag_Force_Analysis
520
537
then
521
- Success := Flag_Expect_Failure;
522
- return ;
538
+ return False;
523
539
end if ;
524
540
525
- New_Design_File := Null_Iir;
526
-
527
- if False then
528
- -- Speed up analysis: remove all previous designs.
529
- -- However, this is not in the LRM...
530
- Libraries.Purge_Design_File (Design_File);
541
+ if New_Design_File = Design_File then
542
+ pragma Assert (Flags.Flag_Force_Analysis);
543
+ null ;
544
+ else
545
+ Free_Iir (Design_File);
531
546
end if ;
532
547
533
- if Design_File /= Null_Iir then
534
- Unit := Get_First_Design_Unit (Design_File);
548
+ -- Do late analysis checks.
549
+ if New_Design_File /= Null_Iir then
550
+ Unit := Get_First_Design_Unit (New_Design_File);
535
551
while Unit /= Null_Iir loop
536
- -- Analyze unit.
537
- Finish_Compilation (Unit, True);
538
-
539
- Next_Unit := Get_Chain (Unit);
540
-
541
- if Errorout.Nbr_Errors = 0
542
- or else (Flags.Flag_Force_Analysis
543
- and then Get_Library_Unit (Unit) /= Null_Iir)
544
- then
545
- Set_Chain (Unit, Null_Iir);
546
- Libraries.Add_Design_Unit_Into_Library (Unit);
547
- New_Design_File := Get_Design_File (Unit);
548
- end if ;
549
-
550
- Unit := Next_Unit;
552
+ Vhdl.Sem.Sem_Analysis_Checks_List
553
+ (Unit, Is_Warning_Enabled (Warnid_Delayed_Checks));
554
+ Unit := Get_Chain (Unit);
551
555
end loop ;
552
556
553
557
if Errorout.Nbr_Errors > 0
554
558
and then not Flags.Flag_Force_Analysis
555
559
then
556
- Success := Flag_Expect_Failure;
557
- return ;
560
+ return False;
558
561
end if ;
562
+ end if ;
563
+ end if ;
559
564
560
- if New_Design_File = Design_File then
561
- pragma Assert (Flags.Flag_Force_Analysis);
562
- null ;
563
- else
564
- Free_Iir (Design_File);
565
- end if ;
565
+ return True;
566
+ end Analyze_File ;
566
567
567
- -- Do late analysis checks.
568
- if New_Design_File /= Null_Iir then
569
- Unit := Get_First_Design_Unit (New_Design_File);
570
- while Unit /= Null_Iir loop
571
- Vhdl.Sem.Sem_Analysis_Checks_List
572
- (Unit, Is_Warning_Enabled (Warnid_Delayed_Checks));
573
- Unit := Get_Chain (Unit);
574
- end loop ;
575
-
576
- if Errorout.Nbr_Errors > 0
577
- and then not Flags.Flag_Force_Analysis
578
- then
579
- Success := Flag_Expect_Failure;
580
- return ;
581
- end if ;
582
- end if ;
568
+ procedure Perform_Action (Cmd : in out Command_Analyze;
569
+ Args : String_Acc_Array;
570
+ Success : out Boolean)
571
+ is
572
+ pragma Unreferenced (Cmd);
573
+ Id : Name_Id;
574
+ begin
575
+ Success := False;
576
+
577
+ if Args'Length = 0 then
578
+ Error (" no file to analyze" );
579
+ return ;
580
+ end if ;
581
+
582
+ Expect_Filenames (Args);
583
+
584
+ Hooks.Compile_Init.all (True);
585
+
586
+ -- Parse all files.
587
+ for I in Args'Range loop
588
+ Id := Name_Table.Get_Identifier (Args (I).all );
589
+
590
+ if not Analyze_File (Id) then
591
+ Success := Flag_Expect_Failure;
592
+ return ;
583
593
end if ;
584
594
end loop ;
585
595
@@ -588,7 +598,6 @@ package body Ghdlcomp is
588
598
return ;
589
599
end if ;
590
600
591
-
592
601
if Flag_Expect_Failure then
593
602
Success := False;
594
603
return ;
0 commit comments