Accept "in" instance variables
[delight/core.git] / dmd / dump.c
blob770a6bac7c79c44d07976b37fd3159e3bb3c82df
2 // Compiler implementation of the D programming language
3 // Copyright (c) 1999-2006 by Digital Mars
4 // All Rights Reserved
5 // written by Walter Bright
6 // http://www.digitalmars.com
7 // License for redistribution is by either the Artistic License
8 // in artistic.txt, or the GNU General Public License in gnu.txt.
9 // See the included readme.txt for details.
11 /* NOTE: This file has been patched from the original DMD distribution to
12 work with the GDC compiler.
14 Modified by David Friedman, December 2006
17 #include <stdio.h>
18 #include <ctype.h>
19 #include <assert.h>
21 #include "mars.h"
22 #include "mtype.h"
23 #include "declaration.h"
24 #include "expression.h"
25 #include "template.h"
27 static void indent(int indent)
29 int i;
31 for (i = 0; i < indent; i++)
32 printf(" ");
35 static char *type_print(Type *type)
37 return type ? type->toChars() : (char *) "null";
40 void dumpExpressions(int i, Expressions *exps)
42 for (size_t j = 0; j < exps->dim; j++)
43 { Expression *e = (Expression *)exps->data[j];
44 indent(i);
45 printf("(\n");
46 e->dump(i + 2);
47 indent(i);
48 printf(")\n");
52 void Expression::dump(int i)
54 indent(i);
55 printf("%p %s type=%s\n", this, Token::toChars(op), type_print(type));
58 void IntegerExp::dump(int i)
60 indent(i);
61 printf("%p %"PRIdMAX" type=%s\n", this, (intmax_t)value, type_print(type));
64 void IdentifierExp::dump(int i)
66 indent(i);
67 printf("%p ident '%s' type=%s\n", this, ident->toChars(), type_print(type));
70 void DsymbolExp::dump(int i)
72 indent(i);
73 printf("%p %s type=%s\n", this, s->toChars(), type_print(type));
76 void VarExp::dump(int i)
78 indent(i);
79 printf("%p %s var=%s type=%s\n", this, Token::toChars(op), var->toChars(), type_print(type));
82 void UnaExp::dump(int i)
84 indent(i);
85 printf("%p %s type=%s e1=%p\n", this, Token::toChars(op), type_print(type), e1);
86 if (e1)
87 e1->dump(i + 2);
90 void CallExp::dump(int i)
92 UnaExp::dump(i);
93 dumpExpressions(i, arguments);
96 void SliceExp::dump(int i)
98 indent(i);
99 printf("%p %s type=%s e1=%p\n", this, Token::toChars(op), type_print(type), e1);
100 if (e1)
101 e1->dump(i + 2);
102 if (lwr)
103 lwr->dump(i + 2);
104 if (upr)
105 upr->dump(i + 2);
108 void DotIdExp::dump(int i)
110 indent(i);
111 printf("%p %s type=%s ident=%s e1=%p\n", this, Token::toChars(op), type_print(type), ident->toChars(), e1);
112 if (e1)
113 e1->dump(i + 2);
116 void DotVarExp::dump(int i)
118 indent(i);
119 printf("%p %s type=%s var='%s' e1=%p\n", this, Token::toChars(op), type_print(type), var->toChars(), e1);
120 if (e1)
121 e1->dump(i + 2);
124 void DotTemplateInstanceExp::dump(int i)
126 indent(i);
127 printf("%p %s type=%s ti='%s' e1=%p\n", this, Token::toChars(op), type_print(type), ti->toChars(), e1);
128 if (e1)
129 e1->dump(i + 2);
132 void DelegateExp::dump(int i)
134 indent(i);
135 printf("%p %s func=%s type=%s e1=%p\n", this, Token::toChars(op), func->toChars(), type_print(type), e1);
136 if (e1)
137 e1->dump(i + 2);
140 void BinExp::dump(int i)
142 indent(i);
143 printf("%p %s type=%s e1=%p e2=%p\n", this, Token::toChars(op), type_print(type), e1, e2);
144 if (e1)
145 e1->dump(i + 2);
146 if (e2)
147 e2->dump(i + 2);