validate string interning

This commit is contained in:
Irmen de Jong 2021-05-18 23:37:52 +02:00
parent 6b7216f4ec
commit c2cac772e3

View File

@ -282,6 +282,13 @@ class Program(val name: String,
}
fun internString(string: StringLiteralValue, dedup: Boolean): List<String> {
// Move a string literal into the internal, deduplicated, string pool
// replace it with a variable declaration that points to the entry in the pool.
if(string.parent is VarDecl) {
// deduplication can only be performed safely for known-const strings (=string literals OUTSIDE OF A VARDECL)!
throw FatalAstException("cannot intern a string literal that's part of a vardecl")
}
fun getScopedName(string: StringLiteralValue): List<String> {
val internedStringsBlock = modules