Ver código fonte

Allow nullable class name for `StackItem.Method(className, method)` (#8647)

* provide at least method name for callstack

* display `null` module as `<unknown>`
Aleksandr Kuzmenko 6 anos atrás
pai
commit
5067fbb617
2 arquivos alterados com 6 adições e 6 exclusões
  1. 4 4
      std/haxe/CallStack.hx
  2. 2 2
      std/php/_std/haxe/CallStack.hx

+ 4 - 4
std/haxe/CallStack.hx

@@ -29,7 +29,7 @@ enum StackItem {
 	CFunction;
 	Module(m:String);
 	FilePos(s:Null<StackItem>, file:String, line:Int, ?column:Null<Int>);
-	Method(classname:String, method:String);
+	Method(classname:Null<String>, method:String);
 	LocalFunction(?v:Int);
 }
 
@@ -137,7 +137,7 @@ class CallStack {
 		infos.pop();
 		infos.reverse();
 		for (elem in infos)
-			stack.push(FilePos(null, elem._1, elem._2));
+			stack.push(FilePos(Method(null, elem._3), elem._1, elem._2));
 		return stack;
 		#elseif lua
 		var stack = [];
@@ -232,7 +232,7 @@ class CallStack {
 			var infos = python.lib.Traceback.extract_tb(exc._3);
 			infos.reverse();
 			for (elem in infos)
-				stack.push(FilePos(null, elem._1, elem._2));
+				stack.push(FilePos(Method(null, elem._3), elem._1, elem._2));
 		}
 		return stack;
 		#elseif js
@@ -278,7 +278,7 @@ class CallStack {
 				if (s != null)
 					b.add(")");
 			case Method(cname, meth):
-				b.add(cname);
+				b.add(cname == null ? "<unknown>" : cname);
 				b.add(".");
 				b.add(meth);
 			case LocalFunction(n):

+ 2 - 2
std/php/_std/haxe/CallStack.hx

@@ -33,7 +33,7 @@ enum StackItem {
 	CFunction;
 	Module(m:String);
 	FilePos(s:Null<StackItem>, file:String, line:Int, ?column:Null<Int>);
-	Method(classname:String, method:String);
+	Method(classname:Null<String>, method:String);
 	LocalFunction(?v:Int);
 }
 
@@ -94,7 +94,7 @@ class CallStack {
 				if (s != null)
 					b.add(")");
 			case Method(cname, meth):
-				b.add(cname);
+				b.add(cname == null ? "<unknown>" : cname);
 				b.add(".");
 				b.add(meth);
 			case LocalFunction(n):