www.digitalmars.com         C & C++   DMDScript  

D.gnu - gdmd-0.1.tar.gz

reply "Ben Hinkle" <bhinkle4 juno.com> writes:
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,
 - templates (Walter was right- this was easy. It just worked with minimal
 - 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.


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 */
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;
    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 */
    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 */

    int w;
    w = 6;
    w = fooAdd(w); /* template functions seem to work just fine */

    return 0;
Jan 31 2004
next sibling parent "Walter" <walter digitalmars.com> writes:
Nice work! BTW, you can 'fake' gc just by having it call C's malloc and
never worrying about it. On the other hand, dmd's gc is pretty portable,
after all, it already works on win32 and linux.
Feb 01 2004
prev sibling parent Olaf Rogalsky <olaf.rogalsky theorie1.physik.uni-erlangen.de> writes:
Ben Hinkle wrote:
 Posted to my web site http://home.comcast.net/~benhinkle/gdmd-0.1.tar.gz
I almost lost hope on GNU-D. Thank you very much so far. The last time I tried to compile GCC (3.0.xx) on my old IBM RS/6000 workstation (PowerPC with AIX 4.1.4), it failed miserably on the triple test. Perhaps I should try to give it another chance and then get D running :-). Olaf -- +-------------------------------------------------------------------+ I Dr. rer. nat. Olaf Rogalsky Institut fuer Theoretische Physik I I Universitaet Erlangen-Nuernberg I I Tel.: 09131 8528440 Staudtstr. 7 B3 I I Fax.: 09131 8528444 D-91058 Erlangen I | rogalsky theorie1.physik.uni-erlangen.de I +-------------------------------------------------------------------+
Feb 02 2004