Переглянути джерело

Merge pull request #3737 from player-03/development

Added support for conditionals to getValue()
Simon Krajewski 10 роки тому
батько
коміт
6359c685be
1 змінених файлів з 7 додано та 0 видалено
  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) {