mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-10-01 01:29:24 +02:00
[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.
This commit is contained in:
+35
-16
@@ -3,23 +3,42 @@ module std.stdio;
|
||||
import std.traits;
|
||||
|
||||
void _writef(T)(T t) {
|
||||
static if(is(T: Object)) _writef(t.toString()); else
|
||||
static if(is(T==char)) printf("%c", t); else
|
||||
static if(is(T: char[])) printf("%.*s", t.length, t.ptr); else
|
||||
static if(isArray!(T)) {
|
||||
_writef('[');
|
||||
if (t.length) _writef(t[0]);
|
||||
for (int i=1; i<t.length; ++i) { _writef(','); _writef(t[i]); }
|
||||
_writef(']');
|
||||
} else
|
||||
static if(is(T: int)) printf("%i", t); else
|
||||
static if(is(T: real)) printf("%f", t); else
|
||||
static assert(false, "Cannot print "~T.stringof);
|
||||
static if (is(T == char)) {
|
||||
printf("%c", t);
|
||||
}
|
||||
else static if (is(T : char[])) {
|
||||
printf("%.*s", t.length, t.ptr);
|
||||
}
|
||||
else static if (is(T : long)) {
|
||||
printf("%ld", t);
|
||||
}
|
||||
else static if (is(T : ulong)) {
|
||||
printf("%lu", t);
|
||||
}
|
||||
else static if (is(T : real)) {
|
||||
printf("%f", t);
|
||||
}
|
||||
else static if (is(T : Object)) {
|
||||
_writef(t.toString());
|
||||
}
|
||||
else static if(isArray!(T)) {
|
||||
_writef('[');
|
||||
if (t.length) {
|
||||
_writef(t[0]);
|
||||
foreach(v; t[1..$]) {
|
||||
_writef(','); _writef(v);
|
||||
}
|
||||
}
|
||||
_writef(']');
|
||||
}
|
||||
else static assert(0, "Cannot writef:"~T.tostring);
|
||||
}
|
||||
|
||||
void writef(T...)(T t) {
|
||||
foreach (v; t) _writef(v);
|
||||
void writef(T...)(T t)
|
||||
{
|
||||
foreach(v;t) _writef(v);
|
||||
}
|
||||
void writefln(T...)(T t) {
|
||||
writef(t, "\n");
|
||||
void writefln(T...)(T t)
|
||||
{
|
||||
writef(t, '\n');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user