home *** CD-ROM | disk | FTP | other *** search
- $ ! Demo of constraint checking across language boundaries
-
- $ ! DEC Ada calling DEC FORTRAN-77
-
- $ ! the Ada mainline:
-
- $ type adamain.ada
-
- WITH text_io;
- PROCEDURE adamain IS
-
- TYPE rint IS RANGE 1..10;
- i : rint;
-
- PROCEDURE for1 (x : IN OUT rint);
- PRAGMA interface (fortran, for1);
-
- PACKAGE int_io IS NEW text_io.integer_io(rint);
-
- BEGIN
- i := 8;
- text_io.put ("Initial Value OF I IS ");
- int_io.put (i,2);
- text_io.new_line;
- for1 (i); -- assigns I:=20
- text_io.put ("Value OF I after FOR1 IS ");
- int_io.put (i,2);
- text_io.new_line;
- i := i + 1; -- this should cause a constraint_error exception
- text_io.put ("This should NOT be printed ");
- int_io.put (i,2);
- text_io.new_line;
- END adamain;
-
- $ ! the FORTRAN subprogram:
-
- $ type for1.for
-
- subroutine for1 (i)
- i = 20
- return
- end
-
- $ ! compile both
-
- $ fortran for1
-
- $ ada adamain
-
- $ ! place FOR1.OBJ in MYLIB.OLB for later linking process
-
- $ lib mylib for1/replace
-
- $ ! do the link
-
- $ acs link adamain mylib/lib
-
- Invoking the VAX/VMS Linker
-
- $ ! run the program:
-
- $ run adamain
- Initial Value OF I IS 8
- Value OF I after FOR1 IS 20
- CONSTRAINT_ERROR
- Symbolic stack dump follows
- ... detail left out ...
- $ ! note: the assignment back from FOR1 worked
-
- $ ! the constraint error was raised when I did I:=I+1
-
- $
-