[Python-checkins] python/dist/src/Python ast.c,1.1.2.26,1.1.2.27

jhylton@users.sourceforge.net jhylton@users.sourceforge.net
2003年4月28日 05:11:27 -0700


Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1:/tmp/cvs-serv3221a
Modified Files:
 Tag: ast-branch
	ast.c 
Log Message:
Handle keyword arguments at call site.
Index: ast.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/Attic/ast.c,v
retrieving revision 1.1.2.26
retrieving revision 1.1.2.27
diff -C2 -d -r1.1.2.26 -r1.1.2.27
*** ast.c	3 Apr 2003 00:51:45 -0000	1.1.2.26
--- ast.c	28 Apr 2003 12:11:22 -0000	1.1.2.27
***************
*** 869,900 ****
 */
 
! int i, nargs;
 asdl_seq *args = NULL;
 
 REQ(n, arglist);
 
 nargs = 0;
! for (i = 0; i < NCH(n); i++)
! 	if (TYPE(CHILD(n, i)) == argument)
! 	 nargs++;
 
 args = asdl_seq_new(nargs);
 if (!args)
 	return NULL;
 for (i = 0; i < NCH(n); i++) {
 	node *ch = CHILD(n, i);
 	if (TYPE(ch) == argument) {
 	 expr_ty e;
! 	 if (NCH(ch) == 1)
 		e = ast_for_expr(CHILD(ch, 0));
! 	 else
! 		e = NULL;
! 	 asdl_seq_SET(args, i / 2, e);
 	}
 }
 
- 
 /* XXX syntax error if more than 255 arguments */
! return Call(func, args, NULL, NULL, NULL);
 }
 
--- 869,922 ----
 */
 
! int i, nargs, nkeywords;
 asdl_seq *args = NULL;
+ asdl_seq *keywords = NULL;
 
 REQ(n, arglist);
 
 nargs = 0;
! nkeywords = 0;
! for (i = 0; i < NCH(n); i++) 
! 	if (TYPE(CHILD(n, i)) == argument) {
! 	 if (NCH(CHILD(n, i)) == 1)
! 		nargs++;
! 	 else
! 		nkeywords++;
! 	}
 
 args = asdl_seq_new(nargs);
 if (!args)
 	return NULL;
+ keywords = asdl_seq_new(nkeywords);
+ if (!keywords)
+ 	return NULL;
+ nargs = 0;
+ nkeywords = 0;
 for (i = 0; i < NCH(n); i++) {
 	node *ch = CHILD(n, i);
 	if (TYPE(ch) == argument) {
 	 expr_ty e;
! 	 if (NCH(ch) == 1) {
 		e = ast_for_expr(CHILD(ch, 0));
! 		asdl_seq_SET(args, nargs++, e);
! 	 } 
! 	 else {
! 		keyword_ty kw;
! 		identifier key;
! 
! 		/* CHILD(ch, 0) is test, but must be an identifier? */ 
! 		e = ast_for_expr(CHILD(ch, 0));
! 		assert(e->kind == Name_kind);
! 		key = e->v.Name.id;
! 		free(e);
! 		e = ast_for_expr(CHILD(ch, 2));
! 		kw = keyword(key, e);
! 		asdl_seq_SET(keywords, nkeywords++, kw);
! 	 }
 	}
 }
 
 /* XXX syntax error if more than 255 arguments */
! return Call(func, args, keywords, NULL, NULL);
 }
 

AltStyle によって変換されたページ (->オリジナル) /