mirror of
https://github.com/enso-org/enso.git
synced 2024-11-30 05:35:09 +03:00
Rewriting MetadataStorage into Java (#8366)
This commit is contained in:
parent
893965ed5c
commit
7a9a5ba1ff
@ -187,7 +187,7 @@ case object AliasAnalysis extends IRPass {
|
|||||||
case occ: Info.Occurrence =>
|
case occ: Info.Occurrence =>
|
||||||
occ.copy(graph = copyRootScopeGraph)
|
occ.copy(graph = copyRootScopeGraph)
|
||||||
}
|
}
|
||||||
copyNode.updateMetadata(this -->> newMeta)
|
copyNode.updateMetadata(new MetadataPair(this, newMeta))
|
||||||
case None =>
|
case None =>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -243,7 +243,9 @@ case object AliasAnalysis extends IRPass {
|
|||||||
topLevelGraph.rootScope,
|
topLevelGraph.rootScope,
|
||||||
lambdaReuseScope = true
|
lambdaReuseScope = true
|
||||||
)
|
)
|
||||||
).updateMetadata(this -->> Info.Scope.Root(topLevelGraph))
|
).updateMetadata(
|
||||||
|
new MetadataPair(this, Info.Scope.Root(topLevelGraph))
|
||||||
|
)
|
||||||
case _ =>
|
case _ =>
|
||||||
throw new CompilerError(
|
throw new CompilerError(
|
||||||
"The body of a method should always be a function."
|
"The body of a method should always be a function."
|
||||||
@ -259,7 +261,9 @@ case object AliasAnalysis extends IRPass {
|
|||||||
topLevelGraph.rootScope,
|
topLevelGraph.rootScope,
|
||||||
lambdaReuseScope = true
|
lambdaReuseScope = true
|
||||||
)
|
)
|
||||||
).updateMetadata(this -->> Info.Scope.Root(topLevelGraph))
|
).updateMetadata(
|
||||||
|
new MetadataPair(this, Info.Scope.Root(topLevelGraph))
|
||||||
|
)
|
||||||
case _ =>
|
case _ =>
|
||||||
throw new CompilerError(
|
throw new CompilerError(
|
||||||
"The body of a method should always be a function."
|
"The body of a method should always be a function."
|
||||||
@ -293,11 +297,13 @@ case object AliasAnalysis extends IRPass {
|
|||||||
topLevelGraph.rootScope
|
topLevelGraph.rootScope
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> Info.Scope.Root(topLevelGraph))
|
.updateMetadata(
|
||||||
|
new MetadataPair(this, Info.Scope.Root(topLevelGraph))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
).updateMetadata(this -->> Info.Scope.Root(graph))
|
).updateMetadata(new MetadataPair(this, Info.Scope.Root(graph)))
|
||||||
})
|
})
|
||||||
).updateMetadata(this -->> Info.Scope.Root(topLevelGraph))
|
).updateMetadata(new MetadataPair(this, Info.Scope.Root(topLevelGraph)))
|
||||||
case _: Definition.SugaredType =>
|
case _: Definition.SugaredType =>
|
||||||
throw new CompilerError(
|
throw new CompilerError(
|
||||||
"Complex type definitions should not be present during " +
|
"Complex type definitions should not be present during " +
|
||||||
@ -326,7 +332,9 @@ case object AliasAnalysis extends IRPass {
|
|||||||
topLevelGraph.rootScope
|
topLevelGraph.rootScope
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> Info.Scope.Root(topLevelGraph))
|
.updateMetadata(
|
||||||
|
new MetadataPair(this, Info.Scope.Root(topLevelGraph))
|
||||||
|
)
|
||||||
case err: Error => err
|
case err: Error => err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -390,7 +398,9 @@ case object AliasAnalysis extends IRPass {
|
|||||||
currentScope
|
currentScope
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> Info.Scope.Child(graph, currentScope))
|
.updateMetadata(
|
||||||
|
new MetadataPair(this, Info.Scope.Child(graph, currentScope))
|
||||||
|
)
|
||||||
case binding @ Expression.Binding(name, expression, _, _, _) =>
|
case binding @ Expression.Binding(name, expression, _, _, _) =>
|
||||||
if (!parentScope.hasSymbolOccurrenceAs[Occurrence.Def](name.name)) {
|
if (!parentScope.hasSymbolOccurrenceAs[Occurrence.Def](name.name)) {
|
||||||
val isSuspended = expression match {
|
val isSuspended = expression match {
|
||||||
@ -418,7 +428,9 @@ case object AliasAnalysis extends IRPass {
|
|||||||
parentScope
|
parentScope
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> Info.Occurrence(graph, occurrenceId))
|
.updateMetadata(
|
||||||
|
new MetadataPair(this, Info.Occurrence(graph, occurrenceId))
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
errors.Redefined.Binding(binding)
|
errors.Redefined.Binding(binding)
|
||||||
}
|
}
|
||||||
@ -467,7 +479,9 @@ case object AliasAnalysis extends IRPass {
|
|||||||
memberType = analyseExpression(memberType, graph, memberTypeScope),
|
memberType = analyseExpression(memberType, graph, memberTypeScope),
|
||||||
value = analyseExpression(value, graph, valueScope)
|
value = analyseExpression(value, graph, valueScope)
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> Info.Occurrence(graph, labelId))
|
.updateMetadata(
|
||||||
|
new MetadataPair(this, Info.Occurrence(graph, labelId))
|
||||||
|
)
|
||||||
case x =>
|
case x =>
|
||||||
x.mapExpressions(analyseExpression(_, graph, parentScope))
|
x.mapExpressions(analyseExpression(_, graph, parentScope))
|
||||||
}
|
}
|
||||||
@ -515,7 +529,9 @@ case object AliasAnalysis extends IRPass {
|
|||||||
)
|
)
|
||||||
scope.addDefinition(definition)
|
scope.addDefinition(definition)
|
||||||
arg
|
arg
|
||||||
.updateMetadata(this -->> Info.Occurrence(graph, occurrenceId))
|
.updateMetadata(
|
||||||
|
new MetadataPair(this, Info.Occurrence(graph, occurrenceId))
|
||||||
|
)
|
||||||
.copy(
|
.copy(
|
||||||
ascribedType =
|
ascribedType =
|
||||||
arg.ascribedType.map(analyseExpression(_, graph, scope))
|
arg.ascribedType.map(analyseExpression(_, graph, scope))
|
||||||
@ -553,7 +569,9 @@ case object AliasAnalysis extends IRPass {
|
|||||||
ascribedType =
|
ascribedType =
|
||||||
arg.ascribedType.map(analyseExpression(_, graph, scope))
|
arg.ascribedType.map(analyseExpression(_, graph, scope))
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> Info.Occurrence(graph, occurrenceId))
|
.updateMetadata(
|
||||||
|
new MetadataPair(this, Info.Occurrence(graph, occurrenceId))
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
throw new CompilerError(
|
throw new CompilerError(
|
||||||
s"""
|
s"""
|
||||||
@ -591,7 +609,9 @@ case object AliasAnalysis extends IRPass {
|
|||||||
val newScope = scope.addChild()
|
val newScope = scope.addChild()
|
||||||
tSet
|
tSet
|
||||||
.copy(expression = expr.map(analyseExpression(_, graph, newScope)))
|
.copy(expression = expr.map(analyseExpression(_, graph, newScope)))
|
||||||
.updateMetadata(this -->> Info.Scope.Child(graph, newScope))
|
.updateMetadata(
|
||||||
|
new MetadataPair(this, Info.Scope.Child(graph, newScope))
|
||||||
|
)
|
||||||
case _: Operator.Binary =>
|
case _: Operator.Binary =>
|
||||||
throw new CompilerError(
|
throw new CompilerError(
|
||||||
"Binary operator occurred during Alias Analysis."
|
"Binary operator occurred during Alias Analysis."
|
||||||
@ -622,7 +642,9 @@ case object AliasAnalysis extends IRPass {
|
|||||||
}
|
}
|
||||||
arg
|
arg
|
||||||
.copy(value = analyseExpression(expr, graph, currentScope))
|
.copy(value = analyseExpression(expr, graph, currentScope))
|
||||||
.updateMetadata(this -->> Info.Scope.Child(graph, currentScope))
|
.updateMetadata(
|
||||||
|
new MetadataPair(this, Info.Scope.Child(graph, currentScope))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -655,7 +677,9 @@ case object AliasAnalysis extends IRPass {
|
|||||||
currentScope
|
currentScope
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> Info.Scope.Child(graph, currentScope))
|
.updateMetadata(
|
||||||
|
new MetadataPair(this, Info.Scope.Child(graph, currentScope))
|
||||||
|
)
|
||||||
case _: Function.Binding =>
|
case _: Function.Binding =>
|
||||||
throw new CompilerError(
|
throw new CompilerError(
|
||||||
"Function sugar should not be present during alias analysis."
|
"Function sugar should not be present during alias analysis."
|
||||||
@ -698,7 +722,9 @@ case object AliasAnalysis extends IRPass {
|
|||||||
graph.resolveGlobalUsage(occurrence)
|
graph.resolveGlobalUsage(occurrence)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
name.updateMetadata(this -->> Info.Occurrence(graph, occurrenceId))
|
name.updateMetadata(
|
||||||
|
new MetadataPair(this, Info.Occurrence(graph, occurrenceId))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Performs alias analysis on a case expression.
|
/** Performs alias analysis on a case expression.
|
||||||
@ -748,7 +774,9 @@ case object AliasAnalysis extends IRPass {
|
|||||||
currentScope
|
currentScope
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> Info.Scope.Child(graph, currentScope))
|
.updateMetadata(
|
||||||
|
new MetadataPair(this, Info.Scope.Child(graph, currentScope))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Performs alias analysis on a pattern.
|
/** Performs alias analysis on a pattern.
|
||||||
|
@ -2,6 +2,7 @@ package org.enso.compiler.pass.analyse
|
|||||||
|
|
||||||
import org.enso.compiler.context.{FreshNameSupply, InlineContext, ModuleContext}
|
import org.enso.compiler.context.{FreshNameSupply, InlineContext, ModuleContext}
|
||||||
import org.enso.compiler.core.Implicits.AsMetadata
|
import org.enso.compiler.core.Implicits.AsMetadata
|
||||||
|
import org.enso.compiler.core.ir.MetadataStorage.MetadataPair
|
||||||
import org.enso.compiler.core.ir.{
|
import org.enso.compiler.core.ir.{
|
||||||
CallArgument,
|
CallArgument,
|
||||||
Expression,
|
Expression,
|
||||||
@ -10,7 +11,6 @@ import org.enso.compiler.core.ir.{
|
|||||||
Module,
|
Module,
|
||||||
Name
|
Name
|
||||||
}
|
}
|
||||||
import org.enso.compiler.core.ir.MetadataStorage.ToPair
|
|
||||||
import org.enso.compiler.core.ir.module.scope.definition
|
import org.enso.compiler.core.ir.module.scope.definition
|
||||||
import org.enso.compiler.data.BindingsMap.{Resolution, ResolvedMethod}
|
import org.enso.compiler.data.BindingsMap.{Resolution, ResolvedMethod}
|
||||||
import org.enso.compiler.core.CompilerError
|
import org.enso.compiler.core.CompilerError
|
||||||
@ -302,7 +302,9 @@ object AutomaticParallelism extends IRPass {
|
|||||||
),
|
),
|
||||||
None
|
None
|
||||||
)
|
)
|
||||||
.updateMetadata(IgnoredBindings -->> IgnoredBindings.State.Ignored)
|
.updateMetadata(
|
||||||
|
new MetadataPair(IgnoredBindings, IgnoredBindings.State.Ignored)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
val threadSpawns = threadBlocks.values.map { exprs =>
|
val threadSpawns = threadBlocks.values.map { exprs =>
|
||||||
@ -336,7 +338,9 @@ object AutomaticParallelism extends IRPass {
|
|||||||
)
|
)
|
||||||
Expression
|
Expression
|
||||||
.Binding(freshNameSupply.newName(), spawn, None)
|
.Binding(freshNameSupply.newName(), spawn, None)
|
||||||
.updateMetadata(IgnoredBindings -->> IgnoredBindings.State.Ignored)
|
.updateMetadata(
|
||||||
|
new MetadataPair(IgnoredBindings, IgnoredBindings.State.Ignored)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val threadJoins = threadSpawns.map { bind =>
|
val threadJoins = threadSpawns.map { bind =>
|
||||||
@ -360,7 +364,9 @@ object AutomaticParallelism extends IRPass {
|
|||||||
),
|
),
|
||||||
None
|
None
|
||||||
)
|
)
|
||||||
.updateMetadata(IgnoredBindings -->> IgnoredBindings.State.Ignored)
|
.updateMetadata(
|
||||||
|
new MetadataPair(IgnoredBindings, IgnoredBindings.State.Ignored)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
List(
|
List(
|
||||||
|
@ -6,7 +6,7 @@ import org.enso.compiler.core.ir.{Expression, Module, Name}
|
|||||||
import org.enso.compiler.core.ir.module.scope.Definition
|
import org.enso.compiler.core.ir.module.scope.Definition
|
||||||
import org.enso.compiler.core.ir.module.scope.definition
|
import org.enso.compiler.core.ir.module.scope.definition
|
||||||
import org.enso.compiler.core.ir.module.scope.imports
|
import org.enso.compiler.core.ir.module.scope.imports
|
||||||
import org.enso.compiler.core.ir.MetadataStorage.ToPair
|
import org.enso.compiler.core.ir.MetadataStorage.MetadataPair
|
||||||
import org.enso.compiler.data.BindingsMap
|
import org.enso.compiler.data.BindingsMap
|
||||||
import org.enso.compiler.data.BindingsMap.Cons
|
import org.enso.compiler.data.BindingsMap.Cons
|
||||||
import org.enso.compiler.pass.IRPass
|
import org.enso.compiler.pass.IRPass
|
||||||
@ -95,9 +95,12 @@ case object BindingAnalysis extends IRPass {
|
|||||||
.flatten
|
.flatten
|
||||||
.map(BindingsMap.ModuleMethod)
|
.map(BindingsMap.ModuleMethod)
|
||||||
ir.updateMetadata(
|
ir.updateMetadata(
|
||||||
this -->> BindingsMap(
|
new MetadataPair(
|
||||||
definedSumTypes ++ importedPolyglot ++ moduleMethods,
|
this,
|
||||||
moduleContext.moduleReference()
|
BindingsMap(
|
||||||
|
definedSumTypes ++ importedPolyglot ++ moduleMethods,
|
||||||
|
moduleContext.moduleReference()
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ case object CachePreferenceAnalysis extends IRPass {
|
|||||||
): Module = {
|
): Module = {
|
||||||
val weights = WeightInfo()
|
val weights = WeightInfo()
|
||||||
ir.copy(bindings = ir.bindings.map(analyseModuleDefinition(_, weights)))
|
ir.copy(bindings = ir.bindings.map(analyseModuleDefinition(_, weights)))
|
||||||
.updateMetadata(this -->> weights)
|
.updateMetadata(new MetadataPair(this, weights))
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Performs the cache preference analysis on an inline expression.
|
/** Performs the cache preference analysis on an inline expression.
|
||||||
@ -93,12 +93,12 @@ case object CachePreferenceAnalysis extends IRPass {
|
|||||||
case method: definition.Method.Conversion =>
|
case method: definition.Method.Conversion =>
|
||||||
method
|
method
|
||||||
.copy(body = analyseExpression(method.body, weights))
|
.copy(body = analyseExpression(method.body, weights))
|
||||||
.updateMetadata(this -->> weights)
|
.updateMetadata(new MetadataPair(this, weights))
|
||||||
case method @ definition.Method
|
case method @ definition.Method
|
||||||
.Explicit(_, body, _, _, _) =>
|
.Explicit(_, body, _, _, _) =>
|
||||||
method
|
method
|
||||||
.copy(body = analyseExpression(body, weights))
|
.copy(body = analyseExpression(body, weights))
|
||||||
.updateMetadata(this -->> weights)
|
.updateMetadata(new MetadataPair(this, weights))
|
||||||
case _: definition.Method.Binding =>
|
case _: definition.Method.Binding =>
|
||||||
throw new CompilerError(
|
throw new CompilerError(
|
||||||
"Sugared method definitions should not occur during cache " +
|
"Sugared method definitions should not occur during cache " +
|
||||||
@ -145,10 +145,10 @@ case object CachePreferenceAnalysis extends IRPass {
|
|||||||
.foreach(weights.update(_, Weight.Always))
|
.foreach(weights.update(_, Weight.Always))
|
||||||
binding
|
binding
|
||||||
.copy(
|
.copy(
|
||||||
name = binding.name.updateMetadata(this -->> weights),
|
name = binding.name.updateMetadata(new MetadataPair(this, weights)),
|
||||||
expression = analyseExpression(binding.expression, weights)
|
expression = analyseExpression(binding.expression, weights)
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> weights)
|
.updateMetadata(new MetadataPair(this, weights))
|
||||||
case error: Error =>
|
case error: Error =>
|
||||||
error
|
error
|
||||||
case expr =>
|
case expr =>
|
||||||
@ -157,7 +157,7 @@ case object CachePreferenceAnalysis extends IRPass {
|
|||||||
}
|
}
|
||||||
expr
|
expr
|
||||||
.mapExpressions(analyseExpression(_, weights))
|
.mapExpressions(analyseExpression(_, weights))
|
||||||
.updateMetadata(this -->> weights)
|
.updateMetadata(new MetadataPair(this, weights))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,7 +175,7 @@ case object CachePreferenceAnalysis extends IRPass {
|
|||||||
case spec @ DefinitionArgument.Specified(_, _, defValue, _, _, _, _) =>
|
case spec @ DefinitionArgument.Specified(_, _, defValue, _, _, _, _) =>
|
||||||
spec
|
spec
|
||||||
.copy(defaultValue = defValue.map(analyseExpression(_, weights)))
|
.copy(defaultValue = defValue.map(analyseExpression(_, weights)))
|
||||||
.updateMetadata(this -->> weights)
|
.updateMetadata(new MetadataPair(this, weights))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ case object DataflowAnalysis extends IRPass {
|
|||||||
val dependencyInfo = new DependencyInfo
|
val dependencyInfo = new DependencyInfo
|
||||||
ir.copy(
|
ir.copy(
|
||||||
bindings = ir.bindings.map(analyseModuleDefinition(_, dependencyInfo))
|
bindings = ir.bindings.map(analyseModuleDefinition(_, dependencyInfo))
|
||||||
).updateMetadata(this -->> dependencyInfo)
|
).updateMetadata(new MetadataPair(this, dependencyInfo))
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Performs dataflow analysis on an inline expression.
|
/** Performs dataflow analysis on an inline expression.
|
||||||
@ -117,7 +117,7 @@ case object DataflowAnalysis extends IRPass {
|
|||||||
sourceNodes.lazyZip(copyNodes).foreach { case (src, copy) =>
|
sourceNodes.lazyZip(copyNodes).foreach { case (src, copy) =>
|
||||||
src
|
src
|
||||||
.getMetadata(this)
|
.getMetadata(this)
|
||||||
.foreach(_ => copy.updateMetadata(this -->> copyMeta))
|
.foreach(_ => copy.updateMetadata(new MetadataPair(this, copyMeta)))
|
||||||
}
|
}
|
||||||
|
|
||||||
copyOfIr.asInstanceOf[T]
|
copyOfIr.asInstanceOf[T]
|
||||||
@ -151,9 +151,10 @@ case object DataflowAnalysis extends IRPass {
|
|||||||
info.dependencies.updateAt(methodDep, Set(bodyDep, sourceTypeDep))
|
info.dependencies.updateAt(methodDep, Set(bodyDep, sourceTypeDep))
|
||||||
|
|
||||||
m.copy(
|
m.copy(
|
||||||
body = analyseExpression(m.body, info),
|
body = analyseExpression(m.body, info),
|
||||||
sourceTypeName = m.sourceTypeName.updateMetadata(this -->> info)
|
sourceTypeName =
|
||||||
).updateMetadata(this -->> info)
|
m.sourceTypeName.updateMetadata(new MetadataPair(this, info))
|
||||||
|
).updateMetadata(new MetadataPair(this, info))
|
||||||
case method @ definition.Method
|
case method @ definition.Method
|
||||||
.Explicit(_, body, _, _, _) =>
|
.Explicit(_, body, _, _, _) =>
|
||||||
val bodyDep = asStatic(body)
|
val bodyDep = asStatic(body)
|
||||||
@ -163,7 +164,7 @@ case object DataflowAnalysis extends IRPass {
|
|||||||
|
|
||||||
method
|
method
|
||||||
.copy(body = analyseExpression(body, info))
|
.copy(body = analyseExpression(body, info))
|
||||||
.updateMetadata(this -->> info)
|
.updateMetadata(new MetadataPair(this, info))
|
||||||
case tp @ Definition.Type(_, params, members, _, _, _) =>
|
case tp @ Definition.Type(_, params, members, _, _, _) =>
|
||||||
val tpDep = asStatic(tp)
|
val tpDep = asStatic(tp)
|
||||||
val newParams = params.map { param =>
|
val newParams = params.map { param =>
|
||||||
@ -186,10 +187,10 @@ case object DataflowAnalysis extends IRPass {
|
|||||||
.copy(
|
.copy(
|
||||||
arguments = data.arguments.map(analyseDefinitionArgument(_, info))
|
arguments = data.arguments.map(analyseDefinitionArgument(_, info))
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> info)
|
.updateMetadata(new MetadataPair(this, info))
|
||||||
}
|
}
|
||||||
tp.copy(params = newParams, members = newMembers)
|
tp.copy(params = newParams, members = newMembers)
|
||||||
.updateMetadata(this -->> info)
|
.updateMetadata(new MetadataPair(this, info))
|
||||||
case _: definition.Method.Binding =>
|
case _: definition.Method.Binding =>
|
||||||
throw new CompilerError(
|
throw new CompilerError(
|
||||||
"Sugared method definitions should not occur during dataflow " +
|
"Sugared method definitions should not occur during dataflow " +
|
||||||
@ -217,7 +218,7 @@ case object DataflowAnalysis extends IRPass {
|
|||||||
case ann: Name.GenericAnnotation =>
|
case ann: Name.GenericAnnotation =>
|
||||||
ann
|
ann
|
||||||
.copy(expression = analyseExpression(ann.expression, info))
|
.copy(expression = analyseExpression(ann.expression, info))
|
||||||
.updateMetadata(this -->> info)
|
.updateMetadata(new MetadataPair(this, info))
|
||||||
case err: Error => err
|
case err: Error => err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -236,16 +237,16 @@ case object DataflowAnalysis extends IRPass {
|
|||||||
info: DependencyInfo
|
info: DependencyInfo
|
||||||
): Expression = {
|
): Expression = {
|
||||||
expression match {
|
expression match {
|
||||||
case empty: Empty => empty.updateMetadata(this -->> info)
|
case empty: Empty => empty.updateMetadata(new MetadataPair(this, info))
|
||||||
case function: Function => analyseFunction(function, info)
|
case function: Function => analyseFunction(function, info)
|
||||||
case app: Application => analyseApplication(app, info)
|
case app: Application => analyseApplication(app, info)
|
||||||
case typ: Type => analyseType(typ, info)
|
case typ: Type => analyseType(typ, info)
|
||||||
case name: Name => analyseName(name, info)
|
case name: Name => analyseName(name, info)
|
||||||
case cse: Case => analyseCase(cse, info)
|
case cse: Case => analyseCase(cse, info)
|
||||||
case literal: Literal =>
|
case literal: Literal =>
|
||||||
literal.updateMetadata(this -->> info)
|
literal.updateMetadata(new MetadataPair(this, info))
|
||||||
case foreign: Foreign =>
|
case foreign: Foreign =>
|
||||||
foreign.updateMetadata(this -->> info)
|
foreign.updateMetadata(new MetadataPair(this, info))
|
||||||
|
|
||||||
case block @ Expression.Block(expressions, returnValue, _, _, _, _) =>
|
case block @ Expression.Block(expressions, returnValue, _, _, _, _) =>
|
||||||
val retValDep = asStatic(returnValue)
|
val retValDep = asStatic(returnValue)
|
||||||
@ -258,7 +259,7 @@ case object DataflowAnalysis extends IRPass {
|
|||||||
expressions = expressions.map(analyseExpression(_, info)),
|
expressions = expressions.map(analyseExpression(_, info)),
|
||||||
returnValue = analyseExpression(returnValue, info)
|
returnValue = analyseExpression(returnValue, info)
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> info)
|
.updateMetadata(new MetadataPair(this, info))
|
||||||
case binding @ Expression.Binding(name, expression, _, _, _) =>
|
case binding @ Expression.Binding(name, expression, _, _, _) =>
|
||||||
val expressionDep = asStatic(expression)
|
val expressionDep = asStatic(expression)
|
||||||
val nameDep = asStatic(name)
|
val nameDep = asStatic(name)
|
||||||
@ -269,10 +270,10 @@ case object DataflowAnalysis extends IRPass {
|
|||||||
|
|
||||||
binding
|
binding
|
||||||
.copy(
|
.copy(
|
||||||
name = name.updateMetadata(this -->> info),
|
name = name.updateMetadata(new MetadataPair(this, info)),
|
||||||
expression = analyseExpression(expression, info)
|
expression = analyseExpression(expression, info)
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> info)
|
.updateMetadata(new MetadataPair(this, info))
|
||||||
|
|
||||||
case error: Error => error
|
case error: Error => error
|
||||||
case _: Comment =>
|
case _: Comment =>
|
||||||
@ -307,7 +308,7 @@ case object DataflowAnalysis extends IRPass {
|
|||||||
arguments = arguments.map(analyseDefinitionArgument(_, info)),
|
arguments = arguments.map(analyseDefinitionArgument(_, info)),
|
||||||
body = analyseExpression(body, info)
|
body = analyseExpression(body, info)
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> info)
|
.updateMetadata(new MetadataPair(this, info))
|
||||||
case _: Function.Binding =>
|
case _: Function.Binding =>
|
||||||
throw new CompilerError(
|
throw new CompilerError(
|
||||||
"Function sugar should not be present during dataflow analysis."
|
"Function sugar should not be present during dataflow analysis."
|
||||||
@ -345,7 +346,7 @@ case object DataflowAnalysis extends IRPass {
|
|||||||
function = analyseExpression(fn, info),
|
function = analyseExpression(fn, info),
|
||||||
arguments = args.map(analyseCallArgument(_, info))
|
arguments = args.map(analyseCallArgument(_, info))
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> info)
|
.updateMetadata(new MetadataPair(this, info))
|
||||||
case force @ Application.Force(target, _, _, _) =>
|
case force @ Application.Force(target, _, _, _) =>
|
||||||
val targetDep = asStatic(target)
|
val targetDep = asStatic(target)
|
||||||
val forceDep = asStatic(force)
|
val forceDep = asStatic(force)
|
||||||
@ -354,7 +355,7 @@ case object DataflowAnalysis extends IRPass {
|
|||||||
|
|
||||||
force
|
force
|
||||||
.copy(target = analyseExpression(target, info))
|
.copy(target = analyseExpression(target, info))
|
||||||
.updateMetadata(this -->> info)
|
.updateMetadata(new MetadataPair(this, info))
|
||||||
case vector @ Application.Sequence(items, _, _, _) =>
|
case vector @ Application.Sequence(items, _, _, _) =>
|
||||||
val vectorDep = asStatic(vector)
|
val vectorDep = asStatic(vector)
|
||||||
items.foreach(it => {
|
items.foreach(it => {
|
||||||
@ -365,7 +366,7 @@ case object DataflowAnalysis extends IRPass {
|
|||||||
|
|
||||||
vector
|
vector
|
||||||
.copy(items = items.map(analyseExpression(_, info)))
|
.copy(items = items.map(analyseExpression(_, info)))
|
||||||
.updateMetadata(this -->> info)
|
.updateMetadata(new MetadataPair(this, info))
|
||||||
case tSet @ Application.Typeset(expr, _, _, _) =>
|
case tSet @ Application.Typeset(expr, _, _, _) =>
|
||||||
val tSetDep = asStatic(tSet)
|
val tSetDep = asStatic(tSet)
|
||||||
expr.foreach(exp => {
|
expr.foreach(exp => {
|
||||||
@ -376,7 +377,7 @@ case object DataflowAnalysis extends IRPass {
|
|||||||
|
|
||||||
tSet
|
tSet
|
||||||
.copy(expression = expr.map(analyseExpression(_, info)))
|
.copy(expression = expr.map(analyseExpression(_, info)))
|
||||||
.updateMetadata(this -->> info)
|
.updateMetadata(new MetadataPair(this, info))
|
||||||
case _: Operator =>
|
case _: Operator =>
|
||||||
throw new CompilerError("Unexpected operator during Dataflow Analysis.")
|
throw new CompilerError("Unexpected operator during Dataflow Analysis.")
|
||||||
}
|
}
|
||||||
@ -405,7 +406,7 @@ case object DataflowAnalysis extends IRPass {
|
|||||||
typed = analyseExpression(typed, info),
|
typed = analyseExpression(typed, info),
|
||||||
signature = analyseExpression(signature, info)
|
signature = analyseExpression(signature, info)
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> info)
|
.updateMetadata(new MetadataPair(this, info))
|
||||||
|
|
||||||
case fun @ Type.Function(args, result, _, _, _) =>
|
case fun @ Type.Function(args, result, _, _, _) =>
|
||||||
val funDep = asStatic(fun)
|
val funDep = asStatic(fun)
|
||||||
@ -420,7 +421,7 @@ case object DataflowAnalysis extends IRPass {
|
|||||||
args = args.map(analyseExpression(_, info)),
|
args = args.map(analyseExpression(_, info)),
|
||||||
result = analyseExpression(result, info)
|
result = analyseExpression(result, info)
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> info)
|
.updateMetadata(new MetadataPair(this, info))
|
||||||
case ctx @ Type.Context(typed, context, _, _, _) =>
|
case ctx @ Type.Context(typed, context, _, _, _) =>
|
||||||
val ctxDep = asStatic(ctx)
|
val ctxDep = asStatic(ctx)
|
||||||
val typedDep = asStatic(typed)
|
val typedDep = asStatic(typed)
|
||||||
@ -434,7 +435,7 @@ case object DataflowAnalysis extends IRPass {
|
|||||||
typed = analyseExpression(typed, info),
|
typed = analyseExpression(typed, info),
|
||||||
context = analyseExpression(context, info)
|
context = analyseExpression(context, info)
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> info)
|
.updateMetadata(new MetadataPair(this, info))
|
||||||
case err @ Type.Error(typed, error, _, _, _) =>
|
case err @ Type.Error(typed, error, _, _, _) =>
|
||||||
val errDep = asStatic(err)
|
val errDep = asStatic(err)
|
||||||
val typedDep = asStatic(typed)
|
val typedDep = asStatic(typed)
|
||||||
@ -448,7 +449,7 @@ case object DataflowAnalysis extends IRPass {
|
|||||||
typed = analyseExpression(typed, info),
|
typed = analyseExpression(typed, info),
|
||||||
error = analyseExpression(error, info)
|
error = analyseExpression(error, info)
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> info)
|
.updateMetadata(new MetadataPair(this, info))
|
||||||
case member @ `type`.Set.Member(_, memberType, value, _, _, _) =>
|
case member @ `type`.Set.Member(_, memberType, value, _, _, _) =>
|
||||||
val memberDep = asStatic(member)
|
val memberDep = asStatic(member)
|
||||||
val memberTypeDep = asStatic(memberType)
|
val memberTypeDep = asStatic(memberType)
|
||||||
@ -462,7 +463,7 @@ case object DataflowAnalysis extends IRPass {
|
|||||||
memberType = analyseExpression(memberType, info),
|
memberType = analyseExpression(memberType, info),
|
||||||
value = analyseExpression(value, info)
|
value = analyseExpression(value, info)
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> info)
|
.updateMetadata(new MetadataPair(this, info))
|
||||||
case concat @ `type`.Set.Concat(left, right, _, _, _) =>
|
case concat @ `type`.Set.Concat(left, right, _, _, _) =>
|
||||||
val concatDep = asStatic(concat)
|
val concatDep = asStatic(concat)
|
||||||
val leftDep = asStatic(left)
|
val leftDep = asStatic(left)
|
||||||
@ -476,7 +477,7 @@ case object DataflowAnalysis extends IRPass {
|
|||||||
left = analyseExpression(left, info),
|
left = analyseExpression(left, info),
|
||||||
right = analyseExpression(right, info)
|
right = analyseExpression(right, info)
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> info)
|
.updateMetadata(new MetadataPair(this, info))
|
||||||
case eq @ `type`.Set.Equality(left, right, _, _, _) =>
|
case eq @ `type`.Set.Equality(left, right, _, _, _) =>
|
||||||
val eqDep = asStatic(eq)
|
val eqDep = asStatic(eq)
|
||||||
val leftDep = asStatic(left)
|
val leftDep = asStatic(left)
|
||||||
@ -488,7 +489,7 @@ case object DataflowAnalysis extends IRPass {
|
|||||||
eq.copy(
|
eq.copy(
|
||||||
left = analyseExpression(left, info),
|
left = analyseExpression(left, info),
|
||||||
right = analyseExpression(right, info)
|
right = analyseExpression(right, info)
|
||||||
).updateMetadata(this -->> info)
|
).updateMetadata(new MetadataPair(this, info))
|
||||||
case intersect @ `type`.Set.Intersection(left, right, _, _, _) =>
|
case intersect @ `type`.Set.Intersection(left, right, _, _, _) =>
|
||||||
val intersectDep = asStatic(intersect)
|
val intersectDep = asStatic(intersect)
|
||||||
val leftDep = asStatic(left)
|
val leftDep = asStatic(left)
|
||||||
@ -502,7 +503,7 @@ case object DataflowAnalysis extends IRPass {
|
|||||||
left = analyseExpression(left, info),
|
left = analyseExpression(left, info),
|
||||||
right = analyseExpression(right, info)
|
right = analyseExpression(right, info)
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> info)
|
.updateMetadata(new MetadataPair(this, info))
|
||||||
case union @ `type`.Set.Union(operands, _, _, _) =>
|
case union @ `type`.Set.Union(operands, _, _, _) =>
|
||||||
val unionDep = asStatic(union)
|
val unionDep = asStatic(union)
|
||||||
val opDeps = operands.map(asStatic)
|
val opDeps = operands.map(asStatic)
|
||||||
@ -510,7 +511,7 @@ case object DataflowAnalysis extends IRPass {
|
|||||||
info.dependencies.updateAt(unionDep, opDeps.toSet)
|
info.dependencies.updateAt(unionDep, opDeps.toSet)
|
||||||
union
|
union
|
||||||
.copy(operands = operands.map(analyseExpression(_, info)))
|
.copy(operands = operands.map(analyseExpression(_, info)))
|
||||||
.updateMetadata(this -->> info)
|
.updateMetadata(new MetadataPair(this, info))
|
||||||
case subsumption @ `type`.Set.Subsumption(left, right, _, _, _) =>
|
case subsumption @ `type`.Set.Subsumption(left, right, _, _, _) =>
|
||||||
val subDep = asStatic(subsumption)
|
val subDep = asStatic(subsumption)
|
||||||
val leftDep = asStatic(left)
|
val leftDep = asStatic(left)
|
||||||
@ -524,7 +525,7 @@ case object DataflowAnalysis extends IRPass {
|
|||||||
left = analyseExpression(left, info),
|
left = analyseExpression(left, info),
|
||||||
right = analyseExpression(right, info)
|
right = analyseExpression(right, info)
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> info)
|
.updateMetadata(new MetadataPair(this, info))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,10 +542,13 @@ case object DataflowAnalysis extends IRPass {
|
|||||||
*/
|
*/
|
||||||
def analyseName(name: Name, info: DependencyInfo): Name = {
|
def analyseName(name: Name, info: DependencyInfo): Name = {
|
||||||
val aliasInfo = name.passData
|
val aliasInfo = name.passData
|
||||||
.getUnsafe(AliasAnalysis)(
|
.get(AliasAnalysis)
|
||||||
"Name occurrence with missing aliasing information."
|
.getOrElse(
|
||||||
|
throw new CompilerError(
|
||||||
|
"Name occurrence with missing aliasing information."
|
||||||
|
)
|
||||||
)
|
)
|
||||||
.unsafeAs[AliasAnalysis.Info.Occurrence]
|
.asInstanceOf[AliasAnalysis.Info.Occurrence]
|
||||||
|
|
||||||
name match {
|
name match {
|
||||||
case _: Name.Blank =>
|
case _: Name.Blank =>
|
||||||
@ -570,7 +574,7 @@ case object DataflowAnalysis extends IRPass {
|
|||||||
info.dependents.updateAt(key, Set(nameDep))
|
info.dependents.updateAt(key, Set(nameDep))
|
||||||
info.dependencies.updateAt(nameDep, Set(key))
|
info.dependencies.updateAt(nameDep, Set(key))
|
||||||
|
|
||||||
name.updateMetadata(this -->> info)
|
name.updateMetadata(new MetadataPair(this, info))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -602,7 +606,7 @@ case object DataflowAnalysis extends IRPass {
|
|||||||
scrutinee = analyseExpression(expr.scrutinee, info),
|
scrutinee = analyseExpression(expr.scrutinee, info),
|
||||||
branches = expr.branches.map(analyseCaseBranch(_, info))
|
branches = expr.branches.map(analyseCaseBranch(_, info))
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> info)
|
.updateMetadata(new MetadataPair(this, info))
|
||||||
case _: Case.Branch =>
|
case _: Case.Branch =>
|
||||||
throw new CompilerError("Unexpected case branch.")
|
throw new CompilerError("Unexpected case branch.")
|
||||||
}
|
}
|
||||||
@ -636,7 +640,7 @@ case object DataflowAnalysis extends IRPass {
|
|||||||
pattern = analysePattern(pattern, info),
|
pattern = analysePattern(pattern, info),
|
||||||
expression = analyseExpression(expression, info)
|
expression = analyseExpression(expression, info)
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> info)
|
.updateMetadata(new MetadataPair(this, info))
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Performs dataflow analysis on a case branch.
|
/** Performs dataflow analysis on a case branch.
|
||||||
@ -658,7 +662,7 @@ case object DataflowAnalysis extends IRPass {
|
|||||||
info.dependents.updateAt(nameDep, Set(patternDep))
|
info.dependents.updateAt(nameDep, Set(patternDep))
|
||||||
info.dependencies.updateAt(patternDep, Set(nameDep))
|
info.dependencies.updateAt(patternDep, Set(nameDep))
|
||||||
|
|
||||||
named.updateMetadata(this -->> info)
|
named.updateMetadata(new MetadataPair(this, info))
|
||||||
case cons @ Pattern.Constructor(constructor, fields, _, _, _) =>
|
case cons @ Pattern.Constructor(constructor, fields, _, _, _) =>
|
||||||
val consDep = asStatic(constructor)
|
val consDep = asStatic(constructor)
|
||||||
info.dependents.updateAt(consDep, Set(patternDep))
|
info.dependents.updateAt(consDep, Set(patternDep))
|
||||||
@ -674,9 +678,9 @@ case object DataflowAnalysis extends IRPass {
|
|||||||
constructor = analyseName(constructor, info),
|
constructor = analyseName(constructor, info),
|
||||||
fields = fields.map(analysePattern(_, info))
|
fields = fields.map(analysePattern(_, info))
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> info)
|
.updateMetadata(new MetadataPair(this, info))
|
||||||
case literal: Pattern.Literal =>
|
case literal: Pattern.Literal =>
|
||||||
literal.updateMetadata(this -->> info)
|
literal.updateMetadata(new MetadataPair(this, info))
|
||||||
case Pattern.Type(name, tpe, _, _, _) =>
|
case Pattern.Type(name, tpe, _, _, _) =>
|
||||||
val nameDep = asStatic(name)
|
val nameDep = asStatic(name)
|
||||||
info.dependents.updateAt(nameDep, Set(patternDep))
|
info.dependents.updateAt(nameDep, Set(patternDep))
|
||||||
@ -685,12 +689,13 @@ case object DataflowAnalysis extends IRPass {
|
|||||||
info.dependents.updateAt(tpeDep, Set(patternDep))
|
info.dependents.updateAt(tpeDep, Set(patternDep))
|
||||||
info.dependencies.updateAt(patternDep, Set(tpeDep))
|
info.dependencies.updateAt(patternDep, Set(tpeDep))
|
||||||
|
|
||||||
pattern.updateMetadata(this -->> info)
|
pattern.updateMetadata(new MetadataPair(this, info))
|
||||||
case _: Pattern.Documentation =>
|
case _: Pattern.Documentation =>
|
||||||
throw new CompilerError(
|
throw new CompilerError(
|
||||||
"Branch documentation should be desugared at an earlier stage."
|
"Branch documentation should be desugared at an earlier stage."
|
||||||
)
|
)
|
||||||
case err: errors.Pattern => err.updateMetadata(this -->> info)
|
case err: errors.Pattern =>
|
||||||
|
err.updateMetadata(new MetadataPair(this, info))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -720,7 +725,7 @@ case object DataflowAnalysis extends IRPass {
|
|||||||
.copy(
|
.copy(
|
||||||
defaultValue = defValue.map(analyseExpression(_, info))
|
defaultValue = defValue.map(analyseExpression(_, info))
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> info)
|
.updateMetadata(new MetadataPair(this, info))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -753,7 +758,7 @@ case object DataflowAnalysis extends IRPass {
|
|||||||
.copy(
|
.copy(
|
||||||
value = analyseExpression(value, info)
|
value = analyseExpression(value, info)
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> info)
|
.updateMetadata(new MetadataPair(this, info))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ case object GatherDiagnostics extends IRPass {
|
|||||||
ir: Module,
|
ir: Module,
|
||||||
moduleContext: ModuleContext
|
moduleContext: ModuleContext
|
||||||
): Module =
|
): Module =
|
||||||
ir.updateMetadata(this -->> gatherMetadata(ir))
|
ir.updateMetadata(new MetadataPair(this, gatherMetadata(ir)))
|
||||||
|
|
||||||
/** Executes the pass on the provided `ir`, and attaches all the encountered
|
/** Executes the pass on the provided `ir`, and attaches all the encountered
|
||||||
* diagnostics to its metadata storage.
|
* diagnostics to its metadata storage.
|
||||||
@ -54,7 +54,7 @@ case object GatherDiagnostics extends IRPass {
|
|||||||
override def runExpression(
|
override def runExpression(
|
||||||
ir: Expression,
|
ir: Expression,
|
||||||
inlineContext: InlineContext
|
inlineContext: InlineContext
|
||||||
): Expression = ir.updateMetadata(this -->> gatherMetadata(ir))
|
): Expression = ir.updateMetadata(new MetadataPair(this, gatherMetadata(ir)))
|
||||||
|
|
||||||
/** Gathers diagnostics from all children of an IR node.
|
/** Gathers diagnostics from all children of an IR node.
|
||||||
*
|
*
|
||||||
|
@ -112,21 +112,23 @@ case object TailCall extends IRPass {
|
|||||||
.copy(
|
.copy(
|
||||||
body = analyseExpression(method.body, isInTailPosition = true)
|
body = analyseExpression(method.body, isInTailPosition = true)
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> TailPosition.Tail)
|
.updateMetadata(new MetadataPair(this, TailPosition.Tail))
|
||||||
case method @ definition.Method
|
case method @ definition.Method
|
||||||
.Explicit(_, body, _, _, _) =>
|
.Explicit(_, body, _, _, _) =>
|
||||||
method
|
method
|
||||||
.copy(
|
.copy(
|
||||||
body = analyseExpression(body, isInTailPosition = true)
|
body = analyseExpression(body, isInTailPosition = true)
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> TailPosition.Tail)
|
.updateMetadata(new MetadataPair(this, TailPosition.Tail))
|
||||||
case _: definition.Method.Binding =>
|
case _: definition.Method.Binding =>
|
||||||
throw new CompilerError(
|
throw new CompilerError(
|
||||||
"Sugared method definitions should not occur during tail call " +
|
"Sugared method definitions should not occur during tail call " +
|
||||||
"analysis."
|
"analysis."
|
||||||
)
|
)
|
||||||
case _: Definition.Type =>
|
case _: Definition.Type =>
|
||||||
moduleDefinition.updateMetadata(this -->> TailPosition.Tail)
|
moduleDefinition.updateMetadata(
|
||||||
|
new MetadataPair(this, TailPosition.Tail)
|
||||||
|
)
|
||||||
case _: Definition.SugaredType =>
|
case _: Definition.SugaredType =>
|
||||||
throw new CompilerError(
|
throw new CompilerError(
|
||||||
"Complex type definitions should not be present during " +
|
"Complex type definitions should not be present during " +
|
||||||
@ -151,7 +153,7 @@ case object TailCall extends IRPass {
|
|||||||
.copy(expression =
|
.copy(expression =
|
||||||
analyseExpression(ann.expression, isInTailPosition = true)
|
analyseExpression(ann.expression, isInTailPosition = true)
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> TailPosition.Tail)
|
.updateMetadata(new MetadataPair(this, TailPosition.Tail))
|
||||||
case err: Error => err
|
case err: Error => err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -173,7 +175,7 @@ case object TailCall extends IRPass {
|
|||||||
else expression
|
else expression
|
||||||
expressionWithWarning match {
|
expressionWithWarning match {
|
||||||
case empty: Empty =>
|
case empty: Empty =>
|
||||||
empty.updateMetadata(this -->> TailPosition.NotTail)
|
empty.updateMetadata(new MetadataPair(this, TailPosition.NotTail))
|
||||||
case function: Function =>
|
case function: Function =>
|
||||||
analyseFunction(function, isInTailPosition)
|
analyseFunction(function, isInTailPosition)
|
||||||
case caseExpr: Case => analyseCase(caseExpr, isInTailPosition)
|
case caseExpr: Case => analyseCase(caseExpr, isInTailPosition)
|
||||||
@ -181,7 +183,7 @@ case object TailCall extends IRPass {
|
|||||||
case app: Application => analyseApplication(app, isInTailPosition)
|
case app: Application => analyseApplication(app, isInTailPosition)
|
||||||
case name: Name => analyseName(name, isInTailPosition)
|
case name: Name => analyseName(name, isInTailPosition)
|
||||||
case foreign: Foreign =>
|
case foreign: Foreign =>
|
||||||
foreign.updateMetadata(this -->> TailPosition.NotTail)
|
foreign.updateMetadata(new MetadataPair(this, TailPosition.NotTail))
|
||||||
case literal: Literal => analyseLiteral(literal, isInTailPosition)
|
case literal: Literal => analyseLiteral(literal, isInTailPosition)
|
||||||
case _: Comment =>
|
case _: Comment =>
|
||||||
throw new CompilerError(
|
throw new CompilerError(
|
||||||
@ -202,16 +204,20 @@ case object TailCall extends IRPass {
|
|||||||
),
|
),
|
||||||
returnValue = analyseExpression(returnValue, isInTailPosition)
|
returnValue = analyseExpression(returnValue, isInTailPosition)
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> TailPosition.fromBool(isInTailPosition))
|
.updateMetadata(
|
||||||
|
new MetadataPair(this, TailPosition.fromBool(isInTailPosition))
|
||||||
|
)
|
||||||
case binding @ Expression.Binding(_, expression, _, _, _) =>
|
case binding @ Expression.Binding(_, expression, _, _, _) =>
|
||||||
binding
|
binding
|
||||||
.copy(
|
.copy(
|
||||||
expression = analyseExpression(expression, isInTailPosition = false)
|
expression = analyseExpression(expression, isInTailPosition = false)
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> TailPosition.fromBool(isInTailPosition))
|
.updateMetadata(
|
||||||
|
new MetadataPair(this, TailPosition.fromBool(isInTailPosition))
|
||||||
|
)
|
||||||
case err: Diagnostic =>
|
case err: Diagnostic =>
|
||||||
err.updateMetadata(
|
err.updateMetadata(
|
||||||
this -->> TailPosition.fromBool(isInTailPosition)
|
new MetadataPair(this, TailPosition.fromBool(isInTailPosition))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -223,7 +229,9 @@ case object TailCall extends IRPass {
|
|||||||
* @return `name`, annotated with tail position metadata
|
* @return `name`, annotated with tail position metadata
|
||||||
*/
|
*/
|
||||||
def analyseName(name: Name, isInTailPosition: Boolean): Name = {
|
def analyseName(name: Name, isInTailPosition: Boolean): Name = {
|
||||||
name.updateMetadata(this -->> TailPosition.fromBool(isInTailPosition))
|
name.updateMetadata(
|
||||||
|
new MetadataPair(this, TailPosition.fromBool(isInTailPosition))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Performs tail call analysis on a literal.
|
/** Performs tail call analysis on a literal.
|
||||||
@ -237,7 +245,9 @@ case object TailCall extends IRPass {
|
|||||||
literal: Literal,
|
literal: Literal,
|
||||||
isInTailPosition: Boolean
|
isInTailPosition: Boolean
|
||||||
): Literal = {
|
): Literal = {
|
||||||
literal.updateMetadata(this -->> TailPosition.fromBool(isInTailPosition))
|
literal.updateMetadata(
|
||||||
|
new MetadataPair(this, TailPosition.fromBool(isInTailPosition))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Performs tail call analysis on an application.
|
/** Performs tail call analysis on an application.
|
||||||
@ -258,25 +268,33 @@ case object TailCall extends IRPass {
|
|||||||
function = analyseExpression(fn, isInTailPosition = false),
|
function = analyseExpression(fn, isInTailPosition = false),
|
||||||
arguments = args.map(analyseCallArg)
|
arguments = args.map(analyseCallArg)
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> TailPosition.fromBool(isInTailPosition))
|
.updateMetadata(
|
||||||
|
new MetadataPair(this, TailPosition.fromBool(isInTailPosition))
|
||||||
|
)
|
||||||
case force @ Application.Force(target, _, _, _) =>
|
case force @ Application.Force(target, _, _, _) =>
|
||||||
force
|
force
|
||||||
.copy(
|
.copy(
|
||||||
target = analyseExpression(target, isInTailPosition)
|
target = analyseExpression(target, isInTailPosition)
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> TailPosition.fromBool(isInTailPosition))
|
.updateMetadata(
|
||||||
|
new MetadataPair(this, TailPosition.fromBool(isInTailPosition))
|
||||||
|
)
|
||||||
case vector @ Application.Sequence(items, _, _, _) =>
|
case vector @ Application.Sequence(items, _, _, _) =>
|
||||||
vector
|
vector
|
||||||
.copy(items =
|
.copy(items =
|
||||||
items.map(analyseExpression(_, isInTailPosition = false))
|
items.map(analyseExpression(_, isInTailPosition = false))
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> TailPosition.fromBool(isInTailPosition))
|
.updateMetadata(
|
||||||
|
new MetadataPair(this, TailPosition.fromBool(isInTailPosition))
|
||||||
|
)
|
||||||
case tSet @ Application.Typeset(expr, _, _, _) =>
|
case tSet @ Application.Typeset(expr, _, _, _) =>
|
||||||
tSet
|
tSet
|
||||||
.copy(expression =
|
.copy(expression =
|
||||||
expr.map(analyseExpression(_, isInTailPosition = false))
|
expr.map(analyseExpression(_, isInTailPosition = false))
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> TailPosition.fromBool(isInTailPosition))
|
.updateMetadata(
|
||||||
|
new MetadataPair(this, TailPosition.fromBool(isInTailPosition))
|
||||||
|
)
|
||||||
case _: Operator =>
|
case _: Operator =>
|
||||||
throw new CompilerError("Unexpected binary operator.")
|
throw new CompilerError("Unexpected binary operator.")
|
||||||
}
|
}
|
||||||
@ -295,7 +313,7 @@ case object TailCall extends IRPass {
|
|||||||
// Note [Call Argument Tail Position]
|
// Note [Call Argument Tail Position]
|
||||||
value = analyseExpression(expr, isInTailPosition = true)
|
value = analyseExpression(expr, isInTailPosition = true)
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> TailPosition.Tail)
|
.updateMetadata(new MetadataPair(this, TailPosition.Tail))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,7 +350,9 @@ case object TailCall extends IRPass {
|
|||||||
def analyseType(value: Type, isInTailPosition: Boolean): Type = {
|
def analyseType(value: Type, isInTailPosition: Boolean): Type = {
|
||||||
value
|
value
|
||||||
.mapExpressions(analyseExpression(_, isInTailPosition = false))
|
.mapExpressions(analyseExpression(_, isInTailPosition = false))
|
||||||
.updateMetadata(this -->> TailPosition.fromBool(isInTailPosition))
|
.updateMetadata(
|
||||||
|
new MetadataPair(this, TailPosition.fromBool(isInTailPosition))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Performs tail call analysis on a case expression.
|
/** Performs tail call analysis on a case expression.
|
||||||
@ -351,7 +371,9 @@ case object TailCall extends IRPass {
|
|||||||
// Note [Analysing Branches in Case Expressions]
|
// Note [Analysing Branches in Case Expressions]
|
||||||
branches = branches.map(analyseCaseBranch(_, isInTailPosition))
|
branches = branches.map(analyseCaseBranch(_, isInTailPosition))
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> TailPosition.fromBool(isInTailPosition))
|
.updateMetadata(
|
||||||
|
new MetadataPair(this, TailPosition.fromBool(isInTailPosition))
|
||||||
|
)
|
||||||
case _: Case.Branch =>
|
case _: Case.Branch =>
|
||||||
throw new CompilerError("Unexpected case branch.")
|
throw new CompilerError("Unexpected case branch.")
|
||||||
}
|
}
|
||||||
@ -387,7 +409,9 @@ case object TailCall extends IRPass {
|
|||||||
isInTailPosition
|
isInTailPosition
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> TailPosition.fromBool(isInTailPosition))
|
.updateMetadata(
|
||||||
|
new MetadataPair(this, TailPosition.fromBool(isInTailPosition))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Performs tail call analysis on a pattern.
|
/** Performs tail call analysis on a pattern.
|
||||||
@ -404,17 +428,17 @@ case object TailCall extends IRPass {
|
|||||||
.copy(
|
.copy(
|
||||||
name = analyseName(name, isInTailPosition = false)
|
name = analyseName(name, isInTailPosition = false)
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> TailPosition.NotTail)
|
.updateMetadata(new MetadataPair(this, TailPosition.NotTail))
|
||||||
case cons @ Pattern.Constructor(constructor, fields, _, _, _) =>
|
case cons @ Pattern.Constructor(constructor, fields, _, _, _) =>
|
||||||
cons
|
cons
|
||||||
.copy(
|
.copy(
|
||||||
constructor = analyseName(constructor, isInTailPosition = false),
|
constructor = analyseName(constructor, isInTailPosition = false),
|
||||||
fields = fields.map(analysePattern)
|
fields = fields.map(analysePattern)
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> TailPosition.NotTail)
|
.updateMetadata(new MetadataPair(this, TailPosition.NotTail))
|
||||||
case literal: Pattern.Literal =>
|
case literal: Pattern.Literal =>
|
||||||
literal
|
literal
|
||||||
.updateMetadata(this -->> TailPosition.NotTail)
|
.updateMetadata(new MetadataPair(this, TailPosition.NotTail))
|
||||||
case tpePattern @ Pattern.Type(name, tpe, _, _, _) =>
|
case tpePattern @ Pattern.Type(name, tpe, _, _, _) =>
|
||||||
tpePattern
|
tpePattern
|
||||||
.copy(
|
.copy(
|
||||||
@ -422,7 +446,7 @@ case object TailCall extends IRPass {
|
|||||||
tpe = analyseName(tpe, isInTailPosition = false)
|
tpe = analyseName(tpe, isInTailPosition = false)
|
||||||
)
|
)
|
||||||
case err: errors.Pattern =>
|
case err: errors.Pattern =>
|
||||||
err.updateMetadata(this -->> TailPosition.NotTail)
|
err.updateMetadata(new MetadataPair(this, TailPosition.NotTail))
|
||||||
case _: Pattern.Documentation =>
|
case _: Pattern.Documentation =>
|
||||||
throw new CompilerError(
|
throw new CompilerError(
|
||||||
"Branch documentation should be desugared at an earlier stage."
|
"Branch documentation should be desugared at an earlier stage."
|
||||||
@ -457,7 +481,7 @@ case object TailCall extends IRPass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
resultFunction.updateMetadata(
|
resultFunction.updateMetadata(
|
||||||
this -->> TailPosition.fromBool(isInTailPosition)
|
new MetadataPair(this, TailPosition.fromBool(isInTailPosition))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -473,10 +497,10 @@ case object TailCall extends IRPass {
|
|||||||
.copy(
|
.copy(
|
||||||
defaultValue = default.map(x =>
|
defaultValue = default.map(x =>
|
||||||
analyseExpression(x, isInTailPosition = false)
|
analyseExpression(x, isInTailPosition = false)
|
||||||
.updateMetadata(this -->> TailPosition.NotTail)
|
.updateMetadata(new MetadataPair(this, TailPosition.NotTail))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> TailPosition.NotTail)
|
.updateMetadata(new MetadataPair(this, TailPosition.NotTail))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +136,10 @@ case object ComplexType extends IRPass {
|
|||||||
.map(_.annotations)
|
.map(_.annotations)
|
||||||
.getOrElse(Nil)
|
.getOrElse(Nil)
|
||||||
atom.updateMetadata(
|
atom.updateMetadata(
|
||||||
ModuleAnnotations -->> ann.copy(ann.annotations ++ old)
|
new MetadataPair(
|
||||||
|
ModuleAnnotations,
|
||||||
|
ann.copy(ann.annotations ++ old)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.getOrElse(atom)
|
.getOrElse(atom)
|
||||||
@ -212,13 +215,17 @@ case object ComplexType extends IRPass {
|
|||||||
)
|
)
|
||||||
|
|
||||||
val withAnnotations = annotations
|
val withAnnotations = annotations
|
||||||
.map(ann => sumType.updateMetadata(ModuleAnnotations -->> ann))
|
.map(ann =>
|
||||||
|
sumType.updateMetadata(new MetadataPair(ModuleAnnotations, ann))
|
||||||
|
)
|
||||||
.getOrElse(sumType)
|
.getOrElse(sumType)
|
||||||
|
|
||||||
val withDoc = typ
|
val withDoc = typ
|
||||||
.getMetadata(DocumentationComments)
|
.getMetadata(DocumentationComments)
|
||||||
.map(ann =>
|
.map(ann =>
|
||||||
withAnnotations.updateMetadata(DocumentationComments -->> ann)
|
withAnnotations.updateMetadata(
|
||||||
|
new MetadataPair(DocumentationComments, ann)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
.getOrElse(sumType)
|
.getOrElse(sumType)
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ import org.enso.compiler.core.ir.{
|
|||||||
Name,
|
Name,
|
||||||
Type
|
Type
|
||||||
}
|
}
|
||||||
import org.enso.compiler.core.ir.MetadataStorage.ToPair
|
import org.enso.compiler.core.ir.MetadataStorage.MetadataPair
|
||||||
import org.enso.compiler.core.CompilerError
|
import org.enso.compiler.core.CompilerError
|
||||||
import org.enso.compiler.pass.IRPass
|
import org.enso.compiler.pass.IRPass
|
||||||
import org.enso.compiler.pass.analyse.{
|
import org.enso.compiler.pass.analyse.{
|
||||||
@ -192,7 +192,10 @@ case object FunctionBinding extends IRPass {
|
|||||||
firstArg
|
firstArg
|
||||||
.withName(newName)
|
.withName(newName)
|
||||||
.updateMetadata(
|
.updateMetadata(
|
||||||
IgnoredBindings -->> IgnoredBindings.State.Ignored
|
new MetadataPair(
|
||||||
|
IgnoredBindings,
|
||||||
|
IgnoredBindings.State.Ignored
|
||||||
|
)
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
firstArg
|
firstArg
|
||||||
@ -212,7 +215,10 @@ case object FunctionBinding extends IRPass {
|
|||||||
snd
|
snd
|
||||||
.withName(newName)
|
.withName(newName)
|
||||||
.updateMetadata(
|
.updateMetadata(
|
||||||
IgnoredBindings -->> IgnoredBindings.State.Ignored
|
new MetadataPair(
|
||||||
|
IgnoredBindings,
|
||||||
|
IgnoredBindings.State.Ignored
|
||||||
|
)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
rest
|
rest
|
||||||
|
@ -108,8 +108,9 @@ case object DocumentationComments extends IRPass {
|
|||||||
None
|
None
|
||||||
case other =>
|
case other =>
|
||||||
val res = lastDoc match {
|
val res = lastDoc match {
|
||||||
case Some(doc) => other.updateMetadata(this -->> Doc(doc.doc))
|
case Some(doc) =>
|
||||||
case None => other
|
other.updateMetadata(new MetadataPair(this, Doc(doc.doc)))
|
||||||
|
case None => other
|
||||||
}
|
}
|
||||||
lastDoc = None
|
lastDoc = None
|
||||||
Some(res)
|
Some(res)
|
||||||
@ -135,8 +136,9 @@ case object DocumentationComments extends IRPass {
|
|||||||
expression = resolveExpression(expression)
|
expression = resolveExpression(expression)
|
||||||
)
|
)
|
||||||
val res = lastDoc match {
|
val res = lastDoc match {
|
||||||
case Some(doc) => resolved.updateMetadata(this -->> Doc(doc))
|
case Some(doc) =>
|
||||||
case None => resolved
|
resolved.updateMetadata(new MetadataPair(this, Doc(doc)))
|
||||||
|
case None => resolved
|
||||||
}
|
}
|
||||||
lastDoc = None
|
lastDoc = None
|
||||||
Some(res)
|
Some(res)
|
||||||
@ -203,7 +205,7 @@ case object DocumentationComments extends IRPass {
|
|||||||
}
|
}
|
||||||
val newBindings = (allModuleEntities.headOption match {
|
val newBindings = (allModuleEntities.headOption match {
|
||||||
case Some(doc: Comment.Documentation) =>
|
case Some(doc: Comment.Documentation) =>
|
||||||
ir.updateMetadata(this -->> Doc(doc.doc))
|
ir.updateMetadata(new MetadataPair(this, Doc(doc.doc)))
|
||||||
resolveList(ir.bindings.drop(1))
|
resolveList(ir.bindings.drop(1))
|
||||||
case _ => resolveList(ir.bindings)
|
case _ => resolveList(ir.bindings)
|
||||||
}).map(resolveDefinition)
|
}).map(resolveDefinition)
|
||||||
|
@ -4,7 +4,7 @@ import org.enso.compiler.context.{InlineContext, ModuleContext}
|
|||||||
import org.enso.compiler.core.Implicits.AsMetadata
|
import org.enso.compiler.core.Implicits.AsMetadata
|
||||||
import org.enso.compiler.core.ir.{Expression, Module}
|
import org.enso.compiler.core.ir.{Expression, Module}
|
||||||
import org.enso.compiler.core.ir.Name
|
import org.enso.compiler.core.ir.Name
|
||||||
import org.enso.compiler.core.ir.MetadataStorage.ToPair
|
import org.enso.compiler.core.ir.MetadataStorage.MetadataPair
|
||||||
import org.enso.compiler.core.ir.expression.Application
|
import org.enso.compiler.core.ir.expression.Application
|
||||||
import org.enso.compiler.core.ir.expression.errors
|
import org.enso.compiler.core.ir.expression.errors
|
||||||
import org.enso.compiler.pass.IRPass
|
import org.enso.compiler.pass.IRPass
|
||||||
@ -84,7 +84,7 @@ case object ExpressionAnnotations extends IRPass {
|
|||||||
)
|
)
|
||||||
case List(arg) =>
|
case List(arg) =>
|
||||||
doExpression(arg.value)
|
doExpression(arg.value)
|
||||||
.updateMetadata(this -->> Annotations(Seq(ann)))
|
.updateMetadata(new MetadataPair(this, Annotations(Seq(ann))))
|
||||||
case realFun :: args =>
|
case realFun :: args =>
|
||||||
val recurFun = doExpression(realFun.value)
|
val recurFun = doExpression(realFun.value)
|
||||||
val (finalFun, preArgs) = recurFun match {
|
val (finalFun, preArgs) = recurFun match {
|
||||||
@ -95,7 +95,7 @@ case object ExpressionAnnotations extends IRPass {
|
|||||||
val recurArgs = args.map(_.mapExpressions(doExpression))
|
val recurArgs = args.map(_.mapExpressions(doExpression))
|
||||||
app
|
app
|
||||||
.copy(function = finalFun, arguments = preArgs ++ recurArgs)
|
.copy(function = finalFun, arguments = preArgs ++ recurArgs)
|
||||||
.updateMetadata(this -->> Annotations(Seq(ann)))
|
.updateMetadata(new MetadataPair(this, Annotations(Seq(ann))))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
val err =
|
val err =
|
||||||
|
@ -13,7 +13,7 @@ import org.enso.compiler.core.ir.module.scope.Export
|
|||||||
import org.enso.compiler.core.ir.module.scope.definition
|
import org.enso.compiler.core.ir.module.scope.definition
|
||||||
import org.enso.compiler.core.ir.expression.errors
|
import org.enso.compiler.core.ir.expression.errors
|
||||||
import org.enso.compiler.core.ir.expression.warnings
|
import org.enso.compiler.core.ir.expression.warnings
|
||||||
import org.enso.compiler.core.ir.MetadataStorage.ToPair
|
import org.enso.compiler.core.ir.MetadataStorage.MetadataPair
|
||||||
import org.enso.compiler.data.BindingsMap
|
import org.enso.compiler.data.BindingsMap
|
||||||
import org.enso.compiler.data.BindingsMap.{
|
import org.enso.compiler.data.BindingsMap.{
|
||||||
ExportedModule,
|
ExportedModule,
|
||||||
@ -239,7 +239,10 @@ case object FullyQualifiedNames extends IRPass {
|
|||||||
.getOrElse(false)
|
.getOrElse(false)
|
||||||
) {
|
) {
|
||||||
lit.updateMetadata(
|
lit.updateMetadata(
|
||||||
this -->> FQNResolution(ResolvedLibrary(lit.name))
|
new MetadataPair(
|
||||||
|
this,
|
||||||
|
FQNResolution(ResolvedLibrary(lit.name))
|
||||||
|
)
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
lit
|
lit
|
||||||
@ -329,7 +332,7 @@ case object FullyQualifiedNames extends IRPass {
|
|||||||
_.map(resolvedMod =>
|
_.map(resolvedMod =>
|
||||||
freshNameSupply
|
freshNameSupply
|
||||||
.newName(from = Some(name))
|
.newName(from = Some(name))
|
||||||
.updateMetadata(this -->> resolvedMod)
|
.updateMetadata(new MetadataPair(this, resolvedMod))
|
||||||
.setLocation(name.location)
|
.setLocation(name.location)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -60,7 +60,10 @@ case object GenericAnnotations extends IRPass {
|
|||||||
case entity =>
|
case entity =>
|
||||||
val res = Some(
|
val res = Some(
|
||||||
entity.updateMetadata(
|
entity.updateMetadata(
|
||||||
this -->> ModuleAnnotations.Annotations(lastAnnotations)
|
new MetadataPair(
|
||||||
|
this,
|
||||||
|
ModuleAnnotations.Annotations(lastAnnotations)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
lastAnnotations = Seq()
|
lastAnnotations = Seq()
|
||||||
|
@ -13,7 +13,7 @@ import org.enso.compiler.core.ir.{
|
|||||||
}
|
}
|
||||||
import org.enso.compiler.core.ir.module.scope.Definition
|
import org.enso.compiler.core.ir.module.scope.Definition
|
||||||
import org.enso.compiler.core.ir.module.scope.definition
|
import org.enso.compiler.core.ir.module.scope.definition
|
||||||
import org.enso.compiler.core.ir.MetadataStorage.ToPair
|
import org.enso.compiler.core.ir.MetadataStorage.MetadataPair
|
||||||
import org.enso.compiler.core.ir.expression.errors
|
import org.enso.compiler.core.ir.expression.errors
|
||||||
import org.enso.compiler.data.BindingsMap
|
import org.enso.compiler.data.BindingsMap
|
||||||
import org.enso.compiler.data.BindingsMap.{
|
import org.enso.compiler.data.BindingsMap.{
|
||||||
@ -151,7 +151,7 @@ case object GlobalNames extends IRPass {
|
|||||||
ir.transformExpressions {
|
ir.transformExpressions {
|
||||||
case selfTp: Name.SelfType =>
|
case selfTp: Name.SelfType =>
|
||||||
selfTypeResolution
|
selfTypeResolution
|
||||||
.map(res => selfTp.updateMetadata(this -->> res))
|
.map(res => selfTp.updateMetadata(new MetadataPair(this, res)))
|
||||||
.getOrElse(
|
.getOrElse(
|
||||||
errors.Resolution(
|
errors.Resolution(
|
||||||
selfTp,
|
selfTp,
|
||||||
@ -168,7 +168,9 @@ case object GlobalNames extends IRPass {
|
|||||||
FullyQualifiedNames.ResolvedModule(modRef)
|
FullyQualifiedNames.ResolvedModule(modRef)
|
||||||
)
|
)
|
||||||
) =>
|
) =>
|
||||||
lit.updateMetadata(this -->> Resolution(ResolvedModule(modRef)))
|
lit.updateMetadata(
|
||||||
|
new MetadataPair(this, Resolution(ResolvedModule(modRef)))
|
||||||
|
)
|
||||||
case _ =>
|
case _ =>
|
||||||
if (!lit.isMethod && !isLocalVar(lit)) {
|
if (!lit.isMethod && !isLocalVar(lit)) {
|
||||||
val resolution = bindings.resolveName(lit.name)
|
val resolution = bindings.resolveName(lit.name)
|
||||||
@ -180,13 +182,18 @@ case object GlobalNames extends IRPass {
|
|||||||
)
|
)
|
||||||
case Right(r @ BindingsMap.ResolvedMethod(mod, method)) =>
|
case Right(r @ BindingsMap.ResolvedMethod(mod, method)) =>
|
||||||
if (isInsideApplication) {
|
if (isInsideApplication) {
|
||||||
lit.updateMetadata(this -->> BindingsMap.Resolution(r))
|
lit.updateMetadata(
|
||||||
|
new MetadataPair(this, BindingsMap.Resolution(r))
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
val self = freshNameSupply
|
val self = freshNameSupply
|
||||||
.newName()
|
.newName()
|
||||||
.updateMetadata(
|
.updateMetadata(
|
||||||
this -->> BindingsMap.Resolution(
|
new MetadataPair(
|
||||||
BindingsMap.ResolvedModule(mod)
|
this,
|
||||||
|
BindingsMap.Resolution(
|
||||||
|
BindingsMap.ResolvedModule(mod)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
// The synthetic applications gets the location so that instrumentation
|
// The synthetic applications gets the location so that instrumentation
|
||||||
@ -205,14 +212,19 @@ case object GlobalNames extends IRPass {
|
|||||||
.getMetadata(ExpressionAnnotations)
|
.getMetadata(ExpressionAnnotations)
|
||||||
.foreach(annotationsMeta =>
|
.foreach(annotationsMeta =>
|
||||||
app.updateMetadata(
|
app.updateMetadata(
|
||||||
ExpressionAnnotations -->> annotationsMeta
|
new MetadataPair(
|
||||||
|
ExpressionAnnotations,
|
||||||
|
annotationsMeta
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
fun.passData.remove(ExpressionAnnotations)
|
fun.passData.remove(ExpressionAnnotations)
|
||||||
app
|
app
|
||||||
}
|
}
|
||||||
case Right(value) =>
|
case Right(value) =>
|
||||||
lit.updateMetadata(this -->> BindingsMap.Resolution(value))
|
lit.updateMetadata(
|
||||||
|
new MetadataPair(this, BindingsMap.Resolution(value))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -288,8 +300,11 @@ case object GlobalNames extends IRPass {
|
|||||||
val self = freshNameSupply
|
val self = freshNameSupply
|
||||||
.newName()
|
.newName()
|
||||||
.updateMetadata(
|
.updateMetadata(
|
||||||
this -->> BindingsMap.Resolution(
|
new MetadataPair(
|
||||||
BindingsMap.ResolvedModule(mod)
|
this,
|
||||||
|
BindingsMap.Resolution(
|
||||||
|
BindingsMap.ResolvedModule(mod)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
val selfArg = CallArgument.Specified(None, self, None)
|
val selfArg = CallArgument.Specified(None, self, None)
|
||||||
@ -374,7 +389,7 @@ case object GlobalNames extends IRPass {
|
|||||||
): Expression = {
|
): Expression = {
|
||||||
freshNameSupply
|
freshNameSupply
|
||||||
.newName()
|
.newName()
|
||||||
.updateMetadata(this -->> BindingsMap.Resolution(cons))
|
.updateMetadata(new MetadataPair(this, BindingsMap.Resolution(cons)))
|
||||||
}
|
}
|
||||||
|
|
||||||
private def resolveQualName(
|
private def resolveQualName(
|
||||||
|
@ -104,7 +104,7 @@ case object IgnoredBindings extends IRPass {
|
|||||||
|
|
||||||
private def setNotIgnored[T <: IR](ir: T): T = {
|
private def setNotIgnored[T <: IR](ir: T): T = {
|
||||||
if (ir.getMetadata(this).isEmpty) {
|
if (ir.getMetadata(this).isEmpty) {
|
||||||
ir.updateMetadata(this -->> State.NotIgnored)
|
ir.updateMetadata(new MetadataPair(this, State.NotIgnored))
|
||||||
} else {
|
} else {
|
||||||
ir
|
ir
|
||||||
}
|
}
|
||||||
@ -153,7 +153,7 @@ case object IgnoredBindings extends IRPass {
|
|||||||
name = newName,
|
name = newName,
|
||||||
expression = resolveExpression(binding.expression, supply)
|
expression = resolveExpression(binding.expression, supply)
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> State.Ignored)
|
.updateMetadata(new MetadataPair(this, State.Ignored))
|
||||||
} else {
|
} else {
|
||||||
setNotIgnored(
|
setNotIgnored(
|
||||||
binding
|
binding
|
||||||
@ -223,7 +223,7 @@ case object IgnoredBindings extends IRPass {
|
|||||||
.copy(defaultValue =
|
.copy(defaultValue =
|
||||||
spec.defaultValue.map(resolveExpression(_, freshNameSupply))
|
spec.defaultValue.map(resolveExpression(_, freshNameSupply))
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> State.Ignored)
|
.updateMetadata(new MetadataPair(this, State.Ignored))
|
||||||
case spec: DefinitionArgument.Specified =>
|
case spec: DefinitionArgument.Specified =>
|
||||||
if (isIgnored) {
|
if (isIgnored) {
|
||||||
val newName = freshNameSupply
|
val newName = freshNameSupply
|
||||||
@ -240,7 +240,7 @@ case object IgnoredBindings extends IRPass {
|
|||||||
defaultValue =
|
defaultValue =
|
||||||
spec.defaultValue.map(resolveExpression(_, freshNameSupply))
|
spec.defaultValue.map(resolveExpression(_, freshNameSupply))
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> State.Ignored)
|
.updateMetadata(new MetadataPair(this, State.Ignored))
|
||||||
} else {
|
} else {
|
||||||
setNotIgnored(
|
setNotIgnored(
|
||||||
spec
|
spec
|
||||||
@ -334,7 +334,7 @@ case object IgnoredBindings extends IRPass {
|
|||||||
passData = name.passData,
|
passData = name.passData,
|
||||||
diagnostics = name.diagnostics
|
diagnostics = name.diagnostics
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> State.Ignored)
|
.updateMetadata(new MetadataPair(this, State.Ignored))
|
||||||
|
|
||||||
named.copy(
|
named.copy(
|
||||||
name = newName
|
name = newName
|
||||||
@ -358,7 +358,7 @@ case object IgnoredBindings extends IRPass {
|
|||||||
passData = name.passData,
|
passData = name.passData,
|
||||||
diagnostics = name.diagnostics
|
diagnostics = name.diagnostics
|
||||||
)
|
)
|
||||||
.updateMetadata(this -->> State.Ignored)
|
.updateMetadata(new MetadataPair(this, State.Ignored))
|
||||||
|
|
||||||
typed.copy(
|
typed.copy(
|
||||||
name = newName
|
name = newName
|
||||||
|
@ -4,7 +4,7 @@ import org.enso.compiler.context.{InlineContext, ModuleContext}
|
|||||||
import org.enso.compiler.core.Implicits.AsMetadata
|
import org.enso.compiler.core.Implicits.AsMetadata
|
||||||
import org.enso.compiler.core.ir.{Expression, Module}
|
import org.enso.compiler.core.ir.{Expression, Module}
|
||||||
import org.enso.compiler.core.ir.Name
|
import org.enso.compiler.core.ir.Name
|
||||||
import org.enso.compiler.core.ir.MetadataStorage.ToPair
|
import org.enso.compiler.core.ir.MetadataStorage.MetadataPair
|
||||||
import org.enso.compiler.core.ir.expression.Application
|
import org.enso.compiler.core.ir.expression.Application
|
||||||
import org.enso.compiler.data.BindingsMap
|
import org.enso.compiler.data.BindingsMap
|
||||||
import org.enso.compiler.data.BindingsMap.{Resolution, ResolvedModule}
|
import org.enso.compiler.data.BindingsMap.{Resolution, ResolvedModule}
|
||||||
@ -82,7 +82,9 @@ object MethodCalls extends IRPass {
|
|||||||
resolution match {
|
resolution match {
|
||||||
case Some(List(resolution)) =>
|
case Some(List(resolution)) =>
|
||||||
val newName =
|
val newName =
|
||||||
name.updateMetadata(this -->> Resolution(resolution))
|
name.updateMetadata(
|
||||||
|
new MetadataPair(this, Resolution(resolution))
|
||||||
|
)
|
||||||
val newArgs =
|
val newArgs =
|
||||||
app.arguments.map(
|
app.arguments.map(
|
||||||
_.mapExpressions(doExpression(_))
|
_.mapExpressions(doExpression(_))
|
||||||
|
@ -11,7 +11,7 @@ import org.enso.compiler.core.ir.{
|
|||||||
}
|
}
|
||||||
import org.enso.compiler.core.ir.expression.errors
|
import org.enso.compiler.core.ir.expression.errors
|
||||||
import org.enso.compiler.core.ir.module.scope.definition
|
import org.enso.compiler.core.ir.module.scope.definition
|
||||||
import org.enso.compiler.core.ir.MetadataStorage.ToPair
|
import org.enso.compiler.core.ir.MetadataStorage.MetadataPair
|
||||||
import org.enso.compiler.data.BindingsMap
|
import org.enso.compiler.data.BindingsMap
|
||||||
import org.enso.compiler.data.BindingsMap.{Resolution, ResolvedType, Type}
|
import org.enso.compiler.data.BindingsMap.{Resolution, ResolvedType, Type}
|
||||||
import org.enso.compiler.core.CompilerError
|
import org.enso.compiler.core.CompilerError
|
||||||
@ -162,10 +162,12 @@ case object MethodDefinitions extends IRPass {
|
|||||||
)
|
)
|
||||||
case Right(value: BindingsMap.ResolvedModule) =>
|
case Right(value: BindingsMap.ResolvedModule) =>
|
||||||
typePointer.updateMetadata(
|
typePointer.updateMetadata(
|
||||||
this -->> BindingsMap.Resolution(value)
|
new MetadataPair(this, BindingsMap.Resolution(value))
|
||||||
)
|
)
|
||||||
case Right(value: BindingsMap.ResolvedType) =>
|
case Right(value: BindingsMap.ResolvedType) =>
|
||||||
typePointer.updateMetadata(this -->> BindingsMap.Resolution(value))
|
typePointer.updateMetadata(
|
||||||
|
new MetadataPair(this, BindingsMap.Resolution(value))
|
||||||
|
)
|
||||||
case Right(_: BindingsMap.ResolvedPolyglotSymbol) =>
|
case Right(_: BindingsMap.ResolvedPolyglotSymbol) =>
|
||||||
errors.Resolution(
|
errors.Resolution(
|
||||||
typePointer,
|
typePointer,
|
||||||
|
@ -51,14 +51,16 @@ case object ModuleAnnotations extends IRPass {
|
|||||||
case typ: Definition.SugaredType =>
|
case typ: Definition.SugaredType =>
|
||||||
val res = Some(
|
val res = Some(
|
||||||
resolveComplexType(typ).updateMetadata(
|
resolveComplexType(typ).updateMetadata(
|
||||||
this -->> Annotations(lastAnnotations)
|
new MetadataPair(this, Annotations(lastAnnotations))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
lastAnnotations = Seq()
|
lastAnnotations = Seq()
|
||||||
res
|
res
|
||||||
case entity =>
|
case entity =>
|
||||||
val res = Some(
|
val res = Some(
|
||||||
entity.updateMetadata(this -->> Annotations(lastAnnotations))
|
entity.updateMetadata(
|
||||||
|
new MetadataPair(this, Annotations(lastAnnotations))
|
||||||
|
)
|
||||||
)
|
)
|
||||||
lastAnnotations = Seq()
|
lastAnnotations = Seq()
|
||||||
res
|
res
|
||||||
@ -84,7 +86,9 @@ case object ModuleAnnotations extends IRPass {
|
|||||||
case comment: Comment => Some(comment)
|
case comment: Comment => Some(comment)
|
||||||
case entity =>
|
case entity =>
|
||||||
val res = Some(
|
val res = Some(
|
||||||
entity.updateMetadata(this -->> Annotations(lastAnnotations))
|
entity.updateMetadata(
|
||||||
|
new MetadataPair(this, Annotations(lastAnnotations))
|
||||||
|
)
|
||||||
)
|
)
|
||||||
lastAnnotations = Seq()
|
lastAnnotations = Seq()
|
||||||
res
|
res
|
||||||
|
@ -6,7 +6,7 @@ import org.enso.compiler.core.ir.{Expression, Module, Name, Pattern}
|
|||||||
import org.enso.compiler.core.ir.expression.{errors, Case}
|
import org.enso.compiler.core.ir.expression.{errors, Case}
|
||||||
import org.enso.compiler.core.ir.module.scope.Definition
|
import org.enso.compiler.core.ir.module.scope.Definition
|
||||||
import org.enso.compiler.core.ir.module.scope.definition
|
import org.enso.compiler.core.ir.module.scope.definition
|
||||||
import org.enso.compiler.core.ir.MetadataStorage.ToPair
|
import org.enso.compiler.core.ir.MetadataStorage.MetadataPair
|
||||||
import org.enso.compiler.data.BindingsMap
|
import org.enso.compiler.data.BindingsMap
|
||||||
import org.enso.compiler.core.CompilerError
|
import org.enso.compiler.core.CompilerError
|
||||||
import org.enso.compiler.pass.IRPass
|
import org.enso.compiler.pass.IRPass
|
||||||
@ -120,23 +120,23 @@ object Patterns extends IRPass {
|
|||||||
)
|
)
|
||||||
case Right(value: BindingsMap.ResolvedConstructor) =>
|
case Right(value: BindingsMap.ResolvedConstructor) =>
|
||||||
consName.updateMetadata(
|
consName.updateMetadata(
|
||||||
this -->> BindingsMap.Resolution(value)
|
new MetadataPair(this, BindingsMap.Resolution(value))
|
||||||
)
|
)
|
||||||
case Right(value: BindingsMap.ResolvedModule) =>
|
case Right(value: BindingsMap.ResolvedModule) =>
|
||||||
consName.updateMetadata(
|
consName.updateMetadata(
|
||||||
this -->> BindingsMap.Resolution(value)
|
new MetadataPair(this, BindingsMap.Resolution(value))
|
||||||
)
|
)
|
||||||
case Right(value: BindingsMap.ResolvedType) =>
|
case Right(value: BindingsMap.ResolvedType) =>
|
||||||
consName.updateMetadata(
|
consName.updateMetadata(
|
||||||
this -->> BindingsMap.Resolution(value)
|
new MetadataPair(this, BindingsMap.Resolution(value))
|
||||||
)
|
)
|
||||||
case Right(value: BindingsMap.ResolvedPolyglotSymbol) =>
|
case Right(value: BindingsMap.ResolvedPolyglotSymbol) =>
|
||||||
consName.updateMetadata(
|
consName.updateMetadata(
|
||||||
this -->> BindingsMap.Resolution(value)
|
new MetadataPair(this, BindingsMap.Resolution(value))
|
||||||
)
|
)
|
||||||
case Right(value: BindingsMap.ResolvedPolyglotField) =>
|
case Right(value: BindingsMap.ResolvedPolyglotField) =>
|
||||||
consName.updateMetadata(
|
consName.updateMetadata(
|
||||||
this -->> BindingsMap.Resolution(value)
|
new MetadataPair(this, BindingsMap.Resolution(value))
|
||||||
)
|
)
|
||||||
|
|
||||||
case Right(_: BindingsMap.ResolvedMethod) =>
|
case Right(_: BindingsMap.ResolvedMethod) =>
|
||||||
@ -201,7 +201,7 @@ object Patterns extends IRPass {
|
|||||||
)
|
)
|
||||||
case Right(value: BindingsMap.ResolvedType) =>
|
case Right(value: BindingsMap.ResolvedType) =>
|
||||||
tpeName.updateMetadata(
|
tpeName.updateMetadata(
|
||||||
this -->> BindingsMap.Resolution(value)
|
new MetadataPair(this, BindingsMap.Resolution(value))
|
||||||
)
|
)
|
||||||
case Right(_: BindingsMap.ResolvedConstructor) =>
|
case Right(_: BindingsMap.ResolvedConstructor) =>
|
||||||
errors.Resolution(
|
errors.Resolution(
|
||||||
@ -211,11 +211,11 @@ object Patterns extends IRPass {
|
|||||||
)
|
)
|
||||||
case Right(value: BindingsMap.ResolvedPolyglotSymbol) =>
|
case Right(value: BindingsMap.ResolvedPolyglotSymbol) =>
|
||||||
tpeName.updateMetadata(
|
tpeName.updateMetadata(
|
||||||
this -->> BindingsMap.Resolution(value)
|
new MetadataPair(this, BindingsMap.Resolution(value))
|
||||||
)
|
)
|
||||||
case Right(value: BindingsMap.ResolvedPolyglotField) =>
|
case Right(value: BindingsMap.ResolvedPolyglotField) =>
|
||||||
tpeName.updateMetadata(
|
tpeName.updateMetadata(
|
||||||
this -->> BindingsMap.Resolution(value)
|
new MetadataPair(this, BindingsMap.Resolution(value))
|
||||||
)
|
)
|
||||||
/*errors.Resolution(
|
/*errors.Resolution(
|
||||||
tpeName,
|
tpeName,
|
||||||
|
@ -112,7 +112,9 @@ case object TypeFunctions extends IRPass {
|
|||||||
val result = resolveApplication(app)
|
val result = resolveApplication(app)
|
||||||
app
|
app
|
||||||
.getMetadata(DocumentationComments)
|
.getMetadata(DocumentationComments)
|
||||||
.map(doc => result.updateMetadata(DocumentationComments -->> doc))
|
.map(doc =>
|
||||||
|
result.updateMetadata(new MetadataPair(DocumentationComments, doc))
|
||||||
|
)
|
||||||
.getOrElse(result)
|
.getOrElse(result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import org.enso.compiler.core.ir.{Expression, Function, Module, Name}
|
|||||||
import org.enso.compiler.core.ir.expression.errors
|
import org.enso.compiler.core.ir.expression.errors
|
||||||
import org.enso.compiler.core.ir.module.scope.Definition
|
import org.enso.compiler.core.ir.module.scope.Definition
|
||||||
import org.enso.compiler.core.ir.module.scope.definition.Method
|
import org.enso.compiler.core.ir.module.scope.definition.Method
|
||||||
import org.enso.compiler.core.ir.MetadataStorage.ToPair
|
import org.enso.compiler.core.ir.MetadataStorage.MetadataPair
|
||||||
import org.enso.compiler.core.ir.`type`
|
import org.enso.compiler.core.ir.`type`
|
||||||
import org.enso.compiler.data.BindingsMap
|
import org.enso.compiler.data.BindingsMap
|
||||||
import org.enso.compiler.data.BindingsMap.{Resolution, ResolvedModule}
|
import org.enso.compiler.data.BindingsMap.{Resolution, ResolvedModule}
|
||||||
@ -108,8 +108,11 @@ case object TypeNames extends IRPass {
|
|||||||
ir.getMetadata(TypeSignatures)
|
ir.getMetadata(TypeSignatures)
|
||||||
.map { s =>
|
.map { s =>
|
||||||
ir.updateMetadata(
|
ir.updateMetadata(
|
||||||
TypeSignatures -->> TypeSignatures.Signature(
|
new MetadataPair(
|
||||||
resolveSignature(typeParams, bindingsMap, s.signature)
|
TypeSignatures,
|
||||||
|
TypeSignatures.Signature(
|
||||||
|
resolveSignature(typeParams, bindingsMap, s.signature)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -143,7 +146,7 @@ case object TypeNames extends IRPass {
|
|||||||
resolvedName: Either[BindingsMap.ResolutionError, BindingsMap.ResolvedName]
|
resolvedName: Either[BindingsMap.ResolutionError, BindingsMap.ResolvedName]
|
||||||
): Name =
|
): Name =
|
||||||
resolvedName
|
resolvedName
|
||||||
.map(res => name.updateMetadata(this -->> Resolution(res)))
|
.map(res => name.updateMetadata(new MetadataPair(this, Resolution(res))))
|
||||||
.fold(
|
.fold(
|
||||||
error =>
|
error =>
|
||||||
errors.Resolution(name, errors.Resolution.ResolverError(error)),
|
errors.Resolution(name, errors.Resolution.ResolverError(error)),
|
||||||
|
@ -102,14 +102,16 @@ case object TypeSignatures extends IRPass {
|
|||||||
val newMethodWithDoc = asc
|
val newMethodWithDoc = asc
|
||||||
.getMetadata(DocumentationComments)
|
.getMetadata(DocumentationComments)
|
||||||
.map(doc =>
|
.map(doc =>
|
||||||
newMethod.updateMetadata(DocumentationComments -->> doc)
|
newMethod.updateMetadata(
|
||||||
|
new MetadataPair(DocumentationComments, doc)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
.getOrElse(newMethod)
|
.getOrElse(newMethod)
|
||||||
val newMethodWithAnnotations = asc
|
val newMethodWithAnnotations = asc
|
||||||
.getMetadata(ModuleAnnotations)
|
.getMetadata(ModuleAnnotations)
|
||||||
.map(annotations =>
|
.map(annotations =>
|
||||||
newMethodWithDoc.updateMetadata(
|
newMethodWithDoc.updateMetadata(
|
||||||
ModuleAnnotations -->> annotations
|
new MetadataPair(ModuleAnnotations, annotations)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.getOrElse(newMethodWithDoc)
|
.getOrElse(newMethodWithDoc)
|
||||||
@ -119,7 +121,7 @@ case object TypeSignatures extends IRPass {
|
|||||||
if (ref isSameReferenceAs methodRef) {
|
if (ref isSameReferenceAs methodRef) {
|
||||||
Some(
|
Some(
|
||||||
newMethodWithAnnotations.updateMetadata(
|
newMethodWithAnnotations.updateMetadata(
|
||||||
this -->> Signature(sig)
|
new MetadataPair(this, Signature(sig))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
@ -185,7 +187,9 @@ case object TypeSignatures extends IRPass {
|
|||||||
arguments: List[DefinitionArgument]
|
arguments: List[DefinitionArgument]
|
||||||
): Unit = {
|
): Unit = {
|
||||||
arguments.foreach(arg =>
|
arguments.foreach(arg =>
|
||||||
arg.ascribedType.map(t => arg.updateMetadata(this -->> Signature(t)))
|
arg.ascribedType.map(t =>
|
||||||
|
arg.updateMetadata(new MetadataPair(this, Signature(t)))
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,9 +228,12 @@ case object TypeSignatures extends IRPass {
|
|||||||
) =>
|
) =>
|
||||||
val sig = resolveExpression(ascribedType.duplicate())
|
val sig = resolveExpression(ascribedType.duplicate())
|
||||||
specified.copy(
|
specified.copy(
|
||||||
name = specified.name.updateMetadata(this -->> Signature(sig)),
|
name = specified.name.updateMetadata(
|
||||||
ascribedType =
|
new MetadataPair(this, Signature(sig))
|
||||||
Some(ascribedType.updateMetadata(this -->> Signature(sig)))
|
),
|
||||||
|
ascribedType = Some(
|
||||||
|
ascribedType.updateMetadata(new MetadataPair(this, Signature(sig)))
|
||||||
|
)
|
||||||
)
|
)
|
||||||
case argument => argument
|
case argument => argument
|
||||||
}
|
}
|
||||||
@ -239,7 +246,7 @@ case object TypeSignatures extends IRPass {
|
|||||||
private def resolveAscription(sig: Type.Ascription): Expression = {
|
private def resolveAscription(sig: Type.Ascription): Expression = {
|
||||||
val newTyped = sig.typed.mapExpressions(resolveExpression)
|
val newTyped = sig.typed.mapExpressions(resolveExpression)
|
||||||
val newSig = sig.signature.mapExpressions(resolveExpression)
|
val newSig = sig.signature.mapExpressions(resolveExpression)
|
||||||
newTyped.updateMetadata(this -->> Signature(newSig))
|
newTyped.updateMetadata(new MetadataPair(this, Signature(newSig)))
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Resolves type signatures in a block.
|
/** Resolves type signatures in a block.
|
||||||
@ -269,7 +276,9 @@ case object TypeSignatures extends IRPass {
|
|||||||
val newBindingWithDoc = asc
|
val newBindingWithDoc = asc
|
||||||
.getMetadata(DocumentationComments)
|
.getMetadata(DocumentationComments)
|
||||||
.map(doc =>
|
.map(doc =>
|
||||||
newBinding.updateMetadata(DocumentationComments -->> doc)
|
newBinding.updateMetadata(
|
||||||
|
new MetadataPair(DocumentationComments, doc)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
.getOrElse(newBinding)
|
.getOrElse(newBinding)
|
||||||
|
|
||||||
@ -277,7 +286,9 @@ case object TypeSignatures extends IRPass {
|
|||||||
case typedName: Name =>
|
case typedName: Name =>
|
||||||
if (typedName.name == name.name) {
|
if (typedName.name == name.name) {
|
||||||
Some(
|
Some(
|
||||||
newBindingWithDoc.updateMetadata(this -->> Signature(sig))
|
newBindingWithDoc.updateMetadata(
|
||||||
|
new MetadataPair(this, Signature(sig))
|
||||||
|
)
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
List(
|
List(
|
||||||
|
@ -1775,7 +1775,7 @@ final class TreeToIr {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
private MetadataStorage meta() {
|
private MetadataStorage meta() {
|
||||||
return MetadataStorage.apply(nil());
|
return new MetadataStorage();
|
||||||
}
|
}
|
||||||
private DiagnosticStorage diag() {
|
private DiagnosticStorage diag() {
|
||||||
return DiagnosticStorage.apply(nil());
|
return DiagnosticStorage.apply(nil());
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package org.enso.compiler.core.ir;
|
package org.enso.compiler.core.ir;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import org.enso.compiler.core.ir.expression.Application;
|
import org.enso.compiler.core.ir.expression.Application;
|
||||||
@ -357,25 +358,25 @@ public final class IrPersistance {
|
|||||||
@ServiceProvider(service = Persistance.class)
|
@ServiceProvider(service = Persistance.class)
|
||||||
public static final class PersistMetadataStorage extends Persistance<MetadataStorage> {
|
public static final class PersistMetadataStorage extends Persistance<MetadataStorage> {
|
||||||
public PersistMetadataStorage() {
|
public PersistMetadataStorage() {
|
||||||
super(MetadataStorage.class, false, 381);
|
super(MetadataStorage.class, false, 389);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
protected void writeObject(MetadataStorage obj, Output out) throws IOException {
|
protected void writeObject(MetadataStorage obj, Output out) throws IOException {
|
||||||
var map =
|
var map = new LinkedHashMap<ProcessingPass, ProcessingPass.Metadata>();
|
||||||
obj.map(
|
obj.map(
|
||||||
(processingPass, data) -> {
|
(processingPass, data) -> {
|
||||||
var t = new Tuple2<>(processingPass, data);
|
map.put(processingPass, data);
|
||||||
return t;
|
return null;
|
||||||
});
|
});
|
||||||
out.writeInline(scala.collection.immutable.Map.class, map);
|
out.writeInline(java.util.Map.class, map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
protected MetadataStorage readObject(Input in) throws IOException, ClassNotFoundException {
|
protected MetadataStorage readObject(Input in) throws IOException, ClassNotFoundException {
|
||||||
var map = in.readInline(scala.collection.immutable.Map.class);
|
var map = in.readInline(java.util.Map.class);
|
||||||
var storage = new MetadataStorage(map);
|
var storage = new MetadataStorage(map);
|
||||||
return storage;
|
return storage;
|
||||||
}
|
}
|
||||||
@ -398,11 +399,6 @@ public final class IrPersistance {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private static <T> scala.collection.immutable.List<T> nil() {
|
|
||||||
return (scala.collection.immutable.List<T>) scala.collection.immutable.Nil$.MODULE$;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static <T> scala.collection.immutable.List<T> join(
|
private static <T> scala.collection.immutable.List<T> join(
|
||||||
T head, scala.collection.immutable.List<T> tail) {
|
T head, scala.collection.immutable.List<T> tail) {
|
||||||
return scala.collection.immutable.$colon$colon$.MODULE$.apply(head, tail);
|
return scala.collection.immutable.$colon$colon$.MODULE$.apply(head, tail);
|
||||||
|
@ -0,0 +1,214 @@
|
|||||||
|
package org.enso.compiler.core.ir;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.enso.compiler.core.CompilerStub;
|
||||||
|
|
||||||
|
import scala.Option;
|
||||||
|
|
||||||
|
/** Stores metadata for the various passes.
|
||||||
|
*/
|
||||||
|
public final class MetadataStorage {
|
||||||
|
private Map<ProcessingPass, ProcessingPass.Metadata> metadata;
|
||||||
|
|
||||||
|
public MetadataStorage() {
|
||||||
|
this(Collections.emptyMap());
|
||||||
|
}
|
||||||
|
|
||||||
|
public MetadataStorage(Map<ProcessingPass, ProcessingPass.Metadata> init) {
|
||||||
|
this.metadata = init;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Adds a new metadata entity to the pass metadata, or updates it if it
|
||||||
|
* already exists for a given pass.
|
||||||
|
*
|
||||||
|
* @param pass the pass to add the metadata for
|
||||||
|
* @param newMeta the metadata to add for `pass`
|
||||||
|
* @tparam K the concrete type of `pass`
|
||||||
|
*/
|
||||||
|
public void update(ProcessingPass pass, ProcessingPass.Metadata newMeta) {
|
||||||
|
var copy = copyMetaMap();
|
||||||
|
copy.put(pass, newMeta);
|
||||||
|
metadata = copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Adds a metadata pair to the node metadata.
|
||||||
|
*
|
||||||
|
* This will overwrite any entry whose key matches [[MetadataPair#pass]].
|
||||||
|
*
|
||||||
|
* @param <K> the concrete type of the pass
|
||||||
|
* @param metadataPair the pair to add to the storage
|
||||||
|
*/
|
||||||
|
public <K extends ProcessingPass> void update(MetadataPair<K> metadataPair) {
|
||||||
|
update(metadataPair.pass(), metadataPair.metadata());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Removes the metadata for the specified pass from the list.
|
||||||
|
*
|
||||||
|
* @param pass the pass to remove metadata for
|
||||||
|
* @tparam K the concrete type of `pass`
|
||||||
|
* @return the removed metadata for that pass, if it exists
|
||||||
|
*/
|
||||||
|
public Option<ProcessingPass.Metadata> remove(ProcessingPass pass) {
|
||||||
|
var prev = metadata.get(pass);
|
||||||
|
if (prev == null) {
|
||||||
|
return Option.empty();
|
||||||
|
} else {
|
||||||
|
var copy = copyMetaMap();
|
||||||
|
copy.remove(pass);
|
||||||
|
metadata = copy;
|
||||||
|
return Option.apply(prev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Gets the metadata for the specified pass.
|
||||||
|
*
|
||||||
|
* @param pass the pass to get the metadata for
|
||||||
|
* @tparam K the concrete type of `pass`
|
||||||
|
* @return the metadata for `pass`, if it exists
|
||||||
|
*/
|
||||||
|
public Option<ProcessingPass.Metadata> get(ProcessingPass pass) {
|
||||||
|
var prev = (ProcessingPass.Metadata) metadata.get(pass);
|
||||||
|
return Option.apply(prev);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Creates a deep copy of `this`.
|
||||||
|
*
|
||||||
|
* @return a deep copy of `this`
|
||||||
|
*/
|
||||||
|
public MetadataStorage duplicate() {
|
||||||
|
var map = new HashMap<ProcessingPass, ProcessingPass.Metadata>();
|
||||||
|
for (var entry : this.metadata.entrySet()) {
|
||||||
|
var key = entry.getKey();
|
||||||
|
var meta = (ProcessingPass.Metadata) entry.getValue();
|
||||||
|
var duplicated = meta.duplicate();
|
||||||
|
if (duplicated.nonEmpty()) {
|
||||||
|
map.put(key, duplicated.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var res = new MetadataStorage(map);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Maps across the stored metadata, transforming it to an output list.
|
||||||
|
*
|
||||||
|
* @param <R> the resulting element of the list
|
||||||
|
* @param fn the function to apply over the metadata
|
||||||
|
* @return a list containing the results of transforming the metadata storage
|
||||||
|
*/
|
||||||
|
public <R> List<R> map(BiFunction<ProcessingPass, ProcessingPass.Metadata, R> fn) {
|
||||||
|
return metadata.entrySet().stream().map(
|
||||||
|
(en) -> fn.apply(en.getKey(), en.getValue())
|
||||||
|
).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Prepares the metadata for serialization.
|
||||||
|
*
|
||||||
|
* This operation takes place _in place_.
|
||||||
|
*
|
||||||
|
* Metadata prepared for serialization should not contain any links that
|
||||||
|
* span more than one module, or any other properties that are problematic
|
||||||
|
* when serialized.
|
||||||
|
*
|
||||||
|
* Due to the type safety properties of
|
||||||
|
* [[org.enso.compiler.core.ir.MetadataStorage]], to allow this conversion
|
||||||
|
* to work it must be type-refined to return `typeof this`. To that end,
|
||||||
|
* there is no default definition for this method.
|
||||||
|
*
|
||||||
|
* @param compiler the Enso compiler
|
||||||
|
*/
|
||||||
|
public final void prepareForSerialization(CompilerStub compiler) {
|
||||||
|
var newMap = metadata.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, (en) -> {
|
||||||
|
var value = en.getValue();
|
||||||
|
var newVal = value.prepareForSerialization(compiler);
|
||||||
|
return newVal;
|
||||||
|
}));
|
||||||
|
this.metadata.putAll(newMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Restores metadata after it has been deserialized.
|
||||||
|
*
|
||||||
|
* Due to the type safety properties of
|
||||||
|
* [[org.enso.compiler.core.ir.MetadataStorage]], to allow this conversion
|
||||||
|
* to work it must be type-refined to return `typeof this`. To that end,
|
||||||
|
* there is no default definition for this method.
|
||||||
|
*
|
||||||
|
* @param compiler the Enso compiler
|
||||||
|
* @return `true` if restoration was successful, `false` otherwise
|
||||||
|
*/
|
||||||
|
public boolean restoreFromSerialization(CompilerStub compiler) {
|
||||||
|
var ok = new boolean[] { true };
|
||||||
|
var newMap = metadata.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, (en) -> {
|
||||||
|
var value = en.getValue();
|
||||||
|
var newOption = value.restoreFromSerialization(compiler);
|
||||||
|
if (newOption.nonEmpty()) {
|
||||||
|
return newOption.get();
|
||||||
|
} else {
|
||||||
|
ok[0] = false;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
this.metadata = newMap;
|
||||||
|
return ok[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
var sb = new StringBuilder("MetadataStorage[");
|
||||||
|
var names = new ArrayList<String>();
|
||||||
|
for (var v : metadata.values()) {
|
||||||
|
var m = (ProcessingPass.Metadata) v;
|
||||||
|
names.add(m.metadataName());
|
||||||
|
}
|
||||||
|
Collections.sort(names);
|
||||||
|
var sep = "";
|
||||||
|
for (var n : names) {
|
||||||
|
sb.append(sep);
|
||||||
|
sb.append(n);
|
||||||
|
sep = ", ";
|
||||||
|
}
|
||||||
|
sb.append("]");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final Comparator<ProcessingPass> COMPARATOR = (p1, p2) -> {
|
||||||
|
return p1.getClass().getName().compareTo(p2.getClass().getName());
|
||||||
|
};
|
||||||
|
|
||||||
|
private Map<ProcessingPass, ProcessingPass.Metadata> copyMetaMap() {
|
||||||
|
var copy = new TreeMap<ProcessingPass, ProcessingPass.Metadata>(COMPARATOR);
|
||||||
|
copy.putAll(metadata);
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int hash = 5;
|
||||||
|
hash = 17 * hash + Objects.hashCode(this.metadata);
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (obj instanceof MetadataStorage other) {
|
||||||
|
return Objects.equals(this.metadata, other.metadata);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public record MetadataPair<K extends ProcessingPass> (K pass, ProcessingPass.Metadata metadata) {
|
||||||
|
}
|
||||||
|
}
|
@ -17,10 +17,7 @@ object Implicits {
|
|||||||
* @return a string representation of the pass data for [[ir]]
|
* @return a string representation of the pass data for [[ir]]
|
||||||
*/
|
*/
|
||||||
def showPassData: String = {
|
def showPassData: String = {
|
||||||
val metaString: Seq[String] =
|
ir.passData.toString
|
||||||
ir.passData.map((p, m) => (p, m.metadataName)).values.toSeq
|
|
||||||
val alphabetical = metaString.sorted
|
|
||||||
s"$alphabetical"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,7 +88,7 @@ object Implicits {
|
|||||||
* @return the metadata for `pass`, if it exists
|
* @return the metadata for `pass`, if it exists
|
||||||
*/
|
*/
|
||||||
def getMetadata[K <: ProcessingPass](pass: K): Option[pass.Metadata] = {
|
def getMetadata[K <: ProcessingPass](pass: K): Option[pass.Metadata] = {
|
||||||
ir.passData.get(pass)
|
ir.passData.get(pass).asInstanceOf[Option[pass.Metadata]]
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Unsafely gets the metadata for the specified pass, if it exists.
|
/** Unsafely gets the metadata for the specified pass, if it exists.
|
||||||
@ -107,7 +104,10 @@ object Implicits {
|
|||||||
pass: ProcessingPass,
|
pass: ProcessingPass,
|
||||||
msg: => String
|
msg: => String
|
||||||
): pass.Metadata = {
|
): pass.Metadata = {
|
||||||
ir.passData.getUnsafe(pass)(msg)
|
ir.passData
|
||||||
|
.get(pass)
|
||||||
|
.getOrElse(throw new CompilerError(msg))
|
||||||
|
.asInstanceOf[pass.Metadata]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ object CallArgument {
|
|||||||
override val name: Option[Name],
|
override val name: Option[Name],
|
||||||
override val value: Expression,
|
override val value: Expression,
|
||||||
location: Option[IdentifiedLocation],
|
location: Option[IdentifiedLocation],
|
||||||
passData: MetadataStorage = MetadataStorage(),
|
passData: MetadataStorage = new MetadataStorage(),
|
||||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends CallArgument
|
) extends CallArgument
|
||||||
with IRKind.Primitive {
|
with IRKind.Primitive {
|
||||||
@ -106,7 +106,8 @@ object CallArgument {
|
|||||||
keepIdentifiers
|
keepIdentifiers
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
|
@ -61,7 +61,7 @@ object DefinitionArgument {
|
|||||||
override val defaultValue: Option[Expression],
|
override val defaultValue: Option[Expression],
|
||||||
override val suspended: Boolean,
|
override val suspended: Boolean,
|
||||||
location: Option[IdentifiedLocation],
|
location: Option[IdentifiedLocation],
|
||||||
passData: MetadataStorage = MetadataStorage(),
|
passData: MetadataStorage = new MetadataStorage(),
|
||||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends DefinitionArgument
|
) extends DefinitionArgument
|
||||||
with IRKind.Primitive {
|
with IRKind.Primitive {
|
||||||
@ -136,7 +136,8 @@ object DefinitionArgument {
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
|
@ -15,7 +15,7 @@ import java.util.UUID
|
|||||||
*/
|
*/
|
||||||
sealed case class Empty(
|
sealed case class Empty(
|
||||||
override val location: Option[IdentifiedLocation],
|
override val location: Option[IdentifiedLocation],
|
||||||
passData: MetadataStorage = MetadataStorage(),
|
passData: MetadataStorage = new MetadataStorage(),
|
||||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends IR
|
) extends IR
|
||||||
with Expression
|
with Expression
|
||||||
@ -51,7 +51,8 @@ sealed case class Empty(
|
|||||||
): Empty =
|
): Empty =
|
||||||
copy(
|
copy(
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
|
@ -60,7 +60,7 @@ object Expression {
|
|||||||
returnValue: Expression,
|
returnValue: Expression,
|
||||||
location: Option[IdentifiedLocation],
|
location: Option[IdentifiedLocation],
|
||||||
suspended: Boolean = false,
|
suspended: Boolean = false,
|
||||||
passData: MetadataStorage = MetadataStorage(),
|
passData: MetadataStorage = new MetadataStorage(),
|
||||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Expression
|
) extends Expression
|
||||||
with IRKind.Primitive {
|
with IRKind.Primitive {
|
||||||
@ -121,7 +121,8 @@ object Expression {
|
|||||||
keepIdentifiers
|
keepIdentifiers
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
@ -185,7 +186,7 @@ object Expression {
|
|||||||
name: Name,
|
name: Name,
|
||||||
expression: Expression,
|
expression: Expression,
|
||||||
location: Option[IdentifiedLocation],
|
location: Option[IdentifiedLocation],
|
||||||
passData: MetadataStorage = MetadataStorage(),
|
passData: MetadataStorage = new MetadataStorage(),
|
||||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Expression
|
) extends Expression
|
||||||
with IRKind.Primitive {
|
with IRKind.Primitive {
|
||||||
@ -236,7 +237,8 @@ object Expression {
|
|||||||
keepIdentifiers
|
keepIdentifiers
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
|
@ -114,7 +114,8 @@ object Function {
|
|||||||
keepIdentifiers
|
keepIdentifiers
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
@ -200,7 +201,7 @@ object Function {
|
|||||||
override val body: Expression,
|
override val body: Expression,
|
||||||
location: Option[IdentifiedLocation],
|
location: Option[IdentifiedLocation],
|
||||||
override val canBeTCO: Boolean = true,
|
override val canBeTCO: Boolean = true,
|
||||||
passData: MetadataStorage = MetadataStorage(),
|
passData: MetadataStorage = new MetadataStorage(),
|
||||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Function
|
) extends Function
|
||||||
with IRKind.Sugar {
|
with IRKind.Sugar {
|
||||||
@ -271,7 +272,8 @@ object Function {
|
|||||||
keepIdentifiers
|
keepIdentifiers
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
|
@ -40,7 +40,7 @@ object Literal {
|
|||||||
base: Option[String],
|
base: Option[String],
|
||||||
value: String,
|
value: String,
|
||||||
location: Option[IdentifiedLocation],
|
location: Option[IdentifiedLocation],
|
||||||
passData: MetadataStorage = MetadataStorage(),
|
passData: MetadataStorage = new MetadataStorage(),
|
||||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Literal {
|
) extends Literal {
|
||||||
var id: UUID @Identifier = randomId
|
var id: UUID @Identifier = randomId
|
||||||
@ -77,7 +77,8 @@ object Literal {
|
|||||||
): Number =
|
): Number =
|
||||||
copy(
|
copy(
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
@ -166,7 +167,7 @@ object Literal {
|
|||||||
sealed case class Text(
|
sealed case class Text(
|
||||||
text: String,
|
text: String,
|
||||||
location: Option[IdentifiedLocation],
|
location: Option[IdentifiedLocation],
|
||||||
passData: MetadataStorage = MetadataStorage(),
|
passData: MetadataStorage = new MetadataStorage(),
|
||||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Literal {
|
) extends Literal {
|
||||||
var id: UUID @Identifier = randomId
|
var id: UUID @Identifier = randomId
|
||||||
@ -201,7 +202,8 @@ object Literal {
|
|||||||
): Text =
|
): Text =
|
||||||
copy(
|
copy(
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
|
@ -1,272 +0,0 @@
|
|||||||
package org.enso.compiler.core.ir
|
|
||||||
|
|
||||||
import org.enso.compiler.core.ir.MetadataStorage.MetadataPair
|
|
||||||
import org.enso.compiler.core.ir.ProcessingPass
|
|
||||||
import org.enso.compiler.core.CompilerError
|
|
||||||
import org.enso.compiler.core.CompilerStub
|
|
||||||
|
|
||||||
/** Stores metadata for the various passes.
|
|
||||||
*
|
|
||||||
* @param startingMeta metadata mappings to initialise the configuration
|
|
||||||
* storage with
|
|
||||||
*/
|
|
||||||
//noinspection DuplicatedCode
|
|
||||||
final class MetadataStorage(
|
|
||||||
private var metadata: Map[ProcessingPass, Any]
|
|
||||||
) {
|
|
||||||
def this(startingMeta: Seq[MetadataPair[_]] = Seq()) = {
|
|
||||||
this(
|
|
||||||
Map(
|
|
||||||
startingMeta.map(_.asPair.asInstanceOf[(ProcessingPass, Any)]): _*
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Adds a metadata pair to the node metadata.
|
|
||||||
*
|
|
||||||
* This will overwrite any entry whose key matches [[MetadataPair#pass]].
|
|
||||||
*
|
|
||||||
* @param metadataPair the pair to add to the storage
|
|
||||||
* @tparam K the concrete type of the pass
|
|
||||||
*/
|
|
||||||
def update[K <: ProcessingPass](metadataPair: MetadataPair[K]): Unit = {
|
|
||||||
update(metadataPair.pass)(metadataPair.metadata)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Adds a new metadata entity to the pass metadata, or updates it if it
|
|
||||||
* already exists for a given pass.
|
|
||||||
*
|
|
||||||
* @param pass the pass to add the metadata for
|
|
||||||
* @param newMeta the metadata to add for `pass`
|
|
||||||
* @tparam K the concrete type of `pass`
|
|
||||||
*/
|
|
||||||
def update[K <: ProcessingPass](pass: K)(newMeta: pass.Metadata): Unit = {
|
|
||||||
metadata = metadata + (pass -> newMeta)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Removes the metadata for the specified pass from the list.
|
|
||||||
*
|
|
||||||
* @param pass the pass to remove metadata for
|
|
||||||
* @tparam K the concrete type of `pass`
|
|
||||||
* @return the removed metadata for that pass, if it exists
|
|
||||||
*/
|
|
||||||
def remove[K <: ProcessingPass](pass: K): Option[pass.Metadata] = {
|
|
||||||
if (metadata.contains(pass)) {
|
|
||||||
val res = get(pass)
|
|
||||||
metadata = metadata.filter(t => t._1 != pass)
|
|
||||||
res
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Gets the metadata for the specified pass.
|
|
||||||
*
|
|
||||||
* @param pass the pass to get the metadata for
|
|
||||||
* @tparam K the concrete type of `pass`
|
|
||||||
* @return the metadata for `pass`, if it exists
|
|
||||||
*/
|
|
||||||
def get[K <: ProcessingPass](pass: K): Option[pass.Metadata] = {
|
|
||||||
metadata.get(pass).map(_.asInstanceOf[pass.Metadata])
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Unsafely gets the metadata for the specified pass, if it exists.
|
|
||||||
*
|
|
||||||
* @param pass the pass to get metadata for
|
|
||||||
* @param msg the message to throw with if the unsafe get fails
|
|
||||||
* @tparam K the concrete type of `pass`
|
|
||||||
* @throws CompilerError if no metadata exists for `pass`
|
|
||||||
* @return the metadata for `pass`, if it exists
|
|
||||||
*/
|
|
||||||
def getUnsafe[K <: ProcessingPass](
|
|
||||||
pass: K
|
|
||||||
)(msg: => String = s"Missing metadata for pass $pass"): pass.Metadata = {
|
|
||||||
get(pass).getOrElse(throw new CompilerError(msg))
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Compares to pass metadata stores for equality.
|
|
||||||
*
|
|
||||||
* @param obj the object to compare against
|
|
||||||
* @return `true` if `this == obj`, otherwise `false`
|
|
||||||
*/
|
|
||||||
override def equals(obj: Any): Boolean =
|
|
||||||
obj match {
|
|
||||||
case that: MetadataStorage => this.metadata == that.metadata
|
|
||||||
case _ => false
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Maps across the stored metadata, transforming it to an output map.
|
|
||||||
*
|
|
||||||
* @param f the function to apply over the metadata
|
|
||||||
* @tparam K the output key type
|
|
||||||
* @tparam V the output value type
|
|
||||||
* @return a map containing the results of transforming the metadata storage
|
|
||||||
*/
|
|
||||||
def map[K, V](
|
|
||||||
f: (ProcessingPass, ProcessingPass.Metadata) => (K, V)
|
|
||||||
): Map[K, V] = {
|
|
||||||
metadata
|
|
||||||
.asInstanceOf[Map[ProcessingPass, ProcessingPass.Metadata]]
|
|
||||||
.map(f.tupled)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Prepares the metadata for serialization.
|
|
||||||
*
|
|
||||||
* This operation takes place _in place_.
|
|
||||||
*
|
|
||||||
* Metadata prepared for serialization should not contain any links that
|
|
||||||
* span more than one module, or any other properties that are problematic
|
|
||||||
* when serialized.
|
|
||||||
*
|
|
||||||
* Due to the type safety properties of
|
|
||||||
* [[org.enso.compiler.core.ir.MetadataStorage]], to allow this conversion
|
|
||||||
* to work it must be type-refined to return `typeof this`. To that end,
|
|
||||||
* there is no default definition for this method.
|
|
||||||
*
|
|
||||||
* @param compiler the Enso compiler
|
|
||||||
*/
|
|
||||||
def prepareForSerialization(compiler: CompilerStub): Unit = {
|
|
||||||
this.metadata = metadata.map { case (pass, value) =>
|
|
||||||
val metadata = value.asInstanceOf[ProcessingPass.Metadata]
|
|
||||||
val newVal = metadata
|
|
||||||
// HP: could avoid casting by wrapping Metadata with some global compiler reference
|
|
||||||
.prepareForSerialization(compiler.asInstanceOf[metadata.Compiler])
|
|
||||||
(pass, newVal)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Restores metadata after it has been deserialized.
|
|
||||||
*
|
|
||||||
* Due to the type safety properties of
|
|
||||||
* [[org.enso.compiler.core.ir.MetadataStorage]], to allow this conversion
|
|
||||||
* to work it must be type-refined to return `typeof this`. To that end,
|
|
||||||
* there is no default definition for this method.
|
|
||||||
*
|
|
||||||
* @param compiler the Enso compiler
|
|
||||||
* @return `true` if restoration was successful, `false` otherwise
|
|
||||||
*/
|
|
||||||
def restoreFromSerialization(compiler: CompilerStub): Boolean = {
|
|
||||||
this.metadata = metadata.map { case (pass, value) =>
|
|
||||||
val metadata = value.asInstanceOf[ProcessingPass.Metadata]
|
|
||||||
val meta = metadata
|
|
||||||
.restoreFromSerialization(compiler.asInstanceOf[metadata.Compiler])
|
|
||||||
.getOrElse(return false)
|
|
||||||
(pass, meta)
|
|
||||||
}
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Creates a copy of `this`.
|
|
||||||
*
|
|
||||||
* @return a copy of `this`
|
|
||||||
*/
|
|
||||||
def copy: MetadataStorage = {
|
|
||||||
val res = new MetadataStorage
|
|
||||||
res.metadata = this.metadata
|
|
||||||
res
|
|
||||||
}
|
|
||||||
|
|
||||||
override def toString: String = metadata.toString()
|
|
||||||
|
|
||||||
/** Creates a deep copy of `this`.
|
|
||||||
*
|
|
||||||
* @return a deep copy of `this`
|
|
||||||
*/
|
|
||||||
def duplicate: MetadataStorage = {
|
|
||||||
val res = MetadataStorage()
|
|
||||||
res.metadata = for {
|
|
||||||
(pass, meta) <- this.metadata
|
|
||||||
duplicated <- meta.asInstanceOf[ProcessingPass.Metadata].duplicate()
|
|
||||||
} yield (pass, duplicated)
|
|
||||||
|
|
||||||
res
|
|
||||||
}
|
|
||||||
}
|
|
||||||
object MetadataStorage extends MetadataStorageSyntax {
|
|
||||||
|
|
||||||
/** Creates a new pass metadata safely.
|
|
||||||
*
|
|
||||||
* @param pairs the pairs of (pass, metadata)
|
|
||||||
* @return a new [[MetadataStorage]]
|
|
||||||
*/
|
|
||||||
def apply(pairs: MetadataPair[_]*): MetadataStorage = {
|
|
||||||
new MetadataStorage(pairs)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** A dependent pair for storing a pass and its metadata.
|
|
||||||
*
|
|
||||||
* @tparam P the concrete pass type
|
|
||||||
*/
|
|
||||||
sealed trait MetadataPair[P <: ProcessingPass] {
|
|
||||||
|
|
||||||
/** The pass itself. */
|
|
||||||
val pass: P
|
|
||||||
|
|
||||||
/** The metadata instance for [[pass]]. */
|
|
||||||
val metadata: pass.Metadata
|
|
||||||
|
|
||||||
/** Creates a string representation of the dependent pair.
|
|
||||||
*
|
|
||||||
* @return a string representation of `this`
|
|
||||||
*/
|
|
||||||
override def toString: String =
|
|
||||||
s"ConfigPair(pass: $pass, config: $metadata)"
|
|
||||||
|
|
||||||
/** Determines whether two config pairs are equal.
|
|
||||||
*
|
|
||||||
* @param obj the object to check for equality against `this`
|
|
||||||
* @return `true` if `this == obj`, otherwise `false`
|
|
||||||
*/
|
|
||||||
override def equals(obj: Any): Boolean =
|
|
||||||
obj match {
|
|
||||||
case that: MetadataPair[_] =>
|
|
||||||
(this.pass == that.pass) && (this.metadata == that.metadata)
|
|
||||||
case _ => false
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Converts the dependent pair into a standard pair ([[Tuple2]]).
|
|
||||||
*
|
|
||||||
* @return `this` as a pair
|
|
||||||
*/
|
|
||||||
def asPair: (pass.type, pass.Metadata) = (pass, metadata)
|
|
||||||
}
|
|
||||||
object MetadataPair {
|
|
||||||
|
|
||||||
/** Constructs a new metadata pair from a pass and a metadata instance for
|
|
||||||
* that pass.
|
|
||||||
*
|
|
||||||
* @param newPass the pass
|
|
||||||
* @param newMetadata the metadata for `pass`
|
|
||||||
* @tparam P the concrete type of `newPass`
|
|
||||||
* @return a metadata pair containing `newPass` and `configuration`
|
|
||||||
*/
|
|
||||||
def apply[P <: ProcessingPass](newPass: P)(
|
|
||||||
newMetadata: newPass.Metadata
|
|
||||||
): MetadataPair[newPass.type] = {
|
|
||||||
new MetadataPair[newPass.type] {
|
|
||||||
val pass: newPass.type = newPass
|
|
||||||
val metadata: pass.Metadata = newMetadata
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
trait MetadataStorageSyntax {
|
|
||||||
|
|
||||||
/** Adds an extension method on passes for concatenating them into pairs with
|
|
||||||
* metadata for the pass.
|
|
||||||
*
|
|
||||||
* @param pass the pass to create a pair with
|
|
||||||
* @tparam P the concrete type of `pass`
|
|
||||||
*/
|
|
||||||
implicit final class ToPair[P <: ProcessingPass](val pass: P) {
|
|
||||||
|
|
||||||
/** Concatenates [[pass]] with a metadata object for that pass.
|
|
||||||
*
|
|
||||||
* @param metadata the configuration to turn into a pair
|
|
||||||
* @return the pair of ([[pass]], `metadata`)
|
|
||||||
*/
|
|
||||||
def -->>(metadata: pass.Metadata): MetadataPair[pass.type] = {
|
|
||||||
MetadataPair(pass)(metadata)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -29,7 +29,7 @@ final case class Module(
|
|||||||
bindings: List[Definition],
|
bindings: List[Definition],
|
||||||
isPrivate: Boolean,
|
isPrivate: Boolean,
|
||||||
location: Option[IdentifiedLocation],
|
location: Option[IdentifiedLocation],
|
||||||
passData: MetadataStorage = MetadataStorage(),
|
passData: MetadataStorage = new MetadataStorage(),
|
||||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends IR
|
) extends IR
|
||||||
with IRKind.Primitive {
|
with IRKind.Primitive {
|
||||||
@ -94,7 +94,8 @@ final case class Module(
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
|
@ -48,7 +48,7 @@ object Name {
|
|||||||
typePointer: Option[Name],
|
typePointer: Option[Name],
|
||||||
methodName: Name,
|
methodName: Name,
|
||||||
location: Option[IdentifiedLocation],
|
location: Option[IdentifiedLocation],
|
||||||
passData: MetadataStorage = MetadataStorage(),
|
passData: MetadataStorage = new MetadataStorage(),
|
||||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Name
|
) extends Name
|
||||||
with IRKind.Sugar {
|
with IRKind.Sugar {
|
||||||
@ -109,7 +109,8 @@ object Name {
|
|||||||
keepIdentifiers
|
keepIdentifiers
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
@ -208,7 +209,7 @@ object Name {
|
|||||||
final case class Qualified(
|
final case class Qualified(
|
||||||
parts: List[Name],
|
parts: List[Name],
|
||||||
location: Option[IdentifiedLocation],
|
location: Option[IdentifiedLocation],
|
||||||
passData: MetadataStorage = MetadataStorage(),
|
passData: MetadataStorage = new MetadataStorage(),
|
||||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Name
|
) extends Name
|
||||||
with IRKind.Primitive {
|
with IRKind.Primitive {
|
||||||
@ -266,7 +267,8 @@ object Name {
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
@ -290,7 +292,7 @@ object Name {
|
|||||||
*/
|
*/
|
||||||
sealed case class Blank(
|
sealed case class Blank(
|
||||||
location: Option[IdentifiedLocation],
|
location: Option[IdentifiedLocation],
|
||||||
passData: MetadataStorage = MetadataStorage(),
|
passData: MetadataStorage = new MetadataStorage(),
|
||||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Name
|
) extends Name
|
||||||
with IRKind.Sugar {
|
with IRKind.Sugar {
|
||||||
@ -325,7 +327,8 @@ object Name {
|
|||||||
): Blank =
|
): Blank =
|
||||||
copy(
|
copy(
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
@ -362,7 +365,7 @@ object Name {
|
|||||||
sealed case class Special(
|
sealed case class Special(
|
||||||
specialName: Special.Ident,
|
specialName: Special.Ident,
|
||||||
location: Option[IdentifiedLocation],
|
location: Option[IdentifiedLocation],
|
||||||
passData: MetadataStorage = MetadataStorage(),
|
passData: MetadataStorage = new MetadataStorage(),
|
||||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Name
|
) extends Name
|
||||||
with IRKind.Sugar {
|
with IRKind.Sugar {
|
||||||
@ -397,7 +400,8 @@ object Name {
|
|||||||
): Special =
|
): Special =
|
||||||
copy(
|
copy(
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
@ -455,7 +459,7 @@ object Name {
|
|||||||
override val isMethod: Boolean,
|
override val isMethod: Boolean,
|
||||||
location: Option[IdentifiedLocation],
|
location: Option[IdentifiedLocation],
|
||||||
originalName: Option[Name] = None,
|
originalName: Option[Name] = None,
|
||||||
passData: MetadataStorage = MetadataStorage(),
|
passData: MetadataStorage = new MetadataStorage(),
|
||||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Name {
|
) extends Name {
|
||||||
var id: UUID @Identifier = randomId
|
var id: UUID @Identifier = randomId
|
||||||
@ -495,7 +499,8 @@ object Name {
|
|||||||
): Literal =
|
): Literal =
|
||||||
copy(
|
copy(
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
@ -560,7 +565,7 @@ object Name {
|
|||||||
sealed case class BuiltinAnnotation(
|
sealed case class BuiltinAnnotation(
|
||||||
override val name: String,
|
override val name: String,
|
||||||
location: Option[IdentifiedLocation],
|
location: Option[IdentifiedLocation],
|
||||||
passData: MetadataStorage = MetadataStorage(),
|
passData: MetadataStorage = new MetadataStorage(),
|
||||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Annotation
|
) extends Annotation
|
||||||
with IRKind.Primitive {
|
with IRKind.Primitive {
|
||||||
@ -596,7 +601,8 @@ object Name {
|
|||||||
): BuiltinAnnotation =
|
): BuiltinAnnotation =
|
||||||
copy(
|
copy(
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
@ -645,7 +651,7 @@ object Name {
|
|||||||
override val name: String,
|
override val name: String,
|
||||||
expression: Expression,
|
expression: Expression,
|
||||||
location: Option[IdentifiedLocation],
|
location: Option[IdentifiedLocation],
|
||||||
passData: MetadataStorage = MetadataStorage(),
|
passData: MetadataStorage = new MetadataStorage(),
|
||||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Annotation {
|
) extends Annotation {
|
||||||
var id: UUID @Identifier = randomId
|
var id: UUID @Identifier = randomId
|
||||||
@ -683,7 +689,8 @@ object Name {
|
|||||||
): GenericAnnotation =
|
): GenericAnnotation =
|
||||||
copy(
|
copy(
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
@ -731,7 +738,7 @@ object Name {
|
|||||||
sealed case class Self(
|
sealed case class Self(
|
||||||
location: Option[IdentifiedLocation],
|
location: Option[IdentifiedLocation],
|
||||||
synthetic: Boolean = false,
|
synthetic: Boolean = false,
|
||||||
passData: MetadataStorage = MetadataStorage(),
|
passData: MetadataStorage = new MetadataStorage(),
|
||||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Name {
|
) extends Name {
|
||||||
var id: UUID @Identifier = randomId
|
var id: UUID @Identifier = randomId
|
||||||
@ -766,7 +773,8 @@ object Name {
|
|||||||
): Self =
|
): Self =
|
||||||
copy(
|
copy(
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
@ -808,7 +816,7 @@ object Name {
|
|||||||
*/
|
*/
|
||||||
sealed case class SelfType(
|
sealed case class SelfType(
|
||||||
location: Option[IdentifiedLocation],
|
location: Option[IdentifiedLocation],
|
||||||
passData: MetadataStorage = MetadataStorage(),
|
passData: MetadataStorage = new MetadataStorage(),
|
||||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Name {
|
) extends Name {
|
||||||
var id: UUID @Identifier = randomId
|
var id: UUID @Identifier = randomId
|
||||||
@ -842,7 +850,8 @@ object Name {
|
|||||||
): SelfType =
|
): SelfType =
|
||||||
copy(
|
copy(
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
|
@ -44,7 +44,7 @@ object Pattern {
|
|||||||
sealed case class Name(
|
sealed case class Name(
|
||||||
name: IRName,
|
name: IRName,
|
||||||
override val location: Option[IdentifiedLocation],
|
override val location: Option[IdentifiedLocation],
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Pattern {
|
) extends Pattern {
|
||||||
var id: UUID @Identifier = randomId
|
var id: UUID @Identifier = randomId
|
||||||
@ -85,7 +85,8 @@ object Pattern {
|
|||||||
keepIdentifiers
|
keepIdentifiers
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
@ -136,7 +137,7 @@ object Pattern {
|
|||||||
constructor: IRName,
|
constructor: IRName,
|
||||||
fields: List[Pattern],
|
fields: List[Pattern],
|
||||||
override val location: Option[IdentifiedLocation],
|
override val location: Option[IdentifiedLocation],
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Pattern {
|
) extends Pattern {
|
||||||
var id: UUID @Identifier = randomId
|
var id: UUID @Identifier = randomId
|
||||||
@ -188,7 +189,8 @@ object Pattern {
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
@ -286,7 +288,7 @@ object Pattern {
|
|||||||
sealed case class Literal(
|
sealed case class Literal(
|
||||||
literal: IRLiteral,
|
literal: IRLiteral,
|
||||||
override val location: Option[IdentifiedLocation],
|
override val location: Option[IdentifiedLocation],
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Pattern {
|
) extends Pattern {
|
||||||
var id: UUID @Identifier = randomId
|
var id: UUID @Identifier = randomId
|
||||||
@ -327,7 +329,8 @@ object Pattern {
|
|||||||
keepIdentifiers
|
keepIdentifiers
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
@ -380,7 +383,7 @@ object Pattern {
|
|||||||
name: IRName,
|
name: IRName,
|
||||||
tpe: IRName,
|
tpe: IRName,
|
||||||
override val location: Option[IdentifiedLocation],
|
override val location: Option[IdentifiedLocation],
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Pattern {
|
) extends Pattern {
|
||||||
var id: UUID @Identifier = randomId
|
var id: UUID @Identifier = randomId
|
||||||
@ -429,7 +432,8 @@ object Pattern {
|
|||||||
keepIdentifiers
|
keepIdentifiers
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
@ -482,7 +486,7 @@ object Pattern {
|
|||||||
final case class Documentation(
|
final case class Documentation(
|
||||||
doc: String,
|
doc: String,
|
||||||
override val location: Option[IdentifiedLocation],
|
override val location: Option[IdentifiedLocation],
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Pattern {
|
) extends Pattern {
|
||||||
var id: UUID @Identifier = randomId
|
var id: UUID @Identifier = randomId
|
||||||
@ -530,7 +534,8 @@ object Pattern {
|
|||||||
copy(
|
copy(
|
||||||
doc,
|
doc,
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
|
@ -38,7 +38,7 @@ object Type {
|
|||||||
args: List[Expression],
|
args: List[Expression],
|
||||||
result: Expression,
|
result: Expression,
|
||||||
override val location: Option[IdentifiedLocation],
|
override val location: Option[IdentifiedLocation],
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Type {
|
) extends Type {
|
||||||
var id: UUID @Identifier = randomId
|
var id: UUID @Identifier = randomId
|
||||||
@ -79,7 +79,8 @@ object Type {
|
|||||||
keepIdentifiers
|
keepIdentifiers
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
@ -129,7 +130,7 @@ object Type {
|
|||||||
typed: Expression,
|
typed: Expression,
|
||||||
signature: Expression,
|
signature: Expression,
|
||||||
override val location: Option[IdentifiedLocation],
|
override val location: Option[IdentifiedLocation],
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Type
|
) extends Type
|
||||||
with module.scope.Definition
|
with module.scope.Definition
|
||||||
@ -180,7 +181,8 @@ object Type {
|
|||||||
keepIdentifiers
|
keepIdentifiers
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
@ -235,7 +237,7 @@ object Type {
|
|||||||
typed: Expression,
|
typed: Expression,
|
||||||
context: Expression,
|
context: Expression,
|
||||||
override val location: Option[IdentifiedLocation],
|
override val location: Option[IdentifiedLocation],
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Type
|
) extends Type
|
||||||
with IRKind.Primitive {
|
with IRKind.Primitive {
|
||||||
@ -285,7 +287,8 @@ object Type {
|
|||||||
keepIdentifiers
|
keepIdentifiers
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
@ -338,7 +341,7 @@ object Type {
|
|||||||
typed: Expression,
|
typed: Expression,
|
||||||
error: Expression,
|
error: Expression,
|
||||||
override val location: Option[IdentifiedLocation],
|
override val location: Option[IdentifiedLocation],
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Type
|
) extends Type
|
||||||
with IRKind.Primitive {
|
with IRKind.Primitive {
|
||||||
@ -388,7 +391,8 @@ object Type {
|
|||||||
keepLocations
|
keepLocations
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
|
@ -28,7 +28,7 @@ object Application {
|
|||||||
arguments: List[CallArgument],
|
arguments: List[CallArgument],
|
||||||
hasDefaultsSuspended: Boolean,
|
hasDefaultsSuspended: Boolean,
|
||||||
override val location: Option[IdentifiedLocation],
|
override val location: Option[IdentifiedLocation],
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Application
|
) extends Application
|
||||||
with IRKind.Primitive {
|
with IRKind.Primitive {
|
||||||
@ -91,7 +91,8 @@ object Application {
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
@ -143,7 +144,7 @@ object Application {
|
|||||||
sealed case class Force(
|
sealed case class Force(
|
||||||
target: Expression,
|
target: Expression,
|
||||||
override val location: Option[IdentifiedLocation],
|
override val location: Option[IdentifiedLocation],
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Application
|
) extends Application
|
||||||
with IRKind.Primitive {
|
with IRKind.Primitive {
|
||||||
@ -185,7 +186,8 @@ object Application {
|
|||||||
keepIdentifiers
|
keepIdentifiers
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
@ -254,7 +256,7 @@ object Application {
|
|||||||
sealed case class Typeset(
|
sealed case class Typeset(
|
||||||
expression: Option[Expression],
|
expression: Option[Expression],
|
||||||
override val location: Option[IdentifiedLocation],
|
override val location: Option[IdentifiedLocation],
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Literal
|
) extends Literal
|
||||||
with IRKind.Primitive {
|
with IRKind.Primitive {
|
||||||
@ -303,7 +305,8 @@ object Application {
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
@ -349,7 +352,7 @@ object Application {
|
|||||||
sealed case class Sequence(
|
sealed case class Sequence(
|
||||||
items: List[Expression],
|
items: List[Expression],
|
||||||
override val location: Option[IdentifiedLocation],
|
override val location: Option[IdentifiedLocation],
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Literal
|
) extends Literal
|
||||||
with IRKind.Primitive {
|
with IRKind.Primitive {
|
||||||
@ -398,7 +401,8 @@ object Application {
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
|
@ -43,7 +43,7 @@ object Case {
|
|||||||
branches: Seq[Branch],
|
branches: Seq[Branch],
|
||||||
isNested: Boolean,
|
isNested: Boolean,
|
||||||
override val location: Option[IdentifiedLocation],
|
override val location: Option[IdentifiedLocation],
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Case
|
) extends Case
|
||||||
with IRKind.Primitive {
|
with IRKind.Primitive {
|
||||||
@ -109,7 +109,8 @@ object Case {
|
|||||||
),
|
),
|
||||||
isNested = isNested,
|
isNested = isNested,
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
@ -195,7 +196,7 @@ object Case {
|
|||||||
expression: Expression,
|
expression: Expression,
|
||||||
terminalBranch: Boolean,
|
terminalBranch: Boolean,
|
||||||
override val location: Option[IdentifiedLocation],
|
override val location: Option[IdentifiedLocation],
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Case
|
) extends Case
|
||||||
with IRKind.Primitive {
|
with IRKind.Primitive {
|
||||||
@ -264,7 +265,8 @@ object Case {
|
|||||||
),
|
),
|
||||||
terminalBranch = terminalBranch,
|
terminalBranch = terminalBranch,
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
|
@ -39,7 +39,7 @@ object Comment {
|
|||||||
sealed case class Documentation(
|
sealed case class Documentation(
|
||||||
doc: String,
|
doc: String,
|
||||||
override val location: Option[IdentifiedLocation],
|
override val location: Option[IdentifiedLocation],
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Comment
|
) extends Comment
|
||||||
with IRKind.Primitive {
|
with IRKind.Primitive {
|
||||||
@ -75,7 +75,8 @@ object Comment {
|
|||||||
): Documentation =
|
): Documentation =
|
||||||
copy(
|
copy(
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
|
@ -39,7 +39,7 @@ object Error {
|
|||||||
*/
|
*/
|
||||||
sealed case class InvalidIR(
|
sealed case class InvalidIR(
|
||||||
ir: IR,
|
ir: IR,
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Error
|
) extends Error
|
||||||
with Diagnostic.Kind.Static
|
with Diagnostic.Kind.Static
|
||||||
@ -79,7 +79,8 @@ object Error {
|
|||||||
keepDiagnostics,
|
keepDiagnostics,
|
||||||
keepIdentifiers
|
keepIdentifiers
|
||||||
),
|
),
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
|
@ -44,7 +44,7 @@ object Foreign {
|
|||||||
lang: String,
|
lang: String,
|
||||||
code: String,
|
code: String,
|
||||||
override val location: Option[IdentifiedLocation],
|
override val location: Option[IdentifiedLocation],
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Foreign
|
) extends Foreign
|
||||||
with IRKind.Primitive {
|
with IRKind.Primitive {
|
||||||
@ -82,7 +82,8 @@ object Foreign {
|
|||||||
): Definition =
|
): Definition =
|
||||||
copy(
|
copy(
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
|
@ -43,7 +43,7 @@ object Operator {
|
|||||||
operator: Name,
|
operator: Name,
|
||||||
right: CallArgument,
|
right: CallArgument,
|
||||||
override val location: Option[IdentifiedLocation],
|
override val location: Option[IdentifiedLocation],
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Operator
|
) extends Operator
|
||||||
with IRKind.Sugar {
|
with IRKind.Sugar {
|
||||||
@ -102,7 +102,8 @@ object Operator {
|
|||||||
keepIdentifiers
|
keepIdentifiers
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
|
@ -41,7 +41,7 @@ object Section {
|
|||||||
arg: CallArgument,
|
arg: CallArgument,
|
||||||
operator: Name,
|
operator: Name,
|
||||||
override val location: Option[IdentifiedLocation],
|
override val location: Option[IdentifiedLocation],
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Section
|
) extends Section
|
||||||
with IRKind.Sugar {
|
with IRKind.Sugar {
|
||||||
@ -92,7 +92,8 @@ object Section {
|
|||||||
keepIdentifiers
|
keepIdentifiers
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
@ -142,7 +143,7 @@ object Section {
|
|||||||
sealed case class Sides(
|
sealed case class Sides(
|
||||||
operator: Name,
|
operator: Name,
|
||||||
override val location: Option[IdentifiedLocation],
|
override val location: Option[IdentifiedLocation],
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Section
|
) extends Section
|
||||||
with IRKind.Sugar {
|
with IRKind.Sugar {
|
||||||
@ -185,7 +186,8 @@ object Section {
|
|||||||
keepIdentifiers
|
keepIdentifiers
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
@ -234,7 +236,7 @@ object Section {
|
|||||||
operator: Name,
|
operator: Name,
|
||||||
arg: CallArgument,
|
arg: CallArgument,
|
||||||
override val location: Option[IdentifiedLocation],
|
override val location: Option[IdentifiedLocation],
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Section
|
) extends Section
|
||||||
with IRKind.Sugar {
|
with IRKind.Sugar {
|
||||||
@ -285,7 +287,8 @@ object Section {
|
|||||||
keepIdentifiers
|
keepIdentifiers
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
|
@ -18,7 +18,7 @@ import java.util.UUID
|
|||||||
sealed case class Conversion(
|
sealed case class Conversion(
|
||||||
storedIr: IR,
|
storedIr: IR,
|
||||||
reason: Conversion.Reason,
|
reason: Conversion.Reason,
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Error
|
) extends Error
|
||||||
with Diagnostic.Kind.Interactive
|
with Diagnostic.Kind.Interactive
|
||||||
@ -72,7 +72,8 @@ sealed case class Conversion(
|
|||||||
keepDiagnostics,
|
keepDiagnostics,
|
||||||
keepIdentifiers
|
keepIdentifiers
|
||||||
),
|
),
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
|
@ -20,7 +20,7 @@ import scala.annotation.unused
|
|||||||
sealed case class ImportExport(
|
sealed case class ImportExport(
|
||||||
ir: IR,
|
ir: IR,
|
||||||
reason: ImportExport.Reason,
|
reason: ImportExport.Reason,
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Error
|
) extends Error
|
||||||
with Diagnostic.Kind.Interactive
|
with Diagnostic.Kind.Interactive
|
||||||
@ -58,7 +58,8 @@ sealed case class ImportExport(
|
|||||||
keepIdentifiers: Boolean = false
|
keepIdentifiers: Boolean = false
|
||||||
): ImportExport =
|
): ImportExport =
|
||||||
copy(
|
copy(
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
|
@ -19,7 +19,7 @@ import java.util.UUID
|
|||||||
sealed case class Pattern(
|
sealed case class Pattern(
|
||||||
originalPattern: org.enso.compiler.core.ir.Pattern,
|
originalPattern: org.enso.compiler.core.ir.Pattern,
|
||||||
reason: Pattern.Reason,
|
reason: Pattern.Reason,
|
||||||
passData: MetadataStorage = MetadataStorage(),
|
passData: MetadataStorage = new MetadataStorage(),
|
||||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Error
|
) extends Error
|
||||||
with Diagnostic.Kind.Interactive
|
with Diagnostic.Kind.Interactive
|
||||||
@ -68,7 +68,8 @@ sealed case class Pattern(
|
|||||||
keepDiagnostics,
|
keepDiagnostics,
|
||||||
keepIdentifiers
|
keepIdentifiers
|
||||||
),
|
),
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
|
@ -42,7 +42,7 @@ object Redefined {
|
|||||||
*/
|
*/
|
||||||
sealed case class SelfArg(
|
sealed case class SelfArg(
|
||||||
override val location: Option[IdentifiedLocation],
|
override val location: Option[IdentifiedLocation],
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Redefined
|
) extends Redefined
|
||||||
with Diagnostic.Kind.Interactive
|
with Diagnostic.Kind.Interactive
|
||||||
@ -77,7 +77,8 @@ object Redefined {
|
|||||||
): SelfArg =
|
): SelfArg =
|
||||||
copy(
|
copy(
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
@ -123,7 +124,7 @@ object Redefined {
|
|||||||
targetType: Option[Name],
|
targetType: Option[Name],
|
||||||
sourceType: Name,
|
sourceType: Name,
|
||||||
override val location: Option[IdentifiedLocation],
|
override val location: Option[IdentifiedLocation],
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Redefined
|
) extends Redefined
|
||||||
with Diagnostic.Kind.Interactive
|
with Diagnostic.Kind.Interactive
|
||||||
@ -181,7 +182,8 @@ object Redefined {
|
|||||||
keepIdentifiers
|
keepIdentifiers
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
@ -247,7 +249,7 @@ object Redefined {
|
|||||||
atomName: Option[Name],
|
atomName: Option[Name],
|
||||||
methodName: Name,
|
methodName: Name,
|
||||||
override val location: Option[IdentifiedLocation],
|
override val location: Option[IdentifiedLocation],
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Redefined
|
) extends Redefined
|
||||||
with Diagnostic.Kind.Interactive
|
with Diagnostic.Kind.Interactive
|
||||||
@ -304,7 +306,8 @@ object Redefined {
|
|||||||
keepIdentifiers
|
keepIdentifiers
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
@ -370,7 +373,7 @@ object Redefined {
|
|||||||
atomName: Name,
|
atomName: Name,
|
||||||
methodName: Name,
|
methodName: Name,
|
||||||
override val location: Option[IdentifiedLocation],
|
override val location: Option[IdentifiedLocation],
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Redefined
|
) extends Redefined
|
||||||
with Diagnostic.Kind.Interactive
|
with Diagnostic.Kind.Interactive
|
||||||
@ -430,7 +433,8 @@ object Redefined {
|
|||||||
keepIdentifiers
|
keepIdentifiers
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
@ -488,7 +492,7 @@ object Redefined {
|
|||||||
sealed case class Type(
|
sealed case class Type(
|
||||||
typeName: Name,
|
typeName: Name,
|
||||||
override val location: Option[IdentifiedLocation],
|
override val location: Option[IdentifiedLocation],
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Redefined
|
) extends Redefined
|
||||||
with Diagnostic.Kind.Interactive
|
with Diagnostic.Kind.Interactive
|
||||||
@ -535,7 +539,8 @@ object Redefined {
|
|||||||
keepIdentifiers
|
keepIdentifiers
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
@ -588,7 +593,7 @@ object Redefined {
|
|||||||
*/
|
*/
|
||||||
sealed case class Binding(
|
sealed case class Binding(
|
||||||
invalidBinding: Expression.Binding,
|
invalidBinding: Expression.Binding,
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Redefined
|
) extends Redefined
|
||||||
with Diagnostic.Kind.Interactive
|
with Diagnostic.Kind.Interactive
|
||||||
@ -629,7 +634,8 @@ object Redefined {
|
|||||||
keepDiagnostics,
|
keepDiagnostics,
|
||||||
keepIdentifiers
|
keepIdentifiers
|
||||||
),
|
),
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
|
@ -18,7 +18,7 @@ import java.util.UUID
|
|||||||
sealed case class Resolution(
|
sealed case class Resolution(
|
||||||
originalName: Name,
|
originalName: Name,
|
||||||
reason: Resolution.Reason,
|
reason: Resolution.Reason,
|
||||||
passData: MetadataStorage = MetadataStorage(),
|
passData: MetadataStorage = new MetadataStorage(),
|
||||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Error
|
) extends Error
|
||||||
with Diagnostic.Kind.Interactive
|
with Diagnostic.Kind.Interactive
|
||||||
@ -72,7 +72,8 @@ sealed case class Resolution(
|
|||||||
keepDiagnostics,
|
keepDiagnostics,
|
||||||
keepIdentifiers
|
keepIdentifiers
|
||||||
),
|
),
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = randomId
|
id = randomId
|
||||||
|
@ -20,7 +20,7 @@ import scala.annotation.unused
|
|||||||
sealed case class Syntax(
|
sealed case class Syntax(
|
||||||
at: IdentifiedLocation,
|
at: IdentifiedLocation,
|
||||||
reason: Syntax.Reason,
|
reason: Syntax.Reason,
|
||||||
passData: MetadataStorage = MetadataStorage(),
|
passData: MetadataStorage = new MetadataStorage(),
|
||||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Error
|
) extends Error
|
||||||
with Diagnostic.Kind.Interactive
|
with Diagnostic.Kind.Interactive
|
||||||
@ -59,7 +59,8 @@ sealed case class Syntax(
|
|||||||
keepIdentifiers: Boolean = false
|
keepIdentifiers: Boolean = false
|
||||||
): Syntax =
|
): Syntax =
|
||||||
copy(
|
copy(
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
|
@ -53,7 +53,7 @@ object Unexpected {
|
|||||||
*/
|
*/
|
||||||
sealed case class TypeSignature(
|
sealed case class TypeSignature(
|
||||||
override val ir: IR,
|
override val ir: IR,
|
||||||
passData: MetadataStorage = MetadataStorage(),
|
passData: MetadataStorage = new MetadataStorage(),
|
||||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Unexpected
|
) extends Unexpected
|
||||||
with IRKind.Primitive
|
with IRKind.Primitive
|
||||||
@ -105,7 +105,8 @@ object Unexpected {
|
|||||||
keepDiagnostics,
|
keepDiagnostics,
|
||||||
keepIdentifiers
|
keepIdentifiers
|
||||||
),
|
),
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
|
@ -57,7 +57,7 @@ object Definition {
|
|||||||
params: List[DefinitionArgument],
|
params: List[DefinitionArgument],
|
||||||
members: List[Data],
|
members: List[Data],
|
||||||
location: Option[IdentifiedLocation],
|
location: Option[IdentifiedLocation],
|
||||||
passData: MetadataStorage = MetadataStorage(),
|
passData: MetadataStorage = new MetadataStorage(),
|
||||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Definition
|
) extends Definition
|
||||||
with IRKind.Primitive {
|
with IRKind.Primitive {
|
||||||
@ -101,7 +101,8 @@ object Definition {
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
@ -161,7 +162,7 @@ object Definition {
|
|||||||
arguments: List[DefinitionArgument],
|
arguments: List[DefinitionArgument],
|
||||||
annotations: List[Name.GenericAnnotation],
|
annotations: List[Name.GenericAnnotation],
|
||||||
location: Option[IdentifiedLocation],
|
location: Option[IdentifiedLocation],
|
||||||
passData: MetadataStorage = MetadataStorage(),
|
passData: MetadataStorage = new MetadataStorage(),
|
||||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends IR
|
) extends IR
|
||||||
with IRKind.Primitive {
|
with IRKind.Primitive {
|
||||||
@ -222,7 +223,8 @@ object Definition {
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
@ -283,7 +285,7 @@ object Definition {
|
|||||||
arguments: List[DefinitionArgument],
|
arguments: List[DefinitionArgument],
|
||||||
body: List[IR],
|
body: List[IR],
|
||||||
location: Option[IdentifiedLocation],
|
location: Option[IdentifiedLocation],
|
||||||
passData: MetadataStorage = MetadataStorage(),
|
passData: MetadataStorage = new MetadataStorage(),
|
||||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Definition
|
) extends Definition
|
||||||
with IRKind.Sugar {
|
with IRKind.Sugar {
|
||||||
@ -352,7 +354,8 @@ object Definition {
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
|
@ -57,7 +57,7 @@ object Export {
|
|||||||
hiddenNames: Option[List[Name.Literal]],
|
hiddenNames: Option[List[Name.Literal]],
|
||||||
override val location: Option[IdentifiedLocation],
|
override val location: Option[IdentifiedLocation],
|
||||||
isSynthetic: Boolean = false,
|
isSynthetic: Boolean = false,
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends IR
|
) extends IR
|
||||||
with IRKind.Primitive
|
with IRKind.Primitive
|
||||||
@ -114,7 +114,8 @@ object Export {
|
|||||||
): Module =
|
): Module =
|
||||||
copy(
|
copy(
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
|
@ -57,7 +57,7 @@ object Import {
|
|||||||
hiddenNames: Option[List[Name.Literal]],
|
hiddenNames: Option[List[Name.Literal]],
|
||||||
override val location: Option[IdentifiedLocation],
|
override val location: Option[IdentifiedLocation],
|
||||||
isSynthetic: Boolean = false,
|
isSynthetic: Boolean = false,
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Import
|
) extends Import
|
||||||
with IRKind.Primitive {
|
with IRKind.Primitive {
|
||||||
@ -113,7 +113,8 @@ object Import {
|
|||||||
): Module =
|
): Module =
|
||||||
copy(
|
copy(
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
|
@ -61,7 +61,7 @@ object Method {
|
|||||||
methodReference: Name.MethodReference,
|
methodReference: Name.MethodReference,
|
||||||
body: Expression,
|
body: Expression,
|
||||||
location: Option[IdentifiedLocation],
|
location: Option[IdentifiedLocation],
|
||||||
passData: MetadataStorage = MetadataStorage(),
|
passData: MetadataStorage = new MetadataStorage(),
|
||||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) = {
|
) = {
|
||||||
this(
|
this(
|
||||||
@ -133,7 +133,8 @@ object Method {
|
|||||||
keepIdentifiers
|
keepIdentifiers
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy
|
if (keepDiagnostics) diagnostics.copy
|
||||||
else DiagnosticStorage(),
|
else DiagnosticStorage(),
|
||||||
@ -238,7 +239,7 @@ object Method {
|
|||||||
arguments: List[DefinitionArgument],
|
arguments: List[DefinitionArgument],
|
||||||
override val body: Expression,
|
override val body: Expression,
|
||||||
override val location: Option[IdentifiedLocation],
|
override val location: Option[IdentifiedLocation],
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Method
|
) extends Method
|
||||||
with IRKind.Sugar {
|
with IRKind.Sugar {
|
||||||
@ -305,7 +306,8 @@ object Method {
|
|||||||
keepIdentifiers
|
keepIdentifiers
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy
|
if (keepDiagnostics) diagnostics.copy
|
||||||
else DiagnosticStorage(),
|
else DiagnosticStorage(),
|
||||||
@ -377,7 +379,7 @@ object Method {
|
|||||||
sourceTypeName: Expression,
|
sourceTypeName: Expression,
|
||||||
override val body: Expression,
|
override val body: Expression,
|
||||||
override val location: Option[IdentifiedLocation],
|
override val location: Option[IdentifiedLocation],
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Method
|
) extends Method
|
||||||
with IRKind.Primitive {
|
with IRKind.Primitive {
|
||||||
@ -444,7 +446,8 @@ object Method {
|
|||||||
keepIdentifiers
|
keepIdentifiers
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy
|
if (keepDiagnostics) diagnostics.copy
|
||||||
else DiagnosticStorage(),
|
else DiagnosticStorage(),
|
||||||
|
@ -27,7 +27,7 @@ sealed case class Polyglot(
|
|||||||
entity: Polyglot.Entity,
|
entity: Polyglot.Entity,
|
||||||
rename: Option[String],
|
rename: Option[String],
|
||||||
override val location: Option[IdentifiedLocation],
|
override val location: Option[IdentifiedLocation],
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Import
|
) extends Import
|
||||||
with IRKind.Primitive {
|
with IRKind.Primitive {
|
||||||
@ -67,7 +67,8 @@ sealed case class Polyglot(
|
|||||||
): Polyglot =
|
): Polyglot =
|
||||||
copy(
|
copy(
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
|
@ -45,7 +45,7 @@ object Set {
|
|||||||
memberType: Expression,
|
memberType: Expression,
|
||||||
value: Expression,
|
value: Expression,
|
||||||
override val location: Option[IdentifiedLocation],
|
override val location: Option[IdentifiedLocation],
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Set
|
) extends Set
|
||||||
with IRKind.Primitive {
|
with IRKind.Primitive {
|
||||||
@ -105,7 +105,8 @@ object Set {
|
|||||||
keepIdentifiers
|
keepIdentifiers
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
@ -167,7 +168,7 @@ object Set {
|
|||||||
left: Expression,
|
left: Expression,
|
||||||
right: Expression,
|
right: Expression,
|
||||||
override val location: Option[IdentifiedLocation],
|
override val location: Option[IdentifiedLocation],
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Set
|
) extends Set
|
||||||
with IRKind.Primitive {
|
with IRKind.Primitive {
|
||||||
@ -217,7 +218,8 @@ object Set {
|
|||||||
keepIdentifiers
|
keepIdentifiers
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
@ -271,7 +273,7 @@ object Set {
|
|||||||
left: Expression,
|
left: Expression,
|
||||||
right: Expression,
|
right: Expression,
|
||||||
override val location: Option[IdentifiedLocation],
|
override val location: Option[IdentifiedLocation],
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Set
|
) extends Set
|
||||||
with IRKind.Primitive {
|
with IRKind.Primitive {
|
||||||
@ -321,7 +323,8 @@ object Set {
|
|||||||
keepIdentifiers
|
keepIdentifiers
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
@ -375,7 +378,7 @@ object Set {
|
|||||||
left: Expression,
|
left: Expression,
|
||||||
right: Expression,
|
right: Expression,
|
||||||
override val location: Option[IdentifiedLocation],
|
override val location: Option[IdentifiedLocation],
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Set
|
) extends Set
|
||||||
with IRKind.Primitive {
|
with IRKind.Primitive {
|
||||||
@ -425,7 +428,8 @@ object Set {
|
|||||||
keepIdentifiers
|
keepIdentifiers
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
@ -476,7 +480,7 @@ object Set {
|
|||||||
sealed case class Union(
|
sealed case class Union(
|
||||||
operands: List[Expression],
|
operands: List[Expression],
|
||||||
override val location: Option[IdentifiedLocation],
|
override val location: Option[IdentifiedLocation],
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Set
|
) extends Set
|
||||||
with IRKind.Primitive {
|
with IRKind.Primitive {
|
||||||
@ -521,7 +525,8 @@ object Set {
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
@ -573,7 +578,7 @@ object Set {
|
|||||||
left: Expression,
|
left: Expression,
|
||||||
right: Expression,
|
right: Expression,
|
||||||
override val location: Option[IdentifiedLocation],
|
override val location: Option[IdentifiedLocation],
|
||||||
override val passData: MetadataStorage = MetadataStorage(),
|
override val passData: MetadataStorage = new MetadataStorage(),
|
||||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||||
) extends Set
|
) extends Set
|
||||||
with IRKind.Primitive {
|
with IRKind.Primitive {
|
||||||
@ -623,7 +628,8 @@ object Set {
|
|||||||
keepIdentifiers
|
keepIdentifiers
|
||||||
),
|
),
|
||||||
location = if (keepLocations) location else None,
|
location = if (keepLocations) location else None,
|
||||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
passData =
|
||||||
|
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||||
diagnostics =
|
diagnostics =
|
||||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||||
id = if (keepIdentifiers) id else randomId
|
id = if (keepIdentifiers) id else randomId
|
||||||
|
@ -198,7 +198,7 @@ public class IrPersistanceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void serializeModule() throws Exception {
|
public void serializeModule() throws Exception {
|
||||||
var meta = new MetadataStorage(nil());
|
var meta = new MetadataStorage();
|
||||||
var diag = new DiagnosticStorage(nil());
|
var diag = new DiagnosticStorage(nil());
|
||||||
var m = new Module(nil(), nil(), nil(), true, Option.empty(), meta, diag);
|
var m = new Module(nil(), nil(), nil(), true, Option.empty(), meta, diag);
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import org.enso.compiler.core.Implicits.AsMetadata
|
|||||||
import org.enso.compiler.core.ir.{DefinitionArgument, Expression, Module, Name}
|
import org.enso.compiler.core.ir.{DefinitionArgument, Expression, Module, Name}
|
||||||
import org.enso.compiler.core.ir.module.scope.Definition
|
import org.enso.compiler.core.ir.module.scope.Definition
|
||||||
import org.enso.compiler.core.ir.module.scope.definition
|
import org.enso.compiler.core.ir.module.scope.definition
|
||||||
import org.enso.compiler.core.ir.MetadataStorage.ToPair
|
import org.enso.compiler.core.ir.MetadataStorage.MetadataPair
|
||||||
import org.enso.compiler.data.BindingsMap.ModuleReference
|
import org.enso.compiler.data.BindingsMap.ModuleReference
|
||||||
import org.enso.compiler.data.{BindingsMap, CompilerConfig}
|
import org.enso.compiler.data.{BindingsMap, CompilerConfig}
|
||||||
import org.enso.compiler.pass.analyse.BindingAnalysis
|
import org.enso.compiler.pass.analyse.BindingAnalysis
|
||||||
@ -262,9 +262,12 @@ trait CompilerRunner {
|
|||||||
mod,
|
mod,
|
||||||
Module(List(), List(), List(), false, None)
|
Module(List(), List(), List(), false, None)
|
||||||
.updateMetadata(
|
.updateMetadata(
|
||||||
BindingAnalysis -->> BindingsMap(
|
new MetadataPair(
|
||||||
List(),
|
BindingAnalysis,
|
||||||
ModuleReference.Concrete(mod.asCompilerModule())
|
BindingsMap(
|
||||||
|
List(),
|
||||||
|
ModuleReference.Concrete(mod.asCompilerModule())
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -5,10 +5,10 @@ import org.enso.compiler.core.ir.Expression
|
|||||||
import org.enso.compiler.core.ir.Module
|
import org.enso.compiler.core.ir.Module
|
||||||
import org.enso.compiler.core.ir.MetadataStorage
|
import org.enso.compiler.core.ir.MetadataStorage
|
||||||
import org.enso.compiler.core.ir.MetadataStorage._
|
import org.enso.compiler.core.ir.MetadataStorage._
|
||||||
import org.enso.compiler.core.CompilerError
|
|
||||||
import org.enso.compiler.pass.IRPass
|
import org.enso.compiler.pass.IRPass
|
||||||
import org.enso.compiler.test.CompilerTest
|
import org.enso.compiler.test.CompilerTest
|
||||||
import shapeless.test.illTyped
|
import shapeless.test.illTyped
|
||||||
|
import scala.jdk.CollectionConverters._
|
||||||
|
|
||||||
class MetadataStorageTest extends CompilerTest {
|
class MetadataStorageTest extends CompilerTest {
|
||||||
|
|
||||||
@ -82,118 +82,133 @@ class MetadataStorageTest extends CompilerTest {
|
|||||||
|
|
||||||
"The metadata storage" should {
|
"The metadata storage" should {
|
||||||
"allow adding metadata pairs" in {
|
"allow adding metadata pairs" in {
|
||||||
val meta = MetadataStorage()
|
val meta = new MetadataStorage()
|
||||||
|
|
||||||
val pass = TestPass1
|
val pass = TestPass1
|
||||||
val passMeta = TestPass1.Metadata1()
|
val passMeta = TestPass1.Metadata1()
|
||||||
val depPair = pass -->> passMeta
|
val depPair = new MetadataPair(pass, passMeta)
|
||||||
|
|
||||||
meta.update(depPair)
|
meta.update(depPair)
|
||||||
meta.get(pass) shouldEqual Some(passMeta)
|
meta.get(pass) shouldEqual Some(passMeta)
|
||||||
}
|
}
|
||||||
|
|
||||||
"allow adding metadata" in {
|
"allow adding metadata" in {
|
||||||
val meta = MetadataStorage()
|
val meta = new MetadataStorage()
|
||||||
|
|
||||||
val meta1 = TestPass1.Metadata1()
|
val meta1 = TestPass1.Metadata1()
|
||||||
val meta2 = TestPass2.Metadata2()
|
val meta2 = TestPass2.Metadata2()
|
||||||
|
|
||||||
meta.update(TestPass1)(meta1)
|
meta.update(TestPass1, meta1)
|
||||||
meta.update(TestPass2)(meta2)
|
meta.update(TestPass2, meta2)
|
||||||
|
|
||||||
meta.get(TestPass1) shouldEqual Some(meta1)
|
meta.get(TestPass1) shouldEqual Some(meta1)
|
||||||
meta.get(TestPass2) shouldEqual Some(meta2)
|
meta.get(TestPass2) shouldEqual Some(meta2)
|
||||||
}
|
}
|
||||||
|
|
||||||
"allow getting metadata" in {
|
"allow getting metadata" in {
|
||||||
val meta = MetadataStorage()
|
val meta = new MetadataStorage()
|
||||||
val passMeta = TestPass1.Metadata1()
|
val passMeta = TestPass1.Metadata1()
|
||||||
|
|
||||||
meta.update(TestPass1)(passMeta)
|
meta.update(TestPass1, passMeta)
|
||||||
meta.get(TestPass1) shouldEqual Some(passMeta)
|
meta.get(TestPass1) shouldEqual Some(passMeta)
|
||||||
}
|
}
|
||||||
|
|
||||||
"allow unsafely getting metadata" in {
|
"allow unsafely getting metadata" in {
|
||||||
val meta = MetadataStorage()
|
val meta = new MetadataStorage()
|
||||||
val passMeta = TestPass1.Metadata1()
|
val passMeta = TestPass1.Metadata1()
|
||||||
|
|
||||||
meta.update(TestPass1)(passMeta)
|
meta.update(TestPass1, passMeta)
|
||||||
meta.getUnsafe(TestPass1)("aaaa") shouldEqual passMeta
|
meta.get(TestPass1).get shouldEqual passMeta
|
||||||
|
|
||||||
def testThrow = meta.getUnsafe(TestPass2)("aaa")
|
meta.get(TestPass2) match {
|
||||||
val msg = "Compiler Internal Error: aaa"
|
case None =>
|
||||||
|
case any => fail("Expecting None: " + any)
|
||||||
|
}
|
||||||
|
|
||||||
the[CompilerError] thrownBy testThrow should have message msg
|
|
||||||
}
|
}
|
||||||
|
|
||||||
"allow updating metadata" in {
|
"allow updating metadata" in {
|
||||||
val meta = MetadataStorage()
|
val meta = new MetadataStorage()
|
||||||
|
|
||||||
val meta1 = TestPass1.Metadata1()
|
val meta1 = TestPass1.Metadata1()
|
||||||
val meta2 = TestPass1.Metadata1()
|
val meta2 = TestPass1.Metadata1()
|
||||||
|
|
||||||
meta.update(TestPass1)(meta1)
|
meta.update(TestPass1, meta1)
|
||||||
meta.get(TestPass1) shouldEqual Some(meta1)
|
meta.get(TestPass1) shouldEqual Some(meta1)
|
||||||
meta.update(TestPass1)(meta2)
|
meta.update(TestPass1, meta2)
|
||||||
meta.get(TestPass1) shouldEqual Some(meta2)
|
meta.get(TestPass1) shouldEqual Some(meta2)
|
||||||
}
|
}
|
||||||
|
|
||||||
"allow removing metadata" in {
|
"allow removing metadata" in {
|
||||||
val meta = MetadataStorage()
|
val meta = new MetadataStorage()
|
||||||
|
|
||||||
val meta1 = TestPass1.Metadata1()
|
val meta1 = TestPass1.Metadata1()
|
||||||
meta.update(TestPass1)(meta1)
|
meta.update(TestPass1, meta1)
|
||||||
|
|
||||||
meta.remove(TestPass1) shouldEqual Some(meta1)
|
meta.remove(TestPass1) shouldEqual Some(meta1)
|
||||||
meta.get(TestPass1) shouldEqual None
|
meta.get(TestPass1) shouldEqual None
|
||||||
}
|
}
|
||||||
|
|
||||||
"compare equal when containing the same metadata" in {
|
"compare equal when containing the same metadata" in {
|
||||||
val meta1 = MetadataStorage()
|
val meta1 = new MetadataStorage()
|
||||||
val meta2 = MetadataStorage()
|
val meta2 = new MetadataStorage()
|
||||||
|
|
||||||
meta1 shouldEqual meta2
|
meta1 shouldEqual meta2
|
||||||
|
|
||||||
meta1.update(TestPass1)(TestPass1.Metadata1())
|
meta1.update(TestPass1, TestPass1.Metadata1())
|
||||||
meta2.update(TestPass1)(TestPass1.Metadata1())
|
meta2.update(TestPass1, TestPass1.Metadata1())
|
||||||
|
|
||||||
meta1 shouldEqual meta2
|
meta1 shouldEqual meta2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def newMetadataStorage(init: Seq[MetadataPair[_]]): MetadataStorage = {
|
||||||
|
val meta = new MetadataStorage()
|
||||||
|
for (p <- init) {
|
||||||
|
meta.update(p)
|
||||||
|
}
|
||||||
|
meta
|
||||||
|
}
|
||||||
|
|
||||||
"allow mapping over the internal mapping to generate some output" in {
|
"allow mapping over the internal mapping to generate some output" in {
|
||||||
val meta = MetadataStorage(
|
val meta = newMetadataStorage(
|
||||||
TestPass1 -->> TestPass1.Metadata1(),
|
Seq(
|
||||||
TestPass2 -->> TestPass2.Metadata2()
|
new MetadataPair(TestPass1, TestPass1.Metadata1()),
|
||||||
|
new MetadataPair(TestPass2, TestPass2.Metadata2())
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
val expected = Map(
|
val expected = List(
|
||||||
TestPass1 -> "TestPass1.Metadata1",
|
(TestPass1, "TestPass1.Metadata1"),
|
||||||
TestPass2 -> "TestPass2.Metadata2"
|
(TestPass2, "TestPass2.Metadata2")
|
||||||
)
|
)
|
||||||
|
|
||||||
meta.map((p, m) => (p, m.metadataName)) shouldEqual expected
|
meta.map((p, m) => (p, m.metadataName)).asScala shouldEqual expected
|
||||||
}
|
}
|
||||||
|
|
||||||
"allow copying to create a new instance with the same data" in {
|
"allow copying to create a new instance with the same data" in {
|
||||||
val meta = MetadataStorage(
|
val meta = newMetadataStorage(
|
||||||
TestPass1 -->> TestPass1.Metadata1(),
|
Seq(
|
||||||
TestPass2 -->> TestPass2.Metadata2()
|
new MetadataPair(TestPass1, TestPass1.Metadata1()),
|
||||||
|
new MetadataPair(TestPass2, TestPass2.Metadata2())
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
val expected = MetadataStorage(
|
val expected = newMetadataStorage(
|
||||||
TestPass1 -->> TestPass1.Metadata1(),
|
Seq(
|
||||||
TestPass2 -->> TestPass2.Metadata2()
|
new MetadataPair(TestPass1, TestPass1.Metadata1()),
|
||||||
|
new MetadataPair(TestPass2, TestPass2.Metadata2())
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
meta.copy shouldEqual meta
|
meta.duplicate shouldEqual meta
|
||||||
meta.copy shouldEqual expected
|
meta.duplicate shouldEqual expected
|
||||||
}
|
}
|
||||||
|
|
||||||
"enforce safe construction" in {
|
"enforce safe construction" in {
|
||||||
val test1 = TestPass1 -->> TestPass1.Metadata1()
|
val test1 = new MetadataPair(TestPass1, TestPass1.Metadata1())
|
||||||
val test2 = TestPass2 -->> TestPass2.Metadata2()
|
val test2 = new MetadataPair(TestPass2, TestPass2.Metadata2())
|
||||||
|
|
||||||
MetadataStorage(test1, test2)
|
newMetadataStorage(Seq(test1, test2))
|
||||||
|
|
||||||
illTyped("TestPass1 -->> TestPass2.Metadata1()")
|
illTyped("TestPass1 -->> TestPass2.Metadata1()")
|
||||||
illTyped("PassConfiguration(test1, (1, 1))")
|
illTyped("PassConfiguration(test1, (1, 1))")
|
||||||
|
Loading…
Reference in New Issue
Block a user