Skip to content

Instantly share code, notes, and snippets.

@munificent
Created August 5, 2015 16:33
Show Gist options
  • Save munificent/bde42b3d02c563fb4a9c to your computer and use it in GitHub Desktop.
Save munificent/bde42b3d02c563fb4a9c to your computer and use it in GitHub Desktop.
Dart->JS output on a simple program
dart_library.library('simple', null, /* Imports */[
"dart_runtime/dart",
'dart/core'
], /* Lazy imports */[
], function(exports, dart, core) {
'use strict';
let dartx = dart.dartx;
class Simple extends core.Object {
Simple(name) {
this.name = name;
}
greet(who) {
return `Greetings ${who}, I'm ${this.name}!`;
}
}
dart.setSignature(Simple, {
constructors: () => ({Simple: [Simple, [core.String]]}),
methods: () => ({greet: [dart.dynamic, [dart.dynamic]]})
});
function main() {
let s = new Simple('Flyn');
core.print(s.greet('Program'));
}
dart.fn(main);
// Exports:
exports.Simple = Simple;
exports.main = main;
});
//# sourceMappingURL=simple.js.map
(function(){var supportsDirectProtoAccess=function(){var z=function(){}
z.prototype={p:{}}
var y=new z()
return y.__proto__&&y.__proto__.p===z.prototype.p}()
function map(a){a=Object.create(null)
a.x=0
delete a.x
return a}var A=map()
var B=map()
var C=map()
var D=map()
var E=map()
var F=map()
var G=map()
var H=map()
var J=map()
var K=map()
var L=map()
var M=map()
var N=map()
var O=map()
var P=map()
var Q=map()
var R=map()
var S=map()
var T=map()
var U=map()
var V=map()
var W=map()
var X=map()
var Y=map()
var Z=map()
function I(){}init()
function setupProgram(a,b){"use strict"
function processStatics(a2,a3){var h=Object.keys(a2)
for(var g=0;g<h.length;g++){var f=h[g]
if(f==="^")continue
var e=a2[f]
var d=f.charCodeAt(0)
var c
if(d===43){w[c]=f.substring(1)
var a0=a2[f]
if(a0>0)a2[c].$reflectable=a0
if(e&&e.length)init.typeInformation[c]=e}else if(d===42){n[c].$defaultValues=e
var a1=a2.$methodsWithOptionalArguments
if(!a1)a2.$methodsWithOptionalArguments=a1={}
a1[f]=c}else if(typeof e==="function"){n[c=f]=e
i.push(f)
init.globalFunctions[f]=e}else if(e.constructor===Array){}else{}}}var z=0
if(!init.libraries)init.libraries=[]
if(!init.mangledNames)init.mangledNames=map()
if(!init.mangledGlobalNames)init.mangledGlobalNames=map()
if(!init.statics)init.statics=map()
if(!init.typeInformation)init.typeInformation=map()
if(!init.globalFunctions)init.globalFunctions=map()
var y=init.libraries
var x=init.mangledNames
var w=init.mangledGlobalNames
var v=Object.prototype.hasOwnProperty
var u=a.length
var t=map()
t.collected=map()
t.pending=map()
t.constructorsList=[]
t.combinedConstructorFunction="function $reflectable(fn){fn.$reflectable=1;return fn};\n"+"var $desc;\n"
for(var s=0;s<u;s++){var r=a[s]
var q=r[0]
var p=r[1]
var o=r[2]
var n=r[3]
var m=r[4]
var l=!!r[5]
var k=m&&m["^"]
if(k instanceof Array)k=k[0]
var j=[]
var i=[]
processStatics(m,t)
y.push([q,p,j,i,o,k,l,n])}}I.a=function(){}
var dart=[["","",,H,{
"^":"",
c:function(a){if(typeof dartPrint=="function"){dartPrint(a)
return}if(typeof console=="object"&&typeof console.log!="undefined"){console.log(a)
return}if(typeof window=="object")return
if(typeof print=="function"){print(a)
return}throw"Unable to print message: "+String(a)}}],["","",,M,{
"^":"",
b:function(){H.c("Greetings Program, I'm Flyn!")}},1]]
setupProgram(dart,0)
var $=I.p
$=null
init.isHunkLoaded=function(a){return!!$dart_deferred_initializers$[a]}
init.deferredInitialized=new Object(null)
init.isHunkInitialized=function(a){return init.deferredInitialized[a]}
init.initializeLoadedHunk=function(a){$dart_deferred_initializers$[a]($globals$,$)
init.deferredInitialized[a]=true}
init.deferredLibraryUris={}
init.deferredLibraryHashes={};(function(a){for(var z=0;z<a.length;){var y=a[z++]
var x=a[z++]
var w=a[z++]
I.$lazy(y,x,w)}})([])
I=I.$finishIsolateConstructor(I)
$=new I()
init.metadata=[]
init.types=[]
function convertToFastObject(a){function MyClass(){}MyClass.prototype=a
new MyClass()
return a}function convertToSlowObject(a){a.__MAGIC_SLOW_PROPERTY=1
delete a.__MAGIC_SLOW_PROPERTY
return a}A=convertToFastObject(A)
B=convertToFastObject(B)
C=convertToFastObject(C)
D=convertToFastObject(D)
E=convertToFastObject(E)
F=convertToFastObject(F)
G=convertToFastObject(G)
H=convertToFastObject(H)
J=convertToFastObject(J)
K=convertToFastObject(K)
L=convertToFastObject(L)
M=convertToFastObject(M)
N=convertToFastObject(N)
O=convertToFastObject(O)
P=convertToFastObject(P)
Q=convertToFastObject(Q)
R=convertToFastObject(R)
S=convertToFastObject(S)
T=convertToFastObject(T)
U=convertToFastObject(U)
V=convertToFastObject(V)
W=convertToFastObject(W)
X=convertToFastObject(X)
Y=convertToFastObject(Y)
Z=convertToFastObject(Z)
function init(){I.p=Object.create(null)
init.allClasses=map()
init.getTypeFromName=function(a){return init.allClasses[a]}
init.interceptorsByTag=map()
init.leafTags=map()
init.finishedClasses=map()
I.$lazy=function(a,b,c,d,e){if(!init.lazies)init.lazies=Object.create(null)
init.lazies[a]=b
e=e||I.p
var z={}
var y={}
e[a]=z
e[b]=function(){var x=this[a]
try{if(x===z){this[a]=y
try{x=this[a]=c()}finally{if(x===z)this[a]=null}}else if(x===y)H.d(d||a)
return x}finally{this[b]=function(){return this[a]}}}}
I.$finishIsolateConstructor=function(a){var z=a.p
function Isolate(){var y=Object.keys(z)
for(var x=0;x<y.length;x++){var w=y[x]
this[w]=z[w]}var v=init.lazies
var u=v?Object.keys(v):[]
for(var x=0;x<u.length;x++)this[v[u[x]]]=null
function ForceEfficientMap(){}ForceEfficientMap.prototype=this
new ForceEfficientMap()
for(var x=0;x<u.length;x++){var t=v[u[x]]
this[t]=z[t]}}Isolate.prototype=a.prototype
Isolate.prototype.constructor=Isolate
Isolate.p=z
Isolate.a=a.a
return Isolate}}(function(a){if(typeof document==="undefined"){a(null)
return}if(typeof document.currentScript!='undefined'){a(document.currentScript)
return}var z=document.scripts
function onLoad(b){for(var x=0;x<z.length;++x)z[x].removeEventListener("load",onLoad,false)
a(b.target)}for(var y=0;y<z.length;++y)z[y].addEventListener("load",onLoad,false)})(function(a){init.currentScript=a
if(typeof dartMainRunner==="function")dartMainRunner(M.b,[])
else M.b([])})})()
//# sourceMappingURL=out.js.map
class Simple {
String name;
Simple(this.name);
greet(who) => "Greetings $who, I'm $name!";
}
main() {
var s= new Simple('Flyn');
print( s.greet('Program'));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment