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

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

From:
kjs
Date:
January 10, 2009 09:02
Subject:
[svn:parrot] r35344 - trunk/compilers/pirc/src
Message ID:
20090110170224.B4B27CB9F9@x12.develooper.com
Author: kjs
Date: Sat Jan 10 09:02:23 2009
New Revision: 35344

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

Log:
[pirc] some work on annotations stuff.

Modified: trunk/compilers/pirc/src/bcgen.c
==============================================================================
--- trunk/compilers/pirc/src/bcgen.c	(original)
+++ trunk/compilers/pirc/src/bcgen.c	Sat Jan 10 09:02:23 2009
@@ -355,7 +355,7 @@
     bc->opcursor = (opcode_t *)bc->interp->code->base.data;
 }
 
-#if 0
+
 /*
 
 =item C<void
@@ -375,12 +375,27 @@
                                         bc->interp->code->base.dir,
                                         PF_ANNOTATIONS_SEG, segment_name, 1);
 
+    bc->interp->code->annotations->code = bc->interp->code;
+
     /* Create initial group. */
     PackFile_Annotations_add_group(bc->interp,
                                    bc->interp->code->annotations,
-                                   bc->interp->code->base.data);
+                                   bc->opcursor - bc->interp->code->base.data);
 }
 
+/* Look up table for PackFile Annotation types */
+static int packfile_annotation_types[10] = {
+    PF_ANNOTATION_KEY_TYPE_INT,     /* INT_TYPE */
+    PF_ANNOTATION_KEY_TYPE_STR,     /* STRING_TYPE */
+    -1,                             /* PMC_TYPE */
+    PF_ANNOTATION_KEY_TYPE_NUM,     /* NUM_TYPE */
+    -1,                             /* UNKNOWN_TYPE */
+    PF_ANNOTATION_KEY_TYPE_INT,     /* INT_VAL */
+    PF_ANNOTATION_KEY_TYPE_STR,     /* STRING_VAL */
+    -1,                             /* PMC_VAL */
+    PF_ANNOTATION_KEY_TYPE_NUM,     /* NUM_VAL */
+    PF_ANNOTATION_KEY_TYPE_STR      /* USTRING_VAL */
+};
 
 /*
 
@@ -395,11 +410,18 @@
 */
 void
 add_annotation(bytecode * const bc, opcode_t offset, opcode_t key, opcode_t type, opcode_t value) {
+    /* look up the type */
+    int annotation_type = packfile_annotation_types[type];
+    if (annotation_type == -1) {/* this is no good */
+        fprintf(stderr, "wrong annotation type!");
+        return;
+    }
+
     PackFile_Annotations_add_entry(bc->interp, bc->interp->code->annotations,
-                                   offset, key, type, value);
+                                   offset, key, annotation_type, value);
 }
 
-#endif
+
 
 
 /*

Modified: trunk/compilers/pirc/src/piremit.c
==============================================================================
--- trunk/compilers/pirc/src/piremit.c	(original)
+++ trunk/compilers/pirc/src/piremit.c	Sat Jan 10 09:02:23 2009
@@ -907,8 +907,6 @@
     if (lexer->annotations == NULL)
         return;
 
-
-#if 0
     /* create an annotations segment, which is not created by default. */
     create_annotations_segment(lexer->bc, lexer->filename);
 
@@ -937,7 +935,7 @@
                 break;
             default:
                 panic(lexer, "unknown annotation constant type");
-                break;
+                return; /* panic() exits, so this never happens */
         }
 
 
@@ -947,7 +945,7 @@
     }
     while (iter != lexer->annotations->next);
 
-#endif
+
 }
 
 



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