cvsuser 04/03/14 02:11:30
Modified: imcc imcc.y
imcc/t/syn objects.t
Log:
allow .sub open method
Revision Changes Path
1.133 +9 -4 parrot/imcc/imcc.y
Index: imcc.y
===================================================================
RCS file: /cvs/public/parrot/imcc/imcc.y,v
retrieving revision 1.132
retrieving revision 1.133
diff -u -w -r1.132 -r1.133
--- imcc.y 14 Mar 2004 09:45:39 -0000 1.132
+++ imcc.y 14 Mar 2004 10:11:26 -0000 1.133
@@ -292,7 +292,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
+%type <sr> vars _vars var_or_i _var_or_i label_op sub_label_op
%type <i> pasmcode pasmline pasm_inst
%type <sr> pasm_args
%type <symlist> targetlist arglist
@@ -472,9 +472,9 @@
cur_unit = (pragmas.fastcall ? imc_open_unit(interp, IMC_FASTSUB)
: imc_open_unit(interp, IMC_PCCSUB));
}
- IDENTIFIER pcc_sub_proto '\n'
+ sub_label_op pcc_sub_proto '\n'
{
- Instruction *i = iSUBROUTINE(cur_unit, mk_sub_label($3));
+ Instruction *i = iSUBROUTINE(cur_unit, $3);
i->r[1] = $<sr>$ = mk_pcc_sub(str_dup(i->r[0]->name), 0);
add_namespace(interp, i->r[1]);
i->r[1]->pcc_sub->pragma = $4;
@@ -912,7 +912,7 @@
if ($1->set != 'P')
fataly(1, sourcefile, line, "Sub isn't a PMC");
}
- | target ptr IDENTIFIER { cur_obj = $1; $$ = mk_sub_address($3); }
+ | target ptr sub_label_op { cur_obj = $1; $$ = $3; }
| target ptr STRINGC { cur_obj = $1; $$ = mk_const($3, 'S'); }
| target ptr target { cur_obj = $1; $$ = $3; }
;
@@ -996,6 +996,11 @@
keyvec |= KEY_BIT(nargs);
regs[nargs++] = $3; $$ = $1;
}
+ ;
+
+sub_label_op:
+ IDENTIFIER { $$ = mk_sub_address($1); }
+ | PARROT_OP { $$ = mk_sub_address($1); }
;
label_op:
1.7 +23 -1 parrot/imcc/t/syn/objects.t
Index: objects.t
===================================================================
RCS file: /cvs/public/parrot/imcc/t/syn/objects.t,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -w -r1.6 -r1.7
--- objects.t 14 Mar 2004 08:05:41 -0000 1.6
+++ objects.t 14 Mar 2004 10:11:30 -0000 1.7
@@ -1,6 +1,6 @@
#!perl
use strict;
-use TestCompiler tests => 10;
+use TestCompiler tests => 11;
##############################
# Parrot Calling Conventions
@@ -294,6 +294,28 @@
.namespace [ "Foo" ]
.sub _meth
+ print "in meth\n"
+.end
+CODE
+in meth
+done
+OUT
+
+output_is(<<'CODE', <<'OUT', "meth call syntax - reserved word");
+
+.sub _main
+ .local pmc class
+ .local pmc obj
+ newclass class, "Foo"
+ find_type $I0, "Foo"
+ new obj, $I0
+ obj.open()
+ print "done\n"
+ end
+.end
+
+.namespace [ "Foo" ]
+.sub open
print "in meth\n"
.end
CODE