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

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

From:
kjs
Date:
January 6, 2009 05:20
Subject:
[svn:parrot] r35028 - trunk/compilers/pirc/src
Message ID:
20090106132028.5F414CB9F9@x12.develooper.com
Author: kjs
Date: Tue Jan  6 05:20:27 2009
New Revision: 35028

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

Log:
[pirc] more work on annotations and fix a compile error on linux.

Modified: trunk/compilers/pirc/src/bcgen.c
==============================================================================
--- trunk/compilers/pirc/src/bcgen.c	(original)
+++ trunk/compilers/pirc/src/bcgen.c	Tue Jan  6 05:20:27 2009
@@ -401,6 +401,7 @@
 
 #endif
 
+
 /*
 
 =item C<void

Modified: trunk/compilers/pirc/src/bcgen.h
==============================================================================
--- trunk/compilers/pirc/src/bcgen.h	(original)
+++ trunk/compilers/pirc/src/bcgen.h	Tue Jan  6 05:20:27 2009
@@ -49,8 +49,8 @@
  * sub.
  */
 typedef struct lexical {
-    char const     *name;
-    int            *color;
+    char const     *name;     /* name of this lexical */
+    int            *color;    /* register assigned to the lexical */
     struct lexical *next;
 
 } lexical;
@@ -82,6 +82,11 @@
 
 void create_codesegment(bytecode * const bc, int codesize);
 
+void create_annotations_segment(bytecode * const bc, char const * const name);
+
+void add_annotation(bytecode * const bc, opcode_t offset, opcode_t key,
+                                         opcode_t type, opcode_t value);
+
 /* call this to write the PBC file */
 void write_pbc_file(bytecode * const bc, char const * const filename) ;
 

Modified: trunk/compilers/pirc/src/piremit.c
==============================================================================
--- trunk/compilers/pirc/src/piremit.c	(original)
+++ trunk/compilers/pirc/src/piremit.c	Tue Jan  6 05:20:27 2009
@@ -906,8 +906,8 @@
     if (lexer->annotations == NULL)
         return;
 
-#if 0
 
+#if 0
     /* create an annotations segment, which is not created by default. */
     create_annotations_segment(lexer->bc, lexer->filename);
 
@@ -917,13 +917,30 @@
     /* iterate over annotations and store them */
     do {
 
-        /* add the key */
-        opcode_t key  = ....
+        opcode_t key, value;
+
 
-        opcode_t type = ...
-        opcode_t offset = iter->offset;
+        switch (iter->value->type) {
+            case INT_VAL:
+                value = iter->value->val.ival;
+                break;
+            case NUM_VAL:
+                value = add_num_const(lexer->bc, iter->value->val.nval);
+                break;
+            case STRING_VAL:
+                value = add_string_const(lexer->bc, iter->value->val.sval, "ascii");
+                break;
+            case USTRING_VAL:
+                value = add_string_const(lexer->bc, iter->value->val.ustr->contents,
+                                                    iter->value->val.ustr->charset);
+                break;
+            default:
+                panic(lexer, "unknown annotation constant type");
+                break;
+        }
 
-        add_annotation(lexer->bc, offset, key, type, value);
+
+        add_annotation(lexer->bc, iter->offset, key, iter->value->type, value);
 
         iter = iter->next;
     }
@@ -932,6 +949,8 @@
 #endif
 }
 
+
+
 /*
 
 =item C<void

Modified: trunk/compilers/pirc/src/pirpcc.c
==============================================================================
--- trunk/compilers/pirc/src/pirpcc.c	(original)
+++ trunk/compilers/pirc/src/pirpcc.c	Tue Jan  6 05:20:27 2009
@@ -23,6 +23,7 @@
 #include "pircompunit.h"
 #include "pircompiler.h"
 #include "pirerr.h"
+#include "pirdefines.h"
 
 #include "parrot/oplib/ops.h"
 



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