[dmd-internals] A dmd hacking question

deadal nix deadalnix at gmail.com
Sun Mar 25 18:31:56 PDT 2012


Hi,

I wanted to try out to do some hacking into DMD. I ran in a problem that I
have no clue how to solve.

I did the following to generate some function with an alternative syntax :
    Type* type = new TypeIdentifier(loc, typeId);
    Parameters* ps = new Parameters();
    ps->push(new Parameter(0, type, new Identifier("argument",
TOKidentifier), NULL));

    Statement* body = parseStatement(PScurly);
    f = new FuncDeclaration(loc, this->loc, id, STCundefined, new
TypeFunction(ps, type, 0, LINKd, STCundefined));
    f->fbody = body;

    Dsymbols *decldefs = new Dsymbols();
    decldefs->push(f);

    return new TemplateDeclaration(loc, id, tpl, constraint, decldefs, 0);

It works great, except that I can't use argument in the function body. I
got an identifier missing message. What is missing to enable this
identifier to be resolved as a regular function parameter ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/dmd-internals/attachments/20120326/d19912a0/attachment.html>


More information about the dmd-internals mailing list