2
0
Эх сурвалжийг харах

prevent stack overflow with recursive enums toString()

Nicolas Cannasse 11 жил өмнө
parent
commit
39551916e9
1 өөрчлөгдсөн 9 нэмэгдсэн , 2 устгасан
  1. 9 2
      std/flash/Boot.hx

+ 9 - 2
std/flash/Boot.hx

@@ -79,12 +79,19 @@ class Boot extends flash.display.MovieClip {
 		throw "assert";
 	}
 
+	static var IN_E = 0;
 	public static function enum_to_string( e : { tag : String, params : Array<Dynamic> } ) {
 		if( e.params == null )
 			return e.tag;
 		var pstr = [];
-		for( p in e.params )
-			pstr.push(__string_rec(p,""));
+		if( IN_E > 15 ) {
+			pstr.push("...");
+		} else {
+			IN_E++;
+			for( p in e.params )
+				pstr.push(__string_rec(p, ""));
+			IN_E--;
+		}
 		return e.tag+"("+pstr.join(",")+")";
 	}