From ae1d5227de57e9e0b2db9e0fcd33c27a54d8d514 Mon Sep 17 00:00:00 2001 From: steve Date: Sun, 1 Apr 2001 06:40:44 +0000 Subject: [PATCH] Support empty statements for hanging labels. --- vvp/codes.cc | 10 +++++++++- vvp/codes.h | 8 +++++++- vvp/compile.cc | 16 +++++++++++++++- vvp/compile.h | 6 +++++- vvp/parse.y | 10 +++++++--- 5 files changed, 43 insertions(+), 7 deletions(-) diff --git a/vvp/codes.cc b/vvp/codes.cc index 0a26528a0..236394544 100644 --- a/vvp/codes.cc +++ b/vvp/codes.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: codes.cc,v 1.5 2001/03/22 05:28:41 steve Exp $" +#ident "$Id: codes.cc,v 1.6 2001/04/01 06:40:44 steve Exp $" #endif # include "codes.h" @@ -74,6 +74,11 @@ vvp_cpoint_t codespace_allocate(void) return res; } +vvp_cpoint_t codespace_next(void) +{ + return code_count; +} + vvp_code_t codespace_index(vvp_cpoint_t point) { assert(point < code_count); @@ -121,6 +126,9 @@ void codespace_dump(FILE*fd) /* * $Log: codes.cc,v $ + * Revision 1.6 2001/04/01 06:40:44 steve + * Support empty statements for hanging labels. + * * Revision 1.5 2001/03/22 05:28:41 steve * Add code label forward references. * diff --git a/vvp/codes.h b/vvp/codes.h index 0d85ab119..236e29178 100644 --- a/vvp/codes.h +++ b/vvp/codes.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: codes.h,v 1.12 2001/04/01 06:12:13 steve Exp $" +#ident "$Id: codes.h,v 1.13 2001/04/01 06:40:44 steve Exp $" #endif @@ -87,6 +87,9 @@ extern void codespace_init(void); */ extern vvp_cpoint_t codespace_allocate(void); +extern vvp_cpoint_t codespace_next(void); + + /* * Return a pointer to the indexed instruction in the codespace. The * ptr must be a value returned from codespace_allocate. The compiler @@ -100,6 +103,9 @@ extern void codespace_dump(FILE*fd); /* * $Log: codes.h,v $ + * Revision 1.13 2001/04/01 06:40:44 steve + * Support empty statements for hanging labels. + * * Revision 1.12 2001/04/01 06:12:13 steve * Add the bitwise %and instruction. * diff --git a/vvp/compile.cc b/vvp/compile.cc index 1d0b926b7..3e1b6c2ff 100644 --- a/vvp/compile.cc +++ b/vvp/compile.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: compile.cc,v 1.24 2001/04/01 06:12:13 steve Exp $" +#ident "$Id: compile.cc,v 1.25 2001/04/01 06:40:45 steve Exp $" #endif # include "compile.h" @@ -482,6 +482,17 @@ void compile_code(char*label, char*mnem, comp_operands_t opa) free(mnem); } +void compile_codelabel(char*label) +{ + symbol_value_t val; + vvp_cpoint_t ptr = codespace_next(); + + val.num = ptr; + sym_set_value(sym_codespace, label, val); + + free(label); +} + void compile_vpi_call(char*label, char*name, unsigned argc, vpiHandle*argv) { vvp_cpoint_t ptr = codespace_allocate(); @@ -696,6 +707,9 @@ void compile_dump(FILE*fd) /* * $Log: compile.cc,v $ + * Revision 1.25 2001/04/01 06:40:45 steve + * Support empty statements for hanging labels. + * * Revision 1.24 2001/04/01 06:12:13 steve * Add the bitwise %and instruction. * diff --git a/vvp/compile.h b/vvp/compile.h index 319b4ff3d..36605f946 100644 --- a/vvp/compile.h +++ b/vvp/compile.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: compile.h,v 1.12 2001/03/29 03:46:36 steve Exp $" +#ident "$Id: compile.h,v 1.13 2001/04/01 06:40:45 steve Exp $" #endif # include @@ -104,6 +104,7 @@ typedef struct comp_operands_s*comp_operands_t; extern void compile_code(char*label, char*mnem, comp_operands_t opa); extern void compile_vpi_call(char*label, char*name, unsigned argc, vpiHandle*argv); +extern void compile_codelabel(char*label); /* * The parser uses these functions to compile .scope statements. @@ -134,6 +135,9 @@ extern void compile_dump(FILE*fd); /* * $Log: compile.h,v $ + * Revision 1.13 2001/04/01 06:40:45 steve + * Support empty statements for hanging labels. + * * Revision 1.12 2001/03/29 03:46:36 steve * Support named events as mode 2 functors. * diff --git a/vvp/parse.y b/vvp/parse.y index 524e403c9..d630496af 100644 --- a/vvp/parse.y +++ b/vvp/parse.y @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: parse.y,v 1.14 2001/03/29 03:46:36 steve Exp $" +#ident "$Id: parse.y,v 1.15 2001/04/01 06:40:45 steve Exp $" #endif # include "parse_misc.h" @@ -123,9 +123,10 @@ statement on the specific instruction. */ | label_opt T_INSTR operands_opt ';' - { compile_code($1, $2, $3); - } + { compile_code($1, $2, $3); } + | T_LABEL ';' + { compile_codelabel($1); } /* %vpi_call statements are instructions that have unusual operand requirements so are handled by their own rules. */ @@ -307,6 +308,9 @@ int compile_design(const char*path) /* * $Log: parse.y,v $ + * Revision 1.15 2001/04/01 06:40:45 steve + * Support empty statements for hanging labels. + * * Revision 1.14 2001/03/29 03:46:36 steve * Support named events as mode 2 functors. *