From 80155f7b4c177b4e983892dffcf39f56e61f763a Mon Sep 17 00:00:00 2001 From: erikb Date: Tue, 25 Mar 1986 16:40:43 +0000 Subject: [PATCH] introduced the em_code(3L) and em_mes(3L) modules --- lang/cem/cemcom/Files | 5 -- lang/cem/cemcom/LLlex.c | 35 ++++++------- lang/cem/cemcom/LLlex.h | 8 ++- lang/cem/cemcom/LLmessage.c | 3 +- lang/cem/cemcom/Makefile.erik | 51 +++++++++---------- lang/cem/cemcom/Parameters | 4 -- lang/cem/cemcom/arith.h | 2 +- lang/cem/cemcom/asm.c | 3 +- lang/cem/cemcom/blocks.c | 2 +- lang/cem/cemcom/code.c | 12 +++-- lang/cem/cemcom/conversion.c | 2 +- lang/cem/cemcom/domacro.c | 6 +-- lang/cem/cemcom/error.c | 3 +- lang/cem/cemcom/eval.c | 5 +- lang/cem/cemcom/expr.c | 3 +- lang/cem/cemcom/expr.str | 4 +- lang/cem/cemcom/field.c | 3 +- lang/cem/cemcom/ival.c | 93 ++++------------------------------- lang/cem/cemcom/label.h | 3 +- lang/cem/cemcom/main.c | 9 +--- lang/cem/cemcom/stack.c | 6 ++- lang/cem/cemcom/statement.g | 11 +++-- lang/cem/cemcom/switch.c | 3 +- 23 files changed, 99 insertions(+), 177 deletions(-) diff --git a/lang/cem/cemcom/Files b/lang/cem/cemcom/Files index 2d5852866..80cfbaef1 100644 --- a/lang/cem/cemcom/Files +++ b/lang/cem/cemcom/Files @@ -34,9 +34,6 @@ decspecs.str def.str domacro.c dumpidf.c -em.c -em.h -emcode.def error.c eval.c expr.c @@ -58,8 +55,6 @@ level.h macro.str main.c make.allocd -make.emfun -make.emmac make.hfiles make.next make.tokcase diff --git a/lang/cem/cemcom/LLlex.c b/lang/cem/cemcom/LLlex.c index fce9dac6c..220137467 100644 --- a/lang/cem/cemcom/LLlex.c +++ b/lang/cem/cemcom/LLlex.c @@ -189,8 +189,12 @@ go_on: /* rescan, the following character has been read */ case '<': if (AccFileSpecifier) { PushBack(); /* pushback nch */ - ptok->tk_str = - string_token("file specifier", '>'); + ptok->tk_bts = + string_token( + "file specifier", + '>', + &(ptok->tk_len) + ); return ptok->tk_symb = FILESPECIFIER; } if (nch == '<') @@ -310,6 +314,8 @@ go_on: /* rescan, the following character has been read */ } if (ch == '\\') { LoadChar(ch); + if (ch == '\n') + LineNumber++; ch = quoted(ch); } val = val*256 + ch; @@ -323,7 +329,7 @@ go_on: /* rescan, the following character has been read */ return ptok->tk_symb = INTEGER; } case STSTR: /* string */ - ptok->tk_str = string_token("string", '"'); + ptok->tk_bts = string_token("string", '"', &(ptok->tk_len)); return ptok->tk_symb = STRING; case STNUM: /* a numeric constant */ { @@ -466,8 +472,9 @@ skipcomment() } char * -string_token(nm, stop_char) +string_token(nm, stop_char, plen) char *nm; + int *plen; { register int ch; register int str_size; @@ -486,28 +493,18 @@ string_token(nm, stop_char) break; } if (ch == '\\') { - register int nch; - - LoadChar(nch); - if (nch == '\n') { + LoadChar(ch); + if (ch == '\n') LineNumber++; - LoadChar(ch); - continue; - } - else { - str[pos++] = '\\'; - if (pos == str_size) - str = Srealloc(str, - str_size += RSTRSIZE); - ch = nch; - } + ch = quoted(ch); } str[pos++] = ch; if (pos == str_size) str = Srealloc(str, str_size += RSTRSIZE); LoadChar(ch); } - str[pos++] = '\0'; + str[pos++] = '\0'; /* for filenames etc. */ + *plen = pos; return str; } diff --git a/lang/cem/cemcom/LLlex.h b/lang/cem/cemcom/LLlex.h index fbc18ad09..392f6664f 100644 --- a/lang/cem/cemcom/LLlex.h +++ b/lang/cem/cemcom/LLlex.h @@ -13,7 +13,10 @@ struct token { unsigned int tok_line; /* the line it (probably) comes from */ union { struct idf *tok_idf; /* for IDENTIFIER & TYPE_IDENTIFIER */ - char *tok_str; /* for STRING: text */ + struct { /* for STRING */ + char *tok_bts; /* row of bytes */ + int tok_len; /* length of row of bytes */ + } tok_string; struct { /* for INTEGER */ int tok_fund; /* INT or LONG */ arith tok_ival; @@ -26,7 +29,8 @@ struct token { #define tk_file tok_file #define tk_line tok_line #define tk_idf tok_data.tok_idf -#define tk_str tok_data.tok_str +#define tk_bts tok_data.tok_string.tok_bts +#define tk_len tok_data.tok_string.tok_len #define tk_fund tok_data.tok_integer.tok_fund #define tk_ival tok_data.tok_integer.tok_ival #define tk_fval tok_data.tok_fval diff --git a/lang/cem/cemcom/LLmessage.c b/lang/cem/cemcom/LLmessage.c index acb3b9bce..78ca57d02 100644 --- a/lang/cem/cemcom/LLmessage.c +++ b/lang/cem/cemcom/LLmessage.c @@ -37,7 +37,8 @@ insert_token(tk) dot.tk_idf = str2idf("int"); break; case STRING: - dot.tk_str = Salloc("", 1); + dot.tk_bts = Salloc("", 1); + dot.tk_len = 1; break; case INTEGER: dot.tk_fund = INT; diff --git a/lang/cem/cemcom/Makefile.erik b/lang/cem/cemcom/Makefile.erik index af30e957e..f2348fa4c 100644 --- a/lang/cem/cemcom/Makefile.erik +++ b/lang/cem/cemcom/Makefile.erik @@ -9,7 +9,9 @@ EM_INCLUDES =$(EM)/h# # directory containing EM interface definition # Libraries SYSLIB = /user1/erikb/em/lib/libsystem.a -LIBS = $(SYSLIB) +EMLIB = /user1/erikb/em/lib/libemk.a +EMMESLIB = /user1/erikb/em/lib/libem_mes.a +LIBS = $(EMMESLIB) $(EMLIB) $(SYSLIB) LIB_INCLUDES = /user1/erikb/em/h # Where to install the compiler and its driver @@ -42,23 +44,22 @@ COBJ = main.o idf.o declarator.o decspecs.o struct.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 storage.o ival.o conversion.o \ - em.o blocks.o dataflow.o string.o + blocks.o dataflow.o string.o # Objects of other generated C files -GOBJ = char.o symbol2str.o next.o writeem.o +GOBJ = char.o symbol2str.o next.o # generated source files -GSRC = char.c symbol2str.c next.c writeem.c \ +GSRC = char.c symbol2str.c next.c \ code.h declar.h decspecs.h def.h expr.h field.h \ - idf.h macro.h stack.h struct.h switch.h type.h \ - writeem.h + idf.h macro.h stack.h struct.h switch.h type.h # .h files generated by `make hfiles'; PLEASE KEEP THIS UP-TO-DATE! GHSRC = botch_free.h dataflow.h debug.h density.h errout.h \ idepth.h idfsize.h ifdepth.h inputtype.h inumlength.h lapbuf.h \ maxincl.h myalloc.h nobitfield.h nopp.h \ nparams.h numsize.h parbufsize.h pathlength.h predefine.h \ - proc_intf.h strsize.h target_sizes.h textsize.h use_tmp.h \ + strsize.h target_sizes.h textsize.h use_tmp.h \ str_params.h spec_arith.h # Other generated files, for 'make clean' only @@ -119,12 +120,6 @@ struct.h: make.allocd switch.h: make.allocd type.h: make.allocd -writeem.c: make.emfun emcode.def - ./make.emfun emcode.def >writeem.c - -writeem.h: make.emmac emcode.def - ./make.emmac emcode.def >writeem.h - # Objects needed for 'main' OBJ = $(COBJ) $(LOBJ) $(GOBJ) @@ -199,40 +194,38 @@ ch7.o: Lpars.h arith.h assert.h debug.h def.h expr.h idf.h label.h nobitfield.h ch7bin.o: Lpars.h arith.h botch_free.h expr.h idf.h label.h nobitfield.h nopp.h spec_arith.h storage.h struct.h type.h cstoper.o: Lpars.h arith.h expr.h idf.h label.h nobitfield.h nopp.h sizes.h spec_arith.h target_sizes.h type.h arith.o: Lpars.h alloc.h arith.h botch_free.h expr.h field.h idf.h label.h mes.h nobitfield.h nopp.h spec_arith.h storage.h type.h -alloc.o: alloc.h assert.h debug.h myalloc.h -code.o: LLlex.h Lpars.h alloc.h arith.h assert.h atw.h botch_free.h code.h dataflow.h debug.h declar.h decspecs.h def.h em.h expr.h idf.h label.h level.h mes.h nobitfield.h nopp.h proc_intf.h sizes.h spec_arith.h specials.h stack.h storage.h type.h use_tmp.h writeem.h +alloc.o: alloc.h assert.h debug.h myalloc.h +code.o: LLlex.h Lpars.h alloc.h arith.h assert.h atw.h botch_free.h code.h dataflow.h debug.h declar.h decspecs.h def.h expr.h idf.h label.h level.h mes.h nobitfield.h nopp.h sizes.h spec_arith.h specials.h stack.h storage.h type.h use_tmp.h dumpidf.o: Lpars.h arith.h debug.h def.h expr.h field.h idf.h label.h nobitfield.h nopp.h spec_arith.h stack.h struct.h type.h -error.o: LLlex.h arith.h debug.h em.h errout.h expr.h label.h nopp.h proc_intf.h spec_arith.h string.h tokenname.h use_tmp.h writeem.h -field.o: Lpars.h arith.h assert.h code.h debug.h em.h expr.h field.h idf.h label.h nobitfield.h nopp.h proc_intf.h sizes.h spec_arith.h type.h writeem.h +error.o: LLlex.h arith.h debug.h errout.h expr.h label.h nopp.h spec_arith.h string.h tokenname.h use_tmp.h +field.o: Lpars.h arith.h assert.h code.h debug.h expr.h field.h idf.h label.h nobitfield.h nopp.h sizes.h spec_arith.h type.h tokenname.o: LLlex.h Lpars.h arith.h idf.h nopp.h spec_arith.h tokenname.h LLlex.o: LLlex.h Lpars.h alloc.h arith.h assert.h class.h debug.h def.h idf.h idfsize.h input.h nopp.h numsize.h sizes.h spec_arith.h strsize.h LLmessage.o: LLlex.h Lpars.h alloc.h arith.h idf.h nopp.h spec_arith.h -input.o: LLlex.h alloc.h arith.h assert.h debug.h idepth.h input.h inputtype.h interface.h nopp.h pathlength.h spec_arith.h +input.o: LLlex.h alloc.h arith.h assert.h debug.h idepth.h input.h inputtype.h interface.h nopp.h pathlength.h spec_arith.h domacro.o: LLlex.h Lpars.h alloc.h arith.h assert.h botch_free.h class.h debug.h idf.h idfsize.h ifdepth.h input.h interface.h macro.h nopp.h nparams.h parbufsize.h spec_arith.h storage.h textsize.h replace.o: LLlex.h alloc.h arith.h assert.h class.h debug.h idf.h input.h interface.h macro.h nopp.h pathlength.h spec_arith.h string.h strsize.h -init.o: alloc.h class.h idf.h interface.h macro.h nopp.h predefine.h string.h +init.o: alloc.h class.h idf.h interface.h macro.h nopp.h predefine.h string.h options.o: align.h arith.h class.h idf.h idfsize.h macro.h maxincl.h nobitfield.h nopp.h sizes.h spec_arith.h storage.h scan.o: class.h idf.h input.h interface.h lapbuf.h macro.h nopp.h nparams.h skip.o: LLlex.h arith.h class.h input.h interface.h nopp.h spec_arith.h -stack.o: Lpars.h alloc.h arith.h botch_free.h debug.h def.h em.h idf.h level.h mes.h nobitfield.h nopp.h proc_intf.h spec_arith.h stack.h storage.h struct.h type.h use_tmp.h writeem.h +stack.o: Lpars.h alloc.h arith.h botch_free.h debug.h def.h idf.h level.h mes.h nobitfield.h nopp.h spec_arith.h stack.h storage.h struct.h type.h use_tmp.h type.o: Lpars.h align.h alloc.h arith.h def.h idf.h nobitfield.h nopp.h sizes.h spec_arith.h type.h ch7mon.o: Lpars.h arith.h botch_free.h def.h expr.h idf.h label.h nobitfield.h nopp.h spec_arith.h storage.h type.h label.o: Lpars.h arith.h def.h idf.h label.h level.h nobitfield.h nopp.h spec_arith.h type.h -eval.o: Lpars.h align.h arith.h assert.h atw.h code.h dataflow.h debug.h def.h em.h expr.h idf.h label.h level.h mes.h nobitfield.h nopp.h proc_intf.h sizes.h spec_arith.h stack.h string.h type.h writeem.h -switch.o: arith.h assert.h botch_free.h code.h debug.h density.h em.h expr.h idf.h label.h nobitfield.h nopp.h proc_intf.h spec_arith.h storage.h switch.h type.h writeem.h +eval.o: Lpars.h align.h arith.h assert.h atw.h code.h dataflow.h debug.h def.h expr.h idf.h label.h level.h mes.h nobitfield.h nopp.h sizes.h spec_arith.h stack.h string.h type.h +switch.o: Lpars.h arith.h assert.h botch_free.h code.h debug.h density.h expr.h idf.h label.h nobitfield.h nopp.h spec_arith.h storage.h switch.h type.h storage.o: alloc.h assert.h botch_free.h debug.h storage.h -ival.o: Lpars.h align.h arith.h assert.h class.h debug.h def.h em.h expr.h field.h idf.h label.h level.h nobitfield.h nopp.h proc_intf.h sizes.h spec_arith.h string.h struct.h type.h writeem.h -conversion.o: Lpars.h arith.h em.h nobitfield.h proc_intf.h sizes.h spec_arith.h type.h writeem.h -em.o: arith.h em.h label.h proc_intf.h spec_arith.h writeem.h -blocks.o: arith.h atw.h em.h proc_intf.h sizes.h spec_arith.h writeem.h +ival.o: Lpars.h align.h arith.h assert.h class.h debug.h def.h expr.h field.h idf.h label.h level.h nobitfield.h nopp.h sizes.h spec_arith.h string.h struct.h type.h +conversion.o: Lpars.h arith.h nobitfield.h sizes.h spec_arith.h type.h +blocks.o: arith.h atw.h sizes.h spec_arith.h dataflow.o: dataflow.h -string.o: arith.h nopp.h spec_arith.h str_params.h string.h +string.o: arith.h nopp.h spec_arith.h str_params.h string.h tokenfile.o: Lpars.h declar.o: LLlex.h Lpars.h arith.h debug.h declar.h decspecs.h def.h expr.h field.h idf.h label.h nobitfield.h nopp.h sizes.h spec_arith.h struct.h type.h -statement.o: LLlex.h Lpars.h arith.h botch_free.h code.h debug.h def.h em.h expr.h idf.h label.h nobitfield.h nopp.h proc_intf.h spec_arith.h stack.h storage.h type.h writeem.h +statement.o: LLlex.h Lpars.h arith.h botch_free.h code.h debug.h def.h expr.h idf.h label.h nobitfield.h nopp.h spec_arith.h stack.h storage.h type.h expression.o: LLlex.h Lpars.h arith.h expr.h idf.h label.h nobitfield.h nopp.h spec_arith.h type.h program.o: LLlex.h Lpars.h alloc.h arith.h code.h declar.h decspecs.h def.h expr.h idf.h label.h nobitfield.h nopp.h spec_arith.h type.h Lpars.o: Lpars.h char.o: class.h symbol2str.o: Lpars.h -writeem.o: arith.h em.h label.h proc_intf.h spec_arith.h writeem.h diff --git a/lang/cem/cemcom/Parameters b/lang/cem/cemcom/Parameters index 09c7a9d70..1ae2b459c 100644 --- a/lang/cem/cemcom/Parameters +++ b/lang/cem/cemcom/Parameters @@ -95,10 +95,6 @@ #define DEBUG 1 /* perform various self-tests */ -!File: proc_intf.h -#define PROC_INTF 1 /* compile with procedural EM interface */ - - !File: use_tmp.h #define USE_TMP 1 /* collect exa, exp, ina and inp commands and let them precede the rest of diff --git a/lang/cem/cemcom/arith.h b/lang/cem/cemcom/arith.h index 551f7c90b..2e94f70b3 100644 --- a/lang/cem/cemcom/arith.h +++ b/lang/cem/cemcom/arith.h @@ -13,7 +13,7 @@ #ifndef SPECIAL_ARITHMETICS -#define arith long /* native */ +#include /* obtain definition of "arith" */ #else SPECIAL_ARITHMETICS diff --git a/lang/cem/cemcom/asm.c b/lang/cem/cemcom/asm.c index 21daf1f5d..3b8cd1f9a 100644 --- a/lang/cem/cemcom/asm.c +++ b/lang/cem/cemcom/asm.c @@ -1,8 +1,9 @@ /* $Header$ */ /* A S M */ -asm_seen(s) +asm_seen(s, l) char *s; + int l; { /* 'asm' '(' string ')' ';' */ diff --git a/lang/cem/cemcom/blocks.c b/lang/cem/cemcom/blocks.c index 799402e9d..3e4640d3e 100644 --- a/lang/cem/cemcom/blocks.c +++ b/lang/cem/cemcom/blocks.c @@ -1,7 +1,7 @@ /* $Header$ */ /* B L O C K S T O R I N G A N D L O A D I N G */ -#include "em.h" +#include #include "arith.h" #include "sizes.h" #include "atw.h" diff --git a/lang/cem/cemcom/code.c b/lang/cem/cemcom/code.c index 5e2e7365f..689daaa98 100644 --- a/lang/cem/cemcom/code.c +++ b/lang/cem/cemcom/code.c @@ -1,6 +1,8 @@ /* $Header$ */ /* C O D E - G E N E R A T I N G R O U T I N E S */ +#include + #include "dataflow.h" #include "use_tmp.h" #include "botch_free.h" @@ -15,7 +17,6 @@ #include "expr.h" #include "sizes.h" #include "stack.h" -#include "em.h" #include "level.h" #include "decspecs.h" #include "declar.h" @@ -113,13 +114,13 @@ code_scope(text, def) if (fund == FUNCTION) C_exp(text); else - C_exa(text); + C_exa_dnam(text); break; case STATIC: if (fund == FUNCTION) C_inp(text); else - C_ina(text); + C_ina_dnam(text); break; } } @@ -175,7 +176,10 @@ begin_proc(name, def) /* to be called when entering a procedure */ if (strcmp(last_fn_given, FileName) != 0) { /* previous function came from other file */ C_df_dlb(file_name_label = data_label()); - C_con_scon(last_fn_given = FileName, (arith)0); + C_con_scon( + last_fn_given = FileName, + (arith)(strlen(FileName) + 1) + ); } /* enable debug trace of EM source */ C_fil_dlb(file_name_label, (arith)0); diff --git a/lang/cem/cemcom/conversion.c b/lang/cem/cemcom/conversion.c index 07188d6c9..b74f779bf 100644 --- a/lang/cem/cemcom/conversion.c +++ b/lang/cem/cemcom/conversion.c @@ -1,9 +1,9 @@ /* $Header$ */ /* C O N V E R S I O N - C O D E G E N E R A T O R */ +#include #include "arith.h" #include "type.h" -#include "em.h" #include "sizes.h" #include "Lpars.h" diff --git a/lang/cem/cemcom/domacro.c b/lang/cem/cemcom/domacro.c index f2d76d9eb..b0afb18da 100644 --- a/lang/cem/cemcom/domacro.c +++ b/lang/cem/cemcom/domacro.c @@ -229,7 +229,7 @@ do_include() AccFileSpecifier = 1; if (((tok = GetToken(&tk)) == FILESPECIFIER) || tok == STRING) - filenm = tk.tk_str; + filenm = tk.tk_bts; else { lexerror("bad include syntax"); filenm = (char *)0; @@ -393,7 +393,7 @@ do_line(l) LineNumber = l; /* is there a filespecifier? */ if (GetToken(&tk) == STRING) - FileName = tk.tk_str; + FileName = tk.tk_bts; SkipRestOfLine(); } @@ -652,7 +652,7 @@ domacro() } LineNumber = tk.tk_ival; if ((tok = GetToken(&tk)) == STRING) - FileName = tk.tk_str; + FileName = tk.tk_bts; else if (tok != EOI) { error("illegal # line"); diff --git a/lang/cem/cemcom/error.c b/lang/cem/cemcom/error.c index f29e72cdc..bbfe23de5 100644 --- a/lang/cem/cemcom/error.c +++ b/lang/cem/cemcom/error.c @@ -2,6 +2,8 @@ /* E R R O R A N D D I A G N O S T I C R O U T I N E S */ #include +#include + #include "nopp.h" #include "use_tmp.h" #include "errout.h" @@ -13,7 +15,6 @@ #include "label.h" #include "expr.h" #include "LLlex.h" -#include "em.h" /* This file contains the (non-portable) error-message and diagnostic functions. Beware, they are called with a variable number of diff --git a/lang/cem/cemcom/eval.c b/lang/cem/cemcom/eval.c index 719338bb2..ab3af1cd3 100644 --- a/lang/cem/cemcom/eval.c +++ b/lang/cem/cemcom/eval.c @@ -12,6 +12,8 @@ compare() */ +#include + #include "debug.h" #include "nobitfield.h" @@ -32,7 +34,6 @@ #include "align.h" #include "mes.h" #include "atw.h" -#include "em.h" #define CRASH() crash("EVAL: CRASH at line %u", __LINE__) #define roundup(n) ((n) < word_size ? word_size : (n)) @@ -90,7 +91,7 @@ EVAL(expr, val, code, true_label, false_label) label datlab = data_label(); C_df_dlb(datlab); - C_con_scon(expr->SG_VALUE, (arith)0); + C_con_scon(expr->SG_VALUE, (arith)expr->SG_LEN); C_lae_dlb(datlab, (arith)0); } break; diff --git a/lang/cem/cemcom/expr.c b/lang/cem/cemcom/expr.c index 3e4fcacfe..f343c6adb 100644 --- a/lang/cem/cemcom/expr.c +++ b/lang/cem/cemcom/expr.c @@ -200,7 +200,8 @@ string2expr(expr) expr->ex_type = string_type; expr->ex_lvalue = 0; expr->ex_class = String; - expr->SG_VALUE = dot.tk_str; + expr->SG_VALUE = dot.tk_bts; + expr->SG_LEN = dot.tk_len; expr->SG_DATLAB = 0; } diff --git a/lang/cem/cemcom/expr.str b/lang/cem/cemcom/expr.str index b322e8998..5809dccae 100644 --- a/lang/cem/cemcom/expr.str +++ b/lang/cem/cemcom/expr.str @@ -11,7 +11,8 @@ struct value { }; struct string { - char *sg_value; /* string of characters repr. the constant */ + char *sg_value; /* row of bytes repr. the constant */ + int sg_len; /* length of the row */ label sg_datlab; /* global data-label */ }; @@ -55,6 +56,7 @@ struct expr { #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_LEN ex_object.ex_string.sg_len #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 diff --git a/lang/cem/cemcom/field.c b/lang/cem/cemcom/field.c index d9cc1e29b..bc0b76d27 100644 --- a/lang/cem/cemcom/field.c +++ b/lang/cem/cemcom/field.c @@ -4,6 +4,8 @@ #include "nobitfield.h" #ifndef NOBITFIELD +#include + #include "debug.h" #include "arith.h" @@ -16,7 +18,6 @@ #include "sizes.h" #include "Lpars.h" #include "field.h" -#include "em.h" arith tmp_pointer_var(); /* eval.c */ char *symbol2str(); /* symbol2str.c */ diff --git a/lang/cem/cemcom/ival.c b/lang/cem/cemcom/ival.c index 55cb9ff37..d843546d4 100644 --- a/lang/cem/cemcom/ival.c +++ b/lang/cem/cemcom/ival.c @@ -1,11 +1,12 @@ /* $Header$ */ /* CODE FOR THE INITIALISATION OF GLOBAL VARIABLES */ +#include + #include "debug.h" #include "nobitfield.h" #include "string.h" -#include "em.h" #include "arith.h" #include "align.h" #include "label.h" @@ -48,7 +49,7 @@ do_ival(tpp, expr) */ while (strings != 0) { C_df_dlb(strings->SG_DATLAB); - C_con_scon(strings->SG_VALUE, (arith)0); + C_con_scon(strings->SG_VALUE, (arith)strings->SG_LEN); strings = strings->next; } } @@ -97,32 +98,25 @@ IVAL(tpp, expr) */ if (tp->tp_up->tp_fund == CHAR && expr->ex_class == String) init_string(tpp, expr); - else { - /* " int i[24] = 12;" */ + else /* " int i[24] = 12;" */ check_and_pad(expr, tpp); - } return 0; /* nothing left */ case STRUCT: /* struct initialisation */ if (valid_type(tp, "struct") == 0) return 0; - if (ISCOMMA(expr)) { - /* list of initialisation expressions */ + if (ISCOMMA(expr)) /* list of initialisation expressions */ return do_struct(expr, tp); - } /* "struct foo f = 12;" */ check_and_pad(expr, tpp); return 0; case UNION: - /* sorry, but .... */ error("union initialisation not allowed"); return 0; case ERRONEOUS: return 0; - default: - /* fundamental type */ - if (ISCOMMA(expr)) { - /* " int i = {12};" */ + default: /* fundamental type */ + if (ISCOMMA(expr)) { /* " int i = {12};" */ if (IVAL(tpp, expr->OP_LEFT) != 0) too_many_initialisers(expr); /* return remainings of the list for the @@ -500,7 +494,7 @@ check_ival(expr, type) { label datlab = data_label(); - C_ina_pt(datlab); + C_ina_dlb(datlab); C_con_dlb(datlab, (arith)0); expr->SG_DATLAB = datlab; store_string(expr); @@ -557,8 +551,6 @@ check_ival(expr, type) /* init_string() initialises an array of characters by specifying a string constant. - Escaped characters should be converted into its corresponding - ASCII character value. E.g. '\000' -> (char) 0. Alignment is taken care of. */ init_string(tpp, expr) @@ -570,7 +562,7 @@ init_string(tpp, expr) char *s = expr->SG_VALUE; arith ntopad; - length = prepare_string(s); + length = expr->SG_LEN; if (tp->tp_size == (arith)-1) { /* set the dimension */ tp = *tpp = construct_type(ARRAY, tp->tp_up, length); @@ -593,73 +585,6 @@ init_string(tpp, expr) con_byte(0); } -/* prepare_string() strips the escaped characters of a - string and replaces them by the ascii characters they stand for. - The ascii length of the resulting string is returned, including the - terminating null-character. -*/ -int -prepare_string(str) - register char *str; -{ - register char *t = str; - register count = 1; /* there's always a null at the end ! */ - - while (*str) { - count++; - if (*str == '\\') { - switch (*++str) { - case 'b': - *t++ = '\b'; - str++; - break; - case 'f': - *t++ = '\f'; - str++; - break; - case 'n': - *t++ = '\n'; - str++; - break; - case 'r': - *t++ = '\r'; - str++; - break; - case 't': - *t++ = '\t'; - str++; - break; - - /* octal value of: */ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - { - register cnt = 0, oct = 0; - - do - oct = oct * 8 + *str - '0'; - while (is_oct(*++str) && ++cnt < 3); - *t++ = (char) oct; - break; - } - default: - *t++ = *str++; - break; - } - } - else - *t++ = *str++; - } - *t = '\0'; /* don't forget this one !!! */ - return count; -} - #ifndef NOBITFIELD /* put_bf() takes care of the initialisation of (bit-)field selectors of a struct: each time such an initialisation takes place, diff --git a/lang/cem/cemcom/label.h b/lang/cem/cemcom/label.h index dc93d5c3d..27a1e768b 100644 --- a/lang/cem/cemcom/label.h +++ b/lang/cem/cemcom/label.h @@ -1,7 +1,8 @@ /* $Header$ */ /* L A B E L D E F I N I T I O N */ -#define label unsigned int +#include /* obtain definition of "label" */ + #define NO_LABEL (label) 0 extern label lab_count; diff --git a/lang/cem/cemcom/main.c b/lang/cem/cemcom/main.c index b0354cebd..276b11f01 100644 --- a/lang/cem/cemcom/main.c +++ b/lang/cem/cemcom/main.c @@ -321,31 +321,24 @@ preprocess() printf("\n#line %ld \"%s\"\n", lastlineno, lastfilenm); } - switch (DOT) { - case IDENTIFIER: case TYPE_IDENTIFIER: printf(dot.tk_idf->id_text); printf(" "); break; - case STRING: - printf("\"%s\" ", dot.tk_str); + printf("\"%s\" ", dot.tk_bts); break; - case INTEGER: printf("%ld ", dot.tk_ival); break; - case FLOATING: printf("%s ", dot.tk_fval); break; - case EOI: case EOF: return; - default: /* very expensive... */ printf("%s ", symbol2str(DOT)); } diff --git a/lang/cem/cemcom/stack.c b/lang/cem/cemcom/stack.c index 5b509b4a1..90e9562af 100644 --- a/lang/cem/cemcom/stack.c +++ b/lang/cem/cemcom/stack.c @@ -1,11 +1,14 @@ /* DERIVED FROM $Header$ */ /* S T A C K / U N S T A C K R O U T I N E S */ +#include +#include +#include + #include "debug.h" #include "use_tmp.h" #include "botch_free.h" -#include #include "alloc.h" #include "Lpars.h" #include "arith.h" @@ -17,7 +20,6 @@ #include "storage.h" #include "level.h" #include "mes.h" -#include "em.h" /* #include */ diff --git a/lang/cem/cemcom/statement.g b/lang/cem/cemcom/statement.g index da25a9471..c2eb806f9 100644 --- a/lang/cem/cemcom/statement.g +++ b/lang/cem/cemcom/statement.g @@ -2,6 +2,8 @@ /* STATEMENT SYNTAX PARSER */ { +#include + #include "debug.h" #include "botch_free.h" @@ -13,7 +15,6 @@ #include "expr.h" #include "code.h" #include "storage.h" -#include "em.h" #include "stack.h" #include "def.h" @@ -386,16 +387,18 @@ compound_statement(arith *nbytes;): ; asm_statement - { char *asm_string; + { char *asm_bts; + int asm_len; } : ASM '(' STRING - { asm_string = dot.tk_str; + { asm_bts = dot.tk_bts; + asm_len = dot.tk_len; } ')' ';' - { asm_seen(asm_string); + { asm_seen(asm_bts, asm_len); } ; diff --git a/lang/cem/cemcom/switch.c b/lang/cem/cemcom/switch.c index ba0c7458f..7965c7009 100644 --- a/lang/cem/cemcom/switch.c +++ b/lang/cem/cemcom/switch.c @@ -1,6 +1,8 @@ /* $Header$ */ /* S W I T C H - S T A T E M E N T A D M I N I S T R A T I O N */ +#include + #include "debug.h" #include "botch_free.h" #include "density.h" @@ -15,7 +17,6 @@ #include "assert.h" #include "expr.h" #include "type.h" -#include "em.h" extern char options[]; -- 2.34.1