Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
Ocarina
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
TASTE
Ocarina
Commits
7600dca4
Commit
7600dca4
authored
Sep 05, 2015
by
Julien
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix subprogram calls for shared data
Fixes #49
parent
5fbcffdf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
102 additions
and
114 deletions
+102
-114
src/backends/ocarina-backends-c_common-mapping.adb
src/backends/ocarina-backends-c_common-mapping.adb
+102
-104
src/backends/ocarina-backends-c_tree-nutils.adb
src/backends/ocarina-backends-c_tree-nutils.adb
+0
-10
No files found.
src/backends/ocarina-backends-c_common-mapping.adb
View file @
7600dca4
...
...
@@ -1951,113 +1951,111 @@ package body Ocarina.Backends.C_Common.Mapping is
-- mapped in the case of pure call sequence subprogram because
-- they are used only to close the access chain.
if
Get_Subprogram_Kind
(
S
)
/=
Subprogram_Pure_Call_Sequence
then
if
not
AINU
.
Is_Empty
(
Features
(
S
))
then
F
:=
AIN
.
First_Node
(
Features
(
S
));
while
Present
(
F
)
loop
if
Kind
(
F
)
=
K_Subcomponent_Access_Instance
then
case
Get_Required_Data_Access
(
Corresponding_Instance
(
F
))
is
when
Access_Read_Only
=>
Mode
:=
Mode_In
;
when
Access_Write_Only
=>
Mode
:=
Mode_Out
;
when
Access_Read_Write
=>
Mode
:=
Mode_Inout
;
when
Access_None
=>
-- By default, we allow read/write access
Mode
:=
Mode_Inout
;
when
others
=>
Display_Located_Error
(
AIN
.
Loc
(
F
),
"Unsupported required access"
,
Fatal
=>
True
);
end
case
;
D
:=
Corresponding_Instance
(
F
);
case
Get_Data_Representation
(
D
)
is
when
Data_Integer
|
Data_Boolean
|
Data_Float
|
Data_Fixed
|
Data_Struct
|
Data_String
|
Data_Wide_String
|
Data_Character
|
Data_Wide_Character
|
Data_Array
=>
-- If the data component is a simple data
-- component (not a structure), we simply add a
-- parameter with the computed mode and with a
-- type mapped from the data component.
if
Mode
=
Mode_In
then
Param
:=
CTU
.
Make_Parameter_Specification
(
Defining_Identifier
=>
Map_C_Defining_Identifier
(
F
),
Parameter_Type
=>
Map_C_Data_Type_Designator
(
D
));
else
Param
:=
CTU
.
Make_Parameter_Specification
(
Defining_Identifier
=>
Map_C_Defining_Identifier
(
F
),
Parameter_Type
=>
CTU
.
Make_Pointer_Type
(
Map_C_Data_Type_Designator
(
D
)));
end
if
;
if
not
AINU
.
Is_Empty
(
Features
(
S
))
then
F
:=
AIN
.
First_Node
(
Features
(
S
));
CTU
.
Append_Node_To_List
(
Param
,
Profile
);
when
Data_With_Accessors
=>
-- If the data component is a complex data
-- component (which has subcomponents), we add a
-- parameter with the computed mode and with a
-- type mapped from each subcomponent type.
Field
:=
AIN
.
First_Node
(
Subcomponents
(
D
));
while
Present
(
Field
)
loop
if
AINU
.
Is_Data
(
Corresponding_Instance
(
Field
))
then
if
Mode
=
Mode_In
then
Param
:=
CTU
.
Make_Parameter_Specification
(
Defining_Identifier
=>
Map_C_Defining_Identifier
(
Field
),
Parameter_Type
=>
Map_C_Data_Type_Designator
(
Corresponding_Instance
(
Field
)));
else
Param
:=
CTU
.
Make_Parameter_Specification
(
Defining_Identifier
=>
Map_C_Defining_Identifier
(
Field
),
Parameter_Type
=>
Make_Pointer_Type
(
Map_C_Data_Type_Designator
(
Corresponding_Instance
(
Field
))));
end
if
;
CTU
.
Append_Node_To_List
(
Param
,
Profile
);
end
if
;
Field
:=
AIN
.
Next_Node
(
Field
);
end
loop
;
while
Present
(
F
)
loop
if
Kind
(
F
)
=
K_Subcomponent_Access_Instance
then
case
Get_Required_Data_Access
(
Corresponding_Instance
(
F
))
is
when
Access_Read_Only
=>
Mode
:=
Mode_In
;
when
Access_Write_Only
=>
Mode
:=
Mode_Out
;
when
Access_Read_Write
=>
Mode
:=
Mode_Inout
;
when
Access_None
=>
-- By default, we allow read/write access
Mode
:=
Mode_Inout
;
when
others
=>
Display_Located_Error
(
AIN
.
Loc
(
F
),
"Unsupported required access"
,
Fatal
=>
True
);
end
case
;
when
others
=>
Display_Located_Error
(
AIN
.
Loc
(
F
),
"Unsupported data type"
,
Fatal
=>
True
);
end
case
;
end
if
;
D
:=
Corresponding_Instance
(
F
);
F
:=
AIN
.
Next_Node
(
F
);
end
loop
;
end
if
;
case
Get_Data_Representation
(
D
)
is
when
Data_Integer
|
Data_Boolean
|
Data_Float
|
Data_Fixed
|
Data_Struct
|
Data_String
|
Data_Wide_String
|
Data_Character
|
Data_Wide_Character
|
Data_Array
=>
-- If the data component is a simple data
-- component (not a structure), we simply add a
-- parameter with the computed mode and with a
-- type mapped from the data component.
if
Mode
=
Mode_In
then
Param
:=
CTU
.
Make_Parameter_Specification
(
Defining_Identifier
=>
Map_C_Defining_Identifier
(
F
),
Parameter_Type
=>
Map_C_Data_Type_Designator
(
D
));
else
Param
:=
CTU
.
Make_Parameter_Specification
(
Defining_Identifier
=>
Map_C_Defining_Identifier
(
F
),
Parameter_Type
=>
CTU
.
Make_Pointer_Type
(
Map_C_Data_Type_Designator
(
D
)));
end
if
;
CTU
.
Append_Node_To_List
(
Param
,
Profile
);
when
Data_With_Accessors
=>
-- If the data component is a complex data
-- component (which has subcomponents), we add a
-- parameter with the computed mode and with a
-- type mapped from each subcomponent type.
Field
:=
AIN
.
First_Node
(
Subcomponents
(
D
));
while
Present
(
Field
)
loop
if
AINU
.
Is_Data
(
Corresponding_Instance
(
Field
))
then
if
Mode
=
Mode_In
then
Param
:=
CTU
.
Make_Parameter_Specification
(
Defining_Identifier
=>
Map_C_Defining_Identifier
(
Field
),
Parameter_Type
=>
Map_C_Data_Type_Designator
(
Corresponding_Instance
(
Field
)));
else
Param
:=
CTU
.
Make_Parameter_Specification
(
Defining_Identifier
=>
Map_C_Defining_Identifier
(
Field
),
Parameter_Type
=>
Make_Pointer_Type
(
Map_C_Data_Type_Designator
(
Corresponding_Instance
(
Field
))));
end
if
;
CTU
.
Append_Node_To_List
(
Param
,
Profile
);
end
if
;
Field
:=
AIN
.
Next_Node
(
Field
);
end
loop
;
when
others
=>
Display_Located_Error
(
AIN
.
Loc
(
F
),
"Unsupported data type"
,
Fatal
=>
True
);
end
case
;
end
if
;
F
:=
AIN
.
Next_Node
(
F
);
end
loop
;
end
if
;
N
:=
...
...
src/backends/ocarina-backends-c_tree-nutils.adb
View file @
7600dca4
...
...
@@ -1627,7 +1627,6 @@ package body Ocarina.Backends.C_Tree.Nutils is
N
:
Node_Id
;
F
:
Node_Id
;
M
:
Node_Id
;
Owner
:
Node_Id
;
Declaration
:
Node_Id
;
Data_Accessed
:
Node_Id
;
Hybrid
:
constant
Boolean
:=
...
...
@@ -1933,15 +1932,6 @@ package body Ocarina.Backends.C_Tree.Nutils is
N
:=
Message_Comment
(
"Invoking method"
);
CTU
.
Append_Node_To_List
(
N
,
Statements
);
Owner
:=
Get_Actual_Owner
(
Spg_Call
);
N
:=
Make_Variable_Address
(
CTN
.
Defining_Identifier
(
CTN
.
Object_Node
(
Backend_Node
(
Identifier
(
Owner
)))));
Append_Node_To_List
(
N
,
Call_Profile
);
-- The name of the called subprogram is deduced from the
-- corresponding subprogram spec instance (last element
-- of the 'Path' list) and from the actual data component
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment