diff options
Diffstat (limited to 'src/ortho')
-rw-r--r-- | src/ortho/debug/ortho_debug-disp.adb | 2 | ||||
-rw-r--r-- | src/ortho/debug/ortho_debug.adb | 54 | ||||
-rw-r--r-- | src/ortho/debug/ortho_debug.private.ads | 15 | ||||
-rw-r--r-- | src/ortho/gcc/ortho-lang.c | 10 | ||||
-rw-r--r-- | src/ortho/gcc/ortho_gcc.ads | 10 | ||||
-rw-r--r-- | src/ortho/gcc/ortho_gcc.private.ads | 4 | ||||
-rw-r--r-- | src/ortho/llvm/ortho_llvm.adb | 14 | ||||
-rw-r--r-- | src/ortho/llvm/ortho_llvm.ads | 6 | ||||
-rw-r--r-- | src/ortho/mcode/ortho_code-decls.adb | 18 | ||||
-rw-r--r-- | src/ortho/mcode/ortho_code-decls.ads | 4 | ||||
-rw-r--r-- | src/ortho/mcode/ortho_mcode.adb | 14 | ||||
-rw-r--r-- | src/ortho/mcode/ortho_mcode.ads | 14 | ||||
-rw-r--r-- | src/ortho/mcode/ortho_mcode.private.ads | 4 | ||||
-rw-r--r-- | src/ortho/oread/ortho_front.adb | 8 | ||||
-rw-r--r-- | src/ortho/ortho_nodes.common.ads | 6 |
15 files changed, 89 insertions, 94 deletions
diff --git a/src/ortho/debug/ortho_debug-disp.adb b/src/ortho/debug/ortho_debug-disp.adb index bcca8dbd1..145a4c5e9 100644 --- a/src/ortho/debug/ortho_debug-disp.adb +++ b/src/ortho/debug/ortho_debug-disp.adb @@ -885,7 +885,7 @@ package body Ortho_Debug.Disp is Put (" : "); Disp_Tnode_Name (Decl.Dtype); Put_Line (";"); - when ON_Const_Value => + when ON_Init_Value => Put_Keyword ("constant"); Put (" "); Disp_Ident (Decl.Name); diff --git a/src/ortho/debug/ortho_debug.adb b/src/ortho/debug/ortho_debug.adb index 00bfcbc5c..218fd9671 100644 --- a/src/ortho/debug/ortho_debug.adb +++ b/src/ortho/debug/ortho_debug.adb @@ -1265,58 +1265,57 @@ package body Ortho_Debug is Storage => Storage, Scope => Current_Decl_Scope.Parent, Lineno => 0, - Const_Value => O_Dnode_Null); + Value_Decl => O_Dnode_Null); Add_Decl (Res); end New_Const_Decl; - procedure Start_Const_Value (Const : in out O_Dnode) + procedure Start_Init_Value (Decl : in out O_Dnode) is - subtype O_Dnode_Const_Value is O_Dnode_Type (ON_Const_Value); + subtype O_Dnode_Init_Value is O_Dnode_Type (ON_Init_Value); N : O_Dnode; begin - if Const.Const_Value /= O_Dnode_Null then + if Decl.Value_Decl /= O_Dnode_Null then -- Constant already has a value. raise Syntax_Error; end if; - if Const.Storage = O_Storage_External then - -- An external constant must not have a value. + if Decl.Storage = O_Storage_External then + -- An external variable/constant cannot have a value. raise Syntax_Error; end if; -- FIXME: check scope is the same. - N := new O_Dnode_Const_Value'(Kind => ON_Const_Value, - Name => Const.Name, - Next => null, - Dtype => Const.Dtype, - Storage => Const.Storage, - Scope => Current_Decl_Scope.Parent, - Lineno => 0, - Const_Decl => Const, - Value => O_Cnode_Null); - Const.Const_Value := N; + N := new O_Dnode_Init_Value'(Kind => ON_Init_Value, + Name => Decl.Name, + Next => null, + Dtype => Decl.Dtype, + Storage => Decl.Storage, + Scope => Current_Decl_Scope.Parent, + Lineno => 0, + Init_Decl => Decl, + Value => O_Cnode_Null); + Decl.Value_Decl := N; Add_Decl (N, False); - end Start_Const_Value; + end Start_Init_Value; - procedure Finish_Const_Value (Const : in out O_Dnode; Val : O_Cnode) - is + procedure Finish_Init_Value (Decl : in out O_Dnode; Val : O_Cnode) is begin - if Const.Const_Value = O_Dnode_Null then - -- Start_Const_Value not called. + if Decl.Value_Decl = O_Dnode_Null then + -- Start_Init_Value not called. raise Syntax_Error; end if; - if Const.Const_Value.Value /= O_Cnode_Null then - -- Finish_Const_Value already called. + if Decl.Value_Decl.Value /= O_Cnode_Null then + -- Finish_Init_Value already called. raise Syntax_Error; end if; if Val = O_Cnode_Null then -- No value or bad type. raise Type_Error; end if; - Check_Type (Val.Ctype, Const.Dtype); - Const.Const_Value.Value := Val; - end Finish_Const_Value; + Check_Type (Val.Ctype, Decl.Dtype); + Decl.Value_Decl.Value := Val; + end Finish_Init_Value; procedure New_Var_Decl (Res : out O_Dnode; @@ -1334,7 +1333,8 @@ package body Ortho_Debug is Dtype => Atype, Storage => Storage, Lineno => 0, - Scope => Current_Decl_Scope.Parent); + Scope => Current_Decl_Scope.Parent, + Value_Decl => O_Dnode_Null); Add_Decl (Res); end New_Var_Decl; diff --git a/src/ortho/debug/ortho_debug.private.ads b/src/ortho/debug/ortho_debug.private.ads index 2a733526c..7a050321a 100644 --- a/src/ortho/debug/ortho_debug.private.ads +++ b/src/ortho/debug/ortho_debug.private.ads @@ -48,7 +48,7 @@ private (ON_Type_Decl, ON_Completed_Type_Decl, ON_Const_Decl, ON_Var_Decl, ON_Interface_Decl, ON_Function_Decl, ON_Function_Body, - ON_Const_Value, + ON_Init_Value, ON_Debug_Line_Decl, ON_Debug_Comment_Decl, ON_Debug_Filename_Decl); type O_Dnode_Type (<>); @@ -70,13 +70,14 @@ private null; when ON_Completed_Type_Decl => null; - when ON_Const_Decl => - Const_Value : O_Dnode; - when ON_Const_Value => - Const_Decl : O_Dnode; + when ON_Const_Decl + | ON_Var_Decl => + -- Corresponding declaration for initial value (if any). + Value_Decl : O_Dnode; + when ON_Init_Value => + -- Corresponding declaration of the object. + Init_Decl : O_Dnode; Value : O_Cnode; - when ON_Var_Decl => - null; when ON_Function_Decl => Interfaces : O_Dnode; Func_Body : O_Dnode; diff --git a/src/ortho/gcc/ortho-lang.c b/src/ortho/gcc/ortho-lang.c index 0c38fbfce..b4fdbe388 100644 --- a/src/ortho/gcc/ortho-lang.c +++ b/src/ortho/gcc/ortho-lang.c @@ -1623,17 +1623,17 @@ new_const_decl (tree *res, tree ident, enum o_storage storage, tree atype) } void -start_const_value (tree *cst ATTRIBUTE_UNUSED) +start_init_value (tree *decl ATTRIBUTE_UNUSED) { } void -finish_const_value (tree *cst, tree val) +finish_init_value (tree *decl, tree val) { - DECL_INITIAL (*cst) = val; + DECL_INITIAL (*decl) = val; TREE_CONSTANT (val) = 1; - TREE_STATIC (*cst) = 1; - rest_of_decl_compilation (*cst, current_function_decl == NULL_TREE, 0); + TREE_STATIC (*decl) = 1; + rest_of_decl_compilation (*decl, current_function_decl == NULL_TREE, 0); } void diff --git a/src/ortho/gcc/ortho_gcc.ads b/src/ortho/gcc/ortho_gcc.ads index 6f43be4cb..ab7e0e3d0 100644 --- a/src/ortho/gcc/ortho_gcc.ads +++ b/src/ortho/gcc/ortho_gcc.ads @@ -350,9 +350,9 @@ package Ortho_Gcc is Storage : O_Storage; Atype : O_Tnode); - -- Set the value of a non-external constant. - procedure Start_Const_Value (Const : in out O_Dnode); - procedure Finish_Const_Value (Const : in out O_Dnode; Val : O_Cnode); + -- Set the value of a non-external constant or variable. + procedure Start_Init_Value (Decl : in out O_Dnode); + procedure Finish_Init_Value (Decl : in out O_Dnode; Val : O_Cnode); -- Create a variable declaration. -- A variable can be local only inside a function. @@ -657,8 +657,8 @@ private pragma Import (C, New_Const_Decl); pragma Import (C, New_Var_Decl); - pragma Import (C, Start_Const_Value); - pragma Import (C, Finish_Const_Value); + pragma Import (C, Start_Init_Value); + pragma Import (C, Finish_Init_Value); pragma Import (C, Start_Function_Decl); pragma Import (C, Start_Procedure_Decl); diff --git a/src/ortho/gcc/ortho_gcc.private.ads b/src/ortho/gcc/ortho_gcc.private.ads index 7eacdf48e..615c8aa13 100644 --- a/src/ortho/gcc/ortho_gcc.private.ads +++ b/src/ortho/gcc/ortho_gcc.private.ads @@ -225,8 +225,8 @@ private pragma Import (C, New_Const_Decl); pragma Import (C, New_Var_Decl); - pragma Import (C, Start_Const_Value); - pragma Import (C, Finish_Const_Value); + pragma Import (C, Start_Init_Value); + pragma Import (C, Finish_Init_Value); pragma Import (C, Start_Function_Decl); pragma Import (C, Start_Procedure_Decl); diff --git a/src/ortho/llvm/ortho_llvm.adb b/src/ortho/llvm/ortho_llvm.adb index f6e3dbefc..8106f9d7d 100644 --- a/src/ortho/llvm/ortho_llvm.adb +++ b/src/ortho/llvm/ortho_llvm.adb @@ -2021,22 +2021,22 @@ package body Ortho_LLVM is end New_Const_Decl; ----------------------- - -- Start_Const_Value -- + -- Start_Init_Value -- ----------------------- - procedure Start_Const_Value (Const : in out O_Dnode) is + procedure Start_Init_Value (Decl : in out O_Dnode) is begin null; - end Start_Const_Value; + end Start_Init_Value; ------------------------ - -- Finish_Const_Value -- + -- Finish_Init_Value -- ------------------------ - procedure Finish_Const_Value (Const : in out O_Dnode; Val : O_Cnode) is + procedure Finish_Init_Value (Decl : in out O_Dnode; Val : O_Cnode) is begin - SetInitializer (Const.LLVM, Val.LLVM); - end Finish_Const_Value; + SetInitializer (Decl.LLVM, Val.LLVM); + end Finish_Init_Value; ------------------ -- New_Var_Decl -- diff --git a/src/ortho/llvm/ortho_llvm.ads b/src/ortho/llvm/ortho_llvm.ads index 4cd0feba2..3f77a86b9 100644 --- a/src/ortho/llvm/ortho_llvm.ads +++ b/src/ortho/llvm/ortho_llvm.ads @@ -373,9 +373,9 @@ package Ortho_LLVM is Storage : O_Storage; Atype : O_Tnode); - -- Set the value of a non-external constant. - procedure Start_Const_Value (Const : in out O_Dnode); - procedure Finish_Const_Value (Const : in out O_Dnode; Val : O_Cnode); + -- Set the value of a non-external constant or variable. + procedure Start_Init_Value (Decl : in out O_Dnode); + procedure Finish_Init_Value (Decl : in out O_Dnode; Val : O_Cnode); -- Create a variable declaration. -- A variable can be local only inside a function. diff --git a/src/ortho/mcode/ortho_code-decls.adb b/src/ortho/mcode/ortho_code-decls.adb index b95d4a2b8..a3a5e5eb0 100644 --- a/src/ortho/mcode/ortho_code-decls.adb +++ b/src/ortho/mcode/ortho_code-decls.adb @@ -345,6 +345,8 @@ package body Ortho_Code.Decls is procedure New_Init_Value (Decl : O_Dnode; Val : O_Cnode) is begin + pragma Assert (Get_Decl_Kind (Decl) = OD_Const + or else Get_Decl_Kind (Decl) = OD_Var); if Get_Init_Value (Decl) /= O_Cnode_Null then -- Value was already set. raise Syntax_Error; @@ -363,18 +365,10 @@ package body Ortho_Code.Decls is end if; end New_Init_Value; - procedure New_Const_Value (Cst : O_Dnode; Val : O_Cnode) is - begin - pragma Assert (Get_Decl_Kind (Cst) = OD_Const); - New_Init_Value (Cst, Val); - end New_Const_Value; - - procedure New_Var_Decl - (Res : out O_Dnode; - Ident : O_Ident; - Storage : O_Storage; - Atype : O_Tnode) - is + procedure New_Var_Decl (Res : out O_Dnode; + Ident : O_Ident; + Storage : O_Storage; + Atype : O_Tnode) is begin if Storage = O_Storage_Local then Dnodes.Append (Dnode_Common'(Kind => OD_Local, diff --git a/src/ortho/mcode/ortho_code-decls.ads b/src/ortho/mcode/ortho_code-decls.ads index 0cd532593..70a0ba4df 100644 --- a/src/ortho/mcode/ortho_code-decls.ads +++ b/src/ortho/mcode/ortho_code-decls.ads @@ -132,8 +132,8 @@ package Ortho_Code.Decls is Storage : O_Storage; Atype : O_Tnode); - -- Set the value to CST. - procedure New_Const_Value (Cst : O_Dnode; Val : O_Cnode); + -- Set the value to DECL. + procedure New_Init_Value (Decl : O_Dnode; Val : O_Cnode); -- Create a variable declaration. -- A variable can be local only inside a function. diff --git a/src/ortho/mcode/ortho_mcode.adb b/src/ortho/mcode/ortho_mcode.adb index 77e101721..cb2ab6663 100644 --- a/src/ortho/mcode/ortho_mcode.adb +++ b/src/ortho/mcode/ortho_mcode.adb @@ -29,12 +29,12 @@ package body Ortho_Mcode is null; end New_Debug_Comment_Stmt; - procedure Start_Const_Value (Const : in out O_Dnode) + procedure Start_Init_Value (Decl : in out O_Dnode) is - pragma Unreferenced (Const); + pragma Unreferenced (Decl); begin null; - end Start_Const_Value; + end Start_Init_Value; procedure Start_Record_Type (Elements : out O_Element_List) is begin @@ -112,12 +112,12 @@ package body Ortho_Mcode is Ortho_Code.O_Tnode (Dtype)); end Finish_Access_Type; - procedure Finish_Const_Value (Const : in out O_Dnode; Val : O_Cnode) + procedure Finish_Init_Value (Decl : in out O_Dnode; Val : O_Cnode) is - pragma Warnings (Off, Const); + pragma Warnings (Off, Decl); begin - New_Const_Value (Ortho_Code.O_Dnode (Const), Ortho_Code.O_Cnode (Val)); - end Finish_Const_Value; + New_Init_Value (Ortho_Code.O_Dnode (Decl), Ortho_Code.O_Cnode (Val)); + end Finish_Init_Value; function New_Array_Type (El_Type : O_Tnode; Index_Type : O_Tnode) return O_Tnode is diff --git a/src/ortho/mcode/ortho_mcode.ads b/src/ortho/mcode/ortho_mcode.ads index 45e803690..ec65fab5c 100644 --- a/src/ortho/mcode/ortho_mcode.ads +++ b/src/ortho/mcode/ortho_mcode.ads @@ -297,8 +297,8 @@ package Ortho_Mcode is function New_Slice (Arr : O_Lnode; Res_Type : O_Tnode; Index : O_Enode) return O_Lnode; - -- Get an element of a record. - -- Type of REC must be a record type. + -- Get an element of a record or a union. + -- Type of REC must be a record or a union type. function New_Selected_Element (Rec : O_Lnode; El : O_Fnode) return O_Lnode; @@ -357,9 +357,9 @@ package Ortho_Mcode is Storage : O_Storage; Atype : O_Tnode); - -- Set the value of a non-external constant. - procedure Start_Const_Value (Const : in out O_Dnode); - procedure Finish_Const_Value (Const : in out O_Dnode; Val : O_Cnode); + -- Set the value of a non-external constant or variable. + procedure Start_Init_Value (Decl : in out O_Dnode); + procedure Finish_Init_Value (Decl : in out O_Dnode; Val : O_Cnode); -- Create a variable declaration. -- A variable can be local only inside a function. @@ -538,8 +538,8 @@ private pragma Inline (New_Type_Decl); pragma Inline (New_Const_Decl); - pragma Inline (Start_Const_Value); - pragma Inline (Finish_Const_Value); + pragma Inline (Start_Init_Value); + pragma Inline (Finish_Init_Value); pragma Inline (New_Var_Decl); pragma Inline (New_Obj); diff --git a/src/ortho/mcode/ortho_mcode.private.ads b/src/ortho/mcode/ortho_mcode.private.ads index 1b414773f..5374ae978 100644 --- a/src/ortho/mcode/ortho_mcode.private.ads +++ b/src/ortho/mcode/ortho_mcode.private.ads @@ -106,8 +106,8 @@ private pragma Inline (New_Type_Decl); pragma Inline (New_Const_Decl); - pragma Inline (Start_Const_Value); - pragma Inline (Finish_Const_Value); + pragma Inline (Start_Init_Value); + pragma Inline (Finish_Init_Value); pragma Inline (New_Var_Decl); pragma Inline (New_Obj); diff --git a/src/ortho/oread/ortho_front.adb b/src/ortho/oread/ortho_front.adb index cd01eb368..6ba026221 100644 --- a/src/ortho/oread/ortho_front.adb +++ b/src/ortho/oread/ortho_front.adb @@ -2500,9 +2500,9 @@ package body Ortho_Front is N.Decl_Defined := True; Next_Token; - Start_Const_Value (N.Obj_Node); + Start_Init_Value (N.Obj_Node); Val := Parse_Constant_Value (N.Decl_Dtype); - Finish_Const_Value (N.Obj_Node, Val); + Finish_Init_Value (N.Obj_Node, Val); end if; end Parse_Constant_Declaration; @@ -2528,9 +2528,9 @@ package body Ortho_Front is -- should check the object has no value. Next_Expect (Tok_Assign); Next_Token; - Start_Const_Value (N.Obj_Node); + Start_Init_Value (N.Obj_Node); Val := Parse_Constant_Value (N.Decl_Dtype); - Finish_Const_Value (N.Obj_Node, Val); + Finish_Init_Value (N.Obj_Node, Val); end Parse_Constant_Value_Declaration; procedure Parse_Var_Declaration (Storage : O_Storage) diff --git a/src/ortho/ortho_nodes.common.ads b/src/ortho/ortho_nodes.common.ads index f9caf32a7..a40323656 100644 --- a/src/ortho/ortho_nodes.common.ads +++ b/src/ortho/ortho_nodes.common.ads @@ -344,9 +344,9 @@ package ORTHO_NODES is Storage : O_Storage; Atype : O_Tnode); - -- Set the value of a non-external constant. - procedure Start_Const_Value (Const : in out O_Dnode); - procedure Finish_Const_Value (Const : in out O_Dnode; Val : O_Cnode); + -- Set the value of a non-external constant or variable. + procedure Start_Init_Value (Decl : in out O_Dnode); + procedure Finish_Init_Value (Decl : in out O_Dnode; Val : O_Cnode); -- Create a variable declaration. -- A variable can be local only inside a function. |