made D_ definitions a long and made symbol table generation conditional
This commit is contained in:
parent
612217f906
commit
720d775582
|
@ -79,7 +79,7 @@ SRC = $(CSRC) $(GENCFILES)
|
||||||
GENGFILES= tokenfile.g
|
GENGFILES= tokenfile.g
|
||||||
GENHFILES= Lpars.h debugcst.h density.h errout.h idfsize.h inputtype.h\
|
GENHFILES= Lpars.h debugcst.h density.h errout.h idfsize.h inputtype.h\
|
||||||
numsize.h strsize.h def.h type.h desig.h scope.h node.h\
|
numsize.h strsize.h def.h type.h desig.h scope.h node.h\
|
||||||
target_sizes.h nocross.h
|
target_sizes.h nocross.h dbsymtab.h
|
||||||
HFILES= LLlex.h chk_expr.h class.h const.h debug.h def.h desig.h\
|
HFILES= LLlex.h chk_expr.h class.h const.h debug.h def.h desig.h\
|
||||||
f_info.h idf.h input.h main.h misc.h node.h required.h scope.h\
|
f_info.h idf.h input.h main.h misc.h node.h required.h scope.h\
|
||||||
tokenname.h type.h $(GENHFILES)
|
tokenname.h type.h $(GENHFILES)
|
||||||
|
|
|
@ -55,3 +55,7 @@
|
||||||
|
|
||||||
!File: nocross.h
|
!File: nocross.h
|
||||||
#undef NOCROSS 1 /* define when cross compiler not needed */
|
#undef NOCROSS 1 /* define when cross compiler not needed */
|
||||||
|
|
||||||
|
|
||||||
|
!File: dbsymtab.h
|
||||||
|
#define DBSYMTAB 1 /* ability to produce symbol table for debugger */
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "node.h"
|
#include "node.h"
|
||||||
#include "scope.h"
|
#include "scope.h"
|
||||||
#include "type.h"
|
#include "type.h"
|
||||||
|
#include "dbsymtab.h"
|
||||||
|
|
||||||
#define offsetof(type, field) (int) &(((type *)0)->field)
|
#define offsetof(type, field) (int) &(((type *)0)->field)
|
||||||
#define PC_BUFSIZ (sizeof(struct file) - (int)((struct file *)0)->bufadr)
|
#define PC_BUFSIZ (sizeof(struct file) - (int)((struct file *)0)->bufadr)
|
||||||
|
@ -180,7 +181,9 @@ ConstantDefinition
|
||||||
df->con_const = nd;
|
df->con_const = nd;
|
||||||
df->df_type = nd->nd_type;
|
df->df_type = nd->nd_type;
|
||||||
df->df_flags |= D_SET;
|
df->df_flags |= D_SET;
|
||||||
|
#ifdef DBSYMTAB
|
||||||
if (options['g']) stb_string(df, D_CONST);
|
if (options['g']) stb_string(df, D_CONST);
|
||||||
|
#endif /* DBSYMTAB */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
@ -197,7 +200,9 @@ TypeDefinition
|
||||||
{ if( df = define(id, CurrentScope, D_TYPE) ) {
|
{ if( df = define(id, CurrentScope, D_TYPE) ) {
|
||||||
df->df_type = tp;
|
df->df_type = tp;
|
||||||
df->df_flags |= D_SET;
|
df->df_flags |= D_SET;
|
||||||
|
#ifdef DBSYMTAB
|
||||||
if (options['g']) stb_string(df, D_TYPE);
|
if (options['g']) stb_string(df, D_TYPE);
|
||||||
|
#endif /* DBSYMTAB */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
@ -289,11 +294,15 @@ ProcedureDeclaration
|
||||||
{ DoDirective(dot.TOK_IDF, nd, tp, scl, 0); }
|
{ DoDirective(dot.TOK_IDF, nd, tp, scl, 0); }
|
||||||
|
|
|
|
||||||
{ df = DeclProc(nd, tp, scl);
|
{ df = DeclProc(nd, tp, scl);
|
||||||
|
#ifdef DBSYMTAB
|
||||||
if (options['g']) stb_string(df, D_PROCEDURE);
|
if (options['g']) stb_string(df, D_PROCEDURE);
|
||||||
|
#endif /* DBSYMTAB */
|
||||||
}
|
}
|
||||||
Block(df)
|
Block(df)
|
||||||
{ /* open_scope() is simulated in DeclProc() */
|
{ /* open_scope() is simulated in DeclProc() */
|
||||||
|
#ifdef DBSYMTAB
|
||||||
if (options['g']) stb_string(df, D_PEND);
|
if (options['g']) stb_string(df, D_PEND);
|
||||||
|
#endif /* DBSYMTAB */
|
||||||
close_scope();
|
close_scope();
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -368,12 +377,16 @@ FunctionDeclaration
|
||||||
df->prc_bool =
|
df->prc_bool =
|
||||||
CurrentScope->sc_off =
|
CurrentScope->sc_off =
|
||||||
df->prc_res - int_size;
|
df->prc_res - int_size;
|
||||||
|
#ifdef DBSYMTAB
|
||||||
if (options['g']) stb_string(df, D_FUNCTION);
|
if (options['g']) stb_string(df, D_FUNCTION);
|
||||||
|
#endif /* DBSYMTAB */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Block(df)
|
Block(df)
|
||||||
{ if( df ) {
|
{ if( df ) {
|
||||||
|
#ifdef DBSYMTAB
|
||||||
if (options['g']) stb_string(df, D_PEND);
|
if (options['g']) stb_string(df, D_PEND);
|
||||||
|
#endif /* DBSYMTAB */
|
||||||
EndFunc(df);
|
EndFunc(df);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,32 +80,32 @@ struct def { /* list of definitions for a name */
|
||||||
struct idf *df_idf; /* link back to the name */
|
struct idf *df_idf; /* link back to the name */
|
||||||
struct scope *df_scope; /* scope in which this definition resides */
|
struct scope *df_scope; /* scope in which this definition resides */
|
||||||
long df_kind; /* the kind of this definition: */
|
long df_kind; /* the kind of this definition: */
|
||||||
#define D_PROCEDURE 0x000001 /* procedure */
|
#define D_PROCEDURE 0x000001L /* procedure */
|
||||||
#define D_FUNCTION 0x000002 /* function */
|
#define D_FUNCTION 0x000002L /* function */
|
||||||
#define D_TYPE 0x000004 /* a type */
|
#define D_TYPE 0x000004L /* a type */
|
||||||
#define D_CONST 0x000008 /* a constant */
|
#define D_CONST 0x000008L /* a constant */
|
||||||
#define D_ENUM 0x000010 /* an enumeration literal */
|
#define D_ENUM 0x000010L /* an enumeration literal */
|
||||||
#define D_FIELD 0x000020 /* a field in a record */
|
#define D_FIELD 0x000020L /* a field in a record */
|
||||||
#define D_PROGRAM 0x000040 /* the program */
|
#define D_PROGRAM 0x000040L /* the program */
|
||||||
#define D_VARIABLE 0x000080 /* a variable */
|
#define D_VARIABLE 0x000080L /* a variable */
|
||||||
#define D_PARAMETER 0x000100 /* program parameter */
|
#define D_PARAMETER 0x000100L /* program parameter */
|
||||||
#define D_FORWTYPE 0x000200 /* forward type */
|
#define D_FORWTYPE 0x000200L /* forward type */
|
||||||
#define D_FTYPE 0x000400 /* resolved forward type */
|
#define D_FTYPE 0x000400L /* resolved forward type */
|
||||||
#define D_FWPROCEDURE 0x000800 /* forward procedure */
|
#define D_FWPROCEDURE 0x000800L /* forward procedure */
|
||||||
#define D_FWFUNCTION 0x001000 /* forward function */
|
#define D_FWFUNCTION 0x001000L /* forward function */
|
||||||
#define D_LABEL 0x002000 /* a label */
|
#define D_LABEL 0x002000L /* a label */
|
||||||
#define D_LBOUND 0x004000 /* lower bound id. in conform. array */
|
#define D_LBOUND 0x004000L /* lower bound id. in conform. array */
|
||||||
#define D_UBOUND 0x008000 /* upper bound id. in conform. array */
|
#define D_UBOUND 0x008000L /* upper bound id. in conform. array */
|
||||||
#define D_FORWARD 0x010000 /* directive "forward" */
|
#define D_FORWARD 0x010000L /* directive "forward" */
|
||||||
#define D_EXTERN 0x020000 /* directive "extern" */
|
#define D_EXTERN 0x020000L /* directive "extern" */
|
||||||
#define D_ERROR 0x040000 /* a compiler generated definition
|
#define D_ERROR 0x040000L /* a compiler generated definition
|
||||||
* for an undefined variable */
|
* for an undefined variable */
|
||||||
#define D_MODULE 0x080000 /* the module */
|
#define D_MODULE 0x080000L /* the module */
|
||||||
#define D_INUSE 0x100000 /* variable is in use */
|
#define D_INUSE 0x100000L /* variable is in use */
|
||||||
|
|
||||||
/* special values for stab.c */
|
/* special values for stab.c */
|
||||||
#define D_END (D_MODULE|D_PROCEDURE)
|
#define D_END (D_PROGRAM|D_PROCEDURE)
|
||||||
#define D_PEND (D_MODULE|D_PROCEDURE|D_VARIABLE)
|
#define D_PEND (D_PROGRAM|D_PROCEDURE|D_VARIABLE)
|
||||||
|
|
||||||
#define D_VALUE (D_FUNCTION | D_CONST | D_ENUM | D_FIELD | D_VARIABLE\
|
#define D_VALUE (D_FUNCTION | D_CONST | D_ENUM | D_FIELD | D_VARIABLE\
|
||||||
| D_FWFUNCTION | D_LBOUND | D_UBOUND)
|
| D_FWFUNCTION | D_LBOUND | D_UBOUND)
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "node.h"
|
#include "node.h"
|
||||||
#include "scope.h"
|
#include "scope.h"
|
||||||
#include "type.h"
|
#include "type.h"
|
||||||
|
#include "dbsymtab.h"
|
||||||
|
|
||||||
extern int proclevel;
|
extern int proclevel;
|
||||||
extern int parlevel;
|
extern int parlevel;
|
||||||
|
@ -20,6 +21,7 @@ struct def *
|
||||||
Enter(name, kind, type, pnam)
|
Enter(name, kind, type, pnam)
|
||||||
char *name;
|
char *name;
|
||||||
register struct type *type;
|
register struct type *type;
|
||||||
|
long kind;
|
||||||
{
|
{
|
||||||
/* Enter a definition for "name" with kind "kind" and type
|
/* Enter a definition for "name" with kind "kind" and type
|
||||||
"type" in the Current Scope. If it is a standard name, also
|
"type" in the Current Scope. If it is a standard name, also
|
||||||
|
@ -34,7 +36,9 @@ Enter(name, kind, type, pnam)
|
||||||
df->df_value.df_reqname = pnam;
|
df->df_value.df_reqname = pnam;
|
||||||
df->df_flags |= D_SET;
|
df->df_flags |= D_SET;
|
||||||
}
|
}
|
||||||
|
#ifdef DBSYMTAB
|
||||||
else if (options['g']) stb_string(df, kind);
|
else if (options['g']) stb_string(df, kind);
|
||||||
|
#endif /* DBSYMTAB */
|
||||||
return df;
|
return df;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +69,9 @@ EnterProgList(Idlist)
|
||||||
df->var_name = output;
|
df->var_name = output;
|
||||||
set_outp();
|
set_outp();
|
||||||
}
|
}
|
||||||
|
#ifdef DBSYMTAB
|
||||||
if (options['g']) stb_string(df, D_VARIABLE);
|
if (options['g']) stb_string(df, D_VARIABLE);
|
||||||
|
#endif /* DBSYMTAB */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -163,7 +169,9 @@ EnterVarList(Idlist, type, local)
|
||||||
df->var_name = df->df_idf->id_text;
|
df->var_name = df->df_idf->id_text;
|
||||||
df->df_flags |= D_NOREG;
|
df->df_flags |= D_NOREG;
|
||||||
}
|
}
|
||||||
|
#ifdef DBSYMTAB
|
||||||
if (options['g']) stb_string(df, D_VARIABLE);
|
if (options['g']) stb_string(df, D_VARIABLE);
|
||||||
|
#endif /* DBSYMTAB */
|
||||||
}
|
}
|
||||||
FreeNode(Idlist);
|
FreeNode(Idlist);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "tokenname.h"
|
#include "tokenname.h"
|
||||||
#include "type.h"
|
#include "type.h"
|
||||||
#include "scope.h"
|
#include "scope.h"
|
||||||
|
#include "dbsymtab.h"
|
||||||
|
|
||||||
char options[128];
|
char options[128];
|
||||||
char *ProgName;
|
char *ProgName;
|
||||||
|
@ -106,9 +107,11 @@ Compile(src, dst)
|
||||||
fatal("couldn't open output file");
|
fatal("couldn't open output file");
|
||||||
C_magic();
|
C_magic();
|
||||||
C_ms_emx(word_size, pointer_size);
|
C_ms_emx(word_size, pointer_size);
|
||||||
|
#ifdef DBSYMTAB
|
||||||
if (options['g']) {
|
if (options['g']) {
|
||||||
C_ms_std(FileName, N_SO, 0);
|
C_ms_std(FileName, N_SO, 0);
|
||||||
}
|
}
|
||||||
|
#endif /* DBSYMTAB */
|
||||||
AddRequired();
|
AddRequired();
|
||||||
C_df_dlb(++data_label);
|
C_df_dlb(++data_label);
|
||||||
C_rom_scon(FileName,(arith) strlen(FileName) + 1);
|
C_rom_scon(FileName,(arith) strlen(FileName) + 1);
|
||||||
|
@ -250,7 +253,9 @@ AddRequired()
|
||||||
df->df_type = int_type;
|
df->df_type = int_type;
|
||||||
df->con_const = &maxintnode;
|
df->con_const = &maxintnode;
|
||||||
df->df_flags |= D_SET;
|
df->df_flags |= D_SET;
|
||||||
|
#ifdef DBSYMTAB
|
||||||
if (options['g']) stb_string(df, D_CONST);
|
if (options['g']) stb_string(df, D_CONST);
|
||||||
|
#endif /* DBSYMTAB */
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "node.h"
|
#include "node.h"
|
||||||
#include "scope.h"
|
#include "scope.h"
|
||||||
|
#include "dbsymtab.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
%lexical LLlex;
|
%lexical LLlex;
|
||||||
|
@ -28,10 +29,13 @@ Program
|
||||||
}:
|
}:
|
||||||
ProgramHeading(&df)
|
ProgramHeading(&df)
|
||||||
';' Block(df) '.'
|
';' Block(df) '.'
|
||||||
{ if (options['g']) {
|
{
|
||||||
|
#ifdef DBSYMTAB
|
||||||
|
if (options['g']) {
|
||||||
C_ms_stb_cst(df->df_idf->id_text, N_MAIN, 0, (arith) 0);
|
C_ms_stb_cst(df->df_idf->id_text, N_MAIN, 0, (arith) 0);
|
||||||
stb_string(df, D_END);
|
stb_string(df, D_END);
|
||||||
}
|
}
|
||||||
|
#endif /* DBSYMTAB */
|
||||||
}
|
}
|
||||||
| { df = new_def();
|
| { df = new_def();
|
||||||
df->df_idf = str2idf(FileName, 1);
|
df->df_idf = str2idf(FileName, 1);
|
||||||
|
@ -52,7 +56,9 @@ ProgramHeading(register struct def **df;):
|
||||||
open_scope();
|
open_scope();
|
||||||
GlobalScope = CurrentScope;
|
GlobalScope = CurrentScope;
|
||||||
(*df)->prc_vis = CurrVis;
|
(*df)->prc_vis = CurrVis;
|
||||||
|
#ifdef DBSYMTAB
|
||||||
if (options['g']) stb_string(*df, D_MODULE);
|
if (options['g']) stb_string(*df, D_MODULE);
|
||||||
|
#endif /* DBSYMTAB */
|
||||||
}
|
}
|
||||||
[
|
[
|
||||||
'('
|
'('
|
||||||
|
|
|
@ -9,6 +9,10 @@
|
||||||
|
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
|
|
||||||
|
#include "dbsymtab.h"
|
||||||
|
|
||||||
|
#ifdef DBSYMTAB
|
||||||
|
|
||||||
#include <alloc.h>
|
#include <alloc.h>
|
||||||
#include <em_arith.h>
|
#include <em_arith.h>
|
||||||
#include <em_label.h>
|
#include <em_label.h>
|
||||||
|
@ -225,6 +229,7 @@ stb_type(tp, assign_num)
|
||||||
|
|
||||||
stb_string(df, kind)
|
stb_string(df, kind)
|
||||||
register struct def *df;
|
register struct def *df;
|
||||||
|
long kind;
|
||||||
{
|
{
|
||||||
register struct type *tp = df->df_type;
|
register struct type *tp = df->df_type;
|
||||||
char buf[64];
|
char buf[64];
|
||||||
|
@ -232,11 +237,12 @@ stb_string(df, kind)
|
||||||
create_db_str();
|
create_db_str();
|
||||||
adds_db_str(df->df_idf->id_text);
|
adds_db_str(df->df_idf->id_text);
|
||||||
addc_db_str(':');
|
addc_db_str(':');
|
||||||
switch(kind) {
|
if (kind == D_MODULE) {
|
||||||
case D_MODULE:
|
|
||||||
adds_db_str(sprint(buf, "M%d;", df->prc_vis->sc_count));
|
adds_db_str(sprint(buf, "M%d;", df->prc_vis->sc_count));
|
||||||
C_ms_stb_pnam(db_str.base, N_FUN, proclevel, "m_a_i_n");
|
C_ms_stb_pnam(db_str.base, N_FUN, proclevel, "m_a_i_n");
|
||||||
break;
|
return;
|
||||||
|
}
|
||||||
|
switch((int)kind) {
|
||||||
case D_PROCEDURE:
|
case D_PROCEDURE:
|
||||||
case D_FUNCTION:
|
case D_FUNCTION:
|
||||||
adds_db_str(sprint(buf, "Q%d;", df->prc_vis->sc_count));
|
adds_db_str(sprint(buf, "Q%d;", df->prc_vis->sc_count));
|
||||||
|
@ -367,3 +373,4 @@ stb_string(df, kind)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* DBSYMTAB */
|
||||||
|
|
Loading…
Reference in a new issue