| |
| Posted by Ben Hinkle | PermalinkReply |
|
Ben Hinkle
| Posted to my web site http://home.comcast.net/~benhinkle/gdmd-0.1.tar.gz
New features:
- compiles arbitrary number of toplevel functions
- basic C-style constructs: if statements, loops, labels, arithmetic,
comparison
- templates (Walter was right- this was easy. It just worked with minimal
intervention)
- function overloading
Still missing:
- arrays
- classes
- GC
- exceptions
- asserts
- D function name mangling
- ... everything else ...
I think next up are dynamic arrays or classes. The dynamic array support will probably have to be bootstrapped without any GC since the GC doesn't exist yet. Maybe I'll get lucky and the GC will compile without ever needing to allocate anything.
-Ben
Here is one of the test files gdmd can now compile and run:
module hello2;
extern (C) void printf(char*,...);
template Foo(T) {
extern (C) /* needed for now since it looks like mangling isn't right*/
T addone(T x) {return x+1;}
}
alias Foo!(int).addone fooAdd;
/* try some overloading */
int hello_fcn(int y)
{
return y + 5;
}
double hello_fcn(double y)
{
return y + 6.0; /* must be 6.0 not 6 since const folding doesn't cast */
}
extern (C) /* declare as extern (C) until D's main works */
int
main(char[][] args)
{
printf("hello world.\n");
printf("got %d.\n",hello_fcn(4));
printf("got %g.\n",hello_fcn(4.0));
int x; /* note initializers don't work yet */
int y;
y = 4;
x = y;
L4:
x = x+y; /* labels and basic arithmetic work */
printf("x=%d, y=%d x-y=%d\n",x,y,x-y);
int[] da;
if (x > 10) goto FOO;
/* printf("len=%u\n",da.length); length property doesn't work */
int u; /* declaration inside for loop initialization doesn't work */
GOGO:
for (u=0; (u-2) <= 20; u++) {
if (u == 9) continue;
printf("howdy %d\n",u);
if (u==10) goto L4; /* jumping around seems ok */
}
FOO:
int w;
w = 6;
w = fooAdd(w); /* template functions seem to work just fine */
printf("%d\n",w);
return 0;
}
|