Skip to content

Commit

Permalink
Use bindings associated with module
Browse files Browse the repository at this point in the history
  • Loading branch information
JaroslavTulach committed May 11, 2023
1 parent 67cf459 commit 7f6c0d8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,12 @@ case object BindingAnalysis extends IRPass {
n.exportedSymbols = bp.exportedSymbols
n
} else {
BindingsMap(
val n = BindingsMap(
definedSumTypes ++ importedPolyglot ++ moduleMethods,
ModuleReference.Concrete(moduleContext.module)
)
moduleContext.module.bindings = n
n
}

ir.updateMetadata(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,13 @@ case object GlobalNames extends IRPass {
ir: IR.Module,
moduleContext: ModuleContext
): IR.Module = {
val scopeMap = ir.unsafeGetMetadata(
var scopeMap = ir.unsafeGetMetadata(
BindingAnalysis,
"No binding analysis on the module"
)
if (moduleContext.module.bindings != null) {
scopeMap = moduleContext.module.bindings
}
val freshNameSupply = moduleContext.freshNameSupply.getOrElse(
throw new CompilerError(
"No fresh name supply passed to GlobalNames resolver."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ case object TypeNames extends IRPass {
ir: IR.Module,
moduleContext: ModuleContext
): IR.Module = {
val bindingsMap =
var bindingsMap =
ir.unsafeGetMetadata(BindingAnalysis, "bindings analysis did not run")
if (moduleContext.module.bindings != null) {
bindingsMap = moduleContext.module.bindings
}
ir.copy(bindings = ir.bindings.map { d =>
val mapped = d.mapExpressions(resolveExpression(bindingsMap, _))
doResolveType(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,20 @@ class ImportResolver(compiler: Compiler) {
.map { concreteBindings =>
concreteBindings
}
current.bindings = converted.getOrElse(null)
current.bindings = converted.getOrElse(null)
if (converted.isDefined) {
if (current.bindings == null) {
current.bindings = converted.get
} else {
val update: BindingsMap = current.bindings
val imports = converted.get.resolvedImports ++ update.resolvedImports
val exports = converted.get.resolvedExports ++ update.resolvedExports
val symbols = converted.get.exportedSymbols ++ update.exportedSymbols
converted.get.resolvedImports = imports
converted.get.resolvedExports = exports
converted.get.exportedSymbols = symbols
current.bindings = converted.get
}
}
(
converted
.map(
Expand Down

0 comments on commit 7f6c0d8

Please sign in to comment.