-
Notifications
You must be signed in to change notification settings - Fork 241
Char based on number #938
base: master
Are you sure you want to change the base?
Char based on number #938
Conversation
What do you think the proxy fix would look like? |
First option that I see, is change |
It can be done as separate Transformation and it could be configurable. |
That sounds reasonable - what's the downside that merits making it configurable? |
InferredType is calculated by ILSpy, and it may be buggy sometimes. |
Gotcha, sounds good. Would it make more sense to configure it on a per-method basis or just make it global? It seems to me like you'd want a way to override it per-method when ILSpy does the wrong thing. |
Let's start with global configuration. If anybody will need it - we may discuss what we should do. We are talking about very restricted situations (right now - only F# compiler). |
I should think about updating Try JSIL to support F# so it's easier for people to play around with stuff like this. |
Thought a little bit more on it. Looks like we still need some additional work besides fixing MethodReference. So, looks like we need start with another option - add JSIL.ToString(value,type) and use it as object::ToString replacement. |
Probably we should file separate issue for |
JSSuppressOutput introduced.
I've implemented To make it work, based on #850, I changed |
So, now all tests are passed with this PR. |
@kg, reviewing of proxies feels like too big task, and I probably will not have time for it soon. In my fork I already migrated char to number base - and it now introduce me lot's of merges, so I'd like either merge this PR or think if I could revert this change in my fork. |
According to github this PR has conflicts. However, I'll read over it and let you know if I'd feel okay merging it. Moving char to number will have some awkward JS interop implications but it's fine otherwise, at least in principle. |
I started it based on your suggestion in #860. |
$.Method({ Public: false, Static: false }, null, | ||
new JSIL.MethodSignature(System.Object, []), | ||
function () { | ||
return this._array.charCodeAt(this._index); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This matches .NET, right? re: surrogate pairs, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll check it additionally, but really .Net strings (same as JS string) knows nothing about surrogate pairs.
So, it should just break them into two Chars (and Char is unable to represent surrogate pair, as it only Int16, and we need Int32 for surrogate pairs).
OK, I read through this PR and it looks fine. I'm OK with merging it if you can resolve the conflicts. One question: Did you update things so that char[] arrays have a backing store type of Uint16Array? That would be nice to do at some point, but you don't need to do it right away. |
Thank you for review! |
Here is PR that changes underling type of
System.Char
toNumber
.It reveals one interesting problem. C#, when call virtual method, emits cal to lowest type - for example:
callvirt instance string System.Char::ToString()
.At the same time F#, emits call to highest type - so it will be:
callvirt instance string System.Object::ToString()
Here we have problem - our proxies will replace
Char::ToString()
with special call, but notObject::ToString()
. So, right now this PR breaks translation ofchar.ToString()
method if it was compiled with F# (I moved Issue118_1.fs to FailingTest group).Probably we can solve this problem later. Probably we should solve it before merging this commit. We could solve it for this particular problem, or we could try to solve it in more generic way (for all proxies) with replacing method call with lowest call much earlier.