merge ...

This commit is contained in:
Tomas Lindquist Olsen
2008-08-01 21:56:13 +02:00
4 changed files with 63 additions and 21 deletions

View File

@@ -1,5 +1,7 @@
module qd;
alias char[] string;
extern(C) {
struct SDL_Rect {
short x, y;
@@ -107,6 +109,7 @@ void getpixel32(int x, int y, ubyte[4] *col) {
SDL_GetRGBA(*bufp, display.format, &(*col)[0], &(*col)[1], &(*col)[2], &(*col)[3]);
}
align(1)
struct rgb {
ubyte[3] values;
ubyte r() { return values[0]; }
@@ -288,14 +291,23 @@ void line(T...)(int x0, int y0, int x1, int y1, T p) {
}
}
pragma(LLVM_internal, "intrinsic", "llvm.sqrt.f32") {
float sqrt(float val);
import llvmdc.intrinsics;
alias llvm_sqrt_f32 sqrt;
alias llvm_sqrt_f64 sqrt;
version(X86)
{
alias llvm_sqrt_f80 sqrt;
}
pragma(LLVM_internal, "intrinsic", "llvm.sqrt.f64") {
double sqrt(double val);
real sqrt(real val);
else
{
static import tango.stdc.math;
real sqrt(real x)
{
return tango.stdc.math.sqrtl(x);
}
}
template circle_bresenham_pass(bool first) {
const string xy=(first?"x":"y");
const string yx=(first?"y":"x");
@@ -326,7 +338,6 @@ template circle_bresenham_pass(bool first) {
";
}
import std.stdio;
void circle(T...)(T t) {
static assert(T.length!<3, "Circle: Needs x, y and radius");
int cx=t[0], cy=t[1], xradius=t[2];
@@ -434,7 +445,7 @@ void events(void delegate(int, bool) key=null, void delegate(int, int, ubyte, bo
if (key) key(evt.key.keysym.sym, false);
break;
case SDL_EventType.Quit:
throw new Error("Quit");
throw new Exception("Quit");
break;
default: break;
}
@@ -454,3 +465,10 @@ void events(void delegate(int) key, void delegate(int, int) mouse) {
void events(void delegate(int, bool) key, void delegate(int, int) mouse) {
events(key, (int x, int y, ubyte b, bool p) { mouse(x, y); });
}
void sleep(float secs)
{
assert(secs >= 0);
uint ms = cast(uint)(secs * 1000);
SDL_Delay(ms);
}

View File

@@ -1,19 +1,29 @@
module qd1;
import qd;
import std.c.time: sleep;
void main() {
screen(640, 480);
pset(10, 10);
line(0, 0, 100, 100, Box, Back(Red~Black));
for (int i=0; i<=100; i+=10) {
line(i, 0, 100-i, 100);
line(0, i, 100, 100-i);
}
circle(100, 100, 50, 15, White~Black, Fill=White~Black);
paint(200, 200, Red, Back=White);
circle(100, 100, 50, 15, White);
paint(200, 200, Black);
pset(10, 11); pset(10, 11, Black);
pset(10, 10);
sleep(5);
sleep(1);
cls(Red);
sleep(1);
cls(Green);
sleep(1);
cls(Blue);
sleep(1);
// pset(10, 10);
// line(0, 0, 100, 100, Box, Back(Red~Black));
// for (int i=0; i<=100; i+=10) {
// line(i, 0, 100-i, 100);
// line(0, i, 100, 100-i);
// }
// circle(100, 100, 50, 15, White~Black, Fill=White~Black);
// paint(200, 200, Red, Back=White);
// circle(100, 100, 50, 15, White);
// paint(200, 200, Black);
// pset(10, 11); pset(10, 11, Black);
// pset(10, 10);
// sleep(1);
}

View File

@@ -589,10 +589,21 @@ void DtoDefineFunc(FuncDeclaration* fd)
// FIXME: llvm seems to want an alloca/byval for debug info
if (!vd->needsStorage || vd->nestedref || vd->isRef() || vd->isOut())
{
Logger::println("skipping arg storage for (%s) %s ", vd->loc.toChars(), vd->toChars());
continue;
}
// static array params don't support debug info it seems
// probably because they're not passed byval
else if (vd->type->toBasetype()->ty == Tsarray)
{
Logger::println("skipping arg storage for static array (%s) %s ", vd->loc.toChars(), vd->toChars());
continue;
}
// debug info for normal aggr params seem to work fine
else if (DtoIsPassedByRef(vd->type))
{
Logger::println("skipping arg storage for aggregate (%s) %s ", vd->loc.toChars(), vd->toChars());
if (global.params.symdebug)
DtoDwarfLocalVariable(vd->ir.getIrValue(), vd);
continue;

View File

@@ -23,8 +23,11 @@ LLConstant* DtoConstStructInitializer(StructInitializer* si)
Logger::println("DtoConstStructInitializer: %s", si->toChars());
LOG_SCOPE;
assert(si->ad);
TypeStruct* ts = (TypeStruct*)si->ad->type;
DtoResolveDsymbol(si->ad);
const llvm::StructType* structtype = isaStruct(ts->ir.type->get());
Logger::cout() << "llvm struct type: " << *structtype << '\n';