Mercurial > projects > ldc
comparison lphobos/std/stdio.d @ 94:61615fa85940 trunk
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
Added support for array .sort and .reverse properties.
Fixed some bugs with pointer arithmetic.
Disabled some DMD AST optimizations that was messing things up, destroying valuable information.
Added a KDevelop project file, this is what I use for coding LLVMDC now :)
Other minor stuff.
author | lindquist |
---|---|
date | Mon, 12 Nov 2007 06:32:46 +0100 |
parents | 2c3cd3596187 |
children | 5825d48b27d1 |
comparison
equal
deleted
inserted
replaced
93:08508eebbb3e | 94:61615fa85940 |
---|---|
1 module std.stdio; | 1 module std.stdio; |
2 | 2 |
3 import std.traits; | 3 import std.traits; |
4 | 4 |
5 void _writef(T)(T t) { | 5 void _writef(T)(T t) { |
6 static if(is(T: Object)) _writef(t.toString()); else | 6 static if (is(T == char)) { |
7 static if(is(T==char)) printf("%c", t); else | 7 printf("%c", t); |
8 static if(is(T: char[])) printf("%.*s", t.length, t.ptr); else | 8 } |
9 static if(isArray!(T)) { | 9 else static if (is(T : char[])) { |
10 _writef('['); | 10 printf("%.*s", t.length, t.ptr); |
11 if (t.length) _writef(t[0]); | 11 } |
12 for (int i=1; i<t.length; ++i) { _writef(','); _writef(t[i]); } | 12 else static if (is(T : long)) { |
13 _writef(']'); | 13 printf("%ld", t); |
14 } else | 14 } |
15 static if(is(T: int)) printf("%i", t); else | 15 else static if (is(T : ulong)) { |
16 static if(is(T: real)) printf("%f", t); else | 16 printf("%lu", t); |
17 static assert(false, "Cannot print "~T.stringof); | 17 } |
18 else static if (is(T : real)) { | |
19 printf("%f", t); | |
20 } | |
21 else static if (is(T : Object)) { | |
22 _writef(t.toString()); | |
23 } | |
24 else static if(isArray!(T)) { | |
25 _writef('['); | |
26 if (t.length) { | |
27 _writef(t[0]); | |
28 foreach(v; t[1..$]) { | |
29 _writef(','); _writef(v); | |
30 } | |
31 } | |
32 _writef(']'); | |
33 } | |
34 else static assert(0, "Cannot writef:"~T.tostring); | |
18 } | 35 } |
19 | 36 |
20 void writef(T...)(T t) { | 37 void writef(T...)(T t) |
21 foreach (v; t) _writef(v); | 38 { |
39 foreach(v;t) _writef(v); | |
22 } | 40 } |
23 void writefln(T...)(T t) { | 41 void writefln(T...)(T t) |
24 writef(t, "\n"); | 42 { |
43 writef(t, '\n'); | |
25 } | 44 } |