Kotlin: Comments and tweaks in Label

This commit is contained in:
Ian Lynagh
2022-03-02 14:23:41 +00:00
parent 2c5dc42db4
commit 0bf1ff9f2f

View File

@@ -3,20 +3,38 @@ package com.github.codeql
import java.io.PrintWriter
import java.io.StringWriter
/**
* This represents a label (`#...`) in a TRAP file.
*/
interface Label<T>
class IntLabel<T>(val name: Int): Label<T> {
override fun toString(): String = "#$name"
/**
* The label `#i`, e.g. `#123`. Most labels we generate are of this
* form.
*/
class IntLabel<T>(val i: Int): Label<T> {
override fun toString(): String = "#$i"
}
/**
* The label `#name`, e.g. `#compilation`. This is used when labels are
* shared between different components (e.g. when both the interceptor
* and the extractor need to refer to the same label).
*/
class StringLabel<T>(val name: String): Label<T> {
override fun toString(): String = "#$name"
}
/**
* This is not really a label, but just a `*`. Used in the rare cases
* when we only need to refer to something once, to save adding
* unnecessary labels.
*/
class StarLabel<T>: Label<T> {
override fun toString(): String = "*"
}
// TODO: Remove this and all of its uses
fun <T> fakeLabel(): Label<T> {
if (false) {
println("Fake label")