X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/0a4d6bce78c5cd6fa45e62365bdf22e9edde61bf..925360811f44b121001797130ca89fc777072ae7:/libcycript.cy?ds=sidebyside diff --git a/libcycript.cy b/libcycript.cy index 45caaf2..8240a44 100644 --- a/libcycript.cy +++ b/libcycript.cy @@ -19,10 +19,6 @@ **/ /* }}} */ -var process = { - env: {}, -}; - (function() { this.typeid = function(object) { @@ -188,6 +184,26 @@ Java.on('setup', function() { this.put(key, value); }, }); + + $cy_set(java.lang.Throwable.prototype, { + toCYON: function() { + var message = this.getMessage(); + if (message == null) + message = ''; + else + message = message.toCYON(); + + let stack = this.getStackTrace(); + if (stack.length == 0) + stack = ''; + else { + stack = stack.join('\n '); + stack = ` /*\n ${stack} */`; + } + + return `new ${this.constructor.class.getName()}(${message})${stack}`; + }, + }); }); } @@ -428,6 +444,8 @@ process.binding = function(name) { return binding; }; +process.env = {}; + let environ = *(typedef char ***)(dlsym(RTLD_DEFAULT, "environ")); for (let i = 0; environ[i] != null; ++i) { let assign = environ[i];