Created
May 7, 2011 08:23
-
-
Save kg/960322 to your computer and use it in GitHub Desktop.
JSIL test case (iterator functions)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
public static class Program { | |
public static IEnumerable<int> OneToNine { | |
get { | |
for (int i = 0; i < 10; i++) | |
yield return i; | |
} | |
} | |
public static void Main (string[] args) { | |
foreach (var i in OneToNine) | |
Console.WriteLine("{0}", i); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// soicx5xv, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null | |
JSIL.DeclareNamespace(this, "Program"); | |
JSIL.MakeClass(System.Object, Program, "$ltget_OneToNine$gtd__0", "Program/<get_OneToNine>d__0"); | |
Program.get_OneToNine = function () { | |
return new Program.$ltget_OneToNine$gtd__0(-2); | |
}; | |
Program.Main = function (args) { | |
var enumerator = null, i = 0; | |
enumerator = Program.OneToNine.IEnumerable$bt1_GetEnumerator(); | |
try { | |
__while0__: | |
while (enumerator.IEnumerator_MoveNext()) { | |
i = enumerator.IEnumerator$bt1_Current; | |
System.Console.WriteLine("{0}", i); | |
} | |
} finally { | |
if ((enumerator !== null)) { | |
enumerator.IDisposable_Dispose(); | |
} | |
} | |
}; | |
Object.defineProperty(Program, "OneToNine", | |
{ | |
enumerable: true, | |
get: Program.get_OneToNine | |
} | |
); | |
Program.$ltget_OneToNine$gtd__0.prototype.$lt$gt2__current = 0; | |
Program.$ltget_OneToNine$gtd__0.prototype.$lt$gt1__state = 0; | |
Program.$ltget_OneToNine$gtd__0.prototype.$lt$gtl__initialThreadId = 0; | |
Program.$ltget_OneToNine$gtd__0.prototype.$lti$gt5__1 = 0; | |
Program.$ltget_OneToNine$gtd__0.prototype.IEnumerable$bt1_GetEnumerator = function () { | |
var result = null; | |
if (!((System.Threading.Thread.CurrentThread.ManagedThreadId !== this.$lt$gtl__initialThreadId) || (this.$lt$gt1__state !== -2))) { | |
this.$lt$gt1__state = 0; | |
result = this; | |
} else { | |
result = new Program.$ltget_OneToNine$gtd__0(0); | |
} | |
return result; | |
}; | |
Program.$ltget_OneToNine$gtd__0.prototype.IEnumerable_GetEnumerator = function () { | |
return this.IEnumerable$bt1_GetEnumerator(); | |
}; | |
Program.$ltget_OneToNine$gtd__0.prototype.IEnumerator_MoveNext = function () { | |
var __label0__ = "__entry0__"; | |
__step0__: | |
while (true) { | |
switch (__label0__) { | |
case "__entry0__": | |
switch (this.$lt$gt1__state) { | |
case 0: | |
this.$lt$gt1__state = -1; | |
this.$lti$gt5__1 = 0; | |
break; | |
case 1: | |
this.$lt$gt1__state = -1; | |
this.$lti$gt5__1 = (this.$lti$gt5__1 + 1); | |
break; | |
default: | |
JSIL.UntranslatableInstruction("goto", "IL_69"); | |
} | |
if ((this.$lti$gt5__1 >= 10)) { | |
var __label1__ = "__entry1__"; | |
__step1__: | |
while (true) { | |
switch (__label1__) { | |
case "__entry1__": | |
__label1__ = "IL_69"; | |
continue __step1__; | |
break; | |
case "IL_69": | |
var result = false; | |
break __step1__; | |
} | |
} | |
} else { | |
this.$lt$gt2__current = this.$lti$gt5__1; | |
this.$lt$gt1__state = 1; | |
result = true; | |
} | |
return result; | |
break __step0__; | |
} | |
} | |
}; | |
Program.$ltget_OneToNine$gtd__0.prototype.IEnumerator$bt1_get_Current = function () { | |
return this.$lt$gt2__current; | |
}; | |
Program.$ltget_OneToNine$gtd__0.prototype.IEnumerator_Reset = function () { | |
throw new System.NotSupportedException(); | |
}; | |
Program.$ltget_OneToNine$gtd__0.prototype.IDisposable_Dispose = function () { | |
}; | |
Program.$ltget_OneToNine$gtd__0.prototype.IEnumerator_get_Current = function () { | |
return this.$lt$gt2__current; | |
}; | |
Program.$ltget_OneToNine$gtd__0.prototype._ctor = function ($lt$gt1__state) { | |
System.Object.prototype._ctor.call(this); | |
this.$lt$gt1__state = $lt$gt1__state; | |
this.$lt$gtl__initialThreadId = System.Threading.Thread.CurrentThread.ManagedThreadId; | |
}; | |
Object.defineProperty(Program.$ltget_OneToNine$gtd__0.prototype, "IEnumerator$bt1_Current", | |
{ | |
enumerable: true, | |
get: Program.$ltget_OneToNine$gtd__0.prototype.IEnumerator$bt1_get_Current | |
} | |
); | |
Object.defineProperty(Program.$ltget_OneToNine$gtd__0.prototype, "IEnumerator_Current", | |
{ | |
enumerable: true, | |
get: Program.$ltget_OneToNine$gtd__0.prototype.IEnumerator_get_Current | |
} | |
); | |
Program.$ltget_OneToNine$gtd__0.prototype.__ImplementInterface__(System.Collections.Generic.IEnumerable$bt1.Of(System.Int32)); | |
Program.$ltget_OneToNine$gtd__0.prototype.__ImplementInterface__(System.Collections.IEnumerable); | |
Program.$ltget_OneToNine$gtd__0.prototype.__ImplementInterface__(System.Collections.Generic.IEnumerator$bt1.Of(System.Int32)); | |
Program.$ltget_OneToNine$gtd__0.prototype.__ImplementInterface__(System.Collections.IEnumerator); | |
Program.$ltget_OneToNine$gtd__0.prototype.__ImplementInterface__(System.IDisposable); | |
timeout(30); Program.Main([]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment