NativeStackTrace.hx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package haxe;
  2. import haxe.CallStack.StackItem;
  3. /**
  4. Do not use manually.
  5. **/
  6. @:dox(hide)
  7. @:noCompletion
  8. class NativeStackTrace {
  9. @:ifFeature('haxe.NativeStackTrace.exceptionStack')
  10. static public inline function saveStack(exception:Any):Void {
  11. }
  12. @:noDebug //Do not mess up the exception stack
  13. static public function callStack():Array<String> {
  14. return untyped __global__.__hxcpp_get_call_stack(true);
  15. }
  16. @:noDebug //Do not mess up the exception stack/
  17. static public function exceptionStack():Array<String> {
  18. return untyped __global__.__hxcpp_get_exception_stack();
  19. }
  20. static public function toHaxe(native:Array<String>, skip:Int = 0):Array<StackItem> {
  21. var stack:Array<String> = native;
  22. var m = new Array<StackItem>();
  23. for (i in 0...stack.length) {
  24. if(skip > i) {
  25. continue;
  26. }
  27. var words = stack[i].split("::");
  28. if (words.length == 0)
  29. m.push(CFunction)
  30. else if (words.length == 2)
  31. m.push(Method(words[0], words[1]));
  32. else if (words.length == 4)
  33. m.push(FilePos(Method(words[0], words[1]), words[2], Std.parseInt(words[3])));
  34. }
  35. return m;
  36. }
  37. }