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

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

From:
kjs
Date:
January 18, 2009 10:14
Subject:
[svn:parrot] r35720 - trunk/compilers/pirc/src
Message ID:
20090118181405.399A2CB9AE@x12.develooper.com
Author: kjs
Date: Sun Jan 18 10:14:04 2009
New Revision: 35720

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

Log:
[pirc] fix bytecode generation for keys. Can now index with string literals and registers ($S0, etc.).

Modified: trunk/compilers/pirc/src/bcgen.c
==============================================================================
--- trunk/compilers/pirc/src/bcgen.c	(original)
+++ trunk/compilers/pirc/src/bcgen.c	Sun Jan 18 10:14:04 2009
@@ -579,6 +579,7 @@
 
     index = add_key_const(bc, pfc->u.key);
 
+    fprintf(stderr, "store key at index %d\n", index);
     mem_sys_free(pfc);
 
     return index;

Modified: trunk/compilers/pirc/src/piremit.c
==============================================================================
--- trunk/compilers/pirc/src/piremit.c	(original)
+++ trunk/compilers/pirc/src/piremit.c	Sun Jan 18 10:14:04 2009
@@ -602,16 +602,16 @@
                 switch (t->info->type) {
                     case INT_TYPE:
                         *pc++ = PARROT_ARG_I;
+                        *pc++ = t->info->color;
                         break;
                     case STRING_TYPE:
                         *pc++ = PARROT_ARG_S;
+                        *pc++ = t->info->color;
                         break;
                     default:
                         panic(lexer, "wrong type of key");
                         break;
                 }
-
-                *pc++ = t->info->color;
                 break;
             }
             case EXPR_KEY:
@@ -632,6 +632,10 @@
      */
     keysize = pc - key;
 
+    fprintf(stderr, "key: ");
+    for (index = 0; index < keysize; ++index) {
+        fprintf(stderr, "%d|", key[index]);
+    }
     /* store the key, and emit the index at which it's stored into the code segment */
     index = store_key_bytecode(lexer->bc, key);
     emit_int_arg(lexer->bc, index);

Modified: trunk/compilers/pirc/src/pirop.c
==============================================================================
--- trunk/compilers/pirc/src/pirop.c	(original)
+++ trunk/compilers/pirc/src/pirop.c	Sun Jan 18 10:14:04 2009
@@ -127,7 +127,6 @@
                 *instr_writer++ = '_';
                 *instr_writer++ = 'k';
 
-                /* XXX this switch replaces the messy code below. double-check before delete. */
                 switch (iter->expr.t->key->head->expr->type) {
                     case EXPR_TARGET:
                         switch (iter->expr.t->key->head->expr->expr.t->info->type) {
@@ -136,6 +135,9 @@
                                  * case, do not print the signature; 'kp' is not valid.
                                  */
                                 break;
+                            case STRING_TYPE: /* strings become key-constant */
+                                *instr_writer++ = 'c';
+                                break;
                             case INT_TYPE:
                                 *instr_writer++ = 'i';
                                 break;



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