#include "field.h"
#include "mes.h"
#include "assert.h"
+#include "ch3.h"
+#include "ch3bin.h"
+#include "code_c.h"
+#include "conversion.h"
+#include "cstoper.h"
-extern char *symbol2str();
extern char options[];
-extern arith flt_flt2arith();
-extern label code_string();
-arithbalance(e1p, oper, e2p) /* 3.1.2.5 */
- register struct expr **e1p, **e2p;
- int oper;
+void arithbalance(struct expr **e1p, int oper, struct expr **e2p) /* 3.1.2.5 */
{
/* The expressions *e1p and *e2p are balanced to be operands
of the arithmetic operator oper.
have a floating type, in which case the flags shouldn't
travel upward in the expression tree.
*/
- register int t1, t2, u1, u2;
+ int t1, t2, u1, u2;
int shifting = (oper == LEFT || oper == RIGHT
- || oper == LEFTAB || oper == RIGHTAB);
+ || oper == LEFTAB || oper == RIGHTAB);
int ptrdiff = 0;
t1 = any2arith(e1p, oper);
t2 = any2arith(e2p, oper);
if (int_size != pointer_size) {
- if (ptrdiff = ((*e1p)->ex_flags & EX_PTRDIFF)
+ if ((ptrdiff = ((*e1p)->ex_flags & EX_PTRDIFF))
|| ((*e2p)->ex_flags & EX_PTRDIFF)) {
if (!((*e1p)->ex_flags & EX_PTRDIFF) && t1 == LONG)
ptrdiff = 0;
return;
} else if (t2 == LNGDBL) {
if (t1 != LNGDBL)
- if (t1 == DOUBLE || t1 == FLOAT)
- float2float(e1p, lngdbl_type);
- else
- int2float(e1p, lngdbl_type);
+ {
+ if (t1 == DOUBLE || t1 == FLOAT)
+ {
+ float2float(e1p, lngdbl_type);
+ }
+ else
+ {
+ int2float(e1p, lngdbl_type);
+ }
+ }
return;
}
}
}
-relbalance(e1p, oper, e2p)
- register struct expr **e1p, **e2p;
+void relbalance(struct expr **e1p, int oper, struct expr **e2p)
{
/* The expressions *e1p and *e2p are balanced to be operands
of the relational operator oper, or the ':'.
allows assignments of a null-pointer to a function
pointer.
*/
- register struct expr *e1 = *e1p, *e2 = *e2p;
+ struct expr *e1 = *e1p, *e2 = *e2p;
struct expr *tmpexpr;
if (e1->ex_type->tp_fund == POINTER
arithbalance(e1p, oper, e2p);
}
-ch3pointer(expp, oper, tp)
- struct expr **expp;
- register struct type *tp;
+void ch3pointer(struct expr **expp, int oper, struct type *tp)
{
/* Checks whether *expp may be compared to tp using oper,
as described in chapter 3.3.8 and 3.3.9.
tp is known to be a pointer.
*/
- register struct expr *exp = *expp;
+ struct expr *exp = *expp;
if (exp->ex_type->tp_fund == POINTER) {
if (exp->ex_type != tp)
}
}
-int
-any2arith(expp, oper)
- register struct expr **expp;
- register int oper;
+int any2arith(struct expr **expp, int oper)
{
/* Turns any expression into int_type, long_type,
float_type, double_type or lngdbl_type.
return (*expp)->ex_type->tp_fund;
}
-erroneous2int(expp)
- struct expr **expp;
+void erroneous2int(struct expr **expp)
{
/* the (erroneous) expression *expp is replaced by an
int expression
*expp = exp;
}
-struct expr *
-arith2arith(tp, oper, expr)
- struct type *tp;
- int oper;
- register struct expr *expr;
+struct expr *arith2arith(struct type *tp, int oper, struct expr *expr)
{
/* arith2arith constructs a new expression containing a
run-time conversion between some arithmetic types.
*/
- register struct expr *new = new_expr();
+ struct expr *new = new_expr();
new->ex_file = expr->ex_file;
new->ex_line = expr->ex_line;
return new_oper(tp, new, oper, expr);
}
-int
-int2int(expp, tp)
- struct expr **expp;
- register struct type *tp;
+int int2int(struct expr **expp, struct type *tp)
{
/* The expression *expp, which is of some integral type, is
converted to the integral type tp.
*/
- register struct expr *exp = *expp;
+ struct expr *exp = *expp;
if (is_cp_cst(exp)) {
- register struct type *tp1 = exp->ex_type;
+ struct type *tp1 = exp->ex_type;
exp->ex_type = tp;
if (! tp1->tp_unsigned && tp->tp_unsigned) {
/* With compile-time constants, we don't set fp_used, since this is done
* only when necessary in eval.c.
*/
-int2float(expp, tp)
- register struct expr **expp;
- struct type *tp;
+void int2float(struct expr **expp, struct type *tp)
{
/* The expression *expp, which is of some integral type, is
converted to the floating type tp.
*/
- register struct expr *exp = *expp;
+ struct expr *exp = *expp;
int uns = exp->ex_type->tp_unsigned;
if (is_cp_cst(exp)) {
}
}
-float2int(expp, tp)
- struct expr **expp;
- struct type *tp;
+void float2int(struct expr **expp, struct type *tp)
{
/* The expression *expp, which is of some floating type, is
converted to the integral type tp.
*/
- register struct expr *ex = *expp;
+ struct expr *ex = *expp;
if (is_fp_cst(ex)) {
arith ar = flt_flt2arith(&ex->FL_ARITH, tp->tp_unsigned);
}
}
-float2float(expp, tp)
- register struct expr **expp;
- struct type *tp;
+void float2float(struct expr**expp, struct type *tp)
{
/* The expression *expp, which is of some floating type, is
converted to the floating type tp.
}
}
-array2pointer(exp)
- register struct expr *exp;
+void array2pointer(struct expr *exp)
{
/* The expression, which must be an array, is converted
to a pointer.
, (arith)0, NO_PROTO);
}
-function2pointer(exp)
- register struct expr *exp;
+void function2pointer(struct expr *exp)
{
/* The expression, which must be a function, is converted
to a pointer to the function.
(arith)0, NO_PROTO);
}
-string2pointer(ex)
- register struct expr *ex;
+void string2pointer(struct expr *ex)
{
/* The expression, which must be a string constant, is converted
to a pointer to the string-containing area.
ex->VL_VALUE = (arith)0;
}
-opnd2integral(expp, oper)
- register struct expr **expp;
- int oper;
+void opnd2integral(struct expr **expp, int oper)
{
- register int fund = (*expp)->ex_type->tp_fund;
+ int fund = (*expp)->ex_type->tp_fund;
if (fund != INT && fund != LONG) {
expr_error(*expp, "%s operand to %s",
}
}
-opnd2logical(expp, oper)
- register struct expr **expp;
- int oper;
+void opnd2logical(struct expr **expp, int oper)
{
int fund = (*expp)->ex_type->tp_fund;
}
}
-opnd2test(expp, oper)
- register struct expr **expp;
+void opnd2test(struct expr **expp, int oper)
{
opnd2logical(expp, oper);
if ((*expp)->ex_class == Oper) {
ch3bin(expp, NOTEQUAL, intexpr((arith)0, INT));
}
-any2opnd(expp, oper)
- register struct expr **expp;
+void any2opnd(struct expr **expp, int oper)
{
if (!*expp)
return;
case CHAR:
case SHORT:
case ENUM:
- /* case FLOAT: /* not necessary anymore */
+#if 0
+ case FLOAT: /* not necessary anymore */
+#endif
any2arith(expp, oper);
break;
case ARRAY:
}
}
-any2parameter(expp)
- register struct expr **expp;
+void any2parameter(struct expr **expp)
{
/* To handle default argument promotions
*/
}
#ifndef NOBITFIELD
-field2arith(expp)
- register struct expr **expp;
+void field2arith(struct expr **expp)
{
/* The expression to extract the bitfield value from the
memory word is put in the tree.
*/
- register struct type *tp = (*expp)->ex_type->tp_up;
- register struct field *fd = (*expp)->ex_type->tp_field;
+ struct type *tp = (*expp)->ex_type->tp_up;
+ struct field *fd = (*expp)->ex_type->tp_field;
(*expp)->ex_type = word_type;
/* switch_sign_fp() negates the given floating constant expression,
* and frees the string representing the old value.
*/
-switch_sign_fp(expr)
- register struct expr *expr;
+void switch_sign_fp(struct expr *expr)
{
flt_umin(&(expr->FL_ARITH));
}
#define arith_size (sizeof(arith))
#define arith_sign ((arith) 1 << (arith_size * 8 - 1))
#define max_arith (~arith_sign)
+
+struct expr;
+struct type;
+
+void erroneous2int(struct expr **expp);
+int int2int(struct expr **expp, struct type *tp);
+void int2float(struct expr **expp, struct type *tp);
+void float2float(struct expr**expp, struct type *tp);
+void field2arith(struct expr **expp);
+void ch3pointer(struct expr **expp, int oper, struct type *tp);
\ No newline at end of file
#include "label.h"
#include "stack.h"
#include "Lpars.h"
-extern arith NewLocal();
#define LocalPtrVar() NewLocal(pointer_size, pointer_align, reg_pointer, REGISTER)
#define LocalIntVar() NewLocal(int_size, int_align, reg_any, REGISTER)
+
+static void copy_loop(arith sz, arith src, arith dst);
+
#endif /* STB */
/* Because EM does not support the loading and storing of
while we need a loop to store the stack block into a memory object.
*/
-suitable_sz(sz, al)
- arith sz;
- int al;
+static int suitable_sz(arith sz, int al)
{
return ((int)sz % (int)word_size == 0 && al % word_align == 0) ||
(
);
}
-store_block(sz, al)
- arith sz;
- int al;
+void store_block(arith sz, int al)
{
if (suitable_sz(sz, al))
C_sti(sz);
}
}
-load_block(sz, al)
- arith sz;
- int al;
+void load_block(arith sz, int al)
{
if (suitable_sz(sz, al))
}
}
-copy_block(sz, al)
- arith sz;
- int al;
+void copy_block(arith sz, int al)
{
if (suitable_sz(sz, al))
}
#ifndef STB
-copy_loop(sz, src, dst)
- arith sz, src, dst;
+static void copy_loop(arith sz, arith src, arith dst)
{
/* generate inline byte-copy loop */
label l_cont = text_label(), l_stop = text_label();
--- /dev/null
+#ifndef LANG_CEM_CEMCOM_ANSI_BLOCKS_H
+#define LANG_CEM_CEMCOM_ANSI_BLOCKS_H
+
+void store_block(arith sz, int al);
+void load_block(arith sz, int al);
+void copy_block(arith sz, int al);
+
+#endif
\ No newline at end of file
#include "Lpars.h"
#include "assert.h"
#include "file_info.h"
+#include "ch3.h"
+#include "ch3bin.h"
+#include "decspecs.h"
+#include "conversion.h"
+#include <symbol2str.h>
extern char options[];
-extern char *symbol2str();
-extern struct type *qualifier_type();
+
+static int check_pseudoproto(struct proto *pl, struct proto *opl, int diag);
+static int legal_mixture(struct type *tp, struct type *otp, int diag);
+static int equal_proto(struct proto *pl, struct proto *opl, int diag);
+static int is_arith_type(struct type *tp);
/* Most expression-handling routines have a pointer to a
(struct type *) as first parameter. The object under the pointer
gets updated in the process.
*/
-ch3sel(expp, oper, idf)
- struct expr **expp;
- struct idf *idf;
+void ch3sel(struct expr **expp, int oper, struct idf *idf)
{
/* The selector idf is applied to *expp; oper may be '.' or
ARROW.
*/
- register struct expr *exp;
- register struct type *tp;
- register struct sdef *sd;
+ struct expr *exp;
+ struct type *tp;
+ struct sdef *sd;
any2opnd(expp, oper);
exp = *expp;
*expp = exp;
}
-ch3incr(expp, oper)
- struct expr **expp;
+void ch3incr(struct expr **expp, int oper)
{
/* The monadic prefix/postfix incr/decr operator oper is
applied to *expp.
ch3asgn(expp, oper, intexpr((arith)1, INT));
}
-ch3cast(expp, oper, tp)
- register struct expr **expp;
- register struct type *tp;
+void ch3cast(struct expr **expp, int oper, struct type *tp)
{
/* The expression *expp is cast to type tp; the cast is
caused by the operator oper. If the cast has
to be passed on to run time, its left operand will be an
expression of class Type.
*/
- register struct type *oldtp;
- register struct expr *exp = *expp;
+ struct type *oldtp;
+ struct expr *exp = *expp;
int qual_lev, ascompat = 0;
if (oper == RETURN && tp->tp_fund == VOID) {
/* Determine whether two types are equal.
*/
-equal_type(tp, otp, qual_lev, diag)
- register struct type *tp, *otp;
- int qual_lev, diag;
+int equal_type(struct type *tp, struct type *otp, int qual_lev, int diag)
{
if (tp == otp)
return 1;
}
}
-check_pseudoproto(pl, opl, diag)
- register struct proto *pl, *opl;
+static int check_pseudoproto(struct proto *pl, struct proto *opl, int diag)
{
int retval = 1;
return retval;
}
-legal_mixture(tp, otp, diag)
- struct type *tp, *otp;
- int diag;
+static int legal_mixture(struct type *tp, struct type *otp, int diag)
{
struct proto *pl = tp->tp_proto, *opl = otp->tp_proto;
int retval = 1;
- register struct proto *prot;
+ struct proto *prot;
int fund;
ASSERT( (pl != 0) ^ (opl != 0));
return retval;
}
-equal_proto(pl, opl, diag)
- register struct proto *pl, *opl;
- int diag;
+static int equal_proto(struct proto *pl, struct proto *opl, int diag)
{
if (pl == opl)
return 1;
}
/* check if a type has a consqualified member */
-recurqual(tp, qual)
-struct type *tp;
-int qual;
+int recurqual(struct type *tp, int qual)
{
- register struct sdef *sdf;
+ struct sdef *sdf;
ASSERT(tp);
return 0;
}
-ch3asgn(expp, oper, expr)
- struct expr **expp;
- struct expr *expr;
+void ch3asgn(struct expr **expp, int oper, struct expr *expr)
{
/* The assignment operators.
"f op= e" should be interpreted as
f (typeof (f op e))e
EVAL should however take care of evaluating (typeof (f op e))f
*/
- register struct expr *exp = *expp;
+ struct expr *exp = *expp;
int fund = exp->ex_type->tp_fund;
struct type *tp;
char *oper_string = symbol2str(oper);
/* Some interesting (?) questions answered.
*/
-int
-is_integral_type(tp)
- register struct type *tp;
+int is_integral_type(struct type *tp)
{
switch (tp->tp_fund) {
case CHAR:
}
}
-int
-is_arith_type(tp)
- register struct type *tp;
+static int is_arith_type(struct type *tp)
{
switch (tp->tp_fund) {
case CHAR:
--- /dev/null
+/*
+ * The Amsterdam Compiler Kit
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ */
+
+#ifndef LANG_CEM_CEMCOM_ANSI_CH3_H
+#define LANG_CEM_CEMCOM_ANSI_CH3_H
+
+void ch3cast(struct expr **expp, int oper, struct type *tp);
+void ch3sel(struct expr **expp, int oper, struct idf *idf);
+void ch3incr(struct expr **expp, int oper);
+int equal_type(struct type *tp, struct type *otp, int qual_lev, int diag);
+int recurqual(struct type *tp, int qual);
+void ch3asgn(struct expr **expp, int oper, struct expr *expr);
+int is_integral_type(struct type *tp);
+
+#endif
\ No newline at end of file
#include "expr.h"
#include "Lpars.h"
#include "sizes.h"
+#include "ch3.h"
+#include "ch3bin.h"
+#include "ch3mon.h"
+#include "cstoper.h"
+#include <symbol2str.h>
extern char options[];
-extern char *symbol2str();
+
+static void pntminuspnt(struct expr **expp, int oper, struct expr *expr);
+static int arg_switched(int oper);
+static void mk_binop(struct expr **expp, int oper, struct expr *expr, int commutative);
+static void pointer_arithmetic(struct expr **expp1, int oper, struct expr **expp2);
+static void pointer_binary(struct expr **expp, int oper, struct expr *expr);
/* This chapter asks for the repeated application of code to handle
an operation that may be executed at compile time or at run time,
#define commutative_binop(expp, oper, expr) mk_binop(expp, oper, expr, 1)
#define non_commutative_relop(expp, oper, expr) mk_binop(expp, oper, expr, 1)
-ch3bin(expp, oper, expr)
- register struct expr **expp;
- struct expr *expr;
+void ch3bin(struct expr **expp, int oper, struct expr *expr)
{
/* apply binary operator oper between *expp and expr.
NB: don't swap operands if op is one of the op= operators!!!
}
}
-pntminuspnt(expp, oper, expr)
- register struct expr **expp, *expr;
+static void pntminuspnt(struct expr **expp, int oper, struct expr *expr)
{
/* Subtracting two pointers is so complicated it merits a
routine of its own.
* when the arguments are switched. This is special for some relational
* operators.
*/
-int
-arg_switched(oper)
+static int arg_switched(int oper)
{
switch (oper) {
case '<': return '>';
}
}
-mk_binop(expp, oper, expr, commutative)
- struct expr **expp;
- register struct expr *expr;
+static void mk_binop(struct expr **expp, int oper, struct expr *expr, int commutative)
{
/* Constructs in *expp the operation indicated by the operands.
"commutative" indicates whether "oper" is a commutative
}
}
-pointer_arithmetic(expp1, oper, expp2)
- register struct expr **expp1, **expp2;
+static void pointer_arithmetic(struct expr **expp1, int oper, struct expr **expp2)
{
int typ;
/* prepares the integral expression expp2 in order to
);
}
-pointer_binary(expp, oper, expr)
- register struct expr **expp, *expr;
+static void pointer_binary(struct expr **expp, int oper, struct expr *expr)
{
/* constructs the pointer arithmetic expression out of
a pointer expression, a binary operator and an integral
--- /dev/null
+/*
+ * The Amsterdam Compiler Kit
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ */
+
+#ifndef LANG_CEM_CEMCOM_ANSI_CH3BIN_H
+#define LANG_CEM_CEMCOM_ANSI_CH3BIN_H
+
+void ch3bin(struct expr **expp, int oper, struct expr *expr);
+
+#endif
\ No newline at end of file
#include "idf.h"
#include "def.h"
#include "sizes.h"
+#include "ch3.h"
+#include "ch3mon.h"
+#include <symbol2str.h>
extern char options[];
extern arith full_mask[/*MAXSIZE + 1*/]; /* cstoper.c */
-char *symbol2str(int tok);
-ch3mon(oper, expp)
- register struct expr **expp;
+
+void ch3mon(int oper, struct expr **expp)
{
/* The monadic prefix operator oper is applied to *expp.
*/
--- /dev/null
+/*
+ * The Amsterdam Compiler Kit
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ */
+
+#ifndef LANG_CEM_CEMCOM_ANSI_CH3MON_H
+#define LANG_CEM_CEMCOM_ANSI_CH3MON_H
+
+void ch3mon(int oper, struct expr **expp);
+
+#endif
\ No newline at end of file
#include "assert.h"
#include "LLlex.h"
#include "align.h"
+#include "blocks.h"
+#include "code_c.h"
+#include "conversion.h"
+
+#include <symbol2str.h>
+
#ifdef LINT
#include "l_lint.h"
#endif /* LINT */
label datlab_count = 1;
int fp_used;
-extern arith NewLocal(); /* util.c */
/* global function info */
char *func_name;
#endif /* USE_TMP */
extern char options[];
-extern char *symbol2str();
extern char *source;
+static void def_strings(struct string_cst *sc);
+static void prc_entry(char *name);
+static void prc_exit();
+
#ifndef LINT
-init_code(dst_file)
- char *dst_file;
+void init_code(char *dst_file)
{
/* init_code() initialises the output file on which the
compact EM code is written
struct string_cst *str_list = 0;
-label
-code_string(val, len)
- char *val;
- int len;
+label code_string(char *val, int len)
{
register struct string_cst *sc = new_string_cst();
label dlb = data_label();
return dlb;
}
-def_strings(sc)
- register struct string_cst *sc;
+static void def_strings(struct string_cst *sc)
{
while (sc) {
struct string_cst *sc1 = sc;
}
/* flush_strings() is called from program.g after each external definition */
-flush_strings() {
+void flush_strings()
+{
if (str_list) {
def_strings(str_list);
str_list = 0;
}
#ifndef LINT
-end_code()
+void end_code()
{
/* end_code() performs the actions to be taken when closing
the output stream.
#endif /* LINT */
#ifdef PREPEND_SCOPES
-prepend_scopes()
+void prepend_scopes()
{
/* prepend_scopes() runs down the list of global idf's
and generates those exa's, exp's, ina's and inp's
that superior hindsight has provided.
*/
- register struct stack_entry *se = local_level->sl_entry;
+ struct stack_entry *se = local_level->sl_entry;
#ifdef USE_TMP
C_beginpart(tmp_id);
#endif /* USE_TMP */
while (se != 0) {
- register struct def *df = se->se_idf->id_def;
+ struct def *df = se->se_idf->id_def;
if (df && (df->df_initialized || df->df_used || df->df_alloc)) {
code_scope(se->se_idf->id_text, df);
}
#endif /* PREPEND_SCOPES */
-code_scope(text, def)
- char *text;
- register struct def *def;
+void code_scope(char *text, struct def *def)
{
/* generates code for one name, text, of the storage class
as given by def, if meaningful.
static char *last_fn_given = (char *)0;
static label file_name_label;
-begin_proc(ds, idf) /* to be called when entering a procedure */
- struct decspecs *ds;
- struct idf *idf;
+/* to be called when entering a procedure */
+void begin_proc(struct decspecs *ds, struct idf *idf)
{
/* begin_proc() is called at the entrance of a new function
and performs the necessary code generation:
does not fit in the return area
- a fil pseudo instruction
*/
- register char *name = idf->id_text;
- register struct def *def = idf->id_def;
+ char *name = idf->id_text;
+ struct def *def = idf->id_def;
/* idf->id_def does not indicate the right def structure
* when the function being defined has a parameter of the
#endif
}
-end_proc(fbytes)
- arith fbytes;
+void end_proc(arith fbytes)
{
/* end_proc() deals with the code to be generated at the end of
a function, as there is:
options['n'] = optionsn;
}
-do_return()
+void do_return()
{
/* do_return handles the case of a return without expression.
This version branches to the return label, which is
C_bra(return2_label);
}
-do_return_expr(expr)
- struct expr *expr;
+void do_return_expr(struct expr *expr)
{
/* do_return_expr() generates the expression and the jump for
a return statement with an expression.
return_expr_occurred = 1;
}
-code_declaration(idf, expr, lvl, sc)
- register struct idf *idf; /* idf to be declared */
- struct expr *expr; /* initialisation; NULL if absent */
- int lvl; /* declaration level */
- int sc; /* storage class, as in the declaration */
+/* struct idf *idf idf to be declared
+ * struct expr *expr initialisation; NULL if absent
+ * int lvl declaration level
+ * int sc storage class, as in the declaration
+ */
+void code_declaration(struct idf *idf, struct expr *expr, int lvl, int sc)
{
/* code_declaration() does the actual declaration of the
variable indicated by "idf" on declaration level "lvl".
The sc is the actual storage class, as given in the
declaration.
*/
- register struct def *def = idf->id_def;
- register arith size = def->df_type->tp_size;
+ struct def *def = idf->id_def;
+ arith size = def->df_type->tp_size;
int fund = def->df_type->tp_fund;
int def_sc = def->df_sc;
}
}
-loc_init(expr, id)
- struct expr *expr;
- struct idf *id;
+void loc_init(struct expr *expr, struct idf *id)
{
/* loc_init() generates code for the assignment of
expression expr to the local variable described by id.
It frees the expression afterwards.
*/
- register struct expr *e = expr;
- register struct def *df = id->id_def;
- register struct type *tp = df->df_type;
+ struct expr *e = expr;
+ struct def *df = id->id_def;
+ struct type *tp = df->df_type;
static arith tmpoffset = 0;
static arith unknownsize = 0;
}
}
-bss(idf)
- register struct idf *idf;
+void bss(struct idf *idf)
{
/* bss() allocates bss space for the global idf.
*/
- register struct def *df = idf->id_def;
+ struct def *df = idf->id_def;
#ifndef PREPEND_SCOPES
code_scope(idf->id_text, df);
}
}
-formal_cvt(hasproto,df)
- int hasproto;
- register struct def *df;
+void formal_cvt(int hasproto, struct def *df)
{
/* formal_cvt() converts a formal parameter of type char or
short from int to that type. It also converts a formal
parameter of type float from a double to a float.
*/
- register struct type *tp = df->df_type;
+ struct type *tp = df->df_type;
if (tp->tp_size != int_size &&
(tp->tp_fund == CHAR || tp->tp_fund == SHORT)
#ifdef LINT
/*ARGSUSED*/
#endif /* LINT */
-code_expr(expr, val, code, tlbl, flbl)
- struct expr *expr;
- label tlbl, flbl;
+void code_expr(struct expr *expr, int val, int code, label tlbl, label flbl)
{
/* code_expr() is the parser's interface to the expression code
generator. If line number trace is wanted, it generates a
which are the only ones that are stacked, only the top of
the stack is interesting.
*/
-code_break()
+void code_break()
{
- register struct stmt_block *stmt_block = stmt_stack;
+ struct stmt_block *stmt_block = stmt_stack;
#ifdef DBSYMTAB
if (options['g']) db_line(dot.tk_file, dot.tk_line);
it generates a branch instruction to the continue label of the
innermost statement in which continue has a meaning.
*/
-code_continue()
+void code_continue()
{
- register struct stmt_block *stmt_block = stmt_stack;
+ struct stmt_block *stmt_block = stmt_stack;
while (stmt_block) {
if (stmt_block->st_continue) {
error("continue not inside for, while or do");
}
-stack_stmt(break_label, cont_label)
- label break_label, cont_label;
+void stack_stmt(label break_label, label cont_label)
{
- register struct stmt_block *stmt_block = new_stmt_block();
+ struct stmt_block *stmt_block = new_stmt_block();
stmt_block->next = stmt_stack;
stmt_block->st_break = break_label;
stmt_stack = stmt_block;
}
-unstack_stmt()
+void unstack_stmt()
{
/* unstack_stmt() unstacks the data of a statement
which may contain break or continue
static label prc_name;
-prc_entry(name)
- char *name;
+static void prc_entry(char *name)
{
if (options['p']) {
C_df_dlb(prc_name = data_label());
}
}
-prc_exit()
+static void prc_exit()
{
if (options['p']) {
C_lae_dlb(prc_name, (arith) 0);
}
#ifdef DBSYMTAB
-db_line(file, line)
- char *file;
- unsigned int line;
+void db_line(char *file, unsigned int line)
{
static unsigned oldline;
static char *oldfile;
--- /dev/null
+/*
+ * The Amsterdam Compiler Kit
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ */
+#ifndef LANG_CEM_CEMCOM_ANSI_CODE_H
+#define LANG_CEM_CEMCOM_ANSI_CODE_H
+
+struct decspecs;
+
+void init_code(char *dst_file);
+label code_string(char *val, int len);
+void flush_strings();
+void code_scope(char *text, struct def *def);
+void begin_proc(struct decspecs *ds, struct idf *idf);
+void end_proc(arith fbytes);
+void do_return();
+void do_return_expr(struct expr *expr);
+void code_declaration(struct idf *idf, struct expr *expr, int lvl, int sc);
+void loc_init(struct expr *expr, struct idf *id);
+void bss(struct idf *idf);
+void code_expr(struct expr *expr, int val, int code, label tlbl, label flbl);
+void code_break();
+void code_continue();
+void stack_stmt(label break_label, label cont_label);
+void unstack_stmt();
+
+#ifdef DBSYMTAB
+void db_line(char *file, unsigned int line);
+#endif
+
+#ifdef PREPEND_SCOPES
+void prepend_scopes();
+#endif
+
+#ifndef LINT
+void end_code();
+#endif
+
+#endif
\ No newline at end of file
C??
*/
-static int convtype();
+static int convtype(struct type *tp);
-conversion(from_type, to_type)
- register struct type *from_type, *to_type;
+void conversion(struct type *from_type, struct type *to_type)
{
- register arith from_size = from_type->tp_size;
- register arith to_size = to_type->tp_size;
+ arith from_size = from_type->tp_size;
+ arith to_size = to_type->tp_size;
int from_cnvtype = convtype(from_type);
int to_cnvtype = convtype(to_type);
/* convtype() returns in which category a given type falls:
signed, unsigned or floating
*/
-static int
-convtype(tp)
- register struct type *tp;
+static int convtype(struct type *tp)
{
switch (tp->tp_fund) {
case CHAR:
--- /dev/null
+#ifndef LANG_CEM_CEMCOM_ANSI_CONVERSION_H
+#define LANG_CEM_CEMCOM_ANSI_CONVERSION_H
+
+struct type;
+
+void conversion(struct type *from_type, struct type *to_type);
+
+#endif
\ No newline at end of file
#include "sizes.h"
#include "Lpars.h"
#include "assert.h"
+#include "cstoper.h"
/* full_mask[1] == 0XFF, full_mask[2] == 0XFFFF, .. */
arith full_mask[MAXSIZE + 1];
#endif /* NOCROSS */
extern int ResultKnown;
-cstbin(expp, oper, expr)
- register struct expr **expp, *expr;
+void cstbin(struct expr **expp, int oper, struct expr *expr)
{
/* The operation oper is performed on the constant
expressions *expp(ld) and expr(ct), and the result restored in
*expp.
*/
- register arith o1 = (*expp)->VL_VALUE;
- register arith o2 = expr->VL_VALUE;
+ arith o1 = (*expp)->VL_VALUE;
+ arith o2 = expr->VL_VALUE;
int uns = (*expp)->ex_type->tp_unsigned;
ASSERT(is_ld_cst(*expp) && is_cp_cst(expr));
free_expression(expr);
}
-cut_size(expr)
- register struct expr *expr;
+void cut_size(struct expr *expr)
{
/* The constant value of the expression expr is made to
conform to the size of the type of the expression.
*/
- register arith o1 = expr->VL_VALUE;
+ arith o1 = expr->VL_VALUE;
int uns = expr->ex_type->tp_unsigned;
int size = (int) expr->ex_type->tp_size;
expr->VL_VALUE = o1;
}
-init_cst()
+void init_cst()
{
- register int i = 0;
- register arith bt = (arith)0;
+ int i = 0;
+ arith bt = (arith)0;
while (!(bt < 0)) {
bt = (bt << 8) + 0377, i++;
--- /dev/null
+#ifndef LANG_CEM_CEMCOM_ANSI_CSTOPER_H
+#define LANG_CEM_CEMCOM_ANSI_CSTOPER_H
+
+void cstbin(struct expr **expp, int oper, struct expr *expr);
+void cut_size(struct expr *expr);
+void init_cst();
+
+#endif
\ No newline at end of file
#include "expr.h"
#include "sizes.h"
#include "level.h"
+#include "code_c.h"
#ifdef LINT
#include "l_lint.h"
#endif /* LINT */
struct decspecs null_decspecs;
-do_decspecs(ds)
- register struct decspecs *ds;
+void do_decspecs(struct decspecs *ds)
{
/* The provisional decspecs ds as obtained from the program
is turned into a legal consistent decspecs.
*/
- register struct type *tp = ds->ds_type;
+ struct type *tp = ds->ds_type;
ASSERT(level != L_FORMAL1);
tp = int_type;
}
if (ds->ds_size) {
- register int ds_isshort = (ds->ds_size == SHORT);
+ int ds_isshort = (ds->ds_size == SHORT);
if (ds->ds_typedef) goto SIZE_ERROR; /* yes */
if (tp == int_type) {
ds->ds_notypegiven = 0;
}
if (ds->ds_unsigned) {
- register int ds_isunsigned = (ds->ds_unsigned == UNSIGNED);
+ int ds_isunsigned = (ds->ds_unsigned == UNSIGNED);
if (ds->ds_typedef) goto SIGN_ERROR; /* yes */
/*
In case of a complex type the top of the type list will be
replaced by a qualified version.
*/
-struct type *
-qualifier_type(tp, typequal)
- register struct type *tp;
- int typequal;
+struct type *qualifier_type(struct type *tp, int typequal)
{
- register struct type *dtp = tp;
- register int fund = tp->tp_fund;
+ struct type *dtp = tp;
+ int fund = tp->tp_fund;
while (dtp && dtp->tp_typequal != typequal)
dtp = dtp->next;
int ds_typequal; /* type qualifiers - see type.str */
};
-extern struct type *qualifier_type();
extern struct decspecs null_decspecs;
+
+void do_decspecs(struct decspecs *ds);
+struct type *qualifier_type(struct type *tp, int typequal);
+
#include "align.h"
#include "mes.h"
#include "atw.h"
+#include "blocks.h"
+#include "conversion.h"
#include "specials.h"
#define CRASH() crash("EVAL: CRASH at line %u", __LINE__)
#include "sizes.h"
#include "level.h"
#include "use_tmp.h"
+#include "cstoper.h"
+
+#include <symbol2str.h>
-extern char *symbol2str();
extern char options[];
extern int InSizeof;
#include "expr.h"
#include "code.h"
#include "sizes.h"
-
-extern struct expr *intexpr();
+#include "ch3.h"
+#include "ch3bin.h"
+#include "ch3mon.h"
int InSizeof = 0; /* inside a sizeof- expression */
int ResultKnown = 0; /* result of the expression is already known */
}
/* 3.3.1 */
-primary(register struct expr **expp;) :
+primary(struct expr **expp;) :
IDENTIFIER
{dot2expr(expp);}
|
* are concatenated into a single character string
* literal.
*/
-string(register struct expr **expp;)
- { register int i, len;
- register char *str;
- register int fund;
+string(struct expr **expp;)
+ { int i, len;
+ char *str;
+ int fund;
}
:
STRING
;
/* 3.3.2 */
-postfix_expression(register struct expr **expp;)
+postfix_expression(struct expr **expp;)
{ int oper;
struct expr *e1 = 0;
struct idf *idf;
%first first_of_type_specifier, type_specifier;
/* 3.3.3 & 3.3.4 */
-unary(register struct expr **expp;)
+unary(struct expr **expp;)
{struct type *tp; int oper;}
:
%if (first_of_type_specifier(AHEAD) && AHEAD != IDENTIFIER)
* mark it as used.
* extern int i; .... sizeof(i) .... need not have a definition for i
*/
-size_of(register struct expr **expp;)
+size_of(struct expr **expp;)
{struct type *tp;}
:
SIZEOF { InSizeof++; } /* handle (sizeof(sizeof(int))) too */
{*oper = DOT;}
;
-asgnop(register int *oper;):
+asgnop(int *oper;):
[ '=' | PLUSAB | MINAB | TIMESAB | DIVAB | MODAB
| LEFTAB | RIGHTAB | ANDAB | XORAB | ORAB ]
{ *oper = DOT; }
#include "align.h"
#include "Lpars.h"
#include "field.h"
+#include "conversion.h"
arith NewLocal(); /* util.c */
extern arith full_mask[]; /* cstoper.c */
#include "expr.h"
#include "sizes.h"
#include "Lpars.h"
+#include "cstoper.h"
+
+#include <symbol2str.h>
extern int ResultKnown;
-extern char *symbol2str();
fltcstbin(expp, oper, expr)
register struct expr **expp, *expr;
#include "sizes.h"
#include "Lpars.h"
#include "assert.h"
+#include "ch3.h"
+#include "code_c.h"
+#include "conversion.h"
extern char options[];
extern arith NewLocal();
#include "def.h"
#include "LLlex.h"
#include "estack.h"
+#include "conversion.h"
+#include "cstopen.h"
#define con_nullbyte() C_con_ucon("0", (arith)1)
#define aggregate_type(tp) ((tp)->tp_fund == ARRAY || (tp)->tp_fund == STRUCT)
* to terminate the compilation process.
*/
+#include "blocks.h"
+
#define store_block(sz, al)
#define load_block(sz, al)
#include "type.h"
#include "level.h"
#include "l_state.h"
+#include "conversion.h"
+#include <symbol2str.h>
-extern char *symbol2str();
extern struct type *func_type;
PRIVATE lint_enum_arith();
#include "align.h"
#include "macro.h"
#include "assert.h"
+#include "code_c.h"
+#include "cstoper.h"
+
+#include <symbol2str.h>
extern struct tokenname tkidf[];
-extern char *symbol2str();
extern char options[128];
#ifndef NOPP
#include "use_tmp.h"
#include "dataflow.h"
#include "dbsymtab.h"
+#include "conversion.h"
#ifndef NOPP
extern char **inctable;
#include "code.h"
#include "expr.h"
#include "def.h"
+#include "code_c.h"
#ifdef LINT
#include "l_lint.h"
#endif /* LINT */
#include "decspecs.h"
#include "proto.h"
#include "assert.h"
+#include "conversion.h"
extern char options[];
#include "struct.h"
#include "level.h"
#include "mes.h"
-
+#include "code_c.h"
/* #include <em_reg.h> */
extern char options[];
#include "code.h"
#include "stack.h"
#include "def.h"
+#include "code_c.h"
#ifdef DBSYMTAB
#include <stb.h>
#endif /* DBSYMTAB */
#include "expr.h"
#include "type.h"
#include "sizes.h"
+#include "code_c.h"
extern char options[];
/* $Id$ */
#include "Lpars.h"
-char *
-symbol2str(tok)
- int tok;
+char *symbol2str(int tok)
{
#define SIZBUF 8
/* allow for a few invocations in f.i. an argument list */
+#!/bin/sh
+
cat <<'--EOT--'
+/* Generated by make.tokcase */
+/* $Id$ */
#include "Lpars.h"
-char *
-symbol2str(tok)
- int tok;
+char *symbol2str(int tok)
{
- static char buf[2] = { '\0', '\0' };
+#define SIZBUF 8
+ /* allow for a few invocations in f.i. an argument list */
+ static char buf[SIZBUF];
+ static int index;
- if (040 <= tok && tok < 0177) {
- buf[0] = tok;
- buf[1] = '\0';
- return buf;
- }
switch (tok) {
--EOT--
+
sed '
/{[A-Z]/!d
s/.*{\(.*\),.*\(".*"\).*$/ case \1 :\
return \2;/
'
+
cat <<'--EOT--'
+ default:
+ if (tok <= 0) return "end of file";
+ if (tok < 040 || tok >= 0177) {
+ return "bad token";
+ }
+ /* fall through */
case '\n':
case '\f':
case '\v':
case '\r':
case '\t':
- buf[0] = tok;
- return buf;
- default:
- return "bad token";
+ index = (index+2) & (SIZBUF-1);
+ buf[index] = tok;
+ return &buf[index];
}
}
--EOT--
+#!/bin/sh
+
cat <<'--EOT--'
/* Generated by make.tokcase */
/* $Id$ */
#include "Lpars.h"
-char *
-symbol2str(tok)
- int tok;
+char *symbol2str(int tok)
{
#define SIZBUF 8
/* allow for a few invocations in f.i. an argument list */
- static char buf[SIZBUF] = { '\'', 0, '\'', 0, '\'', 0, '\'', 0};
- static int index = 1;
+ static char buf[SIZBUF];
+ static int index;
switch (tok) {
--EOT--
if (tok < 040 || tok >= 0177) {
return "bad token";
}
- index = (index+4) & (SIZBUF-1);
+ /* fall through */
+ case '\n':
+ case '\f':
+ case '\v':
+ case '\r':
+ case '\t':
+ index = (index+2) & (SIZBUF-1);
buf[index] = tok;
- return &buf[index-1];
+ return &buf[index];
}
}
--EOT--
+#!/bin/sh
+
cat <<'--EOT--'
/* Generated by make.tokcase */
/* $Id$ */
#include "Lpars.h"
-char *
-symbol2str(tok)
- int tok;
+char *symbol2str(int tok)
{
#define SIZBUF 8
/* allow for a few invocations in f.i. an argument list */
+#!/bin/sh
+
cat <<'--EOT--'
/* Generated by make.tokcase */
/* $Id$ */
#include "Lpars.h"
-char *
-symbol2str(tok)
- int tok;
+char *symbol2str(int tok)
{
#define SIZBUF 8
/* allow for a few invocations in f.i. an argument list */
#!/bin/sh
cat <<'--EOT--'
+/* Generated by make.tokcase */
+/* $Id$ */
#include "Lpars.h"
-char *
-symbol2str(tok)
- int tok;
+char *symbol2str(int tok)
{
- static char buf[2] = { '\0', '\0' };
+#define SIZBUF 8
+ /* allow for a few invocations in f.i. an argument list */
+ static char buf[SIZBUF];
+ static int index;
- if (040 <= tok && tok < 0177) {
- buf[0] = tok;
- buf[1] = '\0';
- return buf;
- }
switch (tok) {
--EOT--
+
sed '
/{[A-Z]/!d
s/.*{\(.*\),.*\(".*"\).*$/ case \1 :\
return \2;/
'
+
cat <<'--EOT--'
+ default:
+ if (tok <= 0) return "end of file";
+ if (tok < 040 || tok >= 0177) {
+ return "bad token";
+ }
+ /* fall through */
case '\n':
case '\f':
case '\v':
case '\r':
case '\t':
- buf[0] = tok;
- return buf;
- default:
- return "bad token";
+ index = (index+2) & (SIZBUF-1);
+ buf[index] = tok;
+ return &buf[index];
}
}
--EOT--
+#!/bin/sh
+
cat <<'--EOT--'
/* Generated by make.tokcase */
/* $Id$ */
#include "Lpars.h"
-char *
-symbol2str(tok)
- int tok;
+char *symbol2str(int tok)
{
#define SIZBUF 8
/* allow for a few invocations in f.i. an argument list */
- static char buf[SIZBUF] = { '\'', 0, '\'', 0, '\'', 0, '\'', 0};
- static int index = 1;
+ static char buf[SIZBUF];
+ static int index;
switch (tok) {
--EOT--
cat <<'--EOT--'
default:
if (tok <= 0) return "end of file";
- if (tok == '\n') return "<newline>";
if (tok < 040 || tok >= 0177) {
return "bad token";
}
- index = (index+4) & (SIZBUF-1);
+ /* fall through */
+ case '\n':
+ case '\f':
+ case '\v':
+ case '\r':
+ case '\t':
+ index = (index+2) & (SIZBUF-1);
buf[index] = tok;
- return &buf[index-1];
+ return &buf[index];
}
}
--EOT--