(function() {
+this.typeid = function(object) {
+ return object.$cyt;
+};
+
let $cy_set = function(object, properties) {
for (const name in properties)
Object.defineProperty(object, name, {
});
};
+$cy_set(Boolean.prototype, {
+ toCYON: function() {
+ return `new Boolean(${this.toString()})`;
+ },
+});
+
$cy_set(Date.prototype, {
toCYON: function() {
return `new ${this.constructor.name}(${this.toUTCString().toCYON()})`;
$cy_set(Error.prototype, {
toCYON: function() {
- let stack = this.stack.split('\n');
- if (stack.slice(-1)[0] == "global code")
- stack = stack.slice(0, -1);
- for (let i = 0; i != stack.length; ++i)
- stack[i] = '\n ' + stack[i];
- return `new ${this.constructor.name}(${this.message.toCYON()}) /*${stack.join('')} */`;
+ let stack = this.stack;
+ if (typeof stack == 'undefined')
+ stack = '';
+ else {
+ stack = stack.split('\n');
+ if (stack.slice(-1)[0] == "global code")
+ stack = stack.slice(0, -1);
+ for (let i = 0; i != stack.length; ++i)
+ stack[i] = '\n ' + stack[i];
+ stack = stack.join('');
+ stack = ` /*${stack} */`;
+ }
+ return `new ${this.constructor.name}(${this.message.toCYON()})${stack}`;
+ },
+});
+
+$cy_set(Number.prototype, {
+ toCYON: function() {
+ if ("$cyt" in this)
+ return `${this.$cyt.toCYON()}(${this.toString()})`;
+ return `new Number(${this.toString()})`;
+ },
+});
+
+$cy_set(RegExp.prototype, {
+ toCYON: function() {
+ return this.toString();
},
});