Generate unsigned integers declarations, mostly without implementations

Generate and/or/xor/inv for UByte/UShort using experimental signed counterparts
This commit is contained in:
Ilya Gorbunov
2018-04-27 23:24:10 +03:00
parent e57e3971b6
commit 188d8ab8dd
8 changed files with 716 additions and 5 deletions
+11
View File
@@ -36,6 +36,16 @@ enum class PrimitiveType {
}
}
enum class UnsignedType {
UBYTE,
USHORT,
UINT,
ULONG;
val capitalized: String get() = name.substring(0, 2) + name.substring(2).toLowerCase()
val asSigned: PrimitiveType = PrimitiveType.valueOf(name.substring(1))
}
enum class ProgressionKind {
CHAR,
INT,
@@ -53,3 +63,4 @@ fun areEqualNumbers(v: String) = "$v == other.$v"
fun hashLong(v: String) = "($v xor ($v ushr 32))"
fun convert(v: String, from: UnsignedType, to: UnsignedType) = if (from == to) v else "$v.to${to.capitalized}()"