| Thread overview | |||||
|---|---|---|---|---|---|
|
March 26, 2012 [dmd-internals] A dmd hacking question | ||||
|---|---|---|---|---|
| ||||
Attachments:
| 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 ?
| |||
March 26, 2012 Re: [dmd-internals] A dmd hacking question | ||||
|---|---|---|---|---|
| ||||
Posted in reply to deadal nix | 2012$BG/(B3$B7n(B26$BF|(B10:31 deadal nix <deadalnix@gmail.com>: > 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)); ps->push(new Parameter(0, type, Lexer::idPool("argument"), 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 ? In basic, each identifier object is unique, and in semantic they are compared only their address. Kenji Hara _______________________________________________ dmd-internals mailing list dmd-internals@puremagic.com http://lists.puremagic.com/mailman/listinfo/dmd-internals | |||
March 26, 2012 Re: [dmd-internals] A dmd hacking question | ||||
|---|---|---|---|---|
| ||||
Posted in reply to kenji hara Attachments:
| Thank a lot ! That solved it !
Le 26 mars 2012 05:31, kenji hara <k.hara.pg@gmail.com> a écrit :
> 2012年3月26日10:31 deadal nix <deadalnix@gmail.com>:
> > 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));
>
> ps->push(new Parameter(0, type, Lexer::idPool("argument"), 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 ?
>
> In basic, each identifier object is unique, and in semantic they are compared only their address.
>
> Kenji Hara
> _______________________________________________
> dmd-internals mailing list
> dmd-internals@puremagic.com
> http://lists.puremagic.com/mailman/listinfo/dmd-internals
>
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply