Skip to content

Commit

Permalink
Extend cached BindingsMap, when it exists
Browse files Browse the repository at this point in the history
  • Loading branch information
JaroslavTulach committed May 10, 2023
1 parent 91fba7e commit 0f82e6a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.oracle.truffle.api.library.ExportMessage;
import com.oracle.truffle.api.source.Source;
import com.oracle.truffle.api.source.SourceSection;

import java.io.File;
import java.io.IOException;
import java.util.Collections;
Expand All @@ -27,6 +28,7 @@
import org.enso.compiler.ModuleCache;
import org.enso.compiler.context.SimpleUpdate;
import org.enso.compiler.core.IR;
import org.enso.compiler.data.BindingsMap;
import org.enso.interpreter.node.callable.dispatch.CallOptimiserNode;
import org.enso.interpreter.node.callable.dispatch.LoopingCallOptimiserNode;
import org.enso.interpreter.runtime.builtin.Builtins;
Expand Down Expand Up @@ -102,6 +104,7 @@ public boolean isBefore(CompilationStage stage) {
private boolean hasCrossModuleLinks;
private final boolean synthetic;
private List<QualifiedName> directModulesRefs;
public BindingsMap bindings;

/**
* Creates a new module.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,26 @@ case object BindingAnalysis extends IRPass {
}
.flatten
.map(BindingsMap.ModuleMethod)
ir.updateMetadata(
this -->> BindingsMap(

val bp = moduleContext.module.bindings
val converted = if (moduleContext.module.bindings != null) {
val n = bp.copy(
definedEntities = definedSumTypes ++ importedPolyglot ++ moduleMethods,
currentModule = ModuleReference.Concrete(moduleContext.module)
)
n.resolvedImports = bp.resolvedImports
n.resolvedExports = bp.resolvedExports
n.exportedSymbols = bp.exportedSymbols
n
} else {
BindingsMap(
definedSumTypes ++ importedPolyglot ++ moduleMethods,
ModuleReference.Concrete(moduleContext.module)
)
}

ir.updateMetadata(
this -->> converted
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class ImportResolver(compiler: Compiler) {
module: Module,
bindingsCachingEnabled: Boolean
): (List[Module], List[Module]) = {

def analyzeModule(current: Module): List[Module] = {
val ir = current.getIr
val currentLocal = ir.unsafeGetMetadata(
Expand Down Expand Up @@ -95,11 +94,12 @@ class ImportResolver(compiler: Compiler) {
// - no - ensure they are parsed (load them from cache) and add them to the import/export resolution
compiler.importExportBindings(current) match {
case Some(bindings) =>
val converted = bindings
val converted: Option[BindingsMap] = bindings
.toConcrete(compiler.packageRepository.getModuleMap)
.map { concreteBindings =>
concreteBindings
}
current.bindings = converted.getOrElse(null)
(
converted
.map(
Expand Down

0 comments on commit 0f82e6a

Please sign in to comment.