From a15c4a65d0113aa3462cb9b5d468ff279c46e347 Mon Sep 17 00:00:00 2001 From: Jamie Thompson Date: Mon, 9 Dec 2019 11:49:51 +0100 Subject: [PATCH 1/3] add nameTagToString in TastyFormat --- tasty/src/dotty/tools/tasty/TastyFormat.scala | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tasty/src/dotty/tools/tasty/TastyFormat.scala b/tasty/src/dotty/tools/tasty/TastyFormat.scala index 3f516efe638c..45cb3ba426ee 100644 --- a/tasty/src/dotty/tools/tasty/TastyFormat.scala +++ b/tasty/src/dotty/tools/tasty/TastyFormat.scala @@ -286,6 +286,23 @@ object TastyFormat { } object NameTags extends NameTags + def nameTagToString(tag: Int) = { + import NameTags._ + tag match { + case UTF8 => "UTF8" + case QUALIFIED => "QUALIFIED" + case EXPANDED => "EXPANDED" + case EXPANDPREFIX => "EXPANDPREFIX" + case UNIQUE => "UNIQUE" + case DEFAULTGETTER => "DEFAULTGETTER" + case VARIANT => "VARIANT" + case SUPERACCESSOR => "SUPERACCESSOR" + case INLINEACCESSOR => "INLINEACCESSOR" + case OBJECTCLASS => "OBJECTCLASS" + case SIGNED => "SIGNED" + } + } + // Position header final val SOURCE = 4 From 545df4021122302ee023c18598d99c2599410f29 Mon Sep 17 00:00:00 2001 From: Jamie Thompson Date: Tue, 10 Dec 2019 11:05:38 +0100 Subject: [PATCH 2/3] nameTagToString now total, add doc comments --- tasty/src/dotty/tools/tasty/TastyFormat.scala | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tasty/src/dotty/tools/tasty/TastyFormat.scala b/tasty/src/dotty/tools/tasty/TastyFormat.scala index 45cb3ba426ee..8d468bf90522 100644 --- a/tasty/src/dotty/tools/tasty/TastyFormat.scala +++ b/tasty/src/dotty/tools/tasty/TastyFormat.scala @@ -254,7 +254,7 @@ object TastyFormat { val MajorVersion: Int = 18 val MinorVersion: Int = 0 - /** Tags used to serialize names */ + /** Tags used to serialize names, should update [[nameTagToString]] if a new constant is added */ class NameTags { final val UTF8 = 1 // A simple name in UTF8 encoding. @@ -286,6 +286,11 @@ object TastyFormat { } object NameTags extends NameTags + /**Should be kept in sync with [[NameTags]]. Converts constants to a String representing their identifier, + * or NotANameTag(\d+) if unrecognised. + * + * For debugging purposes when unpickling names in a TASTy file. + */ def nameTagToString(tag: Int) = { import NameTags._ tag match { @@ -300,6 +305,7 @@ object TastyFormat { case INLINEACCESSOR => "INLINEACCESSOR" case OBJECTCLASS => "OBJECTCLASS" case SIGNED => "SIGNED" + case id => s"NotANameTag($id)" } } From 2f2111ab7a7b292b3aec7910bbb4f86190d9a8d6 Mon Sep 17 00:00:00 2001 From: Jamie Thompson Date: Tue, 10 Dec 2019 11:10:17 +0100 Subject: [PATCH 3/3] adjust comment format --- tasty/src/dotty/tools/tasty/TastyFormat.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasty/src/dotty/tools/tasty/TastyFormat.scala b/tasty/src/dotty/tools/tasty/TastyFormat.scala index 8d468bf90522..1a534cd9d547 100644 --- a/tasty/src/dotty/tools/tasty/TastyFormat.scala +++ b/tasty/src/dotty/tools/tasty/TastyFormat.scala @@ -287,7 +287,7 @@ object TastyFormat { object NameTags extends NameTags /**Should be kept in sync with [[NameTags]]. Converts constants to a String representing their identifier, - * or NotANameTag(\d+) if unrecognised. + * or NotANameTag(tag) if unrecognised. * * For debugging purposes when unpickling names in a TASTy file. */