@@ -26,8 +26,8 @@ import scala.collection.mutable.ArrayBuffer
26
26
* @param currentModule the module holding these bindings
27
27
*/
28
28
case class BindingsMap (
29
- definedEntities : List [DefinedEntity ],
30
- currentModule : ModuleReference
29
+ private val _definedEntities : List [DefinedEntity ],
30
+ private val _currentModule : ModuleReference
31
31
) extends IRPass .IRMetadata {
32
32
import BindingsMap ._
33
33
@@ -37,11 +37,23 @@ case class BindingsMap(
37
37
38
38
/** Other modules, imported by [[currentModule ]].
39
39
*/
40
- var resolvedImports : List [ResolvedImport ] = List ()
40
+ private var _resolvedImports : List [ResolvedImport ] = List ()
41
+
42
+ def definedEntities : List [DefinedEntity ] = _definedEntities
43
+ def currentModule : ModuleReference = _currentModule
44
+ def resolvedImports : List [ResolvedImport ] = _resolvedImports
45
+ def resolvedImports_ (v : List [ResolvedImport ]): Unit = {
46
+ _resolvedImports = v
47
+ }
41
48
42
49
/** Symbols exported by [[currentModule ]].
43
50
*/
44
- var exportedSymbols : Map [String , List [ResolvedName ]] = Map ()
51
+ private var _exportedSymbols : Map [String , List [ResolvedName ]] = Map ()
52
+
53
+ def exportedSymbols : Map [String , List [ResolvedName ]] = _exportedSymbols
54
+ def exportedSymbols_ (v : Map [String , List [ResolvedName ]]): Unit = {
55
+ _exportedSymbols = v
56
+ }
45
57
46
58
/** @inheritdoc */
47
59
override def prepareForSerialization (
@@ -63,9 +75,9 @@ case class BindingsMap(
63
75
* @return `this` with module references converted to abstract
64
76
*/
65
77
def toAbstract : BindingsMap = {
66
- val copy = this .copy(currentModule = currentModule .toAbstract)
67
- copy.resolvedImports = this .resolvedImports .map(_.toAbstract)
68
- copy.exportedSymbols = this .exportedSymbols .map { case (key, value) =>
78
+ val copy = this .copy(_currentModule = _currentModule .toAbstract)
79
+ copy._resolvedImports = this ._resolvedImports .map(_.toAbstract)
80
+ copy._exportedSymbols = this ._exportedSymbols .map { case (key, value) =>
69
81
key -> value.map(name => name.toAbstract)
70
82
}
71
83
copy
@@ -77,23 +89,25 @@ case class BindingsMap(
77
89
* instances
78
90
* @return `this` with module references converted to concrete
79
91
*/
80
- def toConcrete (moduleMap : ModuleMap ): Option [BindingsMap ] = {
92
+ private def toConcrete (moduleMap : ModuleMap ): Option [BindingsMap ] = {
81
93
val newMap = this .currentModule.toConcrete(moduleMap).map { module =>
82
- this .copy(currentModule = module)
94
+ this .copy(_currentModule = module)
83
95
}
84
96
85
97
val withImports : Option [BindingsMap ] = newMap.flatMap { bindings =>
86
- val newImports = this .resolvedImports.map(_.toConcrete(moduleMap))
98
+ val newImports = this ._resolvedImports.map(
99
+ _.toConcrete(moduleMap)
100
+ )
87
101
if (newImports.exists(_.isEmpty)) {
88
102
None
89
103
} else {
90
- bindings.resolvedImports = newImports.map(_.get)
104
+ bindings._resolvedImports = newImports.map(_.get)
91
105
Some (bindings)
92
106
}
93
107
}
94
108
95
109
val withSymbols : Option [BindingsMap ] = withImports.flatMap { bindings =>
96
- val newSymbols = this .exportedSymbols .map { case (key, value) =>
110
+ val newSymbols = this ._exportedSymbols .map { case (key, value) =>
97
111
val newValue = value.map(_.toConcrete(moduleMap))
98
112
if (newValue.exists(_.isEmpty)) {
99
113
key -> None
@@ -105,7 +119,7 @@ case class BindingsMap(
105
119
if (newSymbols.exists { case (_, v) => v.isEmpty }) {
106
120
None
107
121
} else {
108
- bindings.exportedSymbols = newSymbols.map { case (k, v) =>
122
+ bindings._exportedSymbols = newSymbols.map { case (k, v) =>
109
123
k -> v.get
110
124
}
111
125
Some (bindings)
0 commit comments