diff options
| author | Jose E. Marchesi <jemarch@gnu.org> | 2026-01-24 20:10:10 +0100 |
|---|---|---|
| committer | Jose E. Marchesi <jemarch@gnu.org> | 2026-01-29 01:37:57 +0100 |
| commit | e41a344ccfab6fe2ac23f958eed8d69b6171890f (patch) | |
| tree | 31494f0734446c078d747c2589b18280f130547b /libjava/gnu/java | |
| parent | 67bb07e67270878f9d3b032f84ee86b970d84b15 (diff) | |
| download | gcc-e41a344ccfab6fe2ac23f958eed8d69b6171890f.zip gcc-e41a344ccfab6fe2ac23f958eed8d69b6171890f.tar.gz gcc-e41a344ccfab6fe2ac23f958eed8d69b6171890f.tar.bz2 | |
a68: support FFI with C via formal holes
This commit adds FFI support to access C variables and call C
functions from Algol 68, using the construct specified by the Modules
and Separated compilation facilities intended to that effect: formal
holes (`nest' constructs).
Briefly put, an `int foo' C variable can be accessed from Algol 68
like:
int foo = nest C "foo";
if foo > 10 then ... fi;
A ref to a C variable `int counter', that allows to modify it as well
as read it:
ref int counter = nest C "&counter";
counter +:= 1;
The address stored in an `int *ptr' variable, as an Algol 68
reference:
ref int ptr = nest C "ptr";
ptr := 100; { Changes the integer pointed by the C ptr }
Calling the standard C `random' function:
proc long int random = nest C "random";
if random < 100 then ... fi;
Some tests and an sketchy section in the manual are also included.
Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>
gcc/algol68/ChangeLog
* ga68.vw: Fix grammar for formal holes.
* ga68.texi (Particular programs): New section.
(Comments): Likewise.
* a68.h: Prototypes for a68_is_c_mode, a68_make_fomal_hole_decl,
a68_lower_formal_hole.
* a68-parser-attrs.def (FORMAL_HOLE): New attribute.
(LANGUAGE_INDICANT): Likewise.
* a68-parser-extract.cc (a68_elaborate_bold_tags): Elaborate
language indicants.
* a68-parser-moids-check.cc (mode_check_unit): Check mode in
formal holes.
* a68-low-units.cc (a68_lower_formal_hole): New function.
* a68-low.cc (a68_make_formal_hole_decl): Likewise.
* a68-moids-misc.cc (a68_is_c_mode): Likewise.
* a68-parser-bottom-up.cc (reduce_formal_holes): Likewise.
gcc/testsuite/ChangeLog
* algol68/compile/error-nest-1.a68: New test.
* algol68/compile/nest-c-1.a68: Likewise.
* algol68/compile/error-nest-5.a68: Likewise.
* algol68/compile/error-nest-4.a68: Likewise.
* algol68/compile/error-nest-3.a68: Likewise.
* algol68/compile/error-nest-2.a68: Likewise.
Diffstat (limited to 'libjava/gnu/java')
0 files changed, 0 insertions, 0 deletions
