Skip to content

@kg /DisplayClassFieldNames.cs
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
JSIL Code Sample: Closures
using System;
public static class Program {
public static void Main (string[] args) {
int x = 1;
string y = "y";
Func<string> a = () => {
return String.Format("x={0}, y={1}", x, y);
};
Console.WriteLine("a()={0}", a());
}
}
JSIL.MakeStaticClass("Program", true, [], function ($) {
$.Method({Static:true , Public:true }, "Main",
$sig.get(1, null, [$jsilcore.TypeRef("System.Array", [$.String])], []),
function Main (args) {
var $l$gc__DisplayClass = new $asm00.Program_$l$gc__DisplayClass1();
$l$gc__DisplayClass.x = 1;
$l$gc__DisplayClass.y = "y";
var a = function () {
return $asm01.System.String.Format("x={0}, y={1}", this.x, this.y);
}.bind($l$gc__DisplayClass);
$asm01.System.Console.WriteLine("a()={0}", a());
}
);
});
JSIL.MakeClass($asm01.TypeRef("System.Object"), "Program/<>c__DisplayClass1", false, [], function ($) {
$.Method({Static:false, Public:true }, ".ctor",
$sig.get(2, null, [], []),
function _ctor () {
}
);
$.Field({Static:false, Public:true }, "x", $.Int32, function ($) {
return 0;
});
$.Field({Static:false, Public:true }, "y", $.String, function ($) {
return null;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.