changeset 192:fda35d57847e

Fixed String parsing, so that they get created with the right type in AST. Also added so that you can parse options to the test program, that will mirror them to Dang. Eg. ./tests/run --semantic-only will pass --semantic-only to Dang on each run.
author Anders Johnsen <skabet@gmail.com>
date Fri, 25 Jul 2008 15:00:54 +0200
parents e799db8d9cb0
children 658178183018
files ast/Exp.d basic/LiteralParsing.d gen/CodeGen.d sema/LiteralInterpreter.d tests/run.d
diffstat 5 files changed, 22 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/ast/Exp.d	Fri Jul 25 14:44:50 2008 +0200
+++ b/ast/Exp.d	Fri Jul 25 15:00:54 2008 +0200
@@ -532,10 +532,21 @@
         this.str = str;
     }
 
-    override DType type() { return DType.Char.getAsStaticArray(data.length); }
+    override DType type() 
+    {
+        switch (data.type)
+        {
+            case StringType.Char:
+                return DType.Char.getAsStaticArray(data.data.length); 
+            case StringType.WChar:
+                return DType.WChar.getAsStaticArray(data.data.length/2); 
+            case StringType.DChar:
+                return DType.DChar.getAsStaticArray(data.data.length/4); 
+        }
+    }
 
     char[] str;
-    ubyte[] data;
+    String data;
 }
 
 class NewExp : Exp
--- a/basic/LiteralParsing.d	Fri Jul 25 14:44:50 2008 +0200
+++ b/basic/LiteralParsing.d	Fri Jul 25 15:00:54 2008 +0200
@@ -299,7 +299,7 @@
 
     }
 
-    printString(str, strBuf);
+//    printString(str, strBuf);
 
     return strBuf;
 }
--- a/gen/CodeGen.d	Fri Jul 25 14:44:50 2008 +0200
+++ b/gen/CodeGen.d	Fri Jul 25 15:00:54 2008 +0200
@@ -716,7 +716,7 @@
                 return LValue(v);
             case ExpType.StringExp:
                 auto stringExp = cast(StringExp)exp;
-                char[] data = cast(char[])stringExp.data;
+                char[] data = cast(char[])stringExp.data.data;
                 auto string_constant = ConstantArray.GetString(data, true);
                 auto gv = m.addGlobal(string_constant, "string");
                 gv.linkage = Linkage.Internal;
--- a/sema/LiteralInterpreter.d	Fri Jul 25 14:44:50 2008 +0200
+++ b/sema/LiteralInterpreter.d	Fri Jul 25 15:00:54 2008 +0200
@@ -21,7 +21,7 @@
     void visitStringExp(StringExp exp)
     {
         auto str = parseString(exp.str, exp.loc, messages);
-        exp.data = str.data;
+        exp.data = str;
     }
 
     void visitIntegerLit(IntegerLit exp)
--- a/tests/run.d	Fri Jul 25 14:44:50 2008 +0200
+++ b/tests/run.d	Fri Jul 25 15:00:54 2008 +0200
@@ -15,7 +15,7 @@
 char[] test_folder = "tests";
 char[] valid_filenames = r"^[^.].*";
 bool print_expected = false;
-
+char[][] options;
 // the tests can be sorted by one of the following functions
 bool nameSort    (FilePath a, FilePath b) { return a.name     < b.name;     }
 bool pathSort    (FilePath a, FilePath b) { return a.toString < b.toString; }
@@ -34,6 +34,9 @@
 
 void main(char[][] args)
 {
+    foreach (arg ; args[1..$])
+        options ~= arg;
+
     scope scan = new FileScan;
 //    scope regex = new Regex(valid_filenames); // DMD FAILS!! ?? 
     // Return true for files/folders to include
@@ -124,7 +127,8 @@
 
     if (compile)
     {
-        auto process = new Process(compiler, "--gen-llvm", p.toString());
+        auto o = compiler ~ options ~ p.toString;
+        auto process = new Process(o);
         process.execute();
         auto result = process.wait();
         return resultOf(p, result.status, fail);