162 Commits

Author SHA1 Message Date
Godzil
ffe13a4583 Update README 2015-06-24 23:41:49 +01:00
George Koehler
c602379db9 Some fixes for aelflod and aslod.
Copy rhead() and rsect() from aslod to aelflod, so aelflod can work
for machine with 64-bit long.

In aelflod, fix ELF header so file(1) no longer reports "corrupted
section header size".

Signed-off-by: Manoel Trapier <godzil@godzil.net>
2015-06-24 23:41:49 +01:00
Godzil
9da790283e Remove/change bad prototypes
In modules/system/time, a bad prototype for "time" was left. There is too some problem with filno under OpenBSD. Currently, the only known OS that don't want to export fileno with c89/c99 standard, is linux, so #ifdef/#endif the prototypes only for linux. (OpenBSD seems to define them as MACROs, that led to errors)
2015-06-24 23:41:49 +01:00
Godzil
0ba3023570 Add a missing header include. 2015-06-24 23:41:49 +01:00
Godzil
06665f4624 Change sbrk definitions.
The prototypes difference between platform is really annoying, since it's hard to always match the system on, and prevent warning on bad types. I try now to always use BRK emulation on all platform that do not match the prototype used in ACK. the PM script should be changed to set this correctly during setup.
2015-06-24 23:41:49 +01:00
Godzil
0f10f91839 Surprisly clang started to tell me where variable may used uninitialized, correcting it!
That's a good point it tell me that, but was a bit unexpected ^^
2015-06-24 23:41:49 +01:00
Godzil
c59e2f03ab Augment the "template" buffer size, 50byte is too short for a path. 2015-06-24 23:41:49 +01:00
Manoel Trapier
5f00cd2e53 Make a brk/sbrk emulation.
Mac OS X seems to have some difficulties with brk/sbrk (maybe with the
4MB heap limit), and replace all the allocation logic will be prone to
errors, I'll add a new define and lib to emulate brk/sbrk using more
standard allocation methods. By default the heap is 64MB, it should be
enough.
2015-06-24 23:41:49 +01:00
Manoel Trapier
e92393d6f3 Correcting a nasty bug introduced in commit 6204c6b6416dfe4d3a0f0b0b7d6d8b5be81acefb 2015-06-24 23:41:49 +01:00
Manoel Trapier
b21aede758 Correct a bad change. 2015-06-24 23:41:49 +01:00
Manoel Trapier
3f6a9560c5 Correct assert definition to correctly display the faulty text instead of "x" 2015-06-24 23:41:49 +01:00
Manoel Trapier
93f542eb7a Add #warning to cemcom.ansi 2015-06-24 23:41:49 +01:00
Manoel Trapier
2071a7dbb0 Correct bad changes 2015-06-24 23:41:48 +01:00
Manoel Trapier
4cb35a7d72 OUPS! printing text here was really not good idea! 2015-06-24 23:41:48 +01:00
Manoel Trapier
d853b7f2fb Converting mach ncg... 2015-06-24 23:41:48 +01:00
Manoel Trapier
ca57bb617b Correct some Linux/clang missing parts. 2015-06-24 23:41:48 +01:00
Godzil
ee6e8bdfc3 Correct comment errors. 2015-06-24 23:41:48 +01:00
Godzil
595e5258aa Update i86 as part. 2015-06-24 23:41:48 +01:00
Godzil
d627b11b98 Do not use ACK cpp (even ANSI one) to compile for the host. 2015-06-24 23:41:48 +01:00
Godzil
da1cb44497 Currently deactivate all language expect ANSI C. 2015-06-24 23:41:48 +01:00
Godzil
a39e88ecca Update generic part of the AS 2015-06-24 23:41:48 +01:00
Godzil
b31c94cf32 cpp.ansi: Add missing "#warning" directive 2015-06-24 23:41:48 +01:00
Manoel Trapier
5c73826e4c Remove unwanted files 2015-06-24 23:41:48 +01:00
Manoel Trapier
46f101f4dd Update makeheader.sh 2015-06-24 23:41:48 +01:00
Manoel Trapier
2830ec90b1 Finishing ANSI C frontend 2015-06-24 23:41:47 +01:00
Manoel Trapier
60b5f91561 More incoherency between MacOSX and Linux... 2015-06-24 23:41:47 +01:00
Godzil
b2d6e23b5f Add small too to generate headers.
(Need cproto)
2015-06-24 23:41:47 +01:00
Godzil
6e6d9c26b5 Working on ANSI C frontend... 2015-06-24 23:41:47 +01:00
Godzil
1c4e04de3a Next batch of changes! 2015-06-24 23:41:47 +01:00
Godzil
a05a174f40 MacOS X/clang found a new batch of warnings :) 2015-06-24 23:41:47 +01:00
Manoel Trapier
1b34c8cc9f Warning hunt on ego. 2015-06-24 23:41:47 +01:00
Manoel Trapier
25c717d9b3 Next batch of warning hunt... 2015-06-24 23:41:47 +01:00
Manoel Trapier
1ed1edf94d Correct an incoherency with arith and label types. 2015-06-24 23:41:47 +01:00
Manoel Trapier
08d1784f95 Remove more warns on ncgg
!! Maybe a bug found in ncgg cgg.y with n_coerc call atline 612
2015-06-24 23:41:47 +01:00
Manoel Trapier
e3b4856beb As suspected clang/Linux have it's own sort of warns ^^ 2015-06-24 23:41:47 +01:00
Godzil
0f7eaacc5f Now CGG compile without warns ;) 2015-06-24 23:41:46 +01:00
Godzil
97bb7d9316 Remove bad prototypes 2015-06-24 23:41:46 +01:00
Manoel Trapier
20d58dea19 Another batch.. 2015-06-24 23:41:46 +01:00
Manoel Trapier
2bbd5a38de More strict checks... 2015-06-24 23:41:46 +01:00
Manoel Trapier
a8d9183e25 Reordonate modules in a more logical way.
(some modules have dependencies on other especially with header files)
2015-06-24 23:41:46 +01:00
Manoel Trapier
a262a916dc Being a bit more strict on warnings (-Wall). 2015-06-24 23:41:46 +01:00
Manoel Trapier
74fb1cff61 Make GCC happy with current patchs and compilation flags. 2015-06-24 23:41:46 +01:00
Godzil
c0cd8650a6 Another batch especially on C ANSI frontend 2015-06-24 23:41:46 +01:00
Godzil
369ec26b03 Add a global symbol2str header 2015-06-24 23:41:46 +01:00
Godzil
2a5ab5b856 Update .gitignore 2015-06-24 23:41:46 +01:00
Godzil
350e569c2c Correct printf with 64bit pointer 2015-06-24 23:41:45 +01:00
Godzil
d87b482eac Correct some error on static function declaration. 2015-06-24 23:41:45 +01:00
Manoel Trapier
b31ac47714 A bit of missing corections. 2015-06-24 23:41:45 +01:00
Manoel Trapier
03763cbbf0 Starting ANSI C frontend 2015-06-24 23:41:45 +01:00
Manoel Trapier
452127650a Next batch 2015-06-24 23:41:45 +01:00
Godzil
bd3e7b87e6 Getting sync. 2015-06-24 23:41:45 +01:00
Godzil
6093a51511 Add missing stdarg (funnily, linux/clang does not complain about this miss) 2015-06-24 23:41:45 +01:00
Manoel Trapier
41f96d5169 Next batch... 2015-06-24 23:41:45 +01:00
Manoel Trapier
c5bfc89269 Update README. 2015-06-24 23:41:45 +01:00
Manoel Trapier
22c8f3ac10 Add transtyping for support of 64bit cpu and 32cpu (or the printf verification for %d/%ld will fail) 2015-06-24 23:41:45 +01:00
Godzil
674eb61908 Another batch... 2015-06-24 23:41:45 +01:00
Godzil
653bd13b40 Correct printf, and minor changes 2015-06-24 23:41:44 +01:00
Godzil
7b8e3edd43 Add missing function prototype. 2015-06-24 23:41:44 +01:00
Godzil
5362498c1c Change arith type to force it to be 32bit. 2015-06-24 23:41:44 +01:00
Manoel Trapier
f6d58a0d04 Another batch... 2015-06-24 23:41:44 +01:00
Manoel Trapier
36a59de862 Change from yacc to byacc (yacc build code that generate warnings...) 2015-06-24 23:41:44 +01:00
Manoel Trapier
0946773758 ANSIfication] Another batch. 2015-06-24 23:41:44 +01:00
Manoel Trapier
3d1d1277b7 Next batch. 2015-06-24 23:41:44 +01:00
Manoel Trapier
60330b05cd Update a bit of module em_code. 2015-06-24 23:41:44 +01:00
Manoel Trapier
e54911f642 Update module assert 2015-06-24 23:41:44 +01:00
Manoel Trapier
71df09d022 Update tokens.g and regenerate tokens.c with it. 2015-06-24 23:41:44 +01:00
Manoel Trapier
498d867bc3 Update LLgen.g and regenerate LLgen.c with it. 2015-06-24 23:41:44 +01:00
Manoel Trapier
f1cd17c51e Next batch, LLgen no longuer have warning under linux/clang. 2015-06-24 23:41:44 +01:00
Manoel Trapier
d28368333a Next batch of Ansi-ification 2015-06-24 23:41:43 +01:00
Manoel Trapier
9f7ae734db Part 1 of warning/old k&r inconsistency correction. 2015-06-24 23:41:43 +01:00
Manoel Trapier
7eff32c40d Force C89 and error on all warnings. 2015-06-24 23:41:43 +01:00
Manoel Trapier
d3715f3ca4 Add missing Copyright file 2015-06-24 23:41:43 +01:00
Manoel Trapier
659f26136a exchange LICENSE and Copyright file 2015-06-24 23:41:43 +01:00
Godzil
33af50ea26 Start k&r to ansi modification 2015-06-24 23:41:43 +01:00
Manoel Trapier
cb89c679ec Update README to display better in markdown 2015-06-24 23:41:43 +01:00
Manoel Trapier
d78a72a6e2 Add markdown and license file 2015-06-24 23:41:43 +01:00
Manoel Trapier
a551523b22 Add gitignore file. 2015-06-24 23:41:43 +01:00
Manoel Trapier
b907b15d4f Add NES platform to default build. (Still more to go to compile correctly) and re-enabling the "k&r" cpp 2015-06-24 23:41:43 +01:00
Manoel Trapier
45e01dcd3e Correct mach cg pmfile that incorrectly reference PLATFORM where it should reference ARCH 2015-06-24 23:41:43 +01:00
Manoel Trapier
cc534493fd Copy pc86 platform to nes platform, and make change accordingly. 2015-06-24 23:41:43 +01:00
David Given
dccecc5d45 Back out erroneous change. 2012-12-14 11:56:21 +00:00
George Koehler
0fc7fd5d33 Prevent segfault when trying to print an error message.
Use <stdarg.h> to pass arguments correctly, as ack/util/util.c
already uses <stdarg.h> the same way.
2012-10-24 13:44:50 -04:00
David Given
4349d702fa Change from using platform-specific types to stdint platform-independent types
when reading the structure header.
2012-09-27 11:32:40 +01:00
David Given
2beb3646a7 Change to use stdint's implementation independent types rather than short and
long (which vary depending on whether you're on a 64-bit system or not).
2012-09-27 10:54:41 +01:00
George Koehler
7ef9b79c11 Merge deletion of many undead files. 2012-09-23 15:31:16 -04:00
George Koehler
3dcc3bd1cf Allow pc86 bootloader to boot from more floppy drives.
When the bootloader probes the drive geometry, the BIOS can clobber the
es register.  If this happens, the bootloader loads the program to the
wrong address, and jumps off the code.  This happens with an emulated
floppy drive in Bochs or QEMU, but not with an emulated hard disk.
2012-09-23 14:43:22 -04:00
George Koehler
e7c79415b5 Prevent division by zero in aslod.
rhead() and rsect() had assumed sizeof(long) == 4, but OpenBSD/amd64
has sizeof(long) == 8.  The problem revealed itself when sect->os_lign
became zero, and align() divided by zero.
2012-09-21 22:51:12 -04:00
George Koehler
0131ca4d46 Delete 689 undead files.
These files "magically reappeared" after the conversion from CVS to
Mercurial.  The old CVS repository deleted these files but did not
record *when* it deleted these files.  The conversion resurrected these
files because they have no history of deletion.  These files were
probably deleted before year 1995.  The CVS repository begins to record
deletions around 1995.

These files may still appear in older revisions of this Mercurial
repository, when they should already be deleted.  There is no way to fix
this, because the CVS repository provides no dates of deletion.

See http://sourceforge.net/mailarchive/message.php?msg_id=29823032
2012-09-20 22:26:32 -04:00
George Koehler
be234ea759 *Again* fix fit16i() for systems with 64-bit long.
I already did this in abebf1586c06, but I edited the wrong file.  Then
in edddc6b7cd17, I deleted that file.

By fixing fit16i(), I can now compile ACK for OpenBSD/amd64.
2012-09-19 23:39:51 -04:00
George Koehler
8bf34937f1 Delete old and unused files from modules/src/em_code 2012-09-17 16:04:55 -04:00
George Koehler
99eb12a282 Fix fit16i() for systems with 64-bit long.
(long)0xFFFF8000 had expanded to 0x00000000FFFF8000.
With (long)(-0x8000), the compiler now extends the negative sign.
2012-09-16 19:57:07 -04:00
George Koehler
96ea0a5903 Fix more functions in util/ack for 64-bit hosts.
This continues the fix from changeset aabde0589450.  We must use
va_list to forward the arguments, because some of the arguments might
be 64-bit pointers.  A pointer does not fit in an int.
2012-09-07 16:28:10 -04:00
George Koehler
800d4ae032 Fix cemcom.ansi for 64-bit hosts.
Hosts with sizeof(arith) == sizeof(long) == 8 need to set full_mask[1]
through full_mask[8].  Because MAXSIZE == 8, we only had full_mask[0]
through full_mask[7].  This fix declares arith full_mask[MAXSIZE + 1]
and prevents a fatal error: "array full_mask too small for this machine"
2012-09-07 15:53:13 -04:00
David Given
6ea172d0d9 Fix a 64-bitness issue (removed some untyped K&R C code that assumed ints
and pointers were the same size).
2012-02-27 22:36:36 +00:00
Ceriel Jacobs
1072a8797e Added atol() that ignores overflow, so that unsigned long constants are dealt with properly 2011-06-15 11:13:48 +02:00
Ceriel Jacobs
2483e5723d Fixed CFU 2011-06-15 10:56:58 +02:00
cjhjacobs
58613009f8 Fixed bug reported on tack-devel mailing list on 20-3-2011 2011-05-18 19:19:19 +02:00
David Given
b6dfaefeff Removed file that the CVS conversion procedure left in (when it shouldn't have). 2011-03-20 20:47:10 +00:00
cvs2hg
eb0b730607 convert CVS tags 2011-02-11 00:51:45 +00:00
dtrg
45ee287136 Replaced dis and new with modern implementations donated by erik@backerud.se. 2010-10-02 21:52:29 +00:00
dtrg
075cb488a3 Call the correct kill() and getpid() syscalls rather than _kill() and _getpid(). 2010-10-02 21:51:40 +00:00
dtrg
a33473e0a5 Now call creat() and open() instead of _creat() and _open(). 2010-09-27 20:47:32 +00:00
dtrg
7292b538bc Added support for remove() and unlink(). 2010-09-27 20:44:49 +00:00
dtrg
a8ecb11013 Fixed very old bug where Streams.GetStreamPosition would return the wrong position --- thanks to Jan Verhoeven for finding this. 2010-09-01 19:55:15 +00:00
dtrg
085f346f8c Fixed definitions of O_* flags. 2010-08-20 19:27:09 +00:00
dtrg
c326f3c6a3 Remove references to using-machine-name-for-compiler, as we don't do that any more. 2010-08-09 22:47:33 +00:00
dtrg
a0c67da261 Changed to actually work. (On modern Linux systems the old version just
crashes. On old Linux systems it apparently only worked by accident.)
2010-08-06 17:06:31 +00:00
dtrg
293f34fa9b Flush stdout before prompting the user for input. 2010-08-06 17:02:16 +00:00
dtrg
da6111328d Flush output stream before waiting for user input. 2010-08-05 22:23:34 +00:00
cvs2hg
7273130b4c fixup commit for tag 'release-6-0-pre-4' 2010-08-04 18:04:08 +00:00
dtrg
9d2d5606ea Forgot to update version number. 2010-08-04 18:04:07 +00:00
dtrg
5147166810 Updated for 6.0pre4. 2010-08-04 18:01:12 +00:00
dtrg
e537bcc321 Fixed typo. 2010-08-04 17:59:40 +00:00
dtrg
5a872eed38 Prevent build failure on modern Bisons (which are more picky than the old yacc this was written for). 2010-08-01 10:36:01 +00:00
dtrg
51b41f72f8 Invoke genfiles explicitly with sh --- CVS doesn't store executable bits. 2010-08-01 10:35:33 +00:00
dtrg
ee72886e54 Renamed 'switch' variable to avoid conflict with a keyword in modern awks. 2010-08-01 10:35:04 +00:00
dtrg
2c54f8c742 Renamed getline() to getln() to avoid conflict with glibc's version. 2010-08-01 10:34:27 +00:00
dtrg
481bcd8a8b Added a very-nearly-noop peephole optimiser for Z80. 2008-03-20 23:20:08 +00:00
dtrg
fc44fe2185 Properly handles files ending in a partial line. 2008-03-20 22:50:50 +00:00
dtrg
4dd1ff6d80 Archival checkin (semi-working code). 2007-11-02 18:56:58 +00:00
cvs2hg
58e5e12ead fixup commit for tag 'release-6-0-pre-3' 2007-04-29 23:09:25 +00:00
dtrg
54ce3f451b Configured distr system for the 6.0pre3 release. 2007-04-29 23:09:24 +00:00
dtrg
663f4f2fb5 Cleaned up a bit and made work with the new platform architecture. 2007-04-29 23:03:24 +00:00
dtrg
78777e802b Now using more conservative optimisation due to random seg fault issues. 2007-04-29 23:02:23 +00:00
dtrg
df088c184b Added optimised rules for int<<8 and uint>>8 (which can be done with simple register shuffling rather than calling .sli). 2007-04-29 23:00:31 +00:00
dtrg
868b8c5075 Fixed the ego parameters to actually allow extended optimisation. 2007-04-29 21:25:09 +00:00
dtrg
eb4ea1e761 Use better optimisation options. 2007-04-29 21:24:17 +00:00
dtrg
494d9a3e4a Now runs descr files through the ANSI C preprocessor, rather than the K&R one (which no longer exists). 2007-04-29 21:23:55 +00:00
dtrg
6127ddf024 Fixed the trap code to write out the error message correctly. 2007-04-29 20:47:48 +00:00
dtrg
9d0f0a8fdd Disabled the code to throw signals on EM traps; this is the platform's job (and requires working signal support, which we may not have). 2007-04-29 20:46:48 +00:00
dtrg
c9d7f7ef23 Added suppot for BSS clearing and command line parsing. 2007-04-29 00:28:06 +00:00
dtrg
a7323e1a8b Documented floating-point status. 2007-04-28 22:34:47 +00:00
dtrg
3a4147a37d Added the Mandelbrot generator. 2007-04-28 22:34:05 +00:00
dtrg
be8baf3da6 Added cpm platform. 2007-04-27 22:42:41 +00:00
dtrg
013f58f94e Added the stdint.h header file. 2007-04-27 22:42:02 +00:00
dtrg
0d8578410c Cleaned up and enabled the support for conditionally emitting the floating-point stdio code. 2007-04-27 22:41:39 +00:00
dtrg
7f266d6b4e Removed a completely pointless 128-byte buffer. 2007-04-27 22:41:05 +00:00
dtrg
440d6faadd Fixed a bug where loc lol stf was getting the constant pushed onto the stack *after* stf had popped it off. 2007-04-27 22:15:31 +00:00
dtrg
24ea8aee3d Updated for the 6.0pre2 release. 2007-04-24 20:45:58 +00:00
dtrg
bc5ccee8d5 Removed bashish. 2007-04-24 19:48:41 +00:00
dtrg
bfeb736c35 Stripped down the library to something approaching the ANSI C minimum and replaced most of the header files, to provide a reasonably consistent base to work up from. 2007-04-24 19:42:24 +00:00
dtrg
740940c9fc Fixed major typos in the signal declarations that was preventing anything that used signal() from compiling. 2007-04-24 19:34:34 +00:00
dtrg
f6085fb234 Updated use of headers to compile cleanly. 2007-04-24 19:33:53 +00:00
dtrg
b8e1348f2a Ensured that _errno is always defined. Rejigged the pc86 boot code so it doesn't always waste 510 bytes of memory. 2007-04-24 19:25:00 +00:00
dtrg
413880c52d Added support for the linux386 platform. Disabled building of the K&R C, Basic and Occam compilers. 2007-04-23 23:41:50 +00:00
dtrg
ae9ac25f45 Modified to run ncgg input files through the ANSI preprocessor rather than the K&R one. 2007-04-23 23:40:59 +00:00
dtrg
f471d2e618 Added the aelflod tool for generating ELF executables. Added documentation for aelflod and ashow. Now installs the documentation when built. 2007-04-23 23:40:10 +00:00
dtrg
67c4f3de87 Modified to allow a space between the sign and the first digit of a constant. 2007-04-23 23:24:46 +00:00
dtrg
9b920e59cb Now fetches argc, argv, env correctly from the host OS. 2007-04-23 23:24:03 +00:00
dtrg
9710c14c93 Added the 'Star Trek' example game. 2007-04-21 23:20:11 +00:00
dtrg
921c55968c Adapted to tell the user what language they were written in (because they're too similar!). Modified the Pascal implementation to work with our new syscall model. 2007-04-21 23:19:32 +00:00
dtrg
1c83baa702 Adapted for ANSI C and our pseudo-Posix syscall interface. 2007-04-21 23:18:14 +00:00
dtrg
b66d66b597 Fixed a bug where the preprocessor would occasionally lose whitespace at the beginning of lines immediately after a #endif, which was confusing the assembler. 2007-04-21 23:10:13 +00:00
dtrg
2a367fa192 Disabled Terminal as it uses hard-coded ioctls and appears to be non-standard anyway. 2007-04-21 23:07:57 +00:00
dtrg
f4e37e1319 Changed to call the isatty() syscall directly, rather than fiddling around with non-portable ioctls. 2007-04-21 23:07:05 +00:00
dtrg
400c475c03 Disabled the K&R C compiler in favour of the ANSI one. 2007-04-21 23:03:35 +00:00
dtrg
b500b1a7b7 Added linux386 platform. 2007-04-21 23:02:11 +00:00
dtrg
201c66879d Updated to work with the new libmon-less setup. 2007-04-21 22:59:42 +00:00
dtrg
04860c08a8 Updated to work with the linux386 platform. 2007-04-21 22:57:51 +00:00
dtrg
daee8da3c4 yacc source files are now run through the ANSI C preprocessor, not the K&R one. 2007-04-21 22:55:59 +00:00
dtrg
4428647786 Everything is built in ANSI C now. 2007-04-21 22:55:04 +00:00
dtrg
d77b4ce97c Renamed the language libraries and runtimes to have more
conventional names.
2007-02-26 22:36:56 +00:00
876 changed files with 22087 additions and 34445 deletions

32
.distr
View File

@@ -1,4 +1,5 @@
README
CHANGES
Copyright
pm
pmfile
@@ -29,7 +30,7 @@ util/cmisc
util/ack
lib/descr/fe
util/arch
util/cpp
#util/cpp
util/cgg
util/ncgg
util/misc
@@ -41,33 +42,16 @@ util/led
lang/cem
lang/pc
lang/m2
lang/occam
lang/basic
#lang/occam
#lang/basic
mach/proto
mach/i80
mach/i86
mach/i386
plat/cpm
plat/pc86
plat/linux386
examples
#Action
#NEW
#README
#TODO
#TakeAction
#bin
#doc
#emtest
#etc
#fast
#fcc
#first
#h
#include
#modules
#lang
#lib
#mach
#man
#util

5
.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
*~
*.o
.*
-.gitignore
/pattern.c

9
.hgtags Normal file
View File

@@ -0,0 +1,9 @@
5a0daa6017c4aa5ae23b870e97eb7431021762bc distr2
15b742c4c278c27029eca0e41f16463bc076de6e distr3
a0686e2ca8d6780ce37b8267b865f60e9317a340 llgen-1-0
d96cd06672c368e8aaa584fead379ce1d343acad oct-1
bf69b3579e8545ecfc03f5e2550586e3c479270d release-6-0-pre-4
e880082b57f12a7df1c33a2da2c7424d6368f185 dist2
fe535e3e8bc859d4a4e4a186f42670f9e588a5aa release-5-6
90102c21c4480102634c6a482d0dd55f2d9ca00f release-6-0-pre-3
ddc0de0e5e7d91b1dcd7c05602c9c2a6adf8d312 release-6-0-pre-1

35
CHANGES Normal file
View File

@@ -0,0 +1,35 @@
# $Source$
# $State$
# $Revision$
6.0pre4
Fixed some minor bit-rotting issues that were preventing compilation on
modern Linux systems.
6.0pre3
Added the cpm platform. Made some optimisations to the i80 code generator,
including getting topgen up and running and adding some peephole optimiser
rules. Fixed loads of bugs in ego so that it now works on platforms that
support it (pc86 and linux386). Made the floating point work on platforms
that support it (pc86 and linux386 again). Made stdint.h work. Lots and lots
of bugfixes and tweaks everywhere.
6.0pre2
Much simplified the syscall interface by disabling libmon and instead
calling the syscalls directly. Disabled the K&R C compiler and libc because
it doesn't actually gain us anything and has a high maintenance load --- the
ANSI C compiler works fine with K&R C. Adapted the rest of the system to
build with the ANSI C compiler. Rewrote the pc86 syscall interface and added
linux386 support, using the i386 code generator. Lots and lots of bugfixes
and tweaks everywhere.
6.0pre1
First working version of the 6.0 release stream. Working frontends: both C
compilers, Pascal, Modula-2, Basic and Occam. Working backends: i86. Working
platforms: pc86, the very noddy testbed setup that produces floppy disk
images.

View File

@@ -1,32 +0,0 @@
Copyright (c) 1987, 1990, 1993, 2005 Vrije Universiteit, Amsterdam, The Netherlands.
All rights reserved.
Redistribution and use of the Amsterdam Compiler Kit in source and
binary forms, with or without modification, are permitted provided
that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Vrije Universiteit nor the names of the
software authors or contributors may be used to endorse or
promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS, AUTHORS, AND
CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL VRIJE UNIVERSITEIT OR ANY AUTHORS OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

1
Copyright Symbolic link
View File

@@ -0,0 +1 @@
LICENSE

32
LICENSE Normal file
View File

@@ -0,0 +1,32 @@
Copyright (c) 1987, 1990, 1993, 2005 Vrije Universiteit, Amsterdam, The Netherlands.
All rights reserved.
Redistribution and use of the Amsterdam Compiler Kit in source and
binary forms, with or without modification, are permitted provided
that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Vrije Universiteit nor the names of the
software authors or contributors may be used to endorse or
promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS, AUTHORS, AND
CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL VRIJE UNIVERSITEIT OR ANY AUTHORS OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

65
README
View File

@@ -1,13 +1,8 @@
# $Source$
# $State$
# $Revision$
THE AMSTERDAM COMPILER KIT V6.0pre1
===================================
© 1987-2005 Vrije Universiteit, Amsterdam
2007-02-25
THE AMSTERDAM COMPILER KIT V6.0pre4
===================================
© 1987-2005 Vrije Universiteit, Amsterdam 2010-08-08
© 2013-2014 Manoel Trapier, Paris
INTRODUCTION
============
@@ -17,22 +12,41 @@ front end compilers for a number of different languages, code generators,
support libraries, and all the tools necessary to go from source code to
executable on any of the platforms it supports.
This is an early prerelease of the upcoming version 6.0 release. Not a
This is an early prerelease of the apocryphal version 6.0 release. Not a
lot is supported, the build mechanism needs work, and a lot of things are
probably broken. However, what's there should be sufficient to get things
done and to evaluate how the full 6.0 release should work.
This is a fork from the original repository found on sourceforge. This
fork exist for three reason, the first is I strongly prefere git than
mercurial (this is a personal preference) and second I want to make it
work on Mac OS X but the OSX clang/gcc does not really like the K&R
syntax, so I take into the process of ANSIfy it. The third reason is why
I want to use the ACK, it support old CPU, like the 6502 or i8080, i8086
and it is open source unlike a lot of compiler we can found nowadays for
such targets, and it support more than C that is a wonderfull bonus!
I have plan to add targets like the NES, add support for the 65c816 and
add the SNES target, add the WonderSwan as a target and so on. I see in
this compiler kit a wonderfull project for all sort of old computer that
are still used nowadays and used CPU that are no longuer targeted by
modern compilers.
I plan to push my changes on the original version, at least for the new
targets and cpu.
SUPPORT
=======
Languages:
ANSI C, K&R C, Pascal, Modula 2, Occam 1, and a Basic variant.
ANSI C, Pascal, Modula 2. K&R is supported via the ANSI C compiler.
Platforms:
pc86 produces bootable floppy disk images for 8086 PCs
linux386 produces ELF executables for PC Linux systems
cpm produces i80 CP/M .COM files
INSTALLATION
@@ -114,6 +128,9 @@ For further information, see the man page (which actually does get
installed, but is rather out of date).
There are some (known working) example programs in the 'examples' directory.
A sample command line is:
ack -mlinux386 -O examples/paranoia.c
GOTCHAS
@@ -121,16 +138,11 @@ GOTCHAS
There are some things you should be aware of.
- The only platform supported so far is pc86, which generates 8086 tiny mode
executables that will work as floppy disk boot images. So, to run, simply dd
the output file (pc86.img by default) onto a floppy disk and boot from it.
Be aware that very little functionality is supported and that the entire
program, heap and stack and code and all, must fit within 64kB. See
plat/pc86/README for more information.
- Look at plat/<PLATFORMNAME>/README for information about the two supported
platforms.
- By default, the ack tool will compile K&R C. Practically all C source these
days is ANSI C --- use the -ansi switch to enable ANSI mode. No, the ACK is
not C99 compatible.
- The library support is fairly limited; for C, it's at roughly the ANSI C
level, and for the other languages it's similar.
- When compiling languages other than C, the ACK will usually look at the
first character of the file. If it's a #, then the file will be run through
@@ -159,12 +171,19 @@ more welcome.
The ACK is licensed under a BSD-like license. Please see the 'Copyright' file
for the full text.
You can find the mailing list on the project's web site:
You will find this "ANSI Fork" on github:
http://github.com/Godzil/ack
You can find the ACK mailing list and the original project's web site:
http://tack.sourceforge.net/
Please enjoy.
Manoel Trapier (aka godzil) for the ANSI-fication port
David Given (dtrg on Sourceforge)
dg@cowlark.com
2007-02-25
2010-08-08

1
README.md Symbolic link
View File

@@ -0,0 +1 @@
README

View File

@@ -21,7 +21,7 @@ PREFIX = "/usr/local"
-- ======================================================================= --
-- FIXME: the following two variables must be set to their Minix variants
-- due to hard-coded references in the descr files. Don't c
-- due to hard-coded references in the descr files.
-- Name of the platform-independent library directory; 'share' on modern
-- systems, 'lib' on Minix-like systems.

View File

@@ -61,7 +61,7 @@ while [ "$1" != "" ]; do
shift
done
if [ "$destdir" == "" ]; then
if [ "$destdir" = "" ]; then
echo "You must specify a destination directory. (Try --help for help.)"
exit 1
fi
@@ -131,7 +131,7 @@ if !(strings $arch | grep archiver > /dev/null); then
echo "architecture.)"
echo ""
echo "Press RETURN to go ahead anyway, or CTRL+C to abort."
read
read ignored
fi
# Actually do the work.
@@ -141,7 +141,7 @@ echo " into destination tree: $destdir"
echo ""
if [ -e $destdir ]; then
if [ "$delete" == "yes" ]; then
if [ "$delete" = "yes" ]; then
echo "Press RETURN to erase $destdir and its contents, or CTRL+C to abort."
read
echo "Erasing..."
@@ -159,7 +159,10 @@ echo "Done."
# Revision history
# $Log$
# Revision 1.4 2007-02-25 20:56:41 dtrg
# Revision 1.5 2007-04-24 19:48:41 dtrg
# Removed bashish.
#
# Revision 1.4 2007/02/25 20:56:41 dtrg
# Performed major renovations to make the script work on OpenBSD.
#
# Revision 1.3 2007/02/24 02:05:56 dtrg

View File

@@ -3,5 +3,8 @@ hilo.c
hilo.mod
hilo.ocm
hilo.p
mandelbrot.c
paranoia.c
startrek.c
startrek.doc
README

View File

@@ -6,7 +6,7 @@ A few notes on the examples
---------------------------
This directory contains a handful of working example programs that can be
built with the ACK. They're intended as a convention source of test code
built with the ACK. They're intended as a convenient source of test code
and as a starting point when writing your own programs.
They consist of:
@@ -17,10 +17,17 @@ hilo.mod Modula-2 version of the Hi/Lo game
hilo.ocm Occam 1 version of the Hi/Lo game
hilo.p Pascal version of the Hi/Lo game
mandelbrot.c A simple Mandelbrot generator, using floating-point maths
paranoia.c An ancient public domain K&R C adventure game
startrek.c An even more ancient public domain ANSI C game
(uses the FPU for distance calculation)
startrek.doc Manual for above (plus in current directory when running)
Enjoy.
(startrek.c was written by David Ahl and converted to C by Chris Nystrom. See
http://www.cactus.org/%7Enystrom/startrek.html for more info.)
David Given
dg@cowlark.com
2007-02-25

View File

@@ -2,7 +2,7 @@
2 ' $State$
3 ' $Revision$
10 print "Hi there! Before we start, what is your name?"
10 print "Hi there! I'm written in Basic. Before we start, what is your name?"
20 input "> ", PlayerName$
30 print
40 print "Hello, "; PlayerName$; "!"

View File

@@ -59,7 +59,7 @@ void game(void)
int main(int argc, char* argv[])
{
printf("\nHi there! Before we start, what is your name?\n");
printf("\nHi there! I'm written in C. Before we start, what is your name?\n");
reads();
strcpy(PlayerName, buffer);
printf("\nHello, %s! ", PlayerName);

View File

@@ -6,13 +6,22 @@
MODULE HiLo;
FROM InOut IMPORT WriteInt, WriteLn, WriteString, ReadString, ReadInt;
FROM random IMPORT Uniform;
FROM Streams IMPORT FlushStream, OutputStream, StreamResult;
VAR
buffer : ARRAY [0..32] OF CHAR;
PROCEDURE flush;
VAR
strus : StreamResult;
BEGIN
FlushStream(OutputStream, strus);
END flush;
PROCEDURE reads;
BEGIN
WriteString("> ");
flush;
ReadString(buffer);
END reads;
@@ -31,8 +40,8 @@ BEGIN
finished := FALSE;
WHILE NOT finished DO
WriteLn;
WriteString("> ");
flush;
ReadInt(guess);
IF guess = Number THEN
@@ -66,7 +75,7 @@ VAR
finished : BOOLEAN;
BEGIN
WriteLn;
WriteString("Hi there! Before we start, what is your name?");
WriteString("Hi there! I'm written in Modula-2. Before we start, what is your name?");
WriteLn;
reads;
WriteLn;

View File

@@ -56,7 +56,7 @@ proc random(value range, var result) =
proc getname =
var seed, buffer[128]:
seq
puts("*nHi there! Before we start, what is your name?*n")
puts("*nHi there! I'm written in Occam. Before we start, what is your name?*n")
puts("> ")
gets(buffer)

View File

@@ -29,10 +29,12 @@ function random(range : integer) : integer;
random := seed mod range;
end;
{ Pascal doesn't provide string input, so we interface to the _read() syscall
and do it manually. }
{ Pascal doesn't provide string input, so we interface to the read() syscall
and do it manually. But... we can't interface to read() directly because
that conflicts with a Pascal keyword. Luckily there's a private function
uread() in the ACK Pascal library that we can use instead. }
function _read(fd : integer; var buffer : char; count : integer) : integer;
function uread(fd : integer; var buffer : char; count : integer) : integer;
extern;
function readchar : char;
@@ -42,7 +44,7 @@ function readchar : char;
begin
c := chr(0);
dummy := _read(0, c, 1);
dummy := uread(0, c, 1);
readchar := c;
end;
@@ -79,7 +81,7 @@ procedure getname;
begin
writeln;
writeln('Hi there! Before we start, what is your name?');
writeln('Hi there! I''m written in Pascal. Before we start, what is your name?');
writeln;
readstring(name, namelen);
writeln;

73
examples/mandelbrot.c Normal file
View File

@@ -0,0 +1,73 @@
/* $Source$
* $State$
* $Revision$
*/
/* Adapted from code by Chris Losinger. (This is the non-obfuscated
* version...
*
* http://www.codeproject.com/cpp/mandelbrot_obfuscation.asp
*/
#include <stdlib.h>
#include <unistd.h>
enum
{
ROWS = 40,
COLUMNS = 60,
MAX_ITERATIONS = 255
};
void nl(void)
{
write(1, "\n", 1);
}
void out(int n)
{
const char* chars = "****++++++---- ";
write(1, chars + (n/16), 1);
}
int main(int argc, const char* argv[])
{
/* Size and position of the visible area. */
double view_r = -2.3, view_i = -1.0;
double zoom = 0.05;
int x, y, n;
for (y=0; y < ROWS; y++)
{
double c_i = view_i + y * zoom;
for (x=0; x < COLUMNS; x++)
{
double c_r = view_r + x*zoom;
double z_r = c_r;
double z_i = c_i;
for (n=0; n < MAX_ITERATIONS; n++)
{
double z_r2 = z_r * z_r;
double z_i2 = z_i * z_i;
/* Have we escaped? */
if (z_r2 + z_i2 > 4)
break;
/* z = z^2 + c */
z_i = 2 * z_r * z_i + c_i;
z_r = z_r2 - z_i2 + c_r;
}
out(n);
}
nl();
}
return 0;
}

1962
examples/startrek.c Normal file

File diff suppressed because it is too large Load Diff

105
examples/startrek.doc Normal file
View File

@@ -0,0 +1,105 @@
1. When you see _Command?_ printed, enter one of the legal commands
(nav, srs, lrs, pha, tor, she, dam, com, or xxx).
2. If you should type in an illegal command, you'll get a short list of
the legal commands printed out.
3. Some commands require you to enter data (for example, the 'nav' command
comes back with 'Course(1-9) ?'.) If you type in illegal data (like
negative numbers), that command will be aborted.
The galaxy is divided into an 8 X 8 quadrant grid, and each quadrant
is further divided into an 8 x 8 sector grid.
You will be assigned a starting point somewhere in the galaxy to begin
a tour of duty as commander of the starship _Enterprise_; your mission:
to seek out and destroy the fleet of Klingon warships which are menacing
the United Federation of Planets.
You have the following commands available to you as Captain of the Starship
Enterprise:
\nav\ Command = Warp Engine Control --
Course is in a circular numerical vector 4 3 2
arrangement as shown. Integer and real . . .
values may be used. (Thus course 1.5 is ...
half-way between 1 and 2. 5 ---*--- 1
...
Values may approach 9.0, which itself is . . .
equivalent to 1.0. 6 7 8
One warp factor is the size of one quadrant. COURSE
Therefore, to get from quadrant 6,5 to 5,5
you would use course 3, warp factor 1.
\srs\ Command = Short Range Sensor Scan
Shows you a scan of your present quadrant.
Symbology on your sensor screen is as follows:
<*> = Your starship's position
+K+ = Klingon battlecruiser
>!< = Federation starbase (Refuel/Repair/Re-Arm here)
* = Star
A condensed 'Status Report' will also be presented.
\lrs\ Command = Long Range Sensor Scan
Shows conditions in space for one quadrant on each side of the Enterprise
(which is in the middle of the scan). The scan is coded in the form \###\
where the units digit is the number of stars, the tens digit is the number
of starbases, and the hundreds digit is the number of Klingons.
Example - 207 = 2 Klingons, No Starbases, & 7 stars.
\pha\ Command = Phaser Control.
Allows you to destroy the Klingon Battle Cruisers by zapping them with
suitably large units of energy to deplete their shield power. (Remember,
Klingons have phasers, too!)
\tor\ Command = Photon Torpedo Control
Torpedo course is the same as used in warp engine control. If you hit
the Klingon vessel, he is destroyed and cannot fire back at you. If you
miss, you are subject to the phaser fire of all other Klingons in the
quadrant.
The Library-Computer (\com\ command) has an option to compute torpedo
trajectory for you (option 2).
\she\ Command = Shield Control
Defines the number of energy units to be assigned to the shields. Energy
is taken from total ship's energy. Note that the status display total
energy includes shield energy.
\dam\ Command = Damage Control report
Gives the state of repair of all devices. Where a negative 'State of Repair'
shows that the device is temporarily damaged.
\com\ Command = Library-Computer
The Library-Computer contains six options:
Option 0 = Cumulative Galactic Record
This option shows computer memory of the results of all previous
short and long range sensor scans.
Option 1 = Status Report
This option shows the number of Klingons, stardates, and starbases
remaining in the game.
Option 2 = Photon Torpedo Data
Which gives directions and distance from Enterprise to all Klingons
in your quadrant.
Option 3 = Starbase Nav Data
This option gives direction and distance to any starbase in your
quadrant.
Option 4 = Direction/Distance Calculator
This option allows you to enter coordinates for direction/distance
calculations.
Option 5 = Galactic /Region Name/ Map
This option prints the names of the sixteen major galactic regions
referred to in the game.

View File

@@ -25,7 +25,7 @@ CXXPROGRAM = "%CXXCOMPILER% %CBUILDFLAGS% %CLINKFLAGS% %CEXTRAFLAGS% -o %out% %i
CLIBRARY = "rm -f %out% && ar cr %out% %in% && ranlib %out%"
CBUILDFLAGS = {"-g"}
CBUILDFLAGS = {"-g", "-Werror", "-std=c89"}
CINCLUDES = EMPTY
CDEFINES = EMPTY
CEXTRAFLAGS = EMPTY

View File

@@ -3,7 +3,7 @@ yacc = simple {
outputs = {"%U%/%I%.c"},
command = {
"yacc -t -b %out[1]:dirname%/y -d %in%",
"byacc -t -b %out[1]:dirname%/y -d %in%",
"mv %out[1]:dirname%/y.tab.c %out[1]%"
}
}

View File

@@ -4,6 +4,9 @@
*/
/* $Id$ */
#ifndef H_CGG_CG_H
#define H_CGG_CG_H
/* offsets of interesting fields in EM-pattern */
#define PO_HASH 0
@@ -165,3 +168,5 @@ typedef struct { /* one to one coercions */
if ((a=((*(b)++)&BMASK)) >= 128) {\
a = ((a-128)<<BSHIFT) | (*(b)++&BMASK); \
}
#endif /* H_CGG_CG_H */

View File

@@ -55,10 +55,7 @@
+ (FL_MSB_AT_LOW_ADDRESS ? 1 : 0))
#ifndef USE_FLT
static int
float_cst(str, sz, buf)
char *str, *buf;
int sz;
static int float_cst(char *str, int sz, char *buf)
{
int i;
char *p;
@@ -87,10 +84,7 @@ float_cst(str, sz, buf)
#include <ctype.h>
#include <flt_arith.h>
int
float_cst(str, sz, buf)
char *str, *buf;
int sz;
int float_cst(char *str, int sz, char *buf)
{
int overflow = 0;
flt_arith e;
@@ -237,7 +231,7 @@ float_cst(str, sz, buf)
#endif /* USE_FLT */
#ifdef CODE_GENERATOR
con_float()
void con_float()
{
char buf[8];
int rval = float_cst(str, (int)argval, buf);
@@ -260,9 +254,7 @@ con_float()
#endif /* CODE_GENERATOR */
#ifdef CODE_EXPANDER
con_float(str, argval)
char *str;
arith argval;
void con_float(char *str, arith argval)
{
char buf[8];
int rval = float_cst(str, (int)argval, buf);

View File

@@ -6,6 +6,12 @@
#define LINO_AD 0
#define FILN_AD 4
/* ERANGE conflicts with a symbol in the ANSI C library. */
#ifdef ERANGE
#undef ERANGE
#endif
#define LINO (*(int *)(_hol0()+LINO_AD))
#define FILN (*(char **)(_hol0()+FILN_AD))

29
h/missing_proto.h Normal file
View File

@@ -0,0 +1,29 @@
#ifndef H_MISSING_PROTO_H
#define H_MISSING_PROTO_H
#ifdef NOSBRK
void *sbrk(__intptr_t increment);
void *brk(void * addr);
#endif
#ifdef NOMKTEMP
char *mktemp(char *template);
#endif
#ifdef EMULATE_BRK
void *sbrk_emu(int increment);
void *brk_emu(const void * addr);
#ifdef sbrk
#undef sbrk
#endif
#ifdef brk
#undef brk
#endif
#define sbrk sbrk_emu
#define brk brk_emu
#endif
#endif /* H_MISSING_H */

View File

@@ -3,6 +3,13 @@
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* EBADF conflicts with the ANSI C definition. */
#ifdef EBADF
#undef EBADF
#endif
#define EARGC 64
#define EEXP 65
#define ELOG 66

15
h/symbol2str.h Normal file
View File

@@ -0,0 +1,15 @@
/*
* The Amsterdam Compiler Kit
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef H_SYMBOL2STR_H
#define H_SYMBOL2STR_H
/* A lot of component use a version of this function, there is currently no header file
* that contain it, and all use the same prototype as they are all generated from the same
* generator.
*/
char *symbol2str(int tok);
#endif

View File

@@ -1,79 +0,0 @@
/* $Id$ */
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/*
* Basic system types and major/minor device constructing/busting macros.
*/
#if !defined(_SYS_TYPES_H)
#define _SYS_TYPES_H
#ifdef __STDC__
#if !defined(_SIZE_T)
#define _SIZE_T
typedef unsigned int size_t; /* type returned by sizeof */
#endif /* _SIZE_T */
#if !defined(_TIME_T)
#define _TIME_T
typedef unsigned long time_t;
#endif /* TIME_T */
#endif
#if !defined(_POSIX_SOURCE)
/* major part of a device */
#define major(x) ((int)(((unsigned)(x)>>8)&0377))
/* minor part of a device */
#define minor(x) ((int)((x)&0377))
/* make a device number */
#define makedev(x,y) ((dev_t)(((x)<<8) | (y)))
typedef unsigned char u_char;
typedef unsigned short u_short;
typedef unsigned int u_int;
typedef unsigned long u_long;
typedef struct _physadr { int r[1]; } *physadr;
typedef long daddr_t;
typedef char * caddr_t;
#if defined(__BSD4_2)
typedef u_long ino_t;
#else
typedef u_short ino_t;
#endif
typedef long swblk_t;
#include <sys/stdtypes.h>
typedef long label_t[14];
typedef short dev_t;
typedef long off_t;
/* system V compatibility: */
typedef unsigned int uint;
typedef unsigned short ushort;
typedef unsigned char uchar_t;
typedef short cnt_t;
typedef long paddr_t;
typedef long key_t;
#else /* _POSIX_SOURCE */
#if defined(_MINIX)
typedef unsigned short dev_t; /* hold (major|minor) device pair */
typedef unsigned char gid_t; /* group id */
typedef unsigned short ino_t; /* i-node number */
typedef unsigned short mode_t; /* mode number within an i-node */
typedef unsigned char nlink_t; /* number-of-links field within an i-node */
typedef long off_t; /* offsets within a file */
typedef int pid_t; /* type for pids (must be signed) */
typedef unsigned short uid_t; /* user id */
#endif /* _MINIX */
#endif /* _POSIX_SOURCE */
#endif /* _SYS_TYPES_H */

View File

@@ -1,79 +0,0 @@
/* $Id$ */
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/*
* Basic system types and major/minor device constructing/busting macros.
*/
#if !defined(_SYS_TYPES_H)
#define _SYS_TYPES_H
#ifdef __STDC__
#if !defined(_SIZE_T)
#define _SIZE_T
typedef unsigned int size_t; /* type returned by sizeof */
#endif /* _SIZE_T */
#if !defined(_TIME_T)
#define _TIME_T
typedef unsigned long time_t;
#endif /* TIME_T */
#endif
#if !defined(_POSIX_SOURCE)
/* major part of a device */
#define major(x) ((int)(((unsigned)(x)>>8)&0377))
/* minor part of a device */
#define minor(x) ((int)((x)&0377))
/* make a device number */
#define makedev(x,y) ((dev_t)(((x)<<8) | (y)))
typedef unsigned char u_char;
typedef unsigned short u_short;
typedef unsigned int u_int;
typedef unsigned long u_long;
typedef struct _physadr { int r[1]; } *physadr;
typedef long daddr_t;
typedef char * caddr_t;
#if defined(__BSD4_2)
typedef u_long ino_t;
#else
typedef u_short ino_t;
#endif
typedef long swblk_t;
#include <sys/stdtypes.h>
typedef long label_t[14];
typedef short dev_t;
typedef long off_t;
/* system V compatibility: */
typedef unsigned int uint;
typedef unsigned short ushort;
typedef unsigned char uchar_t;
typedef short cnt_t;
typedef long paddr_t;
typedef long key_t;
#else /* _POSIX_SOURCE */
#if defined(_MINIX)
typedef unsigned short dev_t; /* hold (major|minor) device pair */
typedef unsigned char gid_t; /* group id */
typedef unsigned short ino_t; /* i-node number */
typedef unsigned short mode_t; /* mode number within an i-node */
typedef unsigned char nlink_t; /* number-of-links field within an i-node */
typedef long off_t; /* offsets within a file */
typedef int pid_t; /* type for pids (must be signed) */
typedef unsigned short uid_t; /* user id */
#endif /* _MINIX */
#endif /* _POSIX_SOURCE */
#endif /* _SYS_TYPES_H */

View File

@@ -41,5 +41,5 @@ lang_basic_runtime = acklibrary {
ackfile (d.."trap.c"),
ackfile (d.."write.c"),
install = pm.install("%BINDIR%%PLATIND%/%PLATFORM%/tail_bc")
install = pm.install("%BINDIR%%PLATIND%/%PLATFORM%/libbasic.a")
}

View File

@@ -2,5 +2,5 @@ pmfile
cemcom.ansi
cpp.ansi
libcc.ansi
cemcom
libcc
#cemcom
#libcc

View File

@@ -1,5 +1,5 @@
!File: lint.h
/*#define LINT 1 /* if defined, 'lint' is produced */
/*#define LINT 1*/ /* if defined, 'lint' is produced */
!File: pathlength.h
@@ -75,7 +75,7 @@
!File: botch_free.h
/*#define BOTCH_FREE 1 /* when defined, botch freed memory, as a check */
/*#define BOTCH_FREE 1*/ /* when defined, botch freed memory, as a check */
!File: dataflow.h
@@ -83,7 +83,7 @@
!File: debug.h
/*#define DEBUG 1 /* perform various self-tests */
/*#define DEBUG 1*/ /* perform various self-tests */
#define NDEBUG 1 /* disable assertions */
@@ -112,17 +112,17 @@
!File: nopp.h
/*#define NOPP 1 /* if NOT defined, use built-int preprocessor */
/*#define NOPP 1*/ /* if NOT defined, use built-int preprocessor */
!File: nobitfield.h
/*#define NOBITFIELD 1 /* if NOT defined, implement bitfields */
/*#define NOBITFIELD 1*/ /* if NOT defined, implement bitfields */
!File: spec_arith.h
/* describes internal compiler arithmetics */
#undef SPECIAL_ARITHMETICS /* something different from native long */
/*#define UNSIGNED_ARITH unsigned arith /* if it is supported */
/*#define UNSIGNED_ARITH unsigned arith*/ /* if it is supported */
!File: static.h
@@ -130,11 +130,11 @@
!File: nocross.h
/*#define NOCROSS 1 /* if NOT defined, cross compiler */
/*#define NOCROSS 1*/ /* if NOT defined, cross compiler */
!File: regcount.h
/*#define REGCOUNT 1 /* count occurrences for register messages */
/*#define REGCOUNT 1*/ /* count occurrences for register messages */
!File: dbsymtab.h

View File

@@ -22,6 +22,9 @@
#include "class.h"
#include "assert.h"
#include "sizes.h"
#include "error.h"
#include "domacro.h"
#include "replace_loc.h"
#include "specials.h" /* registration of special identifiers */
/* Data about the token yielded */
@@ -62,7 +65,7 @@ static LexSP = 0;
E.g. at the invocation of a sub-parser that uses LLlex(), the
state of the current parser should be saved.
*/
PushLex()
void PushLex()
{
ASSERT(LexSP < MAX_LL_DEPTH);
ASSERT(ASIDE == 0); /* ASIDE = 0; */
@@ -70,15 +73,14 @@ PushLex()
LexStack[LexSP++] = dot;
}
PopLex()
void PopLex()
{
ASSERT(LexSP > 0);
dot = LexStack[--LexSP];
}
#endif /* NOPP */
int
LLlex()
int LLlex()
{
/* LLlex() plays the role of Lexical Analyzer for the C parser.
The look-ahead and putting aside of tokens are taken into
@@ -108,12 +110,13 @@ LLlex()
}
char *string_token();
arith char_constant();
char *string_token(char *nm, int stop_char, int *plen);
arith char_constant(char *nm);
void skipcomment();
void strint2tok(char intbuf[], struct token *ptok);
void strflt2tok(char fltbuf[], struct token *ptok);
int
GetToken(ptok)
register struct token *ptok;
int GetToken(struct token *ptok)
{
/* GetToken() is the actual token recognizer. It calls the
control line interpreter if it encounters a "\n{w}*#"
@@ -121,7 +124,7 @@ GetToken(ptok)
needed.
*/
char buf[(IDFSIZE > NUMSIZE ? IDFSIZE : NUMSIZE) + 1];
register int ch, nch;
int ch, nch;
token_nmb++;
@@ -227,8 +230,7 @@ garbage:
case '<':
if (AccFileSpecifier) {
UnGetChar(); /* pushback nch */
ptok->tk_bts = string_token("file specifier",
'>', &(ptok->tk_len));
ptok->tk_bts = string_token("file specifier", '>', &(ptok->tk_len));
return ptok->tk_symb = FILESPECIFIER;
}
if (nch == '<') {
@@ -312,10 +314,10 @@ garbage:
/* fallthrough */
case STIDF:
{
register char *tg = &buf[0];
register int pos = -1;
register struct idf *idef;
extern int idfsize; /* ??? */
char *tg = &buf[0];
int pos = -1;
struct idf *idef;
extern int idfsize;
#ifndef NOPP
int NoExpandNext = 0;
@@ -361,8 +363,8 @@ garbage:
}
case STNUM: /* a numeric constant */
{
register int siz_left = NUMSIZE - 1;
register char *np = &buf[0];
int siz_left = NUMSIZE - 1;
char *np = &buf[0];
int flags = 0;
#define store(ch) if (--siz_left >= 0) \
@@ -444,10 +446,11 @@ garbage:
crash("bad class for char 0%o", ch);
}
/*NOTREACHED*/
return 0;
}
#ifndef NOPP
skipcomment()
void skipcomment()
{
/* The last character read has been the '*' of '/_*'. The
characters, except NL and EOI, between '/_*' and the first
@@ -459,7 +462,7 @@ skipcomment()
EOI is returned by LoadChar only on encountering EOF of the
top-level file...
*/
register int c, oldc = '\0';
int c, oldc = '\0';
NoUnstack++;
c = GetChar();
@@ -501,12 +504,10 @@ skipcomment()
}
#endif /* NOPP */
arith
char_constant(nm)
char *nm;
arith char_constant(char *nm)
{
register arith val = 0;
register int ch;
arith val = 0;
int ch;
int size = 0;
ch = GetChar();
@@ -534,15 +535,12 @@ char_constant(nm)
return val;
}
char *
string_token(nm, stop_char, plen)
char *nm;
int *plen;
char *string_token(char *nm, int stop_char, int *plen)
{
register int ch;
register int str_size;
register char *str = Malloc((unsigned) (str_size = ISTRSIZE));
register int pos = 0;
int ch;
int str_size;
char *str = Malloc((unsigned) (str_size = ISTRSIZE));
int pos = 0;
ch = GetChar();
while (ch != stop_char) {
@@ -567,9 +565,7 @@ string_token(nm, stop_char, plen)
return str;
}
int
quoted(ch)
register int ch;
int quoted(int ch)
{
/* quoted() replaces an escaped character sequence by the
character meant.
@@ -628,9 +624,7 @@ quoted(ch)
}
int
hex_val(ch)
register int ch;
int hex_val(int ch)
{
return is_dig(ch) ? ch - '0'
: is_hex(ch) ? (ch - 'a' + 10) & 017
@@ -638,13 +632,12 @@ hex_val(ch)
}
int
GetChar()
int GetChar()
{
/* The routines GetChar and trigraph parses the trigraph
sequences and removes occurences of \\\n.
*/
register int ch;
int ch;
#ifndef NOPP
again:
@@ -671,10 +664,9 @@ again:
}
#ifndef NOPP
int
trigraph()
int trigraph()
{
register int ch;
int ch;
LoadChar(ch);
if (ch == '?') {
@@ -718,24 +710,22 @@ trigraph()
/* strflt2tok only checks the syntax of the floating-point number and
* selects the right type for the number.
*/
strflt2tok(fltbuf, ptok)
char fltbuf[];
struct token *ptok;
void strflt2tok(char fltbuf[], struct token *ptok)
{
register char *cp = fltbuf;
char *cp = fltbuf;
int malformed = 0;
while (is_dig(*cp)) cp++;
while (is_dig(*(unsigned char *)cp)) cp++;
if (*cp == '.') {
cp++;
while (is_dig(*cp)) cp++;
while (is_dig(*(unsigned char *)cp)) cp++;
}
if (*cp == 'e' || *cp == 'E') {
cp++;
if (*cp == '+' || *cp == '-')
cp++;
if (!is_dig(*cp)) malformed++;
while (is_dig(*cp)) cp++;
if (!is_dig(*(unsigned char *)cp)) malformed++;
while (is_dig(*(unsigned char *)cp)) cp++;
}
if (*cp == 'f' || *cp == 'F') {
if (*(cp + 1)) malformed++;
@@ -757,11 +747,9 @@ struct token *ptok;
}
}
strint2tok(intbuf, ptok)
char intbuf[];
struct token *ptok;
void strint2tok(char intbuf[], struct token *ptok)
{
register char *cp = intbuf;
char *cp = intbuf;
int base = 10;
arith val = 0, dig, ubound;
int uns_flg = 0, lng_flg = 0, malformed = 0, ovfl = 0;
@@ -781,8 +769,8 @@ struct token *ptok;
*/
ubound = max_arith / (base / 2);
while (is_hex(*cp)) {
dig = hex_val(*cp);
while (is_hex(*(unsigned char *)cp)) {
dig = hex_val(*(unsigned char *)cp);
if (dig >= base) {
malformed++; /* ignore */
}

View File

@@ -1,3 +1,5 @@
#ifndef LANG_CEM_CEMCOM_ANSI_LLLEX_H
#define LANG_CEM_CEMCOM_ANSI_LLLEX_H
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
@@ -63,3 +65,21 @@ extern int err_occurred; /* "error.c" */
#define ASIDE aside.tk_symb
#define EOF (-1)
/* lang/cem/cemcom.ansi/LLlex.c */
void PushLex(void);
void PopLex(void);
int LLlex(void);
int GetToken(struct token *ptok);
void skipcomment(void);
arith char_constant(char *nm);
char *string_token(char *nm, int stop_char, int *plen);
int quoted(int ch);
int hex_val(int ch);
int GetChar(void);
int trigraph(void);
void strflt2tok(char fltbuf[], struct token *ptok);
void strint2tok(char intbuf[], struct token *ptok);
#endif /* LANG_CEM_CEMCOM_ANSI_LLLEX_H */

View File

@@ -10,10 +10,14 @@
#include "arith.h"
#include "LLlex.h"
#include "Lpars.h"
#include "error.h"
extern char *symbol2str();
#include <symbol2str.h>
LLmessage(tk) {
void insert_token(int tk);
void LLmessage(tk)
{
err_occurred = 1;
if (tk < 0) {
error("end of file expected");
@@ -34,8 +38,7 @@ LLmessage(tk) {
tk_nmb_at_last_syn_err = token_nmb;
}
insert_token(tk)
int tk;
void insert_token(int tk)
{
aside = dot;

View File

@@ -1,5 +1,5 @@
!File: lint.h
/*#define LINT 1 /* if defined, 'lint' is produced */
/*#define LINT 1*/ /* if defined, 'lint' is produced */
!File: pathlength.h
@@ -75,24 +75,24 @@
!File: botch_free.h
/*#define BOTCH_FREE 1 /* when defined, botch freed memory, as a check */
/*#define BOTCH_FREE 1*/ /* when defined, botch freed memory, as a check */
!File: dataflow.h
/*#define DATAFLOW 1 /* produce some compile-time xref */
/*#define DATAFLOW 1*/ /* produce some compile-time xref */
!File: debug.h
/*#define DEBUG 1 /* perform various self-tests */
/*#define DEBUG 1*/ /* perform various self-tests */
#define NDEBUG 1 /* disable assertions */
!File: use_tmp.h
/*#define PREPEND_SCOPES 1 /* collect exa, exp, ina and inp commands
/*#define PREPEND_SCOPES 1*/ /* collect exa, exp, ina and inp commands
and if USE_TMP is defined let them
precede the rest of the generated
compact code */
/*#define USE_TMP 1 /* use C_insertpart, C_endpart mechanism
/*#define USE_TMP 1*/ /* use C_insertpart, C_endpart mechanism
to generate EM-code in the order needed
for the code-generators. If not defined,
the old-style peephole optimizer is
@@ -108,7 +108,7 @@
!File: inputtype.h
/*#define INP_READ_IN_ONE 1 /* read input file in one */
/*#define INP_READ_IN_ONE 1*/ /* read input file in one */
!File: nopp.h
@@ -116,13 +116,13 @@
!File: nobitfield.h
/*#define NOBITFIELD 1 /* if NOT defined, implement bitfields */
/*#define NOBITFIELD 1*/ /* if NOT defined, implement bitfields */
!File: spec_arith.h
/* describes internal compiler arithmetics */
#undef SPECIAL_ARITHMETICS /* something different from native long */
/*#define UNSIGNED_ARITH unsigned arith /* if it is supported */
/*#define UNSIGNED_ARITH unsigned arith*/ /* if it is supported */
!File: static.h
@@ -130,14 +130,14 @@
!File: nocross.h
/*#define NOCROSS 1 /* if NOT defined, cross compiler */
/*#define NOCROSS 1*/ /* if NOT defined, cross compiler */
!File: regcount.h
/*#define REGCOUNT 1 /* count occurrences for register messages */
/*#define REGCOUNT 1*/ /* count occurrences for register messages */
!File: dbsymtab.h
/*#define DBSYMTAB 1 /* ability to produce symbol table for debugger */
/*#define DBSYMTAB 1*/ /* ability to produce symbol table for debugger */

View File

@@ -27,15 +27,19 @@
#include "field.h"
#include "mes.h"
#include "assert.h"
#include "ch3.h"
#include "ch3bin.h"
#include "code_c.h"
#include "conversion.h"
#include "cstoper.h"
#include "expr_loc.h"
#include "error.h"
#include <symbol2str.h>
extern char *symbol2str();
extern char options[];
extern arith flt_flt2arith();
extern label code_string();
arithbalance(e1p, oper, e2p) /* 3.1.2.5 */
register struct expr **e1p, **e2p;
int oper;
void arithbalance(struct expr **e1p, int oper, struct expr **e2p) /* 3.1.2.5 */
{
/* The expressions *e1p and *e2p are balanced to be operands
of the arithmetic operator oper.
@@ -44,16 +48,16 @@ arithbalance(e1p, oper, e2p) /* 3.1.2.5 */
have a floating type, in which case the flags shouldn't
travel upward in the expression tree.
*/
register int t1, t2, u1, u2;
int t1, t2, u1, u2;
int shifting = (oper == LEFT || oper == RIGHT
|| oper == LEFTAB || oper == RIGHTAB);
|| oper == LEFTAB || oper == RIGHTAB);
int ptrdiff = 0;
t1 = any2arith(e1p, oper);
t2 = any2arith(e2p, oper);
if (int_size != pointer_size) {
if (ptrdiff = ((*e1p)->ex_flags & EX_PTRDIFF)
if ((ptrdiff = ((*e1p)->ex_flags & EX_PTRDIFF))
|| ((*e2p)->ex_flags & EX_PTRDIFF)) {
if (!((*e1p)->ex_flags & EX_PTRDIFF) && t1 == LONG)
ptrdiff = 0;
@@ -82,10 +86,16 @@ arithbalance(e1p, oper, e2p) /* 3.1.2.5 */
return;
} else if (t2 == LNGDBL) {
if (t1 != LNGDBL)
if (t1 == DOUBLE || t1 == FLOAT)
float2float(e1p, lngdbl_type);
else
int2float(e1p, lngdbl_type);
{
if (t1 == DOUBLE || t1 == FLOAT)
{
float2float(e1p, lngdbl_type);
}
else
{
int2float(e1p, lngdbl_type);
}
}
return;
}
@@ -173,8 +183,7 @@ arithbalance(e1p, oper, e2p) /* 3.1.2.5 */
}
}
relbalance(e1p, oper, e2p)
register struct expr **e1p, **e2p;
void relbalance(struct expr **e1p, int oper, struct expr **e2p)
{
/* The expressions *e1p and *e2p are balanced to be operands
of the relational operator oper, or the ':'.
@@ -183,7 +192,7 @@ relbalance(e1p, oper, e2p)
allows assignments of a null-pointer to a function
pointer.
*/
register struct expr *e1 = *e1p, *e2 = *e2p;
struct expr *e1 = *e1p, *e2 = *e2p;
struct expr *tmpexpr;
if (e1->ex_type->tp_fund == POINTER
@@ -206,15 +215,13 @@ relbalance(e1p, oper, e2p)
arithbalance(e1p, oper, e2p);
}
ch3pointer(expp, oper, tp)
struct expr **expp;
register struct type *tp;
void ch3pointer(struct expr **expp, int oper, struct type *tp)
{
/* Checks whether *expp may be compared to tp using oper,
as described in chapter 3.3.8 and 3.3.9.
tp is known to be a pointer.
*/
register struct expr *exp = *expp;
struct expr *exp = *expp;
if (exp->ex_type->tp_fund == POINTER) {
if (exp->ex_type != tp)
@@ -239,10 +246,7 @@ ch3pointer(expp, oper, tp)
}
}
int
any2arith(expp, oper)
register struct expr **expp;
register int oper;
int any2arith(struct expr **expp, int oper)
{
/* Turns any expression into int_type, long_type,
float_type, double_type or lngdbl_type.
@@ -297,8 +301,7 @@ any2arith(expp, oper)
return (*expp)->ex_type->tp_fund;
}
erroneous2int(expp)
struct expr **expp;
void erroneous2int(struct expr **expp)
{
/* the (erroneous) expression *expp is replaced by an
int expression
@@ -312,16 +315,12 @@ erroneous2int(expp)
*expp = exp;
}
struct expr *
arith2arith(tp, oper, expr)
struct type *tp;
int oper;
register struct expr *expr;
struct expr *arith2arith(struct type *tp, int oper, struct expr *expr)
{
/* arith2arith constructs a new expression containing a
run-time conversion between some arithmetic types.
*/
register struct expr *new = new_expr();
struct expr *new = new_expr();
new->ex_file = expr->ex_file;
new->ex_line = expr->ex_line;
@@ -330,18 +329,15 @@ arith2arith(tp, oper, expr)
return new_oper(tp, new, oper, expr);
}
int
int2int(expp, tp)
struct expr **expp;
register struct type *tp;
int int2int(struct expr **expp, struct type *tp)
{
/* The expression *expp, which is of some integral type, is
converted to the integral type tp.
*/
register struct expr *exp = *expp;
struct expr *exp = *expp;
if (is_cp_cst(exp)) {
register struct type *tp1 = exp->ex_type;
struct type *tp1 = exp->ex_type;
exp->ex_type = tp;
if (! tp1->tp_unsigned && tp->tp_unsigned) {
@@ -371,14 +367,12 @@ int2int(expp, tp)
/* With compile-time constants, we don't set fp_used, since this is done
* only when necessary in eval.c.
*/
int2float(expp, tp)
register struct expr **expp;
struct type *tp;
void int2float(struct expr **expp, struct type *tp)
{
/* The expression *expp, which is of some integral type, is
converted to the floating type tp.
*/
register struct expr *exp = *expp;
struct expr *exp = *expp;
int uns = exp->ex_type->tp_unsigned;
if (is_cp_cst(exp)) {
@@ -392,14 +386,12 @@ int2float(expp, tp)
}
}
float2int(expp, tp)
struct expr **expp;
struct type *tp;
void float2int(struct expr **expp, struct type *tp)
{
/* The expression *expp, which is of some floating type, is
converted to the integral type tp.
*/
register struct expr *ex = *expp;
struct expr *ex = *expp;
if (is_fp_cst(ex)) {
arith ar = flt_flt2arith(&ex->FL_ARITH, tp->tp_unsigned);
@@ -420,9 +412,7 @@ float2int(expp, tp)
}
}
float2float(expp, tp)
register struct expr **expp;
struct type *tp;
void float2float(struct expr**expp, struct type *tp)
{
/* The expression *expp, which is of some floating type, is
converted to the floating type tp.
@@ -438,8 +428,7 @@ float2float(expp, tp)
}
}
array2pointer(exp)
register struct expr *exp;
void array2pointer(struct expr *exp)
{
/* The expression, which must be an array, is converted
to a pointer.
@@ -449,8 +438,7 @@ array2pointer(exp)
, (arith)0, NO_PROTO);
}
function2pointer(exp)
register struct expr *exp;
void function2pointer(struct expr *exp)
{
/* The expression, which must be a function, is converted
to a pointer to the function.
@@ -459,8 +447,7 @@ function2pointer(exp)
(arith)0, NO_PROTO);
}
string2pointer(ex)
register struct expr *ex;
void string2pointer(struct expr *ex)
{
/* The expression, which must be a string constant, is converted
to a pointer to the string-containing area.
@@ -474,11 +461,9 @@ string2pointer(ex)
ex->VL_VALUE = (arith)0;
}
opnd2integral(expp, oper)
register struct expr **expp;
int oper;
void opnd2integral(struct expr **expp, int oper)
{
register int fund = (*expp)->ex_type->tp_fund;
int fund = (*expp)->ex_type->tp_fund;
if (fund != INT && fund != LONG) {
expr_error(*expp, "%s operand to %s",
@@ -488,9 +473,7 @@ opnd2integral(expp, oper)
}
}
opnd2logical(expp, oper)
register struct expr **expp;
int oper;
void opnd2logical(struct expr **expp, int oper)
{
int fund = (*expp)->ex_type->tp_fund;
@@ -526,8 +509,7 @@ opnd2logical(expp, oper)
}
}
opnd2test(expp, oper)
register struct expr **expp;
void opnd2test(struct expr **expp, int oper)
{
opnd2logical(expp, oper);
if ((*expp)->ex_class == Oper) {
@@ -551,8 +533,7 @@ opnd2test(expp, oper)
ch3bin(expp, NOTEQUAL, intexpr((arith)0, INT));
}
any2opnd(expp, oper)
register struct expr **expp;
void any2opnd(struct expr **expp, int oper)
{
if (!*expp)
return;
@@ -563,7 +544,9 @@ any2opnd(expp, oper)
case CHAR:
case SHORT:
case ENUM:
/* case FLOAT: /* not necessary anymore */
#if 0
case FLOAT: /* not necessary anymore */
#endif
any2arith(expp, oper);
break;
case ARRAY:
@@ -584,8 +567,7 @@ any2opnd(expp, oper)
}
}
any2parameter(expp)
register struct expr **expp;
void any2parameter(struct expr **expp)
{
/* To handle default argument promotions
*/
@@ -598,14 +580,13 @@ any2parameter(expp)
}
#ifndef NOBITFIELD
field2arith(expp)
register struct expr **expp;
void field2arith(struct expr **expp)
{
/* The expression to extract the bitfield value from the
memory word is put in the tree.
*/
register struct type *tp = (*expp)->ex_type->tp_up;
register struct field *fd = (*expp)->ex_type->tp_field;
struct type *tp = (*expp)->ex_type->tp_up;
struct field *fd = (*expp)->ex_type->tp_field;
(*expp)->ex_type = word_type;
@@ -630,8 +611,7 @@ field2arith(expp)
/* switch_sign_fp() negates the given floating constant expression,
* and frees the string representing the old value.
*/
switch_sign_fp(expr)
register struct expr *expr;
void switch_sign_fp(struct expr *expr)
{
flt_umin(&(expr->FL_ARITH));
}

View File

@@ -1,3 +1,5 @@
#ifndef LANG_CEM_CEMCOM_ANSI_ARITH_H
#define LANG_CEM_CEMCOM_ANSI_ARITH_H
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
@@ -23,10 +25,40 @@
/* All preprocessor arithmetic should be done in longs.
*/
#define arith long /* dummy */
#include <stdint.h>
typedef int32_t arith; /* dummy */
#endif /* SPECIAL_ARITHMETICS */
#define arith_size (sizeof(arith))
#define arith_sign ((arith) 1 << (arith_size * 8 - 1))
#define max_arith (~arith_sign)
struct expr;
struct type;
/* lang/cem/cemcom.ansi/arith.c */
void arithbalance(struct expr **e1p, int oper, struct expr **e2p);
void relbalance(struct expr **e1p, int oper, struct expr **e2p);
void ch3pointer(struct expr **expp, int oper, struct type *tp);
int any2arith(struct expr **expp, int oper);
void erroneous2int(struct expr **expp);
struct expr *arith2arith(struct type *tp, int oper, struct expr *expr);
int int2int(struct expr **expp, struct type *tp);
void int2float(struct expr **expp, struct type *tp);
void float2int(struct expr **expp, struct type *tp);
void float2float(struct expr **expp, struct type *tp);
void array2pointer(struct expr *exp);
void function2pointer(struct expr *exp);
void string2pointer(struct expr *ex);
void opnd2integral(struct expr **expp, int oper);
void opnd2logical(struct expr **expp, int oper);
void opnd2test(struct expr **expp, int oper);
void any2opnd(struct expr **expp, int oper);
void any2parameter(struct expr **expp);
void field2arith(struct expr **expp);
void switch_sign_fp(struct expr *expr);
#endif /* LANG_CEM_CEMCOM_ANSI_ARITH_H */

View File

@@ -18,9 +18,16 @@
#include "label.h"
#include "stack.h"
#include "Lpars.h"
extern arith NewLocal();
#include "util_loc.h"
#include "error.h"
#include "idf_loc.h"
#include "def.h"
#define LocalPtrVar() NewLocal(pointer_size, pointer_align, reg_pointer, REGISTER)
#define LocalIntVar() NewLocal(int_size, int_align, reg_any, REGISTER)
static void copy_loop(arith sz, arith src, arith dst);
#endif /* STB */
/* Because EM does not support the loading and storing of
@@ -52,9 +59,7 @@ extern arith NewLocal();
while we need a loop to store the stack block into a memory object.
*/
suitable_sz(sz, al)
arith sz;
int al;
static int suitable_sz(arith sz, int al)
{
return ((int)sz % (int)word_size == 0 && al % word_align == 0) ||
(
@@ -64,9 +69,7 @@ suitable_sz(sz, al)
);
}
store_block(sz, al)
arith sz;
int al;
void store_block(arith sz, int al)
{
if (suitable_sz(sz, al))
C_sti(sz);
@@ -102,9 +105,7 @@ store_block(sz, al)
}
}
load_block(sz, al)
arith sz;
int al;
void load_block(arith sz, int al)
{
if (suitable_sz(sz, al))
@@ -138,9 +139,7 @@ load_block(sz, al)
}
}
copy_block(sz, al)
arith sz;
int al;
void copy_block(arith sz, int al)
{
if (suitable_sz(sz, al))
@@ -167,8 +166,7 @@ copy_block(sz, al)
}
#ifndef STB
copy_loop(sz, src, dst)
arith sz, src, dst;
static void copy_loop(arith sz, arith src, arith dst)
{
/* generate inline byte-copy loop */
label l_cont = text_label(), l_stop = text_label();

View File

@@ -0,0 +1,8 @@
#ifndef LANG_CEM_CEMCOM_ANSI_BLOCKS_H
#define LANG_CEM_CEMCOM_ANSI_BLOCKS_H
void store_block(arith sz, int al);
void load_block(arith sz, int al);
void copy_block(arith sz, int al);
#endif

View File

@@ -20,26 +20,35 @@
#include "Lpars.h"
#include "assert.h"
#include "file_info.h"
#include "ch3.h"
#include "ch3bin.h"
#include "decspecs.h"
#include "conversion.h"
#include "error.h"
#include "idf_loc.h"
#include "expr_loc.h"
#include <symbol2str.h>
extern char options[];
extern char *symbol2str();
extern struct type *qualifier_type();
static int check_pseudoproto(struct proto *pl, struct proto *opl, int diag);
static int legal_mixture(struct type *tp, struct type *otp, int diag);
static int equal_proto(struct proto *pl, struct proto *opl, int diag);
static int is_arith_type(struct type *tp);
/* Most expression-handling routines have a pointer to a
(struct type *) as first parameter. The object under the pointer
gets updated in the process.
*/
ch3sel(expp, oper, idf)
struct expr **expp;
struct idf *idf;
void ch3sel(struct expr **expp, int oper, struct idf *idf)
{
/* The selector idf is applied to *expp; oper may be '.' or
ARROW.
*/
register struct expr *exp;
register struct type *tp;
register struct sdef *sd;
struct expr *exp;
struct type *tp;
struct sdef *sd;
any2opnd(expp, oper);
exp = *expp;
@@ -162,8 +171,7 @@ ch3sel(expp, oper, idf)
*expp = exp;
}
ch3incr(expp, oper)
struct expr **expp;
void ch3incr(struct expr **expp, int oper)
{
/* The monadic prefix/postfix incr/decr operator oper is
applied to *expp.
@@ -171,17 +179,15 @@ ch3incr(expp, oper)
ch3asgn(expp, oper, intexpr((arith)1, INT));
}
ch3cast(expp, oper, tp)
register struct expr **expp;
register struct type *tp;
void ch3cast(struct expr **expp, int oper, struct type *tp)
{
/* The expression *expp is cast to type tp; the cast is
caused by the operator oper. If the cast has
to be passed on to run time, its left operand will be an
expression of class Type.
*/
register struct type *oldtp;
register struct expr *exp = *expp;
struct type *oldtp;
struct expr *exp = *expp;
int qual_lev, ascompat = 0;
if (oper == RETURN && tp->tp_fund == VOID) {
@@ -410,9 +416,7 @@ ch3cast(expp, oper, tp)
/* Determine whether two types are equal.
*/
equal_type(tp, otp, qual_lev, diag)
register struct type *tp, *otp;
int qual_lev, diag;
int equal_type(struct type *tp, struct type *otp, int qual_lev, int diag)
{
if (tp == otp)
return 1;
@@ -473,8 +477,7 @@ equal_type(tp, otp, qual_lev, diag)
}
}
check_pseudoproto(pl, opl, diag)
register struct proto *pl, *opl;
static int check_pseudoproto(struct proto *pl, struct proto *opl, int diag)
{
int retval = 1;
@@ -517,13 +520,11 @@ check_pseudoproto(pl, opl, diag)
return retval;
}
legal_mixture(tp, otp, diag)
struct type *tp, *otp;
int diag;
static int legal_mixture(struct type *tp, struct type *otp, int diag)
{
struct proto *pl = tp->tp_proto, *opl = otp->tp_proto;
int retval = 1;
register struct proto *prot;
struct proto *prot;
int fund;
ASSERT( (pl != 0) ^ (opl != 0));
@@ -560,9 +561,7 @@ legal_mixture(tp, otp, diag)
return retval;
}
equal_proto(pl, opl, diag)
register struct proto *pl, *opl;
int diag;
static int equal_proto(struct proto *pl, struct proto *opl, int diag)
{
if (pl == opl)
return 1;
@@ -584,11 +583,9 @@ equal_proto(pl, opl, diag)
}
/* check if a type has a consqualified member */
recurqual(tp, qual)
struct type *tp;
int qual;
int recurqual(struct type *tp, int qual)
{
register struct sdef *sdf;
struct sdef *sdf;
ASSERT(tp);
@@ -608,9 +605,7 @@ int qual;
return 0;
}
ch3asgn(expp, oper, expr)
struct expr **expp;
struct expr *expr;
void ch3asgn(struct expr **expp, int oper, struct expr *expr)
{
/* The assignment operators.
"f op= e" should be interpreted as
@@ -625,7 +620,7 @@ ch3asgn(expp, oper, expr)
f (typeof (f op e))e
EVAL should however take care of evaluating (typeof (f op e))f
*/
register struct expr *exp = *expp;
struct expr *exp = *expp;
int fund = exp->ex_type->tp_fund;
struct type *tp;
char *oper_string = symbol2str(oper);
@@ -685,9 +680,7 @@ ch3asgn(expp, oper, expr)
/* Some interesting (?) questions answered.
*/
int
is_integral_type(tp)
register struct type *tp;
int is_integral_type(struct type *tp)
{
switch (tp->tp_fund) {
case CHAR:
@@ -705,9 +698,7 @@ is_integral_type(tp)
}
}
int
is_arith_type(tp)
register struct type *tp;
static int is_arith_type(struct type *tp)
{
switch (tp->tp_fund) {
case CHAR:

View File

@@ -0,0 +1,17 @@
/*
* The Amsterdam Compiler Kit
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef LANG_CEM_CEMCOM_ANSI_CH3_H
#define LANG_CEM_CEMCOM_ANSI_CH3_H
void ch3cast(struct expr **expp, int oper, struct type *tp);
void ch3sel(struct expr **expp, int oper, struct idf *idf);
void ch3incr(struct expr **expp, int oper);
int equal_type(struct type *tp, struct type *otp, int qual_lev, int diag);
int recurqual(struct type *tp, int qual);
void ch3asgn(struct expr **expp, int oper, struct expr *expr);
int is_integral_type(struct type *tp);
#endif

View File

@@ -18,9 +18,24 @@
#include "expr.h"
#include "Lpars.h"
#include "sizes.h"
#include "ch3.h"
#include "ch3bin.h"
#include "ch3mon.h"
#include "cstoper.h"
#include "error.h"
#include "expr_loc.h"
#include "struct_loc.h"
#include "fltcstoper.h"
#include <symbol2str.h>
extern char options[];
extern char *symbol2str();
static void pntminuspnt(struct expr **expp, int oper, struct expr *expr);
static int arg_switched(int oper);
static void mk_binop(struct expr **expp, int oper, struct expr *expr, int commutative);
static void pointer_arithmetic(struct expr **expp1, int oper, struct expr **expp2);
static void pointer_binary(struct expr **expp, int oper, struct expr *expr);
/* This chapter asks for the repeated application of code to handle
an operation that may be executed at compile time or at run time,
@@ -35,9 +50,7 @@ extern char *symbol2str();
#define commutative_binop(expp, oper, expr) mk_binop(expp, oper, expr, 1)
#define non_commutative_relop(expp, oper, expr) mk_binop(expp, oper, expr, 1)
ch3bin(expp, oper, expr)
register struct expr **expp;
struct expr *expr;
void ch3bin(struct expr **expp, int oper, struct expr *expr)
{
/* apply binary operator oper between *expp and expr.
NB: don't swap operands if op is one of the op= operators!!!
@@ -295,8 +308,7 @@ ch3bin(expp, oper, expr)
}
}
pntminuspnt(expp, oper, expr)
register struct expr **expp, *expr;
static void pntminuspnt(struct expr **expp, int oper, struct expr *expr)
{
/* Subtracting two pointers is so complicated it merits a
routine of its own.
@@ -327,8 +339,7 @@ pntminuspnt(expp, oper, expr)
* when the arguments are switched. This is special for some relational
* operators.
*/
int
arg_switched(oper)
static int arg_switched(int oper)
{
switch (oper) {
case '<': return '>';
@@ -339,9 +350,7 @@ arg_switched(oper)
}
}
mk_binop(expp, oper, expr, commutative)
struct expr **expp;
register struct expr *expr;
static void mk_binop(struct expr **expp, int oper, struct expr *expr, int commutative)
{
/* Constructs in *expp the operation indicated by the operands.
"commutative" indicates whether "oper" is a commutative
@@ -365,8 +374,7 @@ mk_binop(expp, oper, expr, commutative)
}
}
pointer_arithmetic(expp1, oper, expp2)
register struct expr **expp1, **expp2;
static void pointer_arithmetic(struct expr **expp1, int oper, struct expr **expp2)
{
int typ;
/* prepares the integral expression expp2 in order to
@@ -386,8 +394,7 @@ pointer_arithmetic(expp1, oper, expp2)
);
}
pointer_binary(expp, oper, expr)
register struct expr **expp, *expr;
static void pointer_binary(struct expr **expp, int oper, struct expr *expr)
{
/* constructs the pointer arithmetic expression out of
a pointer expression, a binary operator and an integral

View File

@@ -0,0 +1,11 @@
/*
* The Amsterdam Compiler Kit
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef LANG_CEM_CEMCOM_ANSI_CH3BIN_H
#define LANG_CEM_CEMCOM_ANSI_CH3BIN_H
void ch3bin(struct expr **expp, int oper, struct expr *expr);
#endif

View File

@@ -18,13 +18,22 @@
#include "idf.h"
#include "def.h"
#include "sizes.h"
#include "ch3.h"
#include "ch3mon.h"
#include "error.h"
#include "expr_loc.h"
#include "stab.h"
#include "util.h"
#include "struct_loc.h"
#include "dataflow.h"
#include <symbol2str.h>
extern char options[];
extern arith full_mask[/*MAXSIZE*/]; /* cstoper.c */
char *symbol2str();
extern arith full_mask[/*MAXSIZE + 1*/]; /* cstoper.c */
ch3mon(oper, expp)
register struct expr **expp;
void ch3mon(int oper, struct expr **expp)
{
/* The monadic prefix operator oper is applied to *expp.
*/

View File

@@ -0,0 +1,11 @@
/*
* The Amsterdam Compiler Kit
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef LANG_CEM_CEMCOM_ANSI_CH3MON_H
#define LANG_CEM_CEMCOM_ANSI_CH3MON_H
void ch3mon(int oper, struct expr **expp);
#endif

View File

@@ -40,6 +40,21 @@
#include "assert.h"
#include "LLlex.h"
#include "align.h"
#include "blocks.h"
#include "code_c.h"
#include "conversion.h"
#include "util_loc.h"
#include "stab.h"
#include "error.h"
#include "struct_loc.h"
#include "ch3.h"
#include "idf_loc.h"
#include "expr_loc.h"
#include "ival.h"
#include "eval.h"
#include <symbol2str.h>
#ifdef LINT
#include "l_lint.h"
#endif /* LINT */
@@ -51,7 +66,6 @@ label lab_count = 1;
label datlab_count = 1;
int fp_used;
extern arith NewLocal(); /* util.c */
/* global function info */
char *func_name;
@@ -66,12 +80,14 @@ static int pro_id;
#endif /* USE_TMP */
extern char options[];
extern char *symbol2str();
extern char *source;
static void def_strings(struct string_cst *sc);
static void prc_entry(char *name);
static void prc_exit();
#ifndef LINT
init_code(dst_file)
char *dst_file;
void init_code(char *dst_file)
{
/* init_code() initialises the output file on which the
compact EM code is written
@@ -108,10 +124,7 @@ init_code(dst_file)
struct string_cst *str_list = 0;
label
code_string(val, len)
char *val;
int len;
label code_string(char *val, int len)
{
register struct string_cst *sc = new_string_cst();
label dlb = data_label();
@@ -125,8 +138,7 @@ code_string(val, len)
return dlb;
}
def_strings(sc)
register struct string_cst *sc;
static void def_strings(struct string_cst *sc)
{
while (sc) {
struct string_cst *sc1 = sc;
@@ -140,7 +152,8 @@ def_strings(sc)
}
/* flush_strings() is called from program.g after each external definition */
flush_strings() {
void flush_strings()
{
if (str_list) {
def_strings(str_list);
str_list = 0;
@@ -148,7 +161,7 @@ flush_strings() {
}
#ifndef LINT
end_code()
void end_code()
{
/* end_code() performs the actions to be taken when closing
the output stream.
@@ -163,19 +176,19 @@ end_code()
#endif /* LINT */
#ifdef PREPEND_SCOPES
prepend_scopes()
void prepend_scopes()
{
/* prepend_scopes() runs down the list of global idf's
and generates those exa's, exp's, ina's and inp's
that superior hindsight has provided.
*/
register struct stack_entry *se = local_level->sl_entry;
struct stack_entry *se = local_level->sl_entry;
#ifdef USE_TMP
C_beginpart(tmp_id);
#endif /* USE_TMP */
while (se != 0) {
register struct def *df = se->se_idf->id_def;
struct def *df = se->se_idf->id_def;
if (df && (df->df_initialized || df->df_used || df->df_alloc)) {
code_scope(se->se_idf->id_text, df);
@@ -188,9 +201,7 @@ prepend_scopes()
}
#endif /* PREPEND_SCOPES */
code_scope(text, def)
char *text;
register struct def *def;
void code_scope(char *text, struct def *def)
{
/* generates code for one name, text, of the storage class
as given by def, if meaningful.
@@ -221,9 +232,8 @@ static int struct_return;
static char *last_fn_given = (char *)0;
static label file_name_label;
begin_proc(ds, idf) /* to be called when entering a procedure */
struct decspecs *ds;
struct idf *idf;
/* to be called when entering a procedure */
void begin_proc(struct decspecs *ds, struct idf *idf)
{
/* begin_proc() is called at the entrance of a new function
and performs the necessary code generation:
@@ -233,8 +243,8 @@ begin_proc(ds, idf) /* to be called when entering a procedure */
does not fit in the return area
- a fil pseudo instruction
*/
register char *name = idf->id_text;
register struct def *def = idf->id_def;
char *name = idf->id_text;
struct def *def = idf->id_def;
/* idf->id_def does not indicate the right def structure
* when the function being defined has a parameter of the
@@ -320,8 +330,7 @@ begin_proc(ds, idf) /* to be called when entering a procedure */
#endif
}
end_proc(fbytes)
arith fbytes;
void end_proc(arith fbytes)
{
/* end_proc() deals with the code to be generated at the end of
a function, as there is:
@@ -391,7 +400,7 @@ end_proc(fbytes)
options['n'] = optionsn;
}
do_return()
void do_return()
{
/* do_return handles the case of a return without expression.
This version branches to the return label, which is
@@ -404,8 +413,7 @@ do_return()
C_bra(return2_label);
}
do_return_expr(expr)
struct expr *expr;
void do_return_expr(struct expr *expr)
{
/* do_return_expr() generates the expression and the jump for
a return statement with an expression.
@@ -420,11 +428,12 @@ do_return_expr(expr)
return_expr_occurred = 1;
}
code_declaration(idf, expr, lvl, sc)
register struct idf *idf; /* idf to be declared */
struct expr *expr; /* initialisation; NULL if absent */
int lvl; /* declaration level */
int sc; /* storage class, as in the declaration */
/* struct idf *idf idf to be declared
* struct expr *expr initialisation; NULL if absent
* int lvl declaration level
* int sc storage class, as in the declaration
*/
void code_declaration(struct idf *idf, struct expr *expr, int lvl, int sc)
{
/* code_declaration() does the actual declaration of the
variable indicated by "idf" on declaration level "lvl".
@@ -445,8 +454,8 @@ code_declaration(idf, expr, lvl, sc)
The sc is the actual storage class, as given in the
declaration.
*/
register struct def *def = idf->id_def;
register arith size = def->df_type->tp_size;
struct def *def = idf->id_def;
arith size = def->df_type->tp_size;
int fund = def->df_type->tp_fund;
int def_sc = def->df_sc;
@@ -532,17 +541,15 @@ code_declaration(idf, expr, lvl, sc)
}
}
loc_init(expr, id)
struct expr *expr;
struct idf *id;
void loc_init(struct expr *expr, struct idf *id)
{
/* loc_init() generates code for the assignment of
expression expr to the local variable described by id.
It frees the expression afterwards.
*/
register struct expr *e = expr;
register struct def *df = id->id_def;
register struct type *tp = df->df_type;
struct expr *e = expr;
struct def *df = id->id_def;
struct type *tp = df->df_type;
static arith tmpoffset = 0;
static arith unknownsize = 0;
@@ -610,12 +617,11 @@ loc_init(expr, id)
}
}
bss(idf)
register struct idf *idf;
void bss(struct idf *idf)
{
/* bss() allocates bss space for the global idf.
*/
register struct def *df = idf->id_def;
struct def *df = idf->id_def;
#ifndef PREPEND_SCOPES
code_scope(idf->id_text, df);
@@ -641,15 +647,13 @@ bss(idf)
}
}
formal_cvt(hasproto,df)
int hasproto;
register struct def *df;
void formal_cvt(int hasproto, struct def *df)
{
/* formal_cvt() converts a formal parameter of type char or
short from int to that type. It also converts a formal
parameter of type float from a double to a float.
*/
register struct type *tp = df->df_type;
struct type *tp = df->df_type;
if (tp->tp_size != int_size &&
(tp->tp_fund == CHAR || tp->tp_fund == SHORT)
@@ -673,9 +677,7 @@ formal_cvt(hasproto,df)
#ifdef LINT
/*ARGSUSED*/
#endif /* LINT */
code_expr(expr, val, code, tlbl, flbl)
struct expr *expr;
label tlbl, flbl;
void code_expr(struct expr *expr, int val, int code, label tlbl, label flbl)
{
/* code_expr() is the parser's interface to the expression code
generator. If line number trace is wanted, it generates a
@@ -708,9 +710,9 @@ static struct stmt_block *stmt_stack; /* top of statement stack */
which are the only ones that are stacked, only the top of
the stack is interesting.
*/
code_break()
void code_break()
{
register struct stmt_block *stmt_block = stmt_stack;
struct stmt_block *stmt_block = stmt_stack;
#ifdef DBSYMTAB
if (options['g']) db_line(dot.tk_file, dot.tk_line);
@@ -726,9 +728,9 @@ code_break()
it generates a branch instruction to the continue label of the
innermost statement in which continue has a meaning.
*/
code_continue()
void code_continue()
{
register struct stmt_block *stmt_block = stmt_stack;
struct stmt_block *stmt_block = stmt_stack;
while (stmt_block) {
if (stmt_block->st_continue) {
@@ -743,10 +745,9 @@ code_continue()
error("continue not inside for, while or do");
}
stack_stmt(break_label, cont_label)
label break_label, cont_label;
void stack_stmt(label break_label, label cont_label)
{
register struct stmt_block *stmt_block = new_stmt_block();
struct stmt_block *stmt_block = new_stmt_block();
stmt_block->next = stmt_stack;
stmt_block->st_break = break_label;
@@ -754,7 +755,7 @@ stack_stmt(break_label, cont_label)
stmt_stack = stmt_block;
}
unstack_stmt()
void unstack_stmt()
{
/* unstack_stmt() unstacks the data of a statement
which may contain break or continue
@@ -766,8 +767,7 @@ unstack_stmt()
static label prc_name;
prc_entry(name)
char *name;
static void prc_entry(char *name)
{
if (options['p']) {
C_df_dlb(prc_name = data_label());
@@ -778,7 +778,7 @@ prc_entry(name)
}
}
prc_exit()
static void prc_exit()
{
if (options['p']) {
C_lae_dlb(prc_name, (arith) 0);
@@ -788,9 +788,7 @@ prc_exit()
}
#ifdef DBSYMTAB
db_line(file, line)
char *file;
unsigned int line;
void db_line(char *file, unsigned int line)
{
static unsigned oldline;
static char *oldfile;

View File

@@ -0,0 +1,42 @@
/*
* The Amsterdam Compiler Kit
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef LANG_CEM_CEMCOM_ANSI_CODE_H
#define LANG_CEM_CEMCOM_ANSI_CODE_H
struct decspecs;
void init_code(char *dst_file);
label code_string(char *val, int len);
void flush_strings();
void code_scope(char *text, struct def *def);
void begin_proc(struct decspecs *ds, struct idf *idf);
void end_proc(arith fbytes);
void do_return();
void do_return_expr(struct expr *expr);
void code_declaration(struct idf *idf, struct expr *expr, int lvl, int sc);
void loc_init(struct expr *expr, struct idf *id);
void bss(struct idf *idf);
void code_expr(struct expr *expr, int val, int code, label tlbl, label flbl);
void code_break();
void code_continue();
void stack_stmt(label break_label, label cont_label);
void unstack_stmt();
void formal_cvt(int hasproto, struct def *df);
#ifdef DBSYMTAB
void db_line(char *file, unsigned int line);
#endif
#ifdef PREPEND_SCOPES
void prepend_scopes();
#endif
#ifndef LINT
void end_code();
#endif
#endif

View File

@@ -13,6 +13,7 @@
#include "type.h"
#include "sizes.h"
#include "Lpars.h"
#include "error.h"
#define T_SIGNED 1
#define T_UNSIGNED 2
@@ -27,13 +28,12 @@
C??
*/
static int convtype();
static int convtype(struct type *tp);
conversion(from_type, to_type)
register struct type *from_type, *to_type;
void conversion(struct type *from_type, struct type *to_type)
{
register arith from_size = from_type->tp_size;
register arith to_size = to_type->tp_size;
arith from_size = from_type->tp_size;
arith to_size = to_type->tp_size;
int from_cnvtype = convtype(from_type);
int to_cnvtype = convtype(to_type);
@@ -126,9 +126,7 @@ conversion(from_type, to_type)
/* convtype() returns in which category a given type falls:
signed, unsigned or floating
*/
static int
convtype(tp)
register struct type *tp;
static int convtype(struct type *tp)
{
switch (tp->tp_fund) {
case CHAR:

View File

@@ -0,0 +1,8 @@
#ifndef LANG_CEM_CEMCOM_ANSI_CONVERSION_H
#define LANG_CEM_CEMCOM_ANSI_CONVERSION_H
struct type;
void conversion(struct type *from_type, struct type *to_type);
#endif

View File

@@ -15,23 +15,26 @@
#include "sizes.h"
#include "Lpars.h"
#include "assert.h"
#include "cstoper.h"
#include "error.h"
#include "expr_loc.h"
arith full_mask[MAXSIZE];/* full_mask[1] == 0XFF, full_mask[2] == 0XFFFF, .. */
/* full_mask[1] == 0XFF, full_mask[2] == 0XFFFF, .. */
arith full_mask[MAXSIZE + 1];
#ifndef NOCROSS
arith max_int; /* maximum integer on target machine */
arith max_unsigned; /* maximum unsigned on target machine */
#endif /* NOCROSS */
extern int ResultKnown;
cstbin(expp, oper, expr)
register struct expr **expp, *expr;
void cstbin(struct expr **expp, int oper, struct expr *expr)
{
/* The operation oper is performed on the constant
expressions *expp(ld) and expr(ct), and the result restored in
*expp.
*/
register arith o1 = (*expp)->VL_VALUE;
register arith o2 = expr->VL_VALUE;
arith o1 = (*expp)->VL_VALUE;
arith o2 = expr->VL_VALUE;
int uns = (*expp)->ex_type->tp_unsigned;
ASSERT(is_ld_cst(*expp) && is_cp_cst(expr));
@@ -204,13 +207,12 @@ cstbin(expp, oper, expr)
free_expression(expr);
}
cut_size(expr)
register struct expr *expr;
void cut_size(struct expr *expr)
{
/* The constant value of the expression expr is made to
conform to the size of the type of the expression.
*/
register arith o1 = expr->VL_VALUE;
arith o1 = expr->VL_VALUE;
int uns = expr->ex_type->tp_unsigned;
int size = (int) expr->ex_type->tp_size;
@@ -240,14 +242,14 @@ cut_size(expr)
expr->VL_VALUE = o1;
}
init_cst()
void init_cst()
{
register int i = 0;
register arith bt = (arith)0;
int i = 0;
arith bt = (arith)0;
while (!(bt < 0)) {
bt = (bt << 8) + 0377, i++;
if (i == MAXSIZE)
if (i > MAXSIZE)
fatal("array full_mask too small for this machine");
full_mask[i] = bt;
}

View File

@@ -0,0 +1,8 @@
#ifndef LANG_CEM_CEMCOM_ANSI_CSTOPER_H
#define LANG_CEM_CEMCOM_ANSI_CSTOPER_H
void cstbin(struct expr **expp, int oper, struct expr *expr);
void cut_size(struct expr *expr);
void init_cst();
#endif

View File

@@ -0,0 +1,11 @@
/*
* The Amsterdam Compiler Kit
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef LANG_CEM_CEMCOM_ANSI_DATAFLOW_H
#define LANG_CEM_CEMCOM_ANSI_DATAFLOW_H
/* lang/cem/cemcom.ansi/dataflow.c */
#endif /* LANG_CEM_CEMCOM_ANSI_DATAFLOW_H */

View File

@@ -17,17 +17,27 @@
#include "label.h"
#include "code.h"
#include "idf.h"
#include "idf_loc.h"
#include "type.h"
#include "type_loc.h"
#include "proto.h"
#include "proto_loc.h"
#include "struct.h"
#include "struct_loc.h"
#include "field.h"
#include "decspecs.h"
#include "def.h"
#include "declar.h"
#include "label.h"
#include "expr.h"
#include "expr_loc.h"
#include "sizes.h"
#include "level.h"
#include "code_c.h"
#include "error.h"
#include "stab.h"
#include "declarator.h"
#ifdef LINT
#include "l_lint.h"
#endif /* LINT */
@@ -712,7 +722,7 @@ parameter_declarator(register struct declarator *dc;)
primary_parameter_declarator(register struct declarator *dc;)
:
[%if (AHEAD == ')' || first_of_parameter_type_list(AHEAD)
[%if ((AHEAD == ')' || first_of_parameter_type_list(AHEAD))
&& (AHEAD != IDENTIFIER))
/* empty */
|

View File

@@ -4,6 +4,8 @@
*/
/* $Id$ */
/* DEFINITION OF DECLARATOR DESCRIPTORS */
#ifndef LANG_CEM_CEMCOM_ANSI_DECLARE_STR
#define LANG_CEM_CEMCOM_ANSI_DECLARE_STR
/* A 'declarator' consists of an idf and a linked list of
language-defined unary operations: *, [] and (), called
@@ -39,3 +41,5 @@ struct decl_unary {
extern struct type *declare_type();
extern struct declarator null_declarator;
#endif /* LANG_CEM_CEMCOM_ANSI_DECLARE_STR */

View File

@@ -20,14 +20,14 @@
#include "expr.h"
#include "sizes.h"
#include "level.h"
#include "error.h"
#include "idf_loc.h"
#include "proto_loc.h"
extern char options[];
struct declarator null_declarator;
struct type *
declare_type(tp, dc)
struct type *tp;
struct declarator *dc;
struct type *declare_type(struct type *tp, struct declarator *dc)
{
/* Applies the decl_unary list starting at dc->dc_decl_unary
to the type tp and returns the result.
@@ -35,7 +35,7 @@ declare_type(tp, dc)
are purely prototypes. Simply add the type list to the
function node.
*/
register struct decl_unary *du = dc->dc_decl_unary;
struct decl_unary *du = dc->dc_decl_unary;
while (du) {
tp = construct_type(du->du_fund, tp, du->du_typequal,
@@ -45,18 +45,13 @@ declare_type(tp, dc)
return tp;
}
add_decl_unary(dc, fund, qual, count, fm, pl)
register struct declarator *dc;
int qual;
arith count;
struct formal *fm;
struct proto *pl;
void add_decl_unary(struct declarator *dc, int fund, int qual, arith count, struct formal *fm, struct proto *pl)
{
/* A decl_unary describing a constructor with fundamental
type fund and with size count is inserted in front of the
declarator dc.
*/
register struct decl_unary *new = new_decl_unary();
struct decl_unary *new = new_decl_unary();
new->next = dc->dc_decl_unary;
new->du_fund = fund;
@@ -77,13 +72,12 @@ add_decl_unary(dc, fund, qual, count, fm, pl)
dc->dc_decl_unary = new;
}
remove_declarator(dc)
struct declarator *dc;
void remove_declarator(struct declarator *dc)
{
/* The decl_unary list starting at dc->dc_decl_unary is
removed.
*/
register struct decl_unary *du = dc->dc_decl_unary;
struct decl_unary *du = dc->dc_decl_unary;
while (du) {
struct decl_unary *old_du = du;
@@ -93,15 +87,14 @@ remove_declarator(dc)
}
}
reject_params(dc)
register struct declarator *dc;
void reject_params(struct declarator *dc)
{
/* The declarator is checked to have no parameters, if it
is an old-style function. If it is a new-style function,
the identifiers are removed. The function is not called in
case of a function definition.
*/
register struct decl_unary *du = dc->dc_decl_unary;
struct decl_unary *du = dc->dc_decl_unary;
int err_given = 0;
if (dc->dc_formal) {
@@ -122,8 +115,7 @@ reject_params(dc)
}
}
check_array_subscript(expr)
register struct expr *expr;
void check_array_subscript(struct expr *expr)
{
arith size = expr->VL_VALUE;

View File

@@ -0,0 +1,16 @@
/*
* The Amsterdam Compiler Kit
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef LANG_CEM_CEMCOM_ANSI_DECLARATOR_H
#define LANG_CEM_CEMCOM_ANSI_DECLARATOR_H
/* lang/cem/cemcom.ansi/declarator.c */
struct type *declare_type(struct type *tp, struct declarator *dc);
void add_decl_unary(struct declarator *dc, int fund, int qual, arith count, struct formal *fm, struct proto *pl);
void remove_declarator(struct declarator *dc);
void reject_params(struct declarator *dc);
void check_array_subscript(struct expr *expr);
#endif /* LANG_CEM_CEMCOM_ANSI_DECLARATOR_H */

View File

@@ -12,21 +12,21 @@
#include "type.h"
#include "level.h"
#include "def.h"
#include "error.h"
#include <symbol2str.h>
extern char options[];
extern int level;
extern char *symbol2str();
extern struct type *qualifier_type();
struct decspecs null_decspecs;
do_decspecs(ds)
register struct decspecs *ds;
void do_decspecs(struct decspecs *ds)
{
/* The provisional decspecs ds as obtained from the program
is turned into a legal consistent decspecs.
*/
register struct type *tp = ds->ds_type;
struct type *tp = ds->ds_type;
ASSERT(level != L_FORMAL1);
@@ -67,7 +67,7 @@ do_decspecs(ds)
tp = int_type;
}
if (ds->ds_size) {
register int ds_isshort = (ds->ds_size == SHORT);
int ds_isshort = (ds->ds_size == SHORT);
if (ds->ds_typedef) goto SIZE_ERROR; /* yes */
if (tp == int_type) {
@@ -82,7 +82,7 @@ do_decspecs(ds)
ds->ds_notypegiven = 0;
}
if (ds->ds_unsigned) {
register int ds_isunsigned = (ds->ds_unsigned == UNSIGNED);
int ds_isunsigned = (ds->ds_unsigned == UNSIGNED);
if (ds->ds_typedef) goto SIGN_ERROR; /* yes */
/*
@@ -113,13 +113,10 @@ do_decspecs(ds)
In case of a complex type the top of the type list will be
replaced by a qualified version.
*/
struct type *
qualifier_type(tp, typequal)
register struct type *tp;
int typequal;
struct type *qualifier_type(struct type *tp, int typequal)
{
register struct type *dtp = tp;
register int fund = tp->tp_fund;
struct type *dtp = tp;
int fund = tp->tp_fund;
while (dtp && dtp->tp_typequal != typequal)
dtp = dtp->next;

View File

@@ -1,3 +1,5 @@
#ifndef LANG_CEM_CEMCOM_ANSI_DECSPECS_H
#define LANG_CEM_CEMCOM_ANSI_DECSPECS_H
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
@@ -17,5 +19,11 @@ struct decspecs {
int ds_typequal; /* type qualifiers - see type.str */
};
extern struct type *qualifier_type();
extern struct decspecs null_decspecs;
/* lang/cem/cemcom.ansi/decspecs.c */
void do_decspecs(struct decspecs *ds);
struct type *qualifier_type(struct type *tp, int typequal);
#endif /* LANG_CEM_CEMCOM_ANSI_DECSPECS_H */

View File

@@ -4,6 +4,8 @@
*/
/* $Id$ */
/* IDENTIFIER DEFINITION DESCRIPTOR */
#ifndef LANG_CEM_CEMCOM_ANSI_DEF_STR
#define LANG_CEM_CEMCOM_ANSI_DEF_STR
#include "lint.h"
@@ -38,3 +40,6 @@ struct def { /* for ordinary tags */
#define REG_BONUS 10 /* register candidate, declared as such */
/* ALLOCDEF "def" 50 */
#endif /* LANG_CEM_CEMCOM_ANSI_DEF_STR */

View File

@@ -5,7 +5,11 @@
/* $Id$ */
/* PREPROCESSOR: CONTROLLINE INTERPRETER */
#include <stdlib.h>
#include <string.h>
#include "debug.h"
#include "specials.h"
#include "arith.h"
#include "LLlex.h"
#include "Lpars.h"
@@ -13,6 +17,13 @@
#include "input.h"
#include "nopp.h"
#include "lint.h"
#include "skip.h"
#include "domacro.h"
#include "error.h"
#include "pragma.h"
#include "program.h"
#include "main.h"
#include "replace_loc.h"
#ifndef NOPP
#include "ifdepth.h"
@@ -36,16 +47,15 @@ int IncludeLevel = 0;
extern char options[];
extern char **inctable; /* list of include directories */
extern char *getwdir();
char ifstack[IFDEPTH]; /* if-stack: the content of an entry is */
/* 1 if a corresponding ELSE has been */
/* encountered. */
int nestlevel = -1;
extern char *getwdir();
struct idf *
GetIdentifier(skiponerr)
int skiponerr; /* skip the rest of the line on error */
/* skiponerr -> skip the rest of the line on error */
struct idf *GetIdentifier(int skiponerr)
{
/* returns a pointer to the descriptor of the identifier that is
read from the input stream. When the input doe not contain
@@ -76,7 +86,7 @@ GetIdentifier(skiponerr)
An error message is produced when the token is not recognized,
i.e. it is not one of "define" .. "undef" , integer or newline.
*/
domacro()
void domacro()
{
struct token tk; /* the token itself */
int toknum;
@@ -126,6 +136,9 @@ domacro()
case K_ERROR: /* "error" */
do_error();
break;
case K_WARNING: /* "warning" */
do_warning();
break;
case K_PRAGMA: /* "pragma" */
do_pragma();
break;
@@ -154,8 +167,7 @@ domacro()
int lint_skip_comment;
#endif
skip_block(to_endif)
int to_endif;
void skip_block(int to_endif)
{
/* skip_block() skips the input from
1) a false #if, #ifdef, #ifndef or #elif until the
@@ -165,8 +177,8 @@ int to_endif;
#ifndef or #elif until the corresponding #endif is
seen.
*/
register int ch;
register int skiplevel = nestlevel; /* current nesting level */
int ch;
int skiplevel = nestlevel; /* current nesting level */
struct token tk;
int toknum;
@@ -289,7 +301,7 @@ int to_endif;
}
ifexpr()
int ifexpr()
{
/* ifexpr() returns whether the restricted constant
expression following #if or #elif evaluates to true. This
@@ -311,7 +323,7 @@ ifexpr()
return (errors == err_occurred) && (ifval != (arith)0);
}
do_include()
void do_include()
{
/* do_include() performs the inclusion of a file.
*/
@@ -356,7 +368,7 @@ do_include()
}
}
do_define()
void do_define()
{
/* do_define() interprets a #define control line.
*/
@@ -395,7 +407,7 @@ do_define()
LineNumber++;
}
push_if()
void push_if()
{
if (nestlevel >= IFDEPTH)
fatal("too many nested #if/#ifdef/#ifndef");
@@ -403,7 +415,7 @@ push_if()
ifstack[++nestlevel] = 0;
}
do_elif()
void do_elif()
{
if (nestlevel <= nestlow) {
lexerror("#elif without corresponding #if");
@@ -420,7 +432,7 @@ do_elif()
}
}
do_else()
void do_else()
{
if (SkipToNewLine())
if (!options['o'])
@@ -436,7 +448,7 @@ do_else()
}
}
do_endif()
void do_endif()
{
if (SkipToNewLine()) {
if (!options['o'])
@@ -448,16 +460,16 @@ do_endif()
else nestlevel--;
}
do_if()
void do_if()
{
push_if();
if (!ifexpr()) /* a false #if/#elif expression */
skip_block(0);
}
do_ifdef(how)
void do_ifdef(how)
{
register struct idf *id;
struct idf *id;
/* how == 1 : ifdef; how == 0 : ifndef
*/
@@ -477,10 +489,9 @@ do_ifdef(how)
}
/* argidf != NULL when the undef came from a -U option */
do_undef(argidf)
struct idf *argidf;
void do_undef(struct idf *argidf)
{
register struct idf *id = argidf;
struct idf *id = argidf;
/* Forget a macro definition. */
if (id || (id = GetIdentifier(1))) {
@@ -503,7 +514,7 @@ do_undef(argidf)
lexerror("illegal #undef construction");
}
do_error()
void do_error()
{
int len;
char *get_text();
@@ -514,10 +525,18 @@ do_error()
LineNumber++;
}
int
getparams(buf, parbuf)
char *buf[];
char parbuf[];
void do_warning()
{
int len;
char *get_text();
char *bp = get_text((char **) 0, &len);
lexwarning("user warning: %s", bp);
free(bp);
LineNumber++;
}
int getparams(char *buf[], char parbuf[])
{
/* getparams() reads the formal parameter list of a macro
definition.
@@ -529,10 +548,10 @@ getparams(buf, parbuf)
Note that the '(' has already been eaten.
The names of the formal parameters are stored into parbuf.
*/
register char **pbuf = &buf[0];
register int c;
register char *ptr = &parbuf[0];
register char **pbuf2;
char **pbuf = &buf[0];
int c;
char *ptr = &parbuf[0];
char **pbuf2;
c = GetChar();
c = skipspaces(c,0);
@@ -583,11 +602,9 @@ getparams(buf, parbuf)
/*NOTREACHED*/
}
macro_def(id, text, nformals, length, flags)
register struct idf *id;
char *text;
void macro_def(struct idf *id, char *text, int nformals, int length, int flags)
{
register struct macro *newdef = id->id_macro;
struct macro *newdef = id->id_macro;
/* macro_def() puts the contents and information of a macro
definition into a structure and stores it into the symbol
@@ -609,15 +626,13 @@ macro_def(id, text, nformals, length, flags)
newdef->mc_flag = flags; /* special flags */
}
int
find_name(nm, index)
char *nm, *index[];
int find_name(char *nm, char *index[])
{
/* find_name() returns the index of "nm" in the namelist
"index" if it can be found there. 0 is returned if it is
not there.
*/
register char **ip = &index[0];
char **ip = &index[0];
while (*ip)
if (strcmp(nm, *ip++) == 0)
@@ -628,10 +643,7 @@ find_name(nm, index)
#define BLANK(ch) ((ch == ' ') || (ch == '\t'))
char *
get_text(formals, length)
char *formals[];
int *length;
char *get_text(char *formals[], int *length)
{
/* get_text() copies the replacement text of a macro
definition with zero, one or more parameters, thereby
@@ -655,9 +667,9 @@ get_text(formals, length)
4- comment, same as for 1
Other tokens will not be seen as such.
*/
register int c;
int c;
struct repl repls;
register struct repl *repl = &repls;
struct repl *repl = &repls;
int blank = 0;
c = GetChar();
@@ -672,7 +684,7 @@ get_text(formals, length)
}
if (c == '\'' || c == '"') {
register int delim = c;
int delim = c;
if (blank) {
blank = 0;
@@ -705,7 +717,7 @@ get_text(formals, length)
} else if (formals
&& (class(c) == STIDF || class(c) == STELL)) {
char id_buf[IDFSIZE + 1];
register char *idp = id_buf;
char *idp = id_buf;
int n;
/* read identifier: it may be a formal parameter */
@@ -722,7 +734,7 @@ get_text(formals, length)
add2repl(repl, ' ');
}
/* construct the formal parameter mark or identifier */
if (n = find_name(id_buf, formals))
if ((n = find_name(id_buf, formals)))
add2repl(repl, FORMALP | (char) n);
else {
idp = id_buf;
@@ -771,8 +783,7 @@ get_text(formals, length)
as strings, without taking care of the leading and trailing
blanks (spaces and tabs).
*/
macroeq(s, t)
register char *s, *t;
int macroeq(char *s, char *t)
{
/* skip leading spaces */
@@ -795,9 +806,8 @@ macroeq(s, t)
}
#else /* NOPP */
struct idf *
GetIdentifier(skiponerr)
int skiponerr; /* skip the rest of the line on error */
/* skiponerr -> skip the rest of the line on error */
struct idf *GetIdentifier(int skiponerr)
{
/* returns a pointer to the descriptor of the identifier that is
read from the input stream. When the input does not contain
@@ -816,7 +826,7 @@ GetIdentifier(skiponerr)
return tk.tk_idf;
}
domacro()
void domacro()
{
int tok;
struct token tk;
@@ -840,8 +850,7 @@ domacro()
#endif /* NOPP */
do_line(l)
unsigned int l;
void do_line(unsigned int l)
{
struct token tk;
int t = GetToken(&tk);

View File

@@ -0,0 +1,31 @@
/*
* The Amsterdam Compiler Kit
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef LANG_CEM_CEMCOM_ANSI_DOMACRO_H
#define LANG_CEM_CEMCOM_ANSI_DOMACRO_H
/* lang/cem/cemcom.ansi/domacro.c */
struct idf *GetIdentifier(int skiponerr);
void domacro(void);
void skip_block(int to_endif);
int ifexpr(void);
void do_include(void);
void do_define(void);
void push_if(void);
void do_elif(void);
void do_else(void);
void do_endif(void);
void do_if(void);
void do_ifdef(int how);
void do_undef(struct idf *argidf);
void do_error(void);
void do_warning(void);
int getparams(char *buf[], char parbuf[]);
void macro_def(struct idf *id, char *text, int nformals, int length, int flags);
int find_name(char *nm, char *index[]);
char *get_text(char *formals[], int *length);
int macroeq(char *s, char *t);
void do_line(unsigned int l);
#endif /* LANG_CEM_CEMCOM_ANSI_DOMACRO_H */

View File

@@ -7,6 +7,7 @@
#include "lint.h"
#if __STDC__
#include <stdio.h>
#include <stdarg.h>
#else
#include <varargs.h>
@@ -22,6 +23,7 @@
#include "lint.h"
#include "nopp.h"
#include "errout.h"
#include "print.h"
#include "tokenname.h"
#include <flt_arith.h>
@@ -30,11 +32,13 @@
#include "expr.h"
#include "def.h"
#include "LLlex.h"
#include "error.h"
/* This file contains the error-message and diagnostic
functions. Beware, they are called with a variable number of
arguments!
*/
static void _error(int class, char *fn, unsigned int ln, char *fmt, va_list ap);
/* error classes */
#define STRICT 1
@@ -62,11 +66,9 @@ extern char loptions[];
expression, whereas other errors use the information in the token.
*/
static _error();
#if __STDC__
/*VARARGS*/
error(char *fmt, ...)
void error(char *fmt, ...)
{
va_list ap;
@@ -78,7 +80,7 @@ error(char *fmt, ...)
}
/*VARARGS*/
expr_error(struct expr *expr, char *fmt, ...)
void expr_error(struct expr *expr, char *fmt, ...)
{
va_list ap;
@@ -94,7 +96,7 @@ expr_error(struct expr *expr, char *fmt, ...)
}
/*VARARGS*/
lexstrict(char *fmt, ...)
void lexstrict(char *fmt, ...)
{
va_list ap;
@@ -106,7 +108,7 @@ lexstrict(char *fmt, ...)
}
/*VARARGS*/
strict(char *fmt, ...)
void strict(char *fmt, ...)
{
va_list ap;
@@ -118,7 +120,7 @@ strict(char *fmt, ...)
}
/*VARARGS*/
expr_strict(struct expr *expr, char *fmt, ...)
void expr_strict(struct expr *expr, char *fmt, ...)
{
va_list ap;
@@ -134,7 +136,7 @@ expr_strict(struct expr *expr, char *fmt, ...)
#ifdef DEBUG
/*VARARGS*/
debug(char *fmt, ...)
void debug(char *fmt, ...)
{
va_list ap;
@@ -147,7 +149,7 @@ debug(char *fmt, ...)
#endif /* DEBUG */
/*VARARGS*/
warning(char *fmt, ...)
void warning(char *fmt, ...)
{
va_list ap;
@@ -159,7 +161,7 @@ warning(char *fmt, ...)
}
/*VARARGS*/
expr_warning(struct expr *expr, char *fmt, ...)
void expr_warning(struct expr *expr, char *fmt, ...)
{
va_list ap;
@@ -176,7 +178,7 @@ expr_warning(struct expr *expr, char *fmt, ...)
#ifdef LINT
/*VARARGS*/
def_warning(struct def *def, char *fmt, ...)
void def_warning(struct def *def, char *fmt, ...)
{
va_list ap;
@@ -189,7 +191,7 @@ def_warning(struct def *def, char *fmt, ...)
/*VARARGS*/
hwarning(char *fmt, ...)
void hwarning(char *fmt, ...)
{
va_list ap;
@@ -202,7 +204,7 @@ hwarning(char *fmt, ...)
}
/*VARARGS*/
awarning(char *fmt, ...)
void awarning(char *fmt, ...)
{
va_list ap;
@@ -217,7 +219,7 @@ awarning(char *fmt, ...)
#endif /* LINT */
/*VARARGS*/
lexerror(char *fmt, ...)
void lexerror(char *fmt, ...)
{
va_list ap;
@@ -229,7 +231,7 @@ lexerror(char *fmt, ...)
}
/*VARARGS*/
lexwarning(char *fmt, ...)
void lexwarning(char *fmt, ...)
{
va_list ap;
@@ -241,7 +243,7 @@ lexwarning(char *fmt, ...)
}
/*VARARGS*/
crash(char *fmt, ...)
void crash(char *fmt, ...)
{
va_list ap;
@@ -261,7 +263,7 @@ crash(char *fmt, ...)
}
/*VARARGS*/
fatal(char *fmt, ...)
void fatal(char *fmt, ...)
{
va_list ap;
@@ -526,15 +528,9 @@ fatal(va_alist) /* fmt, args */
}
#endif
static
_error(class, fn, ln, fmt, ap)
int class;
char *fn;
unsigned int ln;
char *fmt;
va_list ap;
static void _error(int class, char *fn, unsigned int ln, char *fmt, va_list ap)
{
char *remark;
char *remark = NULL;
/* check visibility of message */
switch (class) {
@@ -619,9 +615,9 @@ _error(class, fn, ln, fmt, ap)
#endif /* LINT */
if (fn)
fprint(ERROUT, "\"%s\", line %u: ", fn, ln);
fprintf(stderr, "\"%s\", line %u: ", fn, ln);
if (remark)
fprint(ERROUT, "%s ", remark);
fprintf(stderr, "%s ", remark);
doprnt(ERROUT, fmt, ap); /* contents of error */
fprint(ERROUT, "\n");
fprintf(stderr, "\n");
}

View File

@@ -0,0 +1,22 @@
/*
* The Amsterdam Compiler Kit
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef LANG_CEM_CEMCOM_ANSI_ERROR_H
#define LANG_CEM_CEMCOM_ANSI_ERROR_H
/* lang/cem/cemcom.ansi/error.c */
void error(char *fmt, ...);
void expr_error(struct expr *expr, char *fmt, ...);
void lexstrict(char *fmt, ...);
void strict(char *fmt, ...);
void expr_strict(struct expr *expr, char *fmt, ...);
void warning(char *fmt, ...);
void expr_warning(struct expr *expr, char *fmt, ...);
void lexerror(char *fmt, ...);
void lexwarning(char *fmt, ...);
void crash(char *fmt, ...);
void fatal(char *fmt, ...);
#endif /* LANG_CEM_CEMCOM_ANSI_ERROR_H */

View File

@@ -5,6 +5,10 @@
/* $Id$ */
/* EXPRESSION STACK */
/* Used for global initializations */
#ifndef LANG_CEM_CEMCOM_ANSI_ESTACK_STR
#define LANG_CEM_CEMCOM_ANSI_ESTACK_STR
struct e_stack {
struct e_stack *next;
arith s_cnt1, s_cnt2;
@@ -19,3 +23,5 @@ struct e_stack {
#define last_offset s_cnt2
#define elem_count s_cnt1
#define nelem s_cnt2
#endif /* LANG_CEM_CEMCOM_ANSI_ESTACK_STR */

View File

@@ -15,6 +15,8 @@
#include "nobitfield.h"
#include "dataflow.h"
#include <flt_arith.h>
#include <system.h>
#include "print.h"
#include "arith.h"
#include "type.h"
#include "idf.h"
@@ -30,13 +32,20 @@
#include "align.h"
#include "mes.h"
#include "atw.h"
#include "blocks.h"
#include "conversion.h"
#include "specials.h"
#include "ch3.h"
#include "eval.h"
#include "error.h"
#include "field_loc.h"
#include "struct_loc.h"
#include "util_loc.h"
#include <symbol2str.h>
#define CRASH() crash("EVAL: CRASH at line %u", __LINE__)
char *symbol2str();
char *long2str();
arith NewLocal(); /* util.c */
#define LocalPtrVar() NewLocal(pointer_size, pointer_align, reg_pointer, REGISTER)
extern int err_occurred; /* error.c */
@@ -66,13 +75,10 @@ extern int err_occurred; /* error.c */
labels, in case they are specified (i.e. are non-zero)
*/
EVAL(expr, val, code, true_label, false_label)
register struct expr *expr;
int val, code;
label true_label, false_label;
void EVAL(struct expr *expr, int val, int code, label true_label, label false_label)
{
int vol = (code != TRUE && recurqual(expr->ex_type, TQ_VOLATILE));
register int gencode = code == TRUE;
int gencode = code == TRUE;
if (err_occurred) return;
switch (expr->ex_class) {
@@ -114,9 +120,9 @@ EVAL(expr, val, code, true_label, false_label)
case Oper: /* compound expression */
{
int oper = expr->OP_OPER;
register struct expr *left = expr->OP_LEFT;
register struct expr *right = expr->OP_RIGHT;
register struct type *tp = expr->OP_TYPE;
struct expr *left = expr->OP_LEFT;
struct expr *right = expr->OP_RIGHT;
struct type *tp = expr->OP_TYPE;
switch (oper) {
case '+':
@@ -255,26 +261,44 @@ EVAL(expr, val, code, true_label, false_label)
operands(expr, gencode);
ASSERT(tp->tp_fund==INT || tp->tp_fund==LONG);
if (gencode)
{
if (tp->tp_unsigned)
{
C_rmu(tp->tp_size);
}
else
{
C_rmi(tp->tp_size);
}
}
break;
case LEFT:
operands(expr, gencode);
if (gencode)
{
if (tp->tp_unsigned)
{
C_slu(tp->tp_size);
}
else
{
C_sli(tp->tp_size);
}
}
break;
case RIGHT:
operands(expr, gencode);
if (gencode)
{
if (tp->tp_unsigned)
{
C_sru(tp->tp_size);
}
else
{
C_sri(tp->tp_size);
}
}
break;
case '<':
case LESSEQ:
@@ -472,7 +496,7 @@ EVAL(expr, val, code, true_label, false_label)
}
case '(':
{
register struct expr *ex;
struct expr *ex;
arith ParSize = (arith)0;
label setjmp_label = 0;
arith retspace = 0;
@@ -658,9 +682,7 @@ EVAL(expr, val, code, true_label, false_label)
}
/* compare() serves as an auxiliary function of EVAL */
compare(relop, lbl)
int relop;
label lbl;
void compare(int relop, label lbl)
{
switch (relop) {
case '<':
@@ -687,8 +709,7 @@ compare(relop, lbl)
}
/* truthvalue() serves as an auxiliary function of EVAL */
truthvalue(relop)
int relop;
void truthvalue(int relop)
{
switch (relop) {
case '<':
@@ -716,12 +737,10 @@ truthvalue(relop)
/* assop() generates the opcode of an assignment operators op= */
assop(type, oper)
register struct type *type;
int oper;
void assop(struct type *type, int oper)
{
register arith size;
register uns = type->tp_unsigned;
arith size;
int uns = type->tp_unsigned;
if ((int)(size = type->tp_size) < (int)word_size)
size = word_size;
@@ -821,8 +840,7 @@ assop(type, oper)
}
}
ptr_add(size)
arith size;
void ptr_add(arith size)
{
if (size != pointer_size) {
C_loc(size);
@@ -839,12 +857,10 @@ ptr_add(size)
- into a local static variable
- absolute addressing
*/
store_val(vl, tp)
register struct value *vl;
register struct type *tp;
void store_val(struct value *vl, struct type *tp)
{
register int inword = 0;
register int indword = 0;
int inword = 0;
int indword = 0;
arith val = vl->vl_value;
if (vl->vl_class == Const) { /* absolute addressing */
@@ -857,8 +873,8 @@ store_val(vl, tp)
else if (tp->tp_size == dword_size) indword = 1;
}
if (vl->vl_class == Name) {
register struct idf *id = vl->vl_data.vl_idf;
register struct def *df = id->id_def;
struct idf *id = vl->vl_data.vl_idf;
struct def *df = id->id_def;
/* if (df->df_level == L_GLOBAL) { // } ??? re-examine */
if (df->df_sc == GLOBAL
@@ -910,14 +926,15 @@ store_val(vl, tp)
- static variable
- local variable
*/
load_val(expr, rlval)
register struct expr *expr; /* expression containing the value */
int rlval; /* generate either LVAL or RVAL */
/* expr -> expression containing the value
rlval -> generate either LVAL or RVAL
*/
void load_val(struct expr *expr, int rlval)
{
register struct type *tp = expr->ex_type;
struct type *tp = expr->ex_type;
int rvalue = (rlval == RVAL && expr->ex_lvalue != 0);
register int inword = 0, indword = 0;
register arith val = expr->VL_VALUE;
int inword = 0, indword = 0;
arith val = expr->VL_VALUE;
if (expr->ex_type->tp_fund == FLOAT
|| expr->ex_type->tp_fund == DOUBLE
@@ -957,8 +974,8 @@ load_val(expr, rlval)
}
}
else {
register struct idf *id = expr->VL_IDF;
register struct def *df = id->id_def;
struct idf *id = expr->VL_IDF;
struct def *df = id->id_def;
int fund = df->df_type->tp_fund;
ASSERT(ISNAME(expr));
@@ -1009,8 +1026,7 @@ load_val(expr, rlval)
}
}
load_cst(val, siz)
arith val, siz;
void load_cst(arith val, arith siz)
{
if ((int)siz <= (int)word_size)
C_loc(val);
@@ -1027,8 +1043,7 @@ load_cst(val, siz)
}
}
operands(expr, gencode)
register struct expr *expr;
void operands(struct expr *expr, int gencode)
{
EVAL(expr->OP_LEFT, RVAL, gencode, NO_LABEL, NO_LABEL);
EVAL(expr->OP_RIGHT, RVAL, gencode, NO_LABEL, NO_LABEL);

View File

@@ -0,0 +1,20 @@
/*
* The Amsterdam Compiler Kit
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef LANG_CEM_CEMCOM_ANSI_EVAL_H
#define LANG_CEM_CEMCOM_ANSI_EVAL_H
/* lang/cem/cemcom.ansi/eval.c */
void EVAL(struct expr *expr, int val, int code, label true_label, label false_label);
void compare(int relop, label lbl);
void truthvalue(int relop);
void assop(struct type *type, int oper);
void ptr_add(arith size);
void store_val(struct value *vl, struct type *tp);
void load_val(struct expr *expr, int rlval);
void load_cst(arith val, arith siz);
void operands(struct expr *expr, int gencode);
#endif /* LANG_CEM_CEMCOM_ANSI_EVAL_H */

View File

@@ -5,6 +5,8 @@
/* $Id$ */
/* EXPRESSION TREE HANDLING */
#include <stdlib.h>
#include "lint.h"
#include "debug.h"
#include "assert.h"
@@ -24,14 +26,16 @@
#include "sizes.h"
#include "level.h"
#include "use_tmp.h"
#include "cstoper.h"
#include "idf_loc.h"
#include "expr_loc.h"
#include "error.h"
#include <symbol2str.h>
extern char *symbol2str();
extern char options[];
extern int InSizeof;
int
rank_of(oper)
int oper;
int rank_of(int oper)
{
/* The rank of the operator oper is returned.
*/
@@ -100,13 +104,12 @@ rank_of(oper)
/*NOTREACHED*/
}
dot2expr(expp)
struct expr **expp;
void dot2expr(struct expr **expp)
{
/* The token in dot is converted into an expression, a
pointer to which is stored in *expp.
*/
register struct expr *ex = new_expr();
struct expr *ex = new_expr();
*expp = ex;
ex->ex_file = dot.tk_file;
@@ -127,16 +130,15 @@ dot2expr(expp)
}
}
idf2expr(expr)
register struct expr *expr;
void idf2expr(struct expr *expr)
{
/* Dot contains an identifier which is turned into an
expression.
Note that this constitutes an applied occurrence of
the identifier.
*/
register struct idf *idf = dot.tk_idf; /* != 0*/
register struct def *def = idf->id_def;
struct idf *idf = dot.tk_idf; /* != 0*/
struct def *def = idf->id_def;
if (def == 0) {
if (AHEAD == '(') {
@@ -197,15 +199,12 @@ idf2expr(expr)
}
}
string2expr(expp, str, len)
register struct expr **expp;
int len;
char *str;
void string2expr(struct expr **expp, char *str, int len)
{
/* The string in the argument is converted into an expression,
a pointer to which is stored in *expp.
*/
register struct expr *ex = new_expr();
struct expr *ex = new_expr();
*expp = ex;
ex->ex_file = dot.tk_file;
@@ -219,8 +218,7 @@ string2expr(expp, str, len)
ex->SG_LEN = len;
}
int2expr(expr)
struct expr *expr;
void int2expr(struct expr *expr)
{
/* Dot contains an integer constant which is turned
into an expression.
@@ -228,13 +226,12 @@ int2expr(expr)
fill_int_expr(expr, dot.tk_ival, dot.tk_fund);
}
float2expr(expr)
register struct expr *expr;
void float2expr(struct expr *expr)
{
/* Dot contains a floating point constant which is turned
into an expression.
*/
register int fund;
int fund;
fund = dot.tk_fund;
switch (fund) {
@@ -258,15 +255,12 @@ float2expr(expr)
expr_warning(expr,"internal floating point overflow");
}
struct expr*
intexpr(ivalue, fund)
arith ivalue;
int fund;
struct expr *intexpr(arith ivalue, int fund)
{
/* The value ivalue is turned into an integer expression of
the size indicated by fund.
*/
register struct expr *expr = new_expr();
struct expr *expr = new_expr();
expr->ex_file = dot.tk_file;
expr->ex_line = dot.tk_line;
@@ -274,10 +268,7 @@ intexpr(ivalue, fund)
return expr;
}
fill_int_expr(ex, ivalue, fund)
register struct expr *ex;
arith ivalue;
int fund;
void fill_int_expr(struct expr *ex, arith ivalue, int fund)
{
/* Details derived from ivalue and fund are put into the
constant integer expression ex.
@@ -305,10 +296,7 @@ fill_int_expr(ex, ivalue, fund)
cut_size(ex);
}
struct expr *
new_oper(tp, e1, oper, e2)
struct type *tp;
register struct expr *e1, *e2;
struct expr *new_oper(struct type *tp, struct expr *e1, int oper, struct expr *e2)
{
/* A new expression is constructed which consists of the
operator oper which has e1 and e2 as operands; for a
@@ -316,11 +304,11 @@ new_oper(tp, e1, oper, e2)
During the construction of the right recursive initialisation
tree it is possible for e2 to be NILEXPR.
*/
register struct expr *expr = new_expr();
register struct oper *op;
struct expr *expr = new_expr();
struct oper *op;
if (e2) {
register struct expr *e = e2;
struct expr *e = e2;
while (e->ex_class == Oper && e->OP_LEFT)
e = e->OP_LEFT;
@@ -329,7 +317,7 @@ new_oper(tp, e1, oper, e2)
}
else
if (e1) {
register struct expr *e = e1;
struct expr *e = e1;
while (e->ex_class == Oper && e->OP_RIGHT)
e = e->OP_RIGHT;
@@ -371,8 +359,7 @@ new_oper(tp, e1, oper, e2)
return expr;
}
chk_cst_expr(expp)
struct expr **expp;
void chk_cst_expr(struct expr **expp)
{
/* The expression expr is checked for constancy.
@@ -394,7 +381,7 @@ chk_cst_expr(expp)
Special problems (of which there is only one, sizeof in
Preprocessor #if) have to be dealt with locally
*/
register struct expr *expr = *expp;
struct expr *expr = *expp;
#ifdef DEBUG
print_expr("constant_expression", expr);
@@ -417,9 +404,7 @@ chk_cst_expr(expp)
erroneous2int(expp);
}
init_expression(eppp, expr)
register struct expr ***eppp;
struct expr *expr;
void init_expression(struct expr ***eppp, struct expr *expr)
{
/* The expression expr is added to the tree designated
indirectly by **eppp.
@@ -437,9 +422,7 @@ init_expression(eppp, expr)
*eppp = &(**eppp)->OP_RIGHT;
}
int
is_ld_cst(expr)
register struct expr *expr;
int is_ld_cst(struct expr *expr)
{
/* An expression is a `load-time constant' if it is of the form
<idf> +/- <integral> or <integral>.
@@ -451,9 +434,7 @@ is_ld_cst(expr)
return expr->ex_lvalue == 0 && expr->ex_class == Value;
}
int
is_cp_cst(expr)
struct expr *expr;
int is_cp_cst(struct expr *expr)
{
/* An expression is a `compile-time constant' if it is a
load-time constant, and the idf is not there.
@@ -461,9 +442,7 @@ is_cp_cst(expr)
return is_ld_cst(expr) && expr->VL_CLASS == Const;
}
int
is_fp_cst(expr)
struct expr *expr;
int is_fp_cst(struct expr *expr)
{
/* An expression is a `floating-point constant' if it consists
of the float only.
@@ -471,9 +450,7 @@ is_fp_cst(expr)
return expr->ex_class == Float;
}
int
is_zero_cst(expr)
register struct expr *expr;
int is_zero_cst(struct expr *expr)
{
flt_arith var;
@@ -485,10 +462,10 @@ is_zero_cst(expr)
return flt_cmp(&var, &(expr->FL_ARITH)) == 0;
}
/*NOTREACHED*/
return 0;
}
free_expression(expr)
register struct expr *expr;
void free_expression(struct expr *expr)
{
/* The expression expr is freed recursively.
*/

View File

@@ -9,6 +9,14 @@
a union of various goodies, we define them first; so be patient.
*/
#ifndef LANG_CEM_CEMCOM_ANSI_EXPR_STR
#define LANG_CEM_CEMCOM_ANSI_EXPR_STR
#include "idf.h"
#include "arith.h"
#include <em_label.h>
#include <flt_arith.h>
/* classes of value */
#define Const 1
#define Name 2
@@ -97,3 +105,4 @@ extern struct expr *intexpr(), *new_oper();
/* ALLOCDEF "expr" 20 */
#endif /* LANG_CEM_CEMCOM_ANSI_EXPR_STR */

View File

@@ -0,0 +1,27 @@
/*
* The Amsterdam Compiler Kit
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef LANG_CEM_CEMCOM_ANSI_EXPR_H
#define LANG_CEM_CEMCOM_ANSI_EXPR_H
/* lang/cem/cemcom.ansi/expr.c */
int rank_of(int oper);
void dot2expr(struct expr **expp);
void idf2expr(struct expr *expr);
void string2expr(struct expr **expp, char *str, int len);
void int2expr(struct expr *expr);
void float2expr(struct expr *expr);
struct expr *intexpr(arith ivalue, int fund);
void fill_int_expr(struct expr *ex, arith ivalue, int fund);
struct expr *new_oper(struct type *tp, struct expr *e1, int oper, struct expr *e2);
void chk_cst_expr(struct expr **expp);
void init_expression(struct expr ***eppp, struct expr *expr);
int is_ld_cst(struct expr *expr);
int is_cp_cst(struct expr *expr);
int is_fp_cst(struct expr *expr);
int is_zero_cst(struct expr *expr);
void free_expression(struct expr *expr);
#endif /* LANG_CEM_CEMCOM_ANSI_EXPR_H */

View File

@@ -14,12 +14,20 @@
#include "LLlex.h"
#include "type.h"
#include "idf.h"
#include "decspecs.h"
#include "declar.h"
#include "declarator.h"
#include "label.h"
#include "expr.h"
#include "expr_loc.h"
#include "proto_loc.h"
#include "code.h"
#include "sizes.h"
#include "ch3.h"
#include "ch3bin.h"
#include "ch3mon.h"
#include "error.h"
extern struct expr *intexpr();
int InSizeof = 0; /* inside a sizeof- expression */
int ResultKnown = 0; /* result of the expression is already known */
@@ -31,7 +39,7 @@ int ResultKnown = 0; /* result of the expression is already known */
}
/* 3.3.1 */
primary(register struct expr **expp;) :
primary(struct expr **expp;) :
IDENTIFIER
{dot2expr(expp);}
|
@@ -48,10 +56,10 @@ primary(register struct expr **expp;) :
* are concatenated into a single character string
* literal.
*/
string(register struct expr **expp;)
{ register int i, len;
register char *str;
register int fund;
string(struct expr **expp;)
{ int i, len;
char *str;
int fund;
}
:
STRING
@@ -78,7 +86,7 @@ string(register struct expr **expp;)
;
/* 3.3.2 */
postfix_expression(register struct expr **expp;)
postfix_expression(struct expr **expp;)
{ int oper;
struct expr *e1 = 0;
struct idf *idf;
@@ -120,7 +128,7 @@ parameter_list(struct expr **expp;)
%first first_of_type_specifier, type_specifier;
/* 3.3.3 & 3.3.4 */
unary(register struct expr **expp;)
unary(struct expr **expp;)
{struct type *tp; int oper;}
:
%if (first_of_type_specifier(AHEAD) && AHEAD != IDENTIFIER)
@@ -143,7 +151,7 @@ unary(register struct expr **expp;)
* mark it as used.
* extern int i; .... sizeof(i) .... need not have a definition for i
*/
size_of(register struct expr **expp;)
size_of(struct expr **expp;)
{struct type *tp;}
:
SIZEOF { InSizeof++; } /* handle (sizeof(sizeof(int))) too */
@@ -322,7 +330,7 @@ binop(int *oper;) :
{*oper = DOT;}
;
asgnop(register int *oper;):
asgnop(int *oper;):
[ '=' | PLUSAB | MINAB | TIMESAB | DIVAB | MODAB
| LEFTAB | RIGHTAB | ANDAB | XORAB | ORAB ]
{ *oper = DOT; }

View File

@@ -26,8 +26,11 @@
#include "align.h"
#include "Lpars.h"
#include "field.h"
#include "field_loc.h"
#include "eval.h"
#include "util_loc.h"
#include "conversion.h"
arith NewLocal(); /* util.c */
extern arith full_mask[]; /* cstoper.c */
/* Eval_field() evaluates expressions involving bit fields.
@@ -42,14 +45,12 @@ extern arith full_mask[]; /* cstoper.c */
[3] atype: the type in which the bitfield arithmetic is done;
and in which bitfields are stored!
*/
eval_field(expr, code)
struct expr *expr;
int code;
void eval_field(struct expr *expr, int code)
{
int op = expr->OP_OPER;
register struct expr *leftop = expr->OP_LEFT;
register struct expr *rightop = expr->OP_RIGHT;
register struct field *fd = leftop->ex_type->tp_field;
struct expr *leftop = expr->OP_LEFT;
struct expr *rightop = expr->OP_RIGHT;
struct field *fd = leftop->ex_type->tp_field;
struct type *tp = leftop->ex_type->tp_up;
arith tmpvar = 0;
struct type *atype = ( tp->tp_unsigned
@@ -118,7 +119,7 @@ eval_field(expr, code)
retrieval) is on top of stack.
*/
if (tp->tp_unsigned == 0) { /* sign extension */
register arith shift = (int)word_size * 8 - fd->fd_width;
arith shift = (int)word_size * 8 - fd->fd_width;
C_loc(shift);
C_sli(word_size);
@@ -129,12 +130,7 @@ eval_field(expr, code)
}
}
store_field(fd, uns, code, leftop, tmpvar)
register struct field *fd;
int uns;
int code;
register struct expr *leftop;
arith tmpvar;
void store_field(struct field *fd, int uns, int code, struct expr *leftop, arith tmpvar)
{
C_loc(fd->fd_mask);
C_and(word_size);

View File

@@ -0,0 +1,13 @@
/*
* The Amsterdam Compiler Kit
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef LANG_CEM_CEMCOM_ANSI_FIELD_H
#define LANG_CEM_CEMCOM_ANSI_FIELD_H
/* lang/cem/cemcom.ansi/field.c */
void eval_field(struct expr *expr, int code);
void store_field(struct field *fd, int uns, int code, struct expr *leftop, arith tmpvar);
#endif /* LANG_CEM_CEMCOM_ANSI_FIELD_H */

View File

@@ -18,12 +18,16 @@
#include "expr.h"
#include "sizes.h"
#include "Lpars.h"
#include "cstoper.h"
#include "fltcstoper.h"
#include "error.h"
#include "expr_loc.h"
#include <symbol2str.h>
extern int ResultKnown;
extern char *symbol2str();
fltcstbin(expp, oper, expr)
register struct expr **expp, *expr;
void fltcstbin(struct expr **expp, int oper, struct expr *expr)
{
/* The operation oper is performed on the constant
expressions *expp(ld) and expr(ct), and the result restored in

View File

@@ -0,0 +1,12 @@
/*
* The Amsterdam Compiler Kit
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef LANG_CEM_CEMCOM_ANSI_FLTCSTOPER_H
#define LANG_CEM_CEMCOM_ANSI_FLTCSTOPER_H
/* lang/cem/cemcom.ansi/fltcstoper.c */
void fltcstbin(register struct expr **expp, int oper, register struct expr *expr);
#endif /* LANG_CEM_CEMCOM_ANSI_FLTCSTOPER_H */

View File

@@ -7,6 +7,7 @@
#include <stdlib.h>
#include <string.h>
#include "system.h"
#include "lint.h"
#include <em_reg.h>
#include "debug.h"
@@ -31,10 +32,21 @@
#include "sizes.h"
#include "Lpars.h"
#include "assert.h"
#include "ch3.h"
#include "code_c.h"
#include "conversion.h"
#include "print.h"
#include "idf_loc.h"
#include "struct_loc.h"
#include "proto_loc.h"
#include "util_loc.h"
#include "error.h"
#include "stab.h"
#include "stack_loc.h"
#include <symbol2str.h>
extern char options[];
extern arith NewLocal();
extern char *symbol2str();
#ifdef DEBUG
#define IDF_DEBUG
@@ -42,8 +54,7 @@ extern char *symbol2str();
#include <idf_pkg.body>
struct idf *
gen_idf()
struct idf *gen_idf()
{
/* A new idf is created out of nowhere, to serve as an
anonymous name.
@@ -57,16 +68,12 @@ gen_idf()
return str2idf(s, 0);
}
int
is_anon_idf(idf)
struct idf *idf;
int is_anon_idf(struct idf *idf)
{
return idf->id_text[0] == '#';
}
declare_idf(ds, dc, lvl)
struct decspecs *ds;
struct declarator *dc;
void declare_idf(struct decspecs *ds, struct declarator *dc, int lvl)
{
/* The identifier inside dc is declared on the level lvl, with
properties deduced from the decspecs ds and the declarator
@@ -76,14 +83,14 @@ declare_idf(ds, dc, lvl)
This routine implements the rich semantics of C
declarations.
*/
register struct idf *idf = dc->dc_idf;
register int sc = ds->ds_sc;
struct idf *idf = dc->dc_idf;
int sc = ds->ds_sc;
/* This local copy is essential:
char b(), c;
makes b GLOBAL and c AUTO.
*/
register struct def *def = idf->id_def; /* may be NULL */
register struct type *type;
struct def *def = idf->id_def; /* may be NULL */
struct type *type;
struct stack_level *stl = stack_level_of(lvl);
char formal_array = 0;
@@ -97,8 +104,8 @@ declare_idf(ds, dc, lvl)
else {
/* combine the decspecs and the declarator into one type */
type = declare_type(ds->ds_type, dc);
if (type->tp_size <= (arith)0 &&
actual_declaration(sc, type)) {
if ( (type->tp_size <= (arith)0) &&
actual_declaration(sc, type)) {
if (type->tp_size == (arith) -1) {
/* the type is not yet known,
but it has to be:
@@ -204,7 +211,7 @@ declare_idf(ds, dc, lvl)
def->df_line = idf->id_line;
}
else { /* fill in the def block */
register struct def *newdef = new_def();
struct def *newdef = new_def();
newdef->next = def;
newdef->df_level = lvl;
@@ -253,13 +260,11 @@ declare_idf(ds, dc, lvl)
}
}
actual_declaration(sc, tp)
int sc;
struct type *tp;
int actual_declaration(int sc, struct type *tp)
{
/* An actual_declaration needs space, right here and now.
*/
register int fund = tp->tp_fund;
int fund = tp->tp_fund;
if (sc == ENUM || sc == TYPEDEF) /* virtual declarations */
return 0;
@@ -274,9 +279,7 @@ actual_declaration(sc, tp)
return 1;
}
global_redecl(idf, new_sc, tp)
register struct idf *idf;
struct type *tp;
void global_redecl(struct idf *idf, int new_sc, struct type *tp)
{
/* A global identifier may be declared several times,
provided the declarations do not conflict; they might
@@ -284,7 +287,7 @@ global_redecl(idf, new_sc, tp)
an array) or they might conflict or supplement each other
in storage class.
*/
register struct def *def = idf->id_def;
struct def *def = idf->id_def;
while (def->df_level != L_GLOBAL) def = def->next;
if (!equal_type(tp, def->df_type, 0, 1)) {
@@ -368,10 +371,7 @@ global_redecl(idf, new_sc, tp)
}
}
int
good_formal(def, idf)
register struct def *def;
register struct idf *idf;
int good_formal(struct def *def, struct idf *idf)
{
/* Succeeds if def is a proper L_FORMAL1 definition and
gives an error message otherwise.
@@ -385,12 +385,11 @@ good_formal(def, idf)
return 1;
}
declare_params(dc)
struct declarator *dc;
void declare_params(struct declarator *dc)
{
/* Declares the formal parameters if they exist.
*/
register struct formal *fm = dc->dc_formal;
struct formal *fm = dc->dc_formal;
while (fm) {
declare_parameter(fm->fm_idf);
@@ -398,12 +397,11 @@ declare_params(dc)
}
}
idf_initialized(idf)
register struct idf *idf;
void idf_initialized(struct idf *idf)
{
/* The topmost definition of idf is set to initialized.
*/
register struct def *def = idf->id_def; /* the topmost */
struct def *def = idf->id_def; /* the topmost */
while (def->df_level <= L_PROTO) def = def->next;
if (def->df_initialized)
@@ -415,18 +413,14 @@ idf_initialized(idf)
def->df_initialized = 1;
}
declare_parameter(idf)
struct idf *idf;
void declare_parameter(struct idf *idf)
{
/* idf is declared as a formal.
*/
add_def(idf, FORMAL, int_type, level);
}
declare_enum(tp, idf, l)
struct type *tp;
struct idf *idf;
arith l;
void declare_enum(struct type *tp, struct idf *idf, arith l)
{
/* idf is declared as an enum constant with value l.
*/
@@ -434,13 +428,11 @@ declare_enum(tp, idf, l)
idf->id_def->df_address = l;
}
check_formals(idf, dc)
struct idf *idf;
struct declarator *dc;
void check_formals(struct idf *idf, struct declarator *dc)
{
register struct formal *fm = dc->dc_formal;
register struct proto *pl = idf->id_def->df_type->tp_proto;
register struct decl_unary *du = dc->dc_decl_unary;
struct formal *fm = dc->dc_formal;
struct proto *pl = idf->id_def->df_type->tp_proto;
struct decl_unary *du = dc->dc_decl_unary;
if (!du) { /* error or typdef'ed function */
error("illegal definition of %s", idf->id_text);
@@ -483,7 +475,7 @@ check_formals(idf, dc)
error("incorrect number of parameters");
}
} else { /* make a pseudo-prototype */
register struct proto *lpl = new_proto();
struct proto *lpl = new_proto();
if (!options['o'])
warning("'%s' old-fashioned function definition"
@@ -512,18 +504,16 @@ check_formals(idf, dc)
dc->dc_formal = 0;
}
declare_formals(idf, fp)
struct idf *idf;
arith *fp;
void declare_formals(struct idf *idf, arith *fp)
{
/* Declares those formals as int that haven't been declared
by the user.
An address is assigned to each formal parameter.
The total size of the formals is returned in *fp;
*/
register struct stack_entry *se = stack_level_of(L_FORMAL1)->sl_entry;
struct stack_entry *se = stack_level_of(L_FORMAL1)->sl_entry;
arith f_offset = (arith)0;
register int nparams = 0;
int nparams = 0;
int hasproto;
struct def *df = idf->id_def;
@@ -590,9 +580,7 @@ declare_formals(idf, fp)
*fp = f_offset;
}
int
regtype(tp)
struct type *tp;
int regtype(struct type *tp)
{
switch(tp->tp_fund) {
case INT:
@@ -608,11 +596,7 @@ regtype(tp)
return -1;
}
add_def(idf, sc, tp, lvl)
struct idf *idf;
struct type *tp;
int lvl;
int sc;
void add_def(struct idf *idf, int sc, struct type *tp, int lvl)
{
/* The identifier idf is declared on level lvl with storage
class sc and type tp, through a faked C declaration.
@@ -629,13 +613,12 @@ add_def(idf, sc, tp, lvl)
declare_idf(&Ds, &Dc, lvl);
}
update_ahead(idf)
register struct idf *idf;
void update_ahead(struct idf *idf)
{
/* The tk_symb of the token ahead is updated in the light of new
information about the identifier idf.
*/
register int tk_symb = AHEAD;
int tk_symb = AHEAD;
if ( (tk_symb == IDENTIFIER || tk_symb == TYPE_IDENTIFIER) &&
ahead.tk_idf == idf
@@ -644,8 +627,7 @@ update_ahead(idf)
TYPE_IDENTIFIER : IDENTIFIER;
}
free_formals(fm)
register struct formal *fm;
void free_formals(struct formal *fm)
{
while (fm) {
struct formal *tmp = fm->next;

View File

@@ -4,6 +4,8 @@
*/
/* $Id$ */
/* IDENTIFIER DESCRIPTOR */
#ifndef LANG_CEM_CEMCOM_ANSI_IDF_STR
#define LANG_CEM_CEMCOM_ANSI_IDF_STR
#include "nopp.h"
@@ -47,3 +49,5 @@ struct dependency {
extern int level;
extern struct idf *gen_idf();
#endif /* LANG_CEM_CEMCOM_ANSI_IDF_STR */

View File

@@ -0,0 +1,33 @@
/*
* The Amsterdam Compiler Kit
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef LANG_CEM_CEMCOM_ANSI_IDF_H
#define LANG_CEM_CEMCOM_ANSI_IDF_H
#include "declar.h"
#include "decspecs.h"
#include "def.h"
/* lang/cem/cemcom.ansi/idf.c */
void init_idf(void);
struct idf *str2idf(char tg[], int cpy);
struct idf *gen_idf(void);
int is_anon_idf(struct idf *idf);
void declare_idf(struct decspecs *ds, struct declarator *dc, int lvl);
int actual_declaration(int sc, struct type *tp);
void global_redecl(struct idf *idf, int new_sc, struct type *tp);
int good_formal(struct def *def, struct idf *idf);
void declare_params(struct declarator *dc);
void idf_initialized(struct idf *idf);
void declare_parameter(struct idf *idf);
void declare_enum(struct type *tp, struct idf *idf, arith l);
void check_formals(struct idf *idf, struct declarator *dc);
void declare_formals(struct idf *idf, arith *fp);
int regtype(struct type *tp);
void add_def(struct idf *idf, int sc, struct type *tp, int lvl);
void update_ahead(struct idf *idf);
void free_formals(struct formal *fm);
#endif /* LANG_CEM_CEMCOM_ANSI_IDF_H */

View File

@@ -13,11 +13,17 @@
#include <system.h>
#include <alloc.h>
#include <time.h>
#include <flt_arith.h>
#include <em_label.h>
#include "class.h"
#include "macro.h"
#include "idf.h"
extern char *sprint();
#include "arith.h"
#include "print.h"
#include "expr.h"
#include "error.h"
#include "domacro.h"
struct mkey {
char *mk_reserved;
@@ -28,6 +34,7 @@ struct mkey {
{"else", K_ELSE},
{"endif", K_ENDIF},
{"error", K_ERROR},
{"warning", K_WARNING},
{"if", K_IF},
{"ifdef", K_IFDEF},
{"ifndef", K_IFNDEF},
@@ -38,7 +45,7 @@ struct mkey {
{0, K_UNKNOWN}
};
init_pp()
void init_pp()
{
static char *months[12] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
@@ -55,10 +62,10 @@ init_pp()
id_resmac field of the identifier.
*/
{
register struct mkey *mk = &mkey[0];
struct mkey *mk = &mkey[0];
while (mk->mk_reserved) {
register struct idf *idf = str2idf(mk->mk_reserved, 0);
struct idf *idf = str2idf(mk->mk_reserved, 0);
if (idf->id_resmac)
fatal("maximum identifier length insufficient");

View File

@@ -0,0 +1,12 @@
/*
* The Amsterdam Compiler Kit
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef LANG_CEM_CEMCOM_ANSI_INIT_H
#define LANG_CEM_CEMCOM_ANSI_INIT_H
/* lang/cem/cemcom.ansi/init.c */
void init_pp();
#endif /* LANG_CEM_CEMCOM_ANSI_INIT_H */

View File

@@ -7,9 +7,16 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "idf.h"
#include "arith.h"
#include <em_label.h>
#include <flt_arith.h>
#include "expr.h"
#include "inputtype.h"
#include "file_info.h"
#include "input.h"
#include "replace_loc.h"
#include "error.h"
#define INP_PUSHBACK 3
#define INP_TYPE struct file_info

View File

@@ -3,6 +3,9 @@
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* $Id$ */
#ifndef LANG_CEM_CEMCOM_ANSI_INPUT_H
#define LANG_CEM_CEMCOM_ANSI_INPUT_H
#define INP_PUSHBACK 3
#include <inp_pkg.spec>
@@ -13,3 +16,5 @@
extern int LexSave; /* last character read by GetChar */
extern int GetChar(); /* character input, with trigraph parsing */
#endif /* LANG_CEM_CEMCOM_ANSI_INPUT_H */

View File

@@ -14,6 +14,8 @@
#include "l_lint.h"
#endif /* LINT */
#include "debug.h"
#include <stdio.h>
#include <stdlib.h>
#include <alloc.h>
#include <assert.h>
#include "nobitfield.h"
@@ -21,30 +23,36 @@
#include "arith.h"
#include "label.h"
#include "expr.h"
#include "expr_loc.h"
#include "type.h"
#include "proto.h"
#include "struct.h"
#include "struct_loc.h"
#include "field.h"
#include "assert.h"
#include "Lpars.h"
#include "sizes.h"
#include "align.h"
#include "idf.h"
#include "idf_loc.h"
#include "level.h"
#include "def.h"
#include "ch3.h"
#include "ival.h"
#include "LLlex.h"
#include "estack.h"
#include "conversion.h"
#include "cstoper.h"
#include "error.h"
#define con_nullbyte() C_con_ucon("0", (arith)1)
#define aggregate_type(tp) ((tp)->tp_fund == ARRAY || (tp)->tp_fund == STRUCT)
char *long2str();
char *strncpy();
extern char options[];
static int gen_error;
static int pack_level;
struct type **gen_tphead(), **gen_tpmiddle();
struct sdef *gen_align_to_next();
struct e_stack *p_stack;
}
@@ -52,7 +60,7 @@ struct e_stack *p_stack;
*/
/* 3.5 */
initial_value(register struct type **tpp; register struct expr **expp;) :
initial_value(struct type **tpp; struct expr **expp;) :
{ if (tpp) gen_tpcheck(tpp); }
[
{ if (pack_level == 0) gen_error = 0; }
@@ -122,10 +130,9 @@ initial_value_list(register struct type **tpp; struct expr **expp;)
;
{
gen_tpcheck(tpp)
struct type **tpp;
void gen_tpcheck(struct type **tpp)
{
register struct type *tp;
struct type *tp;
if (gen_error) return;
switch((tp = *tpp)->tp_fund) {
@@ -147,11 +154,9 @@ gen_tpcheck(tpp)
}
}
gen_simple_exp(tpp, expp)
struct type **tpp;
struct expr **expp;
void gen_simple_exp(struct type **tpp, struct expr **expp)
{
register struct type *tp;
struct type *tp;
if (gen_error) return;
tp = *tpp;
@@ -177,12 +182,9 @@ gen_simple_exp(tpp, expp)
}
}
struct type **
arr_elem(tpp, p)
struct type **tpp;
struct e_stack *p;
struct type **arr_elem(struct type **tpp, struct e_stack *p)
{
register struct type *tp = *tpp;
struct type *tp = *tpp;
if (tp->tp_up->tp_fund == CHAR && AHEAD == STRING && p->elem_count == 1) {
p->nelem = 1;
@@ -193,10 +195,7 @@ arr_elem(tpp, p)
return gen_tphead(&(tp->tp_up), 1);
}
struct sdef *
next_field(sd, p)
register struct sdef *sd;
register struct e_stack *p;
struct sdef *next_field(struct sdef *sd, struct e_stack *p)
{
if (sd->sd_sdef)
p->bytes_upto_here += zero_bytes(sd);
@@ -206,13 +205,11 @@ next_field(sd, p)
return sd->sd_sdef;
}
struct type **
gen_tphead(tpp, nest)
struct type **tpp;
struct type **gen_tphead(struct type **tpp, int nest)
{
register struct type *tp = *tpp;
register struct e_stack *p;
register struct sdef *sd;
struct type *tp = *tpp;
struct e_stack *p;
struct sdef *sd;
if (tpp && *tpp == error_type) {
gen_error = pack_level;
@@ -283,12 +280,11 @@ gen_tphead(tpp, nest)
}
}
struct type **
gen_tpmiddle()
struct type **gen_tpmiddle()
{
register struct type *tp;
register struct sdef *sd;
register struct e_stack *p = p_stack;
struct type *tp;
struct sdef *sd;
struct e_stack *p = p_stack;
if (gen_error) {
if (p) return p->s_tpp;
@@ -342,11 +338,9 @@ again:
}
}
struct sdef *
gen_align_to_next(p)
register struct e_stack *p;
struct sdef *gen_align_to_next(struct e_stack *p)
{
register struct sdef *sd = p->s_def;
struct sdef *sd = p->s_def;
if (! sd) return sd;
#ifndef NOBITFIELD
@@ -361,11 +355,11 @@ gen_align_to_next(p)
return sd;
}
gen_tpend()
void gen_tpend()
{
register struct e_stack *p = p_stack;
register struct type *tp;
register struct sdef *sd;
struct e_stack *p = p_stack;
struct type *tp;
struct sdef *sd;
int getout = 0;
while (!getout && p) {
@@ -417,11 +411,9 @@ gen_tpend()
In the latter case, only the first member is initialised and
the rest is zeroed.
*/
check_and_pad(expp, tpp)
struct type **tpp;
struct expr **expp;
void check_and_pad(struct expr **expp, struct type **tpp)
{
register struct type *tp = *tpp;
struct type *tp = *tpp;
if (tp->tp_fund == ARRAY) {
check_and_pad(expp, &(tp->tp_up)); /* first member */
@@ -432,7 +424,7 @@ check_and_pad(expp, tpp)
tp = *tpp = construct_type(ARRAY, tp->tp_up,
0, (arith)1, NO_PROTO);
else {
register int dim = tp->tp_size / tp->tp_up->tp_size;
int dim = tp->tp_size / tp->tp_up->tp_size;
/* pad remaining members with zeroes */
while (--dim > 0)
pad(tp->tp_up);
@@ -440,13 +432,13 @@ check_and_pad(expp, tpp)
}
else
if (tp->tp_fund == STRUCT) {
register struct sdef *sd = tp->tp_sdef;
struct sdef *sd = tp->tp_sdef;
check_and_pad(expp, &(sd->sd_type));
/* next selector is aligned by adding extra zeroes */
if (sd->sd_sdef)
zero_bytes(sd);
while (sd = sd->sd_sdef) { /* pad remaining selectors */
while ( (sd = sd->sd_sdef) ) { /* pad remaining selectors */
pad(sd->sd_type);
if (sd->sd_sdef)
zero_bytes(sd);
@@ -454,7 +446,7 @@ check_and_pad(expp, tpp)
}
else if (tp->tp_fund == UNION) {
/* only the first selector can be initialized */
register struct sdef *sd = tp->tp_sdef;
struct sdef *sd = tp->tp_sdef;
check_and_pad(expp, &(sd->sd_type));
}
@@ -465,11 +457,10 @@ check_and_pad(expp, tpp)
/* pad() fills an element of type tp with zeroes.
If the element is an aggregate, pad() is called recursively.
*/
pad(tpx)
struct type *tpx;
void pad(struct type *tpx)
{
register struct type *tp = tpx;
register arith sz = tp->tp_size;
struct type *tp = tpx;
arith sz = tp->tp_size;
gen_tpcheck(&tpx);
if (gen_error) return;
@@ -496,16 +487,14 @@ pad(tpx)
No further comment is needed to explain the internal structure
of this straightforward function.
*/
check_ival(expp, tp)
register struct type *tp;
struct expr **expp;
void check_ival(struct expr **expp, struct type *tp)
{
/* The philosophy here is that ch3cast puts an explicit
conversion node in front of the expression if the types
are not compatible. In this case, the initialisation
expression is no longer a constant.
*/
register struct expr *expr = *expp;
struct expr *expr = *expp;
switch (tp->tp_fund) {
case CHAR:
@@ -609,13 +598,13 @@ and also to prevent runtime coercions for compile-time constants.
a string constant.
Alignment is taken care of.
*/
ch_array(tpp, ex)
struct type **tpp; /* type tp = array of characters */
struct expr *ex;
/* tpp -> type tp = array of characters */
void ch_array(struct type **tpp, struct expr *ex)
{
register struct type *tp = *tpp;
register int length = ex->SG_LEN, i;
register char *to, *from, *s;
struct type *tp = *tpp;
int length = ex->SG_LEN, i;
char *to, *from, *s;
ASSERT(ex->ex_class == String);
if (tp->tp_size == (arith)-1) {
@@ -651,10 +640,7 @@ ch_array(tpp, ex)
/* As long as some parts of the pipeline cannot handle very long string
constants, string constants are written out in chunks
*/
str_cst(str, len, inrom)
register char *str;
register int len;
int inrom;
void str_cst(char *str, int len, int inrom)
{
int chunksize = ((127 + (int) word_size) / (int) word_size) * (int) word_size;
@@ -678,9 +664,7 @@ str_cst(str, len, inrom)
"throws" the result of "field" out if the current selector
is the last of this number of fields stored at the same address.
*/
put_bf(tp, val)
struct type *tp;
arith val;
void put_bf(struct type *tp, arith val)
{
static long field = (arith)0;
static arith offset = (arith)-1;
@@ -708,9 +692,7 @@ put_bf(tp, val)
}
#endif /* NOBITFIELD */
int
zero_bytes(sd)
register struct sdef *sd;
int zero_bytes(struct sdef *sd)
{
/* fills the space between a selector of a struct
and the next selector of that struct with zero-bytes.
@@ -724,10 +706,7 @@ zero_bytes(sd)
return count;
}
int
valid_type(tp, str)
struct type *tp;
char *str;
int valid_type(struct type *tp, char *str)
{
ASSERT(tp!=(struct type *)0);
if (tp->tp_size < 0) {
@@ -737,10 +716,9 @@ valid_type(tp, str)
return 1;
}
con_int(ex)
register struct expr *ex;
void con_int(struct expr *ex)
{
register struct type *tp = ex->ex_type;
struct type *tp = ex->ex_type;
ASSERT(is_cp_cst(ex));
if (tp->tp_unsigned)
@@ -751,14 +729,13 @@ con_int(ex)
C_con_icon(long2str((long)ex->VL_VALUE, 10), tp->tp_size);
}
illegal_init_cst(ex)
struct expr *ex;
void illegal_init_cst(struct expr *ex)
{
expr_error(ex, "illegal initialization constant");
gen_error = pack_level;
}
too_many_initialisers()
void too_many_initialisers()
{
error("too many initializers");
gen_error = pack_level;

View File

@@ -0,0 +1,66 @@
/*
* The Amsterdam Compiler Kit
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef LANG_CEM_CEMCOM_ANSI_IVAL_H
#define LANG_CEM_CEMCOM_ANSI_IVAL_H
#include "estack.h"
/* lang/cem/cemcom.ansi/ival.g */
void gen_tpcheck(struct type **tpp);
void gen_simple_exp(struct type **tpp, struct expr **expp);
struct type **arr_elem(struct type **tpp, struct e_stack *p);
struct sdef *next_field(struct sdef *sd, struct e_stack *p);
struct type **gen_tphead(struct type **tpp, int nest);
struct type **gen_tpmiddle();
struct sdef *gen_align_to_next(struct e_stack *p);
void gen_tpend();
/* check_and_pad() is given a simple initialisation expression
where the type can be either a simple or an aggregate type.
In the latter case, only the first member is initialised and
the rest is zeroed.
*/
void check_and_pad(struct expr **expp, struct type **tpp);
/* pad() fills an element of type tp with zeroes.
If the element is an aggregate, pad() is called recursively.
*/
void pad(struct type *tpx);
/* check_ival() checks whether the initialisation of an element
of a fundamental type is legal and, if so, performs the initialisation
by directly generating the necessary code.
No further comment is needed to explain the internal structure
of this straightforward function.
*/
void check_ival(struct expr **expp, struct type *tp);
/* ch_array() initialises an array of characters when given
a string constant.
Alignment is taken care of.
*/
/* tpp -> type tp = array of characters */
void ch_array(struct type **tpp, struct expr *ex);
/* As long as some parts of the pipeline cannot handle very long string
constants, string constants are written out in chunks
*/
void str_cst(char *str, int len, int inrom);
#ifndef NOBITFIELD
/* put_bf() takes care of the initialisation of (bit-)field
selectors of a struct: each time such an initialisation takes place,
put_bf() is called instead of the normal code generating routines.
Put_bf() stores the given integral value into "field" and
"throws" the result of "field" out if the current selector
is the last of this number of fields stored at the same address.
*/
void put_bf(struct type *tp, arith val);
#endif /* NOBITFIELD */
int zero_bytes(struct sdef *sd);
int valid_type(struct type *tp, char *str);
void con_int(struct expr *ex);
void illegal_init_cst(struct expr *ex);
void too_many_initialisers();
#endif /* LANG_CEM_CEMCOM_ANSI_IVAL_H */

View File

@@ -14,6 +14,8 @@
* to terminate the compilation process.
*/
#include "blocks.h"
#define store_block(sz, al)
#define load_block(sz, al)

View File

@@ -26,8 +26,9 @@
#include "type.h"
#include "level.h"
#include "l_state.h"
#include "conversion.h"
#include <symbol2str.h>
extern char *symbol2str();
extern struct type *func_type;
PRIVATE lint_enum_arith();

View File

@@ -13,18 +13,20 @@
#include "def.h"
#include "type.h"
#include "stack.h"
#include "error.h"
#include "idf_loc.h"
#include "stack_loc.h"
extern char options[];
enter_label(idf, defining)
register struct idf *idf;
void enter_label(struct idf *idf, int defining)
{
/* The identifier idf is entered as a label. If it is new,
it is entered into the idf list with the largest possible
scope, i.e., on the lowest possible level.
If defining, the label comes from a label statement.
*/
register struct def *def = idf->id_label;
struct def *def = idf->id_label;
if (def) {
if (defining && def->df_initialized)
@@ -44,8 +46,7 @@ enter_label(idf, defining)
def->df_initialized = 1;
}
unstack_label(idf)
register struct idf *idf;
void unstack_label(struct idf *idf)
{
/* The scope in which the label idf occurred is left.
*/

View File

@@ -4,6 +4,8 @@
*/
/* $Id$ */
/* L A B E L D E F I N I T I O N */
#ifndef LANG_CEM_CEMCOM_ANSI_LABEL_H
#define LANG_CEM_CEMCOM_ANSI_LABEL_H
#include <em_label.h> /* obtain definition of "label" */
@@ -26,3 +28,10 @@ extern label datlab_count;
not be there, and if it is there, it may be from a
declaration or another application.
*/
struct idf;
void enter_label(struct idf *idf, int defining);
void unstack_label(struct idf *idf);
#endif /* LANG_CEM_CEMCOM_ANSI_LABEL_H */

View File

@@ -48,5 +48,6 @@ struct macro {
#define K_LINE 10
#define K_PRAGMA 11
#define K_UNDEF 12
#define K_WARNING 13
#define K_FILE 100 /* for dependency generator */
#endif /* NOPP */

View File

@@ -5,10 +5,13 @@
/* $Id$ */
/* MAIN PROGRAM */
#include <string.h>
#include "lint.h"
#include <system.h>
#include "print.h"
#include "debug.h"
#include "nopp.h"
#include "label.h"
#include "trgt_sizes.h"
#include "use_tmp.h"
#include "inputtype.h"
@@ -29,9 +32,21 @@
#include "align.h"
#include "macro.h"
#include "assert.h"
#include "code_c.h"
#include "cstoper.h"
#include "init.h"
#include "options.h"
#include "main.h"
#include "error.h"
#include "stack.h"
#include "stack_loc.h"
#include "idf_loc.h"
#include "program.h"
#include "tokenname.h"
#include <symbol2str.h>
extern struct tokenname tkidf[];
extern char *symbol2str();
extern char options[128];
#ifndef NOPP
@@ -83,8 +98,7 @@ arith ifval; /* ifval will contain the result of the #if expression */
char *prog_name;
main(argc, argv)
char *argv[];
int main(int argc, char *argv[])
{
/* parse and interpret the command line options */
prog_name = argv[0];
@@ -139,15 +153,13 @@ main(argc, argv)
#ifndef NOPP
struct dependency *file_head;
extern char *strrchr();
list_dependencies(source)
char *source;
void list_dependencies(char *source)
{
register struct dependency *p = file_head;
struct dependency *p = file_head;
if (source) {
register char *s = strrchr(source, '.');
char *s = strrchr(source, '.');
if (s && *(s+1)) {
s++;
@@ -157,7 +169,7 @@ char *source;
* object generated, so don't include the pathname
* leading to it.
*/
if (s = strrchr(source, '/')) {
if ( (s = strrchr(source, '/')) ) {
source = s + 1;
}
}
@@ -172,13 +184,12 @@ char *source;
}
}
add_dependency(s)
char *s;
void add_dependency(char *s)
{
register struct idf *p = str2idf(s, 1);
struct idf *p = str2idf(s, 1);
if (! p->id_resmac) {
register struct dependency *q = new_dependency();
struct dependency *q = new_dependency();
p->id_resmac = K_FILE;
q->dep_idf = p;
@@ -187,8 +198,7 @@ char *s;
}
}
dependency(s, source)
char *s, *source;
void dependency(char *s, char *source)
{
if (options['i'] && !strncmp(s, "/usr/include/", 13)) {
return;
@@ -207,12 +217,11 @@ char *source = 0;
char *nmlist = 0;
#endif /* GEN_NM_LIST */
compile(argc, argv)
char *argv[];
void compile(int argc, char *argv[])
{
char *result;
#ifndef LINT
register char *destination = 0;
char *destination = 0;
#endif /* LINT */
#ifdef DEBUG
@@ -318,7 +327,7 @@ compile(argc, argv)
#endif /* NOPP */
}
init()
void init()
{
init_cst(); /* initialize variables of "cstoper.c" */
reserve(tkidf); /* mark the C reserved words as such */
@@ -383,8 +392,7 @@ init()
stack_level();
}
init_specials(si)
register struct sp_id *si;
void init_specials(struct sp_id *si)
{
while (si->si_identifier) {
struct idf *idf = str2idf(si->si_identifier, 0);
@@ -398,7 +406,7 @@ init_specials(si)
#ifdef DEBUG
#ifndef NOPP
preprocess()
void preprocess()
{
/* preprocess() is the "stand-alone" preprocessor which
consecutively calls the lexical analyzer LLlex() to get
@@ -468,7 +476,7 @@ preprocess()
}
#endif /* NOPP */
Info()
void Info()
{
extern int cnt_string_cst, cnt_formal,
cnt_decl_unary, cnt_def, cnt_expr, cnt_field,
@@ -500,14 +508,12 @@ Info()
}
#endif /* DEBUG */
void
No_Mem() /* called by alloc package */
void No_Mem() /* called by alloc package */
{
fatal("out of memory");
}
void
C_failed() /* called by EM_code module */
void C_failed() /* called by EM_code module */
{
fatal("write failed");
}

View File

@@ -0,0 +1,20 @@
/*
* The Amsterdam Compiler Kit
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef LANG_CEM_CEMCOM_ANSI_MAIN_H
#define LANG_CEM_CEMCOM_ANSI_MAIN_H
/* lang/cem/cemcom.ansi/main.c */
int main(int argc, char *argv[]);
void list_dependencies(char *source);
void add_dependency(char *s);
void dependency(char *s, char *source);
void compile(int argc, char *argv[]);
void init(void);
void init_specials(struct sp_id *si);
void No_Mem(void);
void C_failed(void);
#endif /* LANG_CEM_CEMCOM_ANSI_MAIN_H */

View File

@@ -3,11 +3,11 @@
sed -e '
s:^.*[ ]ALLOCDEF[ ].*"\(.*\)"[ ]*\([0-9][0-9]*\).*$:\
/* allocation definitions of struct \1 */\
extern char *st_alloc();\
extern char *st_alloc(char **, unsigned int, int);\
extern struct \1 *h_\1;\
#ifdef DEBUG\
extern int cnt_\1;\
extern char *std_alloc();\
extern char *std_alloc(char **, unsigned int, int, int *);\
#define new_\1() ((struct \1 *) std_alloc((char **)\&h_\1, sizeof(struct \1), \2, \&cnt_\1))\
#else\
#define new_\1() ((struct \1 *) st_alloc((char **)\&h_\1, sizeof(struct \1), \2))\

View File

@@ -5,9 +5,7 @@ cat <<'--EOT--'
/* $Id$ */
#include "Lpars.h"
char *
symbol2str(tok)
int tok;
char *symbol2str(int tok)
{
#define SIZBUF 8
/* allow for a few invocations in f.i. an argument list */

View File

@@ -22,6 +22,9 @@
#include "use_tmp.h"
#include "dataflow.h"
#include "dbsymtab.h"
#include "conversion.h"
#include "error.h"
#include "domacro.h"
#ifndef NOPP
extern char **inctable;
@@ -41,12 +44,11 @@ char loptions[128]; /* one for every char */
extern int idfsize;
extern int density;
static int txt2int();
static int txt2int(char **tp);
do_option(text)
char *text;
void do_option(char *text)
{
register char opt;
char opt;
next_option: /* to allow combined one-char options */
switch (opt = *text++) {
@@ -63,7 +65,7 @@ next_option: /* to allow combined one-char options */
break;
case '-':
options[*text++] = 1; /* flags, debug options etc. */
options[*(unsigned char *)text++] = 1; /* flags, debug options etc. */
goto next_option;
#ifndef LINT
@@ -76,7 +78,7 @@ next_option: /* to allow combined one-char options */
break;
case 'i':
case 'm':
options[opt] = 1;
options[(unsigned char)opt] = 1;
break;
#endif /* NOPP */
#endif /* LINT */
@@ -97,7 +99,7 @@ next_option: /* to allow combined one-char options */
case 'w': /* no warnings will be given */
case 's': /* no stricts will be given */
case 'o': /* no complaints about old-style */
options[opt] = 1;
options[(unsigned char)opt] = 1;
goto next_option;
case 'a': /* suppress all but errors diagnostics */
options['w'] = 1; /* implies -a */
@@ -119,17 +121,17 @@ next_option: /* to allow combined one-char options */
#ifndef NOPP
case 'D' : { /* -Dname : predefine name */
register char *cp = text, *name, *mactext;
char *cp = text, *name, *mactext;
unsigned maclen;
if (class(*cp) != STIDF && class(*cp) != STELL) {
if (class(*(unsigned char *)cp) != STIDF && class(*(unsigned char *)cp) != STELL) {
error("identifier missing in -D%s", text);
break;
}
name = cp;
while (*cp && in_idf(*cp)) {
while (*cp && in_idf(*(unsigned char *)cp)) {
++cp;
}
@@ -155,7 +157,7 @@ next_option: /* to allow combined one-char options */
case 'I' : /* -Ipath : insert "path" into include list */
if (*text) {
int i;
register char *new = text;
char *new = text;
if (inc_total >= inc_max) {
inctable = (char **)
@@ -214,10 +216,10 @@ next_option: /* to allow combined one-char options */
#ifndef NOCROSS
case 'V' : /* set object sizes and alignment requirements */
{
register arith sz, algn;
arith sz, algn;
char c;
while (c = *text++) {
while ( (c = *text++) ) {
sz = txt2int(&text);
algn = 0;
if (*text == '.') {
@@ -302,9 +304,7 @@ next_option: /* to allow combined one-char options */
}
}
static int
txt2int(tp)
register char **tp;
static int txt2int(char **tp)
{
/* the integer pointed to by *tp is read, while increasing
*tp; the resulting value is yielded.

View File

@@ -0,0 +1,12 @@
/*
* The Amsterdam Compiler Kit
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef LANG_CEM_CEMCOM_ANSI_OPTIONS_H
#define LANG_CEM_CEMCOM_ANSI_OPTIONS_H
/* lang/cem/cemcom.ansi/options.c */
void do_option(char *text);
#endif /* LANG_CEM_CEMCOM_ANSI_OPTIONS_H */

View File

@@ -7,6 +7,8 @@
#include "debug.h"
#include "idf.h"
#include "skip.h"
#include "domacro.h"
#define P_UNKNOWN 0
#define NR_PRAGMAS 0
@@ -18,14 +20,12 @@ struct pkey {
{0, P_UNKNOWN}
};
extern struct idf *GetIdentifier();
do_pragma()
void do_pragma()
{
#if NR_PRAGMAS
register struct pkey *pkp = &pragmas[0];
struct pkey *pkp = &pragmas[0];
#endif
register struct idf *id = GetIdentifier(1);
struct idf *id = GetIdentifier(1);
if (id != (struct idf *)0) {
#if NR_PRAGMAS

View File

@@ -0,0 +1,12 @@
/*
* The Amsterdam Compiler Kit
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef LANG_CEM_CEMCOM_ANSI_PRAGMA_H
#define LANG_CEM_CEMCOM_ANSI_PRAGMA_H
/* lang/cem/cemcom.ansi/pragma.c */
int do_pragma(void);
#endif /* LANG_CEM_CEMCOM_ANSI_PRAGMA_H */

View File

@@ -52,13 +52,22 @@
#include "arith.h"
#include "LLlex.h"
#include "idf.h"
#include "idf_loc.h"
#include "label.h"
#include "type.h"
#include "declar.h"
#include "decspecs.h"
#include "code.h"
#include "expr.h"
#include "expr_loc.h"
#include "def.h"
#include "code_c.h"
#include "error.h"
#include "stack.h"
#include "stack_loc.h"
#include "declarator.h"
#include "proto_loc.h"
#ifdef LINT
#include "l_lint.h"
#endif /* LINT */
@@ -67,7 +76,6 @@
extern arith ifval;
#endif /* NOPP */
extern error();
}
control_if_expression

Some files were not shown because too many files have changed in this diff Show More