# HG changeset patch # User Anders Johnsen # Date 1216990854 -7200 # Node ID fda35d57847e0002728b7bcc21c1d1a6993774c8 # Parent e799db8d9cb0f8d88c62d02124668657de08f5f7 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. diff -r e799db8d9cb0 -r fda35d57847e ast/Exp.d --- 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 diff -r e799db8d9cb0 -r fda35d57847e basic/LiteralParsing.d --- 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; } diff -r e799db8d9cb0 -r fda35d57847e gen/CodeGen.d --- 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; diff -r e799db8d9cb0 -r fda35d57847e sema/LiteralInterpreter.d --- 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) diff -r e799db8d9cb0 -r fda35d57847e tests/run.d --- 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);