diff --git a/compiler/build.gradle b/compiler/build.gradle index 45f67efa4..31a466a64 100644 --- a/compiler/build.gradle +++ b/compiler/build.gradle @@ -1,6 +1,7 @@ plugins { id "org.jetbrains.kotlin.jvm" version "1.3.40" id 'application' + id 'org.jetbrains.dokka' version "0.9.18" } repositories { @@ -95,3 +96,9 @@ test { events "passed", "skipped", "failed" } } + + +dokka { + outputFormat = 'html' + outputDirectory = "$buildDir/kdoc" +} diff --git a/compiler/src/prog8/ast/AST.kt b/compiler/src/prog8/ast/AST.kt index a8b491e61..51277905b 100644 --- a/compiler/src/prog8/ast/AST.kt +++ b/compiler/src/prog8/ast/AST.kt @@ -34,7 +34,10 @@ enum class DataType { ARRAY_W, ARRAY_F; - fun assignableTo(targetType: DataType) = + /** + * is the type assignable to the given other type? + */ + infix fun isAssignableTo(targetType: DataType) = // what types are assignable to others without loss of precision? when(this) { UBYTE -> targetType == UBYTE || targetType == UWORD || targetType==WORD || targetType == FLOAT @@ -49,8 +52,14 @@ enum class DataType { } - fun assignableTo(targetTypes: Set) = targetTypes.any { this.assignableTo(it) } + infix fun isAssignableTo(targetTypes: Set) = targetTypes.any { this isAssignableTo it } + infix fun biggerThan(other: DataType) = + when(this) { + in ByteDatatypes -> false + in WordDatatypes -> other in ByteDatatypes + else -> true + } } enum class Register { @@ -412,7 +421,7 @@ interface INameScope { return null } - fun allLabelsAndVariables(): Set = + fun allDefinedNames(): Set = statements.filterIsInstance