-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JavaScript code generation for methods #30
Conversation
Cool! Now try it with inheritance and overriding :^D Tip: you can just ignore method signatures in the source (those declarations of the form |
Test CasesTranslate Nullary Methods into GettersInput
Output
InheritanceInput
Output
Method OverrideInput (from test cases)
Generated code
|
Hmm, I should implement |
Great, looking good!
Yeah, it should probably be implemented as throwing an exception. Let's do it as part of this PR. |
Also, let's merge this first, and soon we'll add proper JS code-gen testing and revisit the tests you described above. |
@chengluyu This branch needs to be rebased on |
@chengluyu Actually since there are many conflicts, it would be easier to hard-reset this branch to the current HEAD of |
I proposed a lot of changes to JSBackend.scala in PR #29. How about do this after when that PR was merged? |
BTW, I have an idea of merging multiple function
into const f = (x) => {
if (x === 0) { return 1; }
else if (x === 1) { return 0; }
else { /* unreachable */ }
} |
But this is not in line with MLscript semantics, which uses shadowing. In MLscript, |
To be more specific, what would you do in this case, for instance? def f 0 = "oops"
def f x = x
f 0 + 1 // valid in MLscript |
Todos
get
property. Because we didn't implement calling nullary methods so far.Examples
Input
Output
Generated