fixup commit for tag 'distr3'
This commit is contained in:
@@ -1,88 +0,0 @@
|
||||
Files
|
||||
cem.1
|
||||
cem.c
|
||||
cemcom.1
|
||||
Parameters
|
||||
Makefile
|
||||
LLlex.c
|
||||
LLlex.h
|
||||
LLmessage.c
|
||||
align.h
|
||||
alloc.c
|
||||
alloc.h
|
||||
arith.c
|
||||
arith.h
|
||||
asm.c
|
||||
assert.h
|
||||
atw.h
|
||||
blocks.c
|
||||
char.tab
|
||||
ch7.c
|
||||
ch7bin.c
|
||||
ch7mon.c
|
||||
class.h
|
||||
code.c
|
||||
code.str
|
||||
conversion.c
|
||||
cstoper.c
|
||||
dataflow.c
|
||||
declar.g
|
||||
declarator.c
|
||||
declar.str
|
||||
decspecs.c
|
||||
decspecs.str
|
||||
def.str
|
||||
domacro.c
|
||||
dumpidf.c
|
||||
error.c
|
||||
eval.c
|
||||
expr.c
|
||||
expr.str
|
||||
expression.g
|
||||
faulty.h
|
||||
field.c
|
||||
field.str
|
||||
file_info.h
|
||||
idf.c
|
||||
idf.str
|
||||
init.c
|
||||
input.c
|
||||
input.h
|
||||
interface.h
|
||||
ival.c
|
||||
label.c
|
||||
label.h
|
||||
level.h
|
||||
macro.str
|
||||
main.c
|
||||
make.allocd
|
||||
make.hfiles
|
||||
make.next
|
||||
make.tokcase
|
||||
make.tokfile
|
||||
mcomm.c
|
||||
mes.h
|
||||
options
|
||||
options.c
|
||||
program.g
|
||||
replace.c
|
||||
scan.c
|
||||
sizes.h
|
||||
skip.c
|
||||
specials.h
|
||||
stack.c
|
||||
stack.str
|
||||
statement.g
|
||||
stb.c
|
||||
storage.c
|
||||
storage.h
|
||||
stmt.str
|
||||
struct.c
|
||||
struct.str
|
||||
switch.c
|
||||
switch.str
|
||||
tab.c
|
||||
tokenname.c
|
||||
tokenname.h
|
||||
type.c
|
||||
type.str
|
||||
@@ -1,799 +0,0 @@
|
||||
# $Header$
|
||||
# M A K E F I L E F O R A C K C - C O M P I L E R
|
||||
|
||||
# Machine and environ dependent definitions
|
||||
EMHOME = /usr/em# # ACK tree on this machine
|
||||
DESTINATION = /user1/$$USER/bin# # where to put the stuff
|
||||
MKDEP = $(EMHOME)/bin/mkdep# # dependency generator
|
||||
MAP =
|
||||
#MAP = -DInsertFile=ins_file -DInsertText=ins_text# bug in m68k2 back end
|
||||
SIM = /user1/dick/bin/sim# # Dicks sim program
|
||||
LINT = /usr/new/lint
|
||||
|
||||
# Libraries and EM interface definitions
|
||||
SYSLIB = $(EMHOME)/modules/lib/libsystem.a
|
||||
EMKLIB = $(EMHOME)/modules/lib/libemk.a
|
||||
EMELIB = $(EMHOME)/modules/lib/libeme.a
|
||||
STRLIB = $(EMHOME)/modules/lib/libstring.a
|
||||
PRTLIB = $(EMHOME)/modules/lib/libprint.a
|
||||
EMMESLIB = $(EMHOME)/modules/lib/libem_mes.a
|
||||
INPLIB = $(EMHOME)/modules/lib/libinput.a
|
||||
ALLOCLIB = $(EMHOME)/modules/lib/liballoc.a
|
||||
MALLOC = $(EMHOME)/modules/lib/malloc.o
|
||||
#CH3LIB = $(EMHOME)/modules/lib/libch3.a
|
||||
CH3LIB =
|
||||
LIBS = $(INPLIB) $(CH3LIB) $(EMMESLIB) $(EMKLIB) \
|
||||
$(PRTLIB) $(STRLIB) $(ALLOCLIB) $(MALLOC) $(SYSLIB)
|
||||
ELIBS = $(INPLIB) $(CH3LIB) $(EMMESLIB) $(EMELIB) \
|
||||
$(PRTLIB) $(STRLIB) $(ALLOCLIB) $(MALLOC) $(SYSLIB)
|
||||
LIB_INCLUDES = -I$(EMHOME)/modules/h -I$(EMHOME)/modules/pkg
|
||||
EM_INCLUDES = -I$(EMHOME)/h
|
||||
SYSLLIB = $(EMHOME)/modules/lib/llib-lsys.ln
|
||||
EMKLLIB = $(EMHOME)/modules/lib/llib-lemk.ln
|
||||
EMELLIB = $(EMHOME)/modules/lib/llib-leme.ln
|
||||
STRLLIB = $(EMHOME)/modules/lib/llib-lstr.ln
|
||||
PRTLLIB = $(EMHOME)/modules/lib/llib-lprint.ln
|
||||
EMMESLLIB = $(EMHOME)/modules/lib/llib-lmes.ln
|
||||
INPLLIB = $(EMHOME)/modules/lib/llib-linput.ln
|
||||
CH3LLIB = $(EMHOME)/modules/lib/llib-lch3.ln
|
||||
ALLOCLLIB = $(EMHOME)/modules/lib/llib-alloc.ln
|
||||
LINTLIBS =
|
||||
#LINTLIBS = $(CH3LLIB) $(INPLLIB) $(EMMESLLIB) $(EMKLLIB) \
|
||||
# $(PRTLLIB) $(STRLLIB) $(SYSLLIB) $(ALLOCLLIB)
|
||||
|
||||
# Where to install the compiler and its driver
|
||||
CEMCOM = $(DESTINATION)/cemcom
|
||||
DRIVER = $(DESTINATION)/cem
|
||||
|
||||
# What C compiler to use and how
|
||||
# CC = $(ACK) -.c
|
||||
# CC = CC
|
||||
# CC = /bin/cc
|
||||
COPTIONS =
|
||||
|
||||
# What parser generator to use and how
|
||||
GEN = $(EMHOME)/bin/LLgen
|
||||
GENOPTIONS = -vv
|
||||
|
||||
# Special #defines during compilation
|
||||
CDEFS = $(MAP) $(EM_INCLUDES) $(LIB_INCLUDES)
|
||||
CFLAGS = $(CDEFS) $(COPTIONS) -O# we cannot pass the COPTIONS to lint!
|
||||
|
||||
# Grammar files and their objects
|
||||
LSRC = tokenfile.g declar.g statement.g expression.g program.g ival.g
|
||||
GLCSRC = tokenfile.c declar.c statement.c expression.c program.c ival.c
|
||||
LOBJ = tokenfile.o declar.o statement.o expression.o program.o Lpars.o ival.o
|
||||
|
||||
# Objects of hand-written C files
|
||||
COBJ = main.o idf.o declarator.o decspecs.o struct.o \
|
||||
expr.o ch7.o ch7bin.o cstoper.o arith.o \
|
||||
asm.o code.o dumpidf.o error.o field.o\
|
||||
tokenname.o LLlex.o LLmessage.o \
|
||||
input.o domacro.o replace.o init.o options.o \
|
||||
scan.o skip.o stack.o type.o ch7mon.o label.o eval.o \
|
||||
switch.o conversion.o \
|
||||
blocks.o dataflow.o Version.o
|
||||
|
||||
# Objects of other generated C files
|
||||
GOBJ = char.o symbol2str.o next.o
|
||||
|
||||
# generated source files
|
||||
GSRC = char.c symbol2str.c next.c \
|
||||
code.h declar.h decspecs.h def.h expr.h field.h estack.h \
|
||||
idf.h macro.h stack.h stmt.h struct.h switch.h type.h
|
||||
|
||||
# .h files generated by `make hfiles'; PLEASE KEEP THIS UP-TO-DATE!
|
||||
GHSRC = botch_free.h dataflow.h debug.h density.h errout.h \
|
||||
idfsize.h ifdepth.h inputtype.h inumlength.h lapbuf.h \
|
||||
maxincl.h nobitfield.h nofloat.h nopp.h noRoption.h nocross.h \
|
||||
nparams.h numsize.h parbufsize.h pathlength.h \
|
||||
strsize.h target_sizes.h textsize.h use_tmp.h spec_arith.h static.h
|
||||
|
||||
# Other generated files, for 'make clean' only
|
||||
GENERATED = tab tokenfile.g Lpars.h LLfiles LL.output lint.out \
|
||||
print Xref lxref hfiles cfiles $(GLCSRC)
|
||||
|
||||
# include files containing ALLOCDEF specifications
|
||||
NEXTFILES = code.str declar.str decspecs.str def.str expr.str field.str \
|
||||
estack.str \
|
||||
idf.str macro.str stack.str stmt.str struct.str switch.str type.str
|
||||
|
||||
.SUFFIXES: .str .h
|
||||
.str.h:
|
||||
./make.allocd <$*.str >$*.h
|
||||
|
||||
all: cc
|
||||
|
||||
cc:
|
||||
make "CC=$(CC)" hfiles
|
||||
make "CC=$(CC)" LLfiles
|
||||
make "CC=$(CC)" main
|
||||
|
||||
cem: cem.c
|
||||
$(CC) -O cem.c $(SYSLIB) -o cem
|
||||
|
||||
lint.cem: cem.c
|
||||
$(LINT) -bx cem.c
|
||||
|
||||
hfiles: ./make.hfiles Parameters
|
||||
./make.hfiles Parameters
|
||||
@touch hfiles
|
||||
|
||||
LLfiles: $(LSRC)
|
||||
$(GEN) $(GENOPTIONS) $(LSRC)
|
||||
@touch LLfiles
|
||||
|
||||
tokenfile.g: tokenname.c make.tokfile
|
||||
<tokenname.c ./make.tokfile >tokenfile.g
|
||||
|
||||
symbol2str.c: tokenname.c make.tokcase
|
||||
<tokenname.c ./make.tokcase >symbol2str.c
|
||||
|
||||
char.c: tab char.tab
|
||||
tab -fchar.tab >char.c
|
||||
|
||||
next.c: make.next $(NEXTFILES)
|
||||
./make.next $(NEXTFILES) >next.c
|
||||
|
||||
code.h: make.allocd
|
||||
declar.h: make.allocd
|
||||
decspecs.h: make.allocd
|
||||
def.h: make.allocd
|
||||
estack.h: make.allocd
|
||||
expr.h: make.allocd
|
||||
field.h: make.allocd
|
||||
idf.h: make.allocd
|
||||
macro.h: make.allocd
|
||||
stack.h: make.allocd
|
||||
stmt.h: make.allocd
|
||||
struct.h: make.allocd
|
||||
switch.h: make.allocd
|
||||
type.h: make.allocd
|
||||
|
||||
# Objects needed for 'main'
|
||||
OBJ = $(COBJ) $(LOBJ) $(GOBJ)
|
||||
|
||||
main: $(OBJ) Makefile
|
||||
$(CC) $(COPTIONS) $(LFLAGS) $(OBJ) $(LIBS) -o main
|
||||
size main
|
||||
|
||||
emain: $(OBJ) Makefile
|
||||
$(CC) $(COPTIONS) $(LFLAGS) $(OBJ) $(ELIBS) -o emain
|
||||
size emain
|
||||
|
||||
cfiles: hfiles LLfiles $(GSRC)
|
||||
@touch cfiles
|
||||
|
||||
install: main cem
|
||||
cp main $(CEMCOM)
|
||||
cp cem $(DRIVER)
|
||||
|
||||
print: files
|
||||
pr `cat files` > print
|
||||
|
||||
tags: cfiles
|
||||
ctags `sources $(OBJ)`
|
||||
|
||||
shar: files
|
||||
shar `cat files`
|
||||
|
||||
listcfiles:
|
||||
@echo `sources $(OBJ)`
|
||||
|
||||
listobjects:
|
||||
@echo $(OBJ)
|
||||
|
||||
depend: cfiles
|
||||
sed '/^#AUTOAUTO/,$$d' Makefile >Makefile.new
|
||||
echo '#AUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTO' >>Makefile.new
|
||||
$(MKDEP) `sources $(OBJ)` | sed 's/\.c:/.o:/' >>Makefile.new
|
||||
mv Makefile Makefile.old
|
||||
mv Makefile.new Makefile
|
||||
|
||||
xref:
|
||||
ctags -x `grep "\.[ch]" files`|sed "s/).*/)/">Xref
|
||||
|
||||
lxref:
|
||||
lxref $(OBJ) -lc >lxref
|
||||
|
||||
lint: lint.main lint.cem lint.tab
|
||||
|
||||
lint.main: cfiles
|
||||
$(LINT) -bx $(CDEFS) `sources $(OBJ)` $(LINTLIBS) >lint.out
|
||||
|
||||
cchk:
|
||||
cchk `sources $(COBJ)`
|
||||
|
||||
clean:
|
||||
rm -f `sources $(LOBJ)` $(OBJ) $(GENERATED) $(GSRC) $(GHSRC)
|
||||
|
||||
tab:
|
||||
$(CC) tab.c -o tab
|
||||
|
||||
lint.tab:
|
||||
$(LINT) -abx tab.c
|
||||
|
||||
sim: cfiles
|
||||
$(SIM) $(SIMFLAGS) `sources $(COBJ)` $(GSRC) $(LSRC)
|
||||
|
||||
#AUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTO
|
||||
main.o: LLlex.h
|
||||
main.o: Lpars.h
|
||||
main.o: align.h
|
||||
main.o: arith.h
|
||||
main.o: debug.h
|
||||
main.o: declar.h
|
||||
main.o: file_info.h
|
||||
main.o: idf.h
|
||||
main.o: input.h
|
||||
main.o: inputtype.h
|
||||
main.o: level.h
|
||||
main.o: maxincl.h
|
||||
main.o: noRoption.h
|
||||
main.o: nobitfield.h
|
||||
main.o: nocross.h
|
||||
main.o: nofloat.h
|
||||
main.o: nopp.h
|
||||
main.o: sizes.h
|
||||
main.o: spec_arith.h
|
||||
main.o: specials.h
|
||||
main.o: target_sizes.h
|
||||
main.o: tokenname.h
|
||||
main.o: type.h
|
||||
main.o: use_tmp.h
|
||||
idf.o: LLlex.h
|
||||
idf.o: Lpars.h
|
||||
idf.o: align.h
|
||||
idf.o: arith.h
|
||||
idf.o: assert.h
|
||||
idf.o: botch_free.h
|
||||
idf.o: debug.h
|
||||
idf.o: declar.h
|
||||
idf.o: decspecs.h
|
||||
idf.o: def.h
|
||||
idf.o: file_info.h
|
||||
idf.o: idf.h
|
||||
idf.o: idfsize.h
|
||||
idf.o: label.h
|
||||
idf.o: level.h
|
||||
idf.o: noRoption.h
|
||||
idf.o: nobitfield.h
|
||||
idf.o: nocross.h
|
||||
idf.o: nofloat.h
|
||||
idf.o: nopp.h
|
||||
idf.o: sizes.h
|
||||
idf.o: spec_arith.h
|
||||
idf.o: specials.h
|
||||
idf.o: stack.h
|
||||
idf.o: struct.h
|
||||
idf.o: target_sizes.h
|
||||
idf.o: type.h
|
||||
declarator.o: Lpars.h
|
||||
declarator.o: arith.h
|
||||
declarator.o: botch_free.h
|
||||
declarator.o: declar.h
|
||||
declarator.o: expr.h
|
||||
declarator.o: idf.h
|
||||
declarator.o: label.h
|
||||
declarator.o: nobitfield.h
|
||||
declarator.o: nocross.h
|
||||
declarator.o: nofloat.h
|
||||
declarator.o: nopp.h
|
||||
declarator.o: sizes.h
|
||||
declarator.o: spec_arith.h
|
||||
declarator.o: target_sizes.h
|
||||
declarator.o: type.h
|
||||
decspecs.o: Lpars.h
|
||||
decspecs.o: arith.h
|
||||
decspecs.o: decspecs.h
|
||||
decspecs.o: def.h
|
||||
decspecs.o: level.h
|
||||
decspecs.o: noRoption.h
|
||||
decspecs.o: nobitfield.h
|
||||
decspecs.o: nofloat.h
|
||||
decspecs.o: spec_arith.h
|
||||
decspecs.o: type.h
|
||||
struct.o: LLlex.h
|
||||
struct.o: Lpars.h
|
||||
struct.o: align.h
|
||||
struct.o: arith.h
|
||||
struct.o: assert.h
|
||||
struct.o: botch_free.h
|
||||
struct.o: debug.h
|
||||
struct.o: def.h
|
||||
struct.o: field.h
|
||||
struct.o: file_info.h
|
||||
struct.o: idf.h
|
||||
struct.o: level.h
|
||||
struct.o: noRoption.h
|
||||
struct.o: nobitfield.h
|
||||
struct.o: nocross.h
|
||||
struct.o: nofloat.h
|
||||
struct.o: nopp.h
|
||||
struct.o: sizes.h
|
||||
struct.o: spec_arith.h
|
||||
struct.o: stack.h
|
||||
struct.o: struct.h
|
||||
struct.o: target_sizes.h
|
||||
struct.o: type.h
|
||||
expr.o: LLlex.h
|
||||
expr.o: Lpars.h
|
||||
expr.o: arith.h
|
||||
expr.o: botch_free.h
|
||||
expr.o: declar.h
|
||||
expr.o: decspecs.h
|
||||
expr.o: def.h
|
||||
expr.o: expr.h
|
||||
expr.o: file_info.h
|
||||
expr.o: idf.h
|
||||
expr.o: label.h
|
||||
expr.o: level.h
|
||||
expr.o: noRoption.h
|
||||
expr.o: nobitfield.h
|
||||
expr.o: nocross.h
|
||||
expr.o: nofloat.h
|
||||
expr.o: nopp.h
|
||||
expr.o: sizes.h
|
||||
expr.o: spec_arith.h
|
||||
expr.o: target_sizes.h
|
||||
expr.o: type.h
|
||||
ch7.o: Lpars.h
|
||||
ch7.o: arith.h
|
||||
ch7.o: assert.h
|
||||
ch7.o: debug.h
|
||||
ch7.o: def.h
|
||||
ch7.o: expr.h
|
||||
ch7.o: idf.h
|
||||
ch7.o: label.h
|
||||
ch7.o: nobitfield.h
|
||||
ch7.o: nofloat.h
|
||||
ch7.o: nopp.h
|
||||
ch7.o: spec_arith.h
|
||||
ch7.o: struct.h
|
||||
ch7.o: type.h
|
||||
ch7bin.o: Lpars.h
|
||||
ch7bin.o: arith.h
|
||||
ch7bin.o: botch_free.h
|
||||
ch7bin.o: expr.h
|
||||
ch7bin.o: idf.h
|
||||
ch7bin.o: label.h
|
||||
ch7bin.o: noRoption.h
|
||||
ch7bin.o: nobitfield.h
|
||||
ch7bin.o: nofloat.h
|
||||
ch7bin.o: nopp.h
|
||||
ch7bin.o: spec_arith.h
|
||||
ch7bin.o: struct.h
|
||||
ch7bin.o: type.h
|
||||
cstoper.o: Lpars.h
|
||||
cstoper.o: arith.h
|
||||
cstoper.o: assert.h
|
||||
cstoper.o: debug.h
|
||||
cstoper.o: expr.h
|
||||
cstoper.o: idf.h
|
||||
cstoper.o: label.h
|
||||
cstoper.o: nobitfield.h
|
||||
cstoper.o: nocross.h
|
||||
cstoper.o: nofloat.h
|
||||
cstoper.o: nopp.h
|
||||
cstoper.o: sizes.h
|
||||
cstoper.o: spec_arith.h
|
||||
cstoper.o: target_sizes.h
|
||||
cstoper.o: type.h
|
||||
arith.o: Lpars.h
|
||||
arith.o: arith.h
|
||||
arith.o: botch_free.h
|
||||
arith.o: expr.h
|
||||
arith.o: field.h
|
||||
arith.o: idf.h
|
||||
arith.o: label.h
|
||||
arith.o: mes.h
|
||||
arith.o: noRoption.h
|
||||
arith.o: nobitfield.h
|
||||
arith.o: nofloat.h
|
||||
arith.o: nopp.h
|
||||
arith.o: spec_arith.h
|
||||
arith.o: type.h
|
||||
code.o: LLlex.h
|
||||
code.o: Lpars.h
|
||||
code.o: align.h
|
||||
code.o: arith.h
|
||||
code.o: assert.h
|
||||
code.o: atw.h
|
||||
code.o: botch_free.h
|
||||
code.o: code.h
|
||||
code.o: dataflow.h
|
||||
code.o: debug.h
|
||||
code.o: declar.h
|
||||
code.o: decspecs.h
|
||||
code.o: def.h
|
||||
code.o: expr.h
|
||||
code.o: file_info.h
|
||||
code.o: idf.h
|
||||
code.o: label.h
|
||||
code.o: level.h
|
||||
code.o: mes.h
|
||||
code.o: noRoption.h
|
||||
code.o: nobitfield.h
|
||||
code.o: nocross.h
|
||||
code.o: nofloat.h
|
||||
code.o: nopp.h
|
||||
code.o: sizes.h
|
||||
code.o: spec_arith.h
|
||||
code.o: specials.h
|
||||
code.o: stack.h
|
||||
code.o: stmt.h
|
||||
code.o: target_sizes.h
|
||||
code.o: type.h
|
||||
code.o: use_tmp.h
|
||||
dumpidf.o: Lpars.h
|
||||
dumpidf.o: arith.h
|
||||
dumpidf.o: debug.h
|
||||
dumpidf.o: def.h
|
||||
dumpidf.o: expr.h
|
||||
dumpidf.o: field.h
|
||||
dumpidf.o: idf.h
|
||||
dumpidf.o: label.h
|
||||
dumpidf.o: nobitfield.h
|
||||
dumpidf.o: nofloat.h
|
||||
dumpidf.o: nopp.h
|
||||
dumpidf.o: spec_arith.h
|
||||
dumpidf.o: stack.h
|
||||
dumpidf.o: static.h
|
||||
dumpidf.o: struct.h
|
||||
dumpidf.o: type.h
|
||||
error.o: LLlex.h
|
||||
error.o: arith.h
|
||||
error.o: debug.h
|
||||
error.o: errout.h
|
||||
error.o: expr.h
|
||||
error.o: file_info.h
|
||||
error.o: label.h
|
||||
error.o: nofloat.h
|
||||
error.o: nopp.h
|
||||
error.o: spec_arith.h
|
||||
error.o: tokenname.h
|
||||
error.o: use_tmp.h
|
||||
field.o: Lpars.h
|
||||
field.o: arith.h
|
||||
field.o: assert.h
|
||||
field.o: code.h
|
||||
field.o: debug.h
|
||||
field.o: expr.h
|
||||
field.o: field.h
|
||||
field.o: idf.h
|
||||
field.o: label.h
|
||||
field.o: nobitfield.h
|
||||
field.o: nocross.h
|
||||
field.o: nofloat.h
|
||||
field.o: nopp.h
|
||||
field.o: sizes.h
|
||||
field.o: spec_arith.h
|
||||
field.o: target_sizes.h
|
||||
field.o: type.h
|
||||
tokenname.o: LLlex.h
|
||||
tokenname.o: Lpars.h
|
||||
tokenname.o: arith.h
|
||||
tokenname.o: file_info.h
|
||||
tokenname.o: idf.h
|
||||
tokenname.o: nofloat.h
|
||||
tokenname.o: nopp.h
|
||||
tokenname.o: spec_arith.h
|
||||
tokenname.o: tokenname.h
|
||||
LLlex.o: LLlex.h
|
||||
LLlex.o: Lpars.h
|
||||
LLlex.o: arith.h
|
||||
LLlex.o: assert.h
|
||||
LLlex.o: class.h
|
||||
LLlex.o: debug.h
|
||||
LLlex.o: def.h
|
||||
LLlex.o: file_info.h
|
||||
LLlex.o: idf.h
|
||||
LLlex.o: idfsize.h
|
||||
LLlex.o: input.h
|
||||
LLlex.o: nocross.h
|
||||
LLlex.o: nofloat.h
|
||||
LLlex.o: nopp.h
|
||||
LLlex.o: numsize.h
|
||||
LLlex.o: sizes.h
|
||||
LLlex.o: spec_arith.h
|
||||
LLlex.o: strsize.h
|
||||
LLlex.o: target_sizes.h
|
||||
LLmessage.o: LLlex.h
|
||||
LLmessage.o: Lpars.h
|
||||
LLmessage.o: arith.h
|
||||
LLmessage.o: file_info.h
|
||||
LLmessage.o: idf.h
|
||||
LLmessage.o: nofloat.h
|
||||
LLmessage.o: nopp.h
|
||||
LLmessage.o: spec_arith.h
|
||||
input.o: file_info.h
|
||||
input.o: input.h
|
||||
input.o: inputtype.h
|
||||
input.o: nopp.h
|
||||
domacro.o: LLlex.h
|
||||
domacro.o: Lpars.h
|
||||
domacro.o: arith.h
|
||||
domacro.o: assert.h
|
||||
domacro.o: botch_free.h
|
||||
domacro.o: class.h
|
||||
domacro.o: debug.h
|
||||
domacro.o: file_info.h
|
||||
domacro.o: idf.h
|
||||
domacro.o: idfsize.h
|
||||
domacro.o: ifdepth.h
|
||||
domacro.o: input.h
|
||||
domacro.o: interface.h
|
||||
domacro.o: macro.h
|
||||
domacro.o: nofloat.h
|
||||
domacro.o: nopp.h
|
||||
domacro.o: nparams.h
|
||||
domacro.o: parbufsize.h
|
||||
domacro.o: spec_arith.h
|
||||
domacro.o: textsize.h
|
||||
replace.o: LLlex.h
|
||||
replace.o: arith.h
|
||||
replace.o: assert.h
|
||||
replace.o: class.h
|
||||
replace.o: debug.h
|
||||
replace.o: file_info.h
|
||||
replace.o: idf.h
|
||||
replace.o: input.h
|
||||
replace.o: interface.h
|
||||
replace.o: macro.h
|
||||
replace.o: nofloat.h
|
||||
replace.o: nopp.h
|
||||
replace.o: pathlength.h
|
||||
replace.o: spec_arith.h
|
||||
replace.o: static.h
|
||||
replace.o: strsize.h
|
||||
init.o: class.h
|
||||
init.o: idf.h
|
||||
init.o: interface.h
|
||||
init.o: macro.h
|
||||
init.o: nopp.h
|
||||
options.o: align.h
|
||||
options.o: arith.h
|
||||
options.o: botch_free.h
|
||||
options.o: class.h
|
||||
options.o: dataflow.h
|
||||
options.o: idf.h
|
||||
options.o: idfsize.h
|
||||
options.o: macro.h
|
||||
options.o: maxincl.h
|
||||
options.o: noRoption.h
|
||||
options.o: nobitfield.h
|
||||
options.o: nocross.h
|
||||
options.o: nofloat.h
|
||||
options.o: nopp.h
|
||||
options.o: sizes.h
|
||||
options.o: spec_arith.h
|
||||
options.o: target_sizes.h
|
||||
options.o: use_tmp.h
|
||||
scan.o: class.h
|
||||
scan.o: idf.h
|
||||
scan.o: input.h
|
||||
scan.o: interface.h
|
||||
scan.o: lapbuf.h
|
||||
scan.o: macro.h
|
||||
scan.o: nopp.h
|
||||
scan.o: nparams.h
|
||||
skip.o: LLlex.h
|
||||
skip.o: arith.h
|
||||
skip.o: class.h
|
||||
skip.o: file_info.h
|
||||
skip.o: input.h
|
||||
skip.o: interface.h
|
||||
skip.o: nofloat.h
|
||||
skip.o: nopp.h
|
||||
skip.o: spec_arith.h
|
||||
stack.o: Lpars.h
|
||||
stack.o: arith.h
|
||||
stack.o: botch_free.h
|
||||
stack.o: debug.h
|
||||
stack.o: def.h
|
||||
stack.o: idf.h
|
||||
stack.o: level.h
|
||||
stack.o: mes.h
|
||||
stack.o: noRoption.h
|
||||
stack.o: nobitfield.h
|
||||
stack.o: nofloat.h
|
||||
stack.o: nopp.h
|
||||
stack.o: spec_arith.h
|
||||
stack.o: stack.h
|
||||
stack.o: struct.h
|
||||
stack.o: type.h
|
||||
type.o: Lpars.h
|
||||
type.o: align.h
|
||||
type.o: arith.h
|
||||
type.o: botch_free.h
|
||||
type.o: def.h
|
||||
type.o: idf.h
|
||||
type.o: nobitfield.h
|
||||
type.o: nocross.h
|
||||
type.o: nofloat.h
|
||||
type.o: nopp.h
|
||||
type.o: sizes.h
|
||||
type.o: spec_arith.h
|
||||
type.o: target_sizes.h
|
||||
type.o: type.h
|
||||
ch7mon.o: Lpars.h
|
||||
ch7mon.o: arith.h
|
||||
ch7mon.o: botch_free.h
|
||||
ch7mon.o: def.h
|
||||
ch7mon.o: expr.h
|
||||
ch7mon.o: idf.h
|
||||
ch7mon.o: label.h
|
||||
ch7mon.o: nobitfield.h
|
||||
ch7mon.o: nofloat.h
|
||||
ch7mon.o: nopp.h
|
||||
ch7mon.o: spec_arith.h
|
||||
ch7mon.o: type.h
|
||||
label.o: Lpars.h
|
||||
label.o: arith.h
|
||||
label.o: def.h
|
||||
label.o: idf.h
|
||||
label.o: label.h
|
||||
label.o: level.h
|
||||
label.o: noRoption.h
|
||||
label.o: nobitfield.h
|
||||
label.o: nofloat.h
|
||||
label.o: nopp.h
|
||||
label.o: spec_arith.h
|
||||
label.o: type.h
|
||||
eval.o: Lpars.h
|
||||
eval.o: align.h
|
||||
eval.o: arith.h
|
||||
eval.o: assert.h
|
||||
eval.o: atw.h
|
||||
eval.o: code.h
|
||||
eval.o: dataflow.h
|
||||
eval.o: debug.h
|
||||
eval.o: def.h
|
||||
eval.o: expr.h
|
||||
eval.o: idf.h
|
||||
eval.o: label.h
|
||||
eval.o: level.h
|
||||
eval.o: mes.h
|
||||
eval.o: nobitfield.h
|
||||
eval.o: nocross.h
|
||||
eval.o: nofloat.h
|
||||
eval.o: nopp.h
|
||||
eval.o: sizes.h
|
||||
eval.o: spec_arith.h
|
||||
eval.o: stack.h
|
||||
eval.o: target_sizes.h
|
||||
eval.o: type.h
|
||||
switch.o: Lpars.h
|
||||
switch.o: arith.h
|
||||
switch.o: assert.h
|
||||
switch.o: botch_free.h
|
||||
switch.o: code.h
|
||||
switch.o: debug.h
|
||||
switch.o: density.h
|
||||
switch.o: expr.h
|
||||
switch.o: idf.h
|
||||
switch.o: label.h
|
||||
switch.o: noRoption.h
|
||||
switch.o: nobitfield.h
|
||||
switch.o: nofloat.h
|
||||
switch.o: nopp.h
|
||||
switch.o: spec_arith.h
|
||||
switch.o: switch.h
|
||||
switch.o: type.h
|
||||
conversion.o: Lpars.h
|
||||
conversion.o: arith.h
|
||||
conversion.o: nobitfield.h
|
||||
conversion.o: nocross.h
|
||||
conversion.o: nofloat.h
|
||||
conversion.o: sizes.h
|
||||
conversion.o: spec_arith.h
|
||||
conversion.o: target_sizes.h
|
||||
conversion.o: type.h
|
||||
blocks.o: align.h
|
||||
blocks.o: arith.h
|
||||
blocks.o: atw.h
|
||||
blocks.o: label.h
|
||||
blocks.o: nocross.h
|
||||
blocks.o: nofloat.h
|
||||
blocks.o: sizes.h
|
||||
blocks.o: spec_arith.h
|
||||
blocks.o: stack.h
|
||||
blocks.o: target_sizes.h
|
||||
dataflow.o: dataflow.h
|
||||
tokenfile.o: Lpars.h
|
||||
declar.o: LLlex.h
|
||||
declar.o: Lpars.h
|
||||
declar.o: arith.h
|
||||
declar.o: debug.h
|
||||
declar.o: declar.h
|
||||
declar.o: decspecs.h
|
||||
declar.o: def.h
|
||||
declar.o: expr.h
|
||||
declar.o: field.h
|
||||
declar.o: file_info.h
|
||||
declar.o: idf.h
|
||||
declar.o: label.h
|
||||
declar.o: level.h
|
||||
declar.o: nobitfield.h
|
||||
declar.o: nocross.h
|
||||
declar.o: nofloat.h
|
||||
declar.o: nopp.h
|
||||
declar.o: sizes.h
|
||||
declar.o: spec_arith.h
|
||||
declar.o: struct.h
|
||||
declar.o: target_sizes.h
|
||||
declar.o: type.h
|
||||
statement.o: LLlex.h
|
||||
statement.o: Lpars.h
|
||||
statement.o: arith.h
|
||||
statement.o: botch_free.h
|
||||
statement.o: code.h
|
||||
statement.o: debug.h
|
||||
statement.o: def.h
|
||||
statement.o: expr.h
|
||||
statement.o: file_info.h
|
||||
statement.o: idf.h
|
||||
statement.o: label.h
|
||||
statement.o: nobitfield.h
|
||||
statement.o: nofloat.h
|
||||
statement.o: nopp.h
|
||||
statement.o: spec_arith.h
|
||||
statement.o: stack.h
|
||||
statement.o: type.h
|
||||
expression.o: LLlex.h
|
||||
expression.o: Lpars.h
|
||||
expression.o: arith.h
|
||||
expression.o: expr.h
|
||||
expression.o: file_info.h
|
||||
expression.o: idf.h
|
||||
expression.o: label.h
|
||||
expression.o: noRoption.h
|
||||
expression.o: nobitfield.h
|
||||
expression.o: nofloat.h
|
||||
expression.o: nopp.h
|
||||
expression.o: spec_arith.h
|
||||
expression.o: type.h
|
||||
program.o: LLlex.h
|
||||
program.o: Lpars.h
|
||||
program.o: arith.h
|
||||
program.o: code.h
|
||||
program.o: declar.h
|
||||
program.o: decspecs.h
|
||||
program.o: def.h
|
||||
program.o: expr.h
|
||||
program.o: file_info.h
|
||||
program.o: idf.h
|
||||
program.o: label.h
|
||||
program.o: nobitfield.h
|
||||
program.o: nofloat.h
|
||||
program.o: nopp.h
|
||||
program.o: spec_arith.h
|
||||
program.o: type.h
|
||||
Lpars.o: Lpars.h
|
||||
ival.o: LLlex.h
|
||||
ival.o: Lpars.h
|
||||
ival.o: align.h
|
||||
ival.o: arith.h
|
||||
ival.o: assert.h
|
||||
ival.o: class.h
|
||||
ival.o: debug.h
|
||||
ival.o: def.h
|
||||
ival.o: estack.h
|
||||
ival.o: expr.h
|
||||
ival.o: field.h
|
||||
ival.o: file_info.h
|
||||
ival.o: idf.h
|
||||
ival.o: label.h
|
||||
ival.o: level.h
|
||||
ival.o: noRoption.h
|
||||
ival.o: nobitfield.h
|
||||
ival.o: nocross.h
|
||||
ival.o: nofloat.h
|
||||
ival.o: nopp.h
|
||||
ival.o: sizes.h
|
||||
ival.o: spec_arith.h
|
||||
ival.o: struct.h
|
||||
ival.o: target_sizes.h
|
||||
ival.o: type.h
|
||||
char.o: class.h
|
||||
symbol2str.o: Lpars.h
|
||||
@@ -1,135 +0,0 @@
|
||||
!File: pathlength.h
|
||||
#define PATHLENGTH 1024 /* max. length of path to file */
|
||||
|
||||
|
||||
!File: errout.h
|
||||
#define ERROUT STDERR /* file pointer for writing messages */
|
||||
#define MAXERR_LINE 5 /* maximum number of error messages given
|
||||
on the same input line. */
|
||||
|
||||
|
||||
!File: idfsize.h
|
||||
#define IDFSIZE 64 /* maximum significant length of an identifier */
|
||||
|
||||
|
||||
!File: numsize.h
|
||||
#define NUMSIZE 256 /* maximum length of a numeric constant */
|
||||
|
||||
|
||||
!File: nparams.h
|
||||
#define NPARAMS 32 /* maximum number of parameters of macros */
|
||||
|
||||
|
||||
!File: ifdepth.h
|
||||
#define IFDEPTH 256 /* maximum number of nested if-constructions */
|
||||
|
||||
|
||||
!File: maxincl.h
|
||||
#define MAXINCL 12 /* maximum number of #include directories */
|
||||
|
||||
|
||||
!File: density.h
|
||||
#define DENSITY 2 /* see switch.[ch] for an explanation */
|
||||
|
||||
|
||||
!File: lapbuf.h
|
||||
#define LAPBUF 4096 /* size of macro actual parameter buffer */
|
||||
|
||||
|
||||
!File: strsize.h
|
||||
#define ISTRSIZE 32 /* minimum number of bytes allocated for
|
||||
storing a string */
|
||||
#define RSTRSIZE 8 /* step size in enlarging the memory for
|
||||
the storage of a string */
|
||||
|
||||
|
||||
!File: target_sizes.h
|
||||
#define MAXSIZE 8 /* the maximum of the SZ_* constants */
|
||||
|
||||
/* target machine sizes */
|
||||
#define SZ_CHAR (arith)1
|
||||
#define SZ_SHORT (arith)2
|
||||
#define SZ_WORD (arith)4
|
||||
#define SZ_INT (arith)4
|
||||
#define SZ_LONG (arith)4
|
||||
#ifndef NOFLOAT
|
||||
#define SZ_FLOAT (arith)4
|
||||
#define SZ_DOUBLE (arith)8
|
||||
#endif NOFLOAT
|
||||
#define SZ_POINTER (arith)4
|
||||
|
||||
/* target machine alignment requirements */
|
||||
#define AL_CHAR 1
|
||||
#define AL_SHORT SZ_SHORT
|
||||
#define AL_WORD SZ_WORD
|
||||
#define AL_INT SZ_WORD
|
||||
#define AL_LONG SZ_WORD
|
||||
#ifndef NOFLOAT
|
||||
#define AL_FLOAT SZ_WORD
|
||||
#define AL_DOUBLE SZ_WORD
|
||||
#endif NOFLOAT
|
||||
#define AL_POINTER SZ_WORD
|
||||
#define AL_STRUCT 1
|
||||
#define AL_UNION 1
|
||||
|
||||
|
||||
!File: botch_free.h
|
||||
#undef BOTCH_FREE 1 /* when defined, botch freed memory, as a check */
|
||||
|
||||
|
||||
!File: dataflow.h
|
||||
#define DATAFLOW 1 /* produce some compile-time xref */
|
||||
|
||||
|
||||
!File: debug.h
|
||||
#undef DEBUG 1 /* perform various self-tests */
|
||||
|
||||
|
||||
!File: use_tmp.h
|
||||
#define USE_TMP 1 /* collect exa, exp, ina and inp commands
|
||||
and let them precede the rest of
|
||||
the generated compact code */
|
||||
|
||||
|
||||
!File: parbufsize.h
|
||||
#define PARBUFSIZE 1024
|
||||
|
||||
|
||||
!File: textsize.h
|
||||
#define ITEXTSIZE 8 /* 1st piece of memory for repl. text */
|
||||
#define RTEXTSIZE 8 /* stepsize for enlarging repl.text */
|
||||
|
||||
|
||||
!File: inputtype.h
|
||||
#undef INP_READ_IN_ONE 1 /* read input file in one */
|
||||
|
||||
|
||||
!File: nopp.h
|
||||
#undef NOPP 1 /* if NOT defined, use built-int preprocessor */
|
||||
|
||||
|
||||
!File: nobitfield.h
|
||||
#undef NOBITFIELD 1 /* if NOT defined, implement bitfields */
|
||||
|
||||
|
||||
!File: spec_arith.h
|
||||
/* describes internal compiler arithmetics */
|
||||
#undef SPECIAL_ARITHMETICS /* something different from native long */
|
||||
|
||||
|
||||
!File: static.h
|
||||
#define GSTATIC /* for large global "static" arrays */
|
||||
|
||||
|
||||
!File: nofloat.h
|
||||
#undef NOFLOAT 1 /* if NOT defined, floats are implemented */
|
||||
|
||||
|
||||
!File: noRoption.h
|
||||
#undef NOROPTION 1 /* if NOT defined, R option is implemented */
|
||||
|
||||
|
||||
!File: nocross.h
|
||||
#undef NOCROSS 1 /* if NOT defined, cross compiler */
|
||||
|
||||
|
||||
@@ -1,159 +0,0 @@
|
||||
/* $Header$ */
|
||||
/* M E M O R Y A L L O C A T I O N R O U T I N E S */
|
||||
|
||||
/* The allocation of memory in this program, which plays an important
|
||||
role in reading files, replacing macros and building expression
|
||||
trees, is not performed by malloc etc. The reason for having own
|
||||
memory allocation routines (malloc(), realloc() and free()) is
|
||||
plain: the garbage collection performed by the library functions
|
||||
malloc(), realloc() and free() costs a lot of time, while in most
|
||||
cases (on a VAX) the freeing and reallocation of memory is not
|
||||
necessary. The only reallocation done in this program is at
|
||||
building strings in memory. This means that the last
|
||||
(re-)allocated piece of memory can be extended.
|
||||
|
||||
The (basic) memory allocating routines offered by this memory
|
||||
handling package are:
|
||||
|
||||
char *malloc(n) : allocate n bytes
|
||||
char *realloc(ptr, n) : reallocate buffer to n bytes
|
||||
(works only if ptr was last allocated)
|
||||
free(ptr) : if ptr points to last allocated
|
||||
memory, this memory is re-allocatable
|
||||
Salloc(str, sz) : save string in malloc storage
|
||||
*/
|
||||
|
||||
#include <system.h>
|
||||
#include "myalloc.h" /* UF */
|
||||
#include "debug.h" /* UF */
|
||||
|
||||
#include "alloc.h"
|
||||
#include "assert.h"
|
||||
|
||||
#ifdef OWNALLOC
|
||||
char *sys_break();
|
||||
/* the following variables are used for book-keeping */
|
||||
static int nfreebytes = 0; /* # free bytes in sys_break space */
|
||||
static char *freeb; /* pointer to first free byte */
|
||||
static char *lastalloc; /* pointer to last malloced sp */
|
||||
static int lastnbytes; /* nr of bytes in last allocated */
|
||||
/* space */
|
||||
static char *firstfreeb = 0;
|
||||
|
||||
#endif OWNALLOC
|
||||
|
||||
char *
|
||||
Salloc(str, sz)
|
||||
register char str[];
|
||||
register int sz;
|
||||
{
|
||||
/* Salloc() is not a primitive function: it just allocates a
|
||||
piece of storage and copies a given string into it.
|
||||
*/
|
||||
char *res = Malloc(sz);
|
||||
register char *m = res;
|
||||
|
||||
while (sz--)
|
||||
*m++ = *str++;
|
||||
return res;
|
||||
}
|
||||
|
||||
#ifdef OWNALLOC
|
||||
|
||||
#define ALIGN(m) (ALIGNSIZE * (((m) - 1) / ALIGNSIZE + 1))
|
||||
|
||||
char *
|
||||
malloc(n)
|
||||
unsigned n;
|
||||
{
|
||||
/* malloc() is a very simple malloc().
|
||||
*/
|
||||
n = ALIGN(n);
|
||||
if (nfreebytes < n) {
|
||||
register nbts = (n <= ALLOCSIZ) ? ALLOCSIZ : n;
|
||||
|
||||
if (!nfreebytes) {
|
||||
if ((freeb = sys_break(nbts)) == ILL_BREAK)
|
||||
fatal("out of memory");
|
||||
}
|
||||
else {
|
||||
if (sys_break(nbts) == ILL_BREAK)
|
||||
fatal("out of memory");
|
||||
}
|
||||
nfreebytes += nbts;
|
||||
}
|
||||
lastalloc = freeb;
|
||||
freeb = lastalloc + n;
|
||||
lastnbytes = n;
|
||||
nfreebytes -= n;
|
||||
return lastalloc;
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
char *
|
||||
realloc(ptr, n)
|
||||
char *ptr;
|
||||
unsigned n;
|
||||
{
|
||||
/* realloc() is designed to append more bytes to the latest
|
||||
allocated piece of memory. However reallocation should be
|
||||
performed, even if the mentioned memory is not the latest
|
||||
allocated one, this situation will not occur. To do so,
|
||||
realloc should know how many bytes are allocated the last
|
||||
time for that piece of memory. ????
|
||||
*/
|
||||
register int nbytes = n;
|
||||
|
||||
ASSERT(ptr == lastalloc); /* security */
|
||||
nbytes -= lastnbytes; /* # bytes required */
|
||||
if (nbytes == 0) /* no extra bytes */
|
||||
return lastalloc;
|
||||
|
||||
/* if nbytes < 0: free last allocated bytes;
|
||||
if nbytes > 0: allocate more bytes
|
||||
*/
|
||||
if (nbytes > 0)
|
||||
nbytes = ALIGN(nbytes);
|
||||
if (nfreebytes < nbytes) {
|
||||
register int nbts = (nbytes < ALLOCSIZ) ? ALLOCSIZ : nbytes;
|
||||
if (sys_break(nbts) == ILL_BREAK)
|
||||
fatal("out of memory");
|
||||
nfreebytes += nbts;
|
||||
}
|
||||
freeb += nbytes; /* less bytes */
|
||||
lastnbytes += nbytes; /* change nr of last all. bytes */
|
||||
nfreebytes -= nbytes; /* less or more free bytes */
|
||||
return lastalloc;
|
||||
}
|
||||
|
||||
/* to ensure that the alloc library package will not be loaded: */
|
||||
/*ARGSUSED*/
|
||||
free(p)
|
||||
char *p;
|
||||
{}
|
||||
|
||||
init_mem()
|
||||
{
|
||||
firstfreeb = sys_break(0);
|
||||
/* align the first memory unit to ALIGNSIZE ??? */
|
||||
if ((long) firstfreeb % ALIGNSIZE != 0) {
|
||||
register char *fb = firstfreeb;
|
||||
|
||||
fb = (char *)ALIGN((long)fb);
|
||||
firstfreeb = sys_break(fb - firstfreeb);
|
||||
firstfreeb = fb;
|
||||
ASSERT((long)firstfreeb % ALIGNSIZE == 0);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
mem_stat()
|
||||
{
|
||||
extern char options[];
|
||||
|
||||
if (options['m'])
|
||||
print("Total nr of bytes allocated: %d\n",
|
||||
sys_break(0) - firstfreeb);
|
||||
}
|
||||
#endif DEBUG
|
||||
#endif OWNALLOC
|
||||
@@ -1,16 +0,0 @@
|
||||
/* $Header$ */
|
||||
/* PROGRAM'S INTERFACE TO MEMORY ALLOCATION ROUTINES */
|
||||
|
||||
/* This file serves as the interface between the program and the
|
||||
memory allocating routines.
|
||||
There are 3 memory allocation routines:
|
||||
char *Malloc(n) to allocate n bytes
|
||||
char *Salloc(str, n) to allocate n bytes
|
||||
and fill them with string str
|
||||
char *Realloc(str, n) reallocate the string at str to n bytes
|
||||
*/
|
||||
|
||||
extern char *Salloc(), *malloc(), *realloc();
|
||||
|
||||
#define Malloc(n) malloc((unsigned)(n))
|
||||
#define Srealloc(ptr,n) realloc(ptr, (unsigned)(n))
|
||||
@@ -1,23 +0,0 @@
|
||||
/* $Header$ */
|
||||
/* C O D E - G E N E R A T O R D E F I N I T I O N S */
|
||||
|
||||
struct stat_block {
|
||||
struct stat_block *next;
|
||||
label st_break;
|
||||
label st_continue;
|
||||
};
|
||||
|
||||
|
||||
/* allocation definitions of struct stat_block */
|
||||
/* ALLOCDEF "stat_block" */
|
||||
extern char *st_alloc();
|
||||
extern struct stat_block *h_stat_block;
|
||||
#define new_stat_block() ((struct stat_block *) \
|
||||
st_alloc((char **)&h_stat_block, sizeof(struct stat_block)))
|
||||
#define free_stat_block(p) st_free(p, h_stat_block, sizeof(struct stat_block))
|
||||
|
||||
|
||||
#define LVAL 0
|
||||
#define RVAL 1
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
@@ -1,45 +0,0 @@
|
||||
/* $Header$ */
|
||||
/* DEFINITION OF DECLARATOR DESCRIPTORS */
|
||||
|
||||
/* A 'declarator' consists of an idf and a linked list of
|
||||
language-defined unary operations: *, [] and (), called
|
||||
decl_unary's.
|
||||
*/
|
||||
|
||||
struct declarator {
|
||||
struct declarator *next;
|
||||
struct idf *dc_idf;
|
||||
struct decl_unary *dc_decl_unary;
|
||||
struct idstack_item *dc_fparams; /* params for function */
|
||||
};
|
||||
|
||||
|
||||
/* allocation definitions of struct declarator */
|
||||
/* ALLOCDEF "declarator" */
|
||||
extern char *st_alloc();
|
||||
extern struct declarator *h_declarator;
|
||||
#define new_declarator() ((struct declarator *) \
|
||||
st_alloc((char **)&h_declarator, sizeof(struct declarator)))
|
||||
#define free_declarator(p) st_free(p, h_declarator, sizeof(struct declarator))
|
||||
|
||||
|
||||
#define NO_PARAMS ((struct idstack_item *) 0)
|
||||
|
||||
struct decl_unary {
|
||||
struct decl_unary *next;
|
||||
int du_fund; /* POINTER, ARRAY or FUNCTION */
|
||||
arith du_count; /* for ARRAYs only */
|
||||
};
|
||||
|
||||
|
||||
/* allocation definitions of struct decl_unary */
|
||||
/* ALLOCDEF "decl_unary" */
|
||||
extern char *st_alloc();
|
||||
extern struct decl_unary *h_decl_unary;
|
||||
#define new_decl_unary() ((struct decl_unary *) \
|
||||
st_alloc((char **)&h_decl_unary, sizeof(struct decl_unary)))
|
||||
#define free_decl_unary(p) st_free(p, h_decl_unary, sizeof(struct decl_unary))
|
||||
|
||||
|
||||
extern struct type *declare_type();
|
||||
extern struct declarator null_declarator;
|
||||
@@ -1,23 +0,0 @@
|
||||
/* $Header$ */
|
||||
/* DECLARATION SPECIFIER DEFINITION */
|
||||
|
||||
struct decspecs {
|
||||
struct decspecs *next;
|
||||
struct type *ds_type; /* single type */
|
||||
int ds_sc_given; /* 1 if the st. class is explicitly given */
|
||||
int ds_sc; /* storage class, given or implied */
|
||||
int ds_size; /* LONG, SHORT or 0 */
|
||||
int ds_unsigned; /* 0 or 1 */
|
||||
};
|
||||
|
||||
|
||||
/* allocation definitions of struct decspecs */
|
||||
/* ALLOCDEF "decspecs" */
|
||||
extern char *st_alloc();
|
||||
extern struct decspecs *h_decspecs;
|
||||
#define new_decspecs() ((struct decspecs *) \
|
||||
st_alloc((char **)&h_decspecs, sizeof(struct decspecs)))
|
||||
#define free_decspecs(p) st_free(p, h_decspecs, sizeof(struct decspecs))
|
||||
|
||||
|
||||
extern struct decspecs null_decspecs;
|
||||
@@ -1,37 +0,0 @@
|
||||
/* $Header$ */
|
||||
/* IDENTIFIER DEFINITION DESCRIPTOR */
|
||||
|
||||
struct def { /* for ordinary tags */
|
||||
struct def *next;
|
||||
int df_level;
|
||||
struct type *df_type;
|
||||
int df_sc; /* may be:
|
||||
GLOBAL, STATIC, EXTERN, IMPLICIT,
|
||||
TYPEDEF,
|
||||
FORMAL, AUTO,
|
||||
ENUM, LABEL
|
||||
*/
|
||||
int df_register; /* REG_NONE, REG_DEFAULT or REG_BONUS */
|
||||
char df_initialized; /* an initialization has been generated */
|
||||
char df_alloc; /* 0, ALLOC_SEEN or ALLOC_DONE */
|
||||
char df_used; /* set if idf is used */
|
||||
char df_formal_array; /* to warn if sizeof is taken */
|
||||
arith df_address;
|
||||
};
|
||||
|
||||
#define ALLOC_SEEN 1 /* an allocating declaration has been seen */
|
||||
#define ALLOC_DONE 2 /* the allocating declaration has been done */
|
||||
|
||||
#define REG_NONE 0 /* no register candidate */
|
||||
#define REG_DEFAULT 1 /* register candidate, not declared as such */
|
||||
#define REG_BONUS 10 /* register candidate, declared as such */
|
||||
|
||||
|
||||
/* allocation definitions of struct def */
|
||||
/* ALLOCDEF "def" */
|
||||
extern char *st_alloc();
|
||||
extern struct def *h_def;
|
||||
#define new_def() ((struct def *) \
|
||||
st_alloc((char **)&h_def, sizeof(struct def)))
|
||||
#define free_def(p) st_free(p, h_def, sizeof(struct def))
|
||||
|
||||
@@ -1,144 +0,0 @@
|
||||
/* $Header$ */
|
||||
/* STRING MANIPULATION AND PRINT ROUTINES */
|
||||
|
||||
#include <system.h>
|
||||
#include "ssize.h"
|
||||
|
||||
char *long2str();
|
||||
|
||||
static
|
||||
integral(c)
|
||||
{
|
||||
switch (c) {
|
||||
case 'b':
|
||||
return -2;
|
||||
case 'd':
|
||||
return 10;
|
||||
case 'o':
|
||||
return -8;
|
||||
case 'u':
|
||||
return -10;
|
||||
case 'x':
|
||||
return -16;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
format(buf, fmt, argp)
|
||||
char *buf, *fmt;
|
||||
char *argp;
|
||||
{
|
||||
register char *pf = fmt, *pa = argp;
|
||||
register char *pb = buf;
|
||||
|
||||
while (*pf) {
|
||||
if (*pf == '%') {
|
||||
register width, base, pad, npad;
|
||||
char *arg;
|
||||
char cbuf[2];
|
||||
char *badformat = "<bad format>";
|
||||
|
||||
/* get padder */
|
||||
if (*++pf == '0') {
|
||||
pad = '0';
|
||||
++pf;
|
||||
}
|
||||
else
|
||||
pad = ' ';
|
||||
|
||||
/* get width */
|
||||
width = 0;
|
||||
while (*pf >= '0' && *pf <= '9')
|
||||
width = 10 * width + *pf++ - '0';
|
||||
|
||||
/* get text and move pa */
|
||||
if (*pf == 's') {
|
||||
arg = *(char **)pa;
|
||||
pa += sizeof(char *);
|
||||
}
|
||||
else
|
||||
if (*pf == 'c') {
|
||||
cbuf[0] = * (char *) pa;
|
||||
cbuf[1] = '\0';
|
||||
pa += sizeof(int);
|
||||
arg = &cbuf[0];
|
||||
}
|
||||
else
|
||||
if (*pf == 'l') {
|
||||
/* alignment ??? */
|
||||
if (base = integral(*++pf)) {
|
||||
arg = long2str(*(long *)pa, base);
|
||||
pa += sizeof(long);
|
||||
}
|
||||
else {
|
||||
pf--;
|
||||
arg = badformat;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (base = integral(*pf)) {
|
||||
arg = long2str((long)*(int *)pa, base);
|
||||
pa += sizeof(int);
|
||||
}
|
||||
else
|
||||
if (*pf == '%')
|
||||
arg = "%";
|
||||
else
|
||||
arg = badformat;
|
||||
|
||||
npad = width - strlen(arg);
|
||||
|
||||
while (npad-- > 0)
|
||||
*pb++ = pad;
|
||||
|
||||
while (*pb++ = *arg++);
|
||||
pb--;
|
||||
pf++;
|
||||
}
|
||||
else
|
||||
*pb++ = *pf++;
|
||||
}
|
||||
return pb - buf;
|
||||
}
|
||||
|
||||
doprnt(fp, fmt, argp)
|
||||
File *fp;
|
||||
char *fmt;
|
||||
int argp[];
|
||||
{
|
||||
char buf[SSIZE];
|
||||
|
||||
sys_write(fp, buf, format(buf, fmt, (char *)argp));
|
||||
}
|
||||
|
||||
/*VARARGS1*/
|
||||
printf(fmt, args)
|
||||
char *fmt;
|
||||
char args;
|
||||
{
|
||||
char buf[SSIZE];
|
||||
|
||||
sys_write(STDOUT, buf, format(buf, fmt, &args));
|
||||
}
|
||||
|
||||
/*VARARGS1*/
|
||||
fprintf(fp, fmt, args)
|
||||
File *fp;
|
||||
char *fmt;
|
||||
char args;
|
||||
{
|
||||
char buf[SSIZE];
|
||||
|
||||
sys_write(fp, buf, format(buf, fmt, &args));
|
||||
}
|
||||
|
||||
/*VARARGS1*/
|
||||
char *
|
||||
sprintf(buf, fmt, args)
|
||||
char *buf, *fmt;
|
||||
char args;
|
||||
{
|
||||
buf[format(buf, fmt, &args)] = '\0';
|
||||
return buf;
|
||||
}
|
||||
@@ -1,201 +0,0 @@
|
||||
/* $Header$ */
|
||||
/* EM CODE OUTPUT ROUTINES */
|
||||
|
||||
#define CMODE 0644
|
||||
#define MAX_ARG_CNT 32
|
||||
|
||||
#include "em.h"
|
||||
#include <system.h>
|
||||
#include "arith.h"
|
||||
#include "label.h"
|
||||
|
||||
/*
|
||||
putbyte(), C_open() and C_close() are the basic routines for
|
||||
respectively write on, open and close the output file.
|
||||
The put_*() functions serve as formatting functions of the
|
||||
various EM language constructs.
|
||||
See "Description of a Machine Architecture for use with
|
||||
Block Structured Languages" par. 11.2 for the meaning of these
|
||||
names.
|
||||
*/
|
||||
|
||||
/* supply a kind of buffered output */
|
||||
#define flush(x) sys_write(ofp, &obuf[0], x)
|
||||
|
||||
static char obuf[BUFSIZ];
|
||||
static char *opp = &obuf[0];
|
||||
File *ofp = 0;
|
||||
|
||||
putbyte(b) /* shouldn't putbyte() be a macro ??? (EB) */
|
||||
int b;
|
||||
{
|
||||
if (opp >= &obuf[BUFSIZ]) { /* flush if buffer overflows */
|
||||
if (flush(BUFSIZ) == 0)
|
||||
sys_stop(S_ABORT);
|
||||
opp = &obuf[0];
|
||||
}
|
||||
*opp++ = (char) b;
|
||||
}
|
||||
|
||||
C_init(wsize, psize)
|
||||
arith wsize, psize;
|
||||
{}
|
||||
|
||||
C_open(nm) /* open file for compact code output */
|
||||
char *nm;
|
||||
{
|
||||
if (nm == 0)
|
||||
ofp = STDOUT; /* standard output */
|
||||
else
|
||||
if (sys_open(nm, OP_WRITE, &ofp) == 0)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
C_close()
|
||||
{
|
||||
if (flush(opp - &obuf[0]) == 0)
|
||||
sys_stop(S_ABORT);
|
||||
opp = obuf; /* reset opp */
|
||||
if (ofp != STDOUT)
|
||||
sys_close(ofp);
|
||||
ofp = 0;
|
||||
}
|
||||
|
||||
C_busy()
|
||||
{
|
||||
return ofp != 0; /* true if code is being generated */
|
||||
}
|
||||
|
||||
/*** the compact code generating routines ***/
|
||||
#define fit16i(x) ((x) >= (long)0xFFFF8000 && (x) <= (long)0x00007FFF)
|
||||
#define fit8u(x) ((x) <= 0xFF) /* x is already unsigned */
|
||||
|
||||
put_ilb(l)
|
||||
label l;
|
||||
{
|
||||
if (fit8u(l)) {
|
||||
put8(sp_ilb1);
|
||||
put8((int)l);
|
||||
}
|
||||
else {
|
||||
put8(sp_ilb2);
|
||||
put16(l);
|
||||
}
|
||||
}
|
||||
|
||||
put_dlb(l)
|
||||
label l;
|
||||
{
|
||||
if (fit8u(l)) {
|
||||
put8(sp_dlb1);
|
||||
put8((int)l);
|
||||
}
|
||||
else {
|
||||
put8(sp_dlb2);
|
||||
put16(l);
|
||||
}
|
||||
}
|
||||
|
||||
put_cst(l)
|
||||
arith l;
|
||||
{
|
||||
if (l >= (arith) -sp_zcst0 && l < (arith) (sp_ncst0 - sp_zcst0)) {
|
||||
/* we can convert 'l' to an int because its value
|
||||
can be stored in a byte.
|
||||
*/
|
||||
put8((int) l + (sp_zcst0 + sp_fcst0));
|
||||
}
|
||||
else
|
||||
if (fit16i(l)) { /* the cast from long to int causes no trouble here */
|
||||
put8(sp_cst2);
|
||||
put16((int) l);
|
||||
}
|
||||
else {
|
||||
put8(sp_cst4);
|
||||
put32(l);
|
||||
}
|
||||
}
|
||||
|
||||
put_doff(l, v)
|
||||
label l;
|
||||
arith v;
|
||||
{
|
||||
if (v == 0)
|
||||
put_dlb(l);
|
||||
else {
|
||||
put8(sp_doff);
|
||||
put_dlb(l);
|
||||
put_cst(v);
|
||||
}
|
||||
}
|
||||
|
||||
put_noff(s, v)
|
||||
char *s;
|
||||
arith v;
|
||||
{
|
||||
if (v == 0)
|
||||
put_dnam(s);
|
||||
else {
|
||||
put8(sp_doff);
|
||||
put_dnam(s);
|
||||
put_cst(v);
|
||||
}
|
||||
}
|
||||
|
||||
put_dnam(s)
|
||||
char *s;
|
||||
{
|
||||
put8(sp_dnam);
|
||||
put_str(s);
|
||||
}
|
||||
|
||||
put_pnam(s)
|
||||
char *s;
|
||||
{
|
||||
put8(sp_pnam);
|
||||
put_str(s);
|
||||
}
|
||||
|
||||
#ifdef ____
|
||||
put_fcon(s, sz)
|
||||
char *s;
|
||||
arith sz;
|
||||
{
|
||||
put8(sp_fcon);
|
||||
put_cst(sz);
|
||||
put_str(s);
|
||||
}
|
||||
#endif ____
|
||||
|
||||
put_wcon(sp, v, sz) /* sp_icon, sp_ucon or sp_fcon with int repr */
|
||||
int sp;
|
||||
char *v;
|
||||
arith sz;
|
||||
{
|
||||
/* how 'bout signextension int --> long ??? */
|
||||
put8(sp);
|
||||
put_cst(sz);
|
||||
put_str(v);
|
||||
}
|
||||
|
||||
put_str(s)
|
||||
char *s;
|
||||
{
|
||||
register int len;
|
||||
|
||||
put_cst((arith) (len = strlen(s)));
|
||||
while (--len >= 0)
|
||||
put8(*s++);
|
||||
}
|
||||
|
||||
put_cstr(s)
|
||||
char *s;
|
||||
{
|
||||
register int len = prepare_string(s);
|
||||
|
||||
put8(sp_scon);
|
||||
put_cst((arith) len);
|
||||
while (--len >= 0)
|
||||
put8(*s++);
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/* $Header$ */
|
||||
/* DESCRIPTION OF INTERFACE TO EM CODE GENERATING ROUTINES */
|
||||
|
||||
#include "proc_intf.h" /* use macros or functions */
|
||||
|
||||
/* include the EM description files */
|
||||
#include <em_spec.h>
|
||||
#include <em_pseu.h>
|
||||
#include <em_mes.h>
|
||||
#include <em_mnem.h>
|
||||
#include <em_reg.h>
|
||||
|
||||
/* macros used in the definitions of the interface functions C_* */
|
||||
#define OP(x) put_op(x)
|
||||
#define CST(x) put_cst(x)
|
||||
#define DCST(x) put_cst(x)
|
||||
#define CSTR(x) put_cstr(x)
|
||||
#define PS(x) put_ps(x)
|
||||
#define DLB(x) put_dlb(x)
|
||||
#define ILB(x) put_ilb(x)
|
||||
#define NOFF(x,y) put_noff((x), (y))
|
||||
#define DOFF(x,y) put_doff((x), (y))
|
||||
#define PNAM(x) put_pnam(x)
|
||||
#define DNAM(x) put_dnam(x)
|
||||
#define CEND() put_cend()
|
||||
#define WCON(x,y,z) put_wcon((x), (y), (z))
|
||||
#define FCON(x,y) put_fcon((x), (y))
|
||||
|
||||
/* variants of primitive "putbyte" */
|
||||
#define put8(x) putbyte(x) /* defined in "em.c" */
|
||||
#define put16(x) (put8((int) x), put8((int) (x >> 8)))
|
||||
#define put32(x) (put16((int) x), put16((int) (x >> 16)))
|
||||
#define put_cend() put8(sp_cend)
|
||||
#define put_op(x) put8(x)
|
||||
#define put_ps(x) put8(x)
|
||||
|
||||
/* user interface */
|
||||
#define C_magic() put16(sp_magic) /* EM magic word */
|
||||
|
||||
#ifndef PROC_INTF
|
||||
#include "writeem.h"
|
||||
#endif PROC_INTF
|
||||
@@ -1,136 +0,0 @@
|
||||
% emcode definitions for the CEM compiler -- intermediate code
|
||||
C_adf(p) | arith p; | OP(op_adf), CST(p)
|
||||
C_adi(p) | arith p; | OP(op_adi), CST(p)
|
||||
C_adp(p) | arith p; | OP(op_adp), CST(p)
|
||||
C_ads(p) | arith p; | OP(op_ads), CST(p)
|
||||
C_adu(p) | arith p; | OP(op_adu), CST(p)
|
||||
C_and(p) | arith p; | OP(op_and), CST(p)
|
||||
C_asp(p) | arith p; | OP(op_asp), CST(p)
|
||||
C_bra(l) | label l; | OP(op_bra), CST((arith)l)
|
||||
C_cai() | | OP(op_cai)
|
||||
C_cal(p) | char *p; | OP(op_cal), PNAM(p)
|
||||
C_cff() | | OP(op_cff)
|
||||
C_cfi() | | OP(op_cfi)
|
||||
C_cfu() | | OP(op_cfu)
|
||||
C_cif() | | OP(op_cif)
|
||||
C_cii() | | OP(op_cii)
|
||||
C_ciu() | | OP(op_ciu)
|
||||
C_cmf(p) | arith p; | OP(op_cmf), CST(p)
|
||||
C_cmi(p) | arith p; | OP(op_cmi), CST(p)
|
||||
C_cmp() | | OP(op_cmp)
|
||||
C_cmu(p) | arith p; | OP(op_cmu), CST(p)
|
||||
C_com(p) | arith p; | OP(op_com), CST(p)
|
||||
C_csa(p) | arith p; | OP(op_csa), CST(p)
|
||||
C_csb(p) | arith p; | OP(op_csb), CST(p)
|
||||
C_cuf() | | OP(op_cuf)
|
||||
C_cui() | | OP(op_cui)
|
||||
C_cuu() | | OP(op_cuu)
|
||||
C_dup(p) | arith p; | OP(op_dup), CST(p)
|
||||
C_dvf(p) | arith p; | OP(op_dvf), CST(p)
|
||||
C_dvi(p) | arith p; | OP(op_dvi), CST(p)
|
||||
C_dvu(p) | arith p; | OP(op_dvu), CST(p)
|
||||
C_fil_dlb(l, o) | label l; arith o; | OP(op_fil), DOFF(l, o)
|
||||
C_ior(p) | arith p; | OP(op_ior), CST(p)
|
||||
C_lae_dnam(p, o) | char *p; arith o; | OP(op_lae), NOFF(p, o)
|
||||
C_lae_dlb(l, o) | label l; arith o; | OP(op_lae), DOFF(l, o)
|
||||
C_lal(p) | arith p; | OP(op_lal), CST(p)
|
||||
C_ldc(p) | arith p; | OP(op_ldc), DCST(p)
|
||||
C_lde_dnam(p, o) | char *p; arith o; | OP(op_lde), NOFF(p, o)
|
||||
C_lde_dlb(l, o) | label l; arith o; | OP(op_lde), DOFF(l, o)
|
||||
C_ldl(p) | arith p; | OP(op_ldl), CST(p)
|
||||
C_lfr(p) | arith p; | OP(op_lfr), CST(p)
|
||||
C_lin(p) | arith p; | OP(op_lin), CST(p)
|
||||
C_loc(p) | arith p; | OP(op_loc), CST(p)
|
||||
C_loe_dnam(p, o) | char *p; arith o; | OP(op_loe), NOFF(p, o)
|
||||
C_loe_dlb(l, o) | label l; arith o; | OP(op_loe), DOFF(l, o)
|
||||
C_loi(p) | arith p; | OP(op_loi), CST(p)
|
||||
C_lol(p) | arith p; | OP(op_lol), CST(p)
|
||||
C_lor(p) | arith p; | OP(op_lor), CST(p)
|
||||
C_lpi(p) | char *p; | OP(op_lpi), PNAM(p)
|
||||
C_mlf(p) | arith p; | OP(op_mlf), CST(p)
|
||||
C_mli(p) | arith p; | OP(op_mli), CST(p)
|
||||
C_mlu(p) | arith p; | OP(op_mlu), CST(p)
|
||||
C_ngf(p) | arith p; | OP(op_ngf), CST(p)
|
||||
C_ngi(p) | arith p; | OP(op_ngi), CST(p)
|
||||
C_ret(p) | arith p; | OP(op_ret), CST(p)
|
||||
C_rmi(p) | arith p; | OP(op_rmi), CST(p)
|
||||
C_rmu(p) | arith p; | OP(op_rmu), CST(p)
|
||||
C_sbf(p) | arith p; | OP(op_sbf), CST(p)
|
||||
C_sbi(p) | arith p; | OP(op_sbi), CST(p)
|
||||
C_sbs(p) | arith p; | OP(op_sbs), CST(p)
|
||||
C_sbu(p) | arith p; | OP(op_sbu), CST(p)
|
||||
C_sde_dnam(p, o) | char *p; arith o; | OP(op_sde), NOFF(p, o)
|
||||
C_sde_dlb(l, o) | label l; arith o; | OP(op_sde), DOFF(l, o)
|
||||
C_sdl(p) | arith p; | OP(op_sdl), CST(p)
|
||||
C_sli(p) | arith p; | OP(op_sli), CST(p)
|
||||
C_slu(p) | arith p; | OP(op_slu), CST(p)
|
||||
C_sri(p) | arith p; | OP(op_sri), CST(p)
|
||||
C_sru(p) | arith p; | OP(op_sru), CST(p)
|
||||
C_ste_dnam(p, o) | char *p; arith o; | OP(op_ste), NOFF(p, o)
|
||||
C_ste_dlb(l, o) | label l; arith o; | OP(op_ste), DOFF(l, o)
|
||||
C_sti(p) | arith p; | OP(op_sti), CST(p)
|
||||
C_stl(p) | arith p; | OP(op_stl), CST(p)
|
||||
C_xor(p) | arith p; | OP(op_xor), CST(p)
|
||||
C_zeq(l) | label l; | OP(op_zeq), CST((arith)l)
|
||||
C_zge(l) | label l; | OP(op_zge), CST((arith)l)
|
||||
C_zgt(l) | label l; | OP(op_zgt), CST((arith)l)
|
||||
C_zle(l) | label l; | OP(op_zle), CST((arith)l)
|
||||
C_zlt(l) | label l; | OP(op_zlt), CST((arith)l)
|
||||
C_zne(l) | label l; | OP(op_zne), CST((arith)l)
|
||||
%
|
||||
C_df_dlb(l) | label l; | DLB(l)
|
||||
C_df_dnam(s) | char *s; | DNAM(s)
|
||||
C_df_ilb(l) | label l; | ILB(l)
|
||||
%
|
||||
C_bss_cst(n, w, i) | arith n, w; int i; |
|
||||
PS(ps_bss), DCST(n), CST(w), CST((arith)i)
|
||||
%
|
||||
C_con_icon(val, siz) | char *val; arith siz; |
|
||||
PS(ps_con), WCON(sp_icon, val, siz), CEND()
|
||||
C_con_ucon(val, siz) | char *val; arith siz; |
|
||||
PS(ps_con), WCON(sp_ucon, val, siz), CEND()
|
||||
C_con_fcon(val, siz) | char *val; arith siz; |
|
||||
PS(ps_con), WCON(sp_fcon, val, siz), CEND()
|
||||
C_con_scon(str, siz) | char *str; arith siz; | PS(ps_con), CSTR(str), CEND()
|
||||
C_con_dnam(str, val) | char *str; arith val; |
|
||||
PS(ps_con), NOFF(str, val), CEND()
|
||||
C_con_dlb(l, val) | label l; arith val; |
|
||||
PS(ps_con), DOFF(l, val), CEND()
|
||||
C_con_pnam(str) | char *str; | PS(ps_con), PNAM(str), CEND()
|
||||
%
|
||||
C_rom_cst(l) | arith l; | PS(ps_rom), CST(l), CEND()
|
||||
C_rom_icon(val, siz) | char *val; arith siz; |
|
||||
PS(ps_rom), WCON(sp_icon, val, siz), CEND()
|
||||
C_rom_fcon(val, siz) | char *val; arith siz; |
|
||||
PS(ps_rom), WCON(sp_fcon, val, siz), CEND()
|
||||
C_rom_ilb(l) | label l; | PS(ps_rom), ILB(l), CEND()
|
||||
%
|
||||
C_cst(l) | arith l; | CST(l)
|
||||
C_icon(val, siz) | char *val; arith siz; | WCON(sp_icon, val, siz)
|
||||
C_ucon(val, siz) | char *val; arith siz; | WCON(sp_ucon, val, siz)
|
||||
C_fcon(val, siz) | char *val; arith siz; | WCON(sp_fcon, val, siz)
|
||||
C_scon(str, siz) | char *str; arith siz; | CSTR(str)
|
||||
C_dnam(str, val) | char *str; arith val; | NOFF(str, val)
|
||||
C_dlb(l, val) | label l; arith val; | DOFF(l, val)
|
||||
C_pnam(str) | char *str; | PNAM(str)
|
||||
C_ilb(l) | label l; | ILB(l)
|
||||
%
|
||||
C_pro_narg(p1) | char *p1; | PS(ps_pro), PNAM(p1), CEND()
|
||||
C_end(l) | arith l; | PS(ps_end), CST(l)
|
||||
%
|
||||
C_exa(s) | char *s; | PS(ps_exa), DNAM(s)
|
||||
C_exp(s) | char *s; | PS(ps_exp), PNAM(s)
|
||||
C_ina_pt(l) | label l; | PS(ps_ina), DLB(l)
|
||||
C_ina(s) | char *s; | PS(ps_ina), DNAM(s)
|
||||
C_inp(s) | char *s; | PS(ps_inp), PNAM(s)
|
||||
%
|
||||
C_ms_err() | | PS(ps_mes), CST((arith)ms_err), CEND()
|
||||
C_ms_emx(p1, p2) | arith p1, p2; |
|
||||
PS(ps_mes), CST((arith)ms_emx), CST(p1), CST(p2), CEND()
|
||||
C_ms_reg(a, b, c, d) | arith a, b; int c, d; |
|
||||
PS(ps_mes), CST((arith)ms_reg), CST(a), CST(b), CST((arith)c), CST((arith)d), CEND()
|
||||
C_ms_src(l, s) | arith l; char *s; |
|
||||
PS(ps_mes), CST((arith)ms_src), CST(l), CSTR(s), CEND()
|
||||
C_ms_flt() | | PS(ps_mes), CST((arith)ms_flt), CEND()
|
||||
C_ms_par(l) | arith l; | PS(ps_mes), CST((arith)ms_par), CST(l), CEND()
|
||||
C_ms_gto() | | PS(ps_mes), CST((arith)ms_gto), CEND()
|
||||
@@ -1,102 +0,0 @@
|
||||
/* $Header$ */
|
||||
/* EXPRESSION DESCRIPTOR */
|
||||
|
||||
/* What we want to define is the struct expr, but since it contains
|
||||
a union of various goodies, we define them first; so be patient.
|
||||
*/
|
||||
|
||||
struct value {
|
||||
struct idf *vl_idf; /* idf of an external name or 0 */
|
||||
arith vl_value; /* constant, or offset if idf != 0 */
|
||||
};
|
||||
|
||||
struct string {
|
||||
char *sg_value; /* string of characters repr. the constant */
|
||||
label sg_datlab; /* global data-label */
|
||||
};
|
||||
|
||||
struct floating {
|
||||
char *fl_value; /* pointer to string repr. the fp const. */
|
||||
label fl_datlab; /* global data_label */
|
||||
};
|
||||
|
||||
struct oper {
|
||||
struct type *op_type; /* resulting type of the operation */
|
||||
struct expr *op_left;
|
||||
int op_oper; /* the symbol of the operator */
|
||||
struct expr *op_right;
|
||||
};
|
||||
|
||||
/* The following constants indicate the class of the expression: */
|
||||
#define Value 0 /* it is a value known at load time */
|
||||
#define String 1 /* it is a string constant */
|
||||
#define Float 2 /* it is a floating point constant */
|
||||
#define Oper 3 /* it is a run-time expression */
|
||||
#define Type 4 /* only its type is relevant */
|
||||
|
||||
struct expr {
|
||||
struct expr *next;
|
||||
char *ex_file; /* the file it (probably) comes from */
|
||||
unsigned int ex_line; /* the line it (probably) comes from */
|
||||
struct type *ex_type;
|
||||
char ex_lvalue;
|
||||
char ex_flags;
|
||||
int ex_class;
|
||||
int ex_depth;
|
||||
union {
|
||||
struct value ex_value;
|
||||
struct string ex_string;
|
||||
struct floating ex_float;
|
||||
struct oper ex_oper;
|
||||
} ex_object;
|
||||
};
|
||||
|
||||
/* some abbreviated selections */
|
||||
#define VL_VALUE ex_object.ex_value.vl_value
|
||||
#define VL_IDF ex_object.ex_value.vl_idf
|
||||
#define SG_VALUE ex_object.ex_string.sg_value
|
||||
#define SG_DATLAB ex_object.ex_string.sg_datlab
|
||||
#define FL_VALUE ex_object.ex_float.fl_value
|
||||
#define FL_DATLAB ex_object.ex_float.fl_datlab
|
||||
#define OP_TYPE ex_object.ex_oper.op_type
|
||||
#define OP_LEFT ex_object.ex_oper.op_left
|
||||
#define OP_OPER ex_object.ex_oper.op_oper
|
||||
#define OP_RIGHT ex_object.ex_oper.op_right
|
||||
|
||||
#define EXPRTYPE(e) ((e)->ex_type->tp_fund)
|
||||
|
||||
/* An expression is a `load-time constant' if it is of the form
|
||||
<idf> +/- <integral> or <integral>;
|
||||
it is a `compile-time constant' if it is an <integral>.
|
||||
*/
|
||||
#define is_ld_cst(e) ((e)->ex_lvalue == 0 && (e)->ex_class == Value)
|
||||
#define is_cp_cst(e) (is_ld_cst(e) && (e)->VL_IDF == 0)
|
||||
|
||||
/* a floating constant expression ?
|
||||
*/
|
||||
#define is_fp_cst(e) ((e)->ex_class == Float)
|
||||
|
||||
/* some bits for the ex_flag field, to keep track of various
|
||||
interesting properties of an expression.
|
||||
*/
|
||||
#define EX_SIZEOF 001 /* contains sizeof operator */
|
||||
#define EX_CAST 002 /* contains cast */
|
||||
#define EX_LOGICAL 004 /* contains logical operator */
|
||||
#define EX_COMMA 010 /* contains expression comma */
|
||||
#define EX_PARENS 020 /* the top level is parenthesized */
|
||||
|
||||
#define NILEXPR ((struct expr *)0)
|
||||
|
||||
extern struct expr *intexpr(), *new_oper();
|
||||
|
||||
|
||||
/* allocation definitions of struct expr */
|
||||
/* ALLOCDEF "expr" */
|
||||
extern char *st_alloc();
|
||||
extern struct expr *h_expr;
|
||||
#define new_expr() ((struct expr *) \
|
||||
st_alloc((char **)&h_expr, sizeof(struct expr)))
|
||||
#define free_expr(p) st_free(p, h_expr, sizeof(struct expr))
|
||||
|
||||
|
||||
#define ISCOMMA(e) ((e)->ex_class == Oper && (e)->OP_OPER == INITCOMMA)
|
||||
@@ -1,20 +0,0 @@
|
||||
/* $Header$ */
|
||||
/* FIELD DESCRIPTOR */
|
||||
|
||||
struct field { /* for field specifiers */
|
||||
struct field *next;
|
||||
arith fd_mask;
|
||||
int fd_shift;
|
||||
int fd_width;
|
||||
struct sdef *fd_sdef; /* upward pointer */
|
||||
};
|
||||
|
||||
|
||||
/* allocation definitions of struct field */
|
||||
/* ALLOCDEF "field" */
|
||||
extern char *st_alloc();
|
||||
extern struct field *h_field;
|
||||
#define new_field() ((struct field *) \
|
||||
st_alloc((char **)&h_field, sizeof(struct field)))
|
||||
#define free_field(p) st_free(p, h_field, sizeof(struct field))
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
/* $Header$ */
|
||||
/* IDENTIFIER DESCRIPTOR */
|
||||
|
||||
#include "nopp.h"
|
||||
|
||||
/* Since the % operation in the calculation of the hash function
|
||||
turns out to be expensive, it is replaced by the cheaper XOR (^).
|
||||
Each character of the identifier is xored with an 8-bit mask which
|
||||
depends on the position of the character; the sum of these results
|
||||
is the hash value. The random masks are obtained from a
|
||||
congruence generator in idf.c.
|
||||
*/
|
||||
|
||||
#define HASHSIZE 256 /* must be a power of 2 */
|
||||
#define HASH_X 0253 /* Knuth's X */
|
||||
#define HASH_A 77 /* Knuth's a */
|
||||
#define HASH_C 153 /* Knuth's c */
|
||||
|
||||
extern char hmask[]; /* the random masks */
|
||||
#define HASHMASK (HASHSIZE-1) /* since it is a power of 2 */
|
||||
#define STARTHASH() (0)
|
||||
#define ENHASH(hs,ch,ps) (hs + (ch ^ hmask[ps]))
|
||||
#define STOPHASH(hs) (hs & HASHMASK)
|
||||
|
||||
struct idstack_item { /* stack of identifiers */
|
||||
struct idstack_item *next;
|
||||
struct idf *is_idf;
|
||||
};
|
||||
|
||||
|
||||
/* allocation definitions of struct idstack_item */
|
||||
/* ALLOCDEF "idstack_item" */
|
||||
extern char *st_alloc();
|
||||
extern struct idstack_item *h_idstack_item;
|
||||
#define new_idstack_item() ((struct idstack_item *) \
|
||||
st_alloc((char **)&h_idstack_item, sizeof(struct idstack_item)))
|
||||
#define free_idstack_item(p) st_free(p, h_idstack_item, sizeof(struct idstack_item))
|
||||
|
||||
|
||||
struct idf {
|
||||
struct idf *next;
|
||||
char *id_text;
|
||||
#ifndef NOPP
|
||||
struct macro *id_macro;
|
||||
int id_resmac; /* if nonzero: keyword of macroproc. */
|
||||
#endif NOPP
|
||||
int id_reserved; /* non-zero for reserved words */
|
||||
struct def *id_def; /* variables, typedefs, enum-constants */
|
||||
struct sdef *id_sdef; /* selector tags */
|
||||
struct tag *id_struct; /* struct and union tags */
|
||||
struct tag *id_enum; /* enum tags */
|
||||
int id_special; /* special action needed at occurrence */
|
||||
};
|
||||
|
||||
|
||||
/* allocation definitions of struct idf */
|
||||
/* ALLOCDEF "idf" */
|
||||
extern char *st_alloc();
|
||||
extern struct idf *h_idf;
|
||||
#define new_idf() ((struct idf *) \
|
||||
st_alloc((char **)&h_idf, sizeof(struct idf)))
|
||||
#define free_idf(p) st_free(p, h_idf, sizeof(struct idf))
|
||||
|
||||
|
||||
extern struct idf *str2idf(), *idf_hashed();
|
||||
|
||||
extern int level;
|
||||
extern struct idf *gen_idf();
|
||||
@@ -1,624 +0,0 @@
|
||||
/*
|
||||
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||
*/
|
||||
/* $Header$ */
|
||||
/* CODE FOR THE INITIALISATION OF GLOBAL VARIABLES */
|
||||
|
||||
#include "nofloat.h"
|
||||
#include <em.h>
|
||||
#include "debug.h"
|
||||
#include <alloc.h>
|
||||
#include "nobitfield.h"
|
||||
#include "arith.h"
|
||||
#include "align.h"
|
||||
#include "label.h"
|
||||
#include "expr.h"
|
||||
#include "type.h"
|
||||
#include "struct.h"
|
||||
#include "field.h"
|
||||
#include "assert.h"
|
||||
#include "Lpars.h"
|
||||
#include "class.h"
|
||||
#include "sizes.h"
|
||||
#include "idf.h"
|
||||
#include "level.h"
|
||||
#include "def.h"
|
||||
|
||||
#define con_nullbyte() C_con_ucon("0", (arith)1)
|
||||
|
||||
char *symbol2str();
|
||||
char *long2str();
|
||||
char *strncpy();
|
||||
struct expr *do_array(), *do_struct(), *IVAL();
|
||||
extern char options[];
|
||||
|
||||
/* do_ival() performs the initialisation of a global variable
|
||||
of type tp with the initialisation expression expr by calling IVAL().
|
||||
Guided by type tp, the expression is evaluated.
|
||||
*/
|
||||
do_ival(tpp, ex)
|
||||
struct type **tpp;
|
||||
struct expr *ex;
|
||||
{
|
||||
if (IVAL(tpp, ex) != 0)
|
||||
too_many_initialisers(ex);
|
||||
}
|
||||
|
||||
/* IVAL() recursively guides the initialisation expression through the
|
||||
different routines for the different types of initialisation:
|
||||
- array initialisation
|
||||
- struct initialisation
|
||||
- fundamental type initialisation
|
||||
Upto now, the initialisation of a union is not allowed!
|
||||
An initialisation expression tree consists of normal expressions
|
||||
which can be joined together by ',' nodes, which operator acts
|
||||
like the lisp function "cons" to build lists.
|
||||
IVAL() returns a pointer to the remaining expression tree.
|
||||
*/
|
||||
struct expr *
|
||||
IVAL(tpp, ex)
|
||||
struct type **tpp; /* type of global variable */
|
||||
register struct expr *ex; /* initialiser expression */
|
||||
{
|
||||
register struct type *tp = *tpp;
|
||||
|
||||
switch (tp->tp_fund) {
|
||||
case ARRAY: /* array initialisation */
|
||||
if (valid_type(tp->tp_up, "array element") == 0)
|
||||
return 0;
|
||||
if (ISCOMMA(ex)) /* list of initialisation expressions */
|
||||
return do_array(ex, tpp);
|
||||
if (tp->tp_up->tp_fund == CHAR && ex->ex_class == String)
|
||||
/* initialisation like char s[] = "I am a string" */
|
||||
ch_array(tpp, ex);
|
||||
else /* " int i[24] = 12;" */
|
||||
check_and_pad(ex, tpp);
|
||||
break;
|
||||
case STRUCT: /* struct initialisation */
|
||||
if (valid_type(tp, "struct") == 0)
|
||||
return 0;
|
||||
if (ISCOMMA(ex)) /* list of initialisation expressions */
|
||||
return do_struct(ex, tp);
|
||||
check_and_pad(ex, tpp); /* "struct foo f = 12;" */
|
||||
break;
|
||||
case UNION:
|
||||
error("union initialisation not allowed");
|
||||
break;
|
||||
case ERRONEOUS:
|
||||
break;
|
||||
default: /* fundamental type */
|
||||
if (ISCOMMA(ex)) { /* " int i = {12};" */
|
||||
if (IVAL(tpp, ex->OP_LEFT) != 0)
|
||||
too_many_initialisers(ex);
|
||||
/* return remainings of the list for the
|
||||
other members of the aggregate, if this
|
||||
item belongs to an aggregate.
|
||||
*/
|
||||
return ex->OP_RIGHT;
|
||||
}
|
||||
check_ival(ex, tp); /* "int i = 12;" */
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* do_array() initialises the members of an array described
|
||||
by type tp with the expressions in expr.
|
||||
Two important cases:
|
||||
- the number of members is known
|
||||
- the number of members is not known
|
||||
In the latter case, do_array() digests the whole expression
|
||||
tree it is given.
|
||||
In the former case, do_array() eats as many members from
|
||||
the expression tree as are needed for the array.
|
||||
If there are not sufficient members for the array, the remaining
|
||||
members are padded with zeroes
|
||||
*/
|
||||
struct expr *
|
||||
do_array(ex, tpp)
|
||||
register struct expr *ex;
|
||||
struct type **tpp;
|
||||
{
|
||||
register struct type *tp = *tpp;
|
||||
register arith elem_count;
|
||||
|
||||
ASSERT(tp->tp_fund == ARRAY && ISCOMMA(ex));
|
||||
/* the following test catches initialisations like
|
||||
char c[] = {"just a string"};
|
||||
or
|
||||
char d[] = {{"just another string"}};
|
||||
The use of the brackets causes this problem.
|
||||
Note: although the implementation of such initialisations
|
||||
is completely foolish, we did it!! (no applause, thank you)
|
||||
*/
|
||||
if (tp->tp_up->tp_fund == CHAR) {
|
||||
register struct expr *f = ex->OP_LEFT, *g = NILEXPR;
|
||||
|
||||
while (ISCOMMA(f)) { /* eat the brackets!!! */
|
||||
g = f;
|
||||
f = f->OP_LEFT;
|
||||
}
|
||||
if (f->ex_class == String) { /* hallelujah, it's a string! */
|
||||
ch_array(tpp, f);
|
||||
return g ? g->OP_RIGHT : ex->OP_RIGHT;
|
||||
}
|
||||
/* else: just go on with the next part of this function */
|
||||
if (g != 0)
|
||||
ex = g;
|
||||
}
|
||||
if (tp->tp_size == (arith)-1) {
|
||||
/* declared with unknown size: [] */
|
||||
for (elem_count = 0; ex; elem_count++) {
|
||||
/* eat whole initialisation expression */
|
||||
if (ISCOMMA(ex->OP_LEFT)) { /* embraced member */
|
||||
if (IVAL(&(tp->tp_up), ex->OP_LEFT) != 0)
|
||||
too_many_initialisers(ex);
|
||||
ex = ex->OP_RIGHT;
|
||||
}
|
||||
else {
|
||||
if (aggregate_type(tp->tp_up))
|
||||
ex = IVAL(&(tp->tp_up), ex);
|
||||
else {
|
||||
check_ival(ex->OP_LEFT, tp->tp_up);
|
||||
ex = ex->OP_RIGHT;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* set the proper size */
|
||||
*tpp = construct_type(ARRAY, tp->tp_up, elem_count);
|
||||
}
|
||||
else { /* the number of members is already known */
|
||||
arith dim = tp->tp_size / tp->tp_up->tp_size;
|
||||
|
||||
for (elem_count = 0; elem_count < dim && ex; elem_count++) {
|
||||
if (ISCOMMA(ex->OP_LEFT)) { /* embraced member */
|
||||
if (IVAL(&(tp->tp_up), ex->OP_LEFT) != 0)
|
||||
too_many_initialisers(ex);
|
||||
ex = ex->OP_RIGHT;
|
||||
}
|
||||
else {
|
||||
if (aggregate_type(tp->tp_up))
|
||||
ex = IVAL(&(tp->tp_up), ex);
|
||||
else {
|
||||
check_ival(ex->OP_LEFT, tp->tp_up);
|
||||
ex = ex->OP_RIGHT;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ex && elem_count == dim)
|
||||
/* all the members are initialised but there
|
||||
remains a part of the expression tree which
|
||||
is returned
|
||||
*/
|
||||
return ex;
|
||||
if ((ex == 0) && elem_count < dim)
|
||||
/* the expression tree is completely absorbed
|
||||
but there are still members which must be
|
||||
initialised with zeroes
|
||||
*/
|
||||
do
|
||||
pad(tp->tp_up);
|
||||
while (++elem_count < dim);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* do_struct() initialises a struct of type tp with the expression expr.
|
||||
The main loop is just controlled by the definition of the selectors
|
||||
during which alignment is taken care of.
|
||||
*/
|
||||
struct expr *
|
||||
do_struct(ex, tp)
|
||||
register struct expr *ex;
|
||||
register struct type *tp;
|
||||
{
|
||||
register struct sdef *sd = tp->tp_sdef;
|
||||
arith bytes_upto_here = (arith)0;
|
||||
arith last_offset = (arith)-1;
|
||||
|
||||
ASSERT(tp->tp_fund == STRUCT && ISCOMMA(ex));
|
||||
/* as long as there are selectors and there is an initialiser.. */
|
||||
while (sd && ex) {
|
||||
if (ISCOMMA(ex->OP_LEFT)) { /* embraced expression */
|
||||
if (IVAL(&(sd->sd_type), ex->OP_LEFT) != 0)
|
||||
too_many_initialisers(ex);
|
||||
ex = ex->OP_RIGHT;
|
||||
}
|
||||
else {
|
||||
if (aggregate_type(sd->sd_type))
|
||||
/* selector is an aggregate itself */
|
||||
ex = IVAL(&(sd->sd_type), ex);
|
||||
else {
|
||||
#ifdef NOBITFIELD
|
||||
/* fundamental type, not embraced */
|
||||
check_ival(ex->OP_LEFT, sd->sd_type);
|
||||
ex = ex->OP_RIGHT;
|
||||
#else
|
||||
if (is_anon_idf(sd->sd_idf))
|
||||
/* a hole in the struct due to
|
||||
the use of ";:n;" in a struct
|
||||
definition.
|
||||
*/
|
||||
put_bf(sd->sd_type, (arith)0);
|
||||
else { /* fundamental type, not embraced */
|
||||
check_ival(ex->OP_LEFT, sd->sd_type);
|
||||
ex = ex->OP_RIGHT;
|
||||
}
|
||||
#endif NOBITFIELD
|
||||
}
|
||||
}
|
||||
if (sd->sd_sdef) /* align upto the next selector boundary */
|
||||
bytes_upto_here += zero_bytes(sd);
|
||||
if (last_offset != sd->sd_offset) {
|
||||
/* don't take the field-width more than once */
|
||||
bytes_upto_here +=
|
||||
size_of_type(sd->sd_type, "selector");
|
||||
last_offset = sd->sd_offset;
|
||||
}
|
||||
sd = sd->sd_sdef;
|
||||
}
|
||||
/* perfect fit if (ex && (sd == 0)) holds */
|
||||
if ((ex == 0) && (sd != 0)) {
|
||||
/* there are selectors left which must be padded with zeroes */
|
||||
do {
|
||||
pad(sd->sd_type);
|
||||
/* take care of the alignment restrictions */
|
||||
if (sd->sd_sdef)
|
||||
bytes_upto_here += zero_bytes(sd);
|
||||
/* no field thrown-outs here */
|
||||
bytes_upto_here +=
|
||||
size_of_type(sd->sd_type, "selector");
|
||||
} while (sd = sd->sd_sdef);
|
||||
}
|
||||
/* keep on aligning... */
|
||||
while (bytes_upto_here++ < tp->tp_size)
|
||||
con_nullbyte();
|
||||
return ex;
|
||||
}
|
||||
|
||||
/* check_and_pad() is given a simple initialisation expression
|
||||
where the type can be either a simple or an aggregate type.
|
||||
In the latter case, only the first member is initialised and
|
||||
the rest is zeroed.
|
||||
*/
|
||||
check_and_pad(ex, tpp)
|
||||
register struct expr *ex;
|
||||
struct type **tpp;
|
||||
{
|
||||
/* ex is of a fundamental type */
|
||||
register struct type *tp = *tpp;
|
||||
|
||||
if (tp->tp_fund == ARRAY) {
|
||||
if (valid_type(tp->tp_up, "array element") == 0)
|
||||
return;
|
||||
check_and_pad(ex, &(tp->tp_up)); /* first member */
|
||||
if (tp->tp_size == (arith)-1)
|
||||
/* no size specified upto here: just
|
||||
set it to the size of one member.
|
||||
*/
|
||||
tp = *tpp = construct_type(ARRAY, tp->tp_up, (arith)1);
|
||||
else {
|
||||
register int dim = tp->tp_size / tp->tp_up->tp_size;
|
||||
/* pad remaining members with zeroes */
|
||||
while (--dim > 0)
|
||||
pad(tp->tp_up);
|
||||
}
|
||||
}
|
||||
else
|
||||
if (tp->tp_fund == STRUCT) {
|
||||
register struct sdef *sd = tp->tp_sdef;
|
||||
|
||||
if (valid_type(tp, "struct") == 0)
|
||||
return;
|
||||
check_and_pad(ex, &(sd->sd_type));
|
||||
/* next selector is aligned by adding extra zeroes */
|
||||
if (sd->sd_sdef)
|
||||
zero_bytes(sd);
|
||||
while (sd = sd->sd_sdef) { /* pad remaining selectors */
|
||||
pad(sd->sd_type);
|
||||
if (sd->sd_sdef)
|
||||
zero_bytes(sd);
|
||||
}
|
||||
}
|
||||
else /* simple type */
|
||||
check_ival(ex, tp);
|
||||
}
|
||||
|
||||
/* pad() fills an element of type tp with zeroes.
|
||||
If the element is an aggregate, pad() is called recursively.
|
||||
*/
|
||||
pad(tp)
|
||||
register struct type *tp;
|
||||
{
|
||||
register arith sz = tp->tp_size;
|
||||
|
||||
switch (tp->tp_fund) {
|
||||
case ARRAY:
|
||||
if (valid_type(tp->tp_up, "array element") == 0)
|
||||
return;
|
||||
break;
|
||||
case STRUCT:
|
||||
if (valid_type(tp, "struct") == 0)
|
||||
return;
|
||||
break;
|
||||
case UNION:
|
||||
if (valid_type(tp, "union") == 0)
|
||||
return;
|
||||
if (options['R']) {
|
||||
warning("initialisation of unions not allowed");
|
||||
}
|
||||
break;
|
||||
#ifndef NOBITFIELD
|
||||
case FIELD:
|
||||
put_bf(tp, (arith)0);
|
||||
return;
|
||||
#endif NOBITFIELD
|
||||
case ERRONEOUS:
|
||||
return;
|
||||
}
|
||||
|
||||
while (sz >= word_size) {
|
||||
C_con_cst((arith) 0);
|
||||
sz -= word_size;
|
||||
}
|
||||
while (sz) {
|
||||
C_con_icon("0", (arith) 1);
|
||||
sz--;
|
||||
}
|
||||
}
|
||||
|
||||
/* check_ival() checks whether the initialisation of an element
|
||||
of a fundamental type is legal and, if so, performs the initialisation
|
||||
by directly generating the necessary code.
|
||||
No further comment is needed to explain the internal structure
|
||||
of this straightforward function.
|
||||
*/
|
||||
check_ival(expr, tp)
|
||||
register struct expr *expr;
|
||||
register struct type *tp;
|
||||
{
|
||||
/* The philosophy here is that ch7cast puts an explicit
|
||||
conversion node in front of the expression if the types
|
||||
are not compatible. In this case, the initialisation
|
||||
expression is no longer a constant.
|
||||
*/
|
||||
struct expr *ex = expr;
|
||||
|
||||
switch (tp->tp_fund) {
|
||||
case CHAR:
|
||||
case SHORT:
|
||||
case INT:
|
||||
case LONG:
|
||||
case ENUM:
|
||||
case POINTER:
|
||||
ch7cast(&ex, '=', tp);
|
||||
expr = ex;
|
||||
#ifdef DEBUG
|
||||
print_expr("init-expr after cast", expr);
|
||||
#endif DEBUG
|
||||
if (!is_ld_cst(expr))
|
||||
illegal_init_cst(expr);
|
||||
else
|
||||
if (expr->VL_CLASS == Const)
|
||||
con_int(expr);
|
||||
else
|
||||
if (expr->VL_CLASS == Name) {
|
||||
register struct idf *idf = expr->VL_IDF;
|
||||
|
||||
if (idf->id_def->df_level >= L_LOCAL)
|
||||
illegal_init_cst(expr);
|
||||
else /* e.g., int f(); int p = f; */
|
||||
if (idf->id_def->df_type->tp_fund == FUNCTION)
|
||||
C_con_pnam(idf->id_text);
|
||||
else /* e.g., int a; int *p = &a; */
|
||||
C_con_dnam(idf->id_text, expr->VL_VALUE);
|
||||
}
|
||||
else {
|
||||
ASSERT(expr->VL_CLASS == Label);
|
||||
C_con_dlb(expr->VL_LBL, expr->VL_VALUE);
|
||||
}
|
||||
break;
|
||||
#ifndef NOFLOAT
|
||||
case FLOAT:
|
||||
case DOUBLE:
|
||||
ch7cast(&ex, '=', tp);
|
||||
expr = ex;
|
||||
#ifdef DEBUG
|
||||
print_expr("init-expr after cast", expr);
|
||||
#endif DEBUG
|
||||
if (expr->ex_class == Float)
|
||||
C_con_fcon(expr->FL_VALUE, expr->ex_type->tp_size);
|
||||
else
|
||||
if (expr->ex_class == Oper && expr->OP_OPER == INT2FLOAT) {
|
||||
/* float f = 1; */
|
||||
expr = expr->OP_RIGHT;
|
||||
if (is_cp_cst(expr))
|
||||
C_con_fcon(long2str((long)expr->VL_VALUE, 10),
|
||||
tp->tp_size);
|
||||
else
|
||||
illegal_init_cst(expr);
|
||||
}
|
||||
else
|
||||
illegal_init_cst(expr);
|
||||
break;
|
||||
#endif NOFLOAT
|
||||
|
||||
#ifndef NOBITFIELD
|
||||
case FIELD:
|
||||
ch7cast(&ex, '=', tp->tp_up);
|
||||
expr = ex;
|
||||
#ifdef DEBUG
|
||||
print_expr("init-expr after cast", expr);
|
||||
#endif DEBUG
|
||||
if (is_cp_cst(expr))
|
||||
put_bf(tp, expr->VL_VALUE);
|
||||
else
|
||||
illegal_init_cst(expr);
|
||||
break;
|
||||
#endif NOBITFIELD
|
||||
|
||||
case ERRONEOUS:
|
||||
break;
|
||||
default:
|
||||
crash("check_ival");
|
||||
}
|
||||
}
|
||||
|
||||
/* ch_array() initialises an array of characters when given
|
||||
a string constant.
|
||||
Alignment is taken care of.
|
||||
*/
|
||||
ch_array(tpp, ex)
|
||||
struct type **tpp; /* type tp = array of characters */
|
||||
struct expr *ex;
|
||||
{
|
||||
register struct type *tp = *tpp;
|
||||
register arith length = ex->SG_LEN;
|
||||
char *s;
|
||||
arith ntopad;
|
||||
|
||||
ASSERT(ex->ex_class == String);
|
||||
if (tp->tp_size == (arith)-1) {
|
||||
/* set the dimension */
|
||||
tp = *tpp = construct_type(ARRAY, tp->tp_up, length);
|
||||
ntopad = align(tp->tp_size, word_size) - tp->tp_size;
|
||||
}
|
||||
else {
|
||||
arith dim = tp->tp_size / tp->tp_up->tp_size;
|
||||
extern char options[];
|
||||
|
||||
if (length > dim) {
|
||||
if (options['R'])
|
||||
too_many_initialisers(ex);
|
||||
else { /* don't take the null byte into account */
|
||||
if (length > dim + 1)
|
||||
expr_warning(ex,
|
||||
"too many initialisers");
|
||||
length = dim;
|
||||
}
|
||||
}
|
||||
ntopad = align(dim, word_size) - length;
|
||||
}
|
||||
/* throw out the characters of the already prepared string */
|
||||
s = Malloc((unsigned) (length + ntopad));
|
||||
clear(s, (int) (length + ntopad));
|
||||
strncpy(s, ex->SG_VALUE, (int) length);
|
||||
free(ex->SG_VALUE);
|
||||
str_cst(s, (int) (length + ntopad));
|
||||
free(s);
|
||||
}
|
||||
|
||||
/* As long as some parts of the pipeline cannot handle very long string
|
||||
constants, string constants are written out in chunks
|
||||
*/
|
||||
str_cst(str, len)
|
||||
register char *str;
|
||||
register int len;
|
||||
{
|
||||
arith chunksize = ((127 + word_size) / word_size) * word_size;
|
||||
|
||||
while (len > chunksize) {
|
||||
C_con_scon(str, chunksize);
|
||||
len -= chunksize;
|
||||
str += chunksize;
|
||||
}
|
||||
C_con_scon(str, (arith) len);
|
||||
}
|
||||
|
||||
#ifndef NOBITFIELD
|
||||
/* put_bf() takes care of the initialisation of (bit-)field
|
||||
selectors of a struct: each time such an initialisation takes place,
|
||||
put_bf() is called instead of the normal code generating routines.
|
||||
Put_bf() stores the given integral value into "field" and
|
||||
"throws" the result of "field" out if the current selector
|
||||
is the last of this number of fields stored at the same address.
|
||||
*/
|
||||
put_bf(tp, val)
|
||||
struct type *tp;
|
||||
arith val;
|
||||
{
|
||||
static long field = (arith)0;
|
||||
static arith offset = (arith)-1;
|
||||
register struct field *fd = tp->tp_field;
|
||||
register struct sdef *sd = fd->fd_sdef;
|
||||
static struct expr exp;
|
||||
|
||||
ASSERT(sd);
|
||||
if (offset == (arith)-1) {
|
||||
/* first bitfield in this field */
|
||||
offset = sd->sd_offset;
|
||||
exp.ex_type = tp->tp_up;
|
||||
exp.ex_class = Value;
|
||||
exp.VL_CLASS = Const;
|
||||
}
|
||||
if (val != 0) /* insert the value into "field" */
|
||||
field |= (val & fd->fd_mask) << fd->fd_shift;
|
||||
if (sd->sd_sdef == 0 || sd->sd_sdef->sd_offset != offset) {
|
||||
/* the selector was the last stored at this address */
|
||||
exp.VL_VALUE = field;
|
||||
con_int(&exp);
|
||||
field = (arith)0;
|
||||
offset = (arith)-1;
|
||||
}
|
||||
}
|
||||
#endif NOBITFIELD
|
||||
|
||||
int
|
||||
zero_bytes(sd)
|
||||
register struct sdef *sd;
|
||||
{
|
||||
/* fills the space between a selector of a struct
|
||||
and the next selector of that struct with zero-bytes.
|
||||
*/
|
||||
register int n = sd->sd_sdef->sd_offset - sd->sd_offset -
|
||||
size_of_type(sd->sd_type, "struct member");
|
||||
register int count = n;
|
||||
|
||||
while (n-- > 0)
|
||||
con_nullbyte();
|
||||
return count;
|
||||
}
|
||||
|
||||
int
|
||||
valid_type(tp, str)
|
||||
struct type *tp;
|
||||
char *str;
|
||||
{
|
||||
if (tp->tp_size < 0) {
|
||||
error("size of %s unknown", str);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
con_int(ex)
|
||||
register struct expr *ex;
|
||||
{
|
||||
register struct type *tp = ex->ex_type;
|
||||
|
||||
ASSERT(is_cp_cst(ex));
|
||||
if (tp->tp_unsigned)
|
||||
C_con_ucon(long2str((long)ex->VL_VALUE, -10), tp->tp_size);
|
||||
else
|
||||
C_con_icon(long2str((long)ex->VL_VALUE, 10), tp->tp_size);
|
||||
}
|
||||
|
||||
illegal_init_cst(ex)
|
||||
struct expr *ex;
|
||||
{
|
||||
expr_error(ex, "illegal initialisation constant");
|
||||
}
|
||||
|
||||
too_many_initialisers(ex)
|
||||
struct expr *ex;
|
||||
{
|
||||
expr_error(ex, "too many initialisers");
|
||||
}
|
||||
|
||||
aggregate_type(tp)
|
||||
register struct type *tp;
|
||||
{
|
||||
return tp->tp_fund == ARRAY || tp->tp_fund == STRUCT;
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
/* $Header$ */
|
||||
/* PREPROCESSOR: DEFINITION OF MACRO DESCRIPTOR */
|
||||
|
||||
#include "nopp.h"
|
||||
|
||||
#ifndef NOPP
|
||||
/* The flags of the mc_flag field of the macro structure. Note that
|
||||
these flags can be set simultaneously.
|
||||
*/
|
||||
#define NOFLAG 0 /* no special flags */
|
||||
#define FUNC 01 /* function attached */
|
||||
#define PREDEF 02 /* predefined macro */
|
||||
|
||||
#define FORMALP 0200 /* mask for creating macro formal parameter */
|
||||
|
||||
/* The macro descriptor is very simple, except the fact that the
|
||||
mc_text, which points to the replacement text, contains the
|
||||
non-ascii characters \201, \202, etc, indicating the position of a
|
||||
formal parameter in this text.
|
||||
*/
|
||||
struct macro {
|
||||
struct macro *next;
|
||||
char * mc_text; /* the replacement text */
|
||||
int mc_nps; /* number of formal parameters */
|
||||
int mc_length; /* length of replacement text */
|
||||
char mc_flag; /* marking this macro */
|
||||
};
|
||||
|
||||
|
||||
/* allocation definitions of struct macro */
|
||||
/* ALLOCDEF "macro" */
|
||||
extern char *st_alloc();
|
||||
extern struct macro *h_macro;
|
||||
#define new_macro() ((struct macro *) \
|
||||
st_alloc((char **)&h_macro, sizeof(struct macro)))
|
||||
#define free_macro(p) st_free(p, h_macro, sizeof(struct macro))
|
||||
|
||||
|
||||
/* `token' numbers of keywords of command-line processor
|
||||
*/
|
||||
#define K_UNKNOWN 0
|
||||
#define K_DEFINE 1
|
||||
#define K_ELIF 2
|
||||
#define K_ELSE 3
|
||||
#define K_ENDIF 4
|
||||
#define K_IF 5
|
||||
#define K_IFDEF 6
|
||||
#define K_IFNDEF 7
|
||||
#define K_INCLUDE 8
|
||||
#define K_LINE 9
|
||||
#define K_UNDEF 10
|
||||
#endif NOPP
|
||||
@@ -1,19 +0,0 @@
|
||||
ed - $1 <<'--EOI--'
|
||||
g/^%/d
|
||||
g/^ /.-1,.j
|
||||
1,$s/^\([^|]*\)|\([^|]*\)|\(.*\)$/\
|
||||
\1 \2 {\
|
||||
\3;\
|
||||
}/
|
||||
1i
|
||||
/* EM COMPACT CODE -- PROCEDURAL INTERFACE (generated from emcode.def) */
|
||||
#include "em.h"
|
||||
#ifdef PROC_INTF
|
||||
#include "label.h"
|
||||
#include "arith.h"
|
||||
.
|
||||
$a
|
||||
#endif PROC_INTF
|
||||
.
|
||||
1,$p
|
||||
--EOI--
|
||||
@@ -1,10 +0,0 @@
|
||||
ed - $1 <<'--EOI--'
|
||||
g/^%/d
|
||||
g/^ /.-1,.j
|
||||
1,$s/^\([^|]*\)|[^|]*|\(.*\)$/\
|
||||
#define \1 (\2)/
|
||||
1i
|
||||
/* EM COMPACT CODE -- MACRO DEFINITIONS (generated from emcode.def) */
|
||||
.
|
||||
1,$p
|
||||
--EOI--
|
||||
@@ -1,46 +0,0 @@
|
||||
/* $Header$ */
|
||||
/* IDENTIFIER STACK DEFINITIONS */
|
||||
|
||||
/* The identifier stack is implemented as a stack of sets.
|
||||
The stack is implemented by a doubly linked list,
|
||||
the sets by singly linked lists.
|
||||
*/
|
||||
|
||||
struct stack_level {
|
||||
struct stack_level *next;
|
||||
struct stack_level *sl_next; /* upward link */
|
||||
struct stack_level *sl_previous; /* downward link */
|
||||
struct stack_entry *sl_entry; /* sideward link */
|
||||
arith sl_local_offset; /* @ for first coming object */
|
||||
arith sl_max_block; /* maximum size of sub-block */
|
||||
int sl_level;
|
||||
};
|
||||
|
||||
|
||||
/* allocation definitions of struct stack_level */
|
||||
/* ALLOCDEF "stack_level" */
|
||||
extern char *st_alloc();
|
||||
extern struct stack_level *h_stack_level;
|
||||
#define new_stack_level() ((struct stack_level *) \
|
||||
st_alloc((char **)&h_stack_level, sizeof(struct stack_level)))
|
||||
#define free_stack_level(p) st_free(p, h_stack_level, sizeof(struct stack_level))
|
||||
|
||||
|
||||
struct stack_entry {
|
||||
struct stack_entry *next;
|
||||
struct idf *se_idf;
|
||||
};
|
||||
|
||||
|
||||
/* allocation definitions of struct stack_entry */
|
||||
/* ALLOCDEF "stack_entry" */
|
||||
extern char *st_alloc();
|
||||
extern struct stack_entry *h_stack_entry;
|
||||
#define new_stack_entry() ((struct stack_entry *) \
|
||||
st_alloc((char **)&h_stack_entry, sizeof(struct stack_entry)))
|
||||
#define free_stack_entry(p) st_free(p, h_stack_entry, sizeof(struct stack_entry))
|
||||
|
||||
|
||||
extern struct stack_level *local_level;
|
||||
extern struct stack_level *stack_level_of();
|
||||
extern int level;
|
||||
@@ -1,67 +0,0 @@
|
||||
/* $Header$ */
|
||||
/* S T R U C T U R E - S T O R A G E M A N A G E M E N T */
|
||||
|
||||
/* Assume that each structure contains a field "next", of pointer
|
||||
type, as first tagfield.
|
||||
struct xxx serves as a general structure: it just declares the
|
||||
tagfield "next" as first field of a structure.
|
||||
Please don't worry about any warnings when compiling this file
|
||||
because some dirty tricks are performed to obtain the necessary
|
||||
actions.
|
||||
*/
|
||||
|
||||
#include "debug.h" /* UF */
|
||||
#include "botch_free.h" /* UF */
|
||||
#include "assert.h"
|
||||
#include "alloc.h"
|
||||
#include "storage.h"
|
||||
|
||||
struct xxx {
|
||||
char *next;
|
||||
};
|
||||
|
||||
char *
|
||||
head_alloc(phead, size)
|
||||
char **phead;
|
||||
int size;
|
||||
{
|
||||
struct xxx *tmp;
|
||||
|
||||
if (*phead == 0) {
|
||||
return Malloc(size);
|
||||
}
|
||||
tmp = (struct xxx *) (*phead);
|
||||
*phead = (char *) tmp->next;
|
||||
return (char *) tmp;
|
||||
}
|
||||
|
||||
/* instead of Calloc: */
|
||||
clear(ptr, n)
|
||||
char *ptr;
|
||||
int n;
|
||||
{
|
||||
ASSERT((long)ptr % sizeof (long) == 0);
|
||||
while (n >= sizeof (long)) { /* high-speed clear loop */
|
||||
*(long *)ptr = 0L;
|
||||
ptr += sizeof (long), n -= sizeof (long);
|
||||
}
|
||||
while (n--)
|
||||
*ptr++ = '\0';
|
||||
}
|
||||
|
||||
#ifdef BOTCH_FREE
|
||||
botch(ptr, n)
|
||||
char *ptr;
|
||||
int n;
|
||||
{ /* Writes garbage over n chars starting from ptr.
|
||||
Used to check if freed memory is used inappropriately.
|
||||
*/
|
||||
ASSERT((long)ptr % sizeof (long) == 0);
|
||||
while (n >= sizeof (long)) { /* high-speed botch loop */
|
||||
*(long *)ptr = 025252525252L;
|
||||
ptr += sizeof (long), n -= sizeof (long);
|
||||
}
|
||||
while (n--)
|
||||
*ptr++ = '\252';
|
||||
}
|
||||
#endif BOTCH_FREE
|
||||
@@ -1,23 +0,0 @@
|
||||
/* $Header$ */
|
||||
/* S T R U C T U R E - S T O R A G E D E F I N I T I O N S */
|
||||
|
||||
/* Storage allocation is one of the most expensive operations in
|
||||
the compiler and consequently much thought and experimentation
|
||||
has gone into it. To simplify the hooking in of new super-fancy
|
||||
algorithms, all allocating and freeing of storage for structs
|
||||
goes through the macros
|
||||
st_alloc(&head, size)
|
||||
st_free(ptr, head, size)
|
||||
which, hopefully, convey enough information.
|
||||
*/
|
||||
|
||||
extern char *head_alloc();
|
||||
|
||||
#define st_alloc(headp, size) head_alloc((char **)headp, size)
|
||||
|
||||
#ifndef BOTCH_FREE
|
||||
#define st_free(ptr, head, size) (ptr->next = head, head = ptr)
|
||||
#else def BOTCH_FREE
|
||||
#define st_free(ptr, head, size) (botch((char *)(ptr), size), \
|
||||
ptr->next = head, head = ptr)
|
||||
#endif BOTCH_FREE
|
||||
@@ -1,277 +0,0 @@
|
||||
/* $Header$ */
|
||||
/* STRING MANIPULATION AND PRINT ROUTINES */
|
||||
|
||||
#include <system.h>
|
||||
#include "string.h"
|
||||
#include "nopp.h"
|
||||
#include "str_params.h"
|
||||
#include "arith.h"
|
||||
|
||||
doprnt(fp, fmt, argp)
|
||||
File *fp;
|
||||
char *fmt;
|
||||
int argp[];
|
||||
{
|
||||
char buf[SSIZE];
|
||||
|
||||
sys_write(fp, buf, format(buf, fmt, (char *)argp));
|
||||
}
|
||||
|
||||
/*VARARGS1*/
|
||||
printf(fmt, args)
|
||||
char *fmt;
|
||||
char args;
|
||||
{
|
||||
char buf[SSIZE];
|
||||
|
||||
sys_write(STDOUT, buf, format(buf, fmt, &args));
|
||||
}
|
||||
|
||||
/*VARARGS1*/
|
||||
fprintf(fp, fmt, args)
|
||||
File *fp;
|
||||
char *fmt;
|
||||
char args;
|
||||
{
|
||||
char buf[SSIZE];
|
||||
|
||||
sys_write(fp, buf, format(buf, fmt, &args));
|
||||
}
|
||||
|
||||
/*VARARGS1*/
|
||||
char *
|
||||
sprintf(buf, fmt, args)
|
||||
char *buf, *fmt;
|
||||
char args;
|
||||
{
|
||||
buf[format(buf, fmt, &args)] = '\0';
|
||||
return buf;
|
||||
}
|
||||
|
||||
int
|
||||
format(buf, fmt, argp)
|
||||
char *buf, *fmt;
|
||||
char *argp;
|
||||
{
|
||||
register char *pf = fmt, *pa = argp;
|
||||
register char *pb = buf;
|
||||
|
||||
while (*pf) {
|
||||
if (*pf == '%') {
|
||||
register width, base, pad, npad;
|
||||
char *arg;
|
||||
char cbuf[2];
|
||||
char *badformat = "<bad format>";
|
||||
|
||||
/* get padder */
|
||||
if (*++pf == '0') {
|
||||
pad = '0';
|
||||
++pf;
|
||||
}
|
||||
else
|
||||
pad = ' ';
|
||||
|
||||
/* get width */
|
||||
width = 0;
|
||||
while (*pf >= '0' && *pf <= '9')
|
||||
width = 10 * width + *pf++ - '0';
|
||||
|
||||
/* get text and move pa */
|
||||
if (*pf == 's') {
|
||||
arg = *(char **)pa;
|
||||
pa += sizeof(char *);
|
||||
}
|
||||
else
|
||||
if (*pf == 'c') {
|
||||
cbuf[0] = * (char *) pa;
|
||||
cbuf[1] = '\0';
|
||||
pa += sizeof(int);
|
||||
arg = &cbuf[0];
|
||||
}
|
||||
else
|
||||
if (*pf == 'l') {
|
||||
/* alignment ??? */
|
||||
if (base = integral(*++pf)) {
|
||||
arg = int_str(*(long *)pa, base);
|
||||
pa += sizeof(long);
|
||||
}
|
||||
else {
|
||||
pf--;
|
||||
arg = badformat;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (base = integral(*pf)) {
|
||||
arg = int_str((long)*(int *)pa, base);
|
||||
pa += sizeof(int);
|
||||
}
|
||||
else
|
||||
if (*pf == '%')
|
||||
arg = "%";
|
||||
else
|
||||
arg = badformat;
|
||||
|
||||
npad = width - strlen(arg);
|
||||
|
||||
while (npad-- > 0)
|
||||
*pb++ = pad;
|
||||
|
||||
while (*pb++ = *arg++);
|
||||
pb--;
|
||||
pf++;
|
||||
}
|
||||
else
|
||||
*pb++ = *pf++;
|
||||
}
|
||||
return pb - buf;
|
||||
}
|
||||
|
||||
integral(c)
|
||||
{
|
||||
switch (c) {
|
||||
case 'b':
|
||||
return -2;
|
||||
case 'd':
|
||||
return 10;
|
||||
case 'o':
|
||||
return -8;
|
||||
case 'u':
|
||||
return -10;
|
||||
case 'x':
|
||||
return -16;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Integer to String translator
|
||||
*/
|
||||
char *
|
||||
int_str(val, base)
|
||||
register long val;
|
||||
register base;
|
||||
{
|
||||
/* int_str() is a very simple integer to string converter.
|
||||
base < 0 : unsigned.
|
||||
base must be an element of [-16,-2] V [2,16].
|
||||
*/
|
||||
static char numbuf[MAXWIDTH];
|
||||
static char vec[] = "0123456789ABCDEF";
|
||||
register char *p = &numbuf[MAXWIDTH];
|
||||
int sign = (base > 0);
|
||||
|
||||
*--p = '\0'; /* null-terminate string */
|
||||
if (val) {
|
||||
if (base > 0) {
|
||||
if (val < (arith)0) {
|
||||
if ((val = -val) < (arith)0)
|
||||
goto overflow;
|
||||
}
|
||||
else
|
||||
sign = 0;
|
||||
}
|
||||
else
|
||||
if (base < 0) { /* unsigned */
|
||||
base = -base;
|
||||
if (val < (arith)0) {
|
||||
register mod, i;
|
||||
|
||||
overflow:
|
||||
/* this takes a rainy Sunday afternoon to explain */
|
||||
/* ??? */
|
||||
mod = 0;
|
||||
for (i = 0; i < 8 * sizeof val; i++) {
|
||||
mod <<= 1;
|
||||
if (val < 0)
|
||||
mod++;
|
||||
val <<= 1;
|
||||
if (mod >= base) {
|
||||
mod -= base;
|
||||
val++;
|
||||
}
|
||||
}
|
||||
*--p = vec[mod];
|
||||
}
|
||||
}
|
||||
|
||||
do {
|
||||
*--p = vec[(int) (val % base)];
|
||||
val /= base;
|
||||
} while (val != (arith)0);
|
||||
|
||||
if (sign)
|
||||
*--p = '-'; /* don't forget it !! */
|
||||
}
|
||||
else
|
||||
*--p = '0'; /* just a simple 0 */
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
/* return negative, zero or positive value if
|
||||
resp. s < t, s == t or s > t
|
||||
*/
|
||||
int
|
||||
strcmp(s, t)
|
||||
register char *s, *t;
|
||||
{
|
||||
while (*s == *t++)
|
||||
if (*s++ == '\0')
|
||||
return 0;
|
||||
return *s - *--t;
|
||||
}
|
||||
|
||||
/* return length of s
|
||||
*/
|
||||
int
|
||||
strlen(s)
|
||||
char *s;
|
||||
{
|
||||
register char *b = s;
|
||||
|
||||
while (*b++)
|
||||
;
|
||||
return b - s - 1;
|
||||
}
|
||||
|
||||
#ifndef NOPP
|
||||
/* append t to s
|
||||
*/
|
||||
char *
|
||||
strcat(s, t)
|
||||
register char *s, *t;
|
||||
{
|
||||
register char *b = s;
|
||||
|
||||
while (*s++)
|
||||
;
|
||||
s--;
|
||||
while (*s++ = *t++)
|
||||
;
|
||||
return b;
|
||||
}
|
||||
|
||||
/* Copy t into s
|
||||
*/
|
||||
char *
|
||||
strcpy(s, t)
|
||||
register char *s, *t;
|
||||
{
|
||||
register char *b = s;
|
||||
|
||||
while (*s++ = *t++)
|
||||
;
|
||||
return b;
|
||||
}
|
||||
|
||||
char *
|
||||
rindex(str, chr)
|
||||
register char *str, chr;
|
||||
{
|
||||
register char *retptr = 0;
|
||||
|
||||
while (*str)
|
||||
if (*str++ == chr)
|
||||
retptr = &str[-1];
|
||||
return retptr;
|
||||
}
|
||||
#endif NOPP
|
||||
@@ -1,13 +0,0 @@
|
||||
/* $Header$ */
|
||||
/* STRING-ROUTINE DEFINITIONS */
|
||||
|
||||
#define stdin 0
|
||||
#define stdout 1
|
||||
#define stderr 2
|
||||
|
||||
#define itos(n) int_str((long)(n), 10)
|
||||
|
||||
char *sprintf(); /* string.h */
|
||||
char *int_str(); /* string.h */
|
||||
|
||||
char *strcpy(), *strcat(), *rindex();
|
||||
@@ -1,44 +0,0 @@
|
||||
/* $Header$ */
|
||||
/* SELECTOR DESCRIPTOR */
|
||||
|
||||
struct sdef { /* for selectors */
|
||||
struct sdef *next;
|
||||
int sd_level;
|
||||
struct idf *sd_idf; /* its name */
|
||||
struct sdef *sd_sdef; /* the next selector */
|
||||
struct type *sd_stype; /* the struct it belongs to */
|
||||
struct type *sd_type; /* its type */
|
||||
arith sd_offset;
|
||||
};
|
||||
|
||||
extern char *st_alloc();
|
||||
|
||||
|
||||
/* allocation definitions of struct sdef */
|
||||
/* ALLOCDEF "sdef" */
|
||||
extern char *st_alloc();
|
||||
extern struct sdef *h_sdef;
|
||||
#define new_sdef() ((struct sdef *) \
|
||||
st_alloc((char **)&h_sdef, sizeof(struct sdef)))
|
||||
#define free_sdef(p) st_free(p, h_sdef, sizeof(struct sdef))
|
||||
|
||||
|
||||
struct tag { /* for struct-, union- and enum tags */
|
||||
struct tag *next;
|
||||
int tg_level;
|
||||
int tg_busy; /* non-zero during declaration of struct/union pack */
|
||||
struct type *tg_type;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* allocation definitions of struct tag */
|
||||
/* ALLOCDEF "tag" */
|
||||
extern char *st_alloc();
|
||||
extern struct tag *h_tag;
|
||||
#define new_tag() ((struct tag *) \
|
||||
st_alloc((char **)&h_tag, sizeof(struct tag)))
|
||||
#define free_tag(p) st_free(p, h_tag, sizeof(struct tag))
|
||||
|
||||
|
||||
struct sdef *idf2sdef();
|
||||
@@ -1,40 +0,0 @@
|
||||
/* $Header$ */
|
||||
/* S W I T C H - T A B L E - S T R U C T U R E */
|
||||
|
||||
struct switch_hdr {
|
||||
struct switch_hdr *next;
|
||||
label sh_break;
|
||||
label sh_default;
|
||||
label sh_table;
|
||||
int sh_nrofentries;
|
||||
struct type *sh_type;
|
||||
arith sh_lowerbd;
|
||||
arith sh_upperbd;
|
||||
struct case_entry *sh_entries;
|
||||
};
|
||||
|
||||
|
||||
/* allocation definitions of struct switch_hdr */
|
||||
/* ALLOCDEF "switch_hdr" */
|
||||
extern char *st_alloc();
|
||||
extern struct switch_hdr *h_switch_hdr;
|
||||
#define new_switch_hdr() ((struct switch_hdr *) \
|
||||
st_alloc((char **)&h_switch_hdr, sizeof(struct switch_hdr)))
|
||||
#define free_switch_hdr(p) st_free(p, h_switch_hdr, sizeof(struct switch_hdr))
|
||||
|
||||
|
||||
struct case_entry {
|
||||
struct case_entry *next;
|
||||
label ce_label;
|
||||
arith ce_value;
|
||||
};
|
||||
|
||||
|
||||
/* allocation definitions of struct case_entry */
|
||||
/* ALLOCDEF "case_entry" */
|
||||
extern char *st_alloc();
|
||||
extern struct case_entry *h_case_entry;
|
||||
#define new_case_entry() ((struct case_entry *) \
|
||||
st_alloc((char **)&h_case_entry, sizeof(struct case_entry)))
|
||||
#define free_case_entry(p) st_free(p, h_case_entry, sizeof(struct case_entry))
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
/* $Header$ */
|
||||
/* SYSTEM DEPENDENT ROUTINES */
|
||||
|
||||
#include "system.h"
|
||||
#include "inputtype.h"
|
||||
#include <sys/stat.h>
|
||||
|
||||
extern long lseek();
|
||||
|
||||
int
|
||||
xopen(name, flag, mode)
|
||||
char *name;
|
||||
{
|
||||
if (name[0] == '-' && name[1] == '\0')
|
||||
return (flag == OP_RDONLY) ? 0 : 1;
|
||||
|
||||
switch (flag) {
|
||||
|
||||
case OP_RDONLY:
|
||||
return open(name, 0);
|
||||
case OP_WRONLY:
|
||||
return open(name, 1);
|
||||
case OP_CREAT:
|
||||
return creat(name, mode);
|
||||
case OP_APPEND:
|
||||
{
|
||||
register fd;
|
||||
|
||||
if ((fd = open(name, 1)) < 0)
|
||||
return -1;
|
||||
lseek(fd, 0L, 2);
|
||||
return fd;
|
||||
}
|
||||
}
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
int
|
||||
xclose(fildes)
|
||||
{
|
||||
if (fildes != 0 && fildes != 1)
|
||||
return close(fildes);
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef READ_IN_ONE
|
||||
long
|
||||
xfsize(fildes)
|
||||
{
|
||||
struct stat stbuf;
|
||||
|
||||
if (fstat(fildes, &stbuf) != 0)
|
||||
return -1;
|
||||
return stbuf.st_size;
|
||||
}
|
||||
#endif READ_IN_ONE
|
||||
|
||||
exit(n)
|
||||
{
|
||||
_exit(n);
|
||||
}
|
||||
|
||||
xstop(how, stat)
|
||||
{
|
||||
switch (how) {
|
||||
case S_ABORT:
|
||||
abort();
|
||||
case S_EXIT:
|
||||
exit(stat);
|
||||
}
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/* $Header$ */
|
||||
/* SYSTEM DEPENDANT DEFINITIONS */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define OP_RDONLY 0 /* open for read */
|
||||
#define OP_WRONLY 1 /* open for write */
|
||||
#define OP_CREAT 2 /* create and open for write */
|
||||
#define OP_APPEND 3 /* open for write at end */
|
||||
|
||||
#define sys_open(name, flag) xopen(name, flag, 0)
|
||||
#define sys_close(fildes) xclose(fildes)
|
||||
#define sys_read(fildes, buffer, nbytes) read(fildes, buffer, nbytes)
|
||||
#define sys_write(fildes, buffer, nbytes) write(fildes, buffer, nbytes)
|
||||
#define sys_creat(name, mode) xopen(name, OP_CREAT, mode)
|
||||
#define sys_remove(name) unlink(name)
|
||||
#define sys_fsize(fd) xfsize(fd)
|
||||
#define sys_sbrk(incr) sbrk(incr)
|
||||
#define sys_stop(how, stat) xstop(how, stat)
|
||||
|
||||
#define S_ABORT 1
|
||||
#define S_EXIT 2
|
||||
|
||||
char *sbrk();
|
||||
long xfsize();
|
||||
|
||||
extern int errno;
|
||||
|
||||
#define sys_errno errno
|
||||
|
||||
#define time_type time_t
|
||||
#define sys_time(tloc) time(tloc)
|
||||
time_type time();
|
||||
@@ -1,52 +0,0 @@
|
||||
/* $Header$ */
|
||||
/* TYPE DESCRIPTOR */
|
||||
|
||||
#include "nobitfield.h"
|
||||
|
||||
struct type {
|
||||
struct type *next; /* used only with ARRAY */
|
||||
short tp_fund; /* fundamental type */
|
||||
char tp_unsigned;
|
||||
int tp_align;
|
||||
arith tp_size; /* -1 if declared but not defined */
|
||||
struct idf *tp_idf; /* name of STRUCT, UNION or ENUM */
|
||||
struct sdef *tp_sdef; /* to first selector */
|
||||
struct type *tp_up; /* from FIELD, POINTER, ARRAY
|
||||
or FUNCTION to fund. */
|
||||
struct field *tp_field; /* field descriptor if fund == FIELD */
|
||||
struct type *tp_pointer;/* to POINTER */
|
||||
struct type *tp_array; /* to ARRAY */
|
||||
struct type *tp_function;/* to FUNCTION */
|
||||
};
|
||||
|
||||
extern struct type
|
||||
*create_type(), *standard_type(), *construct_type(), *pointer_to(),
|
||||
*array_of(), *function_of();
|
||||
|
||||
#ifndef NOBITFIELD
|
||||
extern struct type *field_of();
|
||||
#endif NOBITFIELD
|
||||
|
||||
extern struct type
|
||||
*char_type, *uchar_type,
|
||||
*short_type, *ushort_type,
|
||||
*word_type, *uword_type,
|
||||
*int_type, *uint_type,
|
||||
*long_type, *ulong_type,
|
||||
*float_type, *double_type,
|
||||
*void_type, *label_type,
|
||||
*string_type, *funint_type, *error_type;
|
||||
|
||||
extern struct type *pa_type; /* type.c */
|
||||
|
||||
extern arith size_of_type(), align();
|
||||
|
||||
|
||||
/* allocation definitions of struct type */
|
||||
/* ALLOCDEF "type" */
|
||||
extern char *st_alloc();
|
||||
extern struct type *h_type;
|
||||
#define new_type() ((struct type *) \
|
||||
st_alloc((char **)&h_type, sizeof(struct type)))
|
||||
#define free_type(p) st_free(p, h_type, sizeof(struct type))
|
||||
|
||||
Reference in New Issue
Block a user