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

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

From:
kjs
Date:
January 6, 2009 12:26
Subject:
[svn:parrot] r35079 - trunk/compilers/pirc/src
Message ID:
20090106202611.8A2F1CB9F9@x12.develooper.com
Author: kjs
Date: Tue Jan  6 12:26:10 2009
New Revision: 35079

Modified:
   trunk/compilers/pirc/src/bcgen.c
   trunk/compilers/pirc/src/pircompunit.c
   trunk/compilers/pirc/src/pirop.c
   trunk/compilers/pirc/src/pirpcc.c
   trunk/compilers/pirc/src/pirsymbol.c

Log:
[pirc] implement NCI_CALL bytecode generation + cleanups.


Modified: trunk/compilers/pirc/src/bcgen.c
==============================================================================
--- trunk/compilers/pirc/src/bcgen.c	(original)
+++ trunk/compilers/pirc/src/bcgen.c	Tue Jan  6 12:26:10 2009
@@ -359,7 +359,7 @@
 /*
 
 =item C<void
-create_annotations_segment(bytecode * const bc)>
+create_annotations_segment(bytecode * const bc, char const * const name)>
 
 Create an annotations segment, and an initial annotations group.
 

Modified: trunk/compilers/pirc/src/pircompunit.c
==============================================================================
--- trunk/compilers/pirc/src/pircompunit.c	(original)
+++ trunk/compilers/pirc/src/pircompunit.c	Tue Jan  6 12:26:10 2009
@@ -2464,6 +2464,8 @@
     if (CURRENT_INSTRUCTION(lexer)) {
         switch (CURRENT_INSTRUCTION(lexer)->opcode) {
             case PARROT_OP_tailcall_p:
+            case PARROT_OP_tailcallmethod_p_sc:
+            case PARROT_OP_tailcallmethod_p_p:
             case PARROT_OP_end:
             case PARROT_OP_returncc:
             case PARROT_OP_yield:

Modified: trunk/compilers/pirc/src/pirop.c
==============================================================================
--- trunk/compilers/pirc/src/pirop.c	(original)
+++ trunk/compilers/pirc/src/pirop.c	Tue Jan  6 12:26:10 2009
@@ -28,7 +28,18 @@
  * Note that the last 's' corresponds to USTRING_VAL, which is a unicode
  * string, but when used it's still a string.
  */
-static char const type_codes[10] = {'i', 's', 'p', 'n', '?', 'i', 's', 'p', 'n', 's'};
+static char const type_codes[10] = {
+    'i',   /* INT_TYPE     */
+    's',   /* STRING_TYPE  */
+    'p',   /* PMC_TYPE     */
+    'n',   /* NUM_TYPE     */
+    '?',   /* UNKNOWN_TYPE */
+    'i',   /* INT_VAL      */
+    's',   /* STRING_VAL   */
+    'p',   /* PMC_VAL      */
+    'n',   /* NUM_VAL      */
+    's'    /* USTRING_VAL  */
+};
 
 /*
 

Modified: trunk/compilers/pirc/src/pirpcc.c
==============================================================================
--- trunk/compilers/pirc/src/pirpcc.c	(original)
+++ trunk/compilers/pirc/src/pirpcc.c	Tue Jan  6 12:26:10 2009
@@ -125,7 +125,6 @@
 */
 static target *
 generate_unique_pir_reg(lexer_state * const lexer, pir_type type) {
-    fprintf(stderr, "unique reg of type %d: %d\n", type, lexer->pir_reg_generator - 1);
     return new_reg(lexer, type, --lexer->pir_reg_generator);
 }
 
@@ -317,8 +316,6 @@
     /* add the index (of the signature PMC) in the PBC constant table as operand */
     push_operand(lexer, expr_from_int(lexer, array_index));
 
-    fprintf(stderr, "args2ops: %d arguments\n", num_arguments);
-
     /* no need to continue if there's no arguments */
     if (num_arguments == 0)
         return;
@@ -565,8 +562,8 @@
 Generate instructions for a function invocation using the Native Call
 Interface (NCI). The sequence of instructions is:
 
-XXX complete this.
-
+ set_args_pc
+ get_results_pc
  invokecc_p
 
 =cut
@@ -574,7 +571,18 @@
 */
 static void
 convert_nci_call(lexer_state * const lexer, invocation * const inv) {
-    set_instr(lexer, "invokecc_p");
+    target *sub;
+
+    new_sub_instr(lexer, PARROT_OP_set_args_pc, "set_args_pc", inv->num_arguments);
+    arguments_to_operands(lexer, inv->arguments, inv->num_arguments);
+
+    new_sub_instr(lexer, PARROT_OP_get_results_pc, "get_results_pc", inv->num_results);
+    targets_to_operands(lexer, inv->results, inv->num_results);
+
+    sub = get_invoked_sub(lexer, inv->sub);
+
+    new_sub_instr(lexer, PARROT_OP_invokecc_p, "invokecc_p", 0);
+    add_operands(lexer, "%T", sub);
 }
 
 /*
@@ -588,8 +596,6 @@
  set_returns_pc
  yield
 
-XXX This does not work; why?
-
 =cut
 
 */
@@ -601,7 +607,6 @@
 }
 
 
-
 /*
 
 =item C<static void
@@ -658,7 +663,7 @@
     switch (inv->method->type) {
         case EXPR_TARGET:
             new_sub_instr(lexer, PARROT_OP_tailcallmethod_p_p, "tailcallmethod_p_p", 0);
-            add_operands(lexer, "%T%E", inv->sub, inv->method);
+            add_operands(lexer, "%T%E", inv->sub, inv->method); /* XXX test this */
             break;
         case EXPR_CONSTANT:
             new_sub_instr(lexer, PARROT_OP_tailcallmethod_p_sc, "tailcallmethod_p_sc", 0);
@@ -713,6 +718,7 @@
             break;
     }
 
+
 }
 
 

Modified: trunk/compilers/pirc/src/pirsymbol.c
==============================================================================
--- trunk/compilers/pirc/src/pirsymbol.c	(original)
+++ trunk/compilers/pirc/src/pirsymbol.c	Tue Jan  6 12:26:10 2009
@@ -541,7 +541,7 @@
          * store the register as "used".
          */
         int nextreg = next_register(lexer, type);
-        fprintf(stderr, "mapping reg %d to %d\n", regno, nextreg);
+        /* fprintf(stderr, "mapping reg %d to %d\n", regno, nextreg); */
         return use_register(lexer, type, regno, nextreg);
     }
 }



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