-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix - Unit keyword (and probably others) cannot be used in enum values
- Loading branch information
1 parent
103392c
commit c347ac0
Showing
26 changed files
with
275 additions
and
322 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
.../commonMain/kotlin/community/flock/wirespec/compiler/core/exceptions/WireSpecException.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 12 additions & 2 deletions
14
...r/core/src/commonMain/kotlin/community/flock/wirespec/compiler/core/optimize/Optimizer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,16 @@ | ||
package community.flock.wirespec.compiler.core.optimize | ||
|
||
import arrow.core.NonEmptyList | ||
import community.flock.wirespec.compiler.core.tokenize.CustomType | ||
import community.flock.wirespec.compiler.core.tokenize.SpecificType | ||
import community.flock.wirespec.compiler.core.tokenize.Token | ||
import community.flock.wirespec.compiler.core.tokenize.Tokens | ||
|
||
fun NonEmptyList<Token>.optimize(): NonEmptyList<Token> = this | ||
fun Tokens.optimize(specificTypes: Map<String, SpecificType>): Tokens = map { it.specify(specificTypes) } | ||
|
||
private fun Token.specify(entries: Map<String, SpecificType>) = when (type) { | ||
is CustomType -> entries[value] | ||
?.let { copy(type = it) } | ||
?: this | ||
|
||
else -> this | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.