Browse Source

Merge pull request #3737 from player-03/development

Added support for conditionals to getValue()
Simon Krajewski 10 years ago
parent
commit
6359c685be
1 changed files with 7 additions and 0 deletions
  1. 7 0
      std/haxe/macro/ExprTools.hx

+ 7 - 0
std/haxe/macro/ExprTools.hx

@@ -243,6 +243,13 @@ class ExprTools {
 				}
 				obj;
 			case EArrayDecl(el): el.map(getValue);
+			case EIf(econd, eif, eelse) | ETernary(econd, eif, eelse):
+				if (eelse == null) {
+					throw "If statements only have a value if the else clause is defined";
+				} else {
+					var econd:Dynamic = getValue(econd);
+					econd ? getValue(eif) : getValue(eelse);
+				}
 			case EUnop(op, false, e1):
 				var e1:Dynamic = getValue(e1);
 				switch (op) {