develooper Front page | perl.cvs.parrot | Postings from January 2009

[svn:parrot] r35021 - trunk/compilers/pirc/src

From:
kjs
Date:
January 6, 2009 04:07
Subject:
[svn:parrot] r35021 - trunk/compilers/pirc/src
Message ID:
20090106120728.7A690CB9F9@x12.develooper.com
Author: kjs
Date: Tue Jan  6 04:07:27 2009
New Revision: 35021

Modified:
   trunk/compilers/pirc/src/bcgen.c
   trunk/compilers/pirc/src/pircompunit.c
   trunk/compilers/pirc/src/pircompunit.h
   trunk/compilers/pirc/src/piremit.c

Log:
[pirc] some refactoring for annotations.

Modified: trunk/compilers/pirc/src/bcgen.c
==============================================================================
--- trunk/compilers/pirc/src/bcgen.c	(original)
+++ trunk/compilers/pirc/src/bcgen.c	Tue Jan  6 04:07:27 2009
@@ -359,7 +359,7 @@
 /*
 
 =item C<void
-create_annotations_segment(bytecode * const bc, opcode_t bytecode_offset)>
+create_annotations_segment(bytecode * const bc)>
 
 Create an annotations segment, and an initial annotations group.
 
@@ -367,13 +367,18 @@
 
 */
 void
-create_annotations_segment(bytecode * const bc, opcode_t bytecode_offset) {
+create_annotations_segment(bytecode * const bc, char const * const name) {
+    char *segment_name = (char *)mem_sys_allocate((strlen(name) + 5) * sizeof (char));
+    sprintf(segment_name, "%s_ANN", name);
+
     bc->interp->code->annotations = PackFile_Segment_new_seg(bc->interp,
                                         bc->interp->code->base.dir,
-                                        PF_ANNOTATIONS_SEG, "ANNOTATIONS", 1);
+                                        PF_ANNOTATIONS_SEG, segment_name, 1);
 
     /* Create initial group. */
-    PackFile_Annotations_add_group(bc->interp, bc->interp->code->annotations, bytecode_offset);
+    PackFile_Annotations_add_group(bc->interp,
+                                   bc->interp->code->annotations,
+                                   bc->interp->code->base.data);
 }
 
 

Modified: trunk/compilers/pirc/src/pircompunit.c
==============================================================================
--- trunk/compilers/pirc/src/pircompunit.c	(original)
+++ trunk/compilers/pirc/src/pircompunit.c	Tue Jan  6 04:07:27 2009
@@ -2495,12 +2495,11 @@
     annotation *ann     = (annotation *)pir_mem_allocate(lexer, sizeof (annotation));
     ann->key            = key;
     ann->value          = value;
-    /* store the current statement counter value */
-    ann->bytecode_index = lexer->stmt_counter;
+
     ++lexer->num_annotations; /* keep track of number of annotations */
 
-    /* store a pointer to the current instruction */
-    ann->instr = CURRENT_INSTRUCTION(lexer);
+
+    ann->offset = CURRENT_INSTRUCTION(lexer)->offset;
 
     /* store the annotation in a list, managed by the lexer
      * the list is circular linked, so that the order of annotations is preserved.

Modified: trunk/compilers/pirc/src/pircompunit.h
==============================================================================
--- trunk/compilers/pirc/src/pircompunit.h	(original)
+++ trunk/compilers/pirc/src/pircompunit.h	Tue Jan  6 04:07:27 2009
@@ -333,10 +333,9 @@
 
 /* struct to represent bytecode annotation */
 typedef struct annotation {
-    int bytecode_index;    /* index in bytecode stream from where this annotation is active */
+    opcode_t     offset;
     char const  *key;      /* key of annotation */
     constant    *value;    /* value of annotation */
-    instruction *instr;    /* pointer to the instruction from where the annotation is active */
 
     struct annotation *next; /* next annotation; annotations are stored in a list */
 

Modified: trunk/compilers/pirc/src/piremit.c
==============================================================================
--- trunk/compilers/pirc/src/piremit.c	(original)
+++ trunk/compilers/pirc/src/piremit.c	Tue Jan  6 04:07:27 2009
@@ -909,7 +909,7 @@
 #if 0
 
     /* create an annotations segment, which is not created by default. */
-    create_annotations_segment(lexer->bc, lexer->interp->code->base.data);
+    create_annotations_segment(lexer->bc, lexer->filename);
 
     /* initialize to the first annotation */
     iter = lexer->annotations->next;
@@ -921,7 +921,7 @@
         opcode_t key  = ....
 
         opcode_t type = ...
-        opcode_t offset = (opcode_t)iter->instr->offset;
+        opcode_t offset = iter->offset;
 
         add_annotation(lexer->bc, offset, key, type, value);
 



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About