cvsuser 04/03/30 06:50:00
Modified: imcc/docs calling_conventions.pod
imcc imcc.l
imcc/t/syn pcc.t
Log:
implement argc[ISPN] and is_prototyped
Revision Changes Path
1.21 +8 -1 parrot/imcc/docs/calling_conventions.pod
Index: calling_conventions.pod
===================================================================
RCS file: /cvs/public/parrot/imcc/docs/calling_conventions.pod,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -w -r1.20 -r1.21
--- calling_conventions.pod 18 Mar 2004 17:27:06 -0000 1.20
+++ calling_conventions.pod 30 Mar 2004 14:49:52 -0000 1.21
@@ -134,6 +134,13 @@
=back
+=head2 Getting the Parameter Count
+
+The reserved words C<argcI>, C<argcS>, C<argcP>, and C<argcN> hold the
+count of passed parameters (or return values) according to
+F<docs/pdds/pdd03_calling_conventions.pod>. The variable
+C<is_prototyped> is an alias for C<I0>.
+
=head2 Calling Methods
The syntax is very similar to subroutine calls. The call is done with
@@ -293,7 +300,7 @@
=head1 FILES
F<imcc/imcc.y>, F<imcc/t/syn/bsr.t>, F<imcc/t/syn/pcc.t>,
-F<imcc/t/syn/objects.t>
+F<imcc/t/syn/objects.t>, F<docs/pdds/pdd03_calling_conventions.pod>
=head1 AUTHOR
1.95 +25 -4 parrot/imcc/imcc.l
Index: imcc.l
===================================================================
RCS file: /cvs/public/parrot/imcc/imcc.l,v
retrieving revision 1.94
retrieving revision 1.95
diff -u -w -r1.94 -r1.95
--- imcc.l 19 Mar 2004 09:20:36 -0000 1.94
+++ imcc.l 30 Mar 2004 14:49:56 -0000 1.95
@@ -380,13 +380,34 @@
return VAR;
}
if (cur_unit && cur_unit->instructions &&
- !strcmp(yytext, "self") &&
- (r = cur_unit->instructions->r[1])) {
- if (r->pcc_sub && r->pcc_sub->pragma & P_METHOD)
+ (r = cur_unit->instructions->r[1]) &&
+ r->pcc_sub) {
+ if ((r->pcc_sub->pragma & P_METHOD) &&
+ !strcmp(yytext, "self")) {
valp->s = str_dup("P2");
return REG;
}
-
+ if (!strcmp(yytext, "argcI")) {
+ valp->s = str_dup("I1");
+ return REG;
+ }
+ if (!strcmp(yytext, "argcS")) {
+ valp->s = str_dup("I2");
+ return REG;
+ }
+ if (!strcmp(yytext, "argcP")) {
+ valp->s = str_dup("I3");
+ return REG;
+ }
+ if (!strcmp(yytext, "argcN")) {
+ valp->s = str_dup("I4");
+ return REG;
+ }
+ if (!strcmp(yytext, "is_prototyped")) {
+ valp->s = str_dup("I0");
+ return REG;
+ }
+ }
}
valp->s = str_dup(yytext);
return(!is_def && is_op(interp, valp->s) ? PARROT_OP : IDENTIFIER);
1.40 +47 -1 parrot/imcc/t/syn/pcc.t
Index: pcc.t
===================================================================
RCS file: /cvs/public/parrot/imcc/t/syn/pcc.t,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -w -r1.39 -r1.40
--- pcc.t 22 Mar 2004 14:32:33 -0000 1.39
+++ pcc.t 30 Mar 2004 14:50:00 -0000 1.40
@@ -1,6 +1,6 @@
#!perl
use strict;
-use TestCompiler tests => 35;
+use TestCompiler tests => 36;
##############################
# Parrot Calling Conventions
@@ -1346,5 +1346,51 @@
P3 is not NULL
2
11
+OUT
+
+output_is(<<'CODE', <<'OUT', "argcX identifiers");
+.sub _main
+ .local int i
+ .local int j
+ .local float f
+ .local string s
+ .local string t
+ .local string u
+ .local pmc p
+ .local pmc q
+ _func(i,j,f,s,t,u,p,q)
+ print "proto "
+ print is_prototyped
+ print "\n"
+ print "P "
+ print argcP
+ print "\n"
+ end
+.end
+.sub _func
+ print "proto "
+ print is_prototyped
+ print "\n"
+ print "I "
+ print argcI
+ print "\n"
+ print "S "
+ print argcS
+ print "\n"
+ print "P "
+ print argcP
+ print "\n"
+ print "N "
+ print argcN
+ print "\n"
+.end
+CODE
+proto 1
+I 2
+S 3
+P 2
+N 1
+proto 0
+P 0
OUT