Author: kjs
Date: Thu Jan  1 14:19:43 2009
New Revision: 34768

Modified:
   trunk/compilers/pirc/new/pircompunit.h
   trunk/compilers/pirc/new/piremit.c

Log:
[pirc] small bits for key bytecode stuff. Not too hard after all. Like most 
stuff :-)

Modified: trunk/compilers/pirc/new/pircompunit.h
==============================================================================
--- trunk/compilers/pirc/new/pircompunit.h      (original)
+++ trunk/compilers/pirc/new/pircompunit.h      Thu Jan  1 14:19:43 2009
@@ -185,6 +185,7 @@
 /* The key node is used to represent a key expression */
 typedef struct key {
     expression *expr;      /* value of this key */
+    int         index;     /* key value (if int) or index in constant table */
     struct key *next;      /* in ["x";"y"], there's 2 key nodes; 1 for "x", 1 
for "y",
                               linked by "next" */
 } key;

Modified: trunk/compilers/pirc/new/piremit.c
==============================================================================
--- trunk/compilers/pirc/new/piremit.c  (original)
+++ trunk/compilers/pirc/new/piremit.c  Thu Jan  1 14:19:43 2009
@@ -529,10 +529,6 @@
 
 
 
-
-
-
-
 /*
 
 =item C<static void
@@ -540,6 +536,10 @@
 
 Emit bytecode for the key C<k>.
 
+XXX Not sure what to return. At what point is this function
+called? Do we want to return an index in the constant table?
+or an expression (operand) node.
+
 =cut
 
 */
@@ -552,6 +552,7 @@
     opcode_t    keysize;    /* total size of key in bytecode */
     opcode_t   *pc;         /* cursor to write into key array */
     expression *operand;
+    int         index;
 
     fprintf(stderr, "emit pbc key\n");
     emit_pbc_expr(lexer, k->expr);
@@ -598,11 +599,14 @@
                 *pc++ = t->info->color;
                 break;
             }
+            /* XXX nested keys? */
             default:
+                panic(lexer, "unknown expression type");
                 break;
 
         }
-        /* count the number of keys */
+
+        /* count the number of keys*/
         ++keylength;
         iter = iter->next;
     }
@@ -614,9 +618,9 @@
      */
     keysize = pc - key;
 
-    store_key_bytecode(lexer->bc, key);
+    index = store_key_bytecode(lexer->bc, key);
 
-    operand = expr_from_key(lexer, k);
+    operand = expr_from_int(lexer, index);
     return operand;
 
 }
@@ -645,11 +649,11 @@
         case EXPR_LABEL:
             emit_pbc_label_arg(lexer, operand->expr.l);
             break;
-        /*
+
         case EXPR_KEY:
-            fprintf(stderr, "emit pbc isntr key arg\n");
+            emit_pbc_key(lexer, operand->expr.k);
             break;
-        */
+
         default:
             break;
     }

Reply via email to