Open dubek opened 7 years ago
Trying to understand how skew code generation works I did this change to csharp.sk:
case .SWITCH {
var switchValue = node.switchValue
_emit(_indent + "switch (")
if switchValue.kind == .INDEX {
_emit("(int)")
}
_emitExpression(switchValue, .LOWEST)
_emit(")\n" + _indent + "{\n")
_increaseIndent
But probably it also need to cast in other places a string index is used (like in comparisons and assignments).
Consider this Skew program:
It compiles to JS and runs OK (no assertion). However, when compiling to C# and then to exe, the Mono compiler
mcs
yells:The resulting C# program is:
The problem is that
s[0]
in C# returns a char; inside the case statement this is not automatically casted to int (whereas in==
expressions it is). Maybe instead ofs[0]
skewc should emit something along the lines of Javascript'ss.charCodeAt(0)
(I don't know C#, sorry).