haxe/src/haxe/CallStack.cs
// Generated by Haxe 4.3.7
#pragma warning disable 109, 114, 219, 429, 168, 162
namespace haxe {
public class StackItem : global::haxe.lang.Enum {
protected StackItem(int index) : base(index) {
}
public static readonly global::haxe.StackItem CFunction = new global::haxe.StackItem_CFunction();
public static global::haxe.StackItem Module(string m) {
return new global::haxe.StackItem_Module(m);
}
public static global::haxe.StackItem FilePos(global::haxe.StackItem s, string file, int line, global::haxe.lang.Null<int> column) {
return new global::haxe.StackItem_FilePos(s, file, line, column);
}
public static global::haxe.StackItem Method(string classname, string method) {
return new global::haxe.StackItem_Method(classname, method);
}
public static global::haxe.StackItem LocalFunction(global::haxe.lang.Null<int> v) {
return new global::haxe.StackItem_LocalFunction(v);
}
protected static readonly string[] __hx_constructs = new string[]{"CFunction", "Module", "FilePos", "Method", "LocalFunction"};
}
}
#pragma warning disable 109, 114, 219, 429, 168, 162
namespace haxe {
public sealed class StackItem_CFunction : global::haxe.StackItem {
public StackItem_CFunction() : base(0) {
}
public override string getTag() {
return "CFunction";
}
}
}
#pragma warning disable 109, 114, 219, 429, 168, 162
namespace haxe {
public sealed class StackItem_Module : global::haxe.StackItem {
public StackItem_Module(string m) : base(1) {
this.m = m;
}
public override global::Array<object> getParams() {
return new global::Array<object>(new object[]{this.m});
}
public override string getTag() {
return "Module";
}
public override int GetHashCode() {
unchecked {
return global::haxe.lang.Enum.paramsGetHashCode(1, new object[]{this.m});
}
}
public override bool Equals(object other) {
if (global::System.Object.ReferenceEquals(((object) (this) ), ((object) (other) ))) {
return true;
}
global::haxe.StackItem_Module en = ( other as global::haxe.StackItem_Module );
if (( en == null )) {
return false;
}
if ( ! (global::Type.enumEq<object>(((object) (this.m) ), ((object) (en.m) ))) ) {
return false;
}
return true;
}
public override string toString() {
return global::haxe.lang.Enum.paramsToString("Module", new object[]{this.m});
}
public readonly string m;
}
}
#pragma warning disable 109, 114, 219, 429, 168, 162
namespace haxe {
public sealed class StackItem_FilePos : global::haxe.StackItem {
public StackItem_FilePos(global::haxe.StackItem s, string file, int line, global::haxe.lang.Null<int> column) : base(2) {
this.s = s;
this.file = file;
this.line = line;
this.column = column;
}
public override global::Array<object> getParams() {
return new global::Array<object>(new object[]{this.s, this.file, this.line, (this.column).toDynamic()});
}
public override string getTag() {
return "FilePos";
}
public override int GetHashCode() {
unchecked {
return global::haxe.lang.Enum.paramsGetHashCode(2, new object[]{this.s, this.file, this.line, (this.column).toDynamic()});
}
}
public override bool Equals(object other) {
if (global::System.Object.ReferenceEquals(((object) (this) ), ((object) (other) ))) {
return true;
}
global::haxe.StackItem_FilePos en = ( other as global::haxe.StackItem_FilePos );
if (( en == null )) {
return false;
}
if ( ! (global::Type.enumEq<object>(((object) (this.s) ), ((object) (en.s) ))) ) {
return false;
}
if ( ! (global::Type.enumEq<object>(((object) (this.file) ), ((object) (en.file) ))) ) {
return false;
}
if ( ! (global::Type.enumEq<object>(((object) (this.line) ), ((object) (en.line) ))) ) {
return false;
}
if ( ! (global::Type.enumEq<object>((this.column).toDynamic(), (en.column).toDynamic())) ) {
return false;
}
return true;
}
public override string toString() {
return global::haxe.lang.Enum.paramsToString("FilePos", new object[]{this.s, this.file, this.line, (this.column).toDynamic()});
}
public readonly global::haxe.StackItem s;
public readonly string file;
public readonly int line;
public readonly global::haxe.lang.Null<int> column;
}
}
#pragma warning disable 109, 114, 219, 429, 168, 162
namespace haxe {
public sealed class StackItem_Method : global::haxe.StackItem {
public StackItem_Method(string classname, string method) : base(3) {
this.classname = classname;
this.method = method;
}
public override global::Array<object> getParams() {
return new global::Array<object>(new object[]{this.classname, this.method});
}
public override string getTag() {
return "Method";
}
public override int GetHashCode() {
unchecked {
return global::haxe.lang.Enum.paramsGetHashCode(3, new object[]{this.classname, this.method});
}
}
public override bool Equals(object other) {
if (global::System.Object.ReferenceEquals(((object) (this) ), ((object) (other) ))) {
return true;
}
global::haxe.StackItem_Method en = ( other as global::haxe.StackItem_Method );
if (( en == null )) {
return false;
}
if ( ! (global::Type.enumEq<object>(((object) (this.classname) ), ((object) (en.classname) ))) ) {
return false;
}
if ( ! (global::Type.enumEq<object>(((object) (this.method) ), ((object) (en.method) ))) ) {
return false;
}
return true;
}
public override string toString() {
return global::haxe.lang.Enum.paramsToString("Method", new object[]{this.classname, this.method});
}
public readonly string classname;
public readonly string method;
}
}
#pragma warning disable 109, 114, 219, 429, 168, 162
namespace haxe {
public sealed class StackItem_LocalFunction : global::haxe.StackItem {
public StackItem_LocalFunction(global::haxe.lang.Null<int> v) : base(4) {
this.v = v;
}
public override global::Array<object> getParams() {
return new global::Array<object>(new object[]{(this.v).toDynamic()});
}
public override string getTag() {
return "LocalFunction";
}
public override int GetHashCode() {
unchecked {
return global::haxe.lang.Enum.paramsGetHashCode(4, new object[]{(this.v).toDynamic()});
}
}
public override bool Equals(object other) {
if (global::System.Object.ReferenceEquals(((object) (this) ), ((object) (other) ))) {
return true;
}
global::haxe.StackItem_LocalFunction en = ( other as global::haxe.StackItem_LocalFunction );
if (( en == null )) {
return false;
}
if ( ! (global::Type.enumEq<object>((this.v).toDynamic(), (en.v).toDynamic())) ) {
return false;
}
return true;
}
public override string toString() {
return global::haxe.lang.Enum.paramsToString("LocalFunction", new object[]{(this.v).toDynamic()});
}
public readonly global::haxe.lang.Null<int> v;
}
}
#pragma warning disable 109, 114, 219, 429, 168, 162
namespace haxe._CallStack {
public sealed class CallStack_Impl_ {
public static int get_length(global::Array<object> this1) {
return this1.length;
}
public static global::Array<object> callStack() {
return global::haxe.NativeStackTrace.toHaxe(global::haxe.NativeStackTrace.callStack(), default(global::haxe.lang.Null<int>));
}
public static global::Array<object> exceptionStack(global::haxe.lang.Null<bool> fullStack) {
bool fullStack1 = ( ( ! (fullStack.hasValue) ) ? (false) : ((fullStack).@value) );
global::Array<object> eStack = global::haxe.NativeStackTrace.toHaxe(global::haxe.NativeStackTrace.exceptionStack(), default(global::haxe.lang.Null<int>));
return ((global::Array<object>) (( (fullStack1) ? (eStack) : (global::haxe._CallStack.CallStack_Impl_.subtract(eStack, global::haxe._CallStack.CallStack_Impl_.callStack())) )) );
}
public static string toString(global::Array<object> stack) {
global::StringBuf b = new global::StringBuf();
{
int _g = 0;
global::Array<object> _g1 = ((global::Array<object>) (stack) );
while (( _g < _g1.length )) {
global::haxe.StackItem s = ((global::haxe.StackItem) (_g1[_g]) );
++ _g;
b.@add<string>(((string) ("\nCalled from ") ));
global::haxe._CallStack.CallStack_Impl_.itemToString(b, s);
}
}
return b.toString();
}
public static global::Array<object> subtract(global::Array<object> this1, global::Array<object> stack) {
unchecked {
int startIndex = -1;
int i = -1;
while (( ++ i < this1.length )) {
{
int _g = 0;
int _g1 = ((global::Array<object>) (stack) ).length;
while (( _g < _g1 )) {
int j = _g++;
if (global::haxe._CallStack.CallStack_Impl_.equalItems(((global::haxe.StackItem) (this1[i]) ), ((global::haxe.StackItem) (((global::Array<object>) (stack) )[j]) ))) {
if (( startIndex < 0 )) {
startIndex = i;
}
++ i;
if (( i >= this1.length )) {
break;
}
}
else {
startIndex = -1;
}
}
}
if (( startIndex >= 0 )) {
break;
}
}
if (( startIndex >= 0 )) {
return this1.slice(0, new global::haxe.lang.Null<int>(startIndex, true));
}
else {
return this1;
}
}
}
public static global::Array<object> copy(global::Array<object> this1) {
return this1.copy();
}
public static global::haxe.StackItem @get(global::Array<object> this1, int index) {
return ((global::haxe.StackItem) (this1[index]) );
}
public static global::Array<object> asArray(global::Array<object> this1) {
return this1;
}
public static bool equalItems(global::haxe.StackItem item1, global::haxe.StackItem item2) {
unchecked {
if (( item1 == null )) {
if (( item2 == null )) {
return true;
}
else {
return false;
}
}
else {
switch (item1._hx_index) {
case 0:
{
if (( item2 == null )) {
return false;
}
else if (( item2._hx_index == 0 )) {
return true;
}
else {
return false;
}
}
case 1:
{
if (( item2 == null )) {
return false;
}
else if (( item2._hx_index == 1 )) {
string m2 = ( item2 as global::haxe.StackItem_Module ).m;
string m1 = ( item1 as global::haxe.StackItem_Module ).m;
return ( m1 == m2 );
}
else {
return false;
}
}
case 2:
{
if (( item2 == null )) {
return false;
}
else if (( item2._hx_index == 2 )) {
global::haxe.StackItem item21 = ( item2 as global::haxe.StackItem_FilePos ).s;
string file2 = ( item2 as global::haxe.StackItem_FilePos ).file;
int line2 = ( item2 as global::haxe.StackItem_FilePos ).line;
global::haxe.lang.Null<int> col2 = ( item2 as global::haxe.StackItem_FilePos ).column;
global::haxe.lang.Null<int> col1 = ( item1 as global::haxe.StackItem_FilePos ).column;
int line1 = ( item1 as global::haxe.StackItem_FilePos ).line;
string file1 = ( item1 as global::haxe.StackItem_FilePos ).file;
global::haxe.StackItem item11 = ( item1 as global::haxe.StackItem_FilePos ).s;
if (( ( ( file1 == file2 ) && ( line1 == line2 ) ) && global::haxe.lang.Runtime.eq((col1).toDynamic(), (col2).toDynamic()) )) {
return global::haxe._CallStack.CallStack_Impl_.equalItems(item11, item21);
}
else {
return false;
}
}
else {
return false;
}
}
case 3:
{
if (( item2 == null )) {
return false;
}
else if (( item2._hx_index == 3 )) {
string class2 = ( item2 as global::haxe.StackItem_Method ).classname;
string method2 = ( item2 as global::haxe.StackItem_Method ).method;
string method1 = ( item1 as global::haxe.StackItem_Method ).method;
string class1 = ( item1 as global::haxe.StackItem_Method ).classname;
if (( class1 == class2 )) {
return ( method1 == method2 );
}
else {
return false;
}
}
else {
return false;
}
}
case 4:
{
if (( item2 == null )) {
return false;
}
else if (( item2._hx_index == 4 )) {
global::haxe.lang.Null<int> v2 = ( item2 as global::haxe.StackItem_LocalFunction ).v;
global::haxe.lang.Null<int> v1 = ( item1 as global::haxe.StackItem_LocalFunction ).v;
return global::haxe.lang.Runtime.eq((v1).toDynamic(), (v2).toDynamic());
}
else {
return false;
}
}
}
}
return default(bool);
}
}
public static string exceptionToString(global::haxe.Exception e) {
if (( e.get_previous() == null )) {
string tmp = global::haxe.lang.Runtime.concat("Exception: ", e.toString());
global::Array<object> tmp1 = e.get_stack();
return global::haxe.lang.Runtime.concat(tmp, (( (( tmp1 == null )) ? ("null") : (global::haxe._CallStack.CallStack_Impl_.toString(tmp1)) )));
}
string result = "";
global::haxe.Exception e1 = e;
global::haxe.Exception prev = null;
while (( e1 != null )) {
if (( prev == null )) {
string result1 = global::haxe.lang.Runtime.concat("Exception: ", e1.get_message());
global::Array<object> tmp2 = e1.get_stack();
result = global::haxe.lang.Runtime.concat(global::haxe.lang.Runtime.concat(result1, (( (( tmp2 == null )) ? ("null") : (global::haxe._CallStack.CallStack_Impl_.toString(tmp2)) ))), result);
}
else {
global::Array<object> prevStack = global::haxe._CallStack.CallStack_Impl_.subtract(e1.get_stack(), prev.get_stack());
result = global::haxe.lang.Runtime.concat(global::haxe.lang.Runtime.concat(global::haxe.lang.Runtime.concat(global::haxe.lang.Runtime.concat("Exception: ", e1.get_message()), (( (( prevStack == null )) ? ("null") : (global::haxe._CallStack.CallStack_Impl_.toString(prevStack)) ))), "\n\nNext "), result);
}
prev = e1;
e1 = e1.get_previous();
}
return result;
}
public static void itemToString(global::StringBuf b, global::haxe.StackItem s) {
unchecked {
switch (s._hx_index) {
case 0:
{
b.@add<string>(((string) ("a C function") ));
break;
}
case 1:
{
string m = ( s as global::haxe.StackItem_Module ).m;
{
b.@add<string>(((string) ("module ") ));
b.@add<string>(((string) (m) ));
}
break;
}
case 2:
{
global::haxe.StackItem s1 = ( s as global::haxe.StackItem_FilePos ).s;
string file = ( s as global::haxe.StackItem_FilePos ).file;
int line = ( s as global::haxe.StackItem_FilePos ).line;
global::haxe.lang.Null<int> col = ( s as global::haxe.StackItem_FilePos ).column;
{
if (( s1 != null )) {
global::haxe._CallStack.CallStack_Impl_.itemToString(b, s1);
b.@add<string>(((string) (" (") ));
}
b.@add<string>(((string) (file) ));
b.@add<string>(((string) (" line ") ));
b.@add<int>(((int) (line) ));
if (col.hasValue) {
b.@add<string>(((string) (" column ") ));
b.@add<object>((col).toDynamic());
}
if (( s1 != null )) {
b.@add<string>(((string) (")") ));
}
}
break;
}
case 3:
{
string cname = ( s as global::haxe.StackItem_Method ).classname;
string meth = ( s as global::haxe.StackItem_Method ).method;
{
b.@add<string>(((string) (( (( cname == null )) ? ("<unknown>") : (cname) )) ));
b.@add<string>(((string) (".") ));
b.@add<string>(((string) (meth) ));
}
break;
}
case 4:
{
global::haxe.lang.Null<int> n = ( s as global::haxe.StackItem_LocalFunction ).v;
{
b.@add<string>(((string) ("local function #") ));
b.@add<object>((n).toDynamic());
}
break;
}
}
}
}
}
}