changeset 953:5fa3e0ea06e9

Merged a bunch recent dmd v1 frontend changes into the dmd v2 tree.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Fri, 13 Feb 2009 22:20:30 +0100
parents 29da57670853
children e048e36bc155
files dmd2/dsymbol.c dmd2/dsymbol.h dmd2/mtype.c dmd2/mtype.h dmd2/statement.c dmd2/template.c dmd2/template.h
diffstat 7 files changed, 58 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/dmd2/dsymbol.c	Thu Feb 12 18:39:14 2009 +0100
+++ b/dmd2/dsymbol.c	Fri Feb 13 22:20:30 2009 +0100
@@ -560,6 +560,34 @@
     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;
+}
+
 /*************************************
  */
 
--- a/dmd2/dsymbol.h	Thu Feb 12 18:39:14 2009 +0100
+++ b/dmd2/dsymbol.h	Fri Feb 13 22:20:30 2009 +0100
@@ -121,6 +121,7 @@
     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();
--- a/dmd2/mtype.c	Thu Feb 12 18:39:14 2009 +0100
+++ b/dmd2/mtype.c	Fri Feb 13 22:20:30 2009 +0100
@@ -3074,10 +3074,11 @@
     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 @@
     t->retAttrs = retAttrs;
     t->thisAttrs = thisAttrs;
     t->reverseParams = reverseParams;
-    t->reverseIndex = reverseIndex;
+    t->firstRealArg = firstRealArg;
     return t;
 }
 
--- a/dmd2/mtype.h	Thu Feb 12 18:39:14 2009 +0100
+++ b/dmd2/mtype.h	Fri Feb 13 22:20:30 2009 +0100
@@ -23,6 +23,7 @@
 
 // llvm
 #include "../ir/irtype.h"
+namespace llvm { class Type; }
 
 struct Scope;
 struct Identifier;
@@ -504,11 +505,14 @@
     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
--- a/dmd2/statement.c	Thu Feb 12 18:39:14 2009 +0100
+++ b/dmd2/statement.c	Fri Feb 13 22:20:30 2009 +0100
@@ -2198,12 +2198,6 @@
 	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 @@
 	    return this;
 	}
     }
+
+    // LDC
+    else if (ident == Id::allow_inline)
+    {
+        sc->func->allowInlining = true;
+    }
+
     else
         error("unrecognized pragma(%s)", ident->toChars());
 
--- a/dmd2/template.c	Thu Feb 12 18:39:14 2009 +0100
+++ b/dmd2/template.c	Fri Feb 13 22:20:30 2009 +0100
@@ -3013,7 +3013,10 @@
     this->havetempdecl = 0;
     this->isnested = NULL;
     this->errors = 0;
+
+    // LDC
     this->tinst = NULL;
+    this->tmodule = NULL;
 }
 
 /*****************
@@ -3041,7 +3044,10 @@
     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 @@
     // 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
--- a/dmd2/template.h	Thu Feb 12 18:39:14 2009 +0100
+++ b/dmd2/template.h	Fri Feb 13 22:20:30 2009 +0100
@@ -322,6 +322,7 @@
 
     // LDC
     TemplateInstance *tinst; // enclosing template instance
+    Module* tmodule; // module from outermost enclosing template instantiation
     void printInstantiationTrace();
 };