Merged a bunch recent dmd v1 frontend changes into the dmd v2 tree.

This commit is contained in:
Tomas Lindquist Olsen
2009-02-13 22:20:30 +01:00
parent cedd029720
commit 3e17a21e0b
7 changed files with 58 additions and 9 deletions

View File

@@ -560,6 +560,34 @@ Module *Dsymbol::getModule()
return NULL;
}
/**********************************
* Determine which Module a Dsymbol will be compiled in.
* This may be different from getModule for templates.
*/
Module *Dsymbol::getCompilationModule()
{
Module *m;
TemplateInstance *ti;
Dsymbol *s;
//printf("Dsymbol::getModule()\n");
s = this;
while (s)
{
//printf("\ts = '%s'\n", s->toChars());
m = s->isModule();
if (m)
return m;
ti = s->isTemplateInstance();
if (ti && ti->tmodule)
return ti->tmodule;
s = s->parent;
}
return NULL;
}
/*************************************
*/

View File

@@ -121,6 +121,7 @@ struct Dsymbol : Object
void error(const char *format, ...);
void checkDeprecated(Loc loc, Scope *sc);
Module *getModule();
Module *getCompilationModule(); // possibly different for templates
Dsymbol *pastMixin();
Dsymbol *toParent();
Dsymbol *toParent2();

View File

@@ -3074,10 +3074,11 @@ TypeFunction::TypeFunction(Arguments *parameters, Type *treturn, int varargs, en
this->retInPtr = false;
this->usesThis = false;
this->usesNest = false;
this->structInregArg = NULL;
this->retAttrs = 0;
this->thisAttrs = 0;
this->reverseParams = false;
this->reverseIndex = 0;
this->firstRealArg = 0;
}
Type *TypeFunction::syntaxCopy()
@@ -3095,7 +3096,7 @@ Type *TypeFunction::syntaxCopy()
t->retAttrs = retAttrs;
t->thisAttrs = thisAttrs;
t->reverseParams = reverseParams;
t->reverseIndex = reverseIndex;
t->firstRealArg = firstRealArg;
return t;
}

View File

@@ -23,6 +23,7 @@
// llvm
#include "../ir/irtype.h"
namespace llvm { class Type; }
struct Scope;
struct Identifier;
@@ -504,11 +505,14 @@ struct TypeFunction : TypeNext
bool retInPtr;
bool usesThis;
bool usesNest;
// when the last arg is a struct and passed in EAX, this holds its real type
const llvm::Type* structInregArg;
unsigned retAttrs;
unsigned thisAttrs; // also used for nest
// parameter index in the llvm function that contains the first not-implicit arg
size_t firstRealArg;
bool reverseParams;
size_t reverseIndex;
};
struct TypeDelegate : TypeNext

View File

@@ -2198,12 +2198,6 @@ Statement *IfStatement::semantic(Scope *sc)
condition = condition->semantic(scd);
}
// LDC
else if (ident == Id::allow_inline)
{
sc->func->allowInlining = true;
}
else
scd = sc->push();
ifbody = ifbody->semantic(scd);
@@ -2478,6 +2472,13 @@ Statement *PragmaStatement::semantic(Scope *sc)
return this;
}
}
// LDC
else if (ident == Id::allow_inline)
{
sc->func->allowInlining = true;
}
else
error("unrecognized pragma(%s)", ident->toChars());

View File

@@ -3013,7 +3013,10 @@ TemplateInstance::TemplateInstance(Loc loc, Identifier *ident)
this->havetempdecl = 0;
this->isnested = NULL;
this->errors = 0;
// LDC
this->tinst = NULL;
this->tmodule = NULL;
}
/*****************
@@ -3041,7 +3044,10 @@ TemplateInstance::TemplateInstance(Loc loc, TemplateDeclaration *td, Objects *ti
this->havetempdecl = 1;
this->isnested = NULL;
this->errors = 0;
// LDC
this->tinst = NULL;
this->tmodule = NULL;
assert((size_t)tempdecl->scope > 0x10000);
}
@@ -3112,6 +3118,13 @@ void TemplateInstance::semantic(Scope *sc)
// get the enclosing template instance from the scope tinst
tinst = sc->tinst;
// get the module of the outermost enclosing instantiation
if (tinst)
tmodule = tinst->tmodule;
else
tmodule = sc->module;
//printf("%s in %s\n", toChars(), tmodule->toChars());
#if LOG
printf("\tdo semantic\n");
#endif

View File

@@ -322,6 +322,7 @@ struct TemplateInstance : ScopeDsymbol
// LDC
TemplateInstance *tinst; // enclosing template instance
Module* tmodule; // module from outermost enclosing template instantiation
void printInstantiationTrace();
};