2017-03-18
2017-03-18 13:58:05 by Henrik Grubbström (Grubba) <grubba@grubba.org>
-
a1af3077eb0b36a9256ac464e88d26798476312c
(101 lines)
(+51/-50)
[
Show
| Annotate
]
Branch: 8.1
Compiler: Swap CAR and CDR in F_ASSIGN nodes.
Same for F_MULTI_ASSIGN and F_ASSIGN_SELF.
This gives the same order as for the F_*_EQ nodes,
and makes it possible to simplify the grammar somewhat.
1250:
case F_MULTI_ASSIGN:
if (flags & DO_POP) {
- emit_multi_assign(CAR(n), CDR(n), 0);
+ emit_multi_assign(CDR(n), CAR(n), 0);
return 0;
} else {
/* Fall back to the normal assign case. */
- tmp1=do_docode(CDR(n),DO_LVALUE);
+ tmp1=do_docode(CAR(n),DO_LVALUE);
#ifdef PIKE_DEBUG
if(tmp1 & 1)
Pike_fatal("Very internal compiler error.\n");
1262:
emit1(F_ARRAY_LVALUE, (INT32)(tmp1>>1) );
emit0(F_MARK);
PUSH_CLEANUP_FRAME(do_pop_mark, 0);
- do_docode(CAR(n), 0);
+ do_docode(CDR(n), 0);
emit_apply_builtin("aggregate");
POP_AND_DONT_CLEANUP;
emit0(F_ASSIGN);
1279:
*
* We only want to evaluate car(n) once.
*/
- if( CDR(n)->token == F_AUTO_MAP_MARKER )
+ if( CAR(n)->token == F_AUTO_MAP_MARKER )
yyerror("[*] is not yet supported here\n");
- return emit_ltosval_call_and_assign( CDR(n), CAAAR(n), CDAAR(n) );
+ return emit_ltosval_call_and_assign( CAR(n), CAADR(n), CDADR(n) );
case F_ASSIGN:
- if( CDR(n)->token == F_AUTO_MAP_MARKER )
+ if( CAR(n)->token == F_AUTO_MAP_MARKER )
{
int depth = 0;
- node *lval = CDR(n);
+ node *lval = CAR(n);
while( lval->token == F_AUTO_MAP_MARKER )
{
- lval = CAR(lval);
+ lval = CDR(lval);
depth++;
}
do_docode(lval,0); /* note: not lvalue */
- if(do_docode(CAR(n),0)!=1)
+ if(do_docode(CDR(n),0)!=1)
yyerror("RHS is void!");
- if( CAR(n)->token == F_AUTO_MAP_MARKER ||
- CAR(n)->token == F_AUTO_MAP ||
+ if( CDR(n)->token == F_AUTO_MAP_MARKER ||
+ CDR(n)->token == F_AUTO_MAP ||
/* Well, hello there... ;) */
/* This is what is generated by a[*] += 10 and such. */
- (CAR(n)->token == F_SOFT_CAST &&
- has_automap(CAR(n))))
+ (CDR(n)->token == F_SOFT_CAST &&
+ has_automap(CDR(n))))
{
emit1(F_ASSIGN_INDICES,depth);
}
1316:
return !(flags&DO_POP);
}
- switch(CAR(n)->token)
+ switch(CDR(n)->token)
{
case F_RANGE:
- if(node_is_eq(CDR(n),CAAR(n)))
+ if(node_is_eq(CAR(n),CADR(n)))
{
int num_args;
/* tmp1=do_docode(CDR(n),DO_LVALUE); */
- 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))
+ if(match_types(CAR(n)->type, array_type_string) ||
+ match_types(CAR(n)->type, string_type_string) ||
+ match_types(CAR(n)->type, object_type_string) ||
+ match_types(CAR(n)->type, multiset_type_string) ||
+ match_types(CAR(n)->type, mapping_type_string))
{
- do_docode(CDR(n),DO_LVALUE);
- num_args = do_docode(CDAR(n), 0);
+ do_docode(CAR(n),DO_LVALUE);
+ num_args = do_docode(CDDR(n), 0);
switch (num_args)
{
case 0: emit0(F_LTOSVAL_AND_FREE); break;
1344:
}else{
goto do_not_suboptimize_assign;
emit0(F_LTOSVAL);
- num_args = do_docode(CDAR(n), 0);
+ num_args = do_docode(CDDR(n), 0);
}
- if (CAR (n)->token == F_RANGE)
- emit_range (CAR (n) DO_IF_DEBUG (COMMA num_args));
+ if (CDR (n)->token == F_RANGE)
+ emit_range (CDR (n) DO_IF_DEBUG (COMMA num_args));
else
- emit0(CAR(n)->token);
+ emit0(CDR(n)->token);
emit0(n->token);
return n->token==F_ASSIGN; /* So when is this false? /mast */
1359:
case F_SOFT_CAST:
/* a = [type]`oper(a,*) */
- if( CAAR(n)->token == F_APPLY &&
- is_apply_constant_function_arg0( CAAR(n), CDR(n) ))
+ if( CADR(n)->token == F_APPLY &&
+ is_apply_constant_function_arg0( CADR(n), CAR(n) ))
return 1;
goto do_not_suboptimize_assign;
case F_APPLY:
/* a = `oper(a,*) */
- if (is_apply_constant_function_arg0( CAR(n), CDR(n) ))
+ if (is_apply_constant_function_arg0( CDR(n), CAR(n) ))
return 1;
/* FALL_THROUGH */
default:
do_not_suboptimize_assign:
- switch(CDR(n)->token)
+ switch(CAR(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 );
+ if(CAR(n)->u.integer.b) goto normal_assign;
+ code_expression(CDR(n), 0, "RHS");
+ emit_assign_global( CAR(n)->u.integer.a, flags & DO_POP );
break;
case F_LOCAL:
- if(CDR(n)->u.integer.a >=
- find_local_frame(CDR(n)->u.integer.b)->max_number_of_locals)
+ if(CAR(n)->u.integer.a >=
+ find_local_frame(CAR(n)->u.integer.b)->max_number_of_locals)
yyerror("Illegal to use local variable here.");
- if(CDR(n)->u.integer.b) goto normal_assign;
+ if(CAR(n)->u.integer.b) goto normal_assign;
- if (CDR(n)->node_info & OPT_ASSIGNMENT) {
+ if (CAR(n)->node_info & OPT_ASSIGNMENT) {
/* Initialize. */
emit0(F_CONST0);
- emit1(F_ASSIGN_LOCAL_AND_POP, CDR(n)->u.integer.a);
+ emit1(F_ASSIGN_LOCAL_AND_POP, CAR(n)->u.integer.a);
}
- code_expression(CAR(n), 0, "RHS");
+ code_expression(CDR(n), 0, "RHS");
emit1(flags & DO_POP ? F_ASSIGN_LOCAL_AND_POP:F_ASSIGN_LOCAL,
- CDR(n)->u.integer.a );
+ CAR(n)->u.integer.a );
break;
case F_GET_SET:
{
/* Check for the setter function. */
struct program_state *state = Pike_compiler;
- int program_id = CDR(n)->u.integer.a;
+ int program_id = CAR(n)->u.integer.a;
int level = 0;
while (state && (state->new_program->id != program_id)) {
state = state->previous;
1408:
yyerror("Lost parent.");
} else {
struct reference *ref =
- PTR_FROM_INT(state->new_program, CDR(n)->u.integer.b);
+ PTR_FROM_INT(state->new_program, CAR(n)->u.integer.b);
struct identifier *id =
ID_FROM_PTR(state->new_program, ref);
struct inherit *inh =
1434: Inside #if undefined(USE_APPLY_N)
#ifndef USE_APPLY_N
emit0(F_MARK);
#endif
- code_expression(CAR(n), 0, "RHS");
+ code_expression(CDR(n), 0, "RHS");
} else {
code_expression(CAR(n), 0, "RHS");
#ifndef USE_APPLY_N
1455:
/* FALL_THROUGH */
case F_EXTERNAL:
/* Check that it is in this context */
- if(Pike_compiler ->new_program->id == CDR(n)->u.integer.a)
+ if(Pike_compiler ->new_program->id == CAR(n)->u.integer.a)
{
/* Check that it is a variable */
- if(CDR(n)->u.integer.b != IDREF_MAGIC_THIS &&
- IDENTIFIER_IS_VARIABLE( ID_FROM_INT(Pike_compiler->new_program, CDR(n)->u.integer.b)->identifier_flags))
+ if(CAR(n)->u.integer.b != IDREF_MAGIC_THIS &&
+ IDENTIFIER_IS_VARIABLE( ID_FROM_INT(Pike_compiler->new_program, CAR(n)->u.integer.b)->identifier_flags))
{
- code_expression(CAR(n), 0, "RHS");
- emit_assign_global(CDR(n)->u.integer.b, flags & DO_POP );
+ code_expression(CDR(n), 0, "RHS");
+ emit_assign_global(CAR(n)->u.integer.b, flags & DO_POP );
break;
}
}
1470:
default:
normal_assign:
- tmp1=do_docode(CDR(n),DO_LVALUE);
- if(do_docode(CAR(n),0)!=1) yyerror("RHS is void!");
+ tmp1=do_docode(CAR(n),DO_LVALUE);
+ if(do_docode(CDR(n),0)!=1) yyerror("RHS is void!");
emit0(flags & DO_POP ? F_ASSIGN_AND_POP:F_ASSIGN);
break;
}