cvsuser     04/11/24 08:16:21

  Modified:    imcc     imcc.y
               imcc/t/syn pcc.t
  Log:
  enable quoted subroutine names
  
  Revision  Changes    Path
  1.152     +20 -2     parrot/imcc/imcc.y
  
  Index: imcc.y
  ===================================================================
  RCS file: /cvs/public/parrot/imcc/imcc.y,v
  retrieving revision 1.151
  retrieving revision 1.152
  diff -u -r1.151 -r1.152
  --- imcc.y    10 Nov 2004 07:59:13 -0000      1.151
  +++ imcc.y    24 Nov 2004 16:16:14 -0000      1.152
  @@ -262,6 +262,19 @@
       return i;
   }
   
  +
  +static SymReg *
  +mk_sub_address_fromc(char * name)
  +{
  +    /* name is a quoted sub name */
  +    SymReg *r;
  +
  +    name[strlen(name) - 1] = '\0';
  +    r = mk_sub_address(str_dup(name + 1));
  +    mem_sys_free(name);
  +    return r;
  +}
  +
   void
   IMCC_itcall_sub(Interp* interpreter, SymReg* sub)
   {
  @@ -357,7 +370,7 @@
   %type <i> opt_invocant
   %type <sr> target reg const var string
   %type <sr> key keylist _keylist
  -%type <sr> vars _vars var_or_i _var_or_i label_op sub_label_op
  +%type <sr> vars _vars var_or_i _var_or_i label_op sub_label_op sub_label_op_c
   %type <i> pasmcode pasmline pasm_inst
   %type <sr> pasm_args
   %type <symlist> targetlist arglist
  @@ -559,7 +572,7 @@
              cur_unit = (pragmas.fastcall ? imc_open_unit(interp, IMC_FASTSUB)
                                             : imc_open_unit(interp, 
IMC_PCCSUB));
           }
  -     sub_label_op pcc_sub_proto '\n'
  +     sub_label_op_c pcc_sub_proto '\n'
           {
             Instruction *i = iSUBROUTINE(cur_unit, $3);
             i->r[1] = $<sr>$ = mk_pcc_sub(str_dup(i->r[0]->name), 0);
  @@ -1027,6 +1040,7 @@
      ;
   
   the_sub: IDENTIFIER  { $$ = mk_sub_address($1); }
  +       | STRINGC  { $$ = mk_sub_address_fromc($1); }
          | target   { $$ = $1;
                          if ($1->set != 'P')
                             fataly(1, sourcefile, line, "Sub isn't a PMC");
  @@ -1116,6 +1130,10 @@
                         regs[nargs++] = $3; $$ = $1;
                      }
      ;
  +sub_label_op_c:
  +     sub_label_op
  +   | STRINGC       { $$ = mk_sub_address_fromc($1); }
  +   ;
   
   sub_label_op:
        IDENTIFIER    { $$ = mk_sub_address($1); }
  
  
  
  1.45      +22 -1     parrot/imcc/t/syn/pcc.t
  
  Index: pcc.t
  ===================================================================
  RCS file: /cvs/public/parrot/imcc/t/syn/pcc.t,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- pcc.t     12 Nov 2004 16:38:37 -0000      1.44
  +++ pcc.t     24 Nov 2004 16:16:20 -0000      1.45
  @@ -1,6 +1,6 @@
   #!perl
   use strict;
  -use TestCompiler tests => 39;
  +use TestCompiler tests => 40;
   
   ##############################
   # Parrot Calling Conventions
  @@ -1479,3 +1479,24 @@
   done in coroutine
   done in main
   OUT
  +
  +output_is(<<'CODE', <<'OUT', "quoted sub names");
  +.sub main @MAIN
  +    "foo"()
  +    print "ok\n"
  +.end
  +
  +.sub "foo"
  +    print "foo\n"
  +    "new"()
  +.end
  +
  +.sub "new"
  +    print "new\n"
  +.end
  +CODE
  +foo
  +new
  +ok
  +OUT
  +
  
  
  

Reply via email to