Compare commits

..

80 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
958 changed files with 17790 additions and 19134 deletions

17
.distr
View File

@ -1,7 +1,9 @@
README
CHANGES
Copyright
Makefile
pm
pmfile
config.pm
h
modules/h
@ -11,7 +13,7 @@ util/data
util/LLgen
modules/src/alloc
#modules/src/assert
modules/src/assert
modules/src/system
modules/src/string
modules/src/read_em
@ -29,7 +31,7 @@ util/ack
lib/descr/fe
util/arch
#util/cpp
#util/cgg
util/cgg
util/ncgg
util/misc
util/opt
@ -41,22 +43,15 @@ lang/cem
lang/pc
lang/m2
#lang/occam
lang/basic
#lang/basic
mach/proto
mach/i80
mach/i86
mach/i386
mach/m68020
mach/vc4
plat
plat/cpm
plat/pc86
plat/linux
plat/linux386
plat/linux68k
plat/rpi
examples
man

5
.gitignore vendored Normal file
View File

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

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.

146
Makefile
View File

@ -1,146 +0,0 @@
# ======================================================================= #
# ACK CONFIGURATION #
# (Edit this before building) #
# ======================================================================= #
# What platform to build for by default?
DEFAULT_PLATFORM = pc86
# Where should the ACK put its temporary files?
ACK_TEMP_DIR = /tmp
# Where is the ACK going to be installed, eventually?
PREFIX = /usr/local
# Where do you want to put the object files used when building?
BUILDDIR = $(ACK_TEMP_DIR)/ack-build
# What build flags do you want to use?
CFLAGS = -g
LDFLAGS = -s
# ======================================================================= #
# END OF CONFIGURATION #
# ======================================================================= #
#
# You shouldn't need to change anything below this point unless you are
# actually developing ACK.
OBJDIR = $(BUILDDIR)/obj
BINDIR = $(BUILDDIR)/bin
LIBDIR = $(BUILDDIR)/lib
INCDIR = $(BUILDDIR)/include
INSDIR = $(BUILDDIR)/staging
PLATIND = $(INSDIR)/share/ack
PLATDEP = $(INSDIR)/lib/ack
CC = gcc
AR = ar
RM = rm -f
CP = cp
hide = @
CFLAGS += \
-I$(INCDIR) \
-Imodules/h \
-Ih
LDFLAGS +=
ACKFLAGS = -Ih
all: installables
.DELETE_ON_ERROR:
include first/core.mk
include modules/src/object/build.mk
include modules/src/alloc/build.mk
include modules/src/input/build.mk
include modules/src/idf/build.mk
include modules/src/system/build.mk
include modules/src/string/build.mk
include modules/src/print/build.mk
include modules/src/flt_arith/build.mk
include modules/src/em_code/build.mk
include modules/src/em_mes/build.mk
include modules/src/read_em/build.mk
include util/amisc/build.mk
include util/cmisc/build.mk
include util/ack/build.mk
include util/LLgen/build.mk
include util/data/build.mk
include util/opt/build.mk
include util/ncgg/build.mk
include util/arch/build.mk
include util/misc/build.mk
include util/led/build.mk
include util/topgen/build.mk
include util/ego/build.mk
include lang/cem/build.mk
include lang/basic/build.mk
include lang/pc/build.mk
include lang/m2/build.mk
include mach/proto/as/build.mk
include mach/proto/ncg/build.mk
include mach/proto/top/build.mk
include plat/linux/liblinux/build.mk
include mach/i80/build.mk
include mach/i386/build.mk
include mach/i86/build.mk
include mach/m68020/build.mk
# include mach/powerpc/build.mk
include mach/vc4/build.mk
include plat/build.mk
include plat/pc86/build.mk
include plat/cpm/build.mk
include plat/linux386/build.mk
include plat/linux68k/build.mk
# include plat/linuxppc/build.mk
include plat/rpi/build.mk
.PHONY: installables
installables: $(INSTALLABLES)
@echo ""
@echo "Build completed successfully."
.PHONY: install
install: installables
@echo INSTALLING into $(PREFIX)
$(hide) tar cf - -C $(INSDIR) . | tar xvf - -C $(PREFIX)
.PHONY: clean
clean:
@echo CLEAN
$(hide) $(RM) $(CLEANABLES)
$(INCDIR)/local.h:
@echo LOCAL
@mkdir -p $(dir $@)
$(hide) echo '#define VERSION 3' > $@
$(hide) echo '#define ACKM "$(DEFAULT_PLATFORM)"' >> $@
$(hide) echo '#define BIGMACHINE 1' >> $@
$(hide) echo '#define SYS_5' >> $@
$(INCDIR)/em_path.h:
@echo EM_PATH
@mkdir -p $(dir $@)
$(hide) echo '#define TMP_DIR "$(ACK_TEMP_DIR)"' > $@
$(hide) echo '#define EM_DIR "$(PREFIX)"' >> $@
$(hide) echo '#define ACK_PATH "share/ack/descr"' >> $@
-include $(DEPENDS)

108
README
View File

@ -1,9 +1,8 @@
THE AMSTERDAM COMPILER KIT V6.0pre5
===================================
© 1987-2005 Vrije Universiteit, Amsterdam
2013-05-15
THE AMSTERDAM COMPILER KIT V6.0pre4
===================================
© 1987-2005 Vrije Universiteit, Amsterdam 2010-08-08
© 2013-2014 Manoel Trapier, Paris
INTRODUCTION
============
@ -18,69 +17,82 @@ 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, Pascal, Modula 2, Basic. K&R is supported via the ANSI C compiler.
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
linux68k produces ELF executables for m68020 Linux systems
cpm produces i80 CP/M .COM files
rpi produces Raspberry Pi GPU binaries
INSTALLATION
============
The version 5.0 build mechanism has been completely rewritten. Installation
ought to be fairly straightforward.
The version 6.0 build mechanism has been completely rewritten and is based
around the Prime Mover build tool (see http://primemover.sf.net for more
information). Installation ought to be fairly straightforward.
Requirements:
- an ANSI C compiler. This defaults to gcc. You can change this by setting
the CC make variable.
- flex and yacc.
- GNU make.
- about 40MB free in /tmp (or some other temporary directory).
- an ANSI C compiler. Currently, I'm afraid, it's hard-coded to use gcc.
To change, try changing the variable definitions in first/c.pm. This also
needs to be available as 'cc' from the shell.
- about 20MB free in /tmp (or some other temporary directory).
- about 6MB in the target directory.
Instructions:
- edit the Makefile. There's a small section at the top where you can change
the configuration. Probably the only one you may want to edit is PREFIX,
which changes where the ACK installs to.
- edit config.pm. There's a small section at the top containing some editable
variables. Probably the only one you may want to edit is PREFIX, which
changes where the ACK installs to.
- Run:
make # or gmake
...from the command line. This will do the build.
The make system is fully parallelisable. If you have a multicore system,
you probably want to do:
make -j8 # or gmake -j8
...instead (substituting the right number of cores, of course). You can
also shave a few seconds of the build time by using the -r flag.
./pm configure
...from the command line. This will write out a configuration file.
- Run:
sudo make install
...from the command line. This will install the ACK in your PREFIX
directory (by default, /usr/local).
./pm
...from the command line. This will actually do the build. This takes
about two minutes on my 1.6GHz Athlon Linux machine and about 30 on my
166MHz Pentium OpenBSD machine.
- Run:
./pm install
...from the command line (possibly with sudo). This will install the built
ACK into whatever directory you nominated in PREFIX.
The ACK should now be ready to use.
@ -98,9 +110,8 @@ Some useful options include:
-o <file> specifies the output file
-c produce a .o file
-c.s produce a .s assembly file
-O enable optimisation (optimisation levels go up to 6)
-O enable optimisation
-ansi compile ANSI C (when using the C compiler)
-v be more verbose (repeatable)
<file> build file
ack figures out which language to use from the file extension:
@ -112,7 +123,6 @@ ack figures out which language to use from the file extension:
.p Pascal
.o object files
.s assembly files
.e ACK intermediate code assembly files
For further information, see the man page (which actually does get
installed, but is rather out of date).
@ -123,13 +133,12 @@ A sample command line is:
ack -mlinux386 -O examples/paranoia.c
GOTCHAS
=======
There are some things you should be aware of.
- Look at plat/<PLATFORMNAME>/README for information about the supported
- Look at plat/<PLATFORMNAME>/README for information about the two supported
platforms.
- The library support is fairly limited; for C, it's at roughly the ANSI C
@ -162,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
2013-05-13
2010-08-08

1
README.md Symbolic link
View File

@ -0,0 +1 @@
README

View File

@ -13,7 +13,7 @@ ACK_TEMP_DIR = "/tmp"
-- Where is the ACK going to be installed, eventually?
PREFIX = "/tmp/ack-temp/staging"
PREFIX = "/usr/local"
-- ======================================================================= --
-- BROKEN ACK CONFIGURATION --

View File

@ -143,7 +143,7 @@ echo ""
if [ -e $destdir ]; then
if [ "$delete" = "yes" ]; then
echo "Press RETURN to erase $destdir and its contents, or CTRL+C to abort."
read _ _
read
echo "Erasing..."
rm -rf "$destdir"
else

View File

@ -1,4 +1,9 @@
core.mk
ack.pm
ack-custom.pm
c.pm
llgen.pm
yacc.pm
#create_dir
#cp_dir
#em_path.h.src

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

@ -1,199 +0,0 @@
define reset
$(eval q :=)
$(eval o :=)
$(eval s :=)
$(eval cflags :=)
$(eval ackflags :=)
$(eval ldflags :=)
$(eval objdir :=)
endef
# --- Host compiler
define cfile-rule
$o: $s
@echo CC $o
@mkdir -p $(dir $o)
@$(CC) $(CFLAGS) $(cflags) -MM -MQ $o -o $d $s
$(hide) $(CC) $(CFLAGS) $(cflags) -c -o $o $s
endef
define cfile
$(eval s := $1)
$(eval o := $(OBJDIR)/$(objdir)/$(1:.c=.o))
$(eval d := $(OBJDIR)/$(objdir)/$(1:.c=.d))
$(eval DEPENDS += $d)
$(eval CLEANABLES += $o $d)
$(eval q += $o)
$(eval $(cfile-rule))
endef
# --- ACK compiler
define ackfile-rule
$o: $s $(ACK) \
$(CCOMPILER) \
$(PLATFORM_$(PLATFORM)) \
$(ACK_CORE_TOOLS)
@echo ACK $o
@mkdir -p $(dir $o)
$(hide) ACKDIR=$(INSDIR) $(ACK) $(ACKFLAGS) $(ackflags) -m$(PLATFORM) -c -o $o $s
endef
define ackfile
$(eval s := $1)
$(eval o := $(OBJDIR)/$(objdir)/$(basename $1).o)
$(eval d := $(OBJDIR)/$(objdir)/$(basename $1).d)
$(eval DEPENDS += $d)
$(eval CLEANABLES += $o $d)
$(eval q += $o)
$(eval $(ackfile-rule))
endef
# --- Add a raw to the queue
define file
$(eval q += $1)
endef
# --- Host compiler linking
define cprogram-rule
$o: $s
@echo CPROGRAM $o
@mkdir -p $(dir $o)
$(hide) $(CC) $(CFLAGS) $(cflags) $(LDFLAGS) $(ldflags) -o $o $s
endef
define cprogram
$(eval o := $1)
$(eval s := $q)
$(eval CLEANABLES += $o)
$(eval q := $o)
$(eval $(cprogram-rule))
endef
# --- Host library linking
define clibrary-rule
$o: $s
@echo CLIBRARY $o
@mkdir -p $(dir $o)
@$(RM) $o
$(hide) $(AR) qsc $o $s
endef
define clibrary
$(eval o := $1)
$(eval s := $q)
$(eval CLEANABLES += $o)
$(eval q := $o)
$(eval $(clibrary-rule))
endef
# --- ACK library linking
define acklibrary-rule
$o: $s $(AAL)
@echo ACKLIBRARY $o
@mkdir -p $(dir $o)
@$(RM) $o
$(hide) $(AAL) q $o $s
endef
define acklibrary
$(eval o := $1)
$(eval s := $q)
$(eval CLEANABLES += $o)
$(eval q := $o)
$(eval $(acklibrary-rule))
endef
# --- Copies a file.
define copyto-rule
$o: $s
@echo CP $o
@mkdir -p $(dir $o)
$(hide) $(CP) $s $o
endef
define copyto
$(eval o := $1)
$(eval s := $q)
$(eval CLEANABLES += $o)
$(eval q := $o)
$(eval $(copyto-rule))
endef
# --- Installs a file (copies it and adds it to INSTALLABLES).
define installto-rule
$o: $s
@echo INSTALL $o
@mkdir -p $(dir $o)
$(hide) $(CP) $s $o
endef
define installto
$(eval o := $1)
$(eval s := $q)
$(eval CLEANABLES += $o)
$(eval INSTALLABLES += $o)
$(eval q := $o)
$(eval $(installto-rule))
endef
# --- Adds a dependency for the last object file
define dependson
$(eval $o: $1)
endef
# --- Runs yacc.
# $1: directory to put output files
# $2: input files
#
# Output files are compiled via cfile and queued.
define yacc-impl
$(eval o := $1/y.tab.c)
$(eval CLEANABLES += $o $1/y.tab.h)
$o: $2
@echo YACC $o
@mkdir -p $(dir $o)
$(hide) yacc -t -b $1/y -d $2
$(call cfile, $o)
$1/y.tab.h: $o
endef
yacc = $(eval $(call yacc-impl,$1,$2))
# --- Runs flex.
# $1: directory to put output files
# $2: input files
#
# Output files are compiled via cfile and queued.
define flex-impl
$(eval o := $1/lex.yy.c)
$(eval CLEANABLES += $o)
$o: $2
@echo FLEX $o
@mkdir -p $(dir $o)
$(hide) flex -s -t $2 > $o
$(call cfile, $o)
endef
flex = $(eval $(call flex-impl,$1,$2))

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);

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 */

14
h/out.h
View File

@ -61,11 +61,7 @@ struct outname {
#define RELSZ 0x07 /* relocation length */
#define RELO1 1 /* 1 byte */
#define RELO2 2 /* 2 bytes */
#define RELO4 3 /* 4 bytes */
#define RELOPPC 4 /* PowerPC 26-bit address */
#define RELOH2 5 /* write top 2 bytes of 4 byte word */
#define RELOVC4 6 /* VideoCore IV address in 32-bit instruction */
#define RELO4 4 /* 4 bytes */
#define RELPC 0x08 /* pc relative */
#define RELBR 0x10 /* High order byte lowest address. */
#define RELWR 0x20 /* High order word lowest address. */
@ -101,19 +97,13 @@ struct outname {
/*
* structure format strings
*/
#if 0
/* The following strings only make sense on 32-bit platforms, so we're going
* to try and deprecate them. */
#define SF_HEAD "22222244"
#define SF_SECT "44444"
#define SF_RELO "1124"
#define SF_NAME "4224"
#endif
/*
* structure sizes on disk (bytes in file; add digits in SF_*)
* Note! These are NOT the sizes in memory (64-bit architectures will have
* a different layout).
* structure sizes (bytes in file; add digits in SF_*)
*/
#define SZ_HEAD 20
#define SZ_SECT 20

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,3 +1,3 @@
build.mk
pmfile
src
lib

View File

@ -1,3 +0,0 @@
include lang/basic/lib/build.mk
include lang/basic/src/build.mk

View File

@ -1,4 +1,4 @@
build.mk
pmfile
abs.c
asc.c
asrt.c

View File

@ -7,7 +7,62 @@
/* $Id$ */
#define __NO_DEFS
#include <math.h>
double _atn(double x) { return atan(x); }
double
_atn(x)
double x;
{
/* Algorithm and coefficients from:
"Software manual for the elementary functions"
by W.J. Cody and W. Waite, Prentice-Hall, 1980
*/
static double p[] = {
-0.13688768894191926929e+2,
-0.20505855195861651981e+2,
-0.84946240351320683534e+1,
-0.83758299368150059274e+0
};
static double q[] = {
0.41066306682575781263e+2,
0.86157349597130242515e+2,
0.59578436142597344465e+2,
0.15024001160028576121e+2,
1.0
};
static double a[] = {
0.0,
0.52359877559829887307710723554658381, /* pi/6 */
M_PI_2,
1.04719755119659774615421446109316763 /* pi/3 */
};
int neg = x < 0;
int n;
double g;
if (neg) {
x = -x;
}
if (x > 1.0) {
x = 1.0/x;
n = 2;
}
else n = 0;
if (x > 0.26794919243112270647) { /* 2-sqtr(3) */
n = n + 1;
x = (((0.73205080756887729353*x-0.5)-0.5)+x)/
(1.73205080756887729353+x);
}
/* ??? avoid underflow ??? */
g = x * x;
x += x * g * POLYNOM3(g, p) / POLYNOM4(g, q);
if (n > 1) x = -x;
x += a[n];
return neg ? -x : x;
}

View File

@ -1,48 +0,0 @@
define build-runtime-libbasic-impl
$(call reset)
$(eval objdir := $(PLATFORM))
$(call ackfile, lang/basic/lib/fif.e)
$(call ackfile, lang/basic/lib/fef.e)
$(call ackfile, lang/basic/lib/setline.e)
$(call ackfile, lang/basic/lib/abs.c)
$(call ackfile, lang/basic/lib/asc.c)
$(call ackfile, lang/basic/lib/asrt.c)
$(call ackfile, lang/basic/lib/atn.c)
$(call ackfile, lang/basic/lib/chr.c)
$(call ackfile, lang/basic/lib/conversion.c)
$(call ackfile, lang/basic/lib/error.c)
$(call ackfile, lang/basic/lib/exp.c)
$(call ackfile, lang/basic/lib/file.c)
$(call ackfile, lang/basic/lib/hlt.c)
$(call ackfile, lang/basic/lib/io.c)
$(call ackfile, lang/basic/lib/log.c)
$(call ackfile, lang/basic/lib/mki.c)
$(call ackfile, lang/basic/lib/oct.c)
$(call ackfile, lang/basic/lib/peek.c)
$(call ackfile, lang/basic/lib/power.c)
$(call ackfile, lang/basic/lib/print.c)
$(call ackfile, lang/basic/lib/random.c)
$(call ackfile, lang/basic/lib/read.c)
$(call ackfile, lang/basic/lib/return.c)
$(call ackfile, lang/basic/lib/salloc.c)
$(call ackfile, lang/basic/lib/sgn.c)
$(call ackfile, lang/basic/lib/sin.c)
$(call ackfile, lang/basic/lib/sqt.c)
$(call ackfile, lang/basic/lib/stop.c)
$(call ackfile, lang/basic/lib/string.c)
$(call ackfile, lang/basic/lib/swap.c)
$(call ackfile, lang/basic/lib/trace.c)
$(call ackfile, lang/basic/lib/trap.c)
$(call ackfile, lang/basic/lib/write.c)
$(call acklibrary, $(LIBDIR)/$(PLATFORM)/libbasic.a)
$(call installto, $(PLATIND)/$(PLATFORM)/libbasic.a)
endef
build-runtime-libbasic = $(eval $(build-runtime-libbasic-impl))
$(eval RUNTIMES += libbasic)

View File

@ -1,5 +1,4 @@
#include <stdlib.h>
#include <stdio.h>
/* $Id$ */
/* error takes an error value in the range of 0-255 */
/* and generates a trap */

View File

@ -10,7 +10,88 @@
#define __NO_DEFS
#include <math.h>
double _exp(double x)
static double
ldexp(fl,exp)
double fl;
int exp;
{
return exp(x);
extern double _fef();
int sign = 1;
int currexp;
if (fl<0) {
fl = -fl;
sign = -1;
}
fl = _fef(fl,&currexp);
exp += currexp;
if (exp > 0) {
while (exp>30) {
fl *= (double) (1L << 30);
exp -= 30;
}
fl *= (double) (1L << exp);
}
else {
while (exp<-30) {
fl /= (double) (1L << 30);
exp += 30;
}
fl /= (double) (1L << -exp);
}
return sign * fl;
}
double
_exp(x)
double x;
{
/* Algorithm and coefficients from:
"Software manual for the elementary functions"
by W.J. Cody and W. Waite, Prentice-Hall, 1980
*/
static double p[] = {
0.25000000000000000000e+0,
0.75753180159422776666e-2,
0.31555192765684646356e-4
};
static double q[] = {
0.50000000000000000000e+0,
0.56817302698551221787e-1,
0.63121894374398503557e-3,
0.75104028399870046114e-6
};
double xn, g;
int n;
int negative = x < 0;
if (x <= M_LN_MIN_D) {
return M_MIN_D;
}
if (x >= M_LN_MAX_D) {
if (x > M_LN_MAX_D) error(3);
return M_MAX_D;
}
if (negative) x = -x;
/* ??? avoid underflow ??? */
n = x * M_LOG2E + 0.5; /* 1/ln(2) = log2(e), 0.5 added for rounding */
xn = n;
{
double x1 = (long) x;
double x2 = x - x1;
g = ((x1-xn*0.693359375)+x2) - xn*(-2.1219444005469058277e-4);
}
if (negative) {
g = -g;
n = -n;
}
xn = g * g;
x = g * POLYNOM2(xn, p);
n += 1;
return (ldexp(0.5 + x/(POLYNOM3(xn, q) - x), n));
}

View File

@ -1,4 +1,4 @@
#include <stdlib.h>
/* $Id$ */
_hlt(nr)
int nr;

View File

@ -1,8 +1,9 @@
#include "bc_io.h"
#include <sgtty.h>
/* dtrg --- this originally used sgtty.h to do clever tty manipulation.
* Strictly this should be converted to use termios, but for simplicity
* we're going to stick with plain stdio for now. */
/* $Id$ */
struct sgttyb _ttydef;
/* BASIC has some nasty io characteristics */
@ -64,6 +65,9 @@ char *buf;
if( _chann == -1)
{
pos= _pos;
gtty(0,_ttydef);
_ttydef.sg_flags &= ~ECHO;
stty(0,_ttydef);
}else pos= _fdtable[_chann].pos;
c= buf;
while( (holder = fgetc(_chanrd)) != EOF && holder != '\n'){
@ -75,6 +79,8 @@ char *buf;
if( _chann== -1)
{
_pos=pos;
_ttydef.sg_flags |= ECHO;
stty(0,_ttydef);
} else _fdtable[_chann].pos= pos;
}
_tab(x)

View File

@ -10,7 +10,48 @@
#define __NO_DEFS
#include <math.h>
double _log(double x)
double
_log(x)
double x;
{
return log(x);
/* Algorithm and coefficients from:
"Software manual for the elementary functions"
by W.J. Cody and W. Waite, Prentice-Hall, 1980
*/
static double a[] = {
-0.64124943423745581147e2,
0.16383943563021534222e2,
-0.78956112887491257267e0
};
static double b[] = {
-0.76949932108494879777e3,
0.31203222091924532844e3,
-0.35667977739034646171e2,
1.0
};
extern double _fef();
double znum, zden, z, w;
int exponent;
if (x <= 0) {
error(3);
return -HUGE;
}
x = _fef(x, &exponent);
if (x > M_1_SQRT2) {
znum = (x - 0.5) - 0.5;
zden = x * 0.5 + 0.5;
}
else {
znum = x - 0.5;
zden = znum * 0.5 + 0.5;
exponent--;
}
z = znum/zden; w = z * z;
x = z + z * w * (POLYNOM2(w,a)/POLYNOM3(w,b));
z = exponent;
x += z * (-2.121944400546905827679e-4);
return x + z * 0.693359375;
}

View File

@ -1,5 +1,3 @@
#include <stdlib.h>
#include <stdio.h>
#include "bc_string.h"
/* $Id$ */

View File

@ -1,4 +1,32 @@
#include <math.h>
/* $Id$ */
double _power(double x, double y) { return pow(x, y); }
/*
computes a^b.
uses log and exp
*/
double _log(), _exp();
double
_power(base,pownr)
double pownr, base;
{
double temp;
long l;
if(pownr <= 0.0) {
if(pownr == 0.0) {
if(base <= 0.0)
error(3);
return(0.0);
}
l = base;
if(l != base)
error(3);
temp = _exp(base * _log(-pownr));
if(l & 1)
temp = -temp;
return(temp);
}
return(_exp(base * _log(pownr)));
}

View File

@ -1,5 +1,3 @@
#include <stdlib.h>
#include <stdio.h>
#include "bc_string.h"
#include "bc_io.h"

View File

@ -1,5 +1,4 @@
#include <stdlib.h>
#include <stdio.h>
/* $Id$ */
#if !defined(EM_WSIZE)
#define EM_WSIZE _EM_WSIZE

View File

@ -1,4 +1,6 @@
#include <stdlib.h>
/* $Id$ */
extern char *malloc() ;
char * salloc(length)
unsigned length;

View File

@ -10,7 +10,96 @@
#define __NO_DEFS
#include <math.h>
double _sin(double x) { return sin(x); }
double _cos(double x) { return cos(x); }
double _tan(double x) { return tan(x); }
static double
sinus(x, cos_flag)
double x;
{
/* Algorithm and coefficients from:
"Software manual for the elementary functions"
by W.J. Cody and W. Waite, Prentice-Hall, 1980
*/
static double r[] = {
-0.16666666666666665052e+0,
0.83333333333331650314e-2,
-0.19841269841201840457e-3,
0.27557319210152756119e-5,
-0.25052106798274584544e-7,
0.16058936490371589114e-9,
-0.76429178068910467734e-12,
0.27204790957888846175e-14
};
double xsqr;
double y;
int neg = 0;
if (x < 0) {
x = -x;
neg = 1;
}
if (cos_flag) {
neg = 0;
y = M_PI_2 + x;
}
else y = x;
/* ??? avoid loss of significance, if y is too large, error ??? */
y = y * M_1_PI + 0.5;
/* Use extended precision to calculate reduced argument.
Here we used 12 bits of the mantissa for a1.
Also split x in integer part x1 and fraction part x2.
*/
#define A1 3.1416015625
#define A2 -8.908910206761537356617e-6
{
double x1, x2;
extern double _fif();
_fif(y, 1.0, &y);
if (_fif(y, 0.5, &x1)) neg = !neg;
if (cos_flag) y -= 0.5;
x2 = _fif(x, 1.0, &x1);
x = x1 - y * A1;
x += x2;
x -= y * A2;
#undef A1
#undef A2
}
if (x < 0) {
neg = !neg;
x = -x;
}
/* ??? avoid underflow ??? */
y = x * x;
x += x * y * POLYNOM7(y, r);
return neg ? -x : x;
}
double
_sin(x)
double x;
{
return sinus(x, 0);
}
double
_cos(x)
double x;
{
if (x < 0) x = -x;
return sinus(x, 1);
}
/* EXTENSION */
double
_tan(x)
double x;
{
return _sin(x)/_cos(x);
}

View File

@ -10,5 +10,62 @@
#define __NO_DEFS
#include <math.h>
double _sqt(double x) { return sqrt(x); }
#define NITER 5
static double
ldexp(fl,exp)
double fl;
int exp;
{
extern double _fef();
int sign = 1;
int currexp;
if (fl<0) {
fl = -fl;
sign = -1;
}
fl = _fef(fl,&currexp);
exp += currexp;
if (exp > 0) {
while (exp>30) {
fl *= (double) (1L << 30);
exp -= 30;
}
fl *= (double) (1L << exp);
}
else {
while (exp<-30) {
fl /= (double) (1L << 30);
exp += 30;
}
fl /= (double) (1L << -exp);
}
return sign * fl;
}
double
_sqt(x)
double x;
{
extern double _fef();
int exponent;
double val;
if (x <= 0) {
if (x < 0) error(3);
return 0;
}
val = _fef(x, &exponent);
if (exponent & 1) {
exponent--;
val *= 2;
}
val = ldexp(val + 1.0, exponent/2 - 1);
/* was: val = (val + 1.0)/2.0; val = ldexp(val, exponent/2); */
for (exponent = NITER - 1; exponent >= 0; exponent--) {
val = (val + x / val) / 2.0;
}
return val;
}

View File

@ -1,5 +1,4 @@
#include <stdlib.h>
#include <stdio.h>
/* $Id$ */
_stop()
{

View File

@ -1,5 +1,3 @@
#include <stdlib.h>
#include <string.h>
#include "bc_string.h"
/* $Id$ */

View File

@ -1,5 +1,3 @@
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <setjmp.h>

View File

@ -1,4 +1,4 @@
build.mk
pmfile
basic.g
basic.lex
bem.c

View File

@ -237,7 +237,7 @@ File *stream;
extern char *strchr();
getinputline()
getline()
{
/* get next input line */

View File

@ -1,44 +0,0 @@
D := lang/basic/src
define build-bem-impl
$(call reset)
$(eval cflags += -I$(OBJDIR)/$D -I$D)
$(call cfile, $D/bem.c)
$(call cfile, $D/symbols.c)
$(call cfile, $D/initialize.c)
$(call cfile, $D/compile.c)
$(call cfile, $D/parsepar.c)
$(call cfile, $D/gencode.c)
$(call cfile, $D/util.c)
$(call cfile, $D/graph.c)
$(call cfile, $D/eval.c)
$(call cfile, $D/func.c)
$(call llgen, $(OBJDIR)/$D, $D/basic.g)
$(eval g := $(OBJDIR)/$D/tokentab.h)
$(eval $q: $g)
$(eval CLEANABLES += $g)
$g: $D/maketokentab $(OBJDIR)/$D/Lpars.h
@echo TOKENTAB $$@
@mkdir -p $$(dir $$@)
$(hide) cd $(OBJDIR)/$D && $(abspath $$^)
$(eval $q: $(OBJDIR)/$D/Lpars.h)
$(eval $q: $(INCDIR)/print.h)
$(call file, $(LIBEM_MES))
$(call file, $(LIBEMK))
$(call file, $(LIBEM_DATA))
$(call file, $(LIBALLOC))
$(call file, $(LIBPRINT))
$(call file, $(LIBSTRING))
$(call file, $(LIBSYSTEM))
$(call cprogram, $(BINDIR)/em_bem)
$(call installto, $(PLATDEP)/em_bem)
endef
$(eval $(build-bem-impl))

View File

@ -23,7 +23,7 @@ compileprogram()
prolog2(); /* Some statements are moved from prolog2 to
epilogcode in the new version of the compiler */
while( basicline = 0, getinputline())
while( basicline = 0, getline())
(void) LLparse();
epilogcode();
sys_close(yyin);

View File

@ -644,7 +644,7 @@ prolog2()
C_loi((arith) BEMPTRSIZE);
C_exa_dnam("trpbuf");
C_lae_dnam("trpbuf",(arith)0);
C_cal("__setjmp");
C_cal("setjmp");
C_df_ilb(l);
C_asp((arith)(BEMPTRSIZE+BEMPTRSIZE));
C_lfr((arith)BEMINTSIZE);

View File

@ -1,4 +1,4 @@
build.mk
pmfile
cemcom.ansi
cpp.ansi
libcc.ansi

View File

@ -1,6 +0,0 @@
include lang/cem/cpp.ansi/build.mk
include lang/cem/cemcom.ansi/build.mk
include lang/cem/libcc.ansi/build.mk
$(eval CCOMPILER := $(CPPANSI) $(CEMCOMANSI) $(LIBCCANSIHEADERS))

View File

@ -1,4 +1,4 @@
build.mk
pmfile
LLlex.c
LLlex.h
LLmessage.c

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

@ -5,8 +5,13 @@
/* $Id$ */
/* L E X I C A L A N A L Y Z E R */
#include "debug.h"
#include "lint.h"
#include <alloc.h>
#include "parameters.h"
#include "idfsize.h"
#include "numsize.h"
#include "strsize.h"
#include "nopp.h"
#include "input.h"
#include "arith.h"
#include "def.h"
@ -17,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 */
@ -57,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; */
@ -65,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
@ -103,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}*#"
@ -116,7 +124,7 @@ GetToken(ptok)
needed.
*/
char buf[(IDFSIZE > NUMSIZE ? IDFSIZE : NUMSIZE) + 1];
register int ch, nch;
int ch, nch;
token_nmb++;
@ -222,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 == '<') {
@ -307,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;
@ -356,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) \
@ -439,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
@ -454,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();
@ -496,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();
@ -529,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) {
@ -562,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.
@ -623,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
@ -633,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:
@ -666,10 +664,9 @@ again:
}
#ifndef NOPP
int
trigraph()
int trigraph()
{
register int ch;
int ch;
LoadChar(ch);
if (ch == '?') {
@ -713,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++;
@ -752,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;
@ -776,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".
@ -11,6 +13,7 @@
*/
#include "file_info.h"
#include "nopp.h"
/* the structure of a token: */
struct token {
@ -62,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

@ -5,7 +5,8 @@
/* $Id$ */
/* A L I G N M E N T D E F I N I T I O N S */
#include "parameters.h"
#include "nocross.h"
#include "trgt_sizes.h"
#ifndef NOCROSS
extern int

View File

@ -11,8 +11,11 @@
semantics of C is a mess.
*/
#include "parameters.h"
#include <alloc.h>
#include "debug.h"
#include "lint.h"
#include "nobitfield.h"
#include "idf.h"
#include <flt_arith.h>
#include "arith.h"
#include "sizes.h"
@ -24,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.
@ -41,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;
@ -79,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;
}
@ -170,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 ':'.
@ -180,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
@ -203,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)
@ -236,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.
@ -294,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
@ -309,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;
@ -327,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) {
@ -368,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)) {
@ -389,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);
@ -417,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.
@ -435,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.
@ -446,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.
@ -456,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.
@ -471,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",
@ -485,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;
@ -523,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) {
@ -548,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;
@ -560,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:
@ -581,8 +567,7 @@ any2opnd(expp, oper)
}
}
any2parameter(expp)
register struct expr **expp;
void any2parameter(struct expr **expp)
{
/* To handle default argument promotions
*/
@ -595,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;
@ -627,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".
@ -13,7 +15,7 @@
be handy.
*/
#include "parameters.h"
#include "spec_arith.h"
#ifndef SPECIAL_ARITHMETICS
@ -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

@ -1,6 +1,5 @@
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* $Id$ */
@ -11,8 +10,7 @@
there is no reasonable method to prove that a program is 100%
correct, these assertions are needed in some places.
*/
#include "parameters.h"
#include "debug.h" /* UF */
#ifdef DEBUG
/* Note: this macro uses parameter substitution inside strings */

View File

@ -5,7 +5,7 @@
/* $Id$ */
/* B L O C K S T O R I N G A N D L O A D I N G */
#include "parameters.h"
#include "lint.h"
#ifndef LINT
#include <em.h>
@ -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

@ -1,156 +0,0 @@
D := lang/cem/cemcom.ansi
define build-cemcom-ansi-allocd-header
$(eval g := $(OBJDIR)/$D/$(strip $1).h)
$g: $D/$(strip $1).str $D/make.allocd
@echo ALLOCD $$@
@mkdir -p $$(dir $$@)
$(hide) $D/make.allocd < $$^ > $$@
$(eval CLEANABLES += $g)
$(eval $q: $g)
endef
define build-cemcom-ansi-next
$(eval CLEANABLES += $(OBJDIR)/$D/next.c)
$(OBJDIR)/$D/next.c: $D/make.next $1
@echo NEXT $$@
@mkdir -p $$(dir $$@)
$(hide) $$^ > $$@
$(call cfile, $(OBJDIR)/$D/next.c)
$(foreach f, $1, $(call build-cemcom-ansi-allocd-header, \
$(basename $(notdir $f))))
endef
define build-cemcom-ansi-impl
$(call reset)
$(eval cflags += -I$(OBJDIR)/$D -I$D)
$(call cfile, $D/arith.c)
$(call dependson, $(INCDIR)/flt_arith.h)
$(call cfile, $D/blocks.c)
$(call dependson, $(INCDIR)/em_codeEK.h)
$(call cfile, $D/LLlex.c)
$(call cfile, $D/LLmessage.c)
$(call cfile, $D/ch3.c)
$(call cfile, $D/ch3bin.c)
$(call cfile, $D/ch3mon.c)
$(call cfile, $D/code.c)
$(call cfile, $D/conversion.c)
$(call cfile, $D/cstoper.c)
$(call cfile, $D/dataflow.c)
$(call cfile, $D/declarator.c)
$(call cfile, $D/decspecs.c)
$(call cfile, $D/domacro.c)
$(call cfile, $D/dumpidf.c)
$(call cfile, $D/error.c)
$(call cfile, $D/eval.c)
$(call cfile, $D/expr.c)
$(call cfile, $D/field.c)
$(call cfile, $D/fltcstoper.c)
$(call cfile, $D/idf.c)
$(call cfile, $D/init.c)
$(call cfile, $D/input.c)
$(call cfile, $D/l_comment.c)
$(call cfile, $D/l_ev_ord.c)
$(call cfile, $D/l_lint.c)
$(call cfile, $D/l_misc.c)
$(call cfile, $D/l_outdef.c)
$(call cfile, $D/l_states.c)
$(call cfile, $D/label.c)
$(call cfile, $D/main.c)
$(call cfile, $D/options.c)
$(call cfile, $D/pragma.c)
$(call cfile, $D/proto.c)
$(call cfile, $D/replace.c)
$(call cfile, $D/skip.c)
$(call cfile, $D/stab.c)
$(call cfile, $D/stack.c)
$(call cfile, $D/struct.c)
$(call cfile, $D/switch.c)
$(call cfile, $D/tokenname.c)
$(call cfile, $D/type.c)
$(call cfile, $D/util.c)
$(call llgen, $(OBJDIR)/$D, \
$(OBJDIR)/$D/tokenfile.g \
$D/program.g \
$D/declar.g \
$D/expression.g \
$D/statement.g \
$D/ival.g)
$(eval CLEANABLES += $(OBJDIR)/$D/tokenfile.g)
$(OBJDIR)/$D/tokenfile.g: $D/make.tokfile $D/tokenname.c
@echo TOKENFILE $$@
@mkdir -p $$(dir $$@)
$(hide) sh $D/make.tokfile < $D/tokenname.c > $$@
$(call tabgen, $D/char.tab)
$(eval $q: $(OBJDIR)/$D/parameters.h)
$(eval CLEANABLES += $(OBJDIR)/$D/parameters.h)
$(OBJDIR)/$D/parameters.h: $D/BigPars
@echo PARAMETERS $$@
@mkdir -p $$(dir $$@)
$(hide) echo '#ifndef PARAMETERS_H' > $$@
$(hide) echo '#define PARAMETERS_H' >> $$@
$(hide) grep -v '^!' < $D/BigPars >> $$@
$(hide) echo '#endif' >> $$@
$(eval CLEANABLES += $(OBJDIR)/$D/symbol2str.c)
$(OBJDIR)/$D/symbol2str.c: $D/make.tokcase $D/tokenname.c
@echo TOKCASE $$@
@mkdir -p $$(dir $$@)
$(hide) $D/make.tokcase < $D/tokenname.c > $$@
$(call cfile, $(OBJDIR)/$D/symbol2str.c)
$(call build-cemcom-ansi-next, \
$D/code.str \
$D/declar.str \
$D/def.str \
$D/expr.str \
$D/field.str \
$D/estack.str \
$D/util.str \
$D/proto.str \
$D/replace.str \
$D/idf.str \
$D/macro.str \
$D/stack.str \
$D/stmt.str \
$D/struct.str \
$D/switch.str \
$D/type.str \
$D/l_brace.str \
$D/l_state.str \
$D/l_outdef.str)
$(eval $q: $(OBJDIR)/$D/Lpars.h)
$(call file, $(LIBEM_MES))
$(call file, $(LIBEMK))
$(call file, $(LIBEM_DATA))
$(call file, $(LIBINPUT))
$(call file, $(LIBASSERT))
$(call file, $(LIBALLOC))
$(call file, $(LIBFLT_ARITH))
$(call file, $(LIBPRINT))
$(call file, $(LIBSYSTEM))
$(call file, $(LIBSTRING))
$(call cprogram, $(BINDIR)/cemcom.ansi)
$(call installto, $(PLATDEP)/em_cemcom.ansi)
$(eval CEMCOMANSI := $o)
$(call reset)
$(eval q := $D/cemcom.ansi.1)
$(call installto, $(INSDIR)/share/man/man1/cemcom.6)
endef
$(eval $(build-cemcom-ansi-impl))

View File

@ -5,10 +5,12 @@
/* $Id$ */
/* S E M A N T I C A N A L Y S I S -- C H A P T E R 3.3 */
#include "parameters.h"
#include "debug.h"
#include "lint.h"
#include "nobitfield.h"
#include "idf.h"
#include <flt_arith.h>
#include "arith.h"
#include "idf.h"
#include "proto.h"
#include "type.h"
#include "struct.h"
@ -18,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;
@ -160,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.
@ -169,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) {
@ -408,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;
@ -471,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;
@ -515,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));
@ -558,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;
@ -582,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);
@ -606,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
@ -623,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);
@ -683,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:
@ -703,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

@ -5,8 +5,11 @@
/* $Id$ */
/* SEMANTIC ANALYSIS (CHAPTER 3.3) -- BINARY OPERATORS */
#include "parameters.h"
#include "botch_free.h"
#include "debug.h"
#include <alloc.h>
#include "lint.h"
#include "idf.h"
#include <flt_arith.h>
#include "arith.h"
#include "type.h"
@ -15,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,
@ -32,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!!!
@ -292,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.
@ -324,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 '>';
@ -336,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
@ -362,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
@ -383,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

@ -5,24 +5,35 @@
/* $Id$ */
/* SEMANTIC ANALYSIS (CHAPTER 3.3) -- MONADIC OPERATORS */
#include "parameters.h"
#include "botch_free.h"
#include "debug.h"
#include <alloc.h>
#include "nobitfield.h"
#include "Lpars.h"
#include <flt_arith.h>
#include "idf.h"
#include "arith.h"
#include "type.h"
#include "label.h"
#include "expr.h"
#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 + 1*/]; /* cstoper.c */
char *symbol2str();
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

@ -7,18 +7,23 @@
#include <stdlib.h>
#include <string.h>
#include "parameters.h"
#include "lint.h"
#include "debug.h"
#include "dbsymtab.h"
#ifndef LINT
#include <em.h>
#else
#include "l_em.h"
#include "l_lint.h"
#endif /* LINT */
#include "botch_free.h"
#include <alloc.h>
#include "dataflow.h"
#include "use_tmp.h"
#include <flt_arith.h>
#include "idf.h"
#include "arith.h"
#include "type.h"
#include "idf.h"
#include "label.h"
#include "code.h"
#include "stmt.h"
@ -35,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 */
@ -46,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;
@ -61,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
@ -103,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();
@ -120,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;
@ -135,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;
@ -143,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.
@ -158,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);
@ -183,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.
@ -216,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:
@ -228,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
@ -315,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:
@ -386,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
@ -399,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.
@ -415,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".
@ -440,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;
@ -527,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;
@ -605,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);
@ -636,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)
@ -668,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
@ -703,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);
@ -721,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) {
@ -738,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;
@ -749,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
@ -761,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());
@ -773,7 +778,7 @@ prc_entry(name)
}
}
prc_exit()
static void prc_exit()
{
if (options['p']) {
C_lae_dlb(prc_name, (arith) 0);
@ -783,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

@ -5,7 +5,7 @@
/* $Id$ */
/* C O N V E R S I O N - C O D E G E N E R A T O R */
#include "parameters.h"
#include "lint.h"
#ifndef LINT
#include <em.h>
@ -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

@ -5,7 +5,8 @@
/* $Id$ */
/* C O N S T A N T E X P R E S S I O N H A N D L I N G */
#include "parameters.h"
#include "trgt_sizes.h"
#include "idf.h"
#include <flt_arith.h>
#include "arith.h"
#include "type.h"
@ -14,6 +15,9 @@
#include "sizes.h"
#include "Lpars.h"
#include "assert.h"
#include "cstoper.h"
#include "error.h"
#include "expr_loc.h"
/* full_mask[1] == 0XFF, full_mask[2] == 0XFFFF, .. */
arith full_mask[MAXSIZE + 1];
@ -23,15 +27,14 @@ 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,10 +242,10 @@ 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++;

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

@ -9,7 +9,7 @@
Use the compiler option --d.
*/
#include "parameters.h" /* UF */
#include "dataflow.h" /* UF */
#ifdef DATAFLOW
char *CurrentFunction = 0;

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

@ -6,25 +6,38 @@
/* DECLARATION SYNTAX PARSER */
{
#include "parameters.h"
#include "lint.h"
#include "dbsymtab.h"
#include <alloc.h>
#include "nobitfield.h"
#include "debug.h"
#include <flt_arith.h>
#include "idf.h"
#include "arith.h"
#include "LLlex.h"
#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 */
@ -709,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

@ -5,7 +5,8 @@
/* $Id$ */
/* D E C L A R A T O R M A N I P U L A T I O N */
#include "parameters.h"
#include "debug.h"
#include "botch_free.h"
#include <alloc.h>
#include <flt_arith.h>
#include "arith.h"
@ -14,18 +15,19 @@
#include "Lpars.h"
#include "declar.h"
#include "def.h"
#include "idf.h"
#include "label.h"
#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.
@ -33,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,
@ -43,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;
@ -75,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;
@ -91,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) {
@ -120,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,8 +4,10 @@
*/
/* $Id$ */
/* IDENTIFIER DEFINITION DESCRIPTOR */
#ifndef LANG_CEM_CEMCOM_ANSI_DEF_STR
#define LANG_CEM_CEMCOM_ANSI_DEF_STR
#include "parameters.h"
#include "lint.h"
struct def { /* for ordinary tags */
struct def *next;
@ -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,20 +5,40 @@
/* $Id$ */
/* PREPROCESSOR: CONTROLLINE INTERPRETER */
#include <stdlib.h>
#include "parameters.h"
#include "idf.h"
#include <stdlib.h>
#include <string.h>
#include "debug.h"
#include "specials.h"
#include "arith.h"
#include "LLlex.h"
#include "Lpars.h"
#include "idf.h"
#include "input.h"
#include "replace.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"
#include "botch_free.h"
#include "nparams.h"
#include "parbufsize.h"
#include "textsize.h"
#include "idfsize.h"
#include "assert.h"
#include <alloc.h>
#include "class.h"
#include "macro.h"
#include "macbuf.h"
#include "replace.h"
#include "dbsymtab.h"
#ifdef DBSYMTAB
#include <stb.h>
#include <em.h>
@ -27,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
@ -67,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;
@ -117,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;
@ -145,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
@ -156,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;
@ -280,7 +301,7 @@ int to_endif;
}
ifexpr()
int ifexpr()
{
/* ifexpr() returns whether the restricted constant
expression following #if or #elif evaluates to true. This
@ -302,7 +323,7 @@ ifexpr()
return (errors == err_occurred) && (ifval != (arith)0);
}
do_include()
void do_include()
{
/* do_include() performs the inclusion of a file.
*/
@ -347,7 +368,7 @@ do_include()
}
}
do_define()
void do_define()
{
/* do_define() interprets a #define control line.
*/
@ -386,7 +407,7 @@ do_define()
LineNumber++;
}
push_if()
void push_if()
{
if (nestlevel >= IFDEPTH)
fatal("too many nested #if/#ifdef/#ifndef");
@ -394,7 +415,7 @@ push_if()
ifstack[++nestlevel] = 0;
}
do_elif()
void do_elif()
{
if (nestlevel <= nestlow) {
lexerror("#elif without corresponding #if");
@ -411,7 +432,7 @@ do_elif()
}
}
do_else()
void do_else()
{
if (SkipToNewLine())
if (!options['o'])
@ -427,7 +448,7 @@ do_else()
}
}
do_endif()
void do_endif()
{
if (SkipToNewLine()) {
if (!options['o'])
@ -439,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
*/
@ -468,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))) {
@ -494,7 +514,7 @@ do_undef(argidf)
lexerror("illegal #undef construction");
}
do_error()
void do_error()
{
int len;
char *get_text();
@ -505,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.
@ -520,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);
@ -574,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
@ -600,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)
@ -619,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
@ -646,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();
@ -663,7 +684,7 @@ get_text(formals, length)
}
if (c == '\'' || c == '"') {
register int delim = c;
int delim = c;
if (blank) {
blank = 0;
@ -696,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 */
@ -713,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;
@ -762,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 */
@ -786,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
@ -807,7 +826,7 @@ GetIdentifier(skiponerr)
return tk.tk_idf;
}
domacro()
void domacro()
{
int tok;
struct token tk;
@ -831,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

@ -5,13 +5,16 @@
/* $Id$ */
/* DUMP ROUTINES */
#include "debug.h"
#ifdef DEBUG
#include "parameters.h"
#include <alloc.h>
#include "nopp.h"
#include "nobitfield.h"
#include <flt_arith.h>
#include "arith.h"
#include "stack.h"
#include "idf.h"
#include "def.h"
#include "type.h"
#include "proto.h"

View File

@ -5,8 +5,9 @@
/* $Id$ */
/* E R R O R A N D D I A G N O S T I C R O U T I N E S */
#include "parameters.h"
#include "lint.h"
#if __STDC__
#include <stdio.h>
#include <stdarg.h>
#else
#include <varargs.h>
@ -18,6 +19,12 @@
#include "l_em.h"
#endif /* LINT */
#include "debug.h"
#include "lint.h"
#include "nopp.h"
#include "errout.h"
#include "print.h"
#include "tokenname.h"
#include <flt_arith.h>
#include "arith.h"
@ -25,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
@ -57,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;
@ -73,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;
@ -89,7 +96,7 @@ expr_error(struct expr *expr, char *fmt, ...)
}
/*VARARGS*/
lexstrict(char *fmt, ...)
void lexstrict(char *fmt, ...)
{
va_list ap;
@ -101,7 +108,7 @@ lexstrict(char *fmt, ...)
}
/*VARARGS*/
strict(char *fmt, ...)
void strict(char *fmt, ...)
{
va_list ap;
@ -113,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;
@ -129,7 +136,7 @@ expr_strict(struct expr *expr, char *fmt, ...)
#ifdef DEBUG
/*VARARGS*/
debug(char *fmt, ...)
void debug(char *fmt, ...)
{
va_list ap;
@ -142,7 +149,7 @@ debug(char *fmt, ...)
#endif /* DEBUG */
/*VARARGS*/
warning(char *fmt, ...)
void warning(char *fmt, ...)
{
va_list ap;
@ -154,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;
@ -171,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;
@ -184,7 +191,7 @@ def_warning(struct def *def, char *fmt, ...)
/*VARARGS*/
hwarning(char *fmt, ...)
void hwarning(char *fmt, ...)
{
va_list ap;
@ -197,7 +204,7 @@ hwarning(char *fmt, ...)
}
/*VARARGS*/
awarning(char *fmt, ...)
void awarning(char *fmt, ...)
{
va_list ap;
@ -212,7 +219,7 @@ awarning(char *fmt, ...)
#endif /* LINT */
/*VARARGS*/
lexerror(char *fmt, ...)
void lexerror(char *fmt, ...)
{
va_list ap;
@ -224,7 +231,7 @@ lexerror(char *fmt, ...)
}
/*VARARGS*/
lexwarning(char *fmt, ...)
void lexwarning(char *fmt, ...)
{
va_list ap;
@ -236,7 +243,7 @@ lexwarning(char *fmt, ...)
}
/*VARARGS*/
crash(char *fmt, ...)
void crash(char *fmt, ...)
{
va_list ap;
@ -256,7 +263,7 @@ crash(char *fmt, ...)
}
/*VARARGS*/
fatal(char *fmt, ...)
void fatal(char *fmt, ...)
{
va_list ap;
@ -521,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) {
@ -614,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

@ -5,16 +5,21 @@
/* $Id$ */
/* EXPRESSION-CODE GENERATOR */
#include "parameters.h"
#include "lint.h"
#ifndef LINT
#include <em.h>
#include <em_reg.h>
#include <alloc.h>
#include "debug.h"
#include "nobitfield.h"
#include "dataflow.h"
#include <flt_arith.h>
#include "idf.h"
#include <system.h>
#include "print.h"
#include "arith.h"
#include "type.h"
#include "idf.h"
#include "label.h"
#include "code.h"
#include "assert.h"
@ -27,18 +32,25 @@
#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 */
/* EVAL() is the main expression-tree evaluator, which turns
any legal expression tree into EM code. parameters.h:
any legal expression tree into EM code. Parameters:
struct expr *expr
pointer to root of the expression tree to be evaluated
@ -63,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) {
@ -111,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 '+':
@ -252,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:
@ -469,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;
@ -655,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 '<':
@ -684,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 '<':
@ -713,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;
@ -818,8 +840,7 @@ assop(type, oper)
}
}
ptr_add(size)
arith size;
void ptr_add(arith size)
{
if (size != pointer_size) {
C_loc(size);
@ -836,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 */
@ -854,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
@ -907,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
@ -954,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));
@ -1006,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);
@ -1024,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,12 +5,15 @@
/* $Id$ */
/* EXPRESSION TREE HANDLING */
#include <stdlib.h>
#include "parameters.h"
#include <stdlib.h>
#include "lint.h"
#include "debug.h"
#include "assert.h"
#include "botch_free.h"
#include <alloc.h>
#include "idf.h"
#include <flt_arith.h>
#include "idf.h"
#include "arith.h"
#include "def.h"
#include "type.h"
@ -22,14 +25,17 @@
#include "declar.h"
#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.
*/
@ -98,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;
@ -125,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 == '(') {
@ -195,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;
@ -217,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.
@ -226,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) {
@ -256,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;
@ -272,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.
@ -303,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
@ -314,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;
@ -327,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;
@ -369,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.
@ -392,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);
@ -415,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.
@ -435,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>.
@ -449,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.
@ -459,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.
@ -469,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;
@ -483,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

@ -7,17 +7,27 @@
{
#include <alloc.h>
#include "parameters.h"
#include "lint.h"
#include "debug.h"
#include <flt_arith.h>
#include "arith.h"
#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 */
@ -29,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);}
|
@ -46,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
@ -76,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;
@ -118,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)
@ -141,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 */
@ -320,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

@ -5,16 +5,19 @@
/* $Id$ */
/* BITFIELD EXPRESSION EVALUATOR */
#include "parameters.h"
#include "lint.h"
#ifndef LINT
#include "nobitfield.h"
#ifndef NOBITFIELD
#include <em.h>
#include <em_reg.h>
#include "debug.h"
#include <flt_arith.h>
#include "arith.h"
#include "type.h"
#include "idf.h"
#include "label.h"
#include "code.h"
#include "assert.h"
@ -23,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.
@ -39,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
@ -115,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);
@ -126,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

@ -6,9 +6,11 @@
/* C O N S T A N T E X P R E S S I O N H A N D L I N G */
/* F O R F L O A T I N G P O I N T N U M B E R S */
#include "parameters.h"
#include "debug.h"
#include "assert.h"
#include <alloc.h>
#include "trgt_sizes.h"
#include "idf.h"
#include <flt_arith.h>
#include "arith.h"
#include "type.h"
@ -16,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,15 +7,21 @@
#include <stdlib.h>
#include <string.h>
#include "parameters.h"
#include "system.h"
#include "lint.h"
#include <em_reg.h>
#include "debug.h"
#include "idfsize.h"
#include "botch_free.h"
#include "nopp.h"
#include "nparams.h"
#include <alloc.h>
#include "idf.h"
#include "arith.h"
#include "align.h"
#include "LLlex.h"
#include "level.h"
#include "stack.h"
#include "idf.h"
#include "label.h"
#include "def.h"
#include "type.h"
@ -26,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
@ -37,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.
@ -52,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
@ -71,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;
@ -92,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:
@ -199,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;
@ -248,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;
@ -269,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
@ -279,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)) {
@ -363,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.
@ -380,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);
@ -393,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)
@ -410,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.
*/
@ -429,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);
@ -478,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"
@ -507,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;
@ -585,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:
@ -603,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.
@ -624,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
@ -639,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,8 +4,10 @@
*/
/* $Id$ */
/* IDENTIFIER DESCRIPTOR */
#ifndef LANG_CEM_CEMCOM_ANSI_IDF_STR
#define LANG_CEM_CEMCOM_ANSI_IDF_STR
#include "parameters.h"
#include "nopp.h"
struct id_u {
#ifndef NOPP
@ -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

@ -7,17 +7,23 @@
#include <stdlib.h>
#include <string.h>
#include "parameters.h"
#include "nopp.h"
#ifndef NOPP
#include <system.h>
#include <alloc.h>
#include <time.h>
#include "idf.h"
#include <flt_arith.h>
#include <em_label.h>
#include "class.h"
#include "macro.h"
extern char *sprint();
#include "idf.h"
#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");

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