mirror of
https://github.com/enso-org/enso.git
synced 2024-11-26 17:06:48 +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 =>
|
||||
occ.copy(graph = copyRootScopeGraph)
|
||||
}
|
||||
copyNode.updateMetadata(this -->> newMeta)
|
||||
copyNode.updateMetadata(new MetadataPair(this, newMeta))
|
||||
case None =>
|
||||
}
|
||||
}
|
||||
@ -243,7 +243,9 @@ case object AliasAnalysis extends IRPass {
|
||||
topLevelGraph.rootScope,
|
||||
lambdaReuseScope = true
|
||||
)
|
||||
).updateMetadata(this -->> Info.Scope.Root(topLevelGraph))
|
||||
).updateMetadata(
|
||||
new MetadataPair(this, Info.Scope.Root(topLevelGraph))
|
||||
)
|
||||
case _ =>
|
||||
throw new CompilerError(
|
||||
"The body of a method should always be a function."
|
||||
@ -259,7 +261,9 @@ case object AliasAnalysis extends IRPass {
|
||||
topLevelGraph.rootScope,
|
||||
lambdaReuseScope = true
|
||||
)
|
||||
).updateMetadata(this -->> Info.Scope.Root(topLevelGraph))
|
||||
).updateMetadata(
|
||||
new MetadataPair(this, Info.Scope.Root(topLevelGraph))
|
||||
)
|
||||
case _ =>
|
||||
throw new CompilerError(
|
||||
"The body of a method should always be a function."
|
||||
@ -293,11 +297,13 @@ case object AliasAnalysis extends IRPass {
|
||||
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 =>
|
||||
throw new CompilerError(
|
||||
"Complex type definitions should not be present during " +
|
||||
@ -326,7 +332,9 @@ case object AliasAnalysis extends IRPass {
|
||||
topLevelGraph.rootScope
|
||||
)
|
||||
)
|
||||
.updateMetadata(this -->> Info.Scope.Root(topLevelGraph))
|
||||
.updateMetadata(
|
||||
new MetadataPair(this, Info.Scope.Root(topLevelGraph))
|
||||
)
|
||||
case err: Error => err
|
||||
}
|
||||
}
|
||||
@ -390,7 +398,9 @@ case object AliasAnalysis extends IRPass {
|
||||
currentScope
|
||||
)
|
||||
)
|
||||
.updateMetadata(this -->> Info.Scope.Child(graph, currentScope))
|
||||
.updateMetadata(
|
||||
new MetadataPair(this, Info.Scope.Child(graph, currentScope))
|
||||
)
|
||||
case binding @ Expression.Binding(name, expression, _, _, _) =>
|
||||
if (!parentScope.hasSymbolOccurrenceAs[Occurrence.Def](name.name)) {
|
||||
val isSuspended = expression match {
|
||||
@ -418,7 +428,9 @@ case object AliasAnalysis extends IRPass {
|
||||
parentScope
|
||||
)
|
||||
)
|
||||
.updateMetadata(this -->> Info.Occurrence(graph, occurrenceId))
|
||||
.updateMetadata(
|
||||
new MetadataPair(this, Info.Occurrence(graph, occurrenceId))
|
||||
)
|
||||
} else {
|
||||
errors.Redefined.Binding(binding)
|
||||
}
|
||||
@ -467,7 +479,9 @@ case object AliasAnalysis extends IRPass {
|
||||
memberType = analyseExpression(memberType, graph, memberTypeScope),
|
||||
value = analyseExpression(value, graph, valueScope)
|
||||
)
|
||||
.updateMetadata(this -->> Info.Occurrence(graph, labelId))
|
||||
.updateMetadata(
|
||||
new MetadataPair(this, Info.Occurrence(graph, labelId))
|
||||
)
|
||||
case x =>
|
||||
x.mapExpressions(analyseExpression(_, graph, parentScope))
|
||||
}
|
||||
@ -515,7 +529,9 @@ case object AliasAnalysis extends IRPass {
|
||||
)
|
||||
scope.addDefinition(definition)
|
||||
arg
|
||||
.updateMetadata(this -->> Info.Occurrence(graph, occurrenceId))
|
||||
.updateMetadata(
|
||||
new MetadataPair(this, Info.Occurrence(graph, occurrenceId))
|
||||
)
|
||||
.copy(
|
||||
ascribedType =
|
||||
arg.ascribedType.map(analyseExpression(_, graph, scope))
|
||||
@ -553,7 +569,9 @@ case object AliasAnalysis extends IRPass {
|
||||
ascribedType =
|
||||
arg.ascribedType.map(analyseExpression(_, graph, scope))
|
||||
)
|
||||
.updateMetadata(this -->> Info.Occurrence(graph, occurrenceId))
|
||||
.updateMetadata(
|
||||
new MetadataPair(this, Info.Occurrence(graph, occurrenceId))
|
||||
)
|
||||
} else {
|
||||
throw new CompilerError(
|
||||
s"""
|
||||
@ -591,7 +609,9 @@ case object AliasAnalysis extends IRPass {
|
||||
val newScope = scope.addChild()
|
||||
tSet
|
||||
.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 =>
|
||||
throw new CompilerError(
|
||||
"Binary operator occurred during Alias Analysis."
|
||||
@ -622,7 +642,9 @@ case object AliasAnalysis extends IRPass {
|
||||
}
|
||||
arg
|
||||
.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
|
||||
)
|
||||
)
|
||||
.updateMetadata(this -->> Info.Scope.Child(graph, currentScope))
|
||||
.updateMetadata(
|
||||
new MetadataPair(this, Info.Scope.Child(graph, currentScope))
|
||||
)
|
||||
case _: Function.Binding =>
|
||||
throw new CompilerError(
|
||||
"Function sugar should not be present during alias analysis."
|
||||
@ -698,7 +722,9 @@ case object AliasAnalysis extends IRPass {
|
||||
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.
|
||||
@ -748,7 +774,9 @@ case object AliasAnalysis extends IRPass {
|
||||
currentScope
|
||||
)
|
||||
)
|
||||
.updateMetadata(this -->> Info.Scope.Child(graph, currentScope))
|
||||
.updateMetadata(
|
||||
new MetadataPair(this, Info.Scope.Child(graph, currentScope))
|
||||
)
|
||||
}
|
||||
|
||||
/** 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.core.Implicits.AsMetadata
|
||||
import org.enso.compiler.core.ir.MetadataStorage.MetadataPair
|
||||
import org.enso.compiler.core.ir.{
|
||||
CallArgument,
|
||||
Expression,
|
||||
@ -10,7 +11,6 @@ import org.enso.compiler.core.ir.{
|
||||
Module,
|
||||
Name
|
||||
}
|
||||
import org.enso.compiler.core.ir.MetadataStorage.ToPair
|
||||
import org.enso.compiler.core.ir.module.scope.definition
|
||||
import org.enso.compiler.data.BindingsMap.{Resolution, ResolvedMethod}
|
||||
import org.enso.compiler.core.CompilerError
|
||||
@ -302,7 +302,9 @@ object AutomaticParallelism extends IRPass {
|
||||
),
|
||||
None
|
||||
)
|
||||
.updateMetadata(IgnoredBindings -->> IgnoredBindings.State.Ignored)
|
||||
.updateMetadata(
|
||||
new MetadataPair(IgnoredBindings, IgnoredBindings.State.Ignored)
|
||||
)
|
||||
)
|
||||
|
||||
val threadSpawns = threadBlocks.values.map { exprs =>
|
||||
@ -336,7 +338,9 @@ object AutomaticParallelism extends IRPass {
|
||||
)
|
||||
Expression
|
||||
.Binding(freshNameSupply.newName(), spawn, None)
|
||||
.updateMetadata(IgnoredBindings -->> IgnoredBindings.State.Ignored)
|
||||
.updateMetadata(
|
||||
new MetadataPair(IgnoredBindings, IgnoredBindings.State.Ignored)
|
||||
)
|
||||
}
|
||||
|
||||
val threadJoins = threadSpawns.map { bind =>
|
||||
@ -360,7 +364,9 @@ object AutomaticParallelism extends IRPass {
|
||||
),
|
||||
None
|
||||
)
|
||||
.updateMetadata(IgnoredBindings -->> IgnoredBindings.State.Ignored)
|
||||
.updateMetadata(
|
||||
new MetadataPair(IgnoredBindings, IgnoredBindings.State.Ignored)
|
||||
)
|
||||
}
|
||||
|
||||
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.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.Cons
|
||||
import org.enso.compiler.pass.IRPass
|
||||
@ -95,9 +95,12 @@ case object BindingAnalysis extends IRPass {
|
||||
.flatten
|
||||
.map(BindingsMap.ModuleMethod)
|
||||
ir.updateMetadata(
|
||||
this -->> BindingsMap(
|
||||
definedSumTypes ++ importedPolyglot ++ moduleMethods,
|
||||
moduleContext.moduleReference()
|
||||
new MetadataPair(
|
||||
this,
|
||||
BindingsMap(
|
||||
definedSumTypes ++ importedPolyglot ++ moduleMethods,
|
||||
moduleContext.moduleReference()
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ case object CachePreferenceAnalysis extends IRPass {
|
||||
): Module = {
|
||||
val weights = WeightInfo()
|
||||
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.
|
||||
@ -93,12 +93,12 @@ case object CachePreferenceAnalysis extends IRPass {
|
||||
case method: definition.Method.Conversion =>
|
||||
method
|
||||
.copy(body = analyseExpression(method.body, weights))
|
||||
.updateMetadata(this -->> weights)
|
||||
.updateMetadata(new MetadataPair(this, weights))
|
||||
case method @ definition.Method
|
||||
.Explicit(_, body, _, _, _) =>
|
||||
method
|
||||
.copy(body = analyseExpression(body, weights))
|
||||
.updateMetadata(this -->> weights)
|
||||
.updateMetadata(new MetadataPair(this, weights))
|
||||
case _: definition.Method.Binding =>
|
||||
throw new CompilerError(
|
||||
"Sugared method definitions should not occur during cache " +
|
||||
@ -145,10 +145,10 @@ case object CachePreferenceAnalysis extends IRPass {
|
||||
.foreach(weights.update(_, Weight.Always))
|
||||
binding
|
||||
.copy(
|
||||
name = binding.name.updateMetadata(this -->> weights),
|
||||
name = binding.name.updateMetadata(new MetadataPair(this, weights)),
|
||||
expression = analyseExpression(binding.expression, weights)
|
||||
)
|
||||
.updateMetadata(this -->> weights)
|
||||
.updateMetadata(new MetadataPair(this, weights))
|
||||
case error: Error =>
|
||||
error
|
||||
case expr =>
|
||||
@ -157,7 +157,7 @@ case object CachePreferenceAnalysis extends IRPass {
|
||||
}
|
||||
expr
|
||||
.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, _, _, _, _) =>
|
||||
spec
|
||||
.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
|
||||
ir.copy(
|
||||
bindings = ir.bindings.map(analyseModuleDefinition(_, dependencyInfo))
|
||||
).updateMetadata(this -->> dependencyInfo)
|
||||
).updateMetadata(new MetadataPair(this, dependencyInfo))
|
||||
}
|
||||
|
||||
/** Performs dataflow analysis on an inline expression.
|
||||
@ -117,7 +117,7 @@ case object DataflowAnalysis extends IRPass {
|
||||
sourceNodes.lazyZip(copyNodes).foreach { case (src, copy) =>
|
||||
src
|
||||
.getMetadata(this)
|
||||
.foreach(_ => copy.updateMetadata(this -->> copyMeta))
|
||||
.foreach(_ => copy.updateMetadata(new MetadataPair(this, copyMeta)))
|
||||
}
|
||||
|
||||
copyOfIr.asInstanceOf[T]
|
||||
@ -151,9 +151,10 @@ case object DataflowAnalysis extends IRPass {
|
||||
info.dependencies.updateAt(methodDep, Set(bodyDep, sourceTypeDep))
|
||||
|
||||
m.copy(
|
||||
body = analyseExpression(m.body, info),
|
||||
sourceTypeName = m.sourceTypeName.updateMetadata(this -->> info)
|
||||
).updateMetadata(this -->> info)
|
||||
body = analyseExpression(m.body, info),
|
||||
sourceTypeName =
|
||||
m.sourceTypeName.updateMetadata(new MetadataPair(this, info))
|
||||
).updateMetadata(new MetadataPair(this, info))
|
||||
case method @ definition.Method
|
||||
.Explicit(_, body, _, _, _) =>
|
||||
val bodyDep = asStatic(body)
|
||||
@ -163,7 +164,7 @@ case object DataflowAnalysis extends IRPass {
|
||||
|
||||
method
|
||||
.copy(body = analyseExpression(body, info))
|
||||
.updateMetadata(this -->> info)
|
||||
.updateMetadata(new MetadataPair(this, info))
|
||||
case tp @ Definition.Type(_, params, members, _, _, _) =>
|
||||
val tpDep = asStatic(tp)
|
||||
val newParams = params.map { param =>
|
||||
@ -186,10 +187,10 @@ case object DataflowAnalysis extends IRPass {
|
||||
.copy(
|
||||
arguments = data.arguments.map(analyseDefinitionArgument(_, info))
|
||||
)
|
||||
.updateMetadata(this -->> info)
|
||||
.updateMetadata(new MetadataPair(this, info))
|
||||
}
|
||||
tp.copy(params = newParams, members = newMembers)
|
||||
.updateMetadata(this -->> info)
|
||||
.updateMetadata(new MetadataPair(this, info))
|
||||
case _: definition.Method.Binding =>
|
||||
throw new CompilerError(
|
||||
"Sugared method definitions should not occur during dataflow " +
|
||||
@ -217,7 +218,7 @@ case object DataflowAnalysis extends IRPass {
|
||||
case ann: Name.GenericAnnotation =>
|
||||
ann
|
||||
.copy(expression = analyseExpression(ann.expression, info))
|
||||
.updateMetadata(this -->> info)
|
||||
.updateMetadata(new MetadataPair(this, info))
|
||||
case err: Error => err
|
||||
}
|
||||
}
|
||||
@ -236,16 +237,16 @@ case object DataflowAnalysis extends IRPass {
|
||||
info: DependencyInfo
|
||||
): Expression = {
|
||||
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 app: Application => analyseApplication(app, info)
|
||||
case typ: Type => analyseType(typ, info)
|
||||
case name: Name => analyseName(name, info)
|
||||
case cse: Case => analyseCase(cse, info)
|
||||
case literal: Literal =>
|
||||
literal.updateMetadata(this -->> info)
|
||||
literal.updateMetadata(new MetadataPair(this, info))
|
||||
case foreign: Foreign =>
|
||||
foreign.updateMetadata(this -->> info)
|
||||
foreign.updateMetadata(new MetadataPair(this, info))
|
||||
|
||||
case block @ Expression.Block(expressions, returnValue, _, _, _, _) =>
|
||||
val retValDep = asStatic(returnValue)
|
||||
@ -258,7 +259,7 @@ case object DataflowAnalysis extends IRPass {
|
||||
expressions = expressions.map(analyseExpression(_, info)),
|
||||
returnValue = analyseExpression(returnValue, info)
|
||||
)
|
||||
.updateMetadata(this -->> info)
|
||||
.updateMetadata(new MetadataPair(this, info))
|
||||
case binding @ Expression.Binding(name, expression, _, _, _) =>
|
||||
val expressionDep = asStatic(expression)
|
||||
val nameDep = asStatic(name)
|
||||
@ -269,10 +270,10 @@ case object DataflowAnalysis extends IRPass {
|
||||
|
||||
binding
|
||||
.copy(
|
||||
name = name.updateMetadata(this -->> info),
|
||||
name = name.updateMetadata(new MetadataPair(this, info)),
|
||||
expression = analyseExpression(expression, info)
|
||||
)
|
||||
.updateMetadata(this -->> info)
|
||||
.updateMetadata(new MetadataPair(this, info))
|
||||
|
||||
case error: Error => error
|
||||
case _: Comment =>
|
||||
@ -307,7 +308,7 @@ case object DataflowAnalysis extends IRPass {
|
||||
arguments = arguments.map(analyseDefinitionArgument(_, info)),
|
||||
body = analyseExpression(body, info)
|
||||
)
|
||||
.updateMetadata(this -->> info)
|
||||
.updateMetadata(new MetadataPair(this, info))
|
||||
case _: Function.Binding =>
|
||||
throw new CompilerError(
|
||||
"Function sugar should not be present during dataflow analysis."
|
||||
@ -345,7 +346,7 @@ case object DataflowAnalysis extends IRPass {
|
||||
function = analyseExpression(fn, info),
|
||||
arguments = args.map(analyseCallArgument(_, info))
|
||||
)
|
||||
.updateMetadata(this -->> info)
|
||||
.updateMetadata(new MetadataPair(this, info))
|
||||
case force @ Application.Force(target, _, _, _) =>
|
||||
val targetDep = asStatic(target)
|
||||
val forceDep = asStatic(force)
|
||||
@ -354,7 +355,7 @@ case object DataflowAnalysis extends IRPass {
|
||||
|
||||
force
|
||||
.copy(target = analyseExpression(target, info))
|
||||
.updateMetadata(this -->> info)
|
||||
.updateMetadata(new MetadataPair(this, info))
|
||||
case vector @ Application.Sequence(items, _, _, _) =>
|
||||
val vectorDep = asStatic(vector)
|
||||
items.foreach(it => {
|
||||
@ -365,7 +366,7 @@ case object DataflowAnalysis extends IRPass {
|
||||
|
||||
vector
|
||||
.copy(items = items.map(analyseExpression(_, info)))
|
||||
.updateMetadata(this -->> info)
|
||||
.updateMetadata(new MetadataPair(this, info))
|
||||
case tSet @ Application.Typeset(expr, _, _, _) =>
|
||||
val tSetDep = asStatic(tSet)
|
||||
expr.foreach(exp => {
|
||||
@ -376,7 +377,7 @@ case object DataflowAnalysis extends IRPass {
|
||||
|
||||
tSet
|
||||
.copy(expression = expr.map(analyseExpression(_, info)))
|
||||
.updateMetadata(this -->> info)
|
||||
.updateMetadata(new MetadataPair(this, info))
|
||||
case _: Operator =>
|
||||
throw new CompilerError("Unexpected operator during Dataflow Analysis.")
|
||||
}
|
||||
@ -405,7 +406,7 @@ case object DataflowAnalysis extends IRPass {
|
||||
typed = analyseExpression(typed, info),
|
||||
signature = analyseExpression(signature, info)
|
||||
)
|
||||
.updateMetadata(this -->> info)
|
||||
.updateMetadata(new MetadataPair(this, info))
|
||||
|
||||
case fun @ Type.Function(args, result, _, _, _) =>
|
||||
val funDep = asStatic(fun)
|
||||
@ -420,7 +421,7 @@ case object DataflowAnalysis extends IRPass {
|
||||
args = args.map(analyseExpression(_, info)),
|
||||
result = analyseExpression(result, info)
|
||||
)
|
||||
.updateMetadata(this -->> info)
|
||||
.updateMetadata(new MetadataPair(this, info))
|
||||
case ctx @ Type.Context(typed, context, _, _, _) =>
|
||||
val ctxDep = asStatic(ctx)
|
||||
val typedDep = asStatic(typed)
|
||||
@ -434,7 +435,7 @@ case object DataflowAnalysis extends IRPass {
|
||||
typed = analyseExpression(typed, info),
|
||||
context = analyseExpression(context, info)
|
||||
)
|
||||
.updateMetadata(this -->> info)
|
||||
.updateMetadata(new MetadataPair(this, info))
|
||||
case err @ Type.Error(typed, error, _, _, _) =>
|
||||
val errDep = asStatic(err)
|
||||
val typedDep = asStatic(typed)
|
||||
@ -448,7 +449,7 @@ case object DataflowAnalysis extends IRPass {
|
||||
typed = analyseExpression(typed, info),
|
||||
error = analyseExpression(error, info)
|
||||
)
|
||||
.updateMetadata(this -->> info)
|
||||
.updateMetadata(new MetadataPair(this, info))
|
||||
case member @ `type`.Set.Member(_, memberType, value, _, _, _) =>
|
||||
val memberDep = asStatic(member)
|
||||
val memberTypeDep = asStatic(memberType)
|
||||
@ -462,7 +463,7 @@ case object DataflowAnalysis extends IRPass {
|
||||
memberType = analyseExpression(memberType, info),
|
||||
value = analyseExpression(value, info)
|
||||
)
|
||||
.updateMetadata(this -->> info)
|
||||
.updateMetadata(new MetadataPair(this, info))
|
||||
case concat @ `type`.Set.Concat(left, right, _, _, _) =>
|
||||
val concatDep = asStatic(concat)
|
||||
val leftDep = asStatic(left)
|
||||
@ -476,7 +477,7 @@ case object DataflowAnalysis extends IRPass {
|
||||
left = analyseExpression(left, info),
|
||||
right = analyseExpression(right, info)
|
||||
)
|
||||
.updateMetadata(this -->> info)
|
||||
.updateMetadata(new MetadataPair(this, info))
|
||||
case eq @ `type`.Set.Equality(left, right, _, _, _) =>
|
||||
val eqDep = asStatic(eq)
|
||||
val leftDep = asStatic(left)
|
||||
@ -488,7 +489,7 @@ case object DataflowAnalysis extends IRPass {
|
||||
eq.copy(
|
||||
left = analyseExpression(left, info),
|
||||
right = analyseExpression(right, info)
|
||||
).updateMetadata(this -->> info)
|
||||
).updateMetadata(new MetadataPair(this, info))
|
||||
case intersect @ `type`.Set.Intersection(left, right, _, _, _) =>
|
||||
val intersectDep = asStatic(intersect)
|
||||
val leftDep = asStatic(left)
|
||||
@ -502,7 +503,7 @@ case object DataflowAnalysis extends IRPass {
|
||||
left = analyseExpression(left, info),
|
||||
right = analyseExpression(right, info)
|
||||
)
|
||||
.updateMetadata(this -->> info)
|
||||
.updateMetadata(new MetadataPair(this, info))
|
||||
case union @ `type`.Set.Union(operands, _, _, _) =>
|
||||
val unionDep = asStatic(union)
|
||||
val opDeps = operands.map(asStatic)
|
||||
@ -510,7 +511,7 @@ case object DataflowAnalysis extends IRPass {
|
||||
info.dependencies.updateAt(unionDep, opDeps.toSet)
|
||||
union
|
||||
.copy(operands = operands.map(analyseExpression(_, info)))
|
||||
.updateMetadata(this -->> info)
|
||||
.updateMetadata(new MetadataPair(this, info))
|
||||
case subsumption @ `type`.Set.Subsumption(left, right, _, _, _) =>
|
||||
val subDep = asStatic(subsumption)
|
||||
val leftDep = asStatic(left)
|
||||
@ -524,7 +525,7 @@ case object DataflowAnalysis extends IRPass {
|
||||
left = analyseExpression(left, 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 = {
|
||||
val aliasInfo = name.passData
|
||||
.getUnsafe(AliasAnalysis)(
|
||||
"Name occurrence with missing aliasing information."
|
||||
.get(AliasAnalysis)
|
||||
.getOrElse(
|
||||
throw new CompilerError(
|
||||
"Name occurrence with missing aliasing information."
|
||||
)
|
||||
)
|
||||
.unsafeAs[AliasAnalysis.Info.Occurrence]
|
||||
.asInstanceOf[AliasAnalysis.Info.Occurrence]
|
||||
|
||||
name match {
|
||||
case _: Name.Blank =>
|
||||
@ -570,7 +574,7 @@ case object DataflowAnalysis extends IRPass {
|
||||
info.dependents.updateAt(key, Set(nameDep))
|
||||
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),
|
||||
branches = expr.branches.map(analyseCaseBranch(_, info))
|
||||
)
|
||||
.updateMetadata(this -->> info)
|
||||
.updateMetadata(new MetadataPair(this, info))
|
||||
case _: Case.Branch =>
|
||||
throw new CompilerError("Unexpected case branch.")
|
||||
}
|
||||
@ -636,7 +640,7 @@ case object DataflowAnalysis extends IRPass {
|
||||
pattern = analysePattern(pattern, info),
|
||||
expression = analyseExpression(expression, info)
|
||||
)
|
||||
.updateMetadata(this -->> info)
|
||||
.updateMetadata(new MetadataPair(this, info))
|
||||
}
|
||||
|
||||
/** Performs dataflow analysis on a case branch.
|
||||
@ -658,7 +662,7 @@ case object DataflowAnalysis extends IRPass {
|
||||
info.dependents.updateAt(nameDep, Set(patternDep))
|
||||
info.dependencies.updateAt(patternDep, Set(nameDep))
|
||||
|
||||
named.updateMetadata(this -->> info)
|
||||
named.updateMetadata(new MetadataPair(this, info))
|
||||
case cons @ Pattern.Constructor(constructor, fields, _, _, _) =>
|
||||
val consDep = asStatic(constructor)
|
||||
info.dependents.updateAt(consDep, Set(patternDep))
|
||||
@ -674,9 +678,9 @@ case object DataflowAnalysis extends IRPass {
|
||||
constructor = analyseName(constructor, info),
|
||||
fields = fields.map(analysePattern(_, info))
|
||||
)
|
||||
.updateMetadata(this -->> info)
|
||||
.updateMetadata(new MetadataPair(this, info))
|
||||
case literal: Pattern.Literal =>
|
||||
literal.updateMetadata(this -->> info)
|
||||
literal.updateMetadata(new MetadataPair(this, info))
|
||||
case Pattern.Type(name, tpe, _, _, _) =>
|
||||
val nameDep = asStatic(name)
|
||||
info.dependents.updateAt(nameDep, Set(patternDep))
|
||||
@ -685,12 +689,13 @@ case object DataflowAnalysis extends IRPass {
|
||||
info.dependents.updateAt(tpeDep, Set(patternDep))
|
||||
info.dependencies.updateAt(patternDep, Set(tpeDep))
|
||||
|
||||
pattern.updateMetadata(this -->> info)
|
||||
pattern.updateMetadata(new MetadataPair(this, info))
|
||||
case _: Pattern.Documentation =>
|
||||
throw new CompilerError(
|
||||
"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(
|
||||
defaultValue = defValue.map(analyseExpression(_, info))
|
||||
)
|
||||
.updateMetadata(this -->> info)
|
||||
.updateMetadata(new MetadataPair(this, info))
|
||||
}
|
||||
}
|
||||
|
||||
@ -753,7 +758,7 @@ case object DataflowAnalysis extends IRPass {
|
||||
.copy(
|
||||
value = analyseExpression(value, info)
|
||||
)
|
||||
.updateMetadata(this -->> info)
|
||||
.updateMetadata(new MetadataPair(this, info))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ case object GatherDiagnostics extends IRPass {
|
||||
ir: Module,
|
||||
moduleContext: ModuleContext
|
||||
): 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
|
||||
* diagnostics to its metadata storage.
|
||||
@ -54,7 +54,7 @@ case object GatherDiagnostics extends IRPass {
|
||||
override def runExpression(
|
||||
ir: Expression,
|
||||
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.
|
||||
*
|
||||
|
@ -112,21 +112,23 @@ case object TailCall extends IRPass {
|
||||
.copy(
|
||||
body = analyseExpression(method.body, isInTailPosition = true)
|
||||
)
|
||||
.updateMetadata(this -->> TailPosition.Tail)
|
||||
.updateMetadata(new MetadataPair(this, TailPosition.Tail))
|
||||
case method @ definition.Method
|
||||
.Explicit(_, body, _, _, _) =>
|
||||
method
|
||||
.copy(
|
||||
body = analyseExpression(body, isInTailPosition = true)
|
||||
)
|
||||
.updateMetadata(this -->> TailPosition.Tail)
|
||||
.updateMetadata(new MetadataPair(this, TailPosition.Tail))
|
||||
case _: definition.Method.Binding =>
|
||||
throw new CompilerError(
|
||||
"Sugared method definitions should not occur during tail call " +
|
||||
"analysis."
|
||||
)
|
||||
case _: Definition.Type =>
|
||||
moduleDefinition.updateMetadata(this -->> TailPosition.Tail)
|
||||
moduleDefinition.updateMetadata(
|
||||
new MetadataPair(this, TailPosition.Tail)
|
||||
)
|
||||
case _: Definition.SugaredType =>
|
||||
throw new CompilerError(
|
||||
"Complex type definitions should not be present during " +
|
||||
@ -151,7 +153,7 @@ case object TailCall extends IRPass {
|
||||
.copy(expression =
|
||||
analyseExpression(ann.expression, isInTailPosition = true)
|
||||
)
|
||||
.updateMetadata(this -->> TailPosition.Tail)
|
||||
.updateMetadata(new MetadataPair(this, TailPosition.Tail))
|
||||
case err: Error => err
|
||||
}
|
||||
}
|
||||
@ -173,7 +175,7 @@ case object TailCall extends IRPass {
|
||||
else expression
|
||||
expressionWithWarning match {
|
||||
case empty: Empty =>
|
||||
empty.updateMetadata(this -->> TailPosition.NotTail)
|
||||
empty.updateMetadata(new MetadataPair(this, TailPosition.NotTail))
|
||||
case function: Function =>
|
||||
analyseFunction(function, isInTailPosition)
|
||||
case caseExpr: Case => analyseCase(caseExpr, isInTailPosition)
|
||||
@ -181,7 +183,7 @@ case object TailCall extends IRPass {
|
||||
case app: Application => analyseApplication(app, isInTailPosition)
|
||||
case name: Name => analyseName(name, isInTailPosition)
|
||||
case foreign: Foreign =>
|
||||
foreign.updateMetadata(this -->> TailPosition.NotTail)
|
||||
foreign.updateMetadata(new MetadataPair(this, TailPosition.NotTail))
|
||||
case literal: Literal => analyseLiteral(literal, isInTailPosition)
|
||||
case _: Comment =>
|
||||
throw new CompilerError(
|
||||
@ -202,16 +204,20 @@ case object TailCall extends IRPass {
|
||||
),
|
||||
returnValue = analyseExpression(returnValue, isInTailPosition)
|
||||
)
|
||||
.updateMetadata(this -->> TailPosition.fromBool(isInTailPosition))
|
||||
.updateMetadata(
|
||||
new MetadataPair(this, TailPosition.fromBool(isInTailPosition))
|
||||
)
|
||||
case binding @ Expression.Binding(_, expression, _, _, _) =>
|
||||
binding
|
||||
.copy(
|
||||
expression = analyseExpression(expression, isInTailPosition = false)
|
||||
)
|
||||
.updateMetadata(this -->> TailPosition.fromBool(isInTailPosition))
|
||||
.updateMetadata(
|
||||
new MetadataPair(this, TailPosition.fromBool(isInTailPosition))
|
||||
)
|
||||
case err: Diagnostic =>
|
||||
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
|
||||
*/
|
||||
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.
|
||||
@ -237,7 +245,9 @@ case object TailCall extends IRPass {
|
||||
literal: Literal,
|
||||
isInTailPosition: Boolean
|
||||
): Literal = {
|
||||
literal.updateMetadata(this -->> TailPosition.fromBool(isInTailPosition))
|
||||
literal.updateMetadata(
|
||||
new MetadataPair(this, TailPosition.fromBool(isInTailPosition))
|
||||
)
|
||||
}
|
||||
|
||||
/** Performs tail call analysis on an application.
|
||||
@ -258,25 +268,33 @@ case object TailCall extends IRPass {
|
||||
function = analyseExpression(fn, isInTailPosition = false),
|
||||
arguments = args.map(analyseCallArg)
|
||||
)
|
||||
.updateMetadata(this -->> TailPosition.fromBool(isInTailPosition))
|
||||
.updateMetadata(
|
||||
new MetadataPair(this, TailPosition.fromBool(isInTailPosition))
|
||||
)
|
||||
case force @ Application.Force(target, _, _, _) =>
|
||||
force
|
||||
.copy(
|
||||
target = analyseExpression(target, isInTailPosition)
|
||||
)
|
||||
.updateMetadata(this -->> TailPosition.fromBool(isInTailPosition))
|
||||
.updateMetadata(
|
||||
new MetadataPair(this, TailPosition.fromBool(isInTailPosition))
|
||||
)
|
||||
case vector @ Application.Sequence(items, _, _, _) =>
|
||||
vector
|
||||
.copy(items =
|
||||
items.map(analyseExpression(_, isInTailPosition = false))
|
||||
)
|
||||
.updateMetadata(this -->> TailPosition.fromBool(isInTailPosition))
|
||||
.updateMetadata(
|
||||
new MetadataPair(this, TailPosition.fromBool(isInTailPosition))
|
||||
)
|
||||
case tSet @ Application.Typeset(expr, _, _, _) =>
|
||||
tSet
|
||||
.copy(expression =
|
||||
expr.map(analyseExpression(_, isInTailPosition = false))
|
||||
)
|
||||
.updateMetadata(this -->> TailPosition.fromBool(isInTailPosition))
|
||||
.updateMetadata(
|
||||
new MetadataPair(this, TailPosition.fromBool(isInTailPosition))
|
||||
)
|
||||
case _: Operator =>
|
||||
throw new CompilerError("Unexpected binary operator.")
|
||||
}
|
||||
@ -295,7 +313,7 @@ case object TailCall extends IRPass {
|
||||
// Note [Call Argument Tail Position]
|
||||
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 = {
|
||||
value
|
||||
.mapExpressions(analyseExpression(_, isInTailPosition = false))
|
||||
.updateMetadata(this -->> TailPosition.fromBool(isInTailPosition))
|
||||
.updateMetadata(
|
||||
new MetadataPair(this, TailPosition.fromBool(isInTailPosition))
|
||||
)
|
||||
}
|
||||
|
||||
/** Performs tail call analysis on a case expression.
|
||||
@ -351,7 +371,9 @@ case object TailCall extends IRPass {
|
||||
// Note [Analysing Branches in Case Expressions]
|
||||
branches = branches.map(analyseCaseBranch(_, isInTailPosition))
|
||||
)
|
||||
.updateMetadata(this -->> TailPosition.fromBool(isInTailPosition))
|
||||
.updateMetadata(
|
||||
new MetadataPair(this, TailPosition.fromBool(isInTailPosition))
|
||||
)
|
||||
case _: Case.Branch =>
|
||||
throw new CompilerError("Unexpected case branch.")
|
||||
}
|
||||
@ -387,7 +409,9 @@ case object TailCall extends IRPass {
|
||||
isInTailPosition
|
||||
)
|
||||
)
|
||||
.updateMetadata(this -->> TailPosition.fromBool(isInTailPosition))
|
||||
.updateMetadata(
|
||||
new MetadataPair(this, TailPosition.fromBool(isInTailPosition))
|
||||
)
|
||||
}
|
||||
|
||||
/** Performs tail call analysis on a pattern.
|
||||
@ -404,17 +428,17 @@ case object TailCall extends IRPass {
|
||||
.copy(
|
||||
name = analyseName(name, isInTailPosition = false)
|
||||
)
|
||||
.updateMetadata(this -->> TailPosition.NotTail)
|
||||
.updateMetadata(new MetadataPair(this, TailPosition.NotTail))
|
||||
case cons @ Pattern.Constructor(constructor, fields, _, _, _) =>
|
||||
cons
|
||||
.copy(
|
||||
constructor = analyseName(constructor, isInTailPosition = false),
|
||||
fields = fields.map(analysePattern)
|
||||
)
|
||||
.updateMetadata(this -->> TailPosition.NotTail)
|
||||
.updateMetadata(new MetadataPair(this, TailPosition.NotTail))
|
||||
case literal: Pattern.Literal =>
|
||||
literal
|
||||
.updateMetadata(this -->> TailPosition.NotTail)
|
||||
.updateMetadata(new MetadataPair(this, TailPosition.NotTail))
|
||||
case tpePattern @ Pattern.Type(name, tpe, _, _, _) =>
|
||||
tpePattern
|
||||
.copy(
|
||||
@ -422,7 +446,7 @@ case object TailCall extends IRPass {
|
||||
tpe = analyseName(tpe, isInTailPosition = false)
|
||||
)
|
||||
case err: errors.Pattern =>
|
||||
err.updateMetadata(this -->> TailPosition.NotTail)
|
||||
err.updateMetadata(new MetadataPair(this, TailPosition.NotTail))
|
||||
case _: Pattern.Documentation =>
|
||||
throw new CompilerError(
|
||||
"Branch documentation should be desugared at an earlier stage."
|
||||
@ -457,7 +481,7 @@ case object TailCall extends IRPass {
|
||||
}
|
||||
|
||||
resultFunction.updateMetadata(
|
||||
this -->> TailPosition.fromBool(isInTailPosition)
|
||||
new MetadataPair(this, TailPosition.fromBool(isInTailPosition))
|
||||
)
|
||||
}
|
||||
|
||||
@ -473,10 +497,10 @@ case object TailCall extends IRPass {
|
||||
.copy(
|
||||
defaultValue = default.map(x =>
|
||||
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)
|
||||
.getOrElse(Nil)
|
||||
atom.updateMetadata(
|
||||
ModuleAnnotations -->> ann.copy(ann.annotations ++ old)
|
||||
new MetadataPair(
|
||||
ModuleAnnotations,
|
||||
ann.copy(ann.annotations ++ old)
|
||||
)
|
||||
)
|
||||
})
|
||||
.getOrElse(atom)
|
||||
@ -212,13 +215,17 @@ case object ComplexType extends IRPass {
|
||||
)
|
||||
|
||||
val withAnnotations = annotations
|
||||
.map(ann => sumType.updateMetadata(ModuleAnnotations -->> ann))
|
||||
.map(ann =>
|
||||
sumType.updateMetadata(new MetadataPair(ModuleAnnotations, ann))
|
||||
)
|
||||
.getOrElse(sumType)
|
||||
|
||||
val withDoc = typ
|
||||
.getMetadata(DocumentationComments)
|
||||
.map(ann =>
|
||||
withAnnotations.updateMetadata(DocumentationComments -->> ann)
|
||||
withAnnotations.updateMetadata(
|
||||
new MetadataPair(DocumentationComments, ann)
|
||||
)
|
||||
)
|
||||
.getOrElse(sumType)
|
||||
|
||||
|
@ -14,7 +14,7 @@ import org.enso.compiler.core.ir.{
|
||||
Name,
|
||||
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.pass.IRPass
|
||||
import org.enso.compiler.pass.analyse.{
|
||||
@ -192,7 +192,10 @@ case object FunctionBinding extends IRPass {
|
||||
firstArg
|
||||
.withName(newName)
|
||||
.updateMetadata(
|
||||
IgnoredBindings -->> IgnoredBindings.State.Ignored
|
||||
new MetadataPair(
|
||||
IgnoredBindings,
|
||||
IgnoredBindings.State.Ignored
|
||||
)
|
||||
)
|
||||
} else {
|
||||
firstArg
|
||||
@ -212,7 +215,10 @@ case object FunctionBinding extends IRPass {
|
||||
snd
|
||||
.withName(newName)
|
||||
.updateMetadata(
|
||||
IgnoredBindings -->> IgnoredBindings.State.Ignored
|
||||
new MetadataPair(
|
||||
IgnoredBindings,
|
||||
IgnoredBindings.State.Ignored
|
||||
)
|
||||
)
|
||||
),
|
||||
rest
|
||||
|
@ -108,8 +108,9 @@ case object DocumentationComments extends IRPass {
|
||||
None
|
||||
case other =>
|
||||
val res = lastDoc match {
|
||||
case Some(doc) => other.updateMetadata(this -->> Doc(doc.doc))
|
||||
case None => other
|
||||
case Some(doc) =>
|
||||
other.updateMetadata(new MetadataPair(this, Doc(doc.doc)))
|
||||
case None => other
|
||||
}
|
||||
lastDoc = None
|
||||
Some(res)
|
||||
@ -135,8 +136,9 @@ case object DocumentationComments extends IRPass {
|
||||
expression = resolveExpression(expression)
|
||||
)
|
||||
val res = lastDoc match {
|
||||
case Some(doc) => resolved.updateMetadata(this -->> Doc(doc))
|
||||
case None => resolved
|
||||
case Some(doc) =>
|
||||
resolved.updateMetadata(new MetadataPair(this, Doc(doc)))
|
||||
case None => resolved
|
||||
}
|
||||
lastDoc = None
|
||||
Some(res)
|
||||
@ -203,7 +205,7 @@ case object DocumentationComments extends IRPass {
|
||||
}
|
||||
val newBindings = (allModuleEntities.headOption match {
|
||||
case Some(doc: Comment.Documentation) =>
|
||||
ir.updateMetadata(this -->> Doc(doc.doc))
|
||||
ir.updateMetadata(new MetadataPair(this, Doc(doc.doc)))
|
||||
resolveList(ir.bindings.drop(1))
|
||||
case _ => resolveList(ir.bindings)
|
||||
}).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.ir.{Expression, Module}
|
||||
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.errors
|
||||
import org.enso.compiler.pass.IRPass
|
||||
@ -84,7 +84,7 @@ case object ExpressionAnnotations extends IRPass {
|
||||
)
|
||||
case List(arg) =>
|
||||
doExpression(arg.value)
|
||||
.updateMetadata(this -->> Annotations(Seq(ann)))
|
||||
.updateMetadata(new MetadataPair(this, Annotations(Seq(ann))))
|
||||
case realFun :: args =>
|
||||
val recurFun = doExpression(realFun.value)
|
||||
val (finalFun, preArgs) = recurFun match {
|
||||
@ -95,7 +95,7 @@ case object ExpressionAnnotations extends IRPass {
|
||||
val recurArgs = args.map(_.mapExpressions(doExpression))
|
||||
app
|
||||
.copy(function = finalFun, arguments = preArgs ++ recurArgs)
|
||||
.updateMetadata(this -->> Annotations(Seq(ann)))
|
||||
.updateMetadata(new MetadataPair(this, Annotations(Seq(ann))))
|
||||
}
|
||||
} else {
|
||||
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.expression.errors
|
||||
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.{
|
||||
ExportedModule,
|
||||
@ -239,7 +239,10 @@ case object FullyQualifiedNames extends IRPass {
|
||||
.getOrElse(false)
|
||||
) {
|
||||
lit.updateMetadata(
|
||||
this -->> FQNResolution(ResolvedLibrary(lit.name))
|
||||
new MetadataPair(
|
||||
this,
|
||||
FQNResolution(ResolvedLibrary(lit.name))
|
||||
)
|
||||
)
|
||||
} else {
|
||||
lit
|
||||
@ -329,7 +332,7 @@ case object FullyQualifiedNames extends IRPass {
|
||||
_.map(resolvedMod =>
|
||||
freshNameSupply
|
||||
.newName(from = Some(name))
|
||||
.updateMetadata(this -->> resolvedMod)
|
||||
.updateMetadata(new MetadataPair(this, resolvedMod))
|
||||
.setLocation(name.location)
|
||||
)
|
||||
)
|
||||
|
@ -60,7 +60,10 @@ case object GenericAnnotations extends IRPass {
|
||||
case entity =>
|
||||
val res = Some(
|
||||
entity.updateMetadata(
|
||||
this -->> ModuleAnnotations.Annotations(lastAnnotations)
|
||||
new MetadataPair(
|
||||
this,
|
||||
ModuleAnnotations.Annotations(lastAnnotations)
|
||||
)
|
||||
)
|
||||
)
|
||||
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.MetadataStorage.ToPair
|
||||
import org.enso.compiler.core.ir.MetadataStorage.MetadataPair
|
||||
import org.enso.compiler.core.ir.expression.errors
|
||||
import org.enso.compiler.data.BindingsMap
|
||||
import org.enso.compiler.data.BindingsMap.{
|
||||
@ -151,7 +151,7 @@ case object GlobalNames extends IRPass {
|
||||
ir.transformExpressions {
|
||||
case selfTp: Name.SelfType =>
|
||||
selfTypeResolution
|
||||
.map(res => selfTp.updateMetadata(this -->> res))
|
||||
.map(res => selfTp.updateMetadata(new MetadataPair(this, res)))
|
||||
.getOrElse(
|
||||
errors.Resolution(
|
||||
selfTp,
|
||||
@ -168,7 +168,9 @@ case object GlobalNames extends IRPass {
|
||||
FullyQualifiedNames.ResolvedModule(modRef)
|
||||
)
|
||||
) =>
|
||||
lit.updateMetadata(this -->> Resolution(ResolvedModule(modRef)))
|
||||
lit.updateMetadata(
|
||||
new MetadataPair(this, Resolution(ResolvedModule(modRef)))
|
||||
)
|
||||
case _ =>
|
||||
if (!lit.isMethod && !isLocalVar(lit)) {
|
||||
val resolution = bindings.resolveName(lit.name)
|
||||
@ -180,13 +182,18 @@ case object GlobalNames extends IRPass {
|
||||
)
|
||||
case Right(r @ BindingsMap.ResolvedMethod(mod, method)) =>
|
||||
if (isInsideApplication) {
|
||||
lit.updateMetadata(this -->> BindingsMap.Resolution(r))
|
||||
lit.updateMetadata(
|
||||
new MetadataPair(this, BindingsMap.Resolution(r))
|
||||
)
|
||||
} else {
|
||||
val self = freshNameSupply
|
||||
.newName()
|
||||
.updateMetadata(
|
||||
this -->> BindingsMap.Resolution(
|
||||
BindingsMap.ResolvedModule(mod)
|
||||
new MetadataPair(
|
||||
this,
|
||||
BindingsMap.Resolution(
|
||||
BindingsMap.ResolvedModule(mod)
|
||||
)
|
||||
)
|
||||
)
|
||||
// The synthetic applications gets the location so that instrumentation
|
||||
@ -205,14 +212,19 @@ case object GlobalNames extends IRPass {
|
||||
.getMetadata(ExpressionAnnotations)
|
||||
.foreach(annotationsMeta =>
|
||||
app.updateMetadata(
|
||||
ExpressionAnnotations -->> annotationsMeta
|
||||
new MetadataPair(
|
||||
ExpressionAnnotations,
|
||||
annotationsMeta
|
||||
)
|
||||
)
|
||||
)
|
||||
fun.passData.remove(ExpressionAnnotations)
|
||||
app
|
||||
}
|
||||
case Right(value) =>
|
||||
lit.updateMetadata(this -->> BindingsMap.Resolution(value))
|
||||
lit.updateMetadata(
|
||||
new MetadataPair(this, BindingsMap.Resolution(value))
|
||||
)
|
||||
}
|
||||
|
||||
} else {
|
||||
@ -288,8 +300,11 @@ case object GlobalNames extends IRPass {
|
||||
val self = freshNameSupply
|
||||
.newName()
|
||||
.updateMetadata(
|
||||
this -->> BindingsMap.Resolution(
|
||||
BindingsMap.ResolvedModule(mod)
|
||||
new MetadataPair(
|
||||
this,
|
||||
BindingsMap.Resolution(
|
||||
BindingsMap.ResolvedModule(mod)
|
||||
)
|
||||
)
|
||||
)
|
||||
val selfArg = CallArgument.Specified(None, self, None)
|
||||
@ -374,7 +389,7 @@ case object GlobalNames extends IRPass {
|
||||
): Expression = {
|
||||
freshNameSupply
|
||||
.newName()
|
||||
.updateMetadata(this -->> BindingsMap.Resolution(cons))
|
||||
.updateMetadata(new MetadataPair(this, BindingsMap.Resolution(cons)))
|
||||
}
|
||||
|
||||
private def resolveQualName(
|
||||
|
@ -104,7 +104,7 @@ case object IgnoredBindings extends IRPass {
|
||||
|
||||
private def setNotIgnored[T <: IR](ir: T): T = {
|
||||
if (ir.getMetadata(this).isEmpty) {
|
||||
ir.updateMetadata(this -->> State.NotIgnored)
|
||||
ir.updateMetadata(new MetadataPair(this, State.NotIgnored))
|
||||
} else {
|
||||
ir
|
||||
}
|
||||
@ -153,7 +153,7 @@ case object IgnoredBindings extends IRPass {
|
||||
name = newName,
|
||||
expression = resolveExpression(binding.expression, supply)
|
||||
)
|
||||
.updateMetadata(this -->> State.Ignored)
|
||||
.updateMetadata(new MetadataPair(this, State.Ignored))
|
||||
} else {
|
||||
setNotIgnored(
|
||||
binding
|
||||
@ -223,7 +223,7 @@ case object IgnoredBindings extends IRPass {
|
||||
.copy(defaultValue =
|
||||
spec.defaultValue.map(resolveExpression(_, freshNameSupply))
|
||||
)
|
||||
.updateMetadata(this -->> State.Ignored)
|
||||
.updateMetadata(new MetadataPair(this, State.Ignored))
|
||||
case spec: DefinitionArgument.Specified =>
|
||||
if (isIgnored) {
|
||||
val newName = freshNameSupply
|
||||
@ -240,7 +240,7 @@ case object IgnoredBindings extends IRPass {
|
||||
defaultValue =
|
||||
spec.defaultValue.map(resolveExpression(_, freshNameSupply))
|
||||
)
|
||||
.updateMetadata(this -->> State.Ignored)
|
||||
.updateMetadata(new MetadataPair(this, State.Ignored))
|
||||
} else {
|
||||
setNotIgnored(
|
||||
spec
|
||||
@ -334,7 +334,7 @@ case object IgnoredBindings extends IRPass {
|
||||
passData = name.passData,
|
||||
diagnostics = name.diagnostics
|
||||
)
|
||||
.updateMetadata(this -->> State.Ignored)
|
||||
.updateMetadata(new MetadataPair(this, State.Ignored))
|
||||
|
||||
named.copy(
|
||||
name = newName
|
||||
@ -358,7 +358,7 @@ case object IgnoredBindings extends IRPass {
|
||||
passData = name.passData,
|
||||
diagnostics = name.diagnostics
|
||||
)
|
||||
.updateMetadata(this -->> State.Ignored)
|
||||
.updateMetadata(new MetadataPair(this, State.Ignored))
|
||||
|
||||
typed.copy(
|
||||
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.ir.{Expression, Module}
|
||||
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.data.BindingsMap
|
||||
import org.enso.compiler.data.BindingsMap.{Resolution, ResolvedModule}
|
||||
@ -82,7 +82,9 @@ object MethodCalls extends IRPass {
|
||||
resolution match {
|
||||
case Some(List(resolution)) =>
|
||||
val newName =
|
||||
name.updateMetadata(this -->> Resolution(resolution))
|
||||
name.updateMetadata(
|
||||
new MetadataPair(this, Resolution(resolution))
|
||||
)
|
||||
val newArgs =
|
||||
app.arguments.map(
|
||||
_.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.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.{Resolution, ResolvedType, Type}
|
||||
import org.enso.compiler.core.CompilerError
|
||||
@ -162,10 +162,12 @@ case object MethodDefinitions extends IRPass {
|
||||
)
|
||||
case Right(value: BindingsMap.ResolvedModule) =>
|
||||
typePointer.updateMetadata(
|
||||
this -->> BindingsMap.Resolution(value)
|
||||
new MetadataPair(this, BindingsMap.Resolution(value))
|
||||
)
|
||||
case Right(value: BindingsMap.ResolvedType) =>
|
||||
typePointer.updateMetadata(this -->> BindingsMap.Resolution(value))
|
||||
typePointer.updateMetadata(
|
||||
new MetadataPair(this, BindingsMap.Resolution(value))
|
||||
)
|
||||
case Right(_: BindingsMap.ResolvedPolyglotSymbol) =>
|
||||
errors.Resolution(
|
||||
typePointer,
|
||||
|
@ -51,14 +51,16 @@ case object ModuleAnnotations extends IRPass {
|
||||
case typ: Definition.SugaredType =>
|
||||
val res = Some(
|
||||
resolveComplexType(typ).updateMetadata(
|
||||
this -->> Annotations(lastAnnotations)
|
||||
new MetadataPair(this, Annotations(lastAnnotations))
|
||||
)
|
||||
)
|
||||
lastAnnotations = Seq()
|
||||
res
|
||||
case entity =>
|
||||
val res = Some(
|
||||
entity.updateMetadata(this -->> Annotations(lastAnnotations))
|
||||
entity.updateMetadata(
|
||||
new MetadataPair(this, Annotations(lastAnnotations))
|
||||
)
|
||||
)
|
||||
lastAnnotations = Seq()
|
||||
res
|
||||
@ -84,7 +86,9 @@ case object ModuleAnnotations extends IRPass {
|
||||
case comment: Comment => Some(comment)
|
||||
case entity =>
|
||||
val res = Some(
|
||||
entity.updateMetadata(this -->> Annotations(lastAnnotations))
|
||||
entity.updateMetadata(
|
||||
new MetadataPair(this, Annotations(lastAnnotations))
|
||||
)
|
||||
)
|
||||
lastAnnotations = Seq()
|
||||
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.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.core.CompilerError
|
||||
import org.enso.compiler.pass.IRPass
|
||||
@ -120,23 +120,23 @@ object Patterns extends IRPass {
|
||||
)
|
||||
case Right(value: BindingsMap.ResolvedConstructor) =>
|
||||
consName.updateMetadata(
|
||||
this -->> BindingsMap.Resolution(value)
|
||||
new MetadataPair(this, BindingsMap.Resolution(value))
|
||||
)
|
||||
case Right(value: BindingsMap.ResolvedModule) =>
|
||||
consName.updateMetadata(
|
||||
this -->> BindingsMap.Resolution(value)
|
||||
new MetadataPair(this, BindingsMap.Resolution(value))
|
||||
)
|
||||
case Right(value: BindingsMap.ResolvedType) =>
|
||||
consName.updateMetadata(
|
||||
this -->> BindingsMap.Resolution(value)
|
||||
new MetadataPair(this, BindingsMap.Resolution(value))
|
||||
)
|
||||
case Right(value: BindingsMap.ResolvedPolyglotSymbol) =>
|
||||
consName.updateMetadata(
|
||||
this -->> BindingsMap.Resolution(value)
|
||||
new MetadataPair(this, BindingsMap.Resolution(value))
|
||||
)
|
||||
case Right(value: BindingsMap.ResolvedPolyglotField) =>
|
||||
consName.updateMetadata(
|
||||
this -->> BindingsMap.Resolution(value)
|
||||
new MetadataPair(this, BindingsMap.Resolution(value))
|
||||
)
|
||||
|
||||
case Right(_: BindingsMap.ResolvedMethod) =>
|
||||
@ -201,7 +201,7 @@ object Patterns extends IRPass {
|
||||
)
|
||||
case Right(value: BindingsMap.ResolvedType) =>
|
||||
tpeName.updateMetadata(
|
||||
this -->> BindingsMap.Resolution(value)
|
||||
new MetadataPair(this, BindingsMap.Resolution(value))
|
||||
)
|
||||
case Right(_: BindingsMap.ResolvedConstructor) =>
|
||||
errors.Resolution(
|
||||
@ -211,11 +211,11 @@ object Patterns extends IRPass {
|
||||
)
|
||||
case Right(value: BindingsMap.ResolvedPolyglotSymbol) =>
|
||||
tpeName.updateMetadata(
|
||||
this -->> BindingsMap.Resolution(value)
|
||||
new MetadataPair(this, BindingsMap.Resolution(value))
|
||||
)
|
||||
case Right(value: BindingsMap.ResolvedPolyglotField) =>
|
||||
tpeName.updateMetadata(
|
||||
this -->> BindingsMap.Resolution(value)
|
||||
new MetadataPair(this, BindingsMap.Resolution(value))
|
||||
)
|
||||
/*errors.Resolution(
|
||||
tpeName,
|
||||
|
@ -112,7 +112,9 @@ case object TypeFunctions extends IRPass {
|
||||
val result = resolveApplication(app)
|
||||
app
|
||||
.getMetadata(DocumentationComments)
|
||||
.map(doc => result.updateMetadata(DocumentationComments -->> doc))
|
||||
.map(doc =>
|
||||
result.updateMetadata(new MetadataPair(DocumentationComments, doc))
|
||||
)
|
||||
.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.module.scope.Definition
|
||||
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.data.BindingsMap
|
||||
import org.enso.compiler.data.BindingsMap.{Resolution, ResolvedModule}
|
||||
@ -108,8 +108,11 @@ case object TypeNames extends IRPass {
|
||||
ir.getMetadata(TypeSignatures)
|
||||
.map { s =>
|
||||
ir.updateMetadata(
|
||||
TypeSignatures -->> TypeSignatures.Signature(
|
||||
resolveSignature(typeParams, bindingsMap, s.signature)
|
||||
new MetadataPair(
|
||||
TypeSignatures,
|
||||
TypeSignatures.Signature(
|
||||
resolveSignature(typeParams, bindingsMap, s.signature)
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
@ -143,7 +146,7 @@ case object TypeNames extends IRPass {
|
||||
resolvedName: Either[BindingsMap.ResolutionError, BindingsMap.ResolvedName]
|
||||
): Name =
|
||||
resolvedName
|
||||
.map(res => name.updateMetadata(this -->> Resolution(res)))
|
||||
.map(res => name.updateMetadata(new MetadataPair(this, Resolution(res))))
|
||||
.fold(
|
||||
error =>
|
||||
errors.Resolution(name, errors.Resolution.ResolverError(error)),
|
||||
|
@ -102,14 +102,16 @@ case object TypeSignatures extends IRPass {
|
||||
val newMethodWithDoc = asc
|
||||
.getMetadata(DocumentationComments)
|
||||
.map(doc =>
|
||||
newMethod.updateMetadata(DocumentationComments -->> doc)
|
||||
newMethod.updateMetadata(
|
||||
new MetadataPair(DocumentationComments, doc)
|
||||
)
|
||||
)
|
||||
.getOrElse(newMethod)
|
||||
val newMethodWithAnnotations = asc
|
||||
.getMetadata(ModuleAnnotations)
|
||||
.map(annotations =>
|
||||
newMethodWithDoc.updateMetadata(
|
||||
ModuleAnnotations -->> annotations
|
||||
new MetadataPair(ModuleAnnotations, annotations)
|
||||
)
|
||||
)
|
||||
.getOrElse(newMethodWithDoc)
|
||||
@ -119,7 +121,7 @@ case object TypeSignatures extends IRPass {
|
||||
if (ref isSameReferenceAs methodRef) {
|
||||
Some(
|
||||
newMethodWithAnnotations.updateMetadata(
|
||||
this -->> Signature(sig)
|
||||
new MetadataPair(this, Signature(sig))
|
||||
)
|
||||
)
|
||||
} else {
|
||||
@ -185,7 +187,9 @@ case object TypeSignatures extends IRPass {
|
||||
arguments: List[DefinitionArgument]
|
||||
): Unit = {
|
||||
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())
|
||||
specified.copy(
|
||||
name = specified.name.updateMetadata(this -->> Signature(sig)),
|
||||
ascribedType =
|
||||
Some(ascribedType.updateMetadata(this -->> Signature(sig)))
|
||||
name = specified.name.updateMetadata(
|
||||
new MetadataPair(this, Signature(sig))
|
||||
),
|
||||
ascribedType = Some(
|
||||
ascribedType.updateMetadata(new MetadataPair(this, Signature(sig)))
|
||||
)
|
||||
)
|
||||
case argument => argument
|
||||
}
|
||||
@ -239,7 +246,7 @@ case object TypeSignatures extends IRPass {
|
||||
private def resolveAscription(sig: Type.Ascription): Expression = {
|
||||
val newTyped = sig.typed.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.
|
||||
@ -269,7 +276,9 @@ case object TypeSignatures extends IRPass {
|
||||
val newBindingWithDoc = asc
|
||||
.getMetadata(DocumentationComments)
|
||||
.map(doc =>
|
||||
newBinding.updateMetadata(DocumentationComments -->> doc)
|
||||
newBinding.updateMetadata(
|
||||
new MetadataPair(DocumentationComments, doc)
|
||||
)
|
||||
)
|
||||
.getOrElse(newBinding)
|
||||
|
||||
@ -277,7 +286,9 @@ case object TypeSignatures extends IRPass {
|
||||
case typedName: Name =>
|
||||
if (typedName.name == name.name) {
|
||||
Some(
|
||||
newBindingWithDoc.updateMetadata(this -->> Signature(sig))
|
||||
newBindingWithDoc.updateMetadata(
|
||||
new MetadataPair(this, Signature(sig))
|
||||
)
|
||||
)
|
||||
} else {
|
||||
List(
|
||||
|
@ -1775,7 +1775,7 @@ final class TreeToIr {
|
||||
});
|
||||
}
|
||||
private MetadataStorage meta() {
|
||||
return MetadataStorage.apply(nil());
|
||||
return new MetadataStorage();
|
||||
}
|
||||
private DiagnosticStorage diag() {
|
||||
return DiagnosticStorage.apply(nil());
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.enso.compiler.core.ir;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import org.enso.compiler.core.ir.expression.Application;
|
||||
@ -357,25 +358,25 @@ public final class IrPersistance {
|
||||
@ServiceProvider(service = Persistance.class)
|
||||
public static final class PersistMetadataStorage extends Persistance<MetadataStorage> {
|
||||
public PersistMetadataStorage() {
|
||||
super(MetadataStorage.class, false, 381);
|
||||
super(MetadataStorage.class, false, 389);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void writeObject(MetadataStorage obj, Output out) throws IOException {
|
||||
var map =
|
||||
obj.map(
|
||||
(processingPass, data) -> {
|
||||
var t = new Tuple2<>(processingPass, data);
|
||||
return t;
|
||||
});
|
||||
out.writeInline(scala.collection.immutable.Map.class, map);
|
||||
var map = new LinkedHashMap<ProcessingPass, ProcessingPass.Metadata>();
|
||||
obj.map(
|
||||
(processingPass, data) -> {
|
||||
map.put(processingPass, data);
|
||||
return null;
|
||||
});
|
||||
out.writeInline(java.util.Map.class, map);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
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);
|
||||
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(
|
||||
T head, scala.collection.immutable.List<T> 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]]
|
||||
*/
|
||||
def showPassData: String = {
|
||||
val metaString: Seq[String] =
|
||||
ir.passData.map((p, m) => (p, m.metadataName)).values.toSeq
|
||||
val alphabetical = metaString.sorted
|
||||
s"$alphabetical"
|
||||
ir.passData.toString
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,7 +88,7 @@ object Implicits {
|
||||
* @return the metadata for `pass`, if it exists
|
||||
*/
|
||||
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.
|
||||
@ -107,7 +104,10 @@ object Implicits {
|
||||
pass: ProcessingPass,
|
||||
msg: => String
|
||||
): 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 value: Expression,
|
||||
location: Option[IdentifiedLocation],
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
passData: MetadataStorage = new MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends CallArgument
|
||||
with IRKind.Primitive {
|
||||
@ -106,7 +106,8 @@ object CallArgument {
|
||||
keepIdentifiers
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
|
@ -61,7 +61,7 @@ object DefinitionArgument {
|
||||
override val defaultValue: Option[Expression],
|
||||
override val suspended: Boolean,
|
||||
location: Option[IdentifiedLocation],
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
passData: MetadataStorage = new MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends DefinitionArgument
|
||||
with IRKind.Primitive {
|
||||
@ -136,7 +136,8 @@ object DefinitionArgument {
|
||||
)
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
|
@ -15,7 +15,7 @@ import java.util.UUID
|
||||
*/
|
||||
sealed case class Empty(
|
||||
override val location: Option[IdentifiedLocation],
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
passData: MetadataStorage = new MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends IR
|
||||
with Expression
|
||||
@ -51,7 +51,8 @@ sealed case class Empty(
|
||||
): Empty =
|
||||
copy(
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
|
@ -60,7 +60,7 @@ object Expression {
|
||||
returnValue: Expression,
|
||||
location: Option[IdentifiedLocation],
|
||||
suspended: Boolean = false,
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
passData: MetadataStorage = new MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Expression
|
||||
with IRKind.Primitive {
|
||||
@ -121,7 +121,8 @@ object Expression {
|
||||
keepIdentifiers
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
@ -185,7 +186,7 @@ object Expression {
|
||||
name: Name,
|
||||
expression: Expression,
|
||||
location: Option[IdentifiedLocation],
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
passData: MetadataStorage = new MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Expression
|
||||
with IRKind.Primitive {
|
||||
@ -236,7 +237,8 @@ object Expression {
|
||||
keepIdentifiers
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
|
@ -114,7 +114,8 @@ object Function {
|
||||
keepIdentifiers
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
@ -200,7 +201,7 @@ object Function {
|
||||
override val body: Expression,
|
||||
location: Option[IdentifiedLocation],
|
||||
override val canBeTCO: Boolean = true,
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
passData: MetadataStorage = new MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Function
|
||||
with IRKind.Sugar {
|
||||
@ -271,7 +272,8 @@ object Function {
|
||||
keepIdentifiers
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
|
@ -40,7 +40,7 @@ object Literal {
|
||||
base: Option[String],
|
||||
value: String,
|
||||
location: Option[IdentifiedLocation],
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
passData: MetadataStorage = new MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Literal {
|
||||
var id: UUID @Identifier = randomId
|
||||
@ -77,7 +77,8 @@ object Literal {
|
||||
): Number =
|
||||
copy(
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
@ -166,7 +167,7 @@ object Literal {
|
||||
sealed case class Text(
|
||||
text: String,
|
||||
location: Option[IdentifiedLocation],
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
passData: MetadataStorage = new MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Literal {
|
||||
var id: UUID @Identifier = randomId
|
||||
@ -201,7 +202,8 @@ object Literal {
|
||||
): Text =
|
||||
copy(
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
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],
|
||||
isPrivate: Boolean,
|
||||
location: Option[IdentifiedLocation],
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
passData: MetadataStorage = new MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends IR
|
||||
with IRKind.Primitive {
|
||||
@ -94,7 +94,8 @@ final case class Module(
|
||||
)
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
|
@ -48,7 +48,7 @@ object Name {
|
||||
typePointer: Option[Name],
|
||||
methodName: Name,
|
||||
location: Option[IdentifiedLocation],
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
passData: MetadataStorage = new MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Name
|
||||
with IRKind.Sugar {
|
||||
@ -109,7 +109,8 @@ object Name {
|
||||
keepIdentifiers
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
@ -208,7 +209,7 @@ object Name {
|
||||
final case class Qualified(
|
||||
parts: List[Name],
|
||||
location: Option[IdentifiedLocation],
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
passData: MetadataStorage = new MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Name
|
||||
with IRKind.Primitive {
|
||||
@ -266,7 +267,8 @@ object Name {
|
||||
)
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
@ -290,7 +292,7 @@ object Name {
|
||||
*/
|
||||
sealed case class Blank(
|
||||
location: Option[IdentifiedLocation],
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
passData: MetadataStorage = new MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Name
|
||||
with IRKind.Sugar {
|
||||
@ -325,7 +327,8 @@ object Name {
|
||||
): Blank =
|
||||
copy(
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
@ -362,7 +365,7 @@ object Name {
|
||||
sealed case class Special(
|
||||
specialName: Special.Ident,
|
||||
location: Option[IdentifiedLocation],
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
passData: MetadataStorage = new MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Name
|
||||
with IRKind.Sugar {
|
||||
@ -397,7 +400,8 @@ object Name {
|
||||
): Special =
|
||||
copy(
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
@ -455,7 +459,7 @@ object Name {
|
||||
override val isMethod: Boolean,
|
||||
location: Option[IdentifiedLocation],
|
||||
originalName: Option[Name] = None,
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
passData: MetadataStorage = new MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Name {
|
||||
var id: UUID @Identifier = randomId
|
||||
@ -495,7 +499,8 @@ object Name {
|
||||
): Literal =
|
||||
copy(
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
@ -560,7 +565,7 @@ object Name {
|
||||
sealed case class BuiltinAnnotation(
|
||||
override val name: String,
|
||||
location: Option[IdentifiedLocation],
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
passData: MetadataStorage = new MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Annotation
|
||||
with IRKind.Primitive {
|
||||
@ -596,7 +601,8 @@ object Name {
|
||||
): BuiltinAnnotation =
|
||||
copy(
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
@ -645,7 +651,7 @@ object Name {
|
||||
override val name: String,
|
||||
expression: Expression,
|
||||
location: Option[IdentifiedLocation],
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
passData: MetadataStorage = new MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Annotation {
|
||||
var id: UUID @Identifier = randomId
|
||||
@ -683,7 +689,8 @@ object Name {
|
||||
): GenericAnnotation =
|
||||
copy(
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
@ -731,7 +738,7 @@ object Name {
|
||||
sealed case class Self(
|
||||
location: Option[IdentifiedLocation],
|
||||
synthetic: Boolean = false,
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
passData: MetadataStorage = new MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Name {
|
||||
var id: UUID @Identifier = randomId
|
||||
@ -766,7 +773,8 @@ object Name {
|
||||
): Self =
|
||||
copy(
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
@ -808,7 +816,7 @@ object Name {
|
||||
*/
|
||||
sealed case class SelfType(
|
||||
location: Option[IdentifiedLocation],
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
passData: MetadataStorage = new MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Name {
|
||||
var id: UUID @Identifier = randomId
|
||||
@ -842,7 +850,8 @@ object Name {
|
||||
): SelfType =
|
||||
copy(
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
|
@ -44,7 +44,7 @@ object Pattern {
|
||||
sealed case class Name(
|
||||
name: IRName,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Pattern {
|
||||
var id: UUID @Identifier = randomId
|
||||
@ -85,7 +85,8 @@ object Pattern {
|
||||
keepIdentifiers
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
@ -136,7 +137,7 @@ object Pattern {
|
||||
constructor: IRName,
|
||||
fields: List[Pattern],
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Pattern {
|
||||
var id: UUID @Identifier = randomId
|
||||
@ -188,7 +189,8 @@ object Pattern {
|
||||
)
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
@ -286,7 +288,7 @@ object Pattern {
|
||||
sealed case class Literal(
|
||||
literal: IRLiteral,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Pattern {
|
||||
var id: UUID @Identifier = randomId
|
||||
@ -327,7 +329,8 @@ object Pattern {
|
||||
keepIdentifiers
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
@ -380,7 +383,7 @@ object Pattern {
|
||||
name: IRName,
|
||||
tpe: IRName,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Pattern {
|
||||
var id: UUID @Identifier = randomId
|
||||
@ -429,7 +432,8 @@ object Pattern {
|
||||
keepIdentifiers
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
@ -482,7 +486,7 @@ object Pattern {
|
||||
final case class Documentation(
|
||||
doc: String,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Pattern {
|
||||
var id: UUID @Identifier = randomId
|
||||
@ -530,7 +534,8 @@ object Pattern {
|
||||
copy(
|
||||
doc,
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
|
@ -38,7 +38,7 @@ object Type {
|
||||
args: List[Expression],
|
||||
result: Expression,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Type {
|
||||
var id: UUID @Identifier = randomId
|
||||
@ -79,7 +79,8 @@ object Type {
|
||||
keepIdentifiers
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
@ -129,7 +130,7 @@ object Type {
|
||||
typed: Expression,
|
||||
signature: Expression,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Type
|
||||
with module.scope.Definition
|
||||
@ -180,7 +181,8 @@ object Type {
|
||||
keepIdentifiers
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
@ -235,7 +237,7 @@ object Type {
|
||||
typed: Expression,
|
||||
context: Expression,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Type
|
||||
with IRKind.Primitive {
|
||||
@ -285,7 +287,8 @@ object Type {
|
||||
keepIdentifiers
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
@ -338,7 +341,7 @@ object Type {
|
||||
typed: Expression,
|
||||
error: Expression,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Type
|
||||
with IRKind.Primitive {
|
||||
@ -388,7 +391,8 @@ object Type {
|
||||
keepLocations
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
|
@ -28,7 +28,7 @@ object Application {
|
||||
arguments: List[CallArgument],
|
||||
hasDefaultsSuspended: Boolean,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Application
|
||||
with IRKind.Primitive {
|
||||
@ -91,7 +91,8 @@ object Application {
|
||||
)
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
@ -143,7 +144,7 @@ object Application {
|
||||
sealed case class Force(
|
||||
target: Expression,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Application
|
||||
with IRKind.Primitive {
|
||||
@ -185,7 +186,8 @@ object Application {
|
||||
keepIdentifiers
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
@ -254,7 +256,7 @@ object Application {
|
||||
sealed case class Typeset(
|
||||
expression: Option[Expression],
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Literal
|
||||
with IRKind.Primitive {
|
||||
@ -303,7 +305,8 @@ object Application {
|
||||
)
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
@ -349,7 +352,7 @@ object Application {
|
||||
sealed case class Sequence(
|
||||
items: List[Expression],
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Literal
|
||||
with IRKind.Primitive {
|
||||
@ -398,7 +401,8 @@ object Application {
|
||||
)
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
|
@ -43,7 +43,7 @@ object Case {
|
||||
branches: Seq[Branch],
|
||||
isNested: Boolean,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Case
|
||||
with IRKind.Primitive {
|
||||
@ -109,7 +109,8 @@ object Case {
|
||||
),
|
||||
isNested = isNested,
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
@ -195,7 +196,7 @@ object Case {
|
||||
expression: Expression,
|
||||
terminalBranch: Boolean,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Case
|
||||
with IRKind.Primitive {
|
||||
@ -264,7 +265,8 @@ object Case {
|
||||
),
|
||||
terminalBranch = terminalBranch,
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
|
@ -39,7 +39,7 @@ object Comment {
|
||||
sealed case class Documentation(
|
||||
doc: String,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Comment
|
||||
with IRKind.Primitive {
|
||||
@ -75,7 +75,8 @@ object Comment {
|
||||
): Documentation =
|
||||
copy(
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
|
@ -39,7 +39,7 @@ object Error {
|
||||
*/
|
||||
sealed case class InvalidIR(
|
||||
ir: IR,
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Error
|
||||
with Diagnostic.Kind.Static
|
||||
@ -79,7 +79,8 @@ object Error {
|
||||
keepDiagnostics,
|
||||
keepIdentifiers
|
||||
),
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
|
@ -44,7 +44,7 @@ object Foreign {
|
||||
lang: String,
|
||||
code: String,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Foreign
|
||||
with IRKind.Primitive {
|
||||
@ -82,7 +82,8 @@ object Foreign {
|
||||
): Definition =
|
||||
copy(
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
|
@ -43,7 +43,7 @@ object Operator {
|
||||
operator: Name,
|
||||
right: CallArgument,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Operator
|
||||
with IRKind.Sugar {
|
||||
@ -102,7 +102,8 @@ object Operator {
|
||||
keepIdentifiers
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
|
@ -41,7 +41,7 @@ object Section {
|
||||
arg: CallArgument,
|
||||
operator: Name,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Section
|
||||
with IRKind.Sugar {
|
||||
@ -92,7 +92,8 @@ object Section {
|
||||
keepIdentifiers
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
@ -142,7 +143,7 @@ object Section {
|
||||
sealed case class Sides(
|
||||
operator: Name,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Section
|
||||
with IRKind.Sugar {
|
||||
@ -185,7 +186,8 @@ object Section {
|
||||
keepIdentifiers
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
@ -234,7 +236,7 @@ object Section {
|
||||
operator: Name,
|
||||
arg: CallArgument,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Section
|
||||
with IRKind.Sugar {
|
||||
@ -285,7 +287,8 @@ object Section {
|
||||
keepIdentifiers
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
|
@ -18,7 +18,7 @@ import java.util.UUID
|
||||
sealed case class Conversion(
|
||||
storedIr: IR,
|
||||
reason: Conversion.Reason,
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Error
|
||||
with Diagnostic.Kind.Interactive
|
||||
@ -72,7 +72,8 @@ sealed case class Conversion(
|
||||
keepDiagnostics,
|
||||
keepIdentifiers
|
||||
),
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
|
@ -20,7 +20,7 @@ import scala.annotation.unused
|
||||
sealed case class ImportExport(
|
||||
ir: IR,
|
||||
reason: ImportExport.Reason,
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Error
|
||||
with Diagnostic.Kind.Interactive
|
||||
@ -58,7 +58,8 @@ sealed case class ImportExport(
|
||||
keepIdentifiers: Boolean = false
|
||||
): ImportExport =
|
||||
copy(
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
|
@ -19,7 +19,7 @@ import java.util.UUID
|
||||
sealed case class Pattern(
|
||||
originalPattern: org.enso.compiler.core.ir.Pattern,
|
||||
reason: Pattern.Reason,
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
passData: MetadataStorage = new MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Error
|
||||
with Diagnostic.Kind.Interactive
|
||||
@ -68,7 +68,8 @@ sealed case class Pattern(
|
||||
keepDiagnostics,
|
||||
keepIdentifiers
|
||||
),
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
|
@ -42,7 +42,7 @@ object Redefined {
|
||||
*/
|
||||
sealed case class SelfArg(
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Redefined
|
||||
with Diagnostic.Kind.Interactive
|
||||
@ -77,7 +77,8 @@ object Redefined {
|
||||
): SelfArg =
|
||||
copy(
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
@ -123,7 +124,7 @@ object Redefined {
|
||||
targetType: Option[Name],
|
||||
sourceType: Name,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Redefined
|
||||
with Diagnostic.Kind.Interactive
|
||||
@ -181,7 +182,8 @@ object Redefined {
|
||||
keepIdentifiers
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
@ -247,7 +249,7 @@ object Redefined {
|
||||
atomName: Option[Name],
|
||||
methodName: Name,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Redefined
|
||||
with Diagnostic.Kind.Interactive
|
||||
@ -304,7 +306,8 @@ object Redefined {
|
||||
keepIdentifiers
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
@ -370,7 +373,7 @@ object Redefined {
|
||||
atomName: Name,
|
||||
methodName: Name,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Redefined
|
||||
with Diagnostic.Kind.Interactive
|
||||
@ -430,7 +433,8 @@ object Redefined {
|
||||
keepIdentifiers
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
@ -488,7 +492,7 @@ object Redefined {
|
||||
sealed case class Type(
|
||||
typeName: Name,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Redefined
|
||||
with Diagnostic.Kind.Interactive
|
||||
@ -535,7 +539,8 @@ object Redefined {
|
||||
keepIdentifiers
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
@ -588,7 +593,7 @@ object Redefined {
|
||||
*/
|
||||
sealed case class Binding(
|
||||
invalidBinding: Expression.Binding,
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Redefined
|
||||
with Diagnostic.Kind.Interactive
|
||||
@ -629,7 +634,8 @@ object Redefined {
|
||||
keepDiagnostics,
|
||||
keepIdentifiers
|
||||
),
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
|
@ -18,7 +18,7 @@ import java.util.UUID
|
||||
sealed case class Resolution(
|
||||
originalName: Name,
|
||||
reason: Resolution.Reason,
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
passData: MetadataStorage = new MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Error
|
||||
with Diagnostic.Kind.Interactive
|
||||
@ -72,7 +72,8 @@ sealed case class Resolution(
|
||||
keepDiagnostics,
|
||||
keepIdentifiers
|
||||
),
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = randomId
|
||||
|
@ -20,7 +20,7 @@ import scala.annotation.unused
|
||||
sealed case class Syntax(
|
||||
at: IdentifiedLocation,
|
||||
reason: Syntax.Reason,
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
passData: MetadataStorage = new MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Error
|
||||
with Diagnostic.Kind.Interactive
|
||||
@ -59,7 +59,8 @@ sealed case class Syntax(
|
||||
keepIdentifiers: Boolean = false
|
||||
): Syntax =
|
||||
copy(
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
|
@ -53,7 +53,7 @@ object Unexpected {
|
||||
*/
|
||||
sealed case class TypeSignature(
|
||||
override val ir: IR,
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
passData: MetadataStorage = new MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Unexpected
|
||||
with IRKind.Primitive
|
||||
@ -105,7 +105,8 @@ object Unexpected {
|
||||
keepDiagnostics,
|
||||
keepIdentifiers
|
||||
),
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
|
@ -57,7 +57,7 @@ object Definition {
|
||||
params: List[DefinitionArgument],
|
||||
members: List[Data],
|
||||
location: Option[IdentifiedLocation],
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
passData: MetadataStorage = new MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Definition
|
||||
with IRKind.Primitive {
|
||||
@ -101,7 +101,8 @@ object Definition {
|
||||
)
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
@ -161,7 +162,7 @@ object Definition {
|
||||
arguments: List[DefinitionArgument],
|
||||
annotations: List[Name.GenericAnnotation],
|
||||
location: Option[IdentifiedLocation],
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
passData: MetadataStorage = new MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends IR
|
||||
with IRKind.Primitive {
|
||||
@ -222,7 +223,8 @@ object Definition {
|
||||
)
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
@ -283,7 +285,7 @@ object Definition {
|
||||
arguments: List[DefinitionArgument],
|
||||
body: List[IR],
|
||||
location: Option[IdentifiedLocation],
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
passData: MetadataStorage = new MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Definition
|
||||
with IRKind.Sugar {
|
||||
@ -352,7 +354,8 @@ object Definition {
|
||||
)
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
|
@ -57,7 +57,7 @@ object Export {
|
||||
hiddenNames: Option[List[Name.Literal]],
|
||||
override val location: Option[IdentifiedLocation],
|
||||
isSynthetic: Boolean = false,
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends IR
|
||||
with IRKind.Primitive
|
||||
@ -114,7 +114,8 @@ object Export {
|
||||
): Module =
|
||||
copy(
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
|
@ -57,7 +57,7 @@ object Import {
|
||||
hiddenNames: Option[List[Name.Literal]],
|
||||
override val location: Option[IdentifiedLocation],
|
||||
isSynthetic: Boolean = false,
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Import
|
||||
with IRKind.Primitive {
|
||||
@ -113,7 +113,8 @@ object Import {
|
||||
): Module =
|
||||
copy(
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
|
@ -61,7 +61,7 @@ object Method {
|
||||
methodReference: Name.MethodReference,
|
||||
body: Expression,
|
||||
location: Option[IdentifiedLocation],
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
passData: MetadataStorage = new MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) = {
|
||||
this(
|
||||
@ -133,7 +133,8 @@ object Method {
|
||||
keepIdentifiers
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy
|
||||
else DiagnosticStorage(),
|
||||
@ -238,7 +239,7 @@ object Method {
|
||||
arguments: List[DefinitionArgument],
|
||||
override val body: Expression,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Method
|
||||
with IRKind.Sugar {
|
||||
@ -305,7 +306,8 @@ object Method {
|
||||
keepIdentifiers
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy
|
||||
else DiagnosticStorage(),
|
||||
@ -377,7 +379,7 @@ object Method {
|
||||
sourceTypeName: Expression,
|
||||
override val body: Expression,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Method
|
||||
with IRKind.Primitive {
|
||||
@ -444,7 +446,8 @@ object Method {
|
||||
keepIdentifiers
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy
|
||||
else DiagnosticStorage(),
|
||||
|
@ -27,7 +27,7 @@ sealed case class Polyglot(
|
||||
entity: Polyglot.Entity,
|
||||
rename: Option[String],
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Import
|
||||
with IRKind.Primitive {
|
||||
@ -67,7 +67,8 @@ sealed case class Polyglot(
|
||||
): Polyglot =
|
||||
copy(
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
|
@ -45,7 +45,7 @@ object Set {
|
||||
memberType: Expression,
|
||||
value: Expression,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Set
|
||||
with IRKind.Primitive {
|
||||
@ -105,7 +105,8 @@ object Set {
|
||||
keepIdentifiers
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
@ -167,7 +168,7 @@ object Set {
|
||||
left: Expression,
|
||||
right: Expression,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Set
|
||||
with IRKind.Primitive {
|
||||
@ -217,7 +218,8 @@ object Set {
|
||||
keepIdentifiers
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
@ -271,7 +273,7 @@ object Set {
|
||||
left: Expression,
|
||||
right: Expression,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Set
|
||||
with IRKind.Primitive {
|
||||
@ -321,7 +323,8 @@ object Set {
|
||||
keepIdentifiers
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
@ -375,7 +378,7 @@ object Set {
|
||||
left: Expression,
|
||||
right: Expression,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Set
|
||||
with IRKind.Primitive {
|
||||
@ -425,7 +428,8 @@ object Set {
|
||||
keepIdentifiers
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
@ -476,7 +480,7 @@ object Set {
|
||||
sealed case class Union(
|
||||
operands: List[Expression],
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Set
|
||||
with IRKind.Primitive {
|
||||
@ -521,7 +525,8 @@ object Set {
|
||||
)
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
@ -573,7 +578,7 @@ object Set {
|
||||
left: Expression,
|
||||
right: Expression,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val passData: MetadataStorage = new MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Set
|
||||
with IRKind.Primitive {
|
||||
@ -623,7 +628,8 @@ object Set {
|
||||
keepIdentifiers
|
||||
),
|
||||
location = if (keepLocations) location else None,
|
||||
passData = if (keepMetadata) passData.duplicate else MetadataStorage(),
|
||||
passData =
|
||||
if (keepMetadata) passData.duplicate else new MetadataStorage(),
|
||||
diagnostics =
|
||||
if (keepDiagnostics) diagnostics.copy else DiagnosticStorage(),
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
|
@ -198,7 +198,7 @@ public class IrPersistanceTest {
|
||||
|
||||
@Test
|
||||
public void serializeModule() throws Exception {
|
||||
var meta = new MetadataStorage(nil());
|
||||
var meta = new MetadataStorage();
|
||||
var diag = new DiagnosticStorage(nil());
|
||||
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.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, CompilerConfig}
|
||||
import org.enso.compiler.pass.analyse.BindingAnalysis
|
||||
@ -262,9 +262,12 @@ trait CompilerRunner {
|
||||
mod,
|
||||
Module(List(), List(), List(), false, None)
|
||||
.updateMetadata(
|
||||
BindingAnalysis -->> BindingsMap(
|
||||
List(),
|
||||
ModuleReference.Concrete(mod.asCompilerModule())
|
||||
new MetadataPair(
|
||||
BindingAnalysis,
|
||||
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.MetadataStorage
|
||||
import org.enso.compiler.core.ir.MetadataStorage._
|
||||
import org.enso.compiler.core.CompilerError
|
||||
import org.enso.compiler.pass.IRPass
|
||||
import org.enso.compiler.test.CompilerTest
|
||||
import shapeless.test.illTyped
|
||||
import scala.jdk.CollectionConverters._
|
||||
|
||||
class MetadataStorageTest extends CompilerTest {
|
||||
|
||||
@ -82,118 +82,133 @@ class MetadataStorageTest extends CompilerTest {
|
||||
|
||||
"The metadata storage" should {
|
||||
"allow adding metadata pairs" in {
|
||||
val meta = MetadataStorage()
|
||||
val meta = new MetadataStorage()
|
||||
|
||||
val pass = TestPass1
|
||||
val passMeta = TestPass1.Metadata1()
|
||||
val depPair = pass -->> passMeta
|
||||
val depPair = new MetadataPair(pass, passMeta)
|
||||
|
||||
meta.update(depPair)
|
||||
meta.get(pass) shouldEqual Some(passMeta)
|
||||
}
|
||||
|
||||
"allow adding metadata" in {
|
||||
val meta = MetadataStorage()
|
||||
val meta = new MetadataStorage()
|
||||
|
||||
val meta1 = TestPass1.Metadata1()
|
||||
val meta2 = TestPass2.Metadata2()
|
||||
|
||||
meta.update(TestPass1)(meta1)
|
||||
meta.update(TestPass2)(meta2)
|
||||
meta.update(TestPass1, meta1)
|
||||
meta.update(TestPass2, meta2)
|
||||
|
||||
meta.get(TestPass1) shouldEqual Some(meta1)
|
||||
meta.get(TestPass2) shouldEqual Some(meta2)
|
||||
}
|
||||
|
||||
"allow getting metadata" in {
|
||||
val meta = MetadataStorage()
|
||||
val meta = new MetadataStorage()
|
||||
val passMeta = TestPass1.Metadata1()
|
||||
|
||||
meta.update(TestPass1)(passMeta)
|
||||
meta.update(TestPass1, passMeta)
|
||||
meta.get(TestPass1) shouldEqual Some(passMeta)
|
||||
}
|
||||
|
||||
"allow unsafely getting metadata" in {
|
||||
val meta = MetadataStorage()
|
||||
val meta = new MetadataStorage()
|
||||
val passMeta = TestPass1.Metadata1()
|
||||
|
||||
meta.update(TestPass1)(passMeta)
|
||||
meta.getUnsafe(TestPass1)("aaaa") shouldEqual passMeta
|
||||
meta.update(TestPass1, passMeta)
|
||||
meta.get(TestPass1).get shouldEqual passMeta
|
||||
|
||||
def testThrow = meta.getUnsafe(TestPass2)("aaa")
|
||||
val msg = "Compiler Internal Error: aaa"
|
||||
meta.get(TestPass2) match {
|
||||
case None =>
|
||||
case any => fail("Expecting None: " + any)
|
||||
}
|
||||
|
||||
the[CompilerError] thrownBy testThrow should have message msg
|
||||
}
|
||||
|
||||
"allow updating metadata" in {
|
||||
val meta = MetadataStorage()
|
||||
val meta = new MetadataStorage()
|
||||
|
||||
val meta1 = TestPass1.Metadata1()
|
||||
val meta2 = TestPass1.Metadata1()
|
||||
|
||||
meta.update(TestPass1)(meta1)
|
||||
meta.update(TestPass1, meta1)
|
||||
meta.get(TestPass1) shouldEqual Some(meta1)
|
||||
meta.update(TestPass1)(meta2)
|
||||
meta.update(TestPass1, meta2)
|
||||
meta.get(TestPass1) shouldEqual Some(meta2)
|
||||
}
|
||||
|
||||
"allow removing metadata" in {
|
||||
val meta = MetadataStorage()
|
||||
val meta = new MetadataStorage()
|
||||
|
||||
val meta1 = TestPass1.Metadata1()
|
||||
meta.update(TestPass1)(meta1)
|
||||
meta.update(TestPass1, meta1)
|
||||
|
||||
meta.remove(TestPass1) shouldEqual Some(meta1)
|
||||
meta.get(TestPass1) shouldEqual None
|
||||
}
|
||||
|
||||
"compare equal when containing the same metadata" in {
|
||||
val meta1 = MetadataStorage()
|
||||
val meta2 = MetadataStorage()
|
||||
val meta1 = new MetadataStorage()
|
||||
val meta2 = new MetadataStorage()
|
||||
|
||||
meta1 shouldEqual meta2
|
||||
|
||||
meta1.update(TestPass1)(TestPass1.Metadata1())
|
||||
meta2.update(TestPass1)(TestPass1.Metadata1())
|
||||
meta1.update(TestPass1, TestPass1.Metadata1())
|
||||
meta2.update(TestPass1, TestPass1.Metadata1())
|
||||
|
||||
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 {
|
||||
val meta = MetadataStorage(
|
||||
TestPass1 -->> TestPass1.Metadata1(),
|
||||
TestPass2 -->> TestPass2.Metadata2()
|
||||
val meta = newMetadataStorage(
|
||||
Seq(
|
||||
new MetadataPair(TestPass1, TestPass1.Metadata1()),
|
||||
new MetadataPair(TestPass2, TestPass2.Metadata2())
|
||||
)
|
||||
)
|
||||
|
||||
val expected = Map(
|
||||
TestPass1 -> "TestPass1.Metadata1",
|
||||
TestPass2 -> "TestPass2.Metadata2"
|
||||
val expected = List(
|
||||
(TestPass1, "TestPass1.Metadata1"),
|
||||
(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 {
|
||||
val meta = MetadataStorage(
|
||||
TestPass1 -->> TestPass1.Metadata1(),
|
||||
TestPass2 -->> TestPass2.Metadata2()
|
||||
val meta = newMetadataStorage(
|
||||
Seq(
|
||||
new MetadataPair(TestPass1, TestPass1.Metadata1()),
|
||||
new MetadataPair(TestPass2, TestPass2.Metadata2())
|
||||
)
|
||||
)
|
||||
|
||||
val expected = MetadataStorage(
|
||||
TestPass1 -->> TestPass1.Metadata1(),
|
||||
TestPass2 -->> TestPass2.Metadata2()
|
||||
val expected = newMetadataStorage(
|
||||
Seq(
|
||||
new MetadataPair(TestPass1, TestPass1.Metadata1()),
|
||||
new MetadataPair(TestPass2, TestPass2.Metadata2())
|
||||
)
|
||||
)
|
||||
|
||||
meta.copy shouldEqual meta
|
||||
meta.copy shouldEqual expected
|
||||
meta.duplicate shouldEqual meta
|
||||
meta.duplicate shouldEqual expected
|
||||
}
|
||||
|
||||
"enforce safe construction" in {
|
||||
val test1 = TestPass1 -->> TestPass1.Metadata1()
|
||||
val test2 = TestPass2 -->> TestPass2.Metadata2()
|
||||
val test1 = new MetadataPair(TestPass1, TestPass1.Metadata1())
|
||||
val test2 = new MetadataPair(TestPass2, TestPass2.Metadata2())
|
||||
|
||||
MetadataStorage(test1, test2)
|
||||
newMetadataStorage(Seq(test1, test2))
|
||||
|
||||
illTyped("TestPass1 -->> TestPass2.Metadata1()")
|
||||
illTyped("PassConfiguration(test1, (1, 1))")
|
||||
|
Loading…
Reference in New Issue
Block a user