-
Notifications
You must be signed in to change notification settings - Fork 5
arrays.equals and nullabe TerminalNodes #8
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
base: master
Are you sure you want to change the base?
Changes from all commits
6184619
d418c80
737cded
5bac473
961955e
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
buildscript { | ||
ext.kotlin_version = '1.2.10' | ||
ext.kotlin_version = '1.2.40' | ||
|
||
repositories { | ||
mavenCentral() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
buildscript { | ||
ext.kotlin_version = '1.2.31' | ||
ext.kotlin_version = '1.2.40' | ||
|
||
repositories { | ||
mavenCentral() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
|
||
buildscript { | ||
ext.kotlin_version = '1.2.31' | ||
ext.kotlin_version = '1.2.40' | ||
|
||
repositories { | ||
mavenCentral() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,12 +27,24 @@ expect object Arrays { | |
|
||
fun equals(a: Array<*>, b: Array<*>): Boolean | ||
|
||
fun equals(a: IntArray, b: IntArray): Boolean | ||
|
||
fun toString(a: Array<*>): String | ||
} | ||
|
||
expect class BitSet { | ||
constructor() | ||
fun Arrays.equals(a: Array<*>?, b: Array<*>?): Boolean { | ||
if (a == null && b == null) return true | ||
if (a == null && b != null || a != null && b == null) return false | ||
return equals(a!!, b!!) | ||
} | ||
|
||
fun Arrays.equals(a: IntArray?, b: IntArray?): Boolean { | ||
if (a == null && b == null) return true | ||
if (a == null && b != null || a != null && b == null) return false | ||
return equals(a!!, b!!) | ||
} | ||
|
||
expect class BitSet() { | ||
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. why did you remove the constructor from BitSet? 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. I only moved the constructor so it is right after the classname 'BitSet()'. There is no difference semantically. |
||
fun set(bitIndex: Int) | ||
fun clear(bitIndex: Int) | ||
fun get(bitIndex: Int): Boolean | ||
|
@@ -41,8 +53,6 @@ expect class BitSet { | |
fun or(alts: BitSet) | ||
} | ||
|
||
//expect class ArrayList<T> : List<T> | ||
|
||
expect object Collections { | ||
fun unmodifiableList(asList: Collection<*>): List<*> | ||
fun <T, U> unmodifiableMap(t: T): U | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,9 @@ | |
|
||
package org.antlr.v4.kotlinruntime.atn | ||
|
||
import com.strumenta.kotlinmultiplatform.Arrays | ||
import com.strumenta.kotlinmultiplatform.equals | ||
|
||
class ArrayPredictionContext( | ||
/** Parent can be null only if full ctx mode and we make an array | ||
* from [.EMPTY] and non-empty. We merge [.EMPTY] by using null parent and | ||
|
@@ -57,9 +60,8 @@ class ArrayPredictionContext( | |
return false // can't be same if hash is different | ||
} | ||
|
||
val a = o as ArrayPredictionContext? | ||
TODO() | ||
//return Arrays.equals(returnStates, a!!.returnStates) && Arrays.equals(parents, a.parents) | ||
o as ArrayPredictionContext | ||
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. why casting it if we do not save it? 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. So the compiler can infer the type later. IntelliJ uses the same trick when generating equals(). Maybe it's a hack, I'm not sure. |
||
return Arrays.equals(returnStates, o.returnStates) && Arrays.equals(parents, o.parents) | ||
} | ||
// | ||
// override fun toString(): String { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
buildscript { | ||
ext.kotlin_version = '1.2.31' | ||
ext.kotlin_version = '1.2.40' | ||
|
||
repositories { | ||
mavenCentral() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
buildscript { | ||
ext.kotlin_version = '1.2.31' | ||
ext.kotlin_version = '1.2.40' | ||
|
||
repositories { | ||
mavenCentral() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
buildscript { | ||
ext.kotlin_version = '1.2.31' | ||
ext.kotlin_version = '1.2.40' | ||
|
||
repositories { | ||
mavenLocal() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -705,11 +705,11 @@ RuleContextDecl(r) ::= "var <r.name>: <r.ctxName>? = null" | |
RuleContextListDecl(rdecl) ::= "var <rdecl.name> : MutableList\<<rdecl.ctxName>> = ArrayList\<<rdecl.ctxName>>()" | ||
|
||
ContextTokenGetterDecl(t) ::= | ||
"fun <t.name>() : TerminalNode = getToken(<parser.name>.Tokens.<t.name>.id, 0) as TerminalNode" | ||
"fun <t.name>() : TerminalNode? = getToken(<parser.name>.Tokens.<t.name>.id, 0)" | ||
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. Probably making these types nullable is causing the compilation issue we see on Travis 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. Yes. I probably need to update some of the dependent code as well. |
||
ContextTokenListGetterDecl(t) ::= | ||
"fun <t.name>() : List\<TerminalNode> = getTokens(<parser.name>.Tokens.<t.name>.id) as TerminalNode" | ||
"fun <t.name>() : List\<TerminalNode> = getTokens(<parser.name>.Tokens.<t.name>.id)" | ||
ContextTokenListIndexedGetterDecl(t) ::= << | ||
fun <t.name>(int i) : TerminalNode = getToken(<parser.name>.Tokens.<t.name>.id, i) as TerminalNode | ||
fun <t.name>(int i) : TerminalNode? = getToken(<parser.name>.Tokens.<t.name>.id, i) | ||
>> | ||
ContextRuleGetterDecl(r) ::= << | ||
fun find<r.name; format="cap">() : <r.ctxName>? = getRuleContext(solver.getType("<r.ctxName>"),0) | ||
|
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.
Why removing this?