Mercurial > projects > dil
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 |
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 | 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 | 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 | 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 | 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 | 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 | 46 char[][] arguments(TypeInfo[] tinfos, void* argptr) |
47 { | |
48 char[][] args; | |
49 foreach (ti; tinfos) | |
50 { | |
51 if (ti == typeid(char[])) | |
52 args ~= format(va_arg!(char[])(argptr)); | |
53 else if (ti == typeid(int)) | |
54 args ~= format(va_arg!(int)(argptr)); | |
55 else if (ti == typeid(dchar)) | |
56 args ~= format(va_arg!(dchar)(argptr)); | |
57 else | |
58 assert(0, "argument type not supported yet."); | |
59 } | |
60 return args; | |
61 } |