DeNA JSX (AltJS): デバッグコンソールにトレース出力

SnippetConsole.jsx

import "console.jsx";

class SnippetConsole {
    var recentMessage : string;
    function constructor() {
        console.log("constructor");
    }
    function log(message:string):void {
        console.log(message);
        console.log(3);
        this.recentMessage = message;
    }
}

class _Main {
    static function main(args : string[]) : void {
        log "hello world!";
        
        var snippet = new SnippetConsole();
        snippet.log("hello world");
    }
}

変換コマンド

$ jsx --executable web --minify --output release/js/snippet-console.js jsx/snippet-console.jsx

snippet-console.js

var JSX={};(function(a){function d(b,e){var a=function(){};a.prototype=e.prototype;var c=new a;for(var d in b){b[d].prototype=c}}function v(c,b){for(var a in b.prototype)if(b.prototype.hasOwnProperty(a))c.prototype[a]=b.prototype[a]}function u(a,b,d){function c(a,b,c){delete a[b];a[b]=c;return c}Object.defineProperty(a,b,{get:function(){return c(a,b,d())},set:function(d){c(a,b,d)},enumerable:true,configurable:true})}function t(a,b,c){return a[b]=a[b]/c|0}var q=parseInt;var h=parseFloat;function s(a){return a!==a}var j=isFinite;var k=encodeURIComponent;var l=decodeURIComponent;var m=encodeURI;var n=decodeURI;var o=Object.prototype.toString;var p=Object.prototype.hasOwnProperty;function b(){}a.require=function(b){var a=g[b];return a!==undefined?a:null};a.profilerIsRunning=function(){return b.getResults!=null};a.getProfileResults=function(){return(b.getResults||function(){return{}})()};a.postProfileResults=function(a,c){if(b.postResults==null)throw new Error('profiler has not been turned on');return b.postResults(a,c)};a.resetProfileResults=function(){if(b.resetResults==null)throw new Error('profiler has not been turned on');return b.resetResults()};a.DEBUG=true;function r(){};d([r],Error);function f(){this.A='';console.log('constructor')};d([f],Object);f.prototype._=function(a){console.log(a);console.log(3);this.A=a};function e(){};d([e],Object);function i(b){var a;console.log('hello world!');a=new f;a._('hello world')};e.main=i;var g={'jsx/snippet-console.jsx':{_Main:e}};a.runMain=function(c,d){var b=a.require(c);if(!b){throw new ReferenceError('entry point module not found in '+c)}if(!b._Main){throw new ReferenceError('entry point _Main not found in '+c)}if(!b._Main.main){throw new ReferenceError('entry point _Main.main(:string[]):void not found in '+c)}b._Main.main(d)};a.runTests=function(i,c){var g=a.require(i);if(!g)return;var d=g._Test;if(!d)return;if(c.length===0){var h=d.prototype;for(var e in h){if(h[e]instanceof Function&&e.match(/^test¥w*$/)){c.push(e)}}}var b=new d;if(b.beforeClass!=null)b.beforeClass(c);for(var f=0;f<c.length;++f){(function(a){if(a in b){b.run(a,function(){b[a]()})}else{throw new ReferenceError('No such test method: '+a)}}(c[f]))}if(b.afterClass!=null)b.afterClass()};function c(b){window.removeEventListener('load',c);document.removeEventListener('DOMContentLoaded',c);a.runMain('jsx/snippet-console.jsx',[])}window.addEventListener('load',c);document.addEventListener('DOMContentLoaded',c)}(JSX))

出力:

hello world!
constructor
hello world
3