pike.git
/
src
/
docode.c
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/docode.c:783:
emit0(F_CONST0); PUSH_CLEANUP_FRAME(do_pop_mark, 0); while ((arg = my_get_arg(&args, ++no)) && *arg) { do_docode(*arg, 0); } emit1(F_LTOSVAL_CALL_BUILTIN_AND_ASSIGN, DO_NOT_WARN((INT32)tmp1)); POP_AND_DONT_CLEANUP; return 1; }
+
static int is_apply_constant_function_arg0( node *n, node *target )
+
{
+
if (/*n->token == F_APPLY &&*/
+
(CAR(n)->token == F_CONSTANT) &&
+
(TYPEOF(CAR(n)->u.sval) == T_FUNCTION) &&
+
(SUBTYPEOF(CAR(n)->u.sval) == FUNCTION_BUILTIN) &&
+
(CAR(n)->u.sval.u.efun->function != f_map) &&
+
(CAR(n)->u.sval.u.efun->function != f_filter)) {
+
/* efuns typically don't access object variables. */
+
node *args = CDR(n), **arg;
+
if (args)
+
{
+
arg = my_get_arg(&args, 0);
+
if (arg && node_is_eq(target, *arg) &&
+
!(args->tree_info & OPT_ASSIGNMENT))
+
{
+
if(match_types(target->type, array_type_string) ||
+
match_types(target->type, string_type_string) ||
+
match_types(target->type, object_type_string) ||
+
match_types(target->type, multiset_type_string) ||
+
match_types(target->type, mapping_type_string))
+
{
+
return emit_ltosval_call_and_assign(target,CAR(n),args);
+
}
+
}
+
}
+
}
+
return 0;
+
}
+
static void emit_multi_assign(node *vals, node *vars, int no) { struct compilation *c = THIS_COMPILATION; node *var; node *val; node **valp = my_get_arg(&vals, no); if (!vars && (!valp || !*valp)) return; if (!(vars && valp && (val = *valp))) { yyerror("Argument count mismatch for multi-assignment.\n");
pike.git/src/docode.c:1316:
} if (CAR (n)->token == F_RANGE) emit_range (CAR (n) DO_IF_DEBUG (COMMA num_args)); else emit0(CAR(n)->token); emit0(n->token); return n->token==F_ASSIGN; /* So when is this false? /mast */ }
+
case F_SOFT_CAST:
+
/* a = [type]`oper(a,*) */
+
if( CAAR(n)->token == F_APPLY &&
+
is_apply_constant_function_arg0( CAAR(n), CDR(n) ))
+
return 1;
+
goto do_not_suboptimize_assign;
case F_APPLY:
-
if
((CAAR(n)->token
== F_CONSTANT) &&
-
(TYPEOF(CAAR(n)->u.sval) == T_FUNCTION) &&
-
(SUBTYPEOF(CAAR(n)->u.sval) == FUNCTION_BUILTIN) &&
-
(CAAR(n)->u.sval.u.efun->function != f_map) &&
-
(CAAR(n)->u.sval.u.efun->function != f_filter)) {
-
/*
efuns
typically
don't
access object variables. */
-
node *args
=
CDAR
(
n)
,
*
*arg;
-
if (args && count_args(args
)
> 1)
-
{
-
arg = my_get_arg(&args, 0);
-
if (
arg && node_
is_
eq(CDR(n), *arg) &&
-
!(args->tree
_
info & OPT
_
ASSIGNMENT)) {
-
if(match
_
types
(
CDR(n)->type,
array_type_string) ||
-
match_types
(
CDR(
n)
->type
,
string_type_string) ||
-
match_types(
CDR(n)
->type,
object_type_string
)
||
-
match_types(CDR(n
)
->type, multiset_type_string) ||
-
match_types(CDR(n)->type, mapping_type_string))
-
{
-
/* First arg is the lvalue.
-
* We optimize this to allow for destructive operations.
-
*/
-
return
emit_ltosval_call_and_assign( CDR(n), CAAR(n), CDAR(n) )
;
-
}
-
}
-
}
-
}
+
/*
a
=
`oper
(
a
,*)
*/
+
if (is_
apply
_
constant
_
function
_
arg0
(
CAR
(n), CDR(n) ))
+
return
1
;
/* FALL_THROUGH */ default: do_not_suboptimize_assign: switch(CDR(n)->token) { case F_GLOBAL: if(CDR(n)->u.integer.b) goto normal_assign; code_expression(CAR(n), 0, "RHS"); emit_assign_global( CDR(n)->u.integer.a, flags & DO_POP ); break;