Eliminate make.allocd --- something about it makes Windows unhappy and it

doesn't add value anyway.
This commit is contained in:
David Given 2022-07-16 19:34:25 +02:00
parent 1a861669c5
commit 04f723b406
22 changed files with 52 additions and 297 deletions

View file

@ -18,6 +18,7 @@
#include <alloc.h>
#include <em_arith.h>
#include <em_label.h>
#include <stdlib.h>
#include "parameters.h"
#include "idf.h"

View file

@ -34,55 +34,10 @@ normalrule {
}
}
local xh_files = {
"./def.xh",
"./node.xh",
"./real.xh",
"./type.xh",
}
for _, f in ipairs(filenamesof(xh_files)) do
local name = replace(basename(f), "%.xh$", "")
normalrule {
name = name.."_h",
ins = {
"./make.allocd",
f
},
outleaves = { name..".h" },
commands = {
"%{ins[1]} < %{ins[2]} > %{outs}",
}
}
end
local xc_files = {
"./casestat.xc",
"./scope.xc",
"./tmpvar.xc",
}
for _, f in ipairs(filenamesof(xc_files)) do
local name = replace(basename(f), "%.xc$", "")
normalrule {
name = name.."_c",
ins = {
"./make.allocd",
f
},
outleaves = { name..".c" },
commands = {
"%{ins[1]} < %{ins[2]} > %{outs}"
}
}
end
normalrule {
name = "next_c",
ins = {
"./make.next",
xh_files,
xc_files
},
outleaves = { "next.c" },
commands = {
@ -110,6 +65,12 @@ tabgen {
cprogram {
name = "em_m2",
srcs = {
"+chartab_c",
"+next_c",
"+symbol2str_c",
"./LLlex.c",
"./LLmessage.c",
"./casestat.c",
"./chk_expr.c",
"./code.c",
"./cstoper.c",
@ -120,33 +81,23 @@ cprogram {
"./error.c",
"./idf.c",
"./input.c",
"./LLlex.c",
"./LLmessage.c",
"./lookup.c",
"./main.c",
"./misc.c",
"./node.c",
"./options.c",
"./scope.c",
"./stab.c",
"./tmpvar.c",
"./tokenname.c",
"./type.c",
"./typequiv.c",
"./walk.c",
"+casestat_c",
"+next_c",
"+scope_c",
"+symbol2str_c",
"+tmpvar_c",
"+chartab_c",
matching(filenamesof("+llgen"), "%.c$"),
},
deps = {
"+def_h",
"+llgen",
"+node_h",
"+parameters_h",
"+real_h",
"+type_h",
"h+emheaders",
"lang/m2/include+headers",
"modules+headers",

View file

@ -19,6 +19,7 @@
#include "parameters.h"
#include "debug.h"
#include <stdlib.h>
#include <assert.h>
#include "em_label.h"
#include "em_arith.h"
@ -50,7 +51,8 @@ struct switch_hdr {
*/
};
/* STATICALLOCDEF "switch_hdr" 5 */
#define new_switch_hdr() ((struct switch_hdr*) calloc(1, sizeof(struct switch_hdr)))
#define free_switch_hdr(p) free(p)
struct case_entry {
struct case_entry *ce_next; /* next in list */
@ -60,7 +62,8 @@ struct case_entry {
/* STATICALLOCDEF "case_entry" 20 */
#define new_case_entry() ((struct case_entry*) calloc(1, sizeof(struct case_entry)))
#define free_case_entry(p) free(p)

View file

@ -15,6 +15,7 @@
#include "parameters.h"
#include "debug.h"
#include <stdlib.h>
#include <assert.h>
#include "em_arith.h"
#include "em_label.h"

View file

@ -132,7 +132,8 @@ struct def { /* list of definitions for a name */
};
/* ALLOCDEF "def" 50 */
#define new_def() ((struct def*) calloc(1, sizeof(struct def)))
#define free_def(p) free(p)
#define NULLDEF ((struct def *) 0)
@ -150,4 +151,4 @@ struct def * DefineLocalModule(struct idf *id);
void CheckWithDef(register struct def *df, struct type *tp);
void end_definition_list(register struct def **pdf);
#endif /* DEF_H_ */
#endif /* DEF_H_ */

View file

@ -19,6 +19,7 @@
#include "parameters.h"
#include "debug.h"
#include <stdlib.h>
#include <assert.h>
#include "em_arith.h"
#include "em_label.h"

View file

@ -23,6 +23,7 @@
#include <varargs.h>
#endif
#include <stdlib.h>
#include <system.h>
#include <em_arith.h>
#include <em_label.h>

View file

@ -15,6 +15,7 @@
#include <em_arith.h>
#include <em_label.h>
#include <assert.h>
#include <stdlib.h>
#include "lookup.h"
#include "LLlex.h"

View file

@ -13,6 +13,7 @@
#include "debug.h"
#include <assert.h>
#include <stdlib.h>
#include "system.h"
#include "em_arith.h"
#include "em_label.h"

View file

@ -1,28 +0,0 @@
#!/bin/sh
sed -e '
s:^.*[ ]ALLOCDEF[ ].*"\(.*\)"[ ]*\([0-9][0-9]*\).*$:\
/* allocation definitions of struct \1 */\
extern char *st_alloc();\
extern struct \1 *h_\1;\
#ifdef DEBUG\
extern int cnt_\1;\
extern char *std_alloc();\
#define new_\1() ((struct \1 *) std_alloc((char **)\&h_\1, sizeof(struct \1), \2, \&cnt_\1))\
#else\
#define new_\1() ((struct \1 *) st_alloc((char **)\&h_\1, sizeof(struct \1), \2))\
#endif\
#define free_\1(p) st_free(p, \&h_\1, sizeof(struct \1))\
:' -e '
s:^.*[ ]STATICALLOCDEF[ ].*"\(.*\)"[ ]*\([0-9][0-9]*\).*$:\
/* allocation definitions of struct \1 */\
extern char *st_alloc();\
struct \1 *h_\1;\
#ifdef DEBUG\
int cnt_\1;\
#define new_\1() ((struct \1 *) std_alloc((char **)\&h_\1, sizeof(struct \1), \2, \&cnt_\1))\
#else\
#define new_\1() ((struct \1 *) st_alloc((char **)\&h_\1, sizeof(struct \1), \2))\
#endif\
#define free_\1(p) st_free(p, \&h_\1, sizeof(struct \1))\
:' | tr -d '\r'

View file

@ -1,35 +0,0 @@
#!/bin/sh
: Update Files from database
PATH=/bin:/usr/bin
case $# in
1) ;;
*) echo use: $0 file >&2
exit 1
esac
(
IFCOMMAND="if [ -r \$FN ] ;\
then if cmp -s \$FN \$TMP;\
then rm \$TMP;\
else mv \$TMP \$FN;\
echo update \$FN;\
fi;\
else mv \$TMP \$FN;\
echo create \$FN;\
fi"
echo 'TMP=.uf$$'
echo 'FN=$TMP'
echo 'cat >$TMP <<\!EOF!'
sed -n '/^!File:/,${
/^$/d
/^!File:[ ]*\(.*\)$/s@@!EOF!\
'"$IFCOMMAND"'\
FN=\1\
cat >$TMP <<\\!EOF!@
p
}' $1
echo '!EOF!'
echo $IFCOMMAND
) | eval "$(cat)"

View file

@ -16,6 +16,7 @@
#include <em_arith.h>
#include <alloc.h>
#include <system.h>
#include <stdlib.h>
#include "LLlex.h"
#include "def.h"

View file

@ -52,9 +52,8 @@ struct node {
#define nd_RVAL nd_token.TOK_RVAL
};
/* ALLOCDEF "node" 50 */
#define new_node() ((struct node*) calloc(1, sizeof(struct node)))
#define free_node(p) free(p)
extern struct node *dot2node(), *dot2leaf(), *getnode();
@ -76,4 +75,4 @@ void FreeNode(register struct node *nd);
int NodeCrash(register struct node* expp, label exit_label, int end_reached);
int PNodeCrash(struct node **expp, int flags);
#endif /* NODE_H_ */
#endif /* NODE_H_ */

View file

@ -14,6 +14,7 @@
#include <em_arith.h>
#include <em_label.h>
#include <alloc.h>
#include <stdlib.h>
#include "type.h"
#include "main.h"

View file

@ -1,158 +0,0 @@
# $Id$
# make Modula-2 compiler
#PARAMS do not remove this line!
UTIL_BIN = \
$(UTIL_HOME)/bin
SRC_DIR = \
$(SRC_HOME)/lang/m2/comp
TABGEN= $(UTIL_BIN)/tabgen
LLGEN = $(UTIL_BIN)/LLgen
LLGENOPTIONS = \
-n
SRC_G = $(SRC_DIR)/program.g $(SRC_DIR)/declar.g \
$(SRC_DIR)/expression.g $(SRC_DIR)/statement.g
GEN_G = tokenfile.g
GFILES= $(GEN_G) $(SRC_G)
SRC_C = $(SRC_DIR)/LLlex.c $(SRC_DIR)/LLmessage.c $(SRC_DIR)/error.c \
$(SRC_DIR)/main.c $(SRC_DIR)/tokenname.c $(SRC_DIR)/idf.c \
$(SRC_DIR)/input.c $(SRC_DIR)/type.c $(SRC_DIR)/def.c \
$(SRC_DIR)/misc.c $(SRC_DIR)/enter.c $(SRC_DIR)/defmodule.c \
$(SRC_DIR)/typequiv.c $(SRC_DIR)/node.c $(SRC_DIR)/cstoper.c \
$(SRC_DIR)/chk_expr.c $(SRC_DIR)/options.c $(SRC_DIR)/walk.c \
$(SRC_DIR)/desig.c $(SRC_DIR)/code.c $(SRC_DIR)/lookup.c \
$(SRC_DIR)/stab.c
GEN_C = tokenfile.c program.c declar.c expression.c statement.c \
symbol2str.c char.c Lpars.c Lncor.c casestat.c tmpvar.c scope.c next.c
CFILES= $(SRC_C) $(GEN_C)
SRC_H = $(SRC_DIR)/LLlex.h $(SRC_DIR)/chk_expr.h $(SRC_DIR)/class.h \
$(SRC_DIR)/debug.h $(SRC_DIR)/desig.h $(SRC_DIR)/f_info.h \
$(SRC_DIR)/idf.h $(SRC_DIR)/input.h $(SRC_DIR)/main.h \
$(SRC_DIR)/misc.h $(SRC_DIR)/scope.h $(SRC_DIR)/standards.h \
$(SRC_DIR)/tokenname.h $(SRC_DIR)/walk.h $(SRC_DIR)/warning.h \
$(SRC_DIR)/SYSTEM.h
GEN_H = errout.h idfsize.h numsize.h strsize.h target_sizes.h bigresult.h \
inputtype.h density.h squeeze.h nocross.h nostrict.h def.h debugcst.h \
type.h Lpars.h node.h strict3rd.h real.h use_insert.h dbsymtab.h \
uns_arith.h def.h type.h node.h real.h
HFILES= $(GEN_H) $(SRC_H)
NEXTFILES = \
$(SRC_DIR)/def.H $(SRC_DIR)/type.H $(SRC_DIR)/node.H $(SRC_DIR)/real.H \
$(SRC_DIR)/scope.C $(SRC_DIR)/tmpvar.C $(SRC_DIR)/casestat.C
all: make.main
make -f make.main main
install: all
cp main $(TARGET_HOME)/lib.bin/em_m2
if [ $(DO_MACHINE_INDEP) = y ] ; \
then mk_manpage $(SRC_DIR)/em_m2.6 $(TARGET_HOME) ; \
mk_manpage $(SRC_DIR)/modula-2.1 $(TARGET_HOME) ; \
fi
cmp: all
-cmp main $(TARGET_HOME)/lib.bin/em_m2
opr:
make pr | opr
pr:
@pr $(SRC_DIR)/proto.make $(SRC_DIR)/proto.main Parameters \
$(SRC_DIR)/char.tab $(SRC_G) $(SRC_H) $(NEXTFILES) $(SRC_C)
lint: make.main
make -f make.main lint
Cfiles: hfiles LLfiles $(GEN_C) $(GEN_H) Makefile
echo $(CFILES) | tr ' ' '\012' > Cfiles
echo $(HFILES) | tr ' ' '\012' >> Cfiles
resolved: Cfiles
CC="$(CC)" UTIL_HOME="$(UTIL_HOME)" do_resolve `cat Cfiles` > Cfiles.new
-if cmp -s Cfiles Cfiles.new ; then rm -f Cfiles.new ; else mv Cfiles.new Cfiles ; fi
touch resolved
# there is no file called "dependencies"; we want dependencies checked
# every time. This means that make.main is made every time. Oh well ...
# it does not take much time.
dependencies: resolved
do_deps `grep '.c$$' Cfiles`
make.main: dependencies make_macros lists $(SRC_DIR)/proto.main
rm_deps $(SRC_DIR)/proto.main | sed -e '/^.PARAMS/r make_macros' -e '/^.LISTS/r lists' > make.main
cat *.dep >> make.main
make_macros: Makefile
echo 'SRC_DIR=$(SRC_DIR)' > make_macros
echo 'UTIL_HOME=$(UTIL_HOME)' >> make_macros
echo 'TARGET_HOME=$(TARGET_HOME)' >> make_macros
echo 'CC=$(CC)' >> make_macros
echo 'COPTIONS=$(COPTIONS)' >> make_macros
echo 'LDOPTIONS=$(LDOPTIONS)' >> make_macros
echo 'LINT=$(LINT)' >> make_macros
echo 'LINTSUF=$(LINTSUF)' >> make_macros
echo 'LINTPREF=$(LINTPREF)' >> make_macros
echo 'LINTOPTIONS=$(LINTOPTIONS)' >> make_macros
echo 'SUF=$(SUF)' >> make_macros
echo 'LIBSUF=$(LIBSUF)' >> make_macros
echo 'CC_AND_MKDEP=$(CC_AND_MKDEP)' >> make_macros
lists: Cfiles
echo "C_SRC = \\" > lists
echo $(CFILES) >> lists
echo "OBJ = \\" >> lists
echo $(CFILES) | sed -e 's|[^ ]*/||g' -e 's/\.c/.$$(SUF)/g' >> lists
clean:
-make -f make.main clean
rm -f $(GEN_C) $(GEN_G) $(GEN_H) hfiles LLfiles Cfiles LL.output
rm -f resolved *.dep lists make.main make_macros
LLfiles: $(GFILES)
$(LLGEN) $(LLGENOPTIONS) $(GFILES)
@touch LLfiles
@if [ -f Lncor.c ] ; then : ; else touch Lncor.c ; fi
hfiles: Parameters $(SRC_DIR)/make.hfiles
$(SRC_DIR)/make.hfiles Parameters
touch hfiles
tokenfile.g: $(SRC_DIR)/tokenname.c $(SRC_DIR)/make.tokfile
$(SRC_DIR)/make.tokfile <$(SRC_DIR)/tokenname.c >tokenfile.g
symbol2str.c: $(SRC_DIR)/tokenname.c $(SRC_DIR)/make.tokcase
$(SRC_DIR)/make.tokcase <$(SRC_DIR)/tokenname.c >symbol2str.c
def.h: $(SRC_DIR)/make.allocd $(SRC_DIR)/def.H
$(SRC_DIR)/make.allocd < $(SRC_DIR)/def.H > def.h
type.h: $(SRC_DIR)/make.allocd $(SRC_DIR)/type.H
$(SRC_DIR)/make.allocd < $(SRC_DIR)/type.H > type.h
real.h: $(SRC_DIR)/make.allocd $(SRC_DIR)/real.H
$(SRC_DIR)/make.allocd < $(SRC_DIR)/real.H > real.h
node.h: $(SRC_DIR)/make.allocd $(SRC_DIR)/node.H
$(SRC_DIR)/make.allocd < $(SRC_DIR)/node.H > node.h
scope.c: $(SRC_DIR)/make.allocd $(SRC_DIR)/scope.C
$(SRC_DIR)/make.allocd < $(SRC_DIR)/scope.C > scope.c
tmpvar.c: $(SRC_DIR)/make.allocd $(SRC_DIR)/tmpvar.C
$(SRC_DIR)/make.allocd < $(SRC_DIR)/tmpvar.C > tmpvar.c
casestat.c: $(SRC_DIR)/make.allocd $(SRC_DIR)/casestat.C
$(SRC_DIR)/make.allocd < $(SRC_DIR)/casestat.C > casestat.c
next.c: $(NEXTFILES) $(SRC_DIR)/make.next
$(SRC_DIR)/make.next $(NEXTFILES) > next.c
char.c: $(SRC_DIR)/char.tab
$(TABGEN) -f$(SRC_DIR)/char.tab >char.c

View file

@ -16,4 +16,5 @@ struct real {
flt_arith r_val;
};
/* ALLOCDEF "real" 20 */
#define new_real() ((struct real*) calloc(1, sizeof(struct real)))
#define free_real(p) free(p)

View file

@ -12,6 +12,7 @@
#include "parameters.h"
#include "debug.h"
#include <stdlib.h>
#include <assert.h>
#include "alloc.h"
#include "em_arith.h"
@ -31,9 +32,11 @@ struct scopelist *CurrVis, *GlobalVis;
extern int proclevel;
extern char options[];
/* STATICALLOCDEF "scope" 10 */
#define new_scope() ((struct scope*) calloc(1, sizeof(struct scope)))
#define free_scope(p) free(p)
/* STATICALLOCDEF "scopelist" 10 */
#define new_scopelist() ((struct scopelist*) calloc(1, sizeof(struct scopelist)))
#define free_scopelist(p) free(p)
static int sc_count;

View file

@ -25,6 +25,7 @@
#include <em_reg.h>
#include <alloc.h>
#include <assert.h>
#include <stdlib.h>
#include "LLlex.h"
#include "def.h"
@ -32,13 +33,15 @@
#include "scope.h"
#include "tmpvar.h"
#include "main.h"
#include "tmpvar.h"
struct tmpvar {
struct tmpvar *t_next;
arith t_offset; /* offset from LocalBase */
};
/* STATICALLOCDEF "tmpvar" 10 */
#define new_tmpvar() ((struct tmpvar*) calloc(1, sizeof(struct tmpvar)))
#define free_tmpvar(p) free(p)
static struct tmpvar *TmpInts, /* for integer temporaries */
*TmpPtrs; /* for pointer temporaries */

View file

@ -9,6 +9,7 @@
/* $Id$ */
#include <stdlib.h>
#include "parameters.h"
#include "tokenname.h"
#include "Lpars.h"

View file

@ -12,6 +12,7 @@
#include "parameters.h"
#include "debug.h"
#include <stdlib.h>
#include <assert.h>
#include <ack_string.h>
#include <alloc.h>

View file

@ -24,8 +24,8 @@ struct paramlist { /* structure for parameterlist of a PROCEDURE */
};
struct paramlist;
/* ALLOCDEF "paramlist" 20 */
#define new_paramlist() ((struct paramlist*) calloc(1, sizeof(struct paramlist)))
#define free_paramlist(p) free(p)
struct enume {
struct def *en_enums; /* Definitions of enumeration literals */
@ -36,7 +36,8 @@ struct enume {
#define enm_rck tp_value.tp_enum->en_rck
};
/* ALLOCDEF "enume" 5 */
#define new_enume() ((struct enume*) calloc(1, sizeof(struct enume)))
#define free_enume(p) free(p)
struct subrange {
arith su_lb, su_ub; /* lower bound and upper bound */
@ -46,7 +47,8 @@ struct subrange {
#define sub_rck tp_value.tp_subrange->su_rck
};
/* ALLOCDEF "subrange" 5 */
#define new_subrange() ((struct subrange*) calloc(1, sizeof(struct subrange)))
#define free_subrange(p) free(p)
struct array {
struct type *ar_elem; /* type of elements */
@ -61,7 +63,8 @@ struct array {
#define arr_high tp_value.tp_arr->ar_high
};
/* ALLOCDEF "array" 5 */
#define new_array() ((struct array*) calloc(1, sizeof(struct array)))
#define free_array(p) free(p)
struct record {
struct scope *rc_scope; /* scope of this record */
@ -126,7 +129,8 @@ struct type {
struct type;
/* ALLOCDEF "type" 50 */
#define new_type() ((struct type*) calloc(1, sizeof(struct type)))
#define free_type(p) free(p)
extern struct type
*bool_type,
@ -290,4 +294,4 @@ int lcm(int m, int n);
#endif /* TYPE_H_ */
#endif /* TYPE_H_ */

View file

@ -15,6 +15,7 @@
#include "parameters.h"
#include "debug.h"
#include <stdlib.h>
#include <em_arith.h>
#include <em_label.h>
#include <assert.h>