pike.git/
src/
pike_types.c
Branch:
Tag:
Non-build tags
All tags
No tags
2008-06-18
2008-06-18 20:48:09 by Henrik Grubbström (Grubba) <grubba@grubba.org>
ebd2e43c0ce87dd95ca4d3fede5dc4b070f58736 (
124
lines) (+
71
/-
53
)
[
Show
|
Annotate
]
Branch:
7.9
Added check_splice_call().
Rev: src/pike_types.c:1.340
Rev: src/pike_types.h:1.120
2:
|| This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information.
-
|| $Id: pike_types.c,v 1.
339
2008/06/
16
22
:
16
:
53
mast
Exp $
+
|| $Id: pike_types.c,v 1.
340
2008/06/
18
20
:
48
:
08
grubba
Exp $
*/ #include "global.h"
6662:
} /* NOTE: fun_type loses a reference. */
+
struct pike_type *check_splice_call(struct pike_string *fun_name,
+
struct pike_type *fun_type,
+
INT32 argno,
+
struct pike_type *arg_type,
+
struct svalue *sval,
+
INT32 flags)
+
{
+
struct compilation *c = THIS_COMPILATION;
+
struct pike_type *tmp = NULL;
+
struct pike_type *res = NULL;
+
struct pike_type *prev = fun_type;
+
int cnt = 256;
+
/* This argument can expand to anything between zero and MAX_ARGS args. */
+
+
copy_pike_type(res, fun_type);
+
+
/* Loop until we get a stable fun_type, or it's an invalid argument. */
+
while ((fun_type = low_new_check_call(debug_malloc_pass(prev),
+
debug_malloc_pass(arg_type),
+
flags, sval)) &&
+
(fun_type != prev) && --cnt) {
+
+
#ifdef PIKE_DEBUG
+
if (l_flag>4) {
+
fprintf(stderr, "\n sub_result_type: ");
+
simple_describe_type(fun_type);
+
}
+
#endif /* PIKE_DEBUG */
+
+
res = dmalloc_touch(struct pike_type *,
+
or_pike_types(debug_malloc_pass(tmp = res),
+
debug_malloc_pass(fun_type), 1));
+
#ifdef PIKE_DEBUG
+
if (l_flag>4) {
+
fprintf(stderr, "\n joined_type: ");
+
simple_describe_type(res);
+
}
+
#endif /* PIKE_DEBUG */
+
+
if ((res == tmp) || (res == fun_type)) {
+
free_type(tmp);
+
break;
+
}
+
free_type(tmp);
+
+
free_type(prev);
+
prev = fun_type;
+
}
+
free_type(prev);
+
if (fun_type) {
+
/* Max args reached or stable type. */
+
free_type(fun_type);
+
} else if (!(flags & CALL_INHIBIT_WARNINGS)) {
+
/* The splice values are invalid for later arguments. */
+
if (cnt == 256) {
+
yywarning("In argument %d to %S: The @-operator argument must be an empty array.",
+
argno, fun_name);
+
} else if (c->lex.pragmas & ID_STRICT_TYPES) {
+
yywarning("In argument %d to %S: The @-operator argument has a max length of %d.",
+
argno, fun_name, 256-cnt);
+
}
+
}
+
+
return res;
+
}
+
+
/* NOTE: fun_type loses a reference. */
struct pike_type *new_check_call(struct pike_string *fun_name, struct pike_type *fun_type, node *args, INT32 *argno, INT32 flags)
6713:
} if (args->token == F_PUSH_ARRAY) {
-
struct pike_type *prev = fun_type;
-
int cnt = 256;
-
/* This token can expand to anything between zero and MAX_ARGS args. */
-
+
#ifdef PIKE_DEBUG if (l_flag>2) { fprintf(stderr, "\n The argument is a splice operator.\n"); } #endif /* PIKE_DEBUG */
-
copy
_
pike
_
type
(
res
, fun_type);
+
res = check
_
splice
_
call
(
fun_name
, fun_type
, *argno,
+
args->type, sval, flags
);
-
/* Loop until we get a stable fun_type, or it's an invalid argument. */
-
while ((fun_type = low_new_check_call(debug_malloc_pass(prev),
-
debug_malloc_pass(args->type),
-
flags, sval)) &&
-
(fun_type != prev) && --cnt) {
-
+
#ifdef PIKE_DEBUG
-
if (l_flag>4) {
-
fprintf(stderr, "\n sub_result_type: ");
-
simple_describe_type(fun_type);
-
}
-
#endif /* PIKE_DEBUG */
-
-
res = dmalloc_touch(struct pike_type *,
-
or_pike_types(debug_malloc_pass(tmp = res),
-
debug_malloc_pass(fun_type), 1));
-
#ifdef PIKE_DEBUG
-
if (l_flag>4) {
-
fprintf(stderr, "\n joined_type: ");
-
simple_describe_type(res);
-
}
-
#endif /* PIKE_DEBUG */
-
-
if ((res == tmp) || (res == fun_type)) {
-
free_type(tmp);
-
break;
-
}
-
free_type(tmp);
-
-
free_type(prev);
-
prev = fun_type;
-
}
-
free_type(prev);
-
if (fun_type) {
-
/* Max args reached or stable type. */
-
free_type(fun_type);
-
} else {
-
/* The splice values are invalid for later arguments. */
-
if (cnt == 256) {
-
yywarning("In argument %d to %S: The @-operator argument must be an empty array.",
-
*argno, fun_name);
-
} else if (c->lex.pragmas & ID_STRICT_TYPES) {
-
yywarning("In argument %d to %S: The @-operator argument has a max length of %d.",
-
*argno, fun_name, 256-cnt);
-
}
-
}
-
-
#ifdef PIKE_DEBUG
+
if (l_flag>2) { fprintf(stderr, "\n result: "); simple_describe_type(res);