예제 #1
0
파일: floodopt.c 프로젝트: tangentforks/zpl
/* this function does the transformation involved in replacing an
 * expression */
static void replace_expression(expr_t* expr,mloop_t* mloop) {
  symboltable_t *new_temp;
  expr_t *new_expr;
  char *new_id = (char *)malloc(10);
  statement_t *body=T_MLOOP_BODY(mloop);

  /* drop out if replacement expr already exists */
  if (find_replacement(mloop, expr)) return;

  /* create a new temporary variable */
  sprintf(new_id,"__temp%d",idnum);
  new_temp = alloc_loc_st (S_VARIABLE,new_id);
  S_DTYPE(new_temp) = T_TYPEINFO(expr);
  S_VAR_INIT(new_temp) = NULL;
  S_INIT(new_temp) = build_init(expr,NULL);
  S_PROHIBITIONS(new_temp) |= TILED_OUTER_MLOOP_FLAG;
  new_expr = build_0ary_op(VARIABLE,new_temp);
  idnum++;

  /* replace the variable */
  T_ADD_MLOOP_VAR (mloop, new_temp, T_MLOOP_ORDER(mloop, T_MLOOP_RANK(mloop)-1));
  replace_expr(expr, copy_expr(new_expr));
  /*add_replacement(mloop,copy_expr(expr),copy_expr(new_expr));*/

  /* if necessary, reassign the variable */
  if (is_written(new_expr,body)) {
    statement_t* post;
    expr_t* reassign;
    reassign=build_binary_op(BIASSIGNMENT,copy_expr(new_expr),copy_expr(expr));
    post=build_expr_statement(reassign,T_LINENO(body),T_FILENAME(body));
    T_PROHIBITIONS(post) |= TILED_OUTER_MLOOP_FLAG;
    T_ADD_MLOOP_POST(mloop,post,T_MLOOP_ORDER(mloop, T_MLOOP_RANK(mloop)-1));
  }
} /* replace_expression(expr,mloop) */
예제 #2
0
파일: conflicts.c 프로젝트: megabajt/poldek
/* trying to resolve conflict by package upgrade */
static int resolve_conflict(int indent, struct i3ctx *ictx,
                            struct pkg *pkg, const struct capreq *cnfl,
                            struct pkg *dbpkg)
{
    struct capreq *req = NULL;
    struct pkg *tomark = NULL;
    tn_array   *candidates = NULL;
    int found = 0, by_replacement = 0;

    if (!ictx->ts->getop(ictx->ts, POLDEK_OP_FOLLOW))
        return 0;

    if (!capreq_versioned(cnfl))
        return 0;
    
    req = capreq_clone(NULL, cnfl);
    
#if 0                           /* debug */
    printf("B %s -> ", capreq_stra(req));
    capreq_revrel(req);
    printf("%s -> ", capreq_stra(req));
    capreq_revrel(req);
    printf("%s\n", capreq_stra(req));
#endif

    DBGF("find_req %s %s\n", pkg_id(pkg), capreq_stra(req));
    capreq_revrel(req);
    DBGF("find_req %s %s\n", pkg_id(pkg), capreq_stra(req));

    if (i3_is_user_choosable_equiv(ictx->ts))
        candidates = pkgs_array_new(8);

    found = i3_find_req(indent, ictx, pkg, req, &tomark, candidates);
    capreq_revrel(req);
    
    if (!found) {
        found = find_replacement(ictx, dbpkg, cnfl, &tomark);
        by_replacement = 1;
        
    } else {
        struct pkg *real_tomark = tomark;

        /* tomark == NULL ? req satsfied by already installed set */
        if (tomark && candidates && n_array_size(candidates) > 1) {
            real_tomark = i3_choose_equiv(ictx->ts, pkg, req, candidates, tomark);
            n_array_cfree(&candidates);
            if (real_tomark == NULL) { /* user aborts */
                ictx->abort = 1;
                found = 0;
            }
        }
        tomark = real_tomark;
    }
    	
    if (!found)
        goto l_end;
        
    if (tomark == NULL)   /* already in inset */
        goto l_end;
    
    found = 0;
    if (by_replacement || pkg_obsoletes_pkg(tomark, dbpkg)) {
        struct i3pkg *i3tomark;

        found = 1;
        i3tomark = i3pkg_new(tomark, 0, pkg, req, I3PKGBY_REQ);
        i3_process_package(indent, ictx, i3tomark);
    }
    
l_end:
    n_array_cfree(&candidates);
    capreq_free(req);
    return found;
}