mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-03-02 10:33:13 +01:00
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
This commit is contained in:
@@ -9071,4 +9071,30 @@ void CondExp::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||
expToCBuffer(buf, hgs, e2, PREC_cond);
|
||||
}
|
||||
|
||||
/************************************************************/
|
||||
|
||||
#if IN_LLVM
|
||||
|
||||
// Strictly LLVMDC specific stuff
|
||||
|
||||
GEPExp::GEPExp(Loc loc, Expression* e, Identifier* id, unsigned idx)
|
||||
: UnaExp(loc, TOKgep, sizeof(GEPExp), e)
|
||||
{
|
||||
index = idx;
|
||||
ident = id;
|
||||
}
|
||||
|
||||
void GEPExp::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||
{
|
||||
expToCBuffer(buf, hgs, e1, PREC_primary);
|
||||
buf->writeByte('.');
|
||||
buf->writestring(ident->toChars());
|
||||
}
|
||||
|
||||
Expression* GEPExp::toLvalue(Scope* sc, Expression* e)
|
||||
{
|
||||
// GEP's are always lvalues, at least in the "LLVM sense" ...
|
||||
return this;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1496,6 +1496,26 @@ struct LineInitExp : DefaultInitExp
|
||||
|
||||
/****************************************************************/
|
||||
|
||||
#if IN_LLVM
|
||||
|
||||
// this stuff is strictly LLVMDC
|
||||
|
||||
struct GEPExp : UnaExp
|
||||
{
|
||||
unsigned index;
|
||||
Identifier* ident;
|
||||
|
||||
GEPExp(Loc loc, Expression* e, Identifier* id, unsigned idx);
|
||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||
Expression *toLvalue(Scope *sc, Expression *e);
|
||||
|
||||
elem *toElem(IRState *irs);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/****************************************************************/
|
||||
|
||||
/* Special values used by the interpreter
|
||||
*/
|
||||
#define EXP_CANT_INTERPRET ((Expression *)1)
|
||||
|
||||
@@ -160,6 +160,11 @@ enum TOK
|
||||
TOKfile,
|
||||
#endif
|
||||
|
||||
// LLVMDC specific
|
||||
#if IN_LLVM
|
||||
TOKgep,
|
||||
#endif
|
||||
|
||||
TOKMAX
|
||||
};
|
||||
|
||||
|
||||
@@ -3174,17 +3174,14 @@ Expression *TypeDelegate::dotExp(Scope *sc, Expression *e, Identifier *ident)
|
||||
#endif
|
||||
if (ident == Id::ptr)
|
||||
{
|
||||
e = new GEPExp(e->loc, e, ident, 0);
|
||||
e->type = tvoidptr;
|
||||
return e;
|
||||
}
|
||||
else if (ident == Id::funcptr)
|
||||
{
|
||||
e = e->addressOf(sc);
|
||||
e->type = tvoidptr;
|
||||
e = new AddExp(e->loc, e, new IntegerExp(PTRSIZE));
|
||||
e->type = tvoidptr;
|
||||
e = new PtrExp(e->loc, e);
|
||||
e->type = next->pointerTo();
|
||||
e = new GEPExp(e->loc, e, ident, 1);
|
||||
e->type = tvoidptr;
|
||||
return e;
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user