annotate trunk/src/Information.d @ 249:32d354584b28

- Upgraded license notices to GPL3.
author aziz
date Wed, 01 Aug 2007 15:14:05 +0000
parents 0fe650a7a8d1
children b4d842b0d2c7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
69
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
1 /++
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
2 Author: Aziz Köksal
249
32d354584b28 - Upgraded license notices to GPL3.
aziz
parents: 94
diff changeset
3 License: GPL3
69
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
4 +/
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
5 module Information;
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
6 import Messages;
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
7 import std.string;
71
b3777cca323c - Added Identity and NotIdentity tokens.
aziz
parents: 69
diff changeset
8 import std.stdarg;
69
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
9
94
0fe650a7a8d1 - Renamed Type enum to InfoType in module Information.
aziz
parents: 71
diff changeset
10 enum InfoType
69
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
11 {
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
12 Lexer,
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
13 Parser,
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
14 Semantic
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
15 }
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
16
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
17 class Information
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
18 {
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
19 MID id;
94
0fe650a7a8d1 - Renamed Type enum to InfoType in module Information.
aziz
parents: 71
diff changeset
20 InfoType type;
69
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
21 uint loc;
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
22 string[] arguments;
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
23
94
0fe650a7a8d1 - Renamed Type enum to InfoType in module Information.
aziz
parents: 71
diff changeset
24 this(InfoType type, MID id, uint loc, string[] arguments)
69
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
25 {
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
26 this.id = id;
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
27 this.type = type;
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
28 this.loc = loc;
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
29 this.arguments = arguments;
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
30 }
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
31
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
32 string getMsg()
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
33 {
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
34 char[] msg = messages[id];
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
35
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
36 if (arguments.length == 0)
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
37 return msg;
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
38
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
39 foreach (i, arg; arguments)
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
40 msg = replace(msg, format("{%s}", i+1), arg);
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
41
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
42 return msg;
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
43 }
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
44 }
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents:
diff changeset
45
71
b3777cca323c - Added Identity and NotIdentity tokens.
aziz
parents: 69
diff changeset
46 char[][] arguments(TypeInfo[] tinfos, void* argptr)
b3777cca323c - Added Identity and NotIdentity tokens.
aziz
parents: 69
diff changeset
47 {
b3777cca323c - Added Identity and NotIdentity tokens.
aziz
parents: 69
diff changeset
48 char[][] args;
b3777cca323c - Added Identity and NotIdentity tokens.
aziz
parents: 69
diff changeset
49 foreach (ti; tinfos)
b3777cca323c - Added Identity and NotIdentity tokens.
aziz
parents: 69
diff changeset
50 {
b3777cca323c - Added Identity and NotIdentity tokens.
aziz
parents: 69
diff changeset
51 if (ti == typeid(char[]))
b3777cca323c - Added Identity and NotIdentity tokens.
aziz
parents: 69
diff changeset
52 args ~= format(va_arg!(char[])(argptr));
b3777cca323c - Added Identity and NotIdentity tokens.
aziz
parents: 69
diff changeset
53 else if (ti == typeid(int))
b3777cca323c - Added Identity and NotIdentity tokens.
aziz
parents: 69
diff changeset
54 args ~= format(va_arg!(int)(argptr));
b3777cca323c - Added Identity and NotIdentity tokens.
aziz
parents: 69
diff changeset
55 else if (ti == typeid(dchar))
b3777cca323c - Added Identity and NotIdentity tokens.
aziz
parents: 69
diff changeset
56 args ~= format(va_arg!(dchar)(argptr));
b3777cca323c - Added Identity and NotIdentity tokens.
aziz
parents: 69
diff changeset
57 else
b3777cca323c - Added Identity and NotIdentity tokens.
aziz
parents: 69
diff changeset
58 assert(0, "argument type not supported yet.");
b3777cca323c - Added Identity and NotIdentity tokens.
aziz
parents: 69
diff changeset
59 }
b3777cca323c - Added Identity and NotIdentity tokens.
aziz
parents: 69
diff changeset
60 return args;
b3777cca323c - Added Identity and NotIdentity tokens.
aziz
parents: 69
diff changeset
61 }