diff --git a/lang/m2/comp/declar.g b/lang/m2/comp/declar.g index 6b7af4496..159e7f238 100644 --- a/lang/m2/comp/declar.g +++ b/lang/m2/comp/declar.g @@ -18,7 +18,6 @@ #include #include "strict3rd.h" -#include "dbsymtab.h" #include "idf.h" #include "LLlex.h" #include "def.h" @@ -114,17 +113,11 @@ declaration { ++proclevel; } ProcedureHeading(&df, D_PROCEDURE) { -#ifdef DBSYMTAB - if (options['g']) stb_string(df, D_PROCEDURE); -#endif /* DBSYMTAB */ } ';' block(&(df->prc_body)) IDENT { -#ifdef DBSYMTAB - if (options['g']) stb_string(df, D_PEND); -#endif /* DBSYMTAB */ EndProc(df, dot.TOK_IDF); --proclevel; } @@ -540,9 +533,6 @@ ConstantDeclaration df->con_const = nd->nd_token; df->df_type = nd->nd_type; FreeNode(nd); -#ifdef DBSYMTAB - if (options['g']) stb_string(df, D_CONST); -#endif /* DBSYMTAB */ } ; diff --git a/lang/m2/comp/enter.c b/lang/m2/comp/enter.c index 2d7a39955..8660f682e 100644 --- a/lang/m2/comp/enter.c +++ b/lang/m2/comp/enter.c @@ -183,9 +183,6 @@ EnterVarList(Idlist, type, local) C_ina_dnam(df->var_name); } } -#ifdef DBSYMTAB - if (options['g']) stb_string(df, D_VARIABLE); -#endif /* DBSYMTAB */ } FreeNode(Idlist); } diff --git a/lang/m2/comp/main.c b/lang/m2/comp/main.c index 5839c690f..ca41411ac 100644 --- a/lang/m2/comp/main.c +++ b/lang/m2/comp/main.c @@ -271,11 +271,13 @@ print("\nNumber of lines read: %d\n", cntlines); } #endif +void No_Mem() { fatal("out of memory"); } +void C_failed() { fatal("write failed"); diff --git a/lang/m2/comp/program.g b/lang/m2/comp/program.g index 96faf91e9..9448959f1 100644 --- a/lang/m2/comp/program.g +++ b/lang/m2/comp/program.g @@ -18,8 +18,8 @@ #include #include -#include "strict3rd.h" #include "dbsymtab.h" +#include "strict3rd.h" #include "main.h" #include "idf.h" #include "LLlex.h" @@ -64,16 +64,8 @@ ModuleDeclaration ';' import(1)* export(&qualified, &exportlist) - { -#ifdef DBSYMTAB - if (options['g']) stb_string(df, D_MODULE); -#endif /* DBSYMTAB */ - } block(&(df->mod_body)) IDENT { EnterExportList(exportlist, qualified); -#ifdef DBSYMTAB - if (options['g']) stb_string(df, D_END); -#endif /* DBSYMTAB */ close_scope(SC_CHKFORW|SC_CHKPROC|SC_REVERSE); match_id(df->df_idf, dot.TOK_IDF); } @@ -166,9 +158,6 @@ DefinitionModule DefinitionModule++; if (!Defined) { Defined = df; -#ifdef DBSYMTAB - if (options['g']) stb_string(df, D_MODULE); -#endif /* DBSYMTAB */ } } ';' @@ -219,12 +208,12 @@ definition df->df_type = construct_type(T_HIDDEN, NULLTYPE); } ] - ';' { #ifdef DBSYMTAB - if (options['g']) stb_string(df, D_TYPE); -#endif /* DBSYMTAB */ + if (options['g']) stb_string(df, D_TYPE); +#endif } + ';' ]* | VAR [ %persistent VariableDeclaration ';' ]* @@ -254,26 +243,12 @@ ProgramModule df->mod_vis = CurrVis; CurrentScope->sc_name = "__M2M_"; CurrentScope->sc_definedby = df; -#ifdef DBSYMTAB - if (options['g']) stb_string(df, D_MODULE); -#endif /* DBSYMTAB */ } } priority(&(df->mod_priority)) ';' import(0)* block(&(df->mod_body)) IDENT { -#ifdef DBSYMTAB - if (options['g']) { - if (state == PROGRAM) { - C_ms_stb_cst(df->df_idf->id_text, - N_MAIN, - 0, - (arith) 0); - } - stb_string(df, D_END); - } -#endif /* DBSYMTAB */ close_scope(SC_CHKFORW|SC_CHKPROC|SC_REVERSE); match_id(df->df_idf, dot.TOK_IDF); } diff --git a/lang/m2/comp/walk.c b/lang/m2/comp/walk.c index 2294c8595..cdf468d7a 100644 --- a/lang/m2/comp/walk.c +++ b/lang/m2/comp/walk.c @@ -60,6 +60,9 @@ static int oldlineno; static int RegisterMessage(); static int WalkDef(); +#ifdef DBSYMTAB +static int stabdef(); +#endif static int MkCalls(); static int UseWarnings(); @@ -194,6 +197,19 @@ WalkModule(module) text_label = 1; /* label at end of initialization routine */ TmpOpen(sc); /* Initialize for temporaries */ C_pro_narg(sc->sc_name); +#ifdef DBSYMTAB + if (options['g']) { + stb_string(module, D_MODULE); + WalkDefList(sc->sc_def, stabdef); + if (state == PROGRAM && module == Defined) { + C_ms_stb_cst(module->df_idf->id_text, + N_MAIN, + 0, + (arith) 0); + } + stb_string(module, D_END); + } +#endif DoPriority(); if (module == Defined) { /* Body of implementation or program module. @@ -317,6 +333,9 @@ WalkProcedure(procedure) C_pro_narg(procedure->prc_name); #ifdef DBSYMTAB if (options['g']) { + stb_string(procedure, D_PROCEDURE); + WalkDefList(procscope->sc_def, stabdef); + stb_string(procedure, D_PEND); C_ms_std((char *) 0, N_LBRAC, proclevel); } #endif /* DBSYMTAB */ @@ -487,6 +506,9 @@ WalkProcedure(procedure) C_pro(procedure->prc_name, -procscope->sc_off); #ifdef DBSYMTAB if (options['g']) { + stb_string(procedure, D_PROCEDURE); + WalkDefList(procscope->sc_def, stabdef); + stb_string(procedure, D_PEND); C_ms_std((char *) 0, N_LBRAC, proclevel); } #endif /* DBSYMTAB */ @@ -1115,3 +1137,17 @@ WalkDefList(df, proc) (*proc)(df); } } + +#ifdef DBSYMTAB +static int +stabdef(df) + t_def *df; +{ + switch(df->df_kind) { + case D_CONST: + case D_VARIABLE: + stb_string(df, df->df_kind); + break; + } +} +#endif