aboutsummaryrefslogtreecommitdiffstats
path: root/src/grt/grt-options.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2015-03-07 07:30:07 +0100
committerTristan Gingold <tgingold@free.fr>2015-03-07 07:30:07 +0100
commit8af64459f397e5037dd7e25317491edad39d8006 (patch)
tree13476a4fe7a97c9dc62df4d03bf33045e2920b04 /src/grt/grt-options.adb
parentad4ac5499e426cff9b76479e8ff6250a32fcbb57 (diff)
downloadghdl-8af64459f397e5037dd7e25317491edad39d8006.tar.gz
ghdl-8af64459f397e5037dd7e25317491edad39d8006.tar.bz2
ghdl-8af64459f397e5037dd7e25317491edad39d8006.zip
Implement ticket 37: add switch -gNAME=VAL to override top entity generics.
Diffstat (limited to 'src/grt/grt-options.adb')
-rw-r--r--src/grt/grt-options.adb46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/grt/grt-options.adb b/src/grt/grt-options.adb
index df1eb4ec8..f3b9e8cdb 100644
--- a/src/grt/grt-options.adb
+++ b/src/grt/grt-options.adb
@@ -470,6 +470,52 @@ package body Grt.Options is
Nbr_Threads := Integer (Val);
end if;
end;
+ elsif Len > 4 and then Option (1 .. 2) = "-g" then
+ if Option (3) = '=' then
+ Error_C ("missing generic name in '");
+ Error_C (Option);
+ Error_E ("'");
+ return;
+ end if;
+ declare
+ Eq_Pos : Natural;
+ Over : Generic_Override_Acc;
+ Name : String_Access;
+ begin
+ if Option (3) = '\' then
+ -- Extended identifier (not yet handled).
+ raise Program_Error;
+ else
+ -- Search for '='.
+ Eq_Pos := 0;
+ for I in 3 .. Option'Last loop
+ if Option (I) = '=' then
+ Eq_Pos := I;
+ exit;
+ end if;
+ end loop;
+ if Eq_Pos = 0 then
+ Error_C ("missing '=' after generic name in '");
+ Error_C (Option);
+ Error_E ("'");
+ end if;
+ Name := new String (1 .. Eq_Pos - 3);
+ for I in 3 .. Eq_Pos - 1 loop
+ Name (I - 2) := To_Lower (Option (I));
+ end loop;
+ end if;
+ Over := new Generic_Override_Type'
+ (Name => Name,
+ Value => new String'(Option (Eq_Pos + 1 .. Option'Last)),
+ Next => null);
+ -- Append.
+ if Last_Generic_Override /= null then
+ Last_Generic_Override.Next := Over;
+ else
+ First_Generic_Override := Over;
+ end if;
+ Last_Generic_Override := Over;
+ end;
elsif not Grt.Hooks.Call_Option_Hooks (Option) then
Error_C ("unknown option '");
Error_C (Option);