view Paper/source/cbc_replace_arguments.c @ 47:e07c7952f237

add sources
author Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
date Wed, 23 Nov 2011 02:27:44 +0900
parents
children
line wrap: on
line source

static tree
cbc_replace_arguments (location_t loc, tree call)
{
  tree arg;
  tree fn;
  tree tmp_decl;
  int i=0;
  call_expr_arg_iterator iter;

  fn = CALL_EXPR_FN (call);
  if ( TREE_CODE (fn)==PARM_DECL || !TREE_CONSTANT (fn) )
    {
      tmp_decl = build_decl (loc, VAR_DECL, NULL_TREE, TREE_TYPE(fn));
      pushdecl (tmp_decl);

      add_stmt (build_modify_expr (loc, tmp_decl, NULL_TREE, NOP_EXPR, loc, fn, NULL_TREE));
      CALL_EXPR_FN (call) = tmp_decl;
    }

  FOR_EACH_CALL_EXPR_ARG (arg, iter, call)
    {
      /* if ( !CONSTANT_CLASS_P (arg) && !VAR_OR_FUNCTION_DECL_P (arg) ) */
      if ( TREE_CODE (arg)==PARM_DECL || !TREE_CONSTANT (arg) )
        {
          tmp_decl = build_decl (loc, VAR_DECL, NULL_TREE, TREE_TYPE(arg));
          pushdecl (tmp_decl);

          add_stmt (build_modify_expr (loc, tmp_decl, NULL_TREE, NOP_EXPR, loc, arg, NULL_TREE));
          CALL_EXPR_ARG (call, i) = tmp_decl;
        }
      i++;
    }

  return call;
}