fixed some depencies between irdump.c and irdumptxt.c
[libfirm] / ir / ana2 / pto_ctx.c
1 /* -*- c -*- */
2
3 /*
4    Project:     libFIRM
5    File name:   ir/ana/pto_ctx.c
6    Purpose:     ...
7    Author:      Florian
8    Modified by:
9    Created:     Sat Nov 13 19:35:27 CET 2004
10    CVS-ID:      $Id$
11    Copyright:   (c) 1999-2004 Universität Karlsruhe
12    Licence:     This file is protected by the GPL -  GNU GENERAL PUBLIC LICENSE.
13 */
14
15 # ifdef HAVE_CONFIG_H
16 #  include <config.h>
17 # endif
18
19 /*
20  pto_ctx: ...
21 */
22
23 # include "pto_ctx.h"
24
25 # include "irnode.h"
26 # include "xmalloc.h"
27
28 # include "pto_debug.h"
29
30 /* Local Defines: */
31
32 /* Local Data Types: */
33
34 /* Local Variables: */
35 static ctx_info_t *curr_ctx = NULL;
36
37 /* Local Prototypes: */
38
39 /* ===================================================
40    Local Implementation:
41    =================================================== */
42
43
44 /* ===================================================
45    Exported Implementation:
46    =================================================== */
47 /* Find the appropriate ctx for the given call and the given graph */
48 /* ctx_info_t *find_ctx (ir_node *call, graph_info_t *ginfo, ctx_info_t *curr_ctx) */
49 int find_ctx_idx (ir_node *call, graph_info_t *ginfo, ctx_info_t *curr_ctx)
50 {
51   int i;
52   const int n_ctxs = ginfo->n_ctxs;
53
54   for (i = 0; i < n_ctxs; i ++) {
55     ctx_info_t *ctx = ginfo->ctxs [i];
56
57     if ((ctx->enc == curr_ctx) && (ctx->call == call)) {
58       return (i);
59     }
60   }
61
62   fflush (stdout);
63   assert (0 && "CTX not found");
64
65   return (-1);
66 }
67
68 /* Get the current ctx */
69 ctx_info_t *get_curr_ctx (void)
70 {
71   return (curr_ctx);
72 }
73
74 /* Set the current ctx to the given ctx.  Return the old value */
75 ctx_info_t *set_curr_ctx (ctx_info_t *ctx)
76 {
77   ctx_info_t *old_ctx = curr_ctx;
78
79   curr_ctx = ctx;
80
81   return (old_ctx);
82 }
83
84
85
86 \f
87 /*
88   $Log$
89   Revision 1.1  2004/11/18 16:37:34  liekweg
90   rewritten
91
92
93 */