Delete 689 undead files.
These files "magically reappeared" after the conversion from CVS to Mercurial. The old CVS repository deleted these files but did not record *when* it deleted these files. The conversion resurrected these files because they have no history of deletion. These files were probably deleted before year 1995. The CVS repository begins to record deletions around 1995. These files may still appear in older revisions of this Mercurial repository, when they should already be deleted. There is no way to fix this, because the CVS repository provides no dates of deletion. See http://sourceforge.net/mailarchive/message.php?msg_id=29823032
This commit is contained in:
@@ -1,64 +0,0 @@
|
||||
# $Header$
|
||||
|
||||
EMHOME=../../..
|
||||
h=$(EMHOME)/h
|
||||
m=$(EMHOME)/modules/h
|
||||
LIBDIR= $(EMHOME)/modules/lib
|
||||
LIBDIR2= $(EMHOME)/lib
|
||||
CFLAGS = -I$h -I$m -O
|
||||
|
||||
FILES= bem.o symbols.o initialize.o compile.o \
|
||||
parsepar.o gencode.o util.o graph.o \
|
||||
eval.o func.o basic.o Lpars.o
|
||||
|
||||
CSRCFILES= bem.c symbols.c initialize.c compile.c \
|
||||
parsepar.c gencode.c util.c graph.c \
|
||||
eval.c func.c
|
||||
CGENFILES= basic.c Lpars.c
|
||||
CFILES=$(CSRCFILES) $(CGENFILES)
|
||||
|
||||
LIBFILES= $(LIBDIR)/libem_mes.a $(LIBDIR)/libemk.a \
|
||||
$(LIBDIR2)/em_data.a $(LIBDIR)/libprint.a \
|
||||
$(LIBDIR)/liballoc.a \
|
||||
$(LIBDIR)/libsystem.a $(LIBDIR)/libstring.a
|
||||
|
||||
LINTLIBFILES= $(LIBDIR)/llib-lem_mes.ln $(LIBDIR)/llib-lemk.ln \
|
||||
$(LIBDIR)/llib-lprint.ln \
|
||||
$(LIBDIR)/llib-lalloc.ln \
|
||||
$(LIBDIR)/llib-lsystem.ln $(LIBDIR)/llib-lstring.ln
|
||||
|
||||
all: dummy bem
|
||||
|
||||
dummy: basic.g
|
||||
LLgen basic.g
|
||||
touch dummy
|
||||
|
||||
install: all
|
||||
cp bem $(EMHOME)/lib/em_bem
|
||||
|
||||
cmp: all
|
||||
cmp bem $(EMHOME)/lib/em_bem
|
||||
|
||||
pr:
|
||||
@pr Makefile maketokentab bem.h symbols.h graph.h basic.g basic.lex $(CSRCFILES)
|
||||
|
||||
opr:
|
||||
make pr | opr
|
||||
|
||||
bem: $(FILES) $(LIBFILES)
|
||||
$(CC) -o bem $(FILES) $(LIBFILES)
|
||||
|
||||
basic.o : basic.c basic.lex Lpars.h llmess.c tokentab.h
|
||||
$(CC) $(CFLAGS) -c basic.c
|
||||
|
||||
$(FILES): bem.h symbols.h graph.h
|
||||
|
||||
tokentab.h: Lpars.h
|
||||
maketokentab
|
||||
|
||||
lint: dummy $(CFILES) tokentab.h
|
||||
lint -b $(CFLAGS) $(CFILES) $(LINTLIBFILES)
|
||||
|
||||
clean:
|
||||
rm -f *.o
|
||||
rm -f basic.c Lpars.h Lpars.c dummy tokentab.h bem
|
||||
@@ -1,143 +0,0 @@
|
||||
!File: lint.h
|
||||
#define LINT 1 /* if defined, 'lint' is produced */
|
||||
#define ANSI 1 /* tell l_* files it's ANSI */
|
||||
|
||||
|
||||
!File: pathlength.h
|
||||
#define PATHLENGTH 1024 /* max. length of path to file */
|
||||
|
||||
|
||||
!File: errout.h
|
||||
#define ERROUT STDERR /* file pointer for writing messages */
|
||||
#define ERR_SHADOW 0 /* a syntax error overshadows error messages
|
||||
until ERR_SHADOW symbols have been
|
||||
accepted without syntax error */
|
||||
|
||||
|
||||
!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 */
|
||||
#define STDC_NPARAMS 31 /* ANSI limit on number of parameters */
|
||||
|
||||
|
||||
!File: ifdepth.h
|
||||
#define IFDEPTH 256 /* maximum number of nested if-constructions */
|
||||
|
||||
|
||||
!File: density.h
|
||||
#define DENSITY 2 /* see switch.[ch] for an explanation */
|
||||
|
||||
|
||||
!File: macbuf.h
|
||||
#define LAPBUF 128 /* initial size of macro replacement buffer */
|
||||
#define ARGBUF 128 /* initial size of macro parameter buffer(s) */
|
||||
|
||||
|
||||
!File: strsize.h
|
||||
#define ISTRSIZE 32 /* minimum number of bytes allocated for
|
||||
storing a string */
|
||||
#define RSTRSIZE 16 /* step size in enlarging the memory for
|
||||
the storage of a string */
|
||||
|
||||
|
||||
!File: trgt_sizes.h
|
||||
#define MAXSIZE 8 /* the maximum of the SZ_* constants */
|
||||
|
||||
/* target machine sizes */
|
||||
#define SZ_CHAR 1
|
||||
#define SZ_SHORT 2
|
||||
#define SZ_WORD 4
|
||||
#define SZ_INT 4
|
||||
#define SZ_LONG 4
|
||||
#define SZ_FLOAT 4
|
||||
#define SZ_DOUBLE 8
|
||||
#define SZ_POINTER 4
|
||||
#define SZ_LNGDBL 8 /* for now */
|
||||
|
||||
/* 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
|
||||
#define AL_FLOAT SZ_WORD
|
||||
#define AL_DOUBLE SZ_WORD
|
||||
#define AL_LNGDBL SZ_WORD
|
||||
#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
|
||||
#undef DATAFLOW 1 /* produce some compile-time xref */
|
||||
|
||||
|
||||
!File: debug.h
|
||||
#undef DEBUG 1 /* perform various self-tests */
|
||||
|
||||
|
||||
!File: use_tmp.h
|
||||
#undef PREPEND_SCOPES 1 /* collect exa, exp, ina and inp commands
|
||||
and if USE_TMP is defined let them
|
||||
precede the rest of the generated
|
||||
compact code */
|
||||
#undef USE_TMP 1 /* use C_insertpart, C_endpart mechanism
|
||||
to generate EM-code in the order needed
|
||||
for the code-generators. If not defined,
|
||||
the old-style peephole optimizer is
|
||||
needed. */
|
||||
|
||||
|
||||
!File: parbufsize.h
|
||||
#define PARBUFSIZE 1024
|
||||
|
||||
|
||||
!File: textsize.h
|
||||
#define ITEXTSIZE 32 /* 1st piece of memory for repl. text */
|
||||
|
||||
|
||||
!File: inputtype.h
|
||||
#define 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 */
|
||||
#undef UNSIGNED_ARITH unsigned arith
|
||||
|
||||
|
||||
!File: static.h
|
||||
#define GSTATIC /* for large global "static" arrays */
|
||||
|
||||
|
||||
!File: nocross.h
|
||||
#undef NOCROSS 1 /* if NOT defined, cross compiler */
|
||||
|
||||
|
||||
!File: regcount.h
|
||||
#undef REGCOUNT 1 /* count occurrences for register messages */
|
||||
|
||||
|
||||
!File: dbsymtab.h
|
||||
#undef DBSYMTAB 1 /* ability to produce symbol table for debugger */
|
||||
|
||||
|
||||
@@ -1,718 +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 $(EMHOME)/lib/em_data.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 Lpars.c ival.c
|
||||
LOBJ = tokenfile.o declar.o statement.o expression.o program.o Lpars.o ival.o
|
||||
|
||||
CSRC = main.c idf.c declarator.c decspecs.c struct.c \
|
||||
expr.c ch7.c ch7bin.c cstoper.c arith.c \
|
||||
asm.c code.c dumpidf.c error.c field.c\
|
||||
tokenname.c LLlex.c LLmessage.c \
|
||||
input.c domacro.c replace.c init.c options.c \
|
||||
scan.c skip.c stack.c type.c ch7mon.c label.c eval.c \
|
||||
switch.c conversion.c util.c \
|
||||
blocks.c dataflow.c Version.c
|
||||
# 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 util.o \
|
||||
blocks.o dataflow.o Version.o
|
||||
|
||||
# Objects of other generated C files
|
||||
GCSRC = char.c symbol2str.c next.c
|
||||
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 util.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 \
|
||||
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 \
|
||||
reg_count.h
|
||||
|
||||
# Other generated files, for 'make clean' only
|
||||
GENERATED = 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 util.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 "EMHOME="$(EMHOME) "CC=$(CC)" hfiles
|
||||
make "EMHOME="$(EMHOME) "CC=$(CC)" LLfiles
|
||||
make "EMHOME="$(EMHOME) "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: char.tab
|
||||
$(EMHOME)/bin/tabgen -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
|
||||
util.h: make.allocd
|
||||
|
||||
# Objects needed for 'main'
|
||||
OBJ = $(COBJ) $(LOBJ) $(GOBJ)
|
||||
SRC = $(CSRC) $(LCSRC) $(GCSRC)
|
||||
|
||||
main: $(OBJ) Makefile.erik
|
||||
$(CC) $(COPTIONS) $(LFLAGS) $(OBJ) $(LIBS) -o main
|
||||
size main
|
||||
|
||||
emain: $(OBJ) Makefile.erik
|
||||
$(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 $(SRC)
|
||||
|
||||
shar: files
|
||||
shar `cat files`
|
||||
|
||||
listcfiles:
|
||||
@echo $(SRC)
|
||||
|
||||
listobjects:
|
||||
@echo $(OBJ)
|
||||
|
||||
depend: cfiles
|
||||
sed '/^#AUTOAUTO/,$$d' Makefile.erik >Makefile.erik.new
|
||||
echo '#AUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTO' >>Makefile.erik.new
|
||||
$(MKDEP) $(SRC) | sed 's/\.c:/.o:/' >>Makefile.erik.new
|
||||
mv Makefile.erik Makefile.erik.old
|
||||
mv Makefile.erik.new Makefile.erik
|
||||
|
||||
xref:
|
||||
ctags -x `grep "\.[ch]" files`|sed "s/).*/)/">Xref
|
||||
|
||||
lxref:
|
||||
lxref $(OBJ) -lc >lxref
|
||||
|
||||
lint: lint.main lint.cem
|
||||
|
||||
lint.main: cfiles
|
||||
$(LINT) -bx $(CDEFS) $(SRC) $(LINTLIBS) >lint.out
|
||||
|
||||
cchk:
|
||||
cchk $(SRC)
|
||||
|
||||
clean:
|
||||
rm -f $(LCSRC) $(OBJ) $(GENERATED) $(GSRC) $(GHSRC)
|
||||
|
||||
sim: cfiles
|
||||
$(SIM) $(SIMFLAGS) $(CSRC) $(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: 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: Lpars.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: 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
|
||||
field.o: Lpars.h
|
||||
field.o: align.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: 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: specials.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
|
||||
util.o: Lpars.h
|
||||
util.o: align.h
|
||||
util.o: def.h
|
||||
util.o: nocross.h
|
||||
util.o: nofloat.h
|
||||
util.o: regcount.h
|
||||
util.o: sizes.h
|
||||
util.o: stack.h
|
||||
util.o: target_sizes.h
|
||||
util.o: use_tmp.h
|
||||
util.o: util.h
|
||||
blocks.o: Lpars.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
|
||||
char.o: class.h
|
||||
symbol2str.o: Lpars.h
|
||||
@@ -1,67 +0,0 @@
|
||||
: create a directory Xsrc with name clashes resolved
|
||||
: and run make in that directory
|
||||
: '$Header$'
|
||||
|
||||
case $# in
|
||||
1)
|
||||
;;
|
||||
*) echo "$0: one argument expected" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
PW=`pwd`
|
||||
options=
|
||||
case $1 in
|
||||
main|emain|lnt)
|
||||
target=$PW/$1
|
||||
;;
|
||||
omain)
|
||||
target=$PW/$1
|
||||
options=-DPEEPHOLE
|
||||
;;
|
||||
cemain)
|
||||
target=$PW/$1
|
||||
options=-DCODE_EXPANDER
|
||||
;;
|
||||
Xlint)
|
||||
target=$1
|
||||
;;
|
||||
*) echo "$0: $1: Illegal argument" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
if test -d ../Xsrc
|
||||
then
|
||||
:
|
||||
else mkdir ../Xsrc
|
||||
fi
|
||||
make EMHOME=$EMHOME longnames
|
||||
: remove code generating routines from the clashes list as they are defines.
|
||||
: code generating routine names start with C_
|
||||
sed '/^C_/d' < longnames > tmp$$
|
||||
cclash -c -l7 tmp$$ > ../Xsrc/Xclashes
|
||||
rm -f tmp$$
|
||||
cd ../Xsrc
|
||||
if cmp -s Xclashes clashes
|
||||
then
|
||||
:
|
||||
else
|
||||
mv Xclashes clashes
|
||||
fi
|
||||
rm -f Makefile
|
||||
for i in `cat $PW/Cfiles`
|
||||
do
|
||||
cat >> Makefile <<EOF
|
||||
|
||||
$i: clashes $PW/$i
|
||||
cid -Fclashes < $PW/$i > $i
|
||||
EOF
|
||||
done
|
||||
make EMHOME=$EMHOME `cat $PW/Cfiles`
|
||||
rm -f Makefile
|
||||
ed - $PW/Makefile <<'EOF'
|
||||
/^#EXCLEXCL/,/^#INCLINCL/d
|
||||
w Makefile
|
||||
q
|
||||
EOF
|
||||
make EMHOME=$EMHOME COPTIONS=$options MACH=$mach CURRDIR=$PW/ $target
|
||||
@@ -1,8 +0,0 @@
|
||||
/* $Header$ */
|
||||
/*
|
||||
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||
*/
|
||||
#ifndef lint
|
||||
static char Version[] = "ACK CEM compiler Version 3.1";
|
||||
#endif lint
|
||||
@@ -1,16 +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$ */
|
||||
/* A S M */
|
||||
|
||||
/*ARGSUSED*/
|
||||
code_asm(s, l)
|
||||
char *s;
|
||||
int l;
|
||||
{
|
||||
/* 'asm' '(' string ')' ';'
|
||||
*/
|
||||
error("\"asm\" instruction not implemented");
|
||||
}
|
||||
@@ -1,230 +0,0 @@
|
||||
.TH CEM 1L 86/11/12
|
||||
.SH NAME
|
||||
cem \- ACK C compiler
|
||||
.SH SYNOPSIS
|
||||
.B cem
|
||||
[ option ] ... file ...
|
||||
.SH DESCRIPTION
|
||||
.I Cem
|
||||
is a
|
||||
.I cc (1)-like
|
||||
C compiler that uses the C front-end compiler
|
||||
.I cemcom (1)
|
||||
of the Amsterdam Compiler Kit.
|
||||
.I Cem
|
||||
interprets its arguments not starting with a '\-' as
|
||||
source files, to be compiled by the various parts of the compilation process,
|
||||
which are listed below.
|
||||
File arguments whose names end with \fB.\fP\fIcharacter\fP are interpreted as
|
||||
follows:
|
||||
.IP .[ao]
|
||||
object file.
|
||||
.IP .[ci]
|
||||
C source code
|
||||
.IP .e
|
||||
EM assembler source file.
|
||||
.IP .k
|
||||
compact EM file, not yet optimized by the EM peephole optimizer.
|
||||
.IP .m
|
||||
compact EM file, already optimized by the peephole optimizer.
|
||||
.IP .s
|
||||
assembler file.
|
||||
.LP
|
||||
The actions to be taken by
|
||||
.I cem
|
||||
are directed by the type of file argument and the various options that are
|
||||
presented to it.
|
||||
.PP
|
||||
The following set of options, which is a mixture of options interpreted by
|
||||
.I cc (1)
|
||||
and
|
||||
.I ack (?)
|
||||
are interpreted by
|
||||
.I cem .
|
||||
(The options not specified here are passed to the loader.)
|
||||
.IP \fB\-B\fP\fIname\fP
|
||||
Use
|
||||
.I name
|
||||
as front-end compiler instead of the default
|
||||
.I cemcom (1).
|
||||
.br
|
||||
Same as "\fB\-Rcem=\fP\fIname\fP".
|
||||
.IP \fB\-C\fP
|
||||
Run C preprocessor
|
||||
.I /lib/cpp
|
||||
only and prevent it from eliding comments.
|
||||
.IP \fB\-D\fP\fIname\fP\fB=\fP\fIdef\fP
|
||||
Define the
|
||||
.I name
|
||||
to the preprocessor, as if by "#define".
|
||||
.IP \fB\-D\fP\fIname\fP
|
||||
.br
|
||||
Same as "\fB\-D\fP\fIname\fP\fB=1\fP".
|
||||
.IP \fB\-E\fP
|
||||
Run only the macro preprocessor on the named files and send the
|
||||
result to standard output.
|
||||
.IP \fB\-I\fP\fIdir\fP
|
||||
\&"#include" files whose names do not begin with '/' are always
|
||||
sought first in the directory of the \fIfile\fP argument, then in directories
|
||||
in \fB\-I\fP options, then in directories on a standard list (which in fact
|
||||
consists of "/usr/include").
|
||||
.IP \fB\-L\fP\fIdir\fP
|
||||
Use \fIdir\fP as library-containing directory instead of the default.
|
||||
.IP \fB\-N\fP\fIc\fP
|
||||
Only effective if ACK pipeline is used.
|
||||
This option causes some default actions and options to be suppressed, according
|
||||
to
|
||||
.I c :
|
||||
.RS
|
||||
.IP \fBc\fP
|
||||
do not convert from EM a.out to local a.out format (i.e., skip the
|
||||
.B cv
|
||||
pass.)
|
||||
.IP \fBl\fP
|
||||
do not pass the default loader flags to the
|
||||
.B ld
|
||||
pass.
|
||||
.RE
|
||||
.IP \fB\-P\fP
|
||||
Same as \fB\-E\fP, but sending the result of input file \fIfile\fP\fB.[ceis]\fP
|
||||
to \fIfile\fP\fB.i\fP.
|
||||
.IP \fB\-R\fP
|
||||
Passed to \fIcemcom\fP(1) in order to parse the named C programs according
|
||||
to the C language as described in [K&R] (also called \fIRestricted\fP C).
|
||||
.IP \fB\-R\fP\fIprog\fP\fB=\fP\fIname\fP
|
||||
.br
|
||||
Use \fIname\fP as program for phase \fIprog\fP of the compilation instead of
|
||||
the default.
|
||||
\&\fIProg\fP is one of the following names:
|
||||
.RS
|
||||
.IP \fBcpp\fP
|
||||
macro preprocessor
|
||||
.IP \fBcem\fP
|
||||
front\-end compiler
|
||||
.IP \fBopt\fP
|
||||
EM peephole optimizer
|
||||
.IP \fBdecode\fP
|
||||
EM compact to EM assembler translator
|
||||
.IP \fBencode\fP
|
||||
EM assembler to EM compact translator
|
||||
.IP \fBbe\fP
|
||||
EM compact code to target\-machine assembly code compiler
|
||||
.IP \fBcg\fP
|
||||
same as \fBbe\fP
|
||||
.IP \fBas\fP
|
||||
assembler
|
||||
.IP \fBld\fP
|
||||
linker/loader
|
||||
.IP \fBcv\fP
|
||||
a.out format converting program (only if ACK pipeline is used)
|
||||
.RE
|
||||
.IP \fB\-R\fP\fIprog\fP\fB\-\fP\fIoption\fP
|
||||
.br
|
||||
Pass \fB\-\fP\fIoption\fP to the compilation phase indicated by \fIprog\fP.
|
||||
.IP \fB\-S\fP
|
||||
Same as \fB\-c.s\fP.
|
||||
.IP \fB\-U\fP\fIname\fP
|
||||
.br
|
||||
Remove any initial definition of \fIname\fP.
|
||||
.IP \fB\-V\fP\fIcm\fP.\fIn\fP,\ \fB\-V\fIcm\fP.\fIncm\fP.\fIn\fP\ ...
|
||||
.br
|
||||
Set the size and alignment requirements of the C constructs of the named
|
||||
C input files.
|
||||
The letter \fIc\fP indicates the simple type, which is one of
|
||||
\fBs\fP(short), \fBi\fP(int), \fBl\fP(long), \fBf\fP(float), \fBd\fP(double) or
|
||||
\fBp\fP(pointer).
|
||||
The \fIm\fP parameter can be used to specify the length of the type (in bytes)
|
||||
and the \fIn\fP parameter for the alignment of that type.
|
||||
Absence of \fIm\fP or \fIn\fP causes the default value to be retained.
|
||||
To specify that the bitfields should be right adjusted instead of the
|
||||
default left adjustment, specify \fBr\fP as \fIc\fP parameter
|
||||
without parameters.
|
||||
.br
|
||||
This option is passed directly to \fIcemcom\fP(1).
|
||||
.IP \fB\-c\fP
|
||||
Same as \fB\-c.o\fP.
|
||||
.IP \fB\-c.e\fP
|
||||
Produce human-readable EM assembly code on \fIfile\fP\fB.e\fP for the
|
||||
named files \fIfile\fP\fB.[cikm]\fP
|
||||
.IP \fB\-c.k\fP
|
||||
Compile C source \fIfile\fP\fB.[ci]\fP or
|
||||
encode human-readable EM assembly code from \fIfile\fP\fB.e\fP
|
||||
into non-optimized compact EM code and write the result on \fIfile\fP\fB.k\fP
|
||||
.IP \fB\-c.m\fP
|
||||
Compile C source \fIfile\fP\fB.[ci]\fP,
|
||||
translate non-optimized EM code from \fIfile\fP\fB.k\fP or
|
||||
encode EM assembly code from \fIfile\fP\fB.e\fP
|
||||
into optimized compact EM code and write the result on \fIfile\fP\fB.m\fP
|
||||
.IP \fB\-c.o\fP
|
||||
Suppress the loading phase of the compilation, and force an object file to
|
||||
be produced even if only one program is compiled
|
||||
.IP \fB\-c.s\fP
|
||||
Compile the named \fIfile\fP\fB.[ceikm]\fP input files, and leave the
|
||||
assembly language output on corresponding files suffixed ".s".
|
||||
.IP \fB\-k\fP
|
||||
Same as \fB\-c.k\fP.
|
||||
.IP \fB\-l\fP\fIname\fP
|
||||
.br
|
||||
Append the library \fBlib\fP\fIname\fP\fB.a\fP to the list of files that
|
||||
should be loaded and linked into the final output file.
|
||||
The library is searched for in the library directory.
|
||||
.IP \fB\-m\fP
|
||||
Same as \fB\-c.m\fP.
|
||||
.IP \fB\-o\fP\ \fIoutput\fP
|
||||
.br
|
||||
Name the final output file \fIoutput\fP.
|
||||
If this option is used, the default "a.out" will be left undisturbed.
|
||||
.IP \fB\-p\fP
|
||||
Produce EM profiling code (\fBfil\fP and \fBlin\fP instructions to
|
||||
enable an interpreter to keep track of the current location in the
|
||||
source code)
|
||||
.IP \fB\-t\fP
|
||||
Keep the intermediate files, produced during the various phases of the
|
||||
compilation.
|
||||
The produced files are named \fIfile\fP\fB.\fP\fIcharacter\fP where
|
||||
\&\fIcharacter\fP indicates the type of the file as listed before.
|
||||
.IP \fB\-v\fP
|
||||
Verbose.
|
||||
Print the commands before they are executed.
|
||||
.IP \fB\-vn\fP
|
||||
Do not really execute (for debugging purposes only).
|
||||
.IP \fB\-vd\fP
|
||||
Print some additional information (for debugging purposes only).
|
||||
.IP \fB\-\-\fP\fIanything\fP
|
||||
.br
|
||||
Equivalent to \fB\-Rcem\-\-\fP\fIanything\fP.
|
||||
The options
|
||||
.B \-\-C ,
|
||||
.B \-\-E
|
||||
and
|
||||
.B \-\-P
|
||||
all have the same effect as respectively
|
||||
.B \-C ,
|
||||
.B \-E
|
||||
and
|
||||
.B \-P
|
||||
except for the fact that the macro preprocessor is taken to be the
|
||||
built\-in preprocessor of the \fBcem\fP phase.
|
||||
Most "\-\-" options are used by
|
||||
.I cemcom (1)
|
||||
to set some internal debug switches.
|
||||
.LP
|
||||
.SH SEE ALSO
|
||||
cemcom(1), cc(1), ack(?), as(1), ld(1)
|
||||
.br
|
||||
.IP [K&R]
|
||||
B.W. Kernighan and D.M. Ritchie, \fIThe C Programming Language\fP,
|
||||
Prentice-Hall, 1978.
|
||||
.SH DIAGNOSTICS
|
||||
.I Cem
|
||||
reports any failure of its components.
|
||||
.SH BUGS
|
||||
.IP \(bu
|
||||
All intermediate files are placed in the current working directory which
|
||||
causes files with the same name as the intermediate files to be overwritten.
|
||||
.IP \(bu
|
||||
.B Cem
|
||||
only accepts a limited number of arguments to be passed to the components.
|
||||
(e.g., 256).
|
||||
.IP \(bu
|
||||
Please report suggestions and other bugs to erikb@vu44.uucp
|
||||
@@ -1,764 +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$ */
|
||||
/*
|
||||
Driver for the CEMCOM compiler: works like /bin/cc and accepts
|
||||
most of the options accepted by /bin/cc and /usr/em/bin/ack.
|
||||
Date written: dec 4, 1985
|
||||
Adapted for 68000 (Aug 19, 1986)
|
||||
Merged the vax and mantra versions (Nov 10, 1986)
|
||||
Author: Erik Baalbergen
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
|
||||
#define MAXARGC 256 /* maximum number of arguments allowed in a list */
|
||||
#define USTR_SIZE 1024 /* maximum length of string variable */
|
||||
|
||||
struct arglist {
|
||||
int al_argc;
|
||||
char *al_argv[MAXARGC];
|
||||
};
|
||||
|
||||
/* some system-dependent variables */
|
||||
char *PP = "/lib/cpp";
|
||||
char *CEM = "/usr/em/lib/em_cemcom";
|
||||
char *ENCODE = "/usr/em/lib/em_encode";
|
||||
char *DECODE = "/usr/em/lib/em_decode";
|
||||
char *OPT = "/usr/em/lib/em_opt";
|
||||
char *SHELL = "/bin/sh";
|
||||
|
||||
#ifndef MANTRA
|
||||
char *CG = "/usr/em/lib/vax4/cg";
|
||||
char *AS = "/bin/as";
|
||||
char *AS_FIX = "/user1/erikb/bin/mcomm";
|
||||
char *LD = "/bin/ld";
|
||||
char *LIBDIR = "/user1/cem/lib";
|
||||
char *V_FLAG = "-Vs2.2w4.4i4.4l4.4f4.4d8.4p4.4";
|
||||
#else MANTRA
|
||||
char *CG = "/usr/em/lib/m68k2/cg";
|
||||
char *AS = "/usr/em/lib/m68k2/as";
|
||||
char *LD = "/usr/em/lib/em_led";
|
||||
char *CV = "/usr/em/lib/m68k2/cv";
|
||||
char *LIBDIR = "/usr/em/lib/m68k2";
|
||||
char *V_FLAG = "-Vs2.2w2.2i2.2l4.2f4.2d8.2p4.2";
|
||||
#endif MANTRA
|
||||
|
||||
struct arglist LD_HEAD = {
|
||||
2,
|
||||
{
|
||||
#ifndef MANTRA
|
||||
"/usr/em/lib/vax4/head_em",
|
||||
"/usr/em/lib/vax4/head_cc"
|
||||
#else MANTRA
|
||||
"/usr/em/lib/m68k2/head_em",
|
||||
"/usr/em/lib/m68k2/head_cc"
|
||||
#endif MANTRA
|
||||
}
|
||||
};
|
||||
|
||||
struct arglist LD_TAIL = {
|
||||
#ifndef MANTRA
|
||||
4,
|
||||
{
|
||||
"/user1/cem/lib/libc.a",
|
||||
"/user1/cem/lib/stb.o",
|
||||
"/usr/em/lib/vax4/tail_mon",
|
||||
"/usr/em/lib/vax4/tail_em"
|
||||
}
|
||||
#else MANTRA
|
||||
7,
|
||||
{
|
||||
"/usr/em/lib/m68k2/tail_cc.1s",
|
||||
"/usr/em/lib/m68k2/tail_cc.2g",
|
||||
"/usr/em/lib/m68k2/tail_cem",
|
||||
"/usr/em/lib/m68k2/tail_fp.a",
|
||||
"/usr/em/lib/m68k2/tail_em.rt",
|
||||
"/usr/em/lib/m68k2/tail_mon",
|
||||
"/usr/em/lib/m68k2/end_em"
|
||||
}
|
||||
#endif MANTRA
|
||||
};
|
||||
|
||||
char *o_FILE = "a.out";
|
||||
#ifdef MANTRA
|
||||
char *cv_FILE = "cv.out";
|
||||
#endif MANTRA
|
||||
|
||||
#define remove(str) (((FLAG(t) == 0) && unlink(str)), (str)[0] = '\0')
|
||||
#define cleanup(str) (str && remove(str))
|
||||
#define mkname(dst, s1, s2) mkstr(dst, (s1), (s2), 0)
|
||||
#define init(al) (al)->al_argc = 1
|
||||
#define library(nm) \
|
||||
mkstr(alloc((unsigned int)strlen(nm) + strlen(LIBDIR) + 7), \
|
||||
LIBDIR, "/lib", nm, ".a", 0)
|
||||
|
||||
struct arglist SRCFILES, LDFILES, GEN_LDFILES, PP_FLAGS, CEM_FLAGS,
|
||||
OPT_FLAGS, DECODE_FLAGS, ENCODE_FLAGS, CG_FLAGS, AS_FLAGS,
|
||||
O_FLAGS, DEBUG_FLAGS, CALL_VEC;
|
||||
|
||||
#ifndef MANTRA
|
||||
struct arglist LD_FLAGS;
|
||||
#else MANTRA
|
||||
struct arglist LD_FLAGS = {
|
||||
5,
|
||||
{
|
||||
"-b0:0x80000",
|
||||
"-a0:2",
|
||||
"-a1:2",
|
||||
"-a2:2",
|
||||
"-a3:2"
|
||||
}
|
||||
};
|
||||
struct arglist CV_FLAGS;
|
||||
int Nc_flag = 0;
|
||||
#endif MANTRA
|
||||
|
||||
/* option naming */
|
||||
#define NAME(chr) chr
|
||||
#define FLAG(chr) NAME(chr)_flag
|
||||
int E_flag, P_flag, S_flag, c_flag, e_flag, k_flag,
|
||||
m_flag, o_flag, t_flag, v_flag;
|
||||
|
||||
/* various passes */
|
||||
struct prog {
|
||||
char *p_name;
|
||||
char **p_task;
|
||||
struct arglist *p_flags;
|
||||
} ProgParts[] = {
|
||||
{ "cpp", &PP, &PP_FLAGS },
|
||||
{ "cem", &CEM, &CEM_FLAGS },
|
||||
{ "opt", &OPT, &OPT_FLAGS },
|
||||
{ "decode", &DECODE, &DECODE_FLAGS },
|
||||
{ "encode", &ENCODE, &ENCODE_FLAGS },
|
||||
{ "be", &CG, &CG_FLAGS },
|
||||
{ "cg", &CG, &CG_FLAGS },
|
||||
{ "as", &AS, &AS_FLAGS },
|
||||
{ "ld", &LD, &LD_FLAGS },
|
||||
#ifdef MANTRA
|
||||
{ "cv", &CV, &CV_FLAGS },
|
||||
#endif MANTRA
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
|
||||
/* various forward declarations */
|
||||
int trap();
|
||||
char *mkstr();
|
||||
char *alloc();
|
||||
long sizeof_file();
|
||||
|
||||
/* various globals */
|
||||
char *ProgCall = 0;
|
||||
int debug = 0;
|
||||
int exec = 1;
|
||||
int RET_CODE = 0;
|
||||
|
||||
main(argc, argv)
|
||||
char *argv[];
|
||||
{
|
||||
char *str, **argvec, *file, *ldfile = 0;
|
||||
int count, ext;
|
||||
char Nfile[USTR_SIZE], kfile[USTR_SIZE], sfile[USTR_SIZE],
|
||||
mfile[USTR_SIZE], ofile[USTR_SIZE], BASE[USTR_SIZE];
|
||||
register struct arglist *call = &CALL_VEC;
|
||||
|
||||
set_traps(trap);
|
||||
ProgCall = *argv++;
|
||||
append(&CEM_FLAGS, "-L");
|
||||
while (--argc > 0) {
|
||||
if (*(str = *argv++) != '-') {
|
||||
append(&SRCFILES, str);
|
||||
continue;
|
||||
}
|
||||
switch (str[1]) {
|
||||
case '-':
|
||||
switch (str[2]) {
|
||||
case 'C':
|
||||
case 'E':
|
||||
case 'P':
|
||||
FLAG(E) = 1;
|
||||
append(&PP_FLAGS, str);
|
||||
PP = CEM;
|
||||
FLAG(P) = (str[2] == 'P');
|
||||
break;
|
||||
default:
|
||||
append(&DEBUG_FLAGS, str);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'B':
|
||||
PP = CEM = &str[2];
|
||||
break;
|
||||
case 'C':
|
||||
case 'E':
|
||||
case 'P':
|
||||
FLAG(E) = 1;
|
||||
append(&PP_FLAGS, str);
|
||||
FLAG(P) = (str[1] == 'P');
|
||||
break;
|
||||
case 'c':
|
||||
if (str[2] == '.') {
|
||||
switch (str[3]) {
|
||||
case 's':
|
||||
FLAG(S) = 1;
|
||||
break;
|
||||
case 'k':
|
||||
FLAG(k) = 1;
|
||||
break;
|
||||
case 'o':
|
||||
FLAG(c) = 1;
|
||||
break;
|
||||
case 'm':
|
||||
FLAG(m) = 1;
|
||||
break;
|
||||
case 'e':
|
||||
FLAG(e) = 1;
|
||||
break;
|
||||
default:
|
||||
bad_option(str);
|
||||
}
|
||||
}
|
||||
else
|
||||
if (str[2] == '\0')
|
||||
FLAG(c) = 1;
|
||||
else
|
||||
bad_option(str);
|
||||
break;
|
||||
case 'D':
|
||||
case 'I':
|
||||
case 'U':
|
||||
append(&PP_FLAGS, str);
|
||||
break;
|
||||
case 'k':
|
||||
FLAG(k) = 1;
|
||||
break;
|
||||
case 'l':
|
||||
if (str[2] == '\0') /* no standard libraries */
|
||||
LD_HEAD.al_argc = LD_TAIL.al_argc = 0;
|
||||
else /* use library from library directory */
|
||||
append(&SRCFILES, library(&str[2]));
|
||||
break;
|
||||
case 'L': /* change default library directory */
|
||||
LIBDIR = &str[2];
|
||||
break;
|
||||
case 'm':
|
||||
FLAG(m) = 1;
|
||||
break;
|
||||
#ifdef MANTRA
|
||||
case 'N':
|
||||
switch (str[2]) {
|
||||
case 'c': /* no a.out conversion */
|
||||
Nc_flag = 1;
|
||||
break;
|
||||
case 'l': /* no default options to led */
|
||||
LD_FLAGS.al_argc = 0;
|
||||
break;
|
||||
default:
|
||||
bad_option(str);
|
||||
}
|
||||
break;
|
||||
#endif MANTRA
|
||||
case 'o':
|
||||
FLAG(o) = 1;
|
||||
if (argc-- < 0)
|
||||
bad_option(str);
|
||||
else
|
||||
o_FILE = *argv++;
|
||||
break;
|
||||
case 'O':
|
||||
append(&O_FLAGS, "-O");
|
||||
break;
|
||||
case 'R':
|
||||
if (str[2] == '\0')
|
||||
append(&CEM_FLAGS, str);
|
||||
else
|
||||
Roption(str);
|
||||
break;
|
||||
case 'S':
|
||||
FLAG(S) = 1;
|
||||
break;
|
||||
case 't':
|
||||
FLAG(t) = 1;
|
||||
break;
|
||||
case 'v': /* set debug switches */
|
||||
FLAG(v) = 1;
|
||||
switch (str[2]) {
|
||||
case 'd':
|
||||
debug = 1;
|
||||
break;
|
||||
case 'n': /* no execute */
|
||||
exec = 0;
|
||||
break;
|
||||
case '\0':
|
||||
break;
|
||||
default:
|
||||
bad_option(str);
|
||||
}
|
||||
break;
|
||||
case 'V':
|
||||
V_FLAG = str;
|
||||
break;
|
||||
default:
|
||||
append(&LD_FLAGS, str);
|
||||
}
|
||||
}
|
||||
if (debug) report("Note: debug output");
|
||||
if (exec == 0)
|
||||
report("Note: no execution");
|
||||
count = SRCFILES.al_argc;
|
||||
argvec = &(SRCFILES.al_argv[0]);
|
||||
Nfile[0] = '\0';
|
||||
while (count-- > 0) {
|
||||
basename(file = *argvec++, BASE);
|
||||
if (FLAG(E)) {
|
||||
char ifile[USTR_SIZE];
|
||||
|
||||
init(call);
|
||||
append(call, PP);
|
||||
concat(call, &DEBUG_FLAGS);
|
||||
concat(call, &PP_FLAGS);
|
||||
append(call, file);
|
||||
runvec(call, FLAG(P) ? mkname(ifile, BASE, ".i") : 0);
|
||||
continue;
|
||||
}
|
||||
ext = extension(file);
|
||||
/* .c to .k and .N */
|
||||
if (ext == 'c' || ext == 'i') {
|
||||
init(call);
|
||||
append(call, CEM);
|
||||
concat(call, &DEBUG_FLAGS);
|
||||
append(call, V_FLAG);
|
||||
concat(call, &CEM_FLAGS);
|
||||
concat(call, &PP_FLAGS);
|
||||
append(call, file);
|
||||
append(call, mkname(kfile, BASE, ".k"));
|
||||
append(call, mkname(Nfile, BASE, ".N"));
|
||||
if (runvec(call, (char *)0)) {
|
||||
file = kfile;
|
||||
ext = 'k';
|
||||
if (sizeof_file(Nfile) <= 0L)
|
||||
remove(Nfile);
|
||||
}
|
||||
else {
|
||||
remove(kfile);
|
||||
remove(Nfile);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
/* .e to .k */
|
||||
if (ext == 'e') {
|
||||
init(call);
|
||||
append(call, ENCODE);
|
||||
concat(call, &ENCODE_FLAGS);
|
||||
append(call, file);
|
||||
append(call, mkname(kfile, BASE, ".k"));
|
||||
if (runvec(call, (char *)0) == 0)
|
||||
continue;
|
||||
file = kfile;
|
||||
ext = 'k';
|
||||
}
|
||||
if (FLAG(k))
|
||||
continue;
|
||||
/* decode .k or .m */
|
||||
if (FLAG(e) && (ext == 'k' || ext == 'm')) {
|
||||
char efile[USTR_SIZE];
|
||||
init(call);
|
||||
append(call, DECODE);
|
||||
concat(call, &DECODE_FLAGS);
|
||||
append(call, file);
|
||||
append(call, mkname(efile, BASE, ".e"));
|
||||
runvec(call, (char *)0);
|
||||
cleanup(kfile);
|
||||
continue;
|
||||
}
|
||||
/* .k to .m */
|
||||
if (ext == 'k') {
|
||||
init(call);
|
||||
append(call, OPT);
|
||||
concat(call, &OPT_FLAGS);
|
||||
append(call, file);
|
||||
if (runvec(call, mkname(mfile, BASE, ".m")) == 0)
|
||||
continue;
|
||||
file = mfile;
|
||||
ext = 'm';
|
||||
cleanup(kfile);
|
||||
}
|
||||
if (FLAG(m))
|
||||
continue;
|
||||
/* .m to .s */
|
||||
if (ext == 'm') {
|
||||
init(call);
|
||||
append(call, CG);
|
||||
concat(call, &CG_FLAGS);
|
||||
append(call, file);
|
||||
append(call, mkname(sfile, BASE, ".s"));
|
||||
if (runvec(call, (char *)0) == 0)
|
||||
continue;
|
||||
if (Nfile[0] != '\0') {
|
||||
#ifndef MANTRA
|
||||
init(call);
|
||||
append(call, AS_FIX);
|
||||
append(call, Nfile);
|
||||
append(call, sfile);
|
||||
runvec(call, (char *)0);
|
||||
#endif MANTRA
|
||||
remove(Nfile);
|
||||
}
|
||||
cleanup(mfile);
|
||||
file = sfile;
|
||||
ext = 's';
|
||||
}
|
||||
if (FLAG(S))
|
||||
continue;
|
||||
/* .s to .o */
|
||||
if (ext == 's') {
|
||||
ldfile = FLAG(c) ?
|
||||
ofile :
|
||||
alloc((unsigned)strlen(BASE) + 3);
|
||||
init(call);
|
||||
append(call, AS);
|
||||
concat(call, &AS_FLAGS);
|
||||
#ifdef MANTRA
|
||||
append(call, "-");
|
||||
#endif MANTRA
|
||||
append(call, "-o");
|
||||
append(call, mkname(ldfile, BASE, ".o"));
|
||||
append(call, file);
|
||||
if (runvec(call, (char *)0) == 0)
|
||||
continue;
|
||||
file = ldfile;
|
||||
ext = 'o';
|
||||
cleanup(sfile);
|
||||
}
|
||||
if (FLAG(c))
|
||||
continue;
|
||||
append(&LDFILES, file);
|
||||
if (ldfile) {
|
||||
append(&GEN_LDFILES, ldfile);
|
||||
ldfile = 0;
|
||||
}
|
||||
}
|
||||
/* *.o to a.out */
|
||||
if (RET_CODE == 0 && LDFILES.al_argc > 0) {
|
||||
init(call);
|
||||
append(call, LD);
|
||||
concat(call, &LD_FLAGS);
|
||||
append(call, "-o");
|
||||
#ifndef MANTRA
|
||||
append(call, o_FILE);
|
||||
#else MANTRA
|
||||
append(call, Nc_flag ? o_FILE : cv_FILE);
|
||||
#endif MANTRA
|
||||
concat(call, &LD_HEAD);
|
||||
concat(call, &LDFILES);
|
||||
concat(call, &LD_TAIL);
|
||||
if (runvec(call, (char *)0)) {
|
||||
register i = GEN_LDFILES.al_argc;
|
||||
|
||||
while (i-- > 0)
|
||||
remove(GEN_LDFILES.al_argv[i]);
|
||||
#ifdef MANTRA
|
||||
/* convert to local a.out format */
|
||||
if (Nc_flag == 0) {
|
||||
init(call);
|
||||
append(call, CV);
|
||||
concat(call, &CV_FLAGS);
|
||||
append(call, cv_FILE);
|
||||
append(call, o_FILE);
|
||||
if (runvec(call, (char *)0))
|
||||
remove(cv_FILE);
|
||||
}
|
||||
#endif MANTRA
|
||||
}
|
||||
}
|
||||
exit(RET_CODE);
|
||||
}
|
||||
|
||||
#define BUFSIZE (USTR_SIZE * MAXARGC)
|
||||
char alloc_buf[BUFSIZE];
|
||||
|
||||
char *
|
||||
alloc(u)
|
||||
unsigned u;
|
||||
{
|
||||
static char *bufptr = &alloc_buf[0];
|
||||
register char *p = bufptr;
|
||||
|
||||
if ((bufptr += u) >= &alloc_buf[BUFSIZE])
|
||||
panic("no space");
|
||||
return p;
|
||||
}
|
||||
|
||||
append(al, arg)
|
||||
register struct arglist *al;
|
||||
char *arg;
|
||||
{
|
||||
if (al->al_argc >= MAXARGC)
|
||||
panic("argument list overflow");
|
||||
al->al_argv[(al->al_argc)++] = arg;
|
||||
}
|
||||
|
||||
concat(al1, al2)
|
||||
struct arglist *al1, *al2;
|
||||
{
|
||||
register int i = al2->al_argc;
|
||||
register char **p = &(al1->al_argv[al1->al_argc]);
|
||||
register char **q = &(al2->al_argv[0]);
|
||||
|
||||
if ((al1->al_argc += i) >= MAXARGC)
|
||||
panic("argument list overflow");
|
||||
while (i-- > 0)
|
||||
*p++ = *q++;
|
||||
}
|
||||
|
||||
/* The next function is a dirty old one, taking a variable number of
|
||||
arguments.
|
||||
Take care that the last argument is a null-valued pointer!
|
||||
*/
|
||||
/*VARARGS1*/
|
||||
char *
|
||||
mkstr(dst, arg)
|
||||
char *dst, *arg;
|
||||
{
|
||||
char **vec = (char **) &arg;
|
||||
register char *p;
|
||||
register char *q = dst;
|
||||
|
||||
while (p = *vec++) {
|
||||
while (*q++ = *p++);
|
||||
q--;
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
|
||||
Roption(str)
|
||||
char *str; /* of the form "prog=/-arg" */
|
||||
{
|
||||
char *eq;
|
||||
char *prog, *arg;
|
||||
char bc;
|
||||
char *cindex();
|
||||
|
||||
prog = &str[2];
|
||||
if (eq = cindex(prog, '='))
|
||||
bc = '=';
|
||||
else
|
||||
if (eq = cindex(prog, '-'))
|
||||
bc = '-';
|
||||
else {
|
||||
bad_option(str);
|
||||
return;
|
||||
}
|
||||
*eq++ = '\0';
|
||||
if (arg = eq) {
|
||||
char *opt = 0;
|
||||
struct prog *pp = &ProgParts[0];
|
||||
|
||||
if (bc == '-')
|
||||
opt = mkstr(alloc((unsigned)strlen(arg) + 2),
|
||||
"-", arg, 0);
|
||||
while (pp->p_name) {
|
||||
if (strcmp(prog, pp->p_name) == 0) {
|
||||
if (opt)
|
||||
append(pp->p_flags, opt);
|
||||
else
|
||||
*(pp->p_task) = arg;
|
||||
return;
|
||||
}
|
||||
pp++;
|
||||
}
|
||||
}
|
||||
bad_option(str);
|
||||
}
|
||||
|
||||
basename(str, dst)
|
||||
char *str;
|
||||
register char *dst;
|
||||
{
|
||||
register char *p1 = str;
|
||||
register char *p2 = p1;
|
||||
|
||||
while (*p1)
|
||||
if (*p1++ == '/')
|
||||
p2 = p1;
|
||||
p1--;
|
||||
if (*--p1 == '.') {
|
||||
*p1 = '\0';
|
||||
while (*dst++ = *p2++) {}
|
||||
*p1 = '.';
|
||||
}
|
||||
else
|
||||
while (*dst++ = *p2++) {}
|
||||
}
|
||||
|
||||
int
|
||||
extension(fn)
|
||||
register char *fn;
|
||||
{
|
||||
char c;
|
||||
|
||||
while (*fn++) {}
|
||||
fn--;
|
||||
c = *--fn;
|
||||
return (*--fn == '.') ? c : 0;
|
||||
}
|
||||
|
||||
long
|
||||
sizeof_file(nm)
|
||||
char *nm;
|
||||
{
|
||||
struct stat stbuf;
|
||||
|
||||
if (stat(nm, &stbuf) == 0)
|
||||
return stbuf.st_size;
|
||||
return -1;
|
||||
}
|
||||
|
||||
char * sysmsg[] = {
|
||||
0,
|
||||
"Hangup",
|
||||
"Interrupt",
|
||||
"Quit",
|
||||
"Illegal instruction",
|
||||
"Trace/BPT trap",
|
||||
"IOT trap",
|
||||
"EMT trap",
|
||||
"Floating exception",
|
||||
"Killed",
|
||||
"Bus error",
|
||||
"Memory fault",
|
||||
"Bad system call",
|
||||
"Broken pipe",
|
||||
"Alarm call",
|
||||
"Terminated",
|
||||
"Signal 16"
|
||||
};
|
||||
|
||||
runvec(vec, outp)
|
||||
struct arglist *vec;
|
||||
char *outp;
|
||||
{
|
||||
int status, fd;
|
||||
char *task = vec->al_argv[1];
|
||||
|
||||
vec->al_argv[vec->al_argc] = 0;
|
||||
if (FLAG(v))
|
||||
print_vec(vec);
|
||||
if (exec == 0)
|
||||
return 1;
|
||||
if (fork() == 0) { /* start up the process */
|
||||
extern int errno;
|
||||
if (outp) { /* redirect standard output */
|
||||
close(1);
|
||||
if ((fd = creat(outp, 0666)) < 0)
|
||||
panic("cannot create %s", outp);
|
||||
if (fd != 1)
|
||||
panic("illegal redirection");
|
||||
}
|
||||
if (debug) report("exec %s", task);
|
||||
execv(task, &(vec->al_argv[1]));
|
||||
/* not an a.out file, let's try it with the SHELL */
|
||||
if (debug) report("try it with %s", SHELL);
|
||||
if (errno == ENOEXEC) {
|
||||
vec->al_argv[0] = SHELL;
|
||||
execv(SHELL, &(vec->al_argv[0]));
|
||||
}
|
||||
/* failed, so ... */
|
||||
panic("cannot execute %s", task);
|
||||
exit(1);
|
||||
}
|
||||
else {
|
||||
int loworder, highorder, sig;
|
||||
|
||||
wait(&status);
|
||||
loworder = status & 0377;
|
||||
highorder = (status >> 8) & 0377;
|
||||
if (loworder == 0) {
|
||||
if (highorder)
|
||||
report("%s: exit status %d", task, highorder);
|
||||
return highorder ? ((RET_CODE = 1), 0) : 1;
|
||||
}
|
||||
else {
|
||||
sig = loworder & 0177;
|
||||
if (sig == 0177)
|
||||
report("%s: stopped by ptrace", task);
|
||||
else
|
||||
if (sysmsg[sig])
|
||||
report("%s: %s%s", task, sysmsg[sig],
|
||||
(loworder & 0200)
|
||||
? " - core dumped"
|
||||
: "");
|
||||
RET_CODE = 1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
bad_option(str)
|
||||
char *str;
|
||||
{
|
||||
report("bad option %s", str);
|
||||
}
|
||||
|
||||
/*VARARGS1*/
|
||||
report(fmt, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9)
|
||||
char *fmt;
|
||||
{
|
||||
fprintf(stderr, "%s: ", ProgCall);
|
||||
fprintf(stderr, fmt, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
/*VARARGS1*/
|
||||
panic(fmt, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9)
|
||||
char *fmt;
|
||||
{
|
||||
fprintf(stderr, "%s: ", ProgCall);
|
||||
fprintf(stderr, fmt, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
||||
fprintf(stderr, "\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
set_traps(f)
|
||||
int (*f)();
|
||||
{
|
||||
signal(SIGHUP, f);
|
||||
signal(SIGINT, f);
|
||||
signal(SIGQUIT, f);
|
||||
signal(SIGALRM, f);
|
||||
signal(SIGTERM, f);
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
trap(sig)
|
||||
{
|
||||
set_traps(SIG_IGN);
|
||||
panic("Trapped");
|
||||
}
|
||||
|
||||
print_vec(vec)
|
||||
struct arglist *vec;
|
||||
{
|
||||
register i;
|
||||
|
||||
for (i = 1; i < vec->al_argc; i++)
|
||||
printf("%s ", vec->al_argv[i]);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
char *
|
||||
cindex(s, c)
|
||||
char *s, c;
|
||||
{
|
||||
while (*s)
|
||||
if (*s++ == c)
|
||||
return s - 1;
|
||||
return (char *) 0;
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
.TH EM_CEMCOM 6ACK
|
||||
.ad
|
||||
.SH NAME
|
||||
em_cemcom \- C to EM compiler
|
||||
.SH SYNOPSIS
|
||||
\fB~/em/lib/em_cemcom\fP [\fIoptions\fP] \fIsource \fP[\fIdestination \fP[\fInamelist\fP]]
|
||||
.SH DESCRIPTION
|
||||
\fICemcom\fP is a compiler that translates C programs
|
||||
into EM compact code.
|
||||
The input is taken from \fIsource\fP, while the
|
||||
EM code is written on \fIdestination\fP.
|
||||
If either of these two names is "\fB-\fP", standard input or output respectively
|
||||
is taken.
|
||||
The file \fInamelist\fP, if supplied, will contain a list of the names
|
||||
of external, so-called \fBcommon\fP, variables.
|
||||
When the preprocessor is invoked to run stand-alone, \fIdestination\fP
|
||||
needs not be specified.
|
||||
.br
|
||||
\fIOptions\fP is a, possibly empty, sequence of the following combinations:
|
||||
.IP \fB\-D\fIname\fR=\fItext\fR
|
||||
.br
|
||||
define \fIname\fR as a macro with \fItext\fR as its replacement text.
|
||||
.IP \fB\-D\fIname\fR
|
||||
.br
|
||||
the same as \fB\-D\fIname\fR=1.
|
||||
.IP \fB\-I\fIdirname\fR
|
||||
.br
|
||||
insert \fIdirname\fR in the list of include directories.
|
||||
.IP \fB\-M\fP\fIn\fP
|
||||
set maximum identifier length to \fIn\fP.
|
||||
.IP \fB\-g\fP
|
||||
produce a DBX-style symbol table.
|
||||
.IP \fB\-n\fR
|
||||
do not generate EM register messages.
|
||||
The user-declared variables are not stored into registers on the target
|
||||
machine.
|
||||
.IP \fB\-L\fR
|
||||
don't generate the EM \fBfil\fR and \fBlin\fR instructions
|
||||
that usually are generated to enable
|
||||
an interpreter to keep track of the current location in the source code.
|
||||
.IP \fB\-p\fR
|
||||
generate code at each procedure entry to call the routine
|
||||
.BR procentry ,
|
||||
and at each return to call the routine
|
||||
.BE procexit .
|
||||
These routines are supplied with one parameter, a pointer to a
|
||||
string containing the name of the procedure.
|
||||
.IP \fB\-A\fR[\fIfile\fR]
|
||||
.br
|
||||
if \fIfile\fR is not given, generate a list
|
||||
of makefile dependencies and write them to the standard output.
|
||||
If \fIfile\fP is given,
|
||||
generate the list of makefile dependencies on file \fIfile\fP.
|
||||
.IP \fB-i\fR
|
||||
when generating makefile dependencies, do not include files from
|
||||
/usr/include.
|
||||
.IP \fB-m\fR
|
||||
when generating makefile dependencies, generate them in the following format:
|
||||
.RS
|
||||
.IP "file.o: file1.h"
|
||||
.RE
|
||||
.IP ""
|
||||
where "file.o" is derived from the source file name. Normally, only a list
|
||||
of files included is generated.
|
||||
.IP \fB\-R\fR
|
||||
interpret the input as restricted C (according to the language as
|
||||
described in \fIThe C programming language\fR by Kernighan and Ritchie.)
|
||||
.IP \fB\-U\fIname\fR
|
||||
.br
|
||||
get rid of the compiler-predefined macro \fIname\fR.
|
||||
.IP \fB\-V\fIcm\fR.\fIn\fR,\ \fB\-V\fIcm\fR.\fIncm\fR.\fIn\fR\ ...
|
||||
.br
|
||||
set the size and alignment requirements.
|
||||
The letter \fIc\fR indicates the simple type, which is one of
|
||||
\fBs\fR(short), \fBi\fR(int), \fBl\fR(long), \fBf\fR(float), \fBd\fR(double) or
|
||||
\fBp\fR(pointer).
|
||||
The \fIm\fR parameter can be used to specify the length of the type (in bytes)
|
||||
and the \fIn\fR parameter for the alignment of that type.
|
||||
Absence of \fIm\fR or \fIn\fR causes the default value to be retained.
|
||||
To specify that the bitfields should be right adjusted instead of the
|
||||
default left adjustment, specify \fBr\fR as \fIc\fR parameter.
|
||||
.IP \fB\-w\fR
|
||||
suppress warning messages.
|
||||
.IP \fB\-s\fR
|
||||
suppress stricts.
|
||||
.IP \fB\-a\fR
|
||||
suppress warnings and stricts.
|
||||
.IP \fB\-o\fR
|
||||
suppress warnings and stricts about old-style.
|
||||
.IP \fB\-\-\fItext\fR
|
||||
.br
|
||||
where \fItext\fR can be either of the above or
|
||||
a debug flag of the compiler (which is not useful for the common user.)
|
||||
This feature can be used in various shell scripts and surrounding programs
|
||||
to force a certain option to be handed over to \fBcemcom\fR.
|
||||
.LP
|
||||
.SH FILES
|
||||
.IR ~em/lib/em_cemcom :
|
||||
the compiler
|
||||
.SH DIAGNOSTICS
|
||||
All warning and error messages are written on standard error output.
|
||||
.SH REFERENCE
|
||||
Baalbergen, E.H., D. Grune, M. Waage ;"\fIThe CEM compiler\fR",
|
||||
Informatica Manual IM-4
|
||||
@@ -1,641 +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$ */
|
||||
/* S E M A N T I C A N A L Y S I S -- C H A P T E R 3.3 */
|
||||
|
||||
#include "lint.h"
|
||||
#include "debug.h"
|
||||
#include "nobitfield.h"
|
||||
#include "idf.h"
|
||||
#include <flt_arith.h>
|
||||
#include "arith.h"
|
||||
#include "proto.h"
|
||||
#include "type.h"
|
||||
#include "struct.h"
|
||||
#include "label.h"
|
||||
#include "expr.h"
|
||||
#include "def.h"
|
||||
#include "Lpars.h"
|
||||
#include "assert.h"
|
||||
#include "file_info.h"
|
||||
|
||||
extern char options[];
|
||||
extern char *symbol2str();
|
||||
extern struct type *qualifier_type();
|
||||
|
||||
/* Most expression-handling routines have a pointer to a
|
||||
(struct type *) as first parameter. The object under the pointer
|
||||
gets updated in the process.
|
||||
*/
|
||||
|
||||
ch7sel(expp, oper, idf)
|
||||
struct expr **expp;
|
||||
struct idf *idf;
|
||||
{
|
||||
/* The selector idf is applied to *expp; oper may be '.' or
|
||||
ARROW.
|
||||
*/
|
||||
register struct expr *exp;
|
||||
register struct type *tp;
|
||||
register struct sdef *sd;
|
||||
|
||||
any2opnd(expp, oper);
|
||||
exp = *expp;
|
||||
tp = exp->ex_type;
|
||||
if (oper == ARROW) {
|
||||
if (tp->tp_fund == POINTER &&
|
||||
( tp->tp_up->tp_fund == STRUCT ||
|
||||
tp->tp_up->tp_fund == UNION)) /* normal case */
|
||||
tp = tp->tp_up;
|
||||
else { /* constructions like "12->selector" and
|
||||
"char c; c->selector"
|
||||
*/
|
||||
switch (tp->tp_fund) {
|
||||
case POINTER:
|
||||
break;
|
||||
case INT:
|
||||
case LONG:
|
||||
/* An error is given in idf2sdef() */
|
||||
ch7cast(expp, CAST, pa_type);
|
||||
sd = idf2sdef(idf, tp);
|
||||
tp = sd->sd_stype;
|
||||
break;
|
||||
default:
|
||||
expr_error(exp, "-> applied to %s",
|
||||
symbol2str(tp->tp_fund));
|
||||
case ERRONEOUS:
|
||||
exp->ex_type = error_type;
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else { /* oper == '.' */
|
||||
/* nothing */
|
||||
}
|
||||
exp = *expp;
|
||||
switch (tp->tp_fund) {
|
||||
case POINTER: /* for int *p; p->next = ... */
|
||||
case STRUCT:
|
||||
case UNION:
|
||||
break;
|
||||
case INT:
|
||||
case LONG:
|
||||
/* warning will be given by idf2sdef() */
|
||||
break;
|
||||
default:
|
||||
if (!is_anon_idf(idf))
|
||||
expr_error(exp, "selector %s applied to %s",
|
||||
idf->id_text, symbol2str(tp->tp_fund));
|
||||
case ERRONEOUS:
|
||||
exp->ex_type = error_type;
|
||||
return;
|
||||
}
|
||||
sd = idf2sdef(idf, tp);
|
||||
if (oper == '.') {
|
||||
/* there are 3 cases in which the selection can be
|
||||
performed compile-time:
|
||||
I: n.sel (n either an identifier or a constant)
|
||||
II: (e.s1).s2 (transformed into (e.(s1+s2)))
|
||||
III: (e->s1).s2 (transformed into (e->(s1+s2)))
|
||||
The code performing these conversions is
|
||||
extremely obscure.
|
||||
*/
|
||||
if (exp->ex_class == Value) {
|
||||
/* It is an object we know the address of; so
|
||||
we can calculate the address of the
|
||||
selected member
|
||||
*/
|
||||
exp->VL_VALUE += sd->sd_offset;
|
||||
exp->ex_type = sd->sd_type;
|
||||
exp->ex_lvalue = exp->ex_type->tp_fund != ARRAY;
|
||||
if (exp->ex_type == error_type) {
|
||||
exp->ex_flags |= EX_ERROR;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (exp->ex_class == Oper) {
|
||||
struct oper *op = &(exp->ex_object.ex_oper);
|
||||
|
||||
if (op->op_oper == '.' || op->op_oper == ARROW) {
|
||||
ASSERT(is_cp_cst(op->op_right));
|
||||
op->op_right->VL_VALUE += sd->sd_offset;
|
||||
exp->ex_type = sd->sd_type;
|
||||
exp->ex_lvalue = exp->ex_type->tp_fund != ARRAY;
|
||||
if (exp->ex_type == error_type) {
|
||||
exp->ex_flags |= EX_ERROR;
|
||||
}
|
||||
}
|
||||
else {
|
||||
exp = new_oper(sd->sd_type, exp, '.',
|
||||
intexpr(sd->sd_offset, INT));
|
||||
exp->ex_lvalue = sd->sd_type->tp_fund != ARRAY;
|
||||
if (!exp->OP_LEFT->ex_lvalue)
|
||||
exp->ex_flags |= EX_ILVALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
else { /* oper == ARROW */
|
||||
exp = new_oper(sd->sd_type,
|
||||
exp, oper, intexpr(sd->sd_offset, INT));
|
||||
exp->ex_lvalue = (sd->sd_type->tp_fund != ARRAY);
|
||||
exp->ex_flags &= ~EX_ILVALUE;
|
||||
}
|
||||
if (sd->sd_type->tp_typequal & TQ_CONST)
|
||||
exp->ex_flags |= EX_READONLY;
|
||||
if (sd->sd_type->tp_typequal & TQ_VOLATILE)
|
||||
exp->ex_flags |= EX_VOLATILE;
|
||||
if (oper == '.' && exp->ex_flags & EX_READONLY) {
|
||||
exp->ex_type = qualifier_type(exp->ex_type, TQ_CONST);
|
||||
}
|
||||
*expp = exp;
|
||||
}
|
||||
|
||||
ch7incr(expp, oper)
|
||||
struct expr **expp;
|
||||
{
|
||||
/* The monadic prefix/postfix incr/decr operator oper is
|
||||
applied to *expp.
|
||||
*/
|
||||
ch7asgn(expp, oper, intexpr((arith)1, INT));
|
||||
}
|
||||
|
||||
ch7cast(expp, oper, tp)
|
||||
register struct expr **expp;
|
||||
register struct type *tp;
|
||||
{
|
||||
/* The expression *expp is cast to type tp; the cast is
|
||||
caused by the operator oper. If the cast has
|
||||
to be passed on to run time, its left operand will be an
|
||||
expression of class Type.
|
||||
*/
|
||||
register struct type *oldtp;
|
||||
|
||||
if ((*expp)->ex_type->tp_fund == FUNCTION)
|
||||
function2pointer(*expp);
|
||||
if ((*expp)->ex_type->tp_fund == ARRAY)
|
||||
array2pointer(*expp);
|
||||
if ((*expp)->ex_class == String)
|
||||
string2pointer(*expp);
|
||||
oldtp = (*expp)->ex_type;
|
||||
|
||||
#ifndef NOBITFIELD
|
||||
if (oldtp->tp_fund == FIELD) {
|
||||
field2arith(expp);
|
||||
ch7cast(expp, oper, tp);
|
||||
}
|
||||
else
|
||||
if (tp->tp_fund == FIELD) {
|
||||
ch7cast(expp, oper, tp->tp_up);
|
||||
}
|
||||
else
|
||||
#endif NOBITFIELD
|
||||
if (equal_type(tp, oldtp)) {
|
||||
/* life is easy */
|
||||
}
|
||||
else
|
||||
if (tp->tp_fund == VOID) {
|
||||
/* easy again */
|
||||
(*expp)->ex_type = void_type;
|
||||
}
|
||||
else
|
||||
if (is_arith_type(oldtp) && is_arith_type(tp)) {
|
||||
int oldi = is_integral_type(oldtp);
|
||||
int i = is_integral_type(tp);
|
||||
|
||||
if (oldi && i) {
|
||||
#ifdef LINT
|
||||
if (oper == CAST)
|
||||
(*expp)->ex_type = tp;
|
||||
else
|
||||
int2int(expp, tp);
|
||||
#else LINT
|
||||
int2int(expp, tp);
|
||||
#endif LINT
|
||||
}
|
||||
else
|
||||
if (oldi && !i) {
|
||||
#ifdef LINT
|
||||
if (oper == CAST)
|
||||
(*expp)->ex_type = tp;
|
||||
else
|
||||
int2float(expp, tp);
|
||||
#else LINT
|
||||
int2float(expp, tp);
|
||||
#endif LINT
|
||||
}
|
||||
else
|
||||
if (!oldi && i) {
|
||||
#ifdef LINT
|
||||
if (oper == CAST)
|
||||
(*expp)->ex_type = tp;
|
||||
else
|
||||
float2int(expp, tp);
|
||||
#else LINT
|
||||
float2int(expp, tp);
|
||||
#endif LINT
|
||||
}
|
||||
else {
|
||||
/* !oldi && !i */
|
||||
#ifdef LINT
|
||||
if (oper == CAST)
|
||||
(*expp)->ex_type = tp;
|
||||
else
|
||||
float2float(expp, tp);
|
||||
#else LINT
|
||||
float2float(expp, tp);
|
||||
#endif LINT
|
||||
}
|
||||
}
|
||||
else
|
||||
if (oldtp->tp_fund == POINTER && tp->tp_fund == POINTER) {
|
||||
if (oper == CASTAB)
|
||||
expr_warning(*expp, "incompatible pointers");
|
||||
else
|
||||
if (oper != CAST)
|
||||
expr_warning(*expp, "incompatible pointers in %s",
|
||||
symbol2str(oper));
|
||||
#ifdef LINT
|
||||
if (oper != CAST)
|
||||
lint_ptr_conv(oldtp->tp_up->tp_fund, tp->tp_up->tp_fund);
|
||||
#endif LINT
|
||||
(*expp)->ex_type = tp; /* free conversion */
|
||||
}
|
||||
else
|
||||
if (oldtp->tp_fund == POINTER && is_integral_type(tp)) {
|
||||
/* from pointer to integral */
|
||||
if (oper != CAST)
|
||||
expr_warning(*expp,
|
||||
"illegal conversion of pointer to %s",
|
||||
symbol2str(tp->tp_fund));
|
||||
if (oldtp->tp_size > tp->tp_size)
|
||||
expr_warning(*expp,
|
||||
"conversion of pointer to %s loses accuracy",
|
||||
symbol2str(tp->tp_fund));
|
||||
if (oldtp->tp_size != tp->tp_size)
|
||||
int2int(expp, tp);
|
||||
else
|
||||
(*expp)->ex_type = tp;
|
||||
}
|
||||
else
|
||||
if (tp->tp_fund == POINTER && is_integral_type(oldtp)) {
|
||||
/* from integral to pointer */
|
||||
switch (oper) {
|
||||
case CAST:
|
||||
break;
|
||||
case CASTAB:
|
||||
case EQUAL:
|
||||
case NOTEQUAL:
|
||||
case '=':
|
||||
case RETURN:
|
||||
if (is_cp_cst(*expp) && (*expp)->VL_VALUE == (arith)0)
|
||||
break;
|
||||
default:
|
||||
expr_warning(*expp,
|
||||
"illegal conversion of %s to pointer",
|
||||
symbol2str(oldtp->tp_fund));
|
||||
break;
|
||||
}
|
||||
if (oldtp->tp_size > tp->tp_size)
|
||||
expr_warning(*expp,
|
||||
"conversion of %s to pointer loses accuracy",
|
||||
symbol2str(oldtp->tp_fund));
|
||||
if (oldtp->tp_size != tp->tp_size)
|
||||
int2int(expp, tp);
|
||||
else
|
||||
(*expp)->ex_type = tp;
|
||||
}
|
||||
else
|
||||
if (oldtp->tp_fund == ERRONEOUS) {
|
||||
/* we just won't look */
|
||||
(*expp)->ex_type = tp; /* brute force */
|
||||
}
|
||||
else
|
||||
if (oldtp->tp_size == tp->tp_size && oper == CAST) {
|
||||
expr_warning(*expp, "dubious conversion based on equal size");
|
||||
(*expp)->ex_type = tp; /* brute force */
|
||||
}
|
||||
else {
|
||||
if (oldtp->tp_fund != ERRONEOUS && tp->tp_fund != ERRONEOUS)
|
||||
expr_error(*expp, "cannot convert %s to %s",
|
||||
symbol2str(oldtp->tp_fund),
|
||||
symbol2str(tp->tp_fund)
|
||||
);
|
||||
(*expp)->ex_type = tp; /* brute force */
|
||||
}
|
||||
if (oper == CAST) {
|
||||
(*expp)->ex_flags |= EX_ILVALUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Determine whether two types are equal.
|
||||
*/
|
||||
equal_type(tp, otp)
|
||||
register struct type *tp, *otp;
|
||||
{
|
||||
if (tp == otp)
|
||||
return 1;
|
||||
if (!tp || !otp)
|
||||
return 0;
|
||||
|
||||
if (tp->tp_fund != otp->tp_fund)
|
||||
return 0;
|
||||
if (tp->tp_unsigned != otp->tp_unsigned)
|
||||
return 0;
|
||||
if (tp->tp_align != otp->tp_align)
|
||||
return 0;
|
||||
if (tp->tp_fund != ARRAY /* && tp->tp_fund != STRUCT */ ) { /* UNION ??? */
|
||||
if (tp->tp_size != otp->tp_size)
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (tp->tp_fund) {
|
||||
|
||||
case FUNCTION:
|
||||
/* If both types have parameter type lists, the type of
|
||||
each parameter in the composite parameter type list
|
||||
is the composite type of the corresponding paramaters.
|
||||
*/
|
||||
if (tp->tp_proto && otp->tp_proto) {
|
||||
if (!equal_proto(tp->tp_proto, otp->tp_proto))
|
||||
return 0;
|
||||
} else if (tp->tp_proto || otp->tp_proto) {
|
||||
if (!legal_mixture(tp, otp))
|
||||
return 0;
|
||||
}
|
||||
return equal_type(tp->tp_up, otp->tp_up);
|
||||
|
||||
case ARRAY:
|
||||
/* If one type is an array of known size, the composite
|
||||
type is an array of that size
|
||||
*/
|
||||
if (tp->tp_size != otp->tp_size &&
|
||||
(tp->tp_size != -1 && otp->tp_size != -1))
|
||||
return 0;
|
||||
return equal_type(tp->tp_up, otp->tp_up);
|
||||
|
||||
case POINTER:
|
||||
if (equal_type(tp->tp_up, otp->tp_up)) {
|
||||
if (otp->tp_up->tp_typequal & TQ_CONST) {
|
||||
if (!(tp->tp_up->tp_typequal & TQ_CONST)) {
|
||||
strict("illegal use of pointer to const object");
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
else return 0;
|
||||
|
||||
case FIELD:
|
||||
return equal_type(tp->tp_up, otp->tp_up);
|
||||
|
||||
case STRUCT:
|
||||
case UNION:
|
||||
case ENUM:
|
||||
return tp->tp_idf == otp->tp_idf && tp->tp_sdef == otp->tp_sdef;
|
||||
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
check_pseudoproto(pl, opl)
|
||||
register struct proto *pl, *opl;
|
||||
{
|
||||
int retval = 1;
|
||||
|
||||
if (pl->pl_flag & PL_ELLIPSIS) {
|
||||
error("illegal ellipsis terminator");
|
||||
return 2;
|
||||
}
|
||||
while (pl && opl) {
|
||||
if (!equal_type(pl->pl_type, opl->pl_type)) {
|
||||
if (!(pl->pl_flag & PL_ERRGIVEN)
|
||||
&& !(opl->pl_flag & PL_ERRGIVEN))
|
||||
error("incorrect type for parameter %s of definition",
|
||||
opl->pl_idf->id_text);
|
||||
pl->pl_flag |= PL_ERRGIVEN;
|
||||
opl->pl_flag |= PL_ERRGIVEN;
|
||||
retval = 2;
|
||||
}
|
||||
pl = pl->next;
|
||||
opl = opl->next;
|
||||
}
|
||||
if (pl || opl) {
|
||||
error("incorrect number of parameters");
|
||||
retval = 2;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
legal_mixture(tp, otp)
|
||||
struct type *tp, *otp;
|
||||
{
|
||||
register struct proto *pl = tp->tp_proto, *opl = otp->tp_proto;
|
||||
int retval = 1;
|
||||
struct proto *prot;
|
||||
int fund;
|
||||
|
||||
ASSERT( (pl != 0) ^ (opl != 0));
|
||||
if (pl) {
|
||||
prot = pl;
|
||||
} else {
|
||||
prot = opl;
|
||||
}
|
||||
if (!opl && otp->tp_pseudoproto) {
|
||||
return check_pseudoproto(tp->tp_proto, otp->tp_pseudoproto);
|
||||
}
|
||||
|
||||
if (prot->pl_flag & PL_ELLIPSIS) {
|
||||
if (!(prot->pl_flag & PL_ERRGIVEN)) {
|
||||
if (pl)
|
||||
error("illegal ellipsis terminator");
|
||||
else error("ellipsis terminator in previous (prototype) declaration");
|
||||
}
|
||||
prot->pl_flag |= PL_ERRGIVEN;
|
||||
prot = prot->next;
|
||||
return 2;
|
||||
}
|
||||
while (prot) {
|
||||
/* if (!(prot->pl_flag & PL_ELLIPSIS)) {} */
|
||||
fund = prot->pl_type->tp_fund;
|
||||
if (fund == CHAR || fund == SHORT || fund == FLOAT) {
|
||||
if (!(prot->pl_flag & PL_ERRGIVEN))
|
||||
error("illegal %s parameter in %sdeclaration",
|
||||
symbol2str(fund), (opl ? "previous (prototype) " : "" ));
|
||||
prot->pl_flag |= PL_ERRGIVEN;
|
||||
retval = 2;
|
||||
}
|
||||
prot = prot->next;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
equal_proto(pl, opl)
|
||||
register struct proto *pl, *opl;
|
||||
{
|
||||
if (pl == opl)
|
||||
return 1;
|
||||
|
||||
/* If only one type is a function type with a parameter type list
|
||||
(a function prototype), the composite type is a function
|
||||
prototype with parameter type list.
|
||||
*/
|
||||
while ( pl && opl) {
|
||||
|
||||
if ((pl->pl_flag & ~PL_ERRGIVEN) != (opl->pl_flag & ~PL_ERRGIVEN))
|
||||
return 0;
|
||||
|
||||
if (!equal_type(pl->pl_type, opl->pl_type))
|
||||
return 0;
|
||||
|
||||
pl = pl->next;
|
||||
opl = opl->next;
|
||||
}
|
||||
return !(pl || opl);
|
||||
}
|
||||
|
||||
recurconst(tp)
|
||||
struct type *tp;
|
||||
{
|
||||
register struct sdef *sdf;
|
||||
|
||||
ASSERT(tp);
|
||||
if (!tp) return 0;
|
||||
if (tp->tp_typequal & TQ_CONST) return 1;
|
||||
sdf = tp->tp_sdef;
|
||||
while (sdf) {
|
||||
if (recurconst(sdf->sd_type))
|
||||
return 1;
|
||||
sdf = sdf->sd_sdef;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
ch7asgn(expp, oper, expr)
|
||||
struct expr **expp;
|
||||
struct expr *expr;
|
||||
{
|
||||
/* The assignment operators.
|
||||
"f op= e" should be interpreted as
|
||||
"f = (typeof f)((typeof (f op e))f op (typeof (f op e))e)"
|
||||
and not as "f = f op (typeof f)e".
|
||||
Consider, for example, (i == 10) i *= 0.9; (i == 9), where
|
||||
typeof i == int.
|
||||
The resulting expression tree becomes:
|
||||
op=
|
||||
/ \
|
||||
/ \
|
||||
f (typeof (f op e))e
|
||||
EVAL should however take care of evaluating (typeof (f op e))f
|
||||
*/
|
||||
register struct expr *exp = *expp;
|
||||
int fund = exp->ex_type->tp_fund;
|
||||
int vol = 0;
|
||||
struct type *tp;
|
||||
|
||||
/* We expect an lvalue */
|
||||
if (!exp->ex_lvalue) {
|
||||
expr_error(exp, "no lvalue in operand of %s", symbol2str(oper));
|
||||
} else if (exp->ex_flags & EX_ILVALUE) {
|
||||
strict("incorrect lvalue in operand of %s", symbol2str(oper));
|
||||
} else if (exp->ex_flags & EX_READONLY) {
|
||||
expr_error(exp, "operand of %s is read-only", symbol2str(oper));
|
||||
} else if (fund == STRUCT || fund == UNION) {
|
||||
if (recurconst(exp->ex_type))
|
||||
expr_error(expr,"operand of %s contains a const-qualified member",
|
||||
symbol2str(oper));
|
||||
}
|
||||
|
||||
/* Preserve volatile markers across the tree.
|
||||
This is questionable, depending on the way the optimizer
|
||||
wants this information.
|
||||
vol = (exp->ex_flags & EX_VOLATILE) || (expr->ex_flags & EX_VOLATILE);
|
||||
*/
|
||||
|
||||
if (oper == '=') {
|
||||
ch7cast(&expr, oper, exp->ex_type);
|
||||
tp = expr->ex_type;
|
||||
}
|
||||
else { /* turn e into e' where typeof(e') = typeof (f op e) */
|
||||
struct expr *extmp = intexpr((arith)0, INT);
|
||||
|
||||
/* this is really $#@&*%$# ! */
|
||||
/* if you correct this, please correct lint_new_oper() too */
|
||||
extmp->ex_lvalue = 1;
|
||||
extmp->ex_type = exp->ex_type;
|
||||
ch7bin(&extmp, oper, expr);
|
||||
/* Note that ch7bin creates a tree of the expression
|
||||
((typeof (f op e))f op (typeof (f op e))e),
|
||||
where f ~ extmp and e ~ expr.
|
||||
We want to use (typeof (f op e))e.
|
||||
Ch7bin does not create a tree if both operands
|
||||
were illegal or constants!
|
||||
*/
|
||||
tp = extmp->ex_type; /* perform the arithmetic in type tp */
|
||||
if (extmp->ex_class == Oper) {
|
||||
expr = extmp->OP_RIGHT;
|
||||
extmp->OP_RIGHT = NILEXPR;
|
||||
free_expression(extmp);
|
||||
}
|
||||
else
|
||||
expr = extmp;
|
||||
}
|
||||
#ifndef NOBITFIELD
|
||||
if (fund == FIELD)
|
||||
exp = new_oper(exp->ex_type->tp_up, exp, oper, expr);
|
||||
else
|
||||
exp = new_oper(exp->ex_type, exp, oper, expr);
|
||||
#else NOBITFIELD
|
||||
exp = new_oper(exp->ex_type, exp, oper, expr);
|
||||
#endif NOBITFIELD
|
||||
exp->OP_TYPE = tp; /* for EVAL() */
|
||||
exp->ex_flags |= vol ? (EX_SIDEEFFECTS|EX_VOLATILE) : EX_SIDEEFFECTS;
|
||||
*expp = exp;
|
||||
}
|
||||
|
||||
/* Some interesting (?) questions answered.
|
||||
*/
|
||||
int
|
||||
is_integral_type(tp)
|
||||
register struct type *tp;
|
||||
{
|
||||
switch (tp->tp_fund) {
|
||||
case GENERIC:
|
||||
case CHAR:
|
||||
case SHORT:
|
||||
case INT:
|
||||
case LONG:
|
||||
case ENUM:
|
||||
return 1;
|
||||
#ifndef NOBITFIELD
|
||||
case FIELD:
|
||||
return is_integral_type(tp->tp_up);
|
||||
#endif NOBITFIELD
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
is_arith_type(tp)
|
||||
register struct type *tp;
|
||||
{
|
||||
switch (tp->tp_fund) {
|
||||
case GENERIC:
|
||||
case CHAR:
|
||||
case SHORT:
|
||||
case INT:
|
||||
case LONG:
|
||||
case ENUM:
|
||||
case FLOAT:
|
||||
case DOUBLE:
|
||||
case LNGDBL:
|
||||
return 1;
|
||||
#ifndef NOBITFIELD
|
||||
case FIELD:
|
||||
return is_arith_type(tp->tp_up);
|
||||
#endif NOBITFIELD
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1,352 +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$ */
|
||||
/* SEMANTIC ANALYSIS (CHAPTER 3.3) -- BINARY OPERATORS */
|
||||
|
||||
#include "botch_free.h"
|
||||
#include <alloc.h>
|
||||
#include "lint.h"
|
||||
#include "idf.h"
|
||||
#include <flt_arith.h>
|
||||
#include "arith.h"
|
||||
#include "type.h"
|
||||
#include "struct.h"
|
||||
#include "label.h"
|
||||
#include "expr.h"
|
||||
#include "Lpars.h"
|
||||
|
||||
extern char options[];
|
||||
extern char *symbol2str();
|
||||
|
||||
/* This chapter asks for the repeated application of code to handle
|
||||
an operation that may be executed at compile time or at run time,
|
||||
depending on the constancy of the operands.
|
||||
*/
|
||||
|
||||
#define commutative_binop(expp, oper, expr) mk_binop(expp, oper, expr, 1)
|
||||
#define non_commutative_binop(expp, oper, expr) mk_binop(expp, oper, expr, 0)
|
||||
|
||||
ch7bin(expp, oper, expr)
|
||||
register struct expr **expp;
|
||||
struct expr *expr;
|
||||
{
|
||||
/* apply binary operator oper between *expp and expr.
|
||||
NB: don't swap operands if op is one of the op= operators!!!
|
||||
*/
|
||||
|
||||
any2opnd(expp, oper);
|
||||
any2opnd(&expr, oper);
|
||||
switch (oper) {
|
||||
case '[': /* 3.3.2.1 */
|
||||
/* indexing follows the commutative laws */
|
||||
switch ((*expp)->ex_type->tp_fund) {
|
||||
case POINTER:
|
||||
case ARRAY:
|
||||
break;
|
||||
case ERRONEOUS:
|
||||
return;
|
||||
default: /* unindexable */
|
||||
switch (expr->ex_type->tp_fund) {
|
||||
case POINTER:
|
||||
case ARRAY:
|
||||
break;
|
||||
case ERRONEOUS:
|
||||
return;
|
||||
default:
|
||||
expr_error(*expp,
|
||||
"indexing an object of type %s",
|
||||
symbol2str((*expp)->ex_type->tp_fund));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
ch7bin(expp, '+', expr);
|
||||
ch7mon('*', expp);
|
||||
break;
|
||||
|
||||
case '(': /* 3.3.2.2 */
|
||||
if ( (*expp)->ex_type->tp_fund == POINTER &&
|
||||
(*expp)->ex_type->tp_up->tp_fund == FUNCTION
|
||||
) {
|
||||
ch7mon('*', expp);
|
||||
}
|
||||
if ((*expp)->ex_type->tp_fund != FUNCTION) {
|
||||
expr_error(*expp, "call of non-function (%s)",
|
||||
symbol2str((*expp)->ex_type->tp_fund));
|
||||
/* leave the expression; it may still serve */
|
||||
free_expression(expr); /* there go the parameters */
|
||||
*expp = new_oper(error_type,
|
||||
*expp, '(', (struct expr *)0);
|
||||
}
|
||||
else
|
||||
*expp = new_oper((*expp)->ex_type->tp_up,
|
||||
*expp, '(', expr);
|
||||
(*expp)->ex_flags |= EX_SIDEEFFECTS;
|
||||
break;
|
||||
|
||||
case PARCOMMA: /* 3.3.2.2 */
|
||||
if ((*expp)->ex_type->tp_fund == FUNCTION)
|
||||
function2pointer(*expp);
|
||||
*expp = new_oper(expr->ex_type, *expp, PARCOMMA, expr);
|
||||
break;
|
||||
|
||||
case '%':
|
||||
case MODAB:
|
||||
case ANDAB:
|
||||
case XORAB:
|
||||
case ORAB:
|
||||
opnd2integral(expp, oper);
|
||||
opnd2integral(&expr, oper);
|
||||
/* fallthrough */
|
||||
case '/':
|
||||
case DIVAB:
|
||||
case TIMESAB:
|
||||
arithbalance(expp, oper, &expr);
|
||||
non_commutative_binop(expp, oper, expr);
|
||||
break;
|
||||
|
||||
case '&':
|
||||
case '^':
|
||||
case '|':
|
||||
opnd2integral(expp, oper);
|
||||
opnd2integral(&expr, oper);
|
||||
/* fallthrough */
|
||||
case '*':
|
||||
arithbalance(expp, oper, &expr);
|
||||
commutative_binop(expp, oper, expr);
|
||||
break;
|
||||
|
||||
case '+':
|
||||
if (expr->ex_type->tp_fund == POINTER) { /* swap operands */
|
||||
struct expr *etmp = expr;
|
||||
expr = *expp;
|
||||
*expp = etmp;
|
||||
}
|
||||
/* fallthrough */
|
||||
case PLUSAB:
|
||||
case POSTINCR:
|
||||
case PLUSPLUS:
|
||||
if ((*expp)->ex_type->tp_fund == POINTER) {
|
||||
pointer_arithmetic(expp, oper, &expr);
|
||||
if (expr->ex_type->tp_size != (*expp)->ex_type->tp_size)
|
||||
ch7cast(&expr, CAST, (*expp)->ex_type);
|
||||
pointer_binary(expp, oper, expr);
|
||||
}
|
||||
else {
|
||||
arithbalance(expp, oper, &expr);
|
||||
if (oper == '+')
|
||||
commutative_binop(expp, oper, expr);
|
||||
else
|
||||
non_commutative_binop(expp, oper, expr);
|
||||
}
|
||||
break;
|
||||
|
||||
case '-':
|
||||
case MINAB:
|
||||
case POSTDECR:
|
||||
case MINMIN:
|
||||
if ((*expp)->ex_type->tp_fund == POINTER) {
|
||||
if (expr->ex_type->tp_fund == POINTER)
|
||||
pntminuspnt(expp, oper, expr);
|
||||
else {
|
||||
pointer_arithmetic(expp, oper, &expr);
|
||||
pointer_binary(expp, oper, expr);
|
||||
}
|
||||
}
|
||||
else {
|
||||
arithbalance(expp, oper, &expr);
|
||||
non_commutative_binop(expp, oper, expr);
|
||||
}
|
||||
break;
|
||||
|
||||
case LEFT:
|
||||
case RIGHT:
|
||||
case LEFTAB:
|
||||
case RIGHTAB:
|
||||
opnd2integral(expp, oper);
|
||||
opnd2integral(&expr, oper);
|
||||
arithbalance(expp, oper, &expr); /* ch. 7.5 */
|
||||
ch7cast(&expr, oper, int_type); /* cvt. rightop to int */
|
||||
non_commutative_binop(expp, oper, expr);
|
||||
break;
|
||||
|
||||
case '<':
|
||||
case '>':
|
||||
case LESSEQ:
|
||||
case GREATEREQ:
|
||||
case EQUAL:
|
||||
case NOTEQUAL:
|
||||
relbalance(expp, oper, &expr);
|
||||
non_commutative_binop(expp, oper, expr);
|
||||
(*expp)->ex_type = int_type;
|
||||
break;
|
||||
|
||||
case AND:
|
||||
case OR:
|
||||
opnd2test(expp, oper);
|
||||
opnd2test(&expr, oper);
|
||||
if (is_cp_cst(*expp)) {
|
||||
register struct expr *ex = *expp;
|
||||
|
||||
/* the following condition is a short-hand for
|
||||
((oper == AND) && o1) || ((oper == OR) && !o1)
|
||||
where o1 == (*expp)->VL_VALUE;
|
||||
and ((oper == AND) || (oper == OR))
|
||||
*/
|
||||
if ((oper == AND) == (ex->VL_VALUE != (arith)0))
|
||||
*expp = expr;
|
||||
else {
|
||||
ex->ex_flags |= expr->ex_flags;
|
||||
free_expression(expr);
|
||||
*expp = intexpr((arith)((oper == AND) ? 0 : 1),
|
||||
INT);
|
||||
}
|
||||
(*expp)->ex_flags |= ex->ex_flags;
|
||||
free_expression(ex);
|
||||
}
|
||||
else
|
||||
if (is_cp_cst(expr)) {
|
||||
/* Note!!!: the following condition is a short-hand for
|
||||
((oper == AND) && o2) || ((oper == OR) && !o2)
|
||||
where o2 == expr->VL_VALUE
|
||||
and ((oper == AND) || (oper == OR))
|
||||
*/
|
||||
if ((oper == AND) == (expr->VL_VALUE != (arith)0)) {
|
||||
(*expp)->ex_flags |= expr->ex_flags;
|
||||
free_expression(expr);
|
||||
}
|
||||
else {
|
||||
if (oper == OR)
|
||||
expr->VL_VALUE = (arith)1;
|
||||
ch7bin(expp, ',', expr);
|
||||
}
|
||||
}
|
||||
else {
|
||||
*expp = new_oper(int_type, *expp, oper, expr);
|
||||
}
|
||||
(*expp)->ex_flags |= EX_LOGICAL;
|
||||
break;
|
||||
|
||||
case ':':
|
||||
if ( is_struct_or_union((*expp)->ex_type->tp_fund)
|
||||
|| is_struct_or_union(expr->ex_type->tp_fund)
|
||||
) {
|
||||
if (!equal_type((*expp)->ex_type, expr->ex_type))
|
||||
expr_error(*expp, "illegal balance");
|
||||
}
|
||||
else
|
||||
relbalance(expp, oper, &expr);
|
||||
#ifdef LINT
|
||||
if ( (is_cp_cst(*expp) && is_cp_cst(expr))
|
||||
&& (*expp)->VL_VALUE == expr->VL_VALUE
|
||||
) {
|
||||
hwarning("operands of : are constant and equal");
|
||||
}
|
||||
#endif LINT
|
||||
*expp = new_oper((*expp)->ex_type, *expp, oper, expr);
|
||||
break;
|
||||
|
||||
case '?':
|
||||
opnd2logical(expp, oper);
|
||||
if (is_cp_cst(*expp)) {
|
||||
#ifdef LINT
|
||||
hwarning("condition in ?: expression is constant");
|
||||
#endif LINT
|
||||
*expp = (*expp)->VL_VALUE ?
|
||||
expr->OP_LEFT : expr->OP_RIGHT;
|
||||
}
|
||||
else {
|
||||
*expp = new_oper(expr->ex_type, *expp, oper, expr);
|
||||
}
|
||||
break;
|
||||
|
||||
case ',':
|
||||
if (is_cp_cst(*expp))
|
||||
*expp = expr;
|
||||
else
|
||||
*expp = new_oper(expr->ex_type, *expp, oper, expr);
|
||||
(*expp)->ex_flags |= EX_COMMA;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pntminuspnt(expp, oper, expr)
|
||||
register struct expr **expp, *expr;
|
||||
{
|
||||
/* Subtracting two pointers is so complicated it merits a
|
||||
routine of its own.
|
||||
*/
|
||||
struct type *up_type = (*expp)->ex_type->tp_up;
|
||||
|
||||
if (!equal_type(up_type, expr->ex_type->tp_up)) {
|
||||
expr_error(*expp, "subtracting incompatible pointers");
|
||||
free_expression(expr);
|
||||
erroneous2int(expp);
|
||||
return;
|
||||
}
|
||||
/* we hope the optimizer will eliminate the load-time
|
||||
pointer subtraction
|
||||
*/
|
||||
*expp = new_oper((*expp)->ex_type, *expp, oper, expr);
|
||||
ch7cast(expp, CAST, pa_type); /* ptr-ptr: result has pa_type */
|
||||
ch7bin(expp, '/',
|
||||
intexpr(size_of_type(up_type, "object"), pa_type->tp_fund));
|
||||
ch7cast(expp, CAST, int_type); /* result will be an integer expr */
|
||||
}
|
||||
|
||||
mk_binop(expp, oper, expr, commutative)
|
||||
struct expr **expp;
|
||||
register struct expr *expr;
|
||||
{
|
||||
/* Constructs in *expp the operation indicated by the operands.
|
||||
"commutative" indicates whether "oper" is a commutative
|
||||
operator.
|
||||
*/
|
||||
register struct expr *ex = *expp;
|
||||
|
||||
if (is_cp_cst(expr) && is_cp_cst(ex))
|
||||
cstbin(expp, oper, expr);
|
||||
else if (is_fp_cst(expr) && is_fp_cst(ex))
|
||||
fltcstbin(expp, oper, expr);
|
||||
else {
|
||||
*expp = (commutative && expr->ex_depth >= ex->ex_depth) ?
|
||||
new_oper(ex->ex_type, expr, oper, ex) :
|
||||
new_oper(ex->ex_type, ex, oper, expr);
|
||||
}
|
||||
}
|
||||
|
||||
pointer_arithmetic(expp1, oper, expp2)
|
||||
register struct expr **expp1, **expp2;
|
||||
{
|
||||
int typ;
|
||||
/* prepares the integral expression expp2 in order to
|
||||
apply it to the pointer expression expp1
|
||||
*/
|
||||
if ((typ = any2arith(expp2, oper)) == FLOAT
|
||||
|| typ == DOUBLE
|
||||
|| typ == LNGDBL) {
|
||||
expr_error(*expp2,
|
||||
"illegal combination of %s and pointer",
|
||||
symbol2str(typ));
|
||||
erroneous2int(expp2);
|
||||
}
|
||||
ch7bin( expp2, '*',
|
||||
intexpr(size_of_type((*expp1)->ex_type->tp_up, "object"),
|
||||
pa_type->tp_fund)
|
||||
);
|
||||
}
|
||||
|
||||
pointer_binary(expp, oper, expr)
|
||||
register struct expr **expp, *expr;
|
||||
{
|
||||
/* constructs the pointer arithmetic expression out of
|
||||
a pointer expression, a binary operator and an integral
|
||||
expression.
|
||||
*/
|
||||
if (is_ld_cst(expr) && is_ld_cst(*expp))
|
||||
cstbin(expp, oper, expr);
|
||||
else
|
||||
*expp = new_oper((*expp)->ex_type, *expp, oper, expr);
|
||||
}
|
||||
@@ -1,168 +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$ */
|
||||
/* SEMANTIC ANALYSIS (CHAPTER 3.3) -- MONADIC OPERATORS */
|
||||
|
||||
#include "botch_free.h"
|
||||
#include <alloc.h>
|
||||
#include "nobitfield.h"
|
||||
#include "Lpars.h"
|
||||
#include <flt_arith.h>
|
||||
#include "arith.h"
|
||||
#include "type.h"
|
||||
#include "label.h"
|
||||
#include "expr.h"
|
||||
#include "idf.h"
|
||||
#include "def.h"
|
||||
|
||||
extern char options[];
|
||||
extern arith full_mask[/*MAXSIZE*/]; /* cstoper.c */
|
||||
char *symbol2str();
|
||||
|
||||
ch7mon(oper, expp)
|
||||
register struct expr **expp;
|
||||
{
|
||||
/* The monadic prefix operator oper is applied to *expp.
|
||||
*/
|
||||
register struct expr *expr;
|
||||
|
||||
switch (oper) {
|
||||
case '*': /* 3.3.3.2 */
|
||||
/* no FIELD type allowed */
|
||||
if ((*expp)->ex_type->tp_fund == ARRAY)
|
||||
array2pointer(*expp);
|
||||
if ((*expp)->ex_type->tp_fund != POINTER) {
|
||||
if ((*expp)->ex_type->tp_fund != FUNCTION) {
|
||||
expr_error(*expp,
|
||||
"* applied to non-pointer (%s)",
|
||||
symbol2str((*expp)->ex_type->tp_fund));
|
||||
} else {
|
||||
warning("superfluous use of * on function");
|
||||
/* ignore indirection (yegh) */
|
||||
}
|
||||
} else {
|
||||
expr = *expp;
|
||||
if (expr->ex_lvalue == 0 && expr->ex_class != String)
|
||||
/* dereference in administration only */
|
||||
expr->ex_type = expr->ex_type->tp_up;
|
||||
else /* runtime code */
|
||||
*expp = new_oper(expr->ex_type->tp_up, NILEXPR,
|
||||
'*', expr);
|
||||
(*expp)->ex_lvalue = (
|
||||
(*expp)->ex_type->tp_fund != ARRAY &&
|
||||
(*expp)->ex_type->tp_fund != FUNCTION
|
||||
);
|
||||
if ((*expp)->ex_type->tp_typequal & TQ_CONST)
|
||||
(*expp)->ex_flags |= EX_READONLY;
|
||||
if ((*expp)->ex_type->tp_typequal & TQ_VOLATILE)
|
||||
(*expp)->ex_flags |= EX_VOLATILE;
|
||||
(*expp)->ex_flags &= ~EX_ILVALUE;
|
||||
}
|
||||
break;
|
||||
case '&':
|
||||
if ((*expp)->ex_type->tp_fund == ARRAY) {
|
||||
expr_warning(*expp, "& before array ignored");
|
||||
array2pointer(*expp);
|
||||
}
|
||||
else
|
||||
if ((*expp)->ex_type->tp_fund == FUNCTION) {
|
||||
expr_warning(*expp, "& before function ignored");
|
||||
function2pointer(*expp);
|
||||
}
|
||||
else
|
||||
#ifndef NOBITFIELD
|
||||
if ((*expp)->ex_type->tp_fund == FIELD)
|
||||
expr_error(*expp, "& applied to field variable");
|
||||
else
|
||||
#endif NOBITFIELD
|
||||
if (!(*expp)->ex_lvalue)
|
||||
expr_error(*expp, "& applied to non-lvalue");
|
||||
else if ((*expp)->ex_flags & EX_ILVALUE)
|
||||
expr_error(*expp, "& applied to illegal lvalue");
|
||||
else {
|
||||
/* assume that enums are already filtered out */
|
||||
if (ISNAME(*expp)) {
|
||||
register struct def *def =
|
||||
(*expp)->VL_IDF->id_def;
|
||||
|
||||
/* &<var> indicates that <var>
|
||||
cannot be used as register
|
||||
anymore
|
||||
*/
|
||||
if (def->df_sc == REGISTER) {
|
||||
expr_error(*expp,
|
||||
"& on register variable not allowed");
|
||||
break; /* break case '&' */
|
||||
}
|
||||
}
|
||||
(*expp)->ex_type = pointer_to((*expp)->ex_type,
|
||||
(*expp)->ex_type->tp_typequal);
|
||||
(*expp)->ex_lvalue = 0;
|
||||
(*expp)->ex_flags &= ~EX_READONLY;
|
||||
}
|
||||
break;
|
||||
case '~':
|
||||
{
|
||||
int fund = (*expp)->ex_type->tp_fund;
|
||||
|
||||
if (fund == FLOAT || fund == DOUBLE || fund == LNGDBL) {
|
||||
expr_error( *expp,
|
||||
"~ not allowed on %s operands",
|
||||
symbol2str(fund));
|
||||
erroneous2int(expp);
|
||||
break;
|
||||
}
|
||||
/* FALLTHROUGH */
|
||||
}
|
||||
case '-':
|
||||
any2arith(expp, oper);
|
||||
if (is_cp_cst(*expp)) {
|
||||
arith o1 = (*expp)->VL_VALUE;
|
||||
|
||||
(*expp)->VL_VALUE = (oper == '-') ? -o1 :
|
||||
((*expp)->ex_type->tp_unsigned ?
|
||||
(~o1) & full_mask[(*expp)->ex_type->tp_size] :
|
||||
~o1
|
||||
);
|
||||
}
|
||||
else
|
||||
if (is_fp_cst(*expp))
|
||||
switch_sign_fp(*expp);
|
||||
else
|
||||
*expp = new_oper((*expp)->ex_type,
|
||||
NILEXPR, oper, *expp);
|
||||
break;
|
||||
case '!':
|
||||
if ((*expp)->ex_type->tp_fund == FUNCTION)
|
||||
function2pointer(*expp);
|
||||
if ((*expp)->ex_type->tp_fund != POINTER)
|
||||
any2arith(expp, oper);
|
||||
opnd2test(expp, '!');
|
||||
if (is_cp_cst(*expp)) {
|
||||
(*expp)->VL_VALUE = !((*expp)->VL_VALUE);
|
||||
(*expp)->ex_type = int_type; /* a cast ???(EB) */
|
||||
}
|
||||
else
|
||||
*expp = new_oper(int_type, NILEXPR, oper, *expp);
|
||||
(*expp)->ex_flags |= EX_LOGICAL;
|
||||
break;
|
||||
case PLUSPLUS:
|
||||
case MINMIN:
|
||||
ch7incr(expp, oper);
|
||||
break;
|
||||
case SIZEOF:
|
||||
if (ISNAME(*expp) && (*expp)->VL_IDF->id_def->df_formal_array)
|
||||
expr_warning(*expp, "sizeof formal array %s is sizeof pointer!",
|
||||
(*expp)->VL_IDF->id_text);
|
||||
expr = intexpr((*expp)->ex_class == String ?
|
||||
(arith)((*expp)->SG_LEN) :
|
||||
size_of_type((*expp)->ex_type, "object"),
|
||||
INT);
|
||||
expr->ex_flags |= EX_SIZEOF;
|
||||
free_expression(*expp);
|
||||
*expp = expr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1,21 +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$ */
|
||||
/* DECLARATION SPECIFIER DEFINITION */
|
||||
|
||||
struct decspecs {
|
||||
struct decspecs *next;
|
||||
struct type *ds_type; /* single type */
|
||||
int ds_notypegiven; /* set if type not given explicitly */
|
||||
int ds_typedef; /* 1 if type was a user typedef */
|
||||
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; /* SIGNED, UNSIGNED or 0 */
|
||||
int ds_typequal; /* type qualifiers - see type.str */
|
||||
};
|
||||
|
||||
extern struct type *qualifier_type();
|
||||
extern struct decspecs null_decspecs;
|
||||
@@ -1,74 +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$ */
|
||||
|
||||
/*
|
||||
*The following functions are hacked to null-functions (i.e. they
|
||||
* do nothing). This needs another solution in the future.
|
||||
*/
|
||||
#include "lint.h"
|
||||
|
||||
#ifdef LINT
|
||||
|
||||
#include "arith.h"
|
||||
#include "label.h"
|
||||
|
||||
C_close(){}
|
||||
int C_busy(){return 0;}
|
||||
|
||||
|
||||
/* More routines */
|
||||
/* ARGSUSED */
|
||||
CC_bhcst(ps_xxx,n,w,i) arith n,w; {}
|
||||
/* ARGSUSED */
|
||||
CC_crcst(ps_xxx,v) arith v; {}
|
||||
/* ARGSUSED */
|
||||
CC_crdlb(ps_xxx,v,s) label v; arith s; {}
|
||||
/* ARGSUSED */
|
||||
CC_crdnam(ps_xxx,v,s) char *v; arith s; {}
|
||||
/* ARGSUSED */
|
||||
CC_crfcon(ps_xxx,v,s) char *v; arith s; {}
|
||||
/* ARGSUSED */
|
||||
CC_cricon(ps_xxx,v,s) char *v; arith s; {}
|
||||
/* ARGSUSED */
|
||||
CC_crilb(ps_xxx,v) label v; {}
|
||||
/* ARGSUSED */
|
||||
CC_crpnam(ps_xxx,v) char *v; {}
|
||||
/* ARGSUSED */
|
||||
CC_crscon(ps_xxx,v,s) char *v; arith s; {}
|
||||
/* ARGSUSED */
|
||||
CC_crucon(ps_xxx,v,s) char *v; arith s; {}
|
||||
/* ARGSUSED */
|
||||
CC_cst(l) {}
|
||||
/* ARGSUSED */
|
||||
CC_dfdlb(l) label l; {}
|
||||
/* ARGSUSED */
|
||||
CC_dfdnam(s) char *s; {}
|
||||
/* ARGSUSED */
|
||||
CC_dfilb(l) label l; {}
|
||||
/* ARGSUSED */
|
||||
CC_end(l) arith l; {}
|
||||
CC_msend() {}
|
||||
/* ARGSUSED */
|
||||
CC_msstart(ms) {}
|
||||
/* ARGSUSED */
|
||||
CC_opcst(op_xxx,c) arith c; {}
|
||||
/* ARGSUSED */
|
||||
CC_opdlb(op_xxx,g,o) label g; arith o; {}
|
||||
/* ARGSUSED */
|
||||
CC_opilb(op_xxx,b) label b; {}
|
||||
/* ARGSUSED */
|
||||
CC_oppnam(op_xxx,p) char *p; {}
|
||||
/* ARGSUSED */
|
||||
CC_pronarg(s) char *s; {}
|
||||
/* ARGSUSED */
|
||||
CC_psdlb(ps_xxx,l) label l; {}
|
||||
/* ARGSUSED */
|
||||
CC_psdnam(ps_xxx,s) char *s; {}
|
||||
/* ARGSUSED */
|
||||
CC_pspnam(ps_xxx,s) char *s; {}
|
||||
/* ARGSUSED */
|
||||
CC_scon(v,s) char *s; {}
|
||||
#endif LINT
|
||||
@@ -1,246 +0,0 @@
|
||||
/* $Header$ */
|
||||
/*
|
||||
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||
*/
|
||||
/* mcomm.c -- change ".lcomm name" into ".comm name" where "name"
|
||||
is specified in a list.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
#define IDFSIZE 4096
|
||||
|
||||
char *readfile();
|
||||
|
||||
struct node {
|
||||
char *name;
|
||||
struct node *left, *right;
|
||||
};
|
||||
|
||||
char *
|
||||
Malloc(n)
|
||||
unsigned n;
|
||||
{
|
||||
char *space;
|
||||
char *malloc();
|
||||
|
||||
if ((space = malloc(n)) == 0) {
|
||||
fprintf(stderr, "out of memory\n");
|
||||
exit(1);
|
||||
}
|
||||
return space;
|
||||
}
|
||||
|
||||
struct node *make_tree();
|
||||
|
||||
#define new_node() ((struct node *) Malloc(sizeof (struct node)))
|
||||
|
||||
main(argc, argv)
|
||||
char *argv[];
|
||||
{
|
||||
char *nl_file, *as_file;
|
||||
char *nl_text, *as_text;
|
||||
struct node *nl_tree = 0;
|
||||
int nl_siz, as_siz;
|
||||
|
||||
if (argc != 3) {
|
||||
fprintf(stderr, "use: %s namelist assembler_file\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
nl_file = argv[1];
|
||||
as_file = argv[2];
|
||||
|
||||
if ((nl_text = readfile(nl_file, &nl_siz)) == 0) {
|
||||
fprintf(stderr, "%s: cannot read namelist %s\n",
|
||||
argv[0], nl_file);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ((as_text = readfile(as_file, &as_siz)) == 0) {
|
||||
fprintf(stderr, "%s: cannot read assembler file %s\n",
|
||||
argv[0], as_file);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
nl_tree = make_tree(nl_text);
|
||||
edit(as_text, nl_tree);
|
||||
|
||||
if (writefile(as_file, as_text, as_siz) == 0) {
|
||||
fprintf(stderr, "%s: cannot write to %s\n", argv[0], as_file);
|
||||
exit(1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stat.h>
|
||||
|
||||
char *
|
||||
readfile(filename, psiz)
|
||||
char *filename;
|
||||
int *psiz;
|
||||
{
|
||||
struct stat stbuf; /* for `stat' to get filesize */
|
||||
register int fd; /* filedescriptor for `filename' */
|
||||
register char *cbuf; /* pointer to buffer to be returned */
|
||||
|
||||
if (((fd = open(filename, 0)) < 0) || (fstat(fd, &stbuf) != 0))
|
||||
return 0;
|
||||
cbuf = Malloc(stbuf.st_size + 1);
|
||||
if (read(fd, cbuf, stbuf.st_size) != stbuf.st_size)
|
||||
return 0;
|
||||
cbuf[stbuf.st_size] = '\0';
|
||||
close(fd); /* filedes no longer needed */
|
||||
*psiz = stbuf.st_size;
|
||||
return cbuf;
|
||||
}
|
||||
|
||||
int
|
||||
writefile(filename, text, size)
|
||||
char *filename, *text;
|
||||
{
|
||||
register fd;
|
||||
|
||||
if ((fd = open(filename, 1)) < 0)
|
||||
return 0;
|
||||
if (write(fd, text, size) != size)
|
||||
return 0;
|
||||
close(fd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct node *
|
||||
make_tree(nl)
|
||||
char *nl;
|
||||
{
|
||||
char *id = nl;
|
||||
struct node *tree = 0;
|
||||
|
||||
while (*nl) {
|
||||
if (*nl == '\n') {
|
||||
*nl = '\0';
|
||||
insert(&tree, id);
|
||||
id = ++nl;
|
||||
}
|
||||
else {
|
||||
++nl;
|
||||
}
|
||||
}
|
||||
return tree;
|
||||
}
|
||||
|
||||
insert(ptree, id)
|
||||
struct node **ptree;
|
||||
char *id;
|
||||
{
|
||||
register cmp;
|
||||
|
||||
if (*ptree == 0) {
|
||||
register struct node *nnode = new_node();
|
||||
|
||||
nnode->name = id;
|
||||
nnode->left = nnode->right = 0;
|
||||
*ptree = nnode;
|
||||
}
|
||||
else
|
||||
if ((cmp = strcmp((*ptree)->name, id)) < 0)
|
||||
insert(&((*ptree)->right), id);
|
||||
else
|
||||
if (cmp > 0)
|
||||
insert(&((*ptree)->left), id);
|
||||
}
|
||||
|
||||
struct node *
|
||||
find(tree, id)
|
||||
struct node *tree;
|
||||
char *id;
|
||||
{
|
||||
register cmp;
|
||||
|
||||
if (tree == 0)
|
||||
return 0;
|
||||
if ((cmp = strcmp(tree->name, id)) < 0)
|
||||
return find(tree->right, id);
|
||||
if (cmp > 0)
|
||||
return find(tree->left, id);
|
||||
return tree;
|
||||
}
|
||||
|
||||
edit(text, tree)
|
||||
char *text;
|
||||
struct node *tree;
|
||||
{
|
||||
register char *ptr = text;
|
||||
char idbuf[IDFSIZE];
|
||||
register char *id;
|
||||
register char *save_ptr;
|
||||
|
||||
while (*ptr) {
|
||||
if (
|
||||
*ptr == '.' &&
|
||||
*++ptr == 'l' &&
|
||||
*++ptr == 'c' &&
|
||||
*++ptr == 'o' &&
|
||||
*++ptr == 'm' &&
|
||||
*++ptr == 'm' &&
|
||||
(*++ptr == ' ' || *ptr == '\t')
|
||||
)
|
||||
{
|
||||
save_ptr = ptr - 6;
|
||||
while (*++ptr == ' ' || *ptr == '\t')
|
||||
;
|
||||
if (*ptr == '_')
|
||||
++ptr;
|
||||
if (InId(*ptr)) {
|
||||
id = &idbuf[0];
|
||||
*id++ = *ptr++;
|
||||
while (InId(*ptr))
|
||||
*id++ = *ptr++;
|
||||
*id = '\0';
|
||||
if (find(tree, idbuf) != 0) {
|
||||
*save_ptr++ = ' ';
|
||||
*save_ptr++ = '.';
|
||||
}
|
||||
}
|
||||
}
|
||||
while (*ptr && *ptr++ != '\n')
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
InId(c)
|
||||
{
|
||||
switch (c) {
|
||||
|
||||
case 'a': case 'b': case 'c': case 'd': case 'e':
|
||||
case 'f': case 'g': case 'h': case 'i': case 'j':
|
||||
case 'k': case 'l': case 'm': case 'n': case 'o':
|
||||
case 'p': case 'q': case 'r': case 's': case 't':
|
||||
case 'u': case 'v': case 'w': case 'x': case 'y':
|
||||
case 'z':
|
||||
case 'A': case 'B': case 'C': case 'D': case 'E':
|
||||
case 'F': case 'G': case 'H': case 'I': case 'J':
|
||||
case 'K': case 'L': case 'M': case 'N': case 'O':
|
||||
case 'P': case 'Q': case 'R': case 'S': case 'T':
|
||||
case 'U': case 'V': case 'W': case 'X': case 'Y':
|
||||
case 'Z':
|
||||
case '_':
|
||||
case '.':
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
return 1;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
puttree(nd)
|
||||
struct node *nd;
|
||||
{
|
||||
if (nd) {
|
||||
puttree(nd->left);
|
||||
printf("%s\n", nd->name);
|
||||
puttree(nd->right);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +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".
|
||||
*/
|
||||
/* Accepted if many characters of long names are significant */
|
||||
/* $Header$ */
|
||||
abcdefghijklmnopr() { }
|
||||
abcdefghijklmnopq() { }
|
||||
main() { }
|
||||
@@ -1,237 +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$ */
|
||||
/* PREPROCESSOR: SCANNER FOR THE ACTUAL PARAMETERS OF MACROS */
|
||||
|
||||
#include "nopp.h"
|
||||
|
||||
#ifndef NOPP
|
||||
/* This file contains the function getactuals() which scans an actual
|
||||
parameter list and splits it up into a list of strings, each one
|
||||
representing an actual parameter.
|
||||
*/
|
||||
|
||||
#include "lapbuf.h" /* UF */
|
||||
#include "nparams.h" /* UF */
|
||||
|
||||
#include "input.h"
|
||||
#include "class.h"
|
||||
#include "idf.h"
|
||||
#include "macro.h"
|
||||
#include "interface.h"
|
||||
#include "file_info.h"
|
||||
|
||||
#define EOS '\0'
|
||||
#define overflow() (fatal("actual parameter buffer overflow"))
|
||||
|
||||
PRIVATE char apbuf[LAPBUF]; /* temporary storage for actual parameters */
|
||||
PRIVATE char *actparams[NPARAMS]; /* pointers to the text of the actuals */
|
||||
PRIVATE char *aptr; /* pointer to last inserted character in apbuf */
|
||||
|
||||
#define copy(ch) ((aptr < &apbuf[LAPBUF]) ? (*aptr++ = ch) : overflow())
|
||||
|
||||
PRIVATE int nr_of_params; /* number of actuals read until now */
|
||||
|
||||
PRIVATE char **
|
||||
getactuals(idef)
|
||||
register struct idf *idef;
|
||||
{
|
||||
/* getactuals() collects the actual parameters and turns them
|
||||
into a list of strings, a pointer to which is returned.
|
||||
*/
|
||||
register acnt = idef->id_macro->mc_nps;
|
||||
|
||||
nr_of_params = 0;
|
||||
actparams[0] = aptr = &apbuf[0];
|
||||
copyact('(', ')', 0); /* read the actual parameters */
|
||||
copy(EOS); /* mark the end of it all */
|
||||
|
||||
if (!nr_of_params++) { /* 0 or 1 parameter */
|
||||
/* there could be a ( <spaces, comment, ...> )
|
||||
*/
|
||||
register char *p = actparams[0];
|
||||
|
||||
while ((class(*p) == STSKIP) || (*p == '\n')) {
|
||||
++p;
|
||||
}
|
||||
|
||||
if (!*p) { /* the case () : 0 parameters */
|
||||
nr_of_params--;
|
||||
}
|
||||
}
|
||||
|
||||
if (nr_of_params != acnt) {
|
||||
/* argument mismatch: too many or too few
|
||||
actual parameters.
|
||||
*/
|
||||
lexwarning("argument mismatch, %s", idef->id_text);
|
||||
|
||||
while (nr_of_params < acnt) {
|
||||
/* too few paraeters: remaining actuals are ""
|
||||
*/
|
||||
actparams[nr_of_params] = "";
|
||||
nr_of_params++;
|
||||
}
|
||||
}
|
||||
|
||||
return actparams;
|
||||
}
|
||||
|
||||
PRIVATE
|
||||
copyact(ch1, ch2, lvl)
|
||||
char ch1, ch2;
|
||||
int lvl;
|
||||
{
|
||||
/* copyact() is taken from Ceriel Jacobs' LLgen, with
|
||||
permission. Its task is to build a list of actuals
|
||||
parameters, which list is surrounded by '(' and ')' and in
|
||||
which the parameters are separated by ',' if there are
|
||||
more than 1. The balancing of '(',')' and '[',']' and
|
||||
'{','}' is taken care of by calling this function
|
||||
recursively. At each level lvl, copyact() reads the input,
|
||||
upto the corresponding closing bracket.
|
||||
|
||||
Opening bracket is ch1, closing bracket is ch2. If
|
||||
lvl != 0, copy opening and closing parameters too.
|
||||
*/
|
||||
register int ch; /* Current char */
|
||||
register int match; /* used to read strings */
|
||||
|
||||
if (lvl) {
|
||||
copy(ch1);
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
LoadChar(ch);
|
||||
|
||||
if (ch == ch2) {
|
||||
if (lvl) {
|
||||
copy(ch);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
switch(ch) {
|
||||
|
||||
#ifdef __MATCHING_PAR__
|
||||
case ')':
|
||||
case '}':
|
||||
case ']':
|
||||
lexerror("unbalanced parenthesis");
|
||||
break;
|
||||
#endif __MATCHING_PAR__
|
||||
|
||||
case '(':
|
||||
copyact('(', ')', lvl+1);
|
||||
break;
|
||||
|
||||
#ifdef __MATCHING_PAR__
|
||||
case '{':
|
||||
/* example:
|
||||
#define declare(v, t) t v
|
||||
declare(v, union{int i, j; float r;});
|
||||
*/
|
||||
copyact('{', '}', lvl+1);
|
||||
break;
|
||||
|
||||
case '[':
|
||||
copyact('[', ']', lvl+1);
|
||||
break;
|
||||
#endif __MATCHING_PAR__
|
||||
|
||||
case '\n':
|
||||
LineNumber++;
|
||||
while (LoadChar(ch), ch == '#') {
|
||||
/* This piece of code needs some
|
||||
explanation: consider the call of
|
||||
the macro defined as:
|
||||
#define sum(b,c) (b + c)
|
||||
in the following form:
|
||||
sum(
|
||||
#include my_phone_number
|
||||
,2)
|
||||
in which case the include must be
|
||||
interpreted as such.
|
||||
*/
|
||||
domacro(); /* has read nl, vt or ff */
|
||||
/* Loop, for another control line */
|
||||
}
|
||||
|
||||
PushBack();
|
||||
copy(' ');
|
||||
break;
|
||||
|
||||
case '/':
|
||||
LoadChar(ch);
|
||||
|
||||
if (ch == '*' && !InputLevel) { /* skip comment */
|
||||
skipcomment();
|
||||
continue;
|
||||
}
|
||||
|
||||
PushBack();
|
||||
copy('/');
|
||||
break;
|
||||
|
||||
case ',':
|
||||
if (!lvl) {
|
||||
/* next parameter encountered */
|
||||
copy(EOS);
|
||||
|
||||
if (++nr_of_params >= NPARAMS) {
|
||||
fatal("too many actual parameters");
|
||||
}
|
||||
|
||||
actparams[nr_of_params] = aptr;
|
||||
}
|
||||
else {
|
||||
copy(ch);
|
||||
}
|
||||
break;
|
||||
|
||||
case '\'':
|
||||
case '"' :
|
||||
/* watch out for brackets in strings, they do
|
||||
not count !
|
||||
*/
|
||||
match = ch;
|
||||
copy(ch);
|
||||
while (LoadChar(ch), ch != EOI) {
|
||||
if (ch == match) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (ch == '\\') {
|
||||
copy(ch);
|
||||
LoadChar(ch);
|
||||
}
|
||||
else
|
||||
if (ch == '\n') {
|
||||
lexerror("newline in string");
|
||||
LineNumber++;
|
||||
copy(match);
|
||||
break;
|
||||
}
|
||||
|
||||
copy(ch);
|
||||
}
|
||||
|
||||
if (ch == match) {
|
||||
copy(ch);
|
||||
break;
|
||||
}
|
||||
/* Fall through */
|
||||
|
||||
case EOI :
|
||||
lexerror("unterminated macro call");
|
||||
return;
|
||||
|
||||
default:
|
||||
copy(ch);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif NOPP
|
||||
@@ -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,146 +0,0 @@
|
||||
!File: lint.h
|
||||
#define LINT 1 /* if defined, 'lint' is produced */
|
||||
|
||||
|
||||
!File: pathlength.h
|
||||
#define PATHLENGTH 1024 /* max. length of path to file */
|
||||
|
||||
|
||||
!File: errout.h
|
||||
#define ERROUT STDERR /* file pointer for writing messages */
|
||||
#define ERR_SHADOW 0 /* a syntax error overshadows error messages
|
||||
until ERR_SHADOW symbols have been
|
||||
accepted without syntax error */
|
||||
|
||||
|
||||
!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: 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
|
||||
#undef DATAFLOW 1 /* produce some compile-time xref */
|
||||
|
||||
|
||||
!File: debug.h
|
||||
#undef DEBUG 1 /* perform various self-tests */
|
||||
|
||||
|
||||
!File: use_tmp.h
|
||||
#undef PREPEND_SCOPES 1 /* collect exa, exp, ina and inp commands
|
||||
and if USE_TMP is defined let them
|
||||
precede the rest of the generated
|
||||
compact code */
|
||||
#undef USE_TMP 1 /* use C_insertpart, C_endpart mechanism
|
||||
to generate EM-code in the order needed
|
||||
for the code-generators. If not defined,
|
||||
the old-style peephole optimizer is
|
||||
needed. */
|
||||
|
||||
|
||||
!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
|
||||
#define 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 */
|
||||
|
||||
|
||||
!File: regcount.h
|
||||
#undef REGCOUNT 1 /* count occurrences for register messages */
|
||||
|
||||
|
||||
@@ -1,139 +0,0 @@
|
||||
!File: lint.h
|
||||
#undef LINT 1 /* if defined, 'lint' is produced */
|
||||
|
||||
|
||||
!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: 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
|
||||
#define 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 */
|
||||
|
||||
|
||||
!File: regcount.h
|
||||
#undef REGCOUNT 1 /* count occurrences for register messages */
|
||||
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
: create a directory Xsrc with name clashes resolved
|
||||
: and run make in that directory
|
||||
: '$Header$'
|
||||
|
||||
case $# in
|
||||
1)
|
||||
;;
|
||||
*) echo "$0: one argument expected" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
PW=`pwd`
|
||||
options=
|
||||
case $1 in
|
||||
main|emain|lnt)
|
||||
target=$PW/$1
|
||||
;;
|
||||
omain)
|
||||
target=$PW/$1
|
||||
options=-DPEEPHOLE
|
||||
;;
|
||||
cemain)
|
||||
target=$PW/$1
|
||||
options=-DCODE_EXPANDER
|
||||
;;
|
||||
Xlint)
|
||||
target=$1
|
||||
;;
|
||||
*) echo "$0: $1: Illegal argument" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
if test -d ../Xsrc
|
||||
then
|
||||
:
|
||||
else mkdir ../Xsrc
|
||||
fi
|
||||
make EMHOME=$EMHOME longnames
|
||||
: remove code generating routines from the clashes list as they are defines.
|
||||
: code generating routine names start with C_
|
||||
sed '/^C_/d' < longnames > tmp$$
|
||||
cclash -c -l7 tmp$$ > ../Xsrc/Xclashes
|
||||
rm -f tmp$$
|
||||
cd ../Xsrc
|
||||
if cmp -s Xclashes clashes
|
||||
then
|
||||
:
|
||||
else
|
||||
mv Xclashes clashes
|
||||
fi
|
||||
rm -f Makefile
|
||||
for i in `cat $PW/Cfiles`
|
||||
do
|
||||
cat >> Makefile <<EOF
|
||||
|
||||
$i: clashes $PW/$i
|
||||
cid -Fclashes < $PW/$i > $i
|
||||
EOF
|
||||
done
|
||||
make EMHOME=$EMHOME `cat $PW/Cfiles`
|
||||
rm -f Makefile
|
||||
ed - $PW/Makefile <<'EOF'
|
||||
/^#EXCLEXCL/,/^#INCLINCL/d
|
||||
w Makefile
|
||||
q
|
||||
EOF
|
||||
make EMHOME=$EMHOME COPTIONS=$options MACH=$mach CURRDIR=$PW/ $target
|
||||
@@ -1,8 +0,0 @@
|
||||
/* $Header$ */
|
||||
/*
|
||||
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||
*/
|
||||
#ifndef lint
|
||||
static char Version[] = "ACK CEM compiler Version 3.2";
|
||||
#endif lint
|
||||
@@ -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,71 +0,0 @@
|
||||
/*
|
||||
* (c) copyright 1990 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||
*/
|
||||
/* $Header$ */
|
||||
|
||||
/*
|
||||
* This file can be considered the em_code.h file of lint.
|
||||
* Those code generating functions that are used by cem and that have not
|
||||
* been defined away by #ifdef LINT, are defined away here. Note that this a
|
||||
* fairly random collection. E.g. it does not include C_open(), since the
|
||||
* standard C-open() C_close() sequence is protected by #ifdef LINT, but it
|
||||
* does include C_close() since the latter is also called in other places,
|
||||
* to terminate the compilation process.
|
||||
*/
|
||||
|
||||
#define C_asp(c)
|
||||
#define C_bra(b)
|
||||
#define C_cal(p)
|
||||
#define C_csa(w)
|
||||
#define C_csb(w)
|
||||
#define C_fil_dlb(g,o)
|
||||
#define C_lae_dlb(g,o)
|
||||
#define C_lal(c)
|
||||
#define C_lin(c)
|
||||
#define C_loi(c)
|
||||
#define C_lol(c)
|
||||
#define C_sdl(c)
|
||||
#define C_sti(c)
|
||||
#define C_stl(c)
|
||||
|
||||
#define C_busy() 0
|
||||
#define C_close()
|
||||
|
||||
#define C_df_dlb(l)
|
||||
#define C_df_dnam(s)
|
||||
#define C_df_ilb(l)
|
||||
|
||||
#define C_pro_narg(s)
|
||||
#define C_end(l)
|
||||
|
||||
#define C_exa_dnam(s)
|
||||
#define C_ina_dnam(s)
|
||||
#define C_ina_dlb(l)
|
||||
#define C_exp(s)
|
||||
#define C_inp(s)
|
||||
|
||||
#define C_bss_cst(n,w,i)
|
||||
|
||||
#define C_con_cst(v)
|
||||
#define C_con_icon(v,s)
|
||||
#define C_con_ucon(v,s)
|
||||
#define C_con_fcon(v,s)
|
||||
#define C_con_scon(v,s)
|
||||
#define C_con_dnam(v,s)
|
||||
#define C_con_dlb(v,s)
|
||||
#define C_con_pnam(v)
|
||||
|
||||
#define C_rom_cst(v)
|
||||
#define C_rom_scon(v,s)
|
||||
#define C_rom_ilb(v)
|
||||
|
||||
#define C_ldl(l)
|
||||
|
||||
#define C_mes_begin(ms)
|
||||
#define C_mes_end()
|
||||
|
||||
#define C_ms_gto()
|
||||
#define C_ms_par(b)
|
||||
#define C_ms_reg(o,s,t,c)
|
||||
|
||||
@@ -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,9 +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$ */
|
||||
/* FAULTY DEFINITIONS */
|
||||
|
||||
#define faulty(tp) ((tp)_faulty(__FILE__, __LINE__))
|
||||
#define fault() (_faulty(__FILE__, __LINE__))
|
||||
@@ -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,70 +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$ */
|
||||
|
||||
/*
|
||||
*The following functions are hacked to null-functions (i.e. they
|
||||
* do nothing). This needs another solution in the future. !!???!!
|
||||
*/
|
||||
#include "lint.h"
|
||||
|
||||
#ifdef LINT
|
||||
|
||||
#include "arith.h"
|
||||
#include "label.h"
|
||||
|
||||
C_close(){}
|
||||
int C_busy(){return 0;}
|
||||
|
||||
|
||||
/* More routines */
|
||||
/* ARGSUSED */
|
||||
CC_bhcst(ps_xxx,n,w,i) arith n,w; {}
|
||||
/* ARGSUSED */
|
||||
CC_crcst(ps_xxx,v) arith v; {}
|
||||
/* ARGSUSED */
|
||||
CC_crdlb(ps_xxx,v,s) label v; arith s; {}
|
||||
/* ARGSUSED */
|
||||
CC_crdnam(ps_xxx,v,s) char *v; arith s; {}
|
||||
/* ARGSUSED */
|
||||
CC_crxcon(op,ps_xxx,v,s) char *v; arith s; {}
|
||||
/* ARGSUSED */
|
||||
CC_crilb(ps_xxx,v) label v; {}
|
||||
/* ARGSUSED */
|
||||
CC_crpnam(ps_xxx,v) char *v; {}
|
||||
/* ARGSUSED */
|
||||
CC_crscon(ps_xxx,v,s) char *v; arith s; {}
|
||||
/* ARGSUSED */
|
||||
CC_cst(l) {}
|
||||
/* ARGSUSED */
|
||||
CC_dfdlb(l) label l; {}
|
||||
/* ARGSUSED */
|
||||
CC_dfdnam(s) char *s; {}
|
||||
/* ARGSUSED */
|
||||
CC_dfilb(l) label l; {}
|
||||
/* ARGSUSED */
|
||||
CC_end(l) arith l; {}
|
||||
CC_msend() {}
|
||||
/* ARGSUSED */
|
||||
CC_msstart(ms) {}
|
||||
/* ARGSUSED */
|
||||
CC_opcst(op_xxx,c) arith c; {}
|
||||
/* ARGSUSED */
|
||||
CC_opdlb(op_xxx,g,o) label g; arith o; {}
|
||||
/* ARGSUSED */
|
||||
CC_opilb(op_xxx,b) label b; {}
|
||||
/* ARGSUSED */
|
||||
CC_oppnam(op_xxx,p) char *p; {}
|
||||
/* ARGSUSED */
|
||||
CC_pronarg(s) char *s; {}
|
||||
/* ARGSUSED */
|
||||
CC_psdlb(ps_xxx,l) label l; {}
|
||||
/* ARGSUSED */
|
||||
CC_psdnam(ps_xxx,s) char *s; {}
|
||||
/* ARGSUSED */
|
||||
CC_pspnam(ps_xxx,s) char *s; {}
|
||||
/* ARGSUSED */
|
||||
CC_scon(v,s) char *s; {}
|
||||
#endif LINT
|
||||
@@ -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,9 +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".
|
||||
*/
|
||||
/* Accepted if many characters of long names are significant */
|
||||
/* $Header$ */
|
||||
abcdefghijklmnopr() { }
|
||||
abcdefghijklmnopq() { }
|
||||
main() { }
|
||||
@@ -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,300 +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$ */
|
||||
/* @cc tab.c -o $INSTALLDIR/tab@
|
||||
tab - table generator
|
||||
|
||||
Author: Erik Baalbergen (..tjalk!erikb)
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define MAXTAB 10000
|
||||
#define MAXBUF 10000
|
||||
#define COMCOM '-'
|
||||
#define FILECOM '%'
|
||||
|
||||
int InputForm = 'c';
|
||||
char OutputForm[MAXBUF] = "%s,\n";
|
||||
int TabSize = 257;
|
||||
char *Table[MAXTAB];
|
||||
char *ProgCall;
|
||||
|
||||
main(argc, argv)
|
||||
char *argv[];
|
||||
{
|
||||
ProgCall = *argv++;
|
||||
argc--;
|
||||
while (argc-- > 0) {
|
||||
if (**argv == COMCOM) {
|
||||
option(*argv++);
|
||||
}
|
||||
else {
|
||||
process(*argv++, InputForm);
|
||||
}
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
char *
|
||||
Salloc(s)
|
||||
char *s;
|
||||
{
|
||||
extern char *malloc(), *strcpy();
|
||||
char *ns = malloc((unsigned int)strlen(s) + 1);
|
||||
|
||||
if (ns) {
|
||||
strcpy(ns, s);
|
||||
}
|
||||
return ns;
|
||||
}
|
||||
|
||||
option(str)
|
||||
char *str;
|
||||
{
|
||||
/* note that *str indicates the source of the option:
|
||||
either COMCOM (from command line) or FILECOM (from a file).
|
||||
*/
|
||||
extern char *sprintf();
|
||||
|
||||
switch (*++str) {
|
||||
|
||||
case ' ': /* command */
|
||||
case '\t':
|
||||
case '\0':
|
||||
break;
|
||||
case 'I':
|
||||
InputForm = *++str;
|
||||
break;
|
||||
case 'f':
|
||||
if (*++str == '\0') {
|
||||
fprintf(stderr, "%s: -f: name expected\n", ProgCall);
|
||||
exit(1);
|
||||
}
|
||||
DoFile(str);
|
||||
break;
|
||||
case 'F':
|
||||
sprintf(OutputForm, "%s\n", ++str);
|
||||
break;
|
||||
case 'T':
|
||||
printf("%s\n", ++str);
|
||||
break;
|
||||
case 'p':
|
||||
PrintTable();
|
||||
break;
|
||||
case 'C':
|
||||
ClearTable();
|
||||
break;
|
||||
case 'S':
|
||||
{
|
||||
register i = stoi(++str);
|
||||
|
||||
if (i <= 0 || i > MAXTAB) {
|
||||
fprintf(stderr, "%s: size would exceed maximum\n",
|
||||
ProgCall);
|
||||
}
|
||||
else {
|
||||
TabSize = i;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
fprintf(stderr, "%s: bad option -%s\n", ProgCall, str);
|
||||
}
|
||||
}
|
||||
|
||||
ClearTable()
|
||||
{
|
||||
register i;
|
||||
|
||||
for (i = 0; i < MAXTAB; i++) {
|
||||
Table[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
PrintTable()
|
||||
{
|
||||
register i;
|
||||
|
||||
for (i = 0; i < TabSize; i++) {
|
||||
if (Table[i]) {
|
||||
printf(OutputForm, Table[i]);
|
||||
}
|
||||
else {
|
||||
printf(OutputForm, "0");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
process(str, format)
|
||||
char *str;
|
||||
{
|
||||
char *cstr = str;
|
||||
char *Name = cstr; /* overwrite original string! */
|
||||
|
||||
/* strip of the entry name
|
||||
*/
|
||||
while (*str && *str != ':') {
|
||||
if (*str == '\\') {
|
||||
++str;
|
||||
}
|
||||
*cstr++ = *str++;
|
||||
}
|
||||
|
||||
if (*str != ':') {
|
||||
fprintf(stderr, "%s: bad specification: \"%s\", ignored\n",
|
||||
ProgCall, Name);
|
||||
return 0;
|
||||
}
|
||||
*cstr = '\0';
|
||||
str++;
|
||||
|
||||
switch (format) {
|
||||
|
||||
case 'c':
|
||||
return c_proc(str, Name);
|
||||
default:
|
||||
fprintf(stderr, "%s: bad input format\n", ProgCall);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
c_proc(str, Name)
|
||||
char *str;
|
||||
char *Name;
|
||||
{
|
||||
int ch, ch2;
|
||||
int quoted();
|
||||
|
||||
while (*str) {
|
||||
if (*str == '\\') {
|
||||
ch = quoted(&str);
|
||||
}
|
||||
else {
|
||||
ch = *str++;
|
||||
}
|
||||
if (*str == '-') {
|
||||
if (*++str == '\\') {
|
||||
ch2 = quoted(&str);
|
||||
}
|
||||
else {
|
||||
if (ch2 = *str++);
|
||||
else str--;
|
||||
}
|
||||
if (ch > ch2) {
|
||||
fprintf(stderr, "%s: bad range\n", ProgCall);
|
||||
return 0;
|
||||
}
|
||||
if (ch >= 0 && ch2 <= 255)
|
||||
while (ch <= ch2)
|
||||
Table[ch++] = Salloc(Name);
|
||||
}
|
||||
else {
|
||||
if (ch >= 0 && ch <= 255)
|
||||
Table[ch] = Salloc(Name);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
quoted(pstr)
|
||||
char **pstr;
|
||||
{
|
||||
register int ch;
|
||||
register int i;
|
||||
register char *str = *pstr;
|
||||
|
||||
if ((*++str >= '0') && (*str <= '9')) {
|
||||
ch = 0;
|
||||
for (i = 0; i < 3; i++) {
|
||||
ch = 8 * ch + *str - '0';
|
||||
if (*++str < '0' || *str > '9')
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch (*str++) {
|
||||
|
||||
case 'n':
|
||||
ch = '\n';
|
||||
break;
|
||||
case 't':
|
||||
ch = '\t';
|
||||
break;
|
||||
case 'b':
|
||||
ch = '\b';
|
||||
break;
|
||||
case 'r':
|
||||
ch = '\r';
|
||||
break;
|
||||
case 'f':
|
||||
ch = '\f';
|
||||
break;
|
||||
default :
|
||||
ch = *str;
|
||||
}
|
||||
}
|
||||
*pstr = str;
|
||||
return ch & 0377;
|
||||
}
|
||||
|
||||
int
|
||||
stoi(str)
|
||||
char *str;
|
||||
{
|
||||
register i = 0;
|
||||
|
||||
while (*str >= '0' && *str <= '9') {
|
||||
i = i * 10 + *str++ - '0';
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
char *
|
||||
getline(s, n, fp)
|
||||
char *s;
|
||||
FILE *fp;
|
||||
{
|
||||
register c = getc(fp);
|
||||
char *str = s;
|
||||
|
||||
while (n--) {
|
||||
if (c == EOF) {
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
if (c == '\n') {
|
||||
*str++ = '\0';
|
||||
return s;
|
||||
}
|
||||
*str++ = c;
|
||||
c = getc(fp);
|
||||
}
|
||||
s[n - 1] = '\0';
|
||||
return s;
|
||||
}
|
||||
|
||||
#define BUFSIZE 1024
|
||||
|
||||
DoFile(name)
|
||||
char *name;
|
||||
{
|
||||
char text[BUFSIZE];
|
||||
FILE *fp;
|
||||
|
||||
if ((fp = fopen(name, "r")) == NULL) {
|
||||
fprintf(stderr, "%s: cannot read file %s\n", ProgCall, name);
|
||||
exit(1);
|
||||
}
|
||||
while (getline(text, BUFSIZE, fp) != NULL) {
|
||||
if (text[0] == FILECOM) {
|
||||
option(text);
|
||||
}
|
||||
else {
|
||||
process(text, InputForm);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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))
|
||||
|
||||
@@ -1,266 +0,0 @@
|
||||
# MAKEFILE FOR (STAND_ALONE) CEM PREPROCESSOR
|
||||
|
||||
EMHOME=../../..
|
||||
MODULES=$(EMHOME)/modules
|
||||
MODULESLIB=$(MODULES)/lib
|
||||
BIN=$(EMHOME)/lib
|
||||
MANDIR=$(EMHOME)/man
|
||||
|
||||
# Some paths
|
||||
|
||||
# Libraries
|
||||
SYSLIB = $(MODULESLIB)/libsystem.a
|
||||
STRLIB = $(MODULESLIB)/libstring.a
|
||||
PRTLIB = $(MODULESLIB)/libprint.a
|
||||
ALLOCLIB = $(MODULESLIB)/liballoc.a
|
||||
ASSERTLIB = $(MODULESLIB)/libassert.a
|
||||
MALLOC = $(MODULESLIB)/malloc.o
|
||||
LIBS = $(PRTLIB) $(STRLIB) $(ALLOCLIB) $(MALLOC) $(ASSERTLIB) $(SYSLIB)
|
||||
LIB_INCLUDES = -I$(MODULES)/h -I$(MODULES)/pkg
|
||||
|
||||
# Where to install the preprocessor
|
||||
CEMPP = $(BIN)/cpp.ansi
|
||||
|
||||
TABGEN = $(EMHOME)/bin/tabgen
|
||||
|
||||
# What C compiler to use and how
|
||||
CC = cc
|
||||
COPTIONS = -O
|
||||
LDFLAGS =
|
||||
|
||||
# What parser generator to use and how
|
||||
GEN = $(EMHOME)/bin/LLgen
|
||||
GENOPTIONS =
|
||||
|
||||
# Special #defines during compilation
|
||||
CDEFS = $(LIB_INCLUDES)
|
||||
CFLAGS = $(CDEFS) $(COPTIONS)# # we cannot pass the COPTIONS to lint!
|
||||
|
||||
# Grammar files and their objects
|
||||
LSRC = tokenfile.g expression.g
|
||||
LCSRC = tokenfile.c expression.c Lpars.c
|
||||
LOBJ = tokenfile.o expression.o Lpars.o
|
||||
|
||||
# Objects of hand-written C files
|
||||
CSRC = LLlex.c LLmessage.c ch3bin.c ch3mon.c domacro.c \
|
||||
error.c idf.c init.c input.c main.c options.c \
|
||||
preprocess.c replace.c skip.c tokenname.c expr.c
|
||||
COBJ = LLlex.o LLmessage.o ch3bin.o ch3mon.o domacro.o \
|
||||
error.o idf.o init.o input.o main.o options.o \
|
||||
preprocess.o replace.o skip.o tokenname.o next.o expr.o
|
||||
|
||||
PRFILES = Makefile Parameters \
|
||||
make.hfiles make.tokcase make.tokfile LLlex.h bits.h file_info.h \
|
||||
idf.h input.h interface.h macro.str replace.str \
|
||||
class.h char.tab expression.g $(CSRC)
|
||||
|
||||
# Objects of other generated C files
|
||||
GOBJ = char.o symbol2str.o
|
||||
|
||||
# generated source files
|
||||
GSRC = char.c symbol2str.c next.c
|
||||
|
||||
# .h files generated by `make.allod'
|
||||
STRSRC = macro.str replace.str
|
||||
GSTRSRC = macro.h replace.h
|
||||
|
||||
# .h files generated by `make hfiles'; PLEASE KEEP THIS UP-TO-DATE!
|
||||
GHSRC = errout.h idfsize.h ifdepth.h macbuf.h \
|
||||
nparams.h numsize.h obufsize.h \
|
||||
parbufsize.h pathlength.h strsize.h textsize.h \
|
||||
botch_free.h debug.h inputtype.h dobits.h ln_prefix.h
|
||||
|
||||
# Other generated files, for 'make clean' only
|
||||
GENERATED = tokenfile.g Lpars.h LLfiles LL.output lint.out \
|
||||
Xref hfiles cfiles tags Makefile.old
|
||||
|
||||
all: cc
|
||||
|
||||
cc: cfiles
|
||||
make "EMHOME="$(EMHOME) "CC=$(CC)" ncpp
|
||||
|
||||
hfiles: Parameters char.c
|
||||
./make.hfiles Parameters
|
||||
@touch hfiles
|
||||
|
||||
.SUFFIXES: .str .h
|
||||
.str.h:
|
||||
./make.allocd <$*.str >$*.h
|
||||
|
||||
char.c: char.tab
|
||||
$(TABGEN) -fchar.tab > char.c
|
||||
|
||||
next.c: make.next $(STRSRC)
|
||||
./make.next $(STRSRC) >next.c
|
||||
|
||||
macro.h: make.allocd
|
||||
replace.h: make.allocd
|
||||
|
||||
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
|
||||
|
||||
# Objects needed for 'ncpp'
|
||||
OBJ = $(COBJ) $(LOBJ) $(GOBJ)
|
||||
SRC = $(CSRC) $(LCSRC) $(GSRC)
|
||||
|
||||
ncpp: $(OBJ) Makefile
|
||||
$(CC) $(COPTIONS) $(LDFLAGS) $(OBJ) $(LIBS) -o ncpp
|
||||
-size ncpp
|
||||
|
||||
cfiles: hfiles LLfiles $(GSRC) $(GSTRSRC)
|
||||
@touch cfiles
|
||||
|
||||
install: all
|
||||
rm -f $(CEMPP)
|
||||
cp ncpp $(CEMPP)
|
||||
rm -f $(MANDIR)/cpp.ansi.6
|
||||
cp ncpp.6 $(MANDIR)/cpp.ansi.6
|
||||
|
||||
cmp: all
|
||||
-cmp ncpp $(CEMPP)
|
||||
-cmp ncpp.6 $(MANDIR)/cpp.ansi.6
|
||||
|
||||
pr:
|
||||
@pr $(PRFILES)
|
||||
|
||||
opr:
|
||||
make pr | opr
|
||||
|
||||
tags: cfiles
|
||||
ctags $(SRC)
|
||||
|
||||
depend: cfiles
|
||||
sed '/^#AUTOAUTO/,$$d' Makefile >Makefile.new
|
||||
echo '#AUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTO' >>Makefile.new
|
||||
$(EMHOME)/bin/mkdep $(SRC) | \
|
||||
sed 's/\.c:/.o:/' >>Makefile.new
|
||||
mv Makefile Makefile.old
|
||||
mv Makefile.new Makefile
|
||||
|
||||
xref:
|
||||
ctags -x `grep "\.[ch]" Files`|sed "s/).*/)/">Xref
|
||||
|
||||
lint: cfiles
|
||||
lint -bx $(CDEFS) $(SRC) >lint.out
|
||||
|
||||
clean:
|
||||
rm -f $(LCSRC) $(OBJ) $(GENERATED) $(GSRC) $(GHSRC) $(GSTRSRC) ncpp Out
|
||||
|
||||
#AUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTO
|
||||
LLlex.o: LLlex.h
|
||||
LLlex.o: Lpars.h
|
||||
LLlex.o: arith.h
|
||||
LLlex.o: bits.h
|
||||
LLlex.o: class.h
|
||||
LLlex.o: dobits.h
|
||||
LLlex.o: file_info.h
|
||||
LLlex.o: idf.h
|
||||
LLlex.o: idfsize.h
|
||||
LLlex.o: input.h
|
||||
LLlex.o: inputtype.h
|
||||
LLlex.o: macro.h
|
||||
LLlex.o: numsize.h
|
||||
LLlex.o: strsize.h
|
||||
LLmessage.o: LLlex.h
|
||||
LLmessage.o: Lpars.h
|
||||
LLmessage.o: arith.h
|
||||
LLmessage.o: file_info.h
|
||||
ch3bin.o: Lpars.h
|
||||
ch3bin.o: arith.h
|
||||
ch3mon.o: Lpars.h
|
||||
ch3mon.o: arith.h
|
||||
domacro.o: LLlex.h
|
||||
domacro.o: Lpars.h
|
||||
domacro.o: arith.h
|
||||
domacro.o: bits.h
|
||||
domacro.o: botch_free.h
|
||||
domacro.o: class.h
|
||||
domacro.o: dobits.h
|
||||
domacro.o: file_info.h
|
||||
domacro.o: idf.h
|
||||
domacro.o: idfsize.h
|
||||
domacro.o: ifdepth.h
|
||||
domacro.o: input.h
|
||||
domacro.o: inputtype.h
|
||||
domacro.o: macbuf.h
|
||||
domacro.o: macro.h
|
||||
domacro.o: nparams.h
|
||||
domacro.o: parbufsize.h
|
||||
domacro.o: replace.h
|
||||
domacro.o: textsize.h
|
||||
error.o: LLlex.h
|
||||
error.o: arith.h
|
||||
error.o: errout.h
|
||||
error.o: file_info.h
|
||||
idf.o: idf.h
|
||||
init.o: class.h
|
||||
init.o: idf.h
|
||||
init.o: macro.h
|
||||
input.o: file_info.h
|
||||
input.o: input.h
|
||||
input.o: inputtype.h
|
||||
main.o: arith.h
|
||||
main.o: file_info.h
|
||||
main.o: idf.h
|
||||
main.o: idfsize.h
|
||||
main.o: macro.h
|
||||
options.o: class.h
|
||||
options.o: idf.h
|
||||
options.o: idfsize.h
|
||||
options.o: macro.h
|
||||
preprocess.o: LLlex.h
|
||||
preprocess.o: arith.h
|
||||
preprocess.o: bits.h
|
||||
preprocess.o: class.h
|
||||
preprocess.o: dobits.h
|
||||
preprocess.o: file_info.h
|
||||
preprocess.o: idf.h
|
||||
preprocess.o: idfsize.h
|
||||
preprocess.o: input.h
|
||||
preprocess.o: inputtype.h
|
||||
preprocess.o: ln_prefix.h
|
||||
preprocess.o: macro.h
|
||||
preprocess.o: obufsize.h
|
||||
preprocess.o: textsize.h
|
||||
replace.o: LLlex.h
|
||||
replace.o: arith.h
|
||||
replace.o: class.h
|
||||
replace.o: file_info.h
|
||||
replace.o: idf.h
|
||||
replace.o: idfsize.h
|
||||
replace.o: input.h
|
||||
replace.o: inputtype.h
|
||||
replace.o: macbuf.h
|
||||
replace.o: macro.h
|
||||
replace.o: nparams.h
|
||||
replace.o: numsize.h
|
||||
replace.o: pathlength.h
|
||||
replace.o: replace.h
|
||||
replace.o: strsize.h
|
||||
skip.o: LLlex.h
|
||||
skip.o: arith.h
|
||||
skip.o: class.h
|
||||
skip.o: file_info.h
|
||||
skip.o: input.h
|
||||
skip.o: inputtype.h
|
||||
tokenname.o: LLlex.h
|
||||
tokenname.o: Lpars.h
|
||||
tokenname.o: arith.h
|
||||
tokenname.o: file_info.h
|
||||
tokenname.o: idf.h
|
||||
expr.o: Lpars.h
|
||||
tokenfile.o: Lpars.h
|
||||
expression.o: LLlex.h
|
||||
expression.o: Lpars.h
|
||||
expression.o: arith.h
|
||||
expression.o: file_info.h
|
||||
Lpars.o: Lpars.h
|
||||
char.o: class.h
|
||||
symbol2str.o: Lpars.h
|
||||
@@ -1,74 +0,0 @@
|
||||
.TH NCPP 6ACK
|
||||
.ad
|
||||
.SH NAME
|
||||
ncpp \- New C Pre-Processor
|
||||
.SH SYNOPSIS
|
||||
ncpp [\-options] [ file ]
|
||||
.SH DESCRIPTION
|
||||
.I Ncpp
|
||||
reads a file, expands macros and include
|
||||
files, and writes an input file for the C compiler.
|
||||
All output is to standard output.
|
||||
.br
|
||||
The following options are supported.
|
||||
.IP -\fBI\fIdirectory\fR
|
||||
.br
|
||||
add this directory to the list of
|
||||
directories searched for #include "..." and #include <...>
|
||||
commands. Note that there is no space between the
|
||||
"-I" and the directory string. More than one -I command
|
||||
is permitted.
|
||||
.IP -\fBI\fR
|
||||
end the list of directories to be searched, and also do not look in
|
||||
default places.
|
||||
.IP -\fBD\fIname\fR=\fItext\fR
|
||||
.br
|
||||
define
|
||||
.I name
|
||||
as a macro with
|
||||
.I text
|
||||
as its replacement text.
|
||||
.IP -\fBD\fIname\fR
|
||||
the same as -\fBD\fIname\fR=1.
|
||||
.IP
|
||||
.IP -\fBU\fIname\fR
|
||||
.br
|
||||
undefine the macro name
|
||||
.IR name .
|
||||
.IP -\fBC\fR
|
||||
leave comments in. By default, C-comments are deleted.
|
||||
.IP -\fBP\fR
|
||||
do not generate line directives
|
||||
.IP -\fBM\fIn\fR
|
||||
set maximum identifier length to
|
||||
.IR n .
|
||||
.PP
|
||||
The following names are always available unless undefined:
|
||||
.RS
|
||||
.IP __STDC__
|
||||
A decimal constant 1, indicating that this is an ANSI C conforming
|
||||
implementation.
|
||||
.IP __FILE__
|
||||
The input (or #include) file being compiled
|
||||
(as a quoted string).
|
||||
.IP __LINE__
|
||||
The line number being compiled.
|
||||
.IP __DATE__
|
||||
The date of translation of the source file. This is a string
|
||||
literal of the form "\fBMmm dd yyyy\fP".
|
||||
.IP __TIME__
|
||||
The time of translation of the source file. This is a string
|
||||
literal of the form "\fBhh:mm:ss\fP".
|
||||
.RE
|
||||
.SH BUGS
|
||||
The output may contain extra spaces, this prevents unintended
|
||||
pasting of tokens.
|
||||
.SH "SEE ALSO"
|
||||
L. Rosler,
|
||||
.I
|
||||
Draft Proposed Standard - Programming Language C,
|
||||
.R
|
||||
ANSI X3J11 Language Subcommittee
|
||||
.SH AUTHOR
|
||||
Leendert van Doorn
|
||||
|
||||
@@ -1,152 +0,0 @@
|
||||
w1
|
||||
st2.w1_i 506
|
||||
(*st3).w1_i 506
|
||||
st1.w1_i 711
|
||||
st2.w1_i 711
|
||||
es2[2].w1_i 711
|
||||
st2.w1_i 577
|
||||
st2.w1_i -577
|
||||
st1.w1_i 577
|
||||
w2
|
||||
s2t2: .w2_i 18000 .w2_d 3.141500
|
||||
s2t3->w2_d 3.141500
|
||||
w3
|
||||
s3t2.w3_a[ 0] a
|
||||
s3t2.w3_a[ 1] b
|
||||
s3t2.w3_a[ 2] c
|
||||
s3t2.w3_a[ 3] d
|
||||
s3t2.w3_a[ 4] e
|
||||
s3t2.w3_a[ 5] f
|
||||
s3t2.w3_a[ 6] g
|
||||
s3t2.w3_a[ 7] h
|
||||
s3t2.w3_a[ 8] i
|
||||
s3t2.w3_a[ 9] j
|
||||
s3t2.w3_a[10] k
|
||||
s3t2.w3_a[11] l
|
||||
s3t2.w3_a[12] m
|
||||
s3t2.w3_a[13] n
|
||||
s3t2.w3_a[14] o
|
||||
s3t2.w3_a[15] p
|
||||
s3t2.w3_a[16] q
|
||||
s3t2.w3_a[17] r
|
||||
s3t2.w3_a[18] s
|
||||
s3t2.w3_a[19] t
|
||||
s3t2.w3_a[20] u
|
||||
s3t2.w3_a[21] v
|
||||
s3t2.w3_a[22] w
|
||||
s3t2.w3_a[23] x
|
||||
s3t2.w3_a[24] y
|
||||
s3t2.w3_a[25] z
|
||||
s3t2.w3_x 1.000000
|
||||
s3t1.w3_a[ 0] A
|
||||
s3t1.w3_a[ 1] B
|
||||
s3t1.w3_a[ 2] C
|
||||
s3t1.w3_a[ 3] D
|
||||
s3t1.w3_a[ 4] E
|
||||
s3t1.w3_a[ 5] F
|
||||
s3t1.w3_a[ 6] G
|
||||
s3t1.w3_a[ 7] H
|
||||
s3t1.w3_a[ 8] I
|
||||
s3t1.w3_a[ 9] J
|
||||
s3t1.w3_a[10] K
|
||||
s3t1.w3_a[11] L
|
||||
s3t1.w3_a[12] M
|
||||
s3t1.w3_a[13] N
|
||||
s3t1.w3_a[14] O
|
||||
s3t1.w3_a[15] P
|
||||
s3t1.w3_a[16] Q
|
||||
s3t1.w3_a[17] R
|
||||
s3t1.w3_a[18] S
|
||||
s3t1.w3_a[19] T
|
||||
s3t1.w3_a[20] U
|
||||
s3t1.w3_a[21] V
|
||||
s3t1.w3_a[22] W
|
||||
s3t1.w3_a[23] X
|
||||
s3t1.w3_a[24] Y
|
||||
s3t1.w3_a[25] Z
|
||||
s3t1.w3_x 0.318319
|
||||
structure parameters
|
||||
before -1
|
||||
str.w3_a[ 0] 1
|
||||
str.w3_a[ 1] 2
|
||||
str.w3_a[ 2] 3
|
||||
str.w3_a[ 3] 4
|
||||
str.w3_a[ 4] 5
|
||||
str.w3_a[ 5] 6
|
||||
str.w3_a[ 6] 7
|
||||
str.w3_a[ 7] 8
|
||||
str.w3_a[ 8] 9
|
||||
str.w3_a[ 9] 10
|
||||
str.w3_a[10] 11
|
||||
str.w3_a[11] 12
|
||||
str.w3_a[12] 13
|
||||
str.w3_a[13] 14
|
||||
str.w3_a[14] 15
|
||||
str.w3_a[15] 16
|
||||
str.w3_a[16] 17
|
||||
str.w3_a[17] 18
|
||||
str.w3_a[18] 19
|
||||
str.w3_a[19] 20
|
||||
str.w3_a[20] 21
|
||||
str.w3_a[21] 22
|
||||
str.w3_a[22] 23
|
||||
str.w3_a[23] 24
|
||||
str.w3_a[24] 25
|
||||
str.w3_a[25] 26
|
||||
str.w3_x 2.810000
|
||||
after 1000
|
||||
|
||||
Stucture valued functions
|
||||
myp.w3_a:
|
||||
0 97
|
||||
1 96
|
||||
2 95
|
||||
3 94
|
||||
4 93
|
||||
5 92
|
||||
6 91
|
||||
7 90
|
||||
8 89
|
||||
9 88
|
||||
10 87
|
||||
11 86
|
||||
12 85
|
||||
13 84
|
||||
14 83
|
||||
15 82
|
||||
16 81
|
||||
17 80
|
||||
18 79
|
||||
19 78
|
||||
20 77
|
||||
21 76
|
||||
22 75
|
||||
23 74
|
||||
24 73
|
||||
25 72
|
||||
0 99
|
||||
1 100
|
||||
2 101
|
||||
3 102
|
||||
4 103
|
||||
5 104
|
||||
6 105
|
||||
7 106
|
||||
8 107
|
||||
9 108
|
||||
10 109
|
||||
11 110
|
||||
12 111
|
||||
13 112
|
||||
14 113
|
||||
15 114
|
||||
16 115
|
||||
17 116
|
||||
18 117
|
||||
19 118
|
||||
20 119
|
||||
21 120
|
||||
22 121
|
||||
23 122
|
||||
24 123
|
||||
25 124
|
||||
@@ -1,53 +0,0 @@
|
||||
.SILENT:
|
||||
CEM=acc
|
||||
head:
|
||||
echo use run
|
||||
|
||||
diffs: $P.cc.r $P.cem.r
|
||||
echo two compiler diff
|
||||
-diff $P.*.r
|
||||
|
||||
diffs3: $P.pcc.r $P.cc.r $P.cem.r
|
||||
echo three compiler diff
|
||||
-diff3 $P.*.r | tee diffs
|
||||
egen: $P.e
|
||||
echo comparing $P.e
|
||||
-if test -f $P.e.g ; then diff -h $P.e $P.e.g ; else echo creating $P.e.g ; cp $P.e $P.e.g ; fi
|
||||
rm -f $P.e
|
||||
$P.e: $P.c
|
||||
$(CEM) -c.e $P.c
|
||||
$P.pcc.r: $P.pcc
|
||||
echo running $P.pcc
|
||||
-$P.pcc >$P.pcc.r
|
||||
rm -f $P.pcc
|
||||
$P.cc.r: $P.cc
|
||||
echo running $P.cc
|
||||
-$P.cc >$P.cc.r
|
||||
rm -f $P.cc
|
||||
$P.cem.r: $P.cem
|
||||
echo running $P.cem
|
||||
-$P.cem >$P.cem.r
|
||||
rm -f $P.cem
|
||||
$P.pcc: /tmp
|
||||
echo pcc $P.c
|
||||
pcc -o $P.pcc $P.c
|
||||
$P.cc: /tmp
|
||||
echo cc $P.c
|
||||
cc -o $P.cc $P.c
|
||||
$P.cem: /tmp
|
||||
echo $(CEM) $P.c
|
||||
$(CEM) -o $P.cem $P.c
|
||||
gen: $P.cem.r
|
||||
echo comparing $P
|
||||
-if test -f $P.cem.g ; then diff -h $P.cem.r $P.cem.g ; else echo creating $P.cem.g ; cp $P.cem.r $P.cem.g ; fi
|
||||
|
||||
install cmp:
|
||||
|
||||
pr:
|
||||
@pr `pwd`/$P.c `pwd`/$P.cem.g
|
||||
|
||||
opr:
|
||||
make pr | opr
|
||||
|
||||
clean:
|
||||
-rm -f $P.[kmsoe] $P.*.r core a.out *.old em_last em_runinf e.out
|
||||
@@ -1,54 +0,0 @@
|
||||
.SILENT:
|
||||
CEM=i86 -DNOFLOAT
|
||||
head:
|
||||
echo use run
|
||||
|
||||
diffs: $P.cc.r $P.cem.r
|
||||
echo two compiler diff
|
||||
-diff $P.*.r
|
||||
|
||||
diffs3: $P.pcc.r $P.cc.r $P.cem.r
|
||||
echo three compiler diff
|
||||
-diff3 $P.*.r | tee diffs
|
||||
egen: $P.e
|
||||
echo comparing $P.e
|
||||
-if test -f $P.e.g ; then diff -h $P.e $P.e.g ; else echo creating $P.e.g ; cp $P.e $P.e.g ; fi
|
||||
rm -f $P.e
|
||||
$P.e: $P.c $(CEM)
|
||||
$(CEM) -c.e $P.c
|
||||
$P.pcc.r: $P.pcc
|
||||
echo running $P.pcc
|
||||
-$P.pcc >$P.pcc.r
|
||||
rm -f $P.pcc
|
||||
$P.cc.r: $P.cc
|
||||
echo running $P.cc
|
||||
-$P.cc >$P.cc.r
|
||||
rm -f $P.cc
|
||||
$P.cem.r: $P.cem
|
||||
echo running $P.cem
|
||||
idl I7 $P.cem
|
||||
-talk I7 >$P.cem.r
|
||||
rm -f $P.cem
|
||||
$P.pcc: $P.c /usr/lib/ccom
|
||||
echo pcc $P.c
|
||||
pcc -o $P.pcc $P.c
|
||||
$P.cc: $P.c /lib/c0 /lib/c1
|
||||
echo cc $P.c
|
||||
cc -o $P.cc $P.c
|
||||
$P.cem: $P.c
|
||||
echo $(CEM) $P.c
|
||||
$(CEM) -o $P.cem $P.c
|
||||
gen: $P.cem.r
|
||||
echo comparing $P
|
||||
-if test -f $P.cem.g ; then diff -h $P.cem.r $P.cem.g ; else echo creating $P.cem.g ; cp $P.cem.r $P.cem.g ; fi
|
||||
|
||||
install cmp:
|
||||
|
||||
pr:
|
||||
@pr `pwd`/$P.c `pwd`/$P.cem.g
|
||||
|
||||
opr:
|
||||
make pr | opr
|
||||
|
||||
clean:
|
||||
-rm -f $P.[kmsoe] $P.*.r core a.out *.old
|
||||
@@ -1,53 +0,0 @@
|
||||
.SILENT:
|
||||
CEM=int -O
|
||||
head:
|
||||
echo use run
|
||||
|
||||
diffs: $P.cc.r $P.cem.r
|
||||
echo two compiler diff
|
||||
-diff $P.*.r
|
||||
|
||||
diffs3: $P.pcc.r $P.cc.r $P.cem.r
|
||||
echo three compiler diff
|
||||
-diff3 $P.*.r | tee diffs
|
||||
egen: $P.e
|
||||
echo comparing $P.e
|
||||
-if test -f $P.e.g ; then diff -h $P.e $P.e.g ; else echo creating $P.e.g ; cp $P.e $P.e.g ; fi
|
||||
rm -f $P.e
|
||||
$P.e: $P.c $(CEM)
|
||||
$(CEM) -c.e $P.c
|
||||
$P.pcc.r: $P.pcc
|
||||
echo running $P.pcc
|
||||
-$P.pcc >$P.pcc.r
|
||||
rm -f $P.pcc
|
||||
$P.cc.r: $P.cc
|
||||
echo running $P.cc
|
||||
-$P.cc >$P.cc.r
|
||||
rm -f $P.cc
|
||||
$P.cem.r: $P.cem
|
||||
echo running $P.cem
|
||||
-/usr/evert/compile/a.out $P.cem >$P.cem.r
|
||||
rm -f $P.cem
|
||||
$P.pcc: $P.c /usr/lib/ccom
|
||||
echo pcc $P.c
|
||||
pcc -o $P.pcc $P.c
|
||||
$P.cc: $P.c /lib/c0 /lib/c1
|
||||
echo cc $P.c
|
||||
cc -o $P.cc $P.c
|
||||
$P.cem: $P.c
|
||||
echo $(CEM) $P.c
|
||||
$(CEM) -o $P.cem $P.c
|
||||
gen: $P.cem.r
|
||||
echo comparing $P
|
||||
-if test -f $P.cem.g ; then diff -h $P.cem.r $P.cem.g ; else echo creating $P.cem.g ; cp $P.cem.r $P.cem.g ; fi
|
||||
|
||||
install cmp:
|
||||
|
||||
pr:
|
||||
@pr `pwd`/$P.c `pwd`/$P.cem.g
|
||||
|
||||
opr:
|
||||
make pr | opr
|
||||
|
||||
clean:
|
||||
-rm -f $P.[kmsoe] $P.*.r core a.out *.old
|
||||
@@ -1,174 +0,0 @@
|
||||
Tue May 22 15:12:22 MDT 1984
|
||||
***** ctconv
|
||||
acc conv.c
|
||||
conv.c
|
||||
"conv.c", line 41: warning: Overflow in constant expression
|
||||
running conv.cem
|
||||
comparing conv
|
||||
***** ctdecl
|
||||
acc decl.c
|
||||
decl.c
|
||||
running decl.cem
|
||||
comparing decl
|
||||
***** ctdivers
|
||||
acc ops.c
|
||||
ops.c
|
||||
running ops.cem
|
||||
comparing ops
|
||||
***** cterr
|
||||
acc bugs.c
|
||||
bugs.c
|
||||
"bugs.c", line 92: warning: Overflow in constant expression
|
||||
running bugs.cem
|
||||
comparing bugs
|
||||
9,$c9,$
|
||||
< compl_ind
|
||||
< END
|
||||
---
|
||||
> END
|
||||
***** ctest1
|
||||
acc test.c
|
||||
test.c
|
||||
running test.cem
|
||||
comparing test
|
||||
***** ctest2
|
||||
acc t7.c
|
||||
t7.c
|
||||
"t7.c", line 161: warning: statement not reached
|
||||
"t7.c", line 178: warning: statement not reached
|
||||
"t7.c", line 182: warning: statement not reached
|
||||
"t7.c", line 186: warning: statement not reached
|
||||
"t7.c", line 190: warning: statement not reached
|
||||
"t7.c", line 194: warning: statement not reached
|
||||
"t7.c", line 198: warning: statement not reached
|
||||
"t7.c", line 205: warning: statement not reached
|
||||
"t7.c", line 207: warning: statement not reached
|
||||
"t7.c", line 211: warning: statement not reached
|
||||
"t7.c", line 213: warning: statement not reached
|
||||
"t7.c", line 287: warning: statement not reached
|
||||
"t7.c", line 294: warning: statement not reached
|
||||
"t7.c", line 300: warning: statement not reached
|
||||
"t7.c", line 307: warning: statement not reached
|
||||
"t7.c", line 343: warning: statement not reached
|
||||
"t7.c", line 344: warning: statement not reached
|
||||
"t7.c", line 345: warning: statement not reached
|
||||
"t7.c", line 346: warning: statement not reached
|
||||
"t7.c", line 348: warning: statement not reached
|
||||
"t7.c", line 452: warning: statement not reached
|
||||
"t7.c", line 561: warning: statement not reached
|
||||
"t7.c", line 589: warning: statement not reached
|
||||
running t7.cem
|
||||
comparing t7
|
||||
***** ctest3
|
||||
acc test2.c
|
||||
test2.c
|
||||
running test2.cem
|
||||
comparing test2
|
||||
***** ctest5
|
||||
acc test1.c
|
||||
test1.c
|
||||
"test1.c", line 101: warning: Illegal shift count in constant expression
|
||||
"test1.c", line 370: warning: illegal pointer combination
|
||||
"test1.c", line 371: warning: illegal pointer combination
|
||||
"test1.c", line 372: warning: illegal pointer combination
|
||||
"test1.c", line 384: warning: illegal pointer combination
|
||||
"test1.c", line 407: warning: illegal pointer combination
|
||||
"test1.c", line 408: warning: illegal pointer combination
|
||||
"test1.c", line 409: warning: illegal pointer combination
|
||||
"test1.c", line 421: warning: illegal pointer combination
|
||||
running test1.cem
|
||||
comparing test1
|
||||
***** ctgen
|
||||
`bf.c' is up to date.
|
||||
acc bf.c
|
||||
bf.c
|
||||
running bf.cem
|
||||
comparing bf
|
||||
`cel.c' is up to date.
|
||||
acc cel.c
|
||||
cel.c
|
||||
running cel.cem
|
||||
comparing cel
|
||||
`clu.c' is up to date.
|
||||
acc clu.c
|
||||
clu.c
|
||||
"clu.c", line 60: warning: Overflow in constant expression
|
||||
"clu.c", line 66: warning: Overflow in constant expression
|
||||
running clu.cem
|
||||
comparing clu
|
||||
28c28
|
||||
< x *= 40000 0
|
||||
---
|
||||
> x *= 40000 6784
|
||||
65c65
|
||||
< y = ( x *= 40000 ) 0 0
|
||||
---
|
||||
> y = ( x *= 40000 ) 6784 6784
|
||||
102c102
|
||||
< no if ( x *= 40000 ) yes() ; else no() 0
|
||||
---
|
||||
> yes if ( x *= 40000 ) yes() ; else no() 6784
|
||||
`ec.c' is up to date.
|
||||
acc ec.c
|
||||
ec.c
|
||||
"ec.c", line 58: warning: Overflow in constant expression
|
||||
"ec.c", line 64: warning: Overflow in constant expression
|
||||
running ec.cem
|
||||
comparing ec
|
||||
`ef.c' is up to date.
|
||||
acc ef.c
|
||||
ef.c
|
||||
running ef.cem
|
||||
comparing ef
|
||||
`ei.c' is up to date.
|
||||
acc ei.c
|
||||
ei.c
|
||||
"ei.c", line 22: warning: Overflow in constant expression
|
||||
"ei.c", line 65: warning: Overflow in constant expression
|
||||
"ei.c", line 108: warning: Overflow in constant expression
|
||||
running ei.cem
|
||||
comparing ei
|
||||
`el.c' is up to date.
|
||||
acc el.c
|
||||
el.c
|
||||
running el.cem
|
||||
comparing el
|
||||
`eu.c' is up to date.
|
||||
acc eu.c
|
||||
eu.c
|
||||
"eu.c", line 58: warning: Overflow in constant expression
|
||||
"eu.c", line 64: warning: Overflow in constant expression
|
||||
running eu.cem
|
||||
comparing eu
|
||||
28c28
|
||||
< x *= 40000 0
|
||||
---
|
||||
> x *= 40000 6784
|
||||
65c65
|
||||
< y = ( x *= 40000 ) 0 0
|
||||
---
|
||||
> y = ( x *= 40000 ) 6784 6784
|
||||
102c102
|
||||
< no if ( x *= 40000 ) yes() ; else no() 0
|
||||
---
|
||||
> yes if ( x *= 40000 ) yes() ; else no() 6784
|
||||
`id.c' is up to date.
|
||||
acc id.c
|
||||
id.c
|
||||
running id.cem
|
||||
comparing id
|
||||
`lc.c' is up to date.
|
||||
acc lc.c
|
||||
lc.c
|
||||
"lc.c", line 60: warning: Overflow in constant expression
|
||||
"lc.c", line 66: warning: Overflow in constant expression
|
||||
running lc.cem
|
||||
comparing lc
|
||||
`ld.c' is up to date.
|
||||
acc ld.c
|
||||
ld.c
|
||||
running ld.cem
|
||||
comparing ld
|
||||
`lf.c' is up to date.
|
||||
acc lf.c
|
||||
lf.c
|
||||
@@ -1,66 +0,0 @@
|
||||
: $Header$
|
||||
: This script makes an archive. The only option it knows is -o, which
|
||||
: creates a library.
|
||||
|
||||
rm -f OLIST
|
||||
|
||||
case $# in
|
||||
0)
|
||||
AR=tar
|
||||
OLIB=libsrc
|
||||
echo 'cf libsrc' > OLIST
|
||||
;;
|
||||
1)
|
||||
if [ "X$1" != "X-o" ]
|
||||
then
|
||||
echo $0: unrecognised option, I only know -o >&2
|
||||
exit 1
|
||||
fi
|
||||
AR=$ASAR
|
||||
echo "rv $OLIB" > OLIST
|
||||
;;
|
||||
*)
|
||||
echo $0: too many arguments >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "X$AR" = "X" ]
|
||||
then
|
||||
echo EEK -- internal error, no archiver >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $AR = tar ]
|
||||
then
|
||||
echo LIST >> OLIST
|
||||
echo MakeArch >> OLIST
|
||||
echo Makefile >> OLIST
|
||||
echo make.proto >> OLIST
|
||||
echo head_ac.e >> OLIST
|
||||
fi
|
||||
|
||||
DIRS=`cat LIST`
|
||||
|
||||
for i in $DIRS
|
||||
do
|
||||
cd $i
|
||||
if make "MACH=$MACH" "MACHFL=$MACHFL" "SUF=$SUF" $AR -f ../Makefile
|
||||
then
|
||||
cd ..
|
||||
if [ $AR = tar ]
|
||||
then
|
||||
echo $i/Makefile >> OLIST
|
||||
echo $i/LIST >> OLIST
|
||||
fi
|
||||
for j in `cat $i/OLIST`
|
||||
do
|
||||
echo $i/$j >> OLIST
|
||||
done
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
$AR `cat OLIST`
|
||||
${RANLIB-:} $OLIB
|
||||
@@ -1,50 +0,0 @@
|
||||
# $Header$
|
||||
# This Makefile is used for building the source archive as well as the
|
||||
# actual library.
|
||||
|
||||
EMHOME=../../..
|
||||
MACH=acc
|
||||
MACHFL=-O -L -Rcem=$(EMHOME)/lib/em_cemcom.ansi -I../headers $(DEFS)
|
||||
PREF=ac
|
||||
SUB=
|
||||
ASAR=arch
|
||||
HEADSRC=$(HOME)
|
||||
OLIB=tail_$(PREF)$(SUB)
|
||||
|
||||
install:
|
||||
MakeArch
|
||||
-mkdir $(EMHOME)/include/tail_ac
|
||||
( cd headers; tar cf - `cat LIST` ) | ( cd $(EMHOME)/include/tail_ac ; tar xf - )
|
||||
|
||||
clean:
|
||||
rm -f OLIST */OLIST
|
||||
(cd ctype; make clean)
|
||||
(cd stdlib; make clean)
|
||||
|
||||
headcp: head
|
||||
../../install head_$(PREF).$(SUF) head_$(PREF)
|
||||
rm -f head_$(PREF).$(SUF)
|
||||
|
||||
head: head_$(PREF).e
|
||||
make -r -f make.proto "CC=$(MACH)" "CFLAGS=-I$(EMHOME)/h $(MACHFL)" head_$(PREF).$(SUF)
|
||||
|
||||
tail: lib
|
||||
|
||||
tailcp: tail
|
||||
../../install $(OLIB)
|
||||
rm -f $(OLIB)
|
||||
|
||||
lib:
|
||||
MACH=$(MACH) MACHFL="$(MACHFL) -LIB" ASAR=$(ASAR) SUF=$(SUF) \
|
||||
OLIB=$(OLIB) MakeArch -o
|
||||
|
||||
ar aal arch:
|
||||
@rm -f OLIST
|
||||
@sed 's/\.[ce]/.$(SUF)/' < LIST | sed '/\.h/D' > OLIST
|
||||
make -r -f ../make.proto "CC=$(MACH)" "CFLAGS=$(MACHFL)" `cat OLIST`
|
||||
|
||||
# arch doesn't work recursively, tar does, which is what we actually want
|
||||
tar:
|
||||
@rm -f OLIST
|
||||
make `cat LIST`
|
||||
cp LIST OLIST
|
||||
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* ctype.c - character handling
|
||||
*/
|
||||
/* $Header$ */
|
||||
|
||||
int isalnum(int c); /* Alpha numeric character */
|
||||
int isalpha(int c); /* Alpha character */
|
||||
int iscntrl(int c); /* Control character */
|
||||
int isdigit(int c); /* Digit character */
|
||||
int isgraph(int c); /* Graphical character */
|
||||
int islower(int c); /* Lower case character */
|
||||
int isprint(int c); /* Printable character */
|
||||
int ispunct(int c); /* Punctuaction character */
|
||||
int isspace(int c); /* Space character */
|
||||
int isupper(int c); /* Upper case character */
|
||||
int isxdigit(int c); /* Hexdecimal digit character */
|
||||
|
||||
int tolower(int c); /* Convert to lower case character */
|
||||
int toupper(int c); /* Convert to upper case character */
|
||||
|
||||
int isalnum(int c) { /* Alpha numeric character */
|
||||
return isdigit(c) || isalpha(c);
|
||||
}
|
||||
|
||||
int isalpha(int c) { /* Alpha character */
|
||||
return isupper(c) || islower(c);
|
||||
}
|
||||
|
||||
int iscntrl(int c) { /* Control character */
|
||||
return (c >= 0 && c <= 0x1f) || c == 0x7f;
|
||||
}
|
||||
|
||||
int isdigit(int c) { /* Digit character */
|
||||
return (unsigned)(c - '0') < 10;
|
||||
}
|
||||
|
||||
int isgraph(int c) { /* Graphical character */
|
||||
return isprint(c) && c != ' ';
|
||||
}
|
||||
|
||||
int islower(int c) { /* Lower case character */
|
||||
return (unsigned)(c - 'a') < 26;
|
||||
}
|
||||
|
||||
int isprint(int c) { /* Printable character */
|
||||
return c > ' ' && c < 0x7f;
|
||||
}
|
||||
|
||||
int ispunct(int c) { /* Punctuation character */
|
||||
return isprint(c) && !(c == ' ' || isalnum(c));
|
||||
}
|
||||
|
||||
int isspace(int c) { /* Space character */
|
||||
return c == ' ' || c == '\f' || c == '\n' ||
|
||||
c == '\r' || c == '\t' || c == '\v';
|
||||
}
|
||||
|
||||
int isupper(int c) { /* Upper case character */
|
||||
return (unsigned)(c - 'A') < 26;
|
||||
}
|
||||
|
||||
int isxdigit(int c) { /* Hexdecimal digit character */
|
||||
return isdigit(c) ||
|
||||
(c >= 'A' && c <= 'F') ||
|
||||
(c >= 'a' && c <= 'f');
|
||||
}
|
||||
|
||||
int tolower(int c) { /* Convert to lower case character */
|
||||
if (!isupper(c)) return c;
|
||||
else return c - 'A' + 'a';
|
||||
}
|
||||
|
||||
int toupper(int c) { /* Convert to upper case character */
|
||||
if (!islower(c)) return c;
|
||||
else return c - 'a' + 'A';
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#if __STDC__ == 1
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#else
|
||||
#define EXIT_SUCCESS 0
|
||||
#define EXIT_FAILURE 1
|
||||
#endif
|
||||
|
||||
#define UCHAR_MAX 256
|
||||
|
||||
char *functab[] = {
|
||||
"isalnum",
|
||||
"isalpha",
|
||||
"iscntrl",
|
||||
"isdigit",
|
||||
"isgraph",
|
||||
"islower",
|
||||
"isprint",
|
||||
"ispunct",
|
||||
"isspace",
|
||||
"isupper",
|
||||
"isxdigit",
|
||||
"isascii",
|
||||
"toupper",
|
||||
"tolower",
|
||||
NULL,
|
||||
};
|
||||
|
||||
char buf[100];
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
register char **name;
|
||||
register int i;
|
||||
FILE *file;
|
||||
|
||||
name = functab;
|
||||
while (*name) {
|
||||
strcpy(buf, *name);
|
||||
strcat(buf, ".c");
|
||||
if (!(file = fopen(buf,"w"))) exit(EXIT_FAILURE);
|
||||
fprintf(file,"int (%s)(int c) {\n", *name);
|
||||
fprintf(file,"\treturn %s(c);\n", *name);
|
||||
fprintf(file,"}\n");
|
||||
fclose(file);
|
||||
name++;
|
||||
}
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
/*
|
||||
* errno.h - error codes
|
||||
*
|
||||
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||
*/
|
||||
/* $Header */
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
int errno = 0;
|
||||
@@ -1,72 +0,0 @@
|
||||
/* $Header$ */
|
||||
|
||||
#if !defined(_SGTTY_H)
|
||||
#define _SGTTY_H
|
||||
/* Data structures for IOCTL. */
|
||||
|
||||
struct sgttyb {
|
||||
char sg_ispeed; /* input speed */
|
||||
char sg_ospeed; /* output speed */
|
||||
char sg_erase; /* erase character */
|
||||
char sg_kill; /* kill character */
|
||||
#if defined(__USG) && !defined(_XENIX)
|
||||
int sg_flags; /* mode flags */
|
||||
#else
|
||||
short sg_flags; /* mode flags */
|
||||
#endif
|
||||
};
|
||||
|
||||
struct tchars {
|
||||
char t_intrc; /* SIGINT char */
|
||||
char t_quitc; /* SIGQUIT char */
|
||||
char t_startc; /* start output (initially CTRL-Q) */
|
||||
char t_stopc; /* stop output (initially CTRL-S) */
|
||||
char t_eofc; /* EOF (initially CTRL-D) */
|
||||
char t_brkc; /* input delimiter (like nl) */
|
||||
};
|
||||
|
||||
/* Field names */
|
||||
#if defined(__USG) && !defined(_XENIX)
|
||||
#define XTABS 0000002 /* do tab expansion */
|
||||
#else
|
||||
#define XTABS 0006000 /* do tab expansion */
|
||||
#endif
|
||||
#define EVENP 0000200 /* even parity */
|
||||
#define ODDP 0000100 /* odd parity */
|
||||
#define RAW 0000040 /* enable raw mode */
|
||||
#define CRMOD 0000020 /* map lf to cr + lf */
|
||||
#define ECHO 0000010 /* echo input */
|
||||
#define LCASE 0000004 /* map upper case to lower on input */
|
||||
#define CBREAK 0000002 /* enable cbreak mode */
|
||||
#if defined(__BSD4_2) || defined(_XENIX)
|
||||
#define TANDEM 0000001 /* automatic flow control */
|
||||
#else
|
||||
#define HUPCL 0000001 /* unused ??? */
|
||||
#endif
|
||||
#define COOKED 0000000 /* neither CBREAK nor RAW */
|
||||
|
||||
#define B0 0
|
||||
#define B50 1
|
||||
#define B75 2
|
||||
#define B110 3
|
||||
#define B134 4
|
||||
#define B150 5
|
||||
#define B200 6
|
||||
#define B300 7
|
||||
#define B600 8
|
||||
#define B1200 9
|
||||
#define B1800 10
|
||||
#define B2400 11
|
||||
#define B4800 12
|
||||
#define B9600 13
|
||||
#define B19200 14
|
||||
#define B38400 15
|
||||
#define EXTA 14
|
||||
#define EXTB 15
|
||||
|
||||
#define TIOCGETP (('t'<<8) | 8)
|
||||
#define TIOCSETP (('t'<<8) | 9)
|
||||
#define TIOCGETC (('t'<<8) | 18)
|
||||
#define TIOCSETC (('t'<<8) | 17)
|
||||
|
||||
#endif /* _SGTTY_H */
|
||||
@@ -1,85 +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$ */
|
||||
|
||||
#if !defined(_SYS_STAT_H)
|
||||
#define _SYS_STAT_H
|
||||
|
||||
struct stat {
|
||||
dev_t st_dev;
|
||||
ino_t st_ino;
|
||||
u_short st_mode;
|
||||
short st_nlink;
|
||||
short st_uid;
|
||||
short st_gid;
|
||||
dev_t st_rdev;
|
||||
off_t st_size;
|
||||
time_t st_atime;
|
||||
#if defined(__BSD4_2)
|
||||
long st_spare1;
|
||||
#endif
|
||||
time_t st_mtime;
|
||||
#if defined(__BSD4_2)
|
||||
long st_spare2;
|
||||
#endif
|
||||
time_t st_ctime;
|
||||
#if defined(__BSD4_2)
|
||||
long st_spare3;
|
||||
long st_blksize;
|
||||
long st_blocks;
|
||||
long st_spare4[2];
|
||||
#endif
|
||||
};
|
||||
|
||||
#define S_IFMT 0170000
|
||||
#define S_IFDIR 0040000
|
||||
#define S_IFCHR 0020000
|
||||
#define S_IFBLK 0060000
|
||||
#define S_IFREG 0100000
|
||||
#if !defined(__BSD4_2)
|
||||
#if !defined(__USG) && !defined(_POSIX_SOURCE)
|
||||
#define S_IFMPC 0030000
|
||||
#define S_IFMPB 0070000
|
||||
#else
|
||||
#define S_IFIFO 0010000
|
||||
#endif
|
||||
#else
|
||||
#define S_IFLNK 0120000
|
||||
#define S_IFSOCK 0140000
|
||||
#endif
|
||||
#define S_ISUID 0004000
|
||||
#define S_ISGID 0002000
|
||||
#define S_ISVTX 0001000
|
||||
#define S_IREAD 0000400
|
||||
#define S_IWRITE 0000200
|
||||
#define S_IEXEC 0000100
|
||||
|
||||
#if defined(__BSD4_2) || defined(_POSIX_SOURCE)
|
||||
#define S_IRWXU 00700 /* owner: rwx------ */
|
||||
#define S_IRUSR 00400 /* owner: r-------- */
|
||||
#define S_IWUSR 00200 /* owner: -w------- */
|
||||
#define S_IXUSR 00100 /* owner: --x------ */
|
||||
|
||||
#define S_IRWXG 00070 /* group: ---rwx--- */
|
||||
#define S_IRGRP 00040 /* group: ---r----- */
|
||||
#define S_IWGRP 00020 /* group: ----w---- */
|
||||
#define S_IXGRP 00010 /* group: -----x--- */
|
||||
|
||||
#define S_IRWXO 00007 /* others: ------rwx */
|
||||
#define S_IROTH 00004 /* others: ------r-- */
|
||||
#define S_IWOTH 00002 /* others: -------w- */
|
||||
#define S_IXOTH 00001 /* others: --------x */
|
||||
|
||||
#if defined(_POSIX_SOURCE)
|
||||
/* The following macros test st_mode (from POSIX Sec. 5.6.1.1.) */
|
||||
#define S_ISREG(m) ((m & S_IFMT) == S_IFREG) /* is a reg file */
|
||||
#define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR) /* is a directory */
|
||||
#define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR) /* is a char spec */
|
||||
#define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK) /* is a block spec */
|
||||
#define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO) /* is a pipe/FIFO */
|
||||
#endif /* _POSIX_SOURCE */
|
||||
#endif /* BSD4_2 || _POSIX_SOURCE */
|
||||
|
||||
#endif /* _SYS_STAT_H */
|
||||
@@ -1,77 +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".
|
||||
*/
|
||||
/*
|
||||
* Basic system types and major/minor device constructing/busting macros.
|
||||
*/
|
||||
/* $Header$ */
|
||||
|
||||
#if !defined(_SYS_TYPES_H)
|
||||
#define _SYS_TYPES_H
|
||||
|
||||
#if !defined(_SIZE_T)
|
||||
#define _SIZE_T
|
||||
typedef unsigned int size_t; /* type returned by sizeof */
|
||||
#endif /* _SIZE_T */
|
||||
|
||||
#if !defined(_TIME_T)
|
||||
#define _TIME_T
|
||||
typedef unsigned long time_t;
|
||||
#endif /* TIME_T */
|
||||
|
||||
#if !defined(_POSIX_SOURCE)
|
||||
|
||||
/* major part of a device */
|
||||
#define major(x) ((int)(((unsigned)(x)>>8)&0377))
|
||||
|
||||
/* minor part of a device */
|
||||
#define minor(x) ((int)((x)&0377))
|
||||
|
||||
/* make a device number */
|
||||
#define makedev(x,y) ((dev_t)(((x)<<8) | (y)))
|
||||
|
||||
typedef unsigned char u_char;
|
||||
typedef unsigned short u_short;
|
||||
typedef unsigned int u_int;
|
||||
typedef unsigned long u_long;
|
||||
|
||||
typedef struct _physadr { int r[1]; } *physadr;
|
||||
typedef long daddr_t;
|
||||
typedef char * caddr_t;
|
||||
#if defined(__BSD4_2)
|
||||
typedef u_long ino_t;
|
||||
#else
|
||||
typedef u_short ino_t;
|
||||
#endif
|
||||
typedef long swblk_t;
|
||||
|
||||
typedef long label_t[14];
|
||||
typedef short dev_t;
|
||||
#if defined(__BSD4_2)
|
||||
typedef int off_t; /* see lseek(2) */
|
||||
#else
|
||||
typedef long off_t;
|
||||
#endif
|
||||
|
||||
/* system V compatibility: */
|
||||
typedef unsigned int uint;
|
||||
typedef unsigned short ushort;
|
||||
typedef unsigned char uchar_t;
|
||||
typedef short cnt_t;
|
||||
typedef long paddr_t;
|
||||
typedef long key_t;
|
||||
#else /* _POSIX_SOURCE */
|
||||
#if defined(_MINIX)
|
||||
typedef unsigned short dev_t; /* hold (major|minor) device pair */
|
||||
typedef unsigned char gid_t; /* group id */
|
||||
typedef unsigned short ino_t; /* i-node number */
|
||||
typedef unsigned short mode_t; /* mode number within an i-node */
|
||||
typedef unsigned char nlink_t; /* number-of-links field within an i-node */
|
||||
typedef long off_t; /* offsets within a file */
|
||||
typedef int pid_t; /* type for pids (must be signed) */
|
||||
typedef unsigned short uid_t; /* user id */
|
||||
#endif /* _MINIX */
|
||||
#endif /* _POSIX_SOURCE */
|
||||
|
||||
#endif /* _SYS_TYPES_H */
|
||||
@@ -1,6 +0,0 @@
|
||||
.SUFFIXES: .o .e .c .m .s
|
||||
|
||||
.c.o .e.o .c.m .e.m .c.s .e.s:
|
||||
$(CC) $(CFLAGS) -c $<
|
||||
|
||||
fake:
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||
*
|
||||
* Author: Ceriel J.H. Jacobs
|
||||
*/
|
||||
/* $Header$ */
|
||||
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
#include "localmath.h"
|
||||
|
||||
double
|
||||
cosh(double x)
|
||||
{
|
||||
if (x < 0) {
|
||||
x = -x;
|
||||
}
|
||||
if (x > M_LN_MAX_D) {
|
||||
/* exp(x) would overflow */
|
||||
if (x >= M_LN_MAX_D + M_LN2) {
|
||||
/* not representable */
|
||||
x = HUGE_VAL;
|
||||
errno = ERANGE;
|
||||
}
|
||||
else x = exp (x - M_LN2);
|
||||
}
|
||||
else {
|
||||
double expx = exp(x);
|
||||
x = 0.5 * (expx + 1.0/expx);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
/*
|
||||
* gcvt.c - conversion for printing a floating point number
|
||||
*/
|
||||
/* $Header$ */
|
||||
|
||||
#ifndef NOFLOAT
|
||||
#include "loc_incl.h"
|
||||
|
||||
#define NDIGINEXP(exp) (((exp) >= 100 || (exp) <= -100) ? 3 : 2)
|
||||
#define LOW_EXP -4
|
||||
#define USE_EXP(exp, ndigits) (((exp) < LOW_EXP + 1) || (exp >= ndigits + 1))
|
||||
|
||||
char *
|
||||
_gcvt(long double value, int ndigit, char *s, int flags)
|
||||
{
|
||||
int sign, dp;
|
||||
register char *s1, *s2;
|
||||
register int i;
|
||||
register int nndigit = ndigit;
|
||||
|
||||
s1 = _ecvt(value, ndigit, &dp, &sign);
|
||||
s2 = s;
|
||||
if (sign) *s2++ = '-';
|
||||
else if (flags & FL_SIGN)
|
||||
*s2++ = '+';
|
||||
else if (flags & FL_SPACE)
|
||||
*s2++ = ' ';
|
||||
|
||||
if (!(flags & FL_ALT))
|
||||
for (i = nndigit - 1; i > 0 && s1[i] == '0'; i--)
|
||||
nndigit--;
|
||||
|
||||
if (USE_EXP(dp,ndigit)) {
|
||||
/* Use E format */
|
||||
dp--;
|
||||
*s2++ = *s1++;
|
||||
if ((nndigit > 1) || (flags & FL_ALT)) *s2++ = '.';
|
||||
while (--nndigit > 0) *s2++ = *s1++;
|
||||
*s2++ = 'e';
|
||||
if (dp < 0) {
|
||||
*s2++ = '-';
|
||||
dp = -dp;
|
||||
}
|
||||
else *s2++ = '+';
|
||||
s2 += NDIGINEXP(dp);
|
||||
*s2 = 0;
|
||||
for (i = NDIGINEXP(dp); i > 0; i--) {
|
||||
*--s2 = dp % 10 + '0';
|
||||
dp /= 10;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
/* Use f format */
|
||||
if (dp <= 0) {
|
||||
if (*s1 != '0') {
|
||||
/* otherwise the whole number is 0 */
|
||||
*s2++ = '0';
|
||||
*s2++ = '.';
|
||||
}
|
||||
while (dp < 0) {
|
||||
dp++;
|
||||
*s2++ = '0';
|
||||
}
|
||||
}
|
||||
for (i = 1; i <= nndigit; i++) {
|
||||
*s2++ = *s1++;
|
||||
if (i == dp) *s2++ = '.';
|
||||
}
|
||||
if (i <= dp) {
|
||||
while (i++ <= dp) *s2++ = '0';
|
||||
*s2++ = '.';
|
||||
}
|
||||
if ((s2[-1]=='.') && !(flags & FL_ALT)) s2--;
|
||||
*s2 = '\0';
|
||||
return s;
|
||||
}
|
||||
#endif /* NOFLOAT */
|
||||
@@ -1,24 +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$ */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define ALIGN(sz) (((sz)+(sizeof(long)-1)/sizeof(long))*sizeof(long))
|
||||
|
||||
void *
|
||||
calloc(size_t nelem, size_t elsize)
|
||||
{
|
||||
register void *p;
|
||||
register long *q;
|
||||
unsigned int size = ALIGN(nelem * elsize);
|
||||
|
||||
if ((p = malloc(size)) == (void *)NULL)
|
||||
return (void *)NULL;
|
||||
/* "The space is intialized to all bits zero" */
|
||||
q = (long *) (p + size);
|
||||
while ((void *) q > p) *--q = 0;
|
||||
return p;
|
||||
}
|
||||
@@ -1,127 +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$ */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define CLICK_SIZE 4096
|
||||
|
||||
#if EM_WSIZE == EM_PSIZE
|
||||
typedef unsigned int vir_bytes;
|
||||
#else
|
||||
typedef long vir_bytes;
|
||||
#endif
|
||||
|
||||
|
||||
#define ALIGN(x, a) (((x) + (a - 1)) & ~(a - 1))
|
||||
#define BUSY 1
|
||||
#define NEXT(p) (* (void **) (p))
|
||||
|
||||
#ifdef pdp
|
||||
#define BUGFIX 64 /* cannot set break in top 64 bytes */
|
||||
#else
|
||||
#define BUGFIX 0
|
||||
#endif
|
||||
|
||||
extern void bcopy(void *, void *, size_t);
|
||||
extern void *sbrk(unsigned int);
|
||||
extern void *brk(unsigned int);
|
||||
static void *bottom, *top;
|
||||
|
||||
static int
|
||||
grow(size_t len)
|
||||
{
|
||||
register void *p;
|
||||
register int click = CLICK_SIZE;
|
||||
|
||||
p = sbrk(0);
|
||||
len += (void *) ALIGN((vir_bytes) p, sizeof(void *)) - p;
|
||||
while (click >= 4) {
|
||||
size_t len1 = ALIGN((vir_bytes)p+len+sizeof(char *),click)-(vir_bytes)p;
|
||||
void *p1 = p;
|
||||
|
||||
if (p + len1 + BUGFIX < p || (p1 = sbrk(len1)) == (void *) -1) {
|
||||
click >>= 1;
|
||||
continue;
|
||||
}
|
||||
p = p1;
|
||||
if (top + sizeof(void *) != p) {
|
||||
/* someone else has done an sbrk */
|
||||
NEXT(top) = (void *) ((vir_bytes) p | BUSY);
|
||||
} else {
|
||||
for (p = bottom; NEXT(p) != NULL; p = (void *) (* (vir_bytes *) p & ~BUSY))
|
||||
;
|
||||
}
|
||||
top = p + len1 - sizeof(void *);
|
||||
NEXT(p) = top;
|
||||
NEXT(top) = NULL;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *
|
||||
malloc(size_t size)
|
||||
{
|
||||
register void *p, *next, *new;
|
||||
register size_t len = ALIGN(size, sizeof(void *)) + sizeof(void *);
|
||||
|
||||
if ((p = bottom) == NULL) {
|
||||
p = sbrk(sizeof(void *));
|
||||
sbrk((void *) ALIGN((vir_bytes) p, sizeof(void *)) - p);
|
||||
p = (void *) ALIGN((vir_bytes) p, sizeof(void *));
|
||||
top = bottom = p;
|
||||
NEXT(p) = NULL;
|
||||
}
|
||||
while ((next = NEXT(p)) != NULL)
|
||||
if ((vir_bytes) next & BUSY) /* already in use */
|
||||
p = (void *) ((vir_bytes) next & ~BUSY);
|
||||
else {
|
||||
while ((new = NEXT(next)) != NULL
|
||||
&& !((vir_bytes) new & BUSY))
|
||||
next = new;
|
||||
if (next - p >= len) { /* fits */
|
||||
if ((new = p + len) < next) /* too big */
|
||||
NEXT(new) = next;
|
||||
NEXT(p) = (void *) ((vir_bytes) new | BUSY);
|
||||
return(p + sizeof(void *));
|
||||
}
|
||||
p = next;
|
||||
}
|
||||
return grow(len) ? malloc(size) : (void *)NULL;
|
||||
}
|
||||
|
||||
void *
|
||||
realloc(void *old, size_t size)
|
||||
{
|
||||
register void *p = old - sizeof(void *), *next, *new;
|
||||
register size_t len = ALIGN(size, sizeof(void *)) + sizeof(void *), n;
|
||||
|
||||
next = (void *) (* (vir_bytes *) p & ~BUSY);
|
||||
n = next - old; /* old size */
|
||||
while ((new = NEXT(next)) != NULL && !((vir_bytes) new & BUSY))
|
||||
next = new;
|
||||
if (next - p >= len) { /* does it still fit */
|
||||
if ((new = p + len) < next) { /* even too big */
|
||||
NEXT(new) = next;
|
||||
NEXT(p) = (void *) ((vir_bytes) new | BUSY);
|
||||
}
|
||||
else
|
||||
NEXT(p) = (void *) ((vir_bytes) next | BUSY);
|
||||
return(old);
|
||||
}
|
||||
if ((new = malloc(size)) == NULL) /* it didn't fit */
|
||||
return((void *)NULL);
|
||||
bcopy(old, new, n); /* n < size */
|
||||
* (vir_bytes *) p &= ~BUSY;
|
||||
return(new);
|
||||
}
|
||||
|
||||
void
|
||||
free(void *p)
|
||||
{
|
||||
if (p != (void *)NULL)
|
||||
*(vir_bytes *) (p - sizeof(void *)) &= ~BUSY;
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* loc_incl.h - some local definitions
|
||||
*/
|
||||
/* $Header$ */
|
||||
|
||||
#define YEAR0 1900 /* the first year */
|
||||
#define EPOCH_YR 1970 /* EPOCH = Jan 1 1970 00:00:00 */
|
||||
#define SECS_DAY (24L * 60L * 60L)
|
||||
#define LEAPYEAR(year) (!((year) % 4) && (((year) % 100) || !((year) % 400)))
|
||||
#define YEARSIZE(year) (LEAPYEAR(year) ? 366 : 365)
|
||||
#define FIRSTSUNDAY(timp) (((timp)->tm_yday - (timp)->tm_wday + 420) % 7)
|
||||
#define FIRSTDAYOF(timp) (((timp)->tm_wday - (timp)->tm_yday + 420) % 7)
|
||||
#define TIME_MAX ULONG_MAX
|
||||
#define ABB_LEN 3
|
||||
|
||||
extern const int _ytab[2][12];
|
||||
extern const char *_days[];
|
||||
extern const char *_months[];
|
||||
|
||||
void _tzset(void);
|
||||
unsigned _dstget(struct tm *timep);
|
||||
|
||||
extern long _timezone;
|
||||
extern long _dst_off;
|
||||
extern int _daylight;
|
||||
extern char *_tzname[2];
|
||||
@@ -1,58 +0,0 @@
|
||||
/* $Header$ */
|
||||
#include <stdio.h>
|
||||
#define ERR(s, c) if(opterr){\
|
||||
fputs(argv[0], stderr);\
|
||||
fputs(s, stderr);\
|
||||
fputc(c, stderr);\
|
||||
fputc('\n', stderr);}
|
||||
|
||||
int opterr = 1;
|
||||
int optind = 1;
|
||||
int optopt;
|
||||
char *optarg;
|
||||
char *index();
|
||||
|
||||
int
|
||||
getopt (argc, argv, opts)
|
||||
char **argv, *opts;
|
||||
{
|
||||
static int sp = 1;
|
||||
register c;
|
||||
register char *cp;
|
||||
|
||||
if (sp == 1)
|
||||
if (optind >= argc ||
|
||||
argv[optind][0] != '-' || argv[optind][1] == '\0')
|
||||
return EOF;
|
||||
else if (strcmp(argv[optind], "--") == NULL) {
|
||||
optind++;
|
||||
return EOF;
|
||||
}
|
||||
optopt = c = argv[optind][sp];
|
||||
if (c == ':' || (cp=index(opts, c)) == NULL) {
|
||||
ERR (": illegal option -- ", c);
|
||||
if (argv[optind][++sp] == '\0') {
|
||||
optind++;
|
||||
sp = 1;
|
||||
}
|
||||
return '?';
|
||||
}
|
||||
if (*++cp == ':') {
|
||||
if (argv[optind][sp+1] != '\0')
|
||||
optarg = &argv[optind++][sp+1];
|
||||
else if (++optind >= argc) {
|
||||
ERR (": option requires an argument -- ", c);
|
||||
sp = 1;
|
||||
return '?';
|
||||
} else
|
||||
optarg = argv[optind++];
|
||||
sp = 1;
|
||||
} else {
|
||||
if (argv[optind][++sp] == '\0') {
|
||||
sp = 1;
|
||||
optind++;
|
||||
}
|
||||
optarg = NULL;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||
*
|
||||
* Author: Ceriel J.H. Jacobs
|
||||
*/
|
||||
|
||||
/* $Header$ */
|
||||
|
||||
#include <math.h>
|
||||
#include <errno.h>
|
||||
|
||||
extern int errno;
|
||||
|
||||
double
|
||||
cosh(x)
|
||||
double x;
|
||||
{
|
||||
extern double exp();
|
||||
|
||||
if (x < 0) {
|
||||
x = -x;
|
||||
}
|
||||
if (x > M_LN_MAX_D) {
|
||||
/* exp(x) would overflow */
|
||||
if (x >= M_LN_MAX_D + M_LN2) {
|
||||
/* not representable */
|
||||
x = HUGE;
|
||||
errno = ERANGE;
|
||||
}
|
||||
else x = exp (x - M_LN2);
|
||||
}
|
||||
else {
|
||||
double expx = exp(x);
|
||||
x = 0.5 * (expx + 1.0/expx);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
!File: errout.h
|
||||
#define ERROUT STDERR /* file pointer for writing messages */
|
||||
#define MAXERR_LINE 100 /* maximum number of error messages given
|
||||
on the same input line. */
|
||||
|
||||
|
||||
!File: idfsize.h
|
||||
#define IDFSIZE 128 /* maximum significant length of an identifier */
|
||||
|
||||
|
||||
!File: numsize.h
|
||||
#define NUMSIZE 256 /* maximum length of a numeric constant */
|
||||
|
||||
|
||||
!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)
|
||||
#define SZ_FLOAT ((arith)4)
|
||||
#define SZ_DOUBLE ((arith)8)
|
||||
#define SZ_POINTER ((arith)4)
|
||||
|
||||
/* target machine alignment requirements */
|
||||
#define AL_CHAR 1
|
||||
#define AL_SHORT ((int)SZ_SHORT)
|
||||
#define AL_WORD ((int)SZ_WORD)
|
||||
#define AL_INT ((int)SZ_WORD)
|
||||
#define AL_LONG ((int)SZ_WORD)
|
||||
#define AL_FLOAT ((int)SZ_WORD)
|
||||
#define AL_DOUBLE ((int)SZ_WORD)
|
||||
#define AL_POINTER ((int)SZ_WORD)
|
||||
#define AL_STRUCT ((int)SZ_WORD)
|
||||
|
||||
|
||||
!File: debugcst.h
|
||||
#define DEBUG 1 /* perform various self-tests */
|
||||
|
||||
!File: inputtype.h
|
||||
#define INP_READ_IN_ONE 1 /* read input file in one */
|
||||
|
||||
|
||||
!File: density.h
|
||||
#define DENSITY 3 /* see casestat.C for an explanation */
|
||||
|
||||
|
||||
!File: squeeze.h
|
||||
#undef SQUEEZE 1 /* define on "small" machines */
|
||||
|
||||
|
||||
!File: strict3rd.h
|
||||
#undef STRICT_3RD_ED 1 /* define on "small" machines, and if you want
|
||||
a compiler that only implements "3rd edition"
|
||||
Modula-2
|
||||
*/
|
||||
|
||||
|
||||
!File: nocross.h
|
||||
#undef NOCROSS 1 /* define when cross-compiler not needed */
|
||||
|
||||
|
||||
!File: nostrict.h
|
||||
#undef NOSTRICT 1 /* define when STRICT warnings disabled
|
||||
(yet another squeezing method)
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
: create a directory Xsrc with name clashes resolved
|
||||
: and run make in that directory
|
||||
: '$Header$'
|
||||
|
||||
case $# in
|
||||
1)
|
||||
;;
|
||||
*) echo "$0: one argument expected" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
PW=`pwd`
|
||||
case $1 in
|
||||
main) target=$PW/$1
|
||||
;;
|
||||
omain) target=$PW/$1
|
||||
options=-DPEEPHOLE
|
||||
;;
|
||||
cemain) target=$PW/$1
|
||||
options=-DCODE_EXPANDER
|
||||
;;
|
||||
Xlint) target=$1
|
||||
;;
|
||||
*) echo "$0: $1: Illegal argument" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
if test -d ../Xsrc
|
||||
then
|
||||
:
|
||||
else mkdir ../Xsrc
|
||||
fi
|
||||
make EMHOME=$EMHOME longnames
|
||||
: remove code generating routines from the clashes list as they are defines.
|
||||
: code generating routine names start with C_
|
||||
sed '/^C_/d' < longnames > tmp$$
|
||||
cclash -c -l7 tmp$$ > ../Xsrc/Xclashes
|
||||
rm -f tmp$$
|
||||
cd ../Xsrc
|
||||
if cmp -s Xclashes clashes
|
||||
then
|
||||
:
|
||||
else
|
||||
mv Xclashes clashes
|
||||
fi
|
||||
rm -f Makefile
|
||||
ed - $PW/Makefile <<'EOF'
|
||||
/^#EXCLEXCL/,/^#INCLINCL/d
|
||||
w Makefile
|
||||
q
|
||||
EOF
|
||||
for i in `cat $PW/Cfiles`
|
||||
do
|
||||
cat >> Makefile <<EOF
|
||||
|
||||
$i: clashes $PW/$i
|
||||
\$(CID) -Fclashes < $PW/$i > $i
|
||||
EOF
|
||||
done
|
||||
make EMHOME=$EMHOME COPTIONS=$options MACH=$MACH CURRDIR=$PW/ $target
|
||||
@@ -1 +0,0 @@
|
||||
static char Version[] = "ACK Modula-2 compiler Version 0.50";
|
||||
@@ -1,15 +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".
|
||||
*
|
||||
* Author: Ceriel J.H. Jacobs
|
||||
*/
|
||||
|
||||
/* C O N S T A N T S F O R E X P R E S S I O N H A N D L I N G */
|
||||
|
||||
/* $Header$ */
|
||||
|
||||
#define arith_sign ((arith) (1L << (sizeof(arith) * 8 - 1)))
|
||||
|
||||
extern unsigned int
|
||||
wrd_bits; /* Number of bits in a word */
|
||||
@@ -1,22 +0,0 @@
|
||||
/* D E F A U L T S I Z E S A N D A L I G N M E N T S */
|
||||
|
||||
/* $Header$ */
|
||||
|
||||
#define MAXSIZE 8 /* the maximum of the SZ_* constants */
|
||||
/* target machine sizes */
|
||||
#define SZ_CHAR (arith)1
|
||||
#define SZ_WORD (arith)4
|
||||
#define SZ_INT (arith)4
|
||||
#define SZ_LONG (arith)4
|
||||
#define SZ_FLOAT (arith)4
|
||||
#define SZ_DOUBLE (arith)8
|
||||
#define SZ_POINTER (arith)4
|
||||
/* target machine alignment requirements */
|
||||
#define AL_CHAR 1
|
||||
#define AL_WORD (int) SZ_WORD
|
||||
#define AL_INT (int) SZ_WORD
|
||||
#define AL_LONG (int) SZ_WORD
|
||||
#define AL_FLOAT (int) SZ_WORD
|
||||
#define AL_DOUBLE (int) SZ_WORD
|
||||
#define AL_POINTER (int) SZ_WORD
|
||||
#define AL_STRUCT 1
|
||||
@@ -1,69 +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".
|
||||
*
|
||||
* Author: Ceriel J.H. Jacobs
|
||||
*/
|
||||
|
||||
/* D E S I G N A T O R D E S C R I P T I O N S */
|
||||
|
||||
/* $Header$ */
|
||||
|
||||
/* Generating code for designators is not particularly easy, especially if
|
||||
you don't know wether you want the address or the value.
|
||||
The next structure is used to generate code for designators.
|
||||
It contains information on how to find the designator, after generation
|
||||
of the code that is common to both address and value computations.
|
||||
*/
|
||||
|
||||
struct desig {
|
||||
short dsg_kind;
|
||||
#define DSG_INIT 0 /* don't know anything yet */
|
||||
#define DSG_LOADED 1 /* designator loaded on top of the stack */
|
||||
#define DSG_PLOADED 2 /* designator accessible through pointer on
|
||||
stack, possibly with an offset
|
||||
*/
|
||||
#define DSG_FIXED 3 /* designator directly accessible */
|
||||
#define DSG_PFIXED 4 /* designator accessible through directly
|
||||
accessible pointer
|
||||
*/
|
||||
#define DSG_INDEXED 5 /* designator accessible through array
|
||||
operation. Address of array descriptor on
|
||||
top of the stack, index beneath that, and
|
||||
base address beneath that
|
||||
*/
|
||||
arith dsg_offset; /* contains an offset for PLOADED,
|
||||
or for FIXED or PFIXED it contains an
|
||||
offset from dsg_name, if it exists,
|
||||
or from the current Local Base
|
||||
*/
|
||||
char *dsg_name; /* name of global variable, used for
|
||||
FIXED and PFIXED
|
||||
*/
|
||||
struct def *dsg_def; /* def structure associated with this
|
||||
designator, or 0
|
||||
*/
|
||||
};
|
||||
|
||||
typedef struct desig t_desig;
|
||||
|
||||
/* ALLOCDEF "desig" 5 */
|
||||
|
||||
/* The next structure describes the designator in a with-statement.
|
||||
We have a linked list of them, as with-statements may be nested.
|
||||
*/
|
||||
|
||||
struct withdesig {
|
||||
struct withdesig *w_next;
|
||||
int w_flags; /* D_USED|D_DEFINED */
|
||||
struct scope *w_scope; /* scope in which fields of this record
|
||||
reside
|
||||
*/
|
||||
t_desig w_desig; /* a desig structure for this particular
|
||||
designator
|
||||
*/
|
||||
};
|
||||
|
||||
extern struct withdesig *WithDesigs;
|
||||
|
||||
#define NO_LABEL ((label) 0)
|
||||
@@ -1,12 +0,0 @@
|
||||
/* $Header$ */
|
||||
|
||||
#include <alloc.h>
|
||||
|
||||
/* Structure to link idf structures together
|
||||
*/
|
||||
struct id_list {
|
||||
struct id_list *next;
|
||||
struct idf *id_ptr;
|
||||
};
|
||||
|
||||
/* ALLOCDEF "id_list" */
|
||||
@@ -1,20 +0,0 @@
|
||||
static char *RcsId = "$Header$";
|
||||
|
||||
#include "idf.h"
|
||||
#include "idlist.h"
|
||||
|
||||
struct id_list *h_id_list; /* Header of free list */
|
||||
|
||||
/* FreeIdList: take a list of id_list structures and put them
|
||||
on the free list of id_list structures
|
||||
*/
|
||||
FreeIdList(p)
|
||||
struct id_list *p;
|
||||
{
|
||||
register struct id_list *q;
|
||||
|
||||
while (q = p) {
|
||||
p = p->next;
|
||||
free_id_list(q);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
/* M I S C E L L A N E O U S */
|
||||
|
||||
/* $Header$ */
|
||||
|
||||
/* ALLOCDEF "id_list" */
|
||||
|
||||
#define is_anon_idf(x) ((x)->id_text[0] == '#')
|
||||
|
||||
extern struct idf
|
||||
*gen_anon_idf();
|
||||
@@ -1,4 +0,0 @@
|
||||
/* Accepted if many characters of long names are significant */
|
||||
abcdefghijklmnopr() { }
|
||||
abcdefghijklmnopq() { }
|
||||
main() { }
|
||||
@@ -1,4 +0,0 @@
|
||||
/* $Header$ */
|
||||
|
||||
#define IDFSIZE 256
|
||||
#define NUMSIZE 256
|
||||
@@ -1,144 +0,0 @@
|
||||
/* P R I N T R O U T I N E S */
|
||||
|
||||
#include <system.h>
|
||||
#include <em_arith.h>
|
||||
|
||||
#define SSIZE 1024 /* string-buffer size for print routines */
|
||||
|
||||
char *long2str();
|
||||
|
||||
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 int 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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -1,295 +0,0 @@
|
||||
/* @cc tab.c -o $INSTALLDIR/tab@
|
||||
tab - table generator
|
||||
|
||||
Author: Erik Baalbergen (..tjalk!erikb)
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
static char *RcsId = "$Header$";
|
||||
|
||||
#define MAXTAB 10000
|
||||
#define MAXBUF 10000
|
||||
#define COMCOM '-'
|
||||
#define FILECOM '%'
|
||||
|
||||
int InputForm = 'c';
|
||||
char OutputForm[MAXBUF] = "%s,\n";
|
||||
int TabSize = 257;
|
||||
char *Table[MAXTAB];
|
||||
char *Name;
|
||||
char *ProgCall;
|
||||
|
||||
main(argc, argv)
|
||||
char *argv[];
|
||||
{
|
||||
ProgCall = *argv++;
|
||||
argc--;
|
||||
while (argc-- > 0) {
|
||||
if (**argv == COMCOM) {
|
||||
option(*argv++);
|
||||
}
|
||||
else {
|
||||
process(*argv++, InputForm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
char *
|
||||
Salloc(s)
|
||||
char *s;
|
||||
{
|
||||
char *malloc();
|
||||
char *ns = malloc(strlen(s) + 1);
|
||||
|
||||
if (ns) {
|
||||
strcpy(ns, s);
|
||||
}
|
||||
return ns;
|
||||
}
|
||||
|
||||
option(str)
|
||||
char *str;
|
||||
{
|
||||
/* note that *str indicates the source of the option:
|
||||
either COMCOM (from command line) or FILECOM (from a file).
|
||||
*/
|
||||
switch (*++str) {
|
||||
|
||||
case ' ': /* command */
|
||||
case '\t':
|
||||
case '\0':
|
||||
break;
|
||||
case 'I':
|
||||
InputForm = *++str;
|
||||
break;
|
||||
case 'f':
|
||||
if (*++str == '\0') {
|
||||
fprintf(stderr, "%s: -f: name expected\n", ProgCall);
|
||||
exit(1);
|
||||
}
|
||||
DoFile(str);
|
||||
break;
|
||||
case 'F':
|
||||
sprintf(OutputForm, "%s\n", ++str);
|
||||
break;
|
||||
case 'T':
|
||||
printf("%s\n", ++str);
|
||||
break;
|
||||
case 'p':
|
||||
PrintTable();
|
||||
break;
|
||||
case 'C':
|
||||
ClearTable();
|
||||
break;
|
||||
case 'S':
|
||||
{
|
||||
register i = stoi(++str);
|
||||
|
||||
if (i <= 0 || i > MAXTAB) {
|
||||
fprintf(stderr, "%s: size would exceed maximum\n",
|
||||
ProgCall);
|
||||
}
|
||||
else {
|
||||
TabSize = i;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
fprintf(stderr, "%s: bad option -%s\n", ProgCall, str);
|
||||
}
|
||||
}
|
||||
|
||||
ClearTable()
|
||||
{
|
||||
register i;
|
||||
|
||||
for (i = 0; i < MAXTAB; i++) {
|
||||
Table[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
PrintTable()
|
||||
{
|
||||
register i;
|
||||
|
||||
for (i = 0; i < TabSize; i++) {
|
||||
if (Table[i]) {
|
||||
printf(OutputForm, Table[i]);
|
||||
}
|
||||
else {
|
||||
printf(OutputForm, "0");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
process(str, format)
|
||||
char *str;
|
||||
{
|
||||
char *cstr = str;
|
||||
char *Name = cstr; /* overwrite original string! */
|
||||
|
||||
/* strip of the entry name
|
||||
*/
|
||||
while (*str && *str != ':') {
|
||||
if (*str == '\\') {
|
||||
++str;
|
||||
}
|
||||
*cstr++ = *str++;
|
||||
}
|
||||
|
||||
if (*str != ':') {
|
||||
fprintf(stderr, "%s: bad specification: \"%s\", ignored\n",
|
||||
ProgCall, Name);
|
||||
return 0;
|
||||
}
|
||||
*cstr = '\0';
|
||||
str++;
|
||||
|
||||
switch (format) {
|
||||
|
||||
case 'c':
|
||||
return c_proc(str, Name);
|
||||
default:
|
||||
fprintf(stderr, "%s: bad input format\n", ProgCall);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
c_proc(str, Name)
|
||||
char *str;
|
||||
char *Name;
|
||||
{
|
||||
int ch, ch2;
|
||||
int quoted();
|
||||
|
||||
while (*str) {
|
||||
if (*str == '\\') {
|
||||
ch = quoted(&str);
|
||||
}
|
||||
else {
|
||||
ch = *str++;
|
||||
}
|
||||
if (*str == '-') {
|
||||
if (*++str == '\\') {
|
||||
ch2 = quoted(&str);
|
||||
}
|
||||
else {
|
||||
if (ch2 = *str++);
|
||||
else str--;
|
||||
}
|
||||
if (ch > ch2) {
|
||||
fprintf(stderr, "%s: bad range\n", ProgCall);
|
||||
return 0;
|
||||
}
|
||||
if (ch >= 0 && ch2 <= 255)
|
||||
while (ch <= ch2)
|
||||
Table[ch++] = Salloc(Name);
|
||||
}
|
||||
else {
|
||||
if (ch >= 0 && ch <= 255)
|
||||
Table[ch] = Salloc(Name);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
quoted(pstr)
|
||||
char **pstr;
|
||||
{
|
||||
register int ch;
|
||||
register int i;
|
||||
register char *str = *pstr;
|
||||
|
||||
if ((*++str >= '0') && (*str <= '9')) {
|
||||
ch = 0;
|
||||
for (i = 0; i < 3; i++) {
|
||||
ch = 8 * ch + *str - '0';
|
||||
if (*++str < '0' || *str > '9')
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch (*str++) {
|
||||
|
||||
case 'n':
|
||||
ch = '\n';
|
||||
break;
|
||||
case 't':
|
||||
ch = '\t';
|
||||
break;
|
||||
case 'b':
|
||||
ch = '\b';
|
||||
break;
|
||||
case 'r':
|
||||
ch = '\r';
|
||||
break;
|
||||
case 'f':
|
||||
ch = '\f';
|
||||
break;
|
||||
default :
|
||||
ch = *str;
|
||||
}
|
||||
}
|
||||
*pstr = str;
|
||||
return ch & 0377;
|
||||
}
|
||||
|
||||
int
|
||||
stoi(str)
|
||||
char *str;
|
||||
{
|
||||
register i = 0;
|
||||
|
||||
while (*str >= '0' && *str <= '9') {
|
||||
i = i * 10 + *str++ - '0';
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
char *
|
||||
getline(s, n, fp)
|
||||
char *s;
|
||||
FILE *fp;
|
||||
{
|
||||
register c = getc(fp);
|
||||
char *str = s;
|
||||
|
||||
while (n--) {
|
||||
if (c == EOF) {
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
if (c == '\n') {
|
||||
*str++ = '\0';
|
||||
return s;
|
||||
}
|
||||
*str++ = c;
|
||||
c = getc(fp);
|
||||
}
|
||||
s[n - 1] = '\0';
|
||||
return s;
|
||||
}
|
||||
|
||||
#define BUFSIZE 1024
|
||||
|
||||
DoFile(name)
|
||||
char *name;
|
||||
{
|
||||
char text[BUFSIZE];
|
||||
FILE *fp;
|
||||
|
||||
if ((fp = fopen(name, "r")) == NULL) {
|
||||
fprintf(stderr, "%s: cannot read file %s\n", ProgCall, name);
|
||||
exit(1);
|
||||
}
|
||||
while (getline(text, BUFSIZE, fp) != NULL) {
|
||||
if (text[0] == FILECOM) {
|
||||
option(text);
|
||||
}
|
||||
else {
|
||||
process(text, InputForm);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
IMPLEMENTATION MODULE ASCII;
|
||||
BEGIN
|
||||
END ASCII.
|
||||
@@ -1,131 +0,0 @@
|
||||
#include <m2_traps.h>
|
||||
;
|
||||
; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||
; See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||
;
|
||||
;
|
||||
; Module: CARDINAL operations with overflow checking
|
||||
; Author: Ceriel J.H. Jacobs
|
||||
; Version: $Header$
|
||||
;
|
||||
|
||||
mes 2,EM_WSIZE,EM_PSIZE
|
||||
|
||||
exp $addu
|
||||
exp $subu
|
||||
exp $mulu
|
||||
#if EM_WSIZE < EM_LSIZE
|
||||
exp $addul
|
||||
exp $subul
|
||||
exp $mulul
|
||||
#endif
|
||||
|
||||
pro $addu,0
|
||||
loc -1
|
||||
lol 0
|
||||
sbu EM_WSIZE
|
||||
lol EM_WSIZE
|
||||
cmu EM_WSIZE
|
||||
zge *1
|
||||
loc M2_UOVFL
|
||||
trp
|
||||
1
|
||||
lol 0
|
||||
lol EM_WSIZE
|
||||
adu EM_WSIZE
|
||||
stl EM_WSIZE
|
||||
ret 0
|
||||
end 0
|
||||
|
||||
#if EM_WSIZE < EM_LSIZE
|
||||
pro $addul,0
|
||||
ldc -1
|
||||
ldl 0
|
||||
sbu EM_LSIZE
|
||||
ldl EM_LSIZE
|
||||
cmu EM_LSIZE
|
||||
zge *1
|
||||
loc M2_UOVFL
|
||||
trp
|
||||
1
|
||||
ldl 0
|
||||
ldl EM_LSIZE
|
||||
adu EM_LSIZE
|
||||
sdl EM_LSIZE
|
||||
ret 0
|
||||
end 0
|
||||
#endif
|
||||
|
||||
pro $mulu,0
|
||||
lol 0
|
||||
zeq *1
|
||||
loc -1
|
||||
lol 0
|
||||
dvu EM_WSIZE
|
||||
lol EM_WSIZE
|
||||
cmu EM_WSIZE
|
||||
zge *1
|
||||
loc M2_UOVFL
|
||||
trp
|
||||
1
|
||||
lol 0
|
||||
lol EM_WSIZE
|
||||
mlu EM_WSIZE
|
||||
stl EM_WSIZE
|
||||
ret 0
|
||||
end 0
|
||||
|
||||
#if EM_WSIZE < EM_LSIZE
|
||||
pro $mulul,0
|
||||
ldl 0
|
||||
ldc 0
|
||||
cmu EM_LSIZE
|
||||
zeq *1
|
||||
ldc -1
|
||||
ldl 0
|
||||
dvu EM_LSIZE
|
||||
ldl EM_LSIZE
|
||||
cmu EM_LSIZE
|
||||
zge *1
|
||||
loc M2_UOVFL
|
||||
trp
|
||||
1
|
||||
ldl 0
|
||||
ldl EM_LSIZE
|
||||
mlu EM_LSIZE
|
||||
sdl EM_LSIZE
|
||||
ret 0
|
||||
end 0
|
||||
#endif
|
||||
|
||||
pro $subu,0
|
||||
lol EM_WSIZE
|
||||
lol 0
|
||||
cmu EM_WSIZE
|
||||
zge *1
|
||||
loc M2_UUVFL
|
||||
trp
|
||||
1
|
||||
lol EM_WSIZE
|
||||
lol 0
|
||||
sbu EM_WSIZE
|
||||
stl EM_WSIZE
|
||||
ret 0
|
||||
end 0
|
||||
|
||||
#if EM_WSIZE < EM_LSIZE
|
||||
pro $subul,0
|
||||
ldl EM_LSIZE
|
||||
ldl 0
|
||||
cmu EM_LSIZE
|
||||
zge *1
|
||||
loc M2_UUVFL
|
||||
trp
|
||||
1
|
||||
ldl EM_LSIZE
|
||||
ldl 0
|
||||
sbu EM_LSIZE
|
||||
sdl EM_LSIZE
|
||||
ret 0
|
||||
end 0
|
||||
#endif
|
||||
@@ -1,13 +0,0 @@
|
||||
(*$Foreign*)
|
||||
DEFINITION MODULE FIFFEF;
|
||||
|
||||
PROCEDURE FIF(arg1, arg2: LONGREAL; VAR intres: LONGREAL) : LONGREAL;
|
||||
(* multiplies arg1 and arg2, and returns the integer part of the
|
||||
result in "intres" and the fraction part as the function result.
|
||||
*)
|
||||
|
||||
PROCEDURE FEF(arg: LONGREAL; VAR exp: INTEGER) : LONGREAL;
|
||||
(* splits "arg" in mantissa and a base-2 exponent.
|
||||
The mantissa is returned, and the exponent is left in "exp".
|
||||
*)
|
||||
END FIFFEF.
|
||||
@@ -1,46 +0,0 @@
|
||||
#
|
||||
mes 2,EM_WSIZE,EM_PSIZE
|
||||
|
||||
#define ARG1 0
|
||||
#define ARG2 EM_DSIZE
|
||||
#define IRES 2*EM_DSIZE
|
||||
|
||||
; FIF is called with three parameters:
|
||||
; - address of integer part result (IRES)
|
||||
; - float two (ARG2)
|
||||
; - float one (ARG1)
|
||||
; and returns an EM_DSIZE-byte floating point number
|
||||
; Definition:
|
||||
; PROCEDURE FIF(ARG1, ARG2: LONGREAL; VAR IRES: LONGREAL) : LONGREAL;
|
||||
|
||||
exp $FIF
|
||||
pro $FIF,0
|
||||
lal 0
|
||||
loi 2*EM_DSIZE
|
||||
fif EM_DSIZE
|
||||
lal IRES
|
||||
loi EM_PSIZE
|
||||
sti EM_DSIZE
|
||||
ret EM_DSIZE
|
||||
end ?
|
||||
|
||||
#define FARG 0
|
||||
#define ERES EM_DSIZE
|
||||
|
||||
; FEF is called with two parameters:
|
||||
; - address of base 2 exponent result (ERES)
|
||||
; - floating point number to be split (FARG)
|
||||
; and returns an EM_DSIZE-byte floating point number (the mantissa)
|
||||
; Definition:
|
||||
; PROCEDURE FEF(FARG: LONGREAL; VAR ERES: integer): LONGREAL;
|
||||
|
||||
exp $FEF
|
||||
pro $FEF,0
|
||||
lal FARG
|
||||
loi EM_DSIZE
|
||||
fef EM_DSIZE
|
||||
lal ERES
|
||||
loi EM_PSIZE
|
||||
sti EM_WSIZE
|
||||
ret EM_DSIZE
|
||||
end ?
|
||||
@@ -1,8 +0,0 @@
|
||||
static char m[] = "Warning: FOR-loop control variable was changed in the body";
|
||||
_forloopchk(a,b)
|
||||
unsigned a, b;
|
||||
{
|
||||
if (a != b) {
|
||||
Traps_Message(m , 0, sizeof(m) - 2, 1);
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
HOME = ../../..
|
||||
DEFDIR = $(HOME)/lib/m2
|
||||
|
||||
SOURCES = ASCII.def EM.def MathLib0.def Processes.def \
|
||||
RealInOut.def Storage.def Arguments.def Conversion.def \
|
||||
random.def Semaphores.def Unix.def RealConver.def \
|
||||
Strings.def InOut.def Terminal.def \
|
||||
Mathlib.def PascalIO.def Traps.def CSP.def \
|
||||
Epilogue.def Streams.def ArraySort.def StripUnix.def \
|
||||
Termcap.def XXTermcap.def
|
||||
|
||||
all:
|
||||
clean:
|
||||
cmp:
|
||||
|
||||
pr:
|
||||
@pr Makefile $(SOURCES)
|
||||
opr:
|
||||
make pr | opr
|
||||
|
||||
install:
|
||||
-mkdir $(DEFDIR)
|
||||
cp $(SOURCES) $(DEFDIR)
|
||||
@@ -1,3 +0,0 @@
|
||||
DEFINITION MODULE TTY;
|
||||
PROCEDURE isatty(fd: INTEGER): BOOLEAN;
|
||||
END TTY.
|
||||
@@ -1,19 +0,0 @@
|
||||
#
|
||||
(*$R-*)
|
||||
IMPLEMENTATION MODULE TTY;
|
||||
FROM Unix IMPORT ioctl;
|
||||
FROM SYSTEM IMPORT ADR;
|
||||
PROCEDURE isatty(fd: INTEGER): BOOLEAN;
|
||||
VAR buf: ARRAY[1..100] OF CHAR;
|
||||
BEGIN
|
||||
#ifdef __USG
|
||||
RETURN ioctl(fd, INTEGER(ORD('T') * 256 + 1), ADR(buf)) >= 0;
|
||||
#else
|
||||
#ifdef __BSD4_2
|
||||
RETURN ioctl(fd, INTEGER(ORD('t') * 256 + 8 + 6*65536 + 40000000H), ADR(buf)) >= 0;
|
||||
#else
|
||||
RETURN ioctl(fd, INTEGER(ORD('t') * 256 + 8), ADR(buf)) >= 0;
|
||||
#endif
|
||||
#endif
|
||||
END isatty;
|
||||
END TTY.
|
||||
@@ -1,29 +0,0 @@
|
||||
#
|
||||
|
||||
; $Header$
|
||||
;
|
||||
; (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||
;
|
||||
; This product is part of the Amsterdam Compiler Kit.
|
||||
;
|
||||
; Permission to use, sell, duplicate or disclose this software must be
|
||||
; obtained in writing. Requests for such permissions may be sent to
|
||||
;
|
||||
; Dr. Andrew S. Tanenbaum
|
||||
; Wiskundig Seminarium
|
||||
; Vrije Universiteit
|
||||
; Postbox 7161
|
||||
; 1007 MC Amsterdam
|
||||
; The Netherlands
|
||||
;
|
||||
;
|
||||
|
||||
mes 2,EM_WSIZE,EM_PSIZE
|
||||
|
||||
; _hol0 return the address of the ABS block (hol0)
|
||||
|
||||
exp $_hol0
|
||||
pro $_hol0,0
|
||||
lae 0
|
||||
ret EM_PSIZE
|
||||
end ?
|
||||
@@ -1,31 +0,0 @@
|
||||
#
|
||||
;
|
||||
; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||
; See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||
;
|
||||
;
|
||||
; Module: range checks for INTEGER, now for array indexing
|
||||
; Author: Ceriel J.H. Jacobs
|
||||
; Version: $Header$
|
||||
;
|
||||
#include <em_abs.h>
|
||||
|
||||
mes 2,EM_WSIZE,EM_PSIZE
|
||||
exp $rcka
|
||||
pro $rcka, 0
|
||||
|
||||
lol EM_PSIZE
|
||||
zlt *1 ; lower bound always 0
|
||||
lol EM_PSIZE
|
||||
lal 0
|
||||
loi EM_PSIZE
|
||||
adp EM_WSIZE
|
||||
loi EM_WSIZE
|
||||
cmi EM_WSIZE
|
||||
zgt *1
|
||||
ret 0
|
||||
1
|
||||
loc EARRAY
|
||||
trp
|
||||
ret 0
|
||||
end 0
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user