cvsuser     05/03/24 08:13:32

  Modified:    imcc     imcc.l imcc.y pcc.c
               imcc/t/syn pcc.t
  Log:
  MMD 5 - @MULTI syntax
  
  * syntax only
  
  Revision  Changes    Path
  1.126     +1 -0      parrot/imcc/imcc.l
  
  Index: imcc.l
  ===================================================================
  RCS file: /cvs/public/parrot/imcc/imcc.l,v
  retrieving revision 1.125
  retrieving revision 1.126
  diff -u -r1.125 -r1.126
  --- imcc.l    21 Mar 2005 09:10:22 -0000      1.125
  +++ imcc.l    24 Mar 2005 16:13:30 -0000      1.126
  @@ -211,6 +211,7 @@
   "prototyped"    return(PROTOTYPED);
   "non_prototyped"    return(NON_PROTOTYPED);
   "method"        return(METHOD);
  +<emit,INITIAL>"@MULTI"   return(MULTI);
   <emit,INITIAL>"@MAIN"    return(MAIN);
   <emit,INITIAL>"@LOAD"    return(LOAD);
   <emit,INITIAL>"@IMMEDIATE"    return(IMMEDIATE);
  
  
  
  1.156     +24 -19    parrot/imcc/imcc.y
  
  Index: imcc.y
  ===================================================================
  RCS file: /cvs/public/parrot/imcc/imcc.y,v
  retrieving revision 1.155
  retrieving revision 1.156
  diff -u -r1.155 -r1.156
  --- imcc.y    21 Mar 2005 09:10:22 -0000      1.155
  +++ imcc.y    24 Mar 2005 16:13:31 -0000      1.156
  @@ -347,6 +347,7 @@
   %token <t> PCC_BEGIN PCC_END PCC_CALL PCC_SUB PCC_BEGIN_RETURN PCC_END_RETURN
   %token <t> PCC_BEGIN_YIELD PCC_END_YIELD NCI_CALL METH_CALL INVOCANT
   %token <t> PROTOTYPED NON_PROTOTYPED MAIN LOAD IMMEDIATE POSTCOMP METHOD ANON
  +%token <t> MULTI
   %token <s> LABEL
   %token <t> EMIT EOM
   %token <s> IREG NREG SREG PREG IDENTIFIER REG MACRO ENDM
  @@ -360,10 +361,10 @@
   %type <s> classname relop
   %type <i> labels _labels label  statement sub_call
   %type <i> pcc_sub_call
  -%type <sr> sub_param sub_params pcc_arg pcc_result pcc_args pcc_results 
pcc_params pcc_param
  +%type <sr> sub_param sub_params pcc_arg pcc_result pcc_args pcc_results
   %type <sr> pcc_returns pcc_return pcc_call arg the_sub
   %type <t> pcc_return_many
  -%type <t> pcc_proto pcc_sub_proto proto
  +%type <t> pcc_proto pcc_sub_proto proto sub_proto multi
   %type <i> instruction assignment if_statement labeled_inst opt_label 
op_assign
   %type <i> func_assign
   %type <i> opt_invocant
  @@ -572,13 +573,16 @@
              cur_unit = (pragmas.fastcall ? imc_open_unit(interp, IMC_FASTSUB)
                                             : imc_open_unit(interp, 
IMC_PCCSUB));
           }
  -     sub_label_op_c pcc_sub_proto '\n'
  +     sub_label_op_c
           {
             Instruction *i = iSUBROUTINE(cur_unit, $3);
  +          /*
  +           * $<sr>$ is the SymReg value of this action rule
  +           */
             i->r[1] = $<sr>$ = mk_pcc_sub(interp, str_dup(i->r[0]->name), 0);
             add_namespace(interp, cur_unit);
  -          i->r[1]->pcc_sub->pragma = $4;
           }
  +     sub_proto '\n' { $<sr>4->pcc_sub->pragma = $5; }
        sub_params
        sub_body  ESUB { $$ = 0; }
      ;
  @@ -586,7 +590,7 @@
   sub_params:
        /* empty */                       { $$ = 0; } %prec LOW_PREC
      | '\n'                              { $$ = 0; }
  -   | sub_params sub_param '\n'         { add_pcc_param($<sr>0, $2);}
  +   | sub_params sub_param '\n'         { add_pcc_param($<sr>-3, $2);}
      ;
   
   sub_param:
  @@ -594,6 +598,17 @@
        type IDENTIFIER          { $$ = mk_ident(interp, $4, $3); is_def=0; }
      ;
   
  +sub_proto:
  +     /* empty */    {  $$ = P_NONE; }
  +   | sub_proto COMMA proto  { $$ |= $3; }
  +   | sub_proto COMMA multi { $$ = $1; }
  +   | proto          { $$ |= $1; }
  +   | multi          { $$ = P_NONE; }
  +   ;
  +
  +multi: MULTI '(' ')'  { $$ = 0; }
  +   ;
  +
   sub_body:
        /* empty */
      |  statements
  @@ -601,28 +616,18 @@
   
   pcc_sub:
        PCC_SUB       { cur_unit = imc_open_unit(interp, IMC_PCCSUB); }
  -     IDENTIFIER pcc_sub_proto '\n'
  +     IDENTIFIER
            {
               Instruction *i = iSUBROUTINE(cur_unit, mk_sub_label(interp, $3));
               i->r[1] = $<sr>$ = mk_pcc_sub(interp, str_dup(i->r[0]->name), 0);
               add_namespace(interp, cur_unit);
  -            i->r[1]->pcc_sub->pragma = $4;
  +
            }
  -     pcc_params
  +     sub_proto '\n' { $<sr>4->pcc_sub->pragma = $5; }
  +     sub_params
        sub_body  ESUB { $$ = 0; }
      ;
   
  -pcc_params:
  -     /* empty */                       { $$ = 0; } %prec LOW_PREC
  -   | '\n'                              { $$ = 0; }
  -   | pcc_params pcc_param '\n'         { add_pcc_param($<sr>0, $2);}
  -   ;
  -
  -pcc_param:
  -     PARAM                             { is_def=1; }
  -     type IDENTIFIER            { $$ = mk_ident(interp, $4, $3); is_def=0; }
  -   ;
  -
   pcc_sub_call:
        PCC_BEGIN pcc_proto '\n'
            {
  
  
  
  1.90      +7 -5      parrot/imcc/pcc.c
  
  Index: pcc.c
  ===================================================================
  RCS file: /cvs/public/parrot/imcc/pcc.c,v
  retrieving revision 1.89
  retrieving revision 1.90
  diff -u -r1.89 -r1.90
  --- pcc.c     24 Mar 2005 14:08:16 -0000      1.89
  +++ pcc.c     24 Mar 2005 16:13:31 -0000      1.90
  @@ -879,7 +879,7 @@
                * sub->pcc_sub->sub is an actual subroutine name,
                * not a variable.
                */
  -            reg = mk_temp_reg(interp, 'P');
  +            reg = get_pasm_reg(interp, "P0");
               add_pcc_sub(sub, reg);
               /*
                * insert set_p_pc with the sub as constant
  @@ -954,10 +954,12 @@
           /* plain sub call */
           if (arg->color != 0) {
               reg = get_pasm_reg(interp, "P0");
  -            regs[0] = reg;
  -            regs[1] = arg;
  -            arg->want_regno = 0;
  -            ins = insINS(interp, unit, ins, "set", regs, 2);
  +            if (reg != arg) {
  +                regs[0] = reg;
  +                regs[1] = arg;
  +                arg->want_regno = 0;
  +                ins = insINS(interp, unit, ins, "set", regs, 2);
  +            }
           }
       }
   
  
  
  
  1.50      +9 -2      parrot/imcc/t/syn/pcc.t
  
  Index: pcc.t
  ===================================================================
  RCS file: /cvs/public/parrot/imcc/t/syn/pcc.t,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- pcc.t     4 Mar 2005 22:18:41 -0000       1.49
  +++ pcc.t     24 Mar 2005 16:13:32 -0000      1.50
  @@ -1,9 +1,9 @@
   #!perl -w
   # Copyright: 2001-2005 The Perl Foundation.  All Rights Reserved.
  -# $Id: pcc.t,v 1.49 2005/03/04 22:18:41 nicholas Exp $
  +# $Id: pcc.t,v 1.50 2005/03/24 16:13:32 leo Exp $
   
   use strict;
  -use Parrot::Test tests => 41;
  +use Parrot::Test tests => 42;
   
   ##############################
   # Parrot Calling Conventions
  @@ -1518,3 +1518,10 @@
   ok
   OUT
   
  +pir_output_is(<<'CODE', <<'OUT', "multi 1");
  +.sub foo @MULTI()
  +    print "ok 1\n"
  +.end
  +CODE
  +ok 1
  +OUT
  
  
  

Reply via email to