Mercurial > projects > dil
changeset 516:433d51c18524
Renamed template Cast to TryCast.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Fri, 14 Dec 2007 22:43:44 +0100 |
parents | 7cb97346bc6f |
children | b465c669d70c |
files | trunk/src/dil/Module.d trunk/src/dil/SettingsLoader.d trunk/src/dil/SyntaxTree.d |
diffstat | 3 files changed, 13 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/trunk/src/dil/Module.d Fri Dec 14 20:12:13 2007 +0100 +++ b/trunk/src/dil/Module.d Fri Dec 14 22:43:44 2007 +0100 @@ -49,7 +49,7 @@ if (root.children.length) { // moduleDecl will be null if first node can't be cast to ModuleDeclaration. - this.moduleDecl = Cast!(ModuleDeclaration)(root.children[0]); + this.moduleDecl = TryCast!(ModuleDeclaration)(root.children[0]); if (moduleDecl) { this.setFQN(moduleDecl.getFQN());
--- a/trunk/src/dil/SettingsLoader.d Fri Dec 14 20:12:13 2007 +0100 +++ b/trunk/src/dil/SettingsLoader.d Fri Dec 14 22:43:44 2007 +0100 @@ -25,7 +25,7 @@ foreach (decl; modul.root.children) { - auto v = Cast!(VariableDeclaration)(decl); + auto v = TryCast!(VariableDeclaration)(decl); if (v is null) continue; @@ -37,29 +37,29 @@ switch (variableName) { case "langfile": - if (auto val = Cast!(StringExpression)(e)) + if (auto val = TryCast!(StringExpression)(e)) GlobalSettings.langFile = val.getString(); break; case "import_paths": - if (auto array = Cast!(ArrayInitializer)(e)) + if (auto array = TryCast!(ArrayInitializer)(e)) { foreach (value; array.values) - if (auto str = Cast!(StringExpression)(value)) + if (auto str = TryCast!(StringExpression)(value)) GlobalSettings.importPaths ~= str.getString(); } else throw new Exception("import_paths variable is set to "~e.classinfo.name~" instead of an ArrayInitializer."); break; case "lexer_error": - if (auto val = Cast!(StringExpression)(e)) + if (auto val = TryCast!(StringExpression)(e)) GlobalSettings.lexerErrorFormat = val.getString(); break; case "parser_error": - if (auto val = Cast!(StringExpression)(e)) + if (auto val = TryCast!(StringExpression)(e)) GlobalSettings.parserErrorFormat = val.getString(); break; case "semantic_error": - if (auto val = Cast!(StringExpression)(e)) + if (auto val = TryCast!(StringExpression)(e)) GlobalSettings.semanticErrorFormat = val.getString(); break; default: @@ -77,7 +77,7 @@ char[][] messages; foreach (decl; modul.root.children) { - auto v = Cast!(VariableDeclaration)(decl); + auto v = TryCast!(VariableDeclaration)(decl); if (v is null) continue; @@ -89,11 +89,11 @@ switch (variableName) { case "messages": - if (auto array = Cast!(ArrayInitializer)(e)) + if (auto array = TryCast!(ArrayInitializer)(e)) { foreach (value; array.values) { - if (auto str = Cast!(StringExpression)(value)) + if (auto str = TryCast!(StringExpression)(value)) messages ~= str.getString(); } } @@ -101,7 +101,7 @@ throw new Exception("messages variable is set to "~e.classinfo.name~" instead of an ArrayInitializer."); break; case "lang_code": - if (auto str = Cast!(StringExpression)(e)) + if (auto str = TryCast!(StringExpression)(e)) GlobalSettings.langCode = str.getString(); break; default:
--- a/trunk/src/dil/SyntaxTree.d Fri Dec 14 20:12:13 2007 +0100 +++ b/trunk/src/dil/SyntaxTree.d Fri Dec 14 22:43:44 2007 +0100 @@ -220,7 +220,7 @@ /// This string is mixed into the constructor of a class that inherits from Node. const string set_kind = `this.kind = mixin("NodeKind." ~ typeof(this).stringof);`; -Class Cast(Class)(Node n) +Class TryCast(Class)(Node n) { assert(n !is null); if (n.kind == mixin("NodeKind." ~ typeof(Class).stringof))