Commit 80ffde06 authored by Benoit Perrot's avatar Benoit Perrot
Browse files

Index: ChangeLog

from  Benoît Perrot  <benoit@lrde.epita.fr>

	Let concrete sections choose how to handle labels definitions.

	* src/inst/section.hh (add_label): Rename as `register_label'.
	* src/inst/data_section.hh, src/inst/text_section.hh:
	(add_label): Rename as...
	(define_label): This, and make it wait for a unique_string and 
	build the label.
	* dev/parse-asm-scan-gen.py: Return a unique_string on a 
	label definition.
	* dev/parse-asm-parse-gen.py: Update accordingly.

Index: src/inst/data_section.hh
--- src/inst/data_section.hh	(revision 160)
+++ src/inst/data_section.hh	(working copy)
@@ -54,9 +54,9 @@
     }
     
   public:
-    void		add_label(Label *label)
+    void		define_label(const misc::unique_string &id)
     {
-      Section::add_label(label, size_);
+      Section::register_label(new inst::Label(id), size_);
     }
     
   public:
Index: src/inst/section.hh
--- src/inst/section.hh	(revision 160)
+++ src/inst/section.hh	(working copy)
@@ -49,7 +49,7 @@
     {}
     
   protected:
-    void		add_label(Label *label, int offset)
+    void		register_label(Label *label, int offset)
     {
       // FIXME: check that this label has not already been added.
       offsets_[*label] = offset;
Index: src/inst/text_section.hh
--- src/inst/text_section.hh	(revision 160)
+++ src/inst/text_section.hh	(working copy)
@@ -54,9 +54,9 @@
     }
 
   public:
-    void		add_label(Label *label)
+    void		define_label(const misc::unique_string &id)
     {
-      Section::add_label(label, insts_.size() * 4);
+      Section::register_label(new inst::Label(id), insts_.size() * 4);
     }
 
   public:
Index: dev/inst-builder-gen.py
--- dev/inst-builder-gen.py	(revision 160)
+++ dev/inst-builder-gen.py	(working copy)
@@ -78,14 +78,14 @@
     }
     
   public:
-    void		add_inst_label(Label *label)
+    void		define_inst_label(const misc::unique_string &id)
     {
-      program_->text_section ().add_label(label);
+      program_->text_section ().define_label(id);
     }
 
-    void		add_data_label(Label *label)
+    void		define_data_label(const misc::unique_string &id)
     {
-      program_->data_section ().add_label(label);
+      program_->data_section ().define_label(id);
     }
 
   public:
Index: dev/parse-asm-scan-gen.py
--- dev/parse-asm-scan-gen.py	(revision 160)
+++ dev/parse-asm-scan-gen.py	(working copy)
@@ -71,7 +71,7 @@
 dec_int			[0-9]+
 hex_int			0x[0-9A-Fa-f]+
 
-label			[a-zA-Z_][a-zA-Z_0-9]*
+id			[a-zA-Z_][a-zA-Z_0-9]*
 %%
 
 %{
@@ -144,14 +144,14 @@
 }
 
 
-{label}			{
+{id}			{
   yylval->label = new inst::Label (yytext);
   return LABEL;
 }
-{label}\":\"		{
+{id}\":\"		{
   std::string label = yytext;
   label.resize(yyleng - 1);
-  yylval->label = new inst::Label (label);
+  yylval->id = &misc::unique_string::create(label);
   return LABEL_DEF;
 }
 
Index: dev/parse-asm-parse-gen.py
--- dev/parse-asm-parse-gen.py	(revision 160)
+++ dev/parse-asm-parse-gen.py	(working copy)
@@ -75,6 +75,7 @@
 {
   int			i;
   std::string		*s;
+  const misc::unique_string	*id;
   inst::Label           *label;
   inst::Register        *reg;
   inst::Exp             *exp;
@@ -84,7 +85,7 @@
 %}
 
 %token <label> LABEL		\"label\"
-%token <label> LABEL_DEF	\"label definition\"
+%token <id> LABEL_DEF		\"label definition\"
 %token <i> INTEGER              \"integer\"
 %token <s> STRING               \"string\"
 %token <reg> REGISTER           \"register\"
@@ -138,7 +139,7 @@
 data
 // Label
 :  LABEL_DEF
-{ program_builder.add_data_label($1); }
+{ program_builder.define_data_label(*$1); }
 
 // Uninitialized space
 | DIR_SPACE INTEGER
@@ -169,7 +170,7 @@
 instruction
 // Label
 : LABEL_DEF
-{ program_builder.add_inst_label($1); }
+{ program_builder.define_inst_label(*$1); }
 
 // Opcodes"""
 
parent 661492f8
2005-01-26 Benot Perrot <benoit@lrde.epita.fr>
Let concrete sections choose how to handle labels definitions.
* src/inst/section.hh (add_label): Rename as `register_label'.
* src/inst/data_section.hh, src/inst/text_section.hh:
(add_label): Rename as...
(define_label): This, and make it wait for a unique_string and
build the label.
* dev/parse-asm-scan-gen.py: Return a unique_string on a
label definition.
* dev/parse-asm-parse-gen.py: Update accordingly.
2005-01-23 Benot Perrot <benoit@lrde.epita.fr>
Copy the instruction list of text section when storing one.
......
......@@ -78,14 +78,14 @@ namespace inst
}
public:
void add_inst_label(Label *label)
void define_inst_label(const misc::unique_string &id)
{
program_->text_section ().add_label(label);
program_->text_section ().define_label(id);
}
void add_data_label(Label *label)
void define_data_label(const misc::unique_string &id)
{
program_->data_section ().add_label(label);
program_->data_section ().define_label(id);
}
public:
......
......@@ -75,6 +75,7 @@ using vm::Cpu;
{
int i;
std::string *s;
const misc::unique_string *id;
inst::Label *label;
inst::Register *reg;
inst::Exp *exp;
......@@ -84,7 +85,7 @@ using vm::Cpu;
%}
%token <label> LABEL \"label\"
%token <label> LABEL_DEF \"label definition\"
%token <id> LABEL_DEF \"label definition\"
%token <i> INTEGER \"integer\"
%token <s> STRING \"string\"
%token <reg> REGISTER \"register\"
......@@ -138,7 +139,7 @@ datas
data
// Label
: LABEL_DEF
{ program_builder.add_data_label($1); }
{ program_builder.define_data_label(*$1); }
// Uninitialized space
| DIR_SPACE INTEGER
......@@ -169,7 +170,7 @@ instructions
instruction
// Label
: LABEL_DEF
{ program_builder.add_inst_label($1); }
{ program_builder.define_inst_label(*$1); }
// Opcodes"""
......
......@@ -71,7 +71,7 @@ eol \\n|\\r|\\n\\r|\\r\\n
dec_int [0-9]+
hex_int 0x[0-9A-Fa-f]+
label [a-zA-Z_][a-zA-Z_0-9]*
id [a-zA-Z_][a-zA-Z_0-9]*
%%
%{
......@@ -144,14 +144,14 @@ print """
}
{label} {
{id} {
yylval->label = new inst::Label (yytext);
return LABEL;
}
{label}\":\" {
{id}\":\" {
std::string label = yytext;
label.resize(yyleng - 1);
yylval->label = new inst::Label (label);
yylval->id = &misc::unique_string::create(label);
return LABEL_DEF;
}
......
......@@ -54,9 +54,9 @@ namespace inst
}
public:
void add_label(Label *label)
void define_label(const misc::unique_string &id)
{
Section::add_label(label, size_);
Section::register_label(new inst::Label(id), size_);
}
public:
......
......@@ -49,7 +49,7 @@ namespace inst
{}
protected:
void add_label(Label *label, int offset)
void register_label(Label *label, int offset)
{
// FIXME: check that this label has not already been added.
offsets_[*label] = offset;
......
......@@ -54,9 +54,9 @@ namespace inst
}
public:
void add_label(Label *label)
void define_label(const misc::unique_string &id)
{
Section::add_label(label, insts_.size() * 4);
Section::register_label(new inst::Label(id), insts_.size() * 4);
}
public:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment