Mark objects with ThreadLocal annotation

This commit is contained in:
Pavel Punegov
2018-08-16 20:56:51 +03:00
committed by Pavel Punegov
parent 93e1609d5e
commit c308e31275
@@ -709,6 +709,17 @@ class RunExternalTestGroup extends RunStandaloneKonanTest {
} }
} }
static String markMutableObjects(String text) {
def idx = text.indexOf("object ")
// FIXME: find only those who has vars inside
if (idx != -1) {
def lineBeforeIdx = text.substring(0, idx).lastIndexOf("\n")
text = text.substring(0, lineBeforeIdx) + "\n@kotlin.native.ThreadLocal" + text.substring(lineBeforeIdx)
}
return text
}
List<String> createTestFiles() { List<String> createTestFiles() {
def identifier = /[a-zA-Z_][a-zA-Z0-9_]/ def identifier = /[a-zA-Z_][a-zA-Z0-9_]/
def fullQualified = /[a-zA-Z_][a-zA-Z0-9_.]/ def fullQualified = /[a-zA-Z_][a-zA-Z0-9_.]/
@@ -741,6 +752,10 @@ class RunExternalTestGroup extends RunStandaloneKonanTest {
if (text =~ boxPattern) { if (text =~ boxPattern) {
imports.add("${pkg}.*") imports.add("${pkg}.*")
} }
// Find mutable objects that should be marked as ThreadLocal
text = markMutableObjects(text)
createFile(filePath, text) createFile(filePath, text)
} }
// TODO: optimize files writes // TODO: optimize files writes