-
Notifications
You must be signed in to change notification settings - Fork 357
feature/Nullish coalescing operator and assignment #464
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1403,12 +1403,19 @@ public enum BinaryOperator: String, CaseIterable { | |
| case RShift = ">>" | ||
| case Exp = "**" | ||
| case UnRShift = ">>>" | ||
| // Nullish coalescing operator (??) | ||
| case NCO = "??" | ||
|
|
||
| var token: String { | ||
| return self.rawValue | ||
| } | ||
|
|
||
| static public func allCaseWithoutNCO() -> Array<BinaryOperator> { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the idea behind this? Why is the new operator special? |
||
| return BinaryOperator.allCases.filter { $0 != .NCO } | ||
| } | ||
| } | ||
|
|
||
|
|
||
| final class BinaryOperation: JsOperation { | ||
| override var opcode: Opcode { .binaryOperation(self) } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -186,6 +186,7 @@ public class RuntimeAssistedMutator: Mutator { | |||
| case LogicalAnd = "LOGICAL_AND" | ||||
| case LogicalOr = "LOGICAL_OR" | ||||
| case LogicalNot = "LOGICAL_NOT" | ||||
| case NCO = "NCO" | ||||
| case BitwiseAnd = "BITWISE_AND" | ||||
| case BitwiseOr = "BITWISE_OR" | ||||
| case BitwiseXor = "BITWISE_XOR" | ||||
|
|
@@ -385,6 +386,8 @@ extension RuntimeAssistedMutator.Action { | |||
| try translateBinaryOperation(.BitOr) | ||||
| case .BitwiseXor: | ||||
| try translateBinaryOperation(.Xor) | ||||
| case .NCO: | ||||
| try translateBinaryOperation(.NCO) | ||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You will also need to update the corresponding JavaScript code, see here:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks very much. I missed something here. |
||||
| case .LeftShift: | ||||
| try translateBinaryOperation(.LShift) | ||||
| case .SignedRightShift: | ||||
|
|
||||
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.
'NCO' is maybe a little weird because none of the other operators have "operator" in their name. 'NC' is maybe a bit short/unintuitive though, so how about just calling it
NullCoalesce?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.
Good point. Thanks!