diff dmd2/mtype.c @ 847:356e65836fb5

Merged DMD 2.021 frontend. Removed generated files from dmd/dmd2 dirs.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Sat, 13 Dec 2008 16:14:37 +0100
parents 43178a913a28
children eb936607f071
line wrap: on
line diff
--- a/dmd2/mtype.c	Sat Dec 13 13:15:31 2008 +0100
+++ b/dmd2/mtype.c	Sat Dec 13 16:14:37 2008 +0100
@@ -2802,7 +2802,7 @@
 
 int TypeAArray::isZeroInit()
 {
-    return 1;
+    return TRUE;
 }
 
 int TypeAArray::checkBoolean()
@@ -3145,7 +3145,10 @@
 
 	    if (!arg1->type->equals(arg2->type))
 		goto Ldistinct;
-	    if (arg1->storageClass != arg2->storageClass)
+	    if ((arg1->storageClass & ~STCscope) != (arg2->storageClass & ~STCscope))
+		inoutmismatch = 1;
+	    // We can add scope, but not subtract it
+	    if (!(arg1->storageClass & STCscope) && (arg2->storageClass & STCscope))
 		inoutmismatch = 1;
 	}
     }
@@ -3650,6 +3653,41 @@
     return next->reliesOnTident();
 }
 
+/***************************
+ * Examine function signature for parameter p and see if
+ * p can 'escape' the scope of the function.
+ */
+
+bool TypeFunction::parameterEscapes(Argument *p)
+{
+
+    /* Scope parameters do not escape.
+     * Allow 'lazy' to imply 'scope' -
+     * lazy parameters can be passed along
+     * as lazy parameters to the next function, but that isn't
+     * escaping.
+     */
+    if (p->storageClass & (STCscope | STClazy))
+	return FALSE;
+
+    if (ispure)
+    {	/* With pure functions, we need only be concerned if p escapes
+	 * via any return statement.
+	 */
+	Type* tret = nextOf()->toBasetype();
+	if (!isref && !tret->hasPointers())
+	{   /* The result has no references, so p could not be escaping
+	     * that way.
+	     */
+	    return FALSE;
+	}
+    }
+
+    /* Assume it escapes in the absence of better information.
+     */
+    return TRUE;
+}
+
 /***************************** TypeDelegate *****************************/
 
 TypeDelegate::TypeDelegate(Type *t)
@@ -4598,6 +4636,12 @@
     {
 	e = defaultInit(loc);
     }
+    else if (ident == Id::stringof)
+    {	char *s = toChars();
+	e = new StringExp(loc, s, strlen(s), 'c');
+	Scope sc;
+	e = e->semantic(&sc);
+    }
     else
     {
 	e = toBasetype()->getProperty(loc, ident);
@@ -6192,10 +6236,15 @@
 	    else if (arg->storageClass & STCauto)
 		buf->writestring("auto ");
 
+	    if (arg->storageClass & STCscope)
+		buf->writestring("scope ");
+
 	    if (arg->storageClass & STCconst)
 		buf->writestring("const ");
 	    if (arg->storageClass & STCinvariant)
 		buf->writestring("invariant ");
+	    if (arg->storageClass & STCshared)
+		buf->writestring("shared ");
 
 	    argbuf.reset();
 	    if (arg->storageClass & STCalias)
@@ -6292,6 +6341,8 @@
 
 void Argument::toDecoBuffer(OutBuffer *buf)
 {
+    if (storageClass & STCscope)
+	buf->writeByte('M');
     switch (storageClass & (STCin | STCout | STCref | STClazy))
     {   case 0:
 	case STCin: