diff dmd/FileInitExp.d @ 23:460959608115

Branch merge.
author Robert Clipsham <robert@octarineparrot.com>
date Mon, 12 Apr 2010 17:00:08 +0100
parents 427f8aa74d28 ddae60498573
children 8c2c7b7579f8
line wrap: on
line diff
--- a/dmd/FileInitExp.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/FileInitExp.d	Mon Apr 12 17:00:08 2010 +0100
@@ -4,23 +4,31 @@
 import dmd.Loc;
 import dmd.Scope;
 import dmd.DefaultInitExp;
+import dmd.StringExp;
 import dmd.TOK;
+import dmd.Util;
+import dmd.Type;
 
-class FileInitExp : DefaultInitExp
-{
-	this(Loc loc)
+class FileInitExp : DefaultInitExp
+{
+	this(Loc loc)
+	{
+		super(loc, TOK.TOKfile, this.sizeof);
+	}
+
+	Expression semantic(Scope sc)
 	{
-		super(loc, TOKfile, FileInitExp.sizeof);
-	}
-
-	Expression semantic(Scope sc)
-	{
-		assert(false);
-	}
-
-	Expression resolve(Loc loc, Scope sc)
-	{
-		assert(false);
-	}
-}
-
+		type = Type.tchar.invariantOf().arrayOf();
+		return this;
+	}
+
+	Expression resolve(Loc loc, Scope sc)
+	{
+		//printf("FileInitExp::resolve() %s\n", toChars());
+		string s = loc.filename ? loc.filename : sc.module_.ident.toChars();
+		Expression e = new StringExp(loc, s);
+		e = e.semantic(sc);
+		e = e.castTo(sc, type);
+		return e;
+	}
+}