Comments (4)
This usually indicates that the compiler generated a goto that the current goto translation algorithm can't express correctly in JS. I think it's possible to express it but the current algorithm needs to be rewritten to support it. I haven't yet encountered any code that actually depends on these gotos.
from jsil.
The code tha depends is quite simple. Here is the examlpe:
IEnumerable strings = Enumerable.Repeat("I like programming.", 15);
With ILSPY it decompiles into:
// System.Linq.Enumerable.<CreateRepeatIterator>d__57<TResult>
bool IEnumerator.MoveNext()
{
switch (this.<>1__state)
{
case 0:
this.<>1__state = -1;
this.<i>5__58 = 0;
break;
case 1:
this.<>1__state = -1;
this.<i>5__58++;
break;
default:
goto IL_6D;
}
bool result;
if (this.<i>5__58 >= this.count)
{
IL_6D:
result = false;
}
else
{
this.<>2__current = this.element;
this.<>1__state = 1;
result = true;
}
return result;
}
The problem is the goto IL_6D in the first switch, which actually just jumps into another if statement, which sets the result to false.
The JSIL generates the following code:
$asm03.System.Linq.Enumerable.$lCreateRepeatIterator$gd__57$b1.prototype.IEnumerator_MoveNext = function () {
var __label0__ = "__entry0__";
__step0__:
while (true) {
switch (__label0__) {
case "__entry0__":
switch (this.$state) {
case 0:
this.$state = -1;
this.i = 0;
break;
case 1:
this.$state = -1;
++this.i;
break;
default:
JSIL.UntranslatableInstruction("goto", "IL_6D");
}
if (this.i >= this.count) {
var __label1__ = "__entry1__";
__step1__:
while (true) {
switch (__label1__) {
case "__entry1__":
__label1__ = "IL_6D";
continue __step1__;
break;
case "IL_6D":
var result = false;
break __step1__;
}
}
} else {
this.$current = this.element;
this.$state = 1;
result = true;
}
return result;
break __step0__;
}
}
};
from jsil.
I think your problem is fixed by 94fe808.
from jsil.
Closer examination revealed a second bug where the body of the if statement's true clause was left empty when I hoisted the label out of it. That bug is particularly sneaky because you can't reproduce it with hand-written C#; only IL produced by the C# compiler for yield return contains gotos structured like this.
from jsil.
Related Issues (20)
- DCE works incorrectly for derived interface implementation
- Content Not Being Generated XNA HOT 1
- Assembly.GetType is not working for generics.
- Unsigned comparisons work incorrect
- Type.FullName is not returning correct name for generic dictionary
- Async state machine incorrect translation HOT 6
- Calling External Library From C# HOT 2
- string.IndexOf(String value, StringComparison comparisonType) not available HOT 2
- Support netstandard assemblies
- ulong math is incorrect HOT 2
- Installing JSIL on Linux HOT 2
- Support pascalabc
- InvalidCastException when using Newtonsoft.Json.dll (10.0.1 .NET 4.0) HOT 1
- Delegate.Method fails when called in constructor. HOT 3
- C# 7.2 "in" keyword in interfaces
- DateTime Object does not implement public functions
- load file
- Attribute properties are missing HOT 1
- How to Convert a CSharp Project to JavaScript on a Mac? HOT 2
- where do I find the namespace and game?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsil.