aboutsummaryrefslogtreecommitdiff
path: root/gcc/python/py-il-dot.h
blob: 4456b8cbf73ab20ad7437ec0feeb5d4f7bfe66c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/* This file is part of GCC.

GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.

GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>. */
#ifndef __GCC_PY_IL_DOT_H_
#define __GCC_PY_IL_DOT_H__

/* DOT tree codes... */
typedef enum {
  D_PRINT_STMT,
  D_IDENTIFIER,
  
  D_MODIFY_EXPR,
  D_MULT_EXPR,
  D_DIVD_EXPR,
  D_ADD_EXPR,
  D_MINUS_EXPR,

  D_T_INTEGER,
  D_T_FLOAT,
  D_T_STRING,

  D_CALL_EXPR,
  D_ATTRIB_REF,

  D_STRUCT_CLASS,
  D_STRUCT_METHOD,

  D_D_EXPR,
  D_TD_COM,
  D_TD_DOT,
  D_TD_NULL,

  D_PRIMITIVE,
} opcode_t ; 

typedef struct GTY(()) gpy_tree_common_dot_t {
  opcode_t T;
  union {
    int integer;
    unsigned char c;
    char * string;
  } o;
} gpy_dot_tree_common ;

typedef struct GTY(()) gpy_tree_dot_t {
  opcode_t T, FT, opaT, opbT;
  /* location_t loc; */
  struct gpy_tree_dot_t * field;
  union {
    struct gpy_tree_dot_t * t;
    gpy_dot_tree_common * tc;
  } opa;
  union {
    struct gpy_tree_dot_t * t;
    gpy_dot_tree_common * tc;
  } opb;
  struct gpy_tree_dot_t * next;
} gpy_dot_tree_t ;
typedef gpy_dot_tree_t * gpydot;

typedef int gpy_int;
DEF_VEC_I (gpy_int);
DEF_VEC_ALLOC_I (gpy_int,gc);

DEF_VEC_P (gpydot);
DEF_VEC_ALLOC_P (gpydot,gc);

#define DOT_TYPE(x)      x->T
#define DOT_CHAIN(x)     x->next
#define DOT_T_FIELD(x)   x->FT
#define DOT_FIELD(x)     x->field

#define DOT_lhs_T(x)     x->opaT
#define DOT_rhs_T(x)     x->opbT

#define DOT_lhs_TT(x)    x->opa.t
#define DOT_rhs_TT(x)    x->opb.t
#define DOT_lhs_TC(x)    x->opa.tc
#define DOT_rhs_TC(x)    x->opb.tc

#define NULL_DOT         (gpy_dot_tree_t *)0
#define DOT_alloc        (gpy_dot_tree_t *)xmalloc (sizeof (gpy_dot_tree_t))
#define DOT_CM_alloc     (gpy_dot_tree_common *)xmalloc (sizeof (gpy_dot_tree_common))

#define DOT_IDENTIFIER_POINTER(x)		\
  DOT_lhs_TC(x)->o.string

extern gpy_dot_tree_t * dot_build_class_decl (gpy_dot_tree_t *, gpy_dot_tree_t *);
extern gpy_dot_tree_t * dot_build_func_decl (gpy_dot_tree_t *, gpy_dot_tree_t *,
					     gpy_dot_tree_t *);

extern gpy_dot_tree_t * dot_build_decl1 (opcode_t, gpy_dot_tree_t *);
extern gpy_dot_tree_t * dot_build_decl2 (opcode_t, gpy_dot_tree_t *, gpy_dot_tree_t *);

extern gpy_dot_tree_t * dot_build_integer (int);
extern gpy_dot_tree_t * dot_build_string (char *);
extern gpy_dot_tree_t * dot_build_identifier (const char *);

extern gpy_dot_tree_t * gpy_dot_process_AST_Align (gpy_dot_tree_t **);

#endif /* __GCC_PY_IL_DOT_H_ */