mirror of
https://github.com/enso-org/enso.git
synced 2024-12-23 15:12:15 +03:00
Translate IR to Java (#8145)
Towards reduced reliance on Scala semantics. Translated IR.scala to IR.java and extracted implicits that now need to be imported explicitly. # Important Notes 1:1 translation. For now `@Identifier` and `@ExternalID` represent the old type aliases but are not verified at compile time. This is because in a mixed Scala/Java world this seems impossible to employ such frameworks as Checker.
This commit is contained in:
parent
53ecaf44ae
commit
10f35390a1
@ -161,7 +161,7 @@ object SearchProtocol {
|
||||
for {
|
||||
externalId <- cursor
|
||||
.downField(CodecField.ExternalId)
|
||||
.as[Option[Suggestion.ExternalId]]
|
||||
.as[Option[Suggestion.ExternalID]]
|
||||
module <- cursor.downField(CodecField.Module).as[String]
|
||||
name <- cursor.downField(CodecField.Name).as[String]
|
||||
params <- cursor
|
||||
@ -334,7 +334,7 @@ object SearchProtocol {
|
||||
*/
|
||||
case class Modify(
|
||||
id: SuggestionId,
|
||||
externalId: Option[FieldUpdate[Suggestion.ExternalId]] = None,
|
||||
externalId: Option[FieldUpdate[Suggestion.ExternalID]] = None,
|
||||
arguments: Option[Seq[SuggestionArgumentUpdate]] = None,
|
||||
module: Option[FieldUpdate[String]] = None,
|
||||
selfType: Option[FieldUpdate[String]] = None,
|
||||
|
@ -45,7 +45,7 @@ import java.util.UUID
|
||||
)
|
||||
sealed trait Suggestion extends ToLogString {
|
||||
|
||||
def externalId: Option[Suggestion.ExternalId]
|
||||
def externalId: Option[Suggestion.ExternalID]
|
||||
def module: String
|
||||
def name: String
|
||||
def returnType: String
|
||||
@ -57,7 +57,7 @@ sealed trait Suggestion extends ToLogString {
|
||||
|
||||
object Suggestion {
|
||||
|
||||
type ExternalId = UUID
|
||||
type ExternalID = UUID
|
||||
|
||||
/** @return `true` if the suggestion id defined in the global (module) scope.
|
||||
*/
|
||||
@ -235,7 +235,7 @@ object Suggestion {
|
||||
override def name: String =
|
||||
module
|
||||
|
||||
override def externalId: Option[ExternalId] =
|
||||
override def externalId: Option[ExternalID] =
|
||||
None
|
||||
|
||||
override def returnType: String =
|
||||
@ -264,7 +264,7 @@ object Suggestion {
|
||||
* @param reexport the module re-exporting this atom
|
||||
*/
|
||||
case class Type(
|
||||
externalId: Option[ExternalId],
|
||||
externalId: Option[ExternalID],
|
||||
module: String,
|
||||
name: String,
|
||||
params: Seq[Argument],
|
||||
@ -305,7 +305,7 @@ object Suggestion {
|
||||
* @param reexport the module re-exporting this atom
|
||||
*/
|
||||
case class Constructor(
|
||||
externalId: Option[ExternalId],
|
||||
externalId: Option[ExternalID],
|
||||
module: String,
|
||||
name: String,
|
||||
arguments: Seq[Argument],
|
||||
@ -372,7 +372,7 @@ object Suggestion {
|
||||
* @param reexport the module re-exporting this method
|
||||
*/
|
||||
case class Getter(
|
||||
externalId: Option[ExternalId],
|
||||
externalId: Option[ExternalID],
|
||||
module: String,
|
||||
name: String,
|
||||
arguments: Seq[Argument],
|
||||
@ -419,7 +419,7 @@ object Suggestion {
|
||||
* @param reexport the module re-exporting this method
|
||||
*/
|
||||
case class DefinedMethod(
|
||||
externalId: Option[ExternalId],
|
||||
externalId: Option[ExternalID],
|
||||
module: String,
|
||||
name: String,
|
||||
arguments: Seq[Argument],
|
||||
@ -461,7 +461,7 @@ object Suggestion {
|
||||
* @param reexport the module re-exporting this conversion
|
||||
*/
|
||||
case class Conversion(
|
||||
externalId: Option[ExternalId],
|
||||
externalId: Option[ExternalID],
|
||||
module: String,
|
||||
arguments: Seq[Argument],
|
||||
selfType: String,
|
||||
@ -510,7 +510,7 @@ object Suggestion {
|
||||
* @param documentation the documentation string
|
||||
*/
|
||||
case class Function(
|
||||
externalId: Option[ExternalId],
|
||||
externalId: Option[ExternalID],
|
||||
module: String,
|
||||
name: String,
|
||||
arguments: Seq[Argument],
|
||||
@ -547,7 +547,7 @@ object Suggestion {
|
||||
* @param documentation the documentation string
|
||||
*/
|
||||
case class Local(
|
||||
externalId: Option[ExternalId],
|
||||
externalId: Option[ExternalID],
|
||||
module: String,
|
||||
name: String,
|
||||
returnType: String,
|
||||
|
@ -799,7 +799,7 @@ object Runtime {
|
||||
* @param reexport the reexport field to update
|
||||
*/
|
||||
case class Modify(
|
||||
externalId: Option[Option[Suggestion.ExternalId]] = None,
|
||||
externalId: Option[Option[Suggestion.ExternalID]] = None,
|
||||
arguments: Option[Seq[SuggestionArgumentAction]] = None,
|
||||
returnType: Option[String] = None,
|
||||
documentation: Option[Option[String]] = None,
|
||||
|
@ -1,13 +1,19 @@
|
||||
package org.enso.compiler.context
|
||||
|
||||
import com.oracle.truffle.api.source.Source
|
||||
|
||||
import java.util.UUID
|
||||
import org.enso.compiler.core.EnsoParser
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.{
|
||||
CompilerError,
|
||||
EnsoParser,
|
||||
ExternalID,
|
||||
IR,
|
||||
Identifier
|
||||
}
|
||||
import org.enso.compiler.core.Implicits.AsMetadata
|
||||
import org.enso.compiler.core.ir.Literal
|
||||
import org.enso.compiler.core.ir.Name
|
||||
import org.enso.compiler.core.ir.module.scope.definition
|
||||
import org.enso.compiler.core.CompilerError
|
||||
import org.enso.compiler.pass.analyse.DataflowAnalysis
|
||||
import org.enso.interpreter.instrument.execution.model.PendingEdit
|
||||
import org.enso.syntax.text.Location
|
||||
@ -30,7 +36,7 @@ case class Changeset[A](
|
||||
source: A,
|
||||
ir: IR,
|
||||
simpleUpdate: Option[SimpleUpdate],
|
||||
invalidated: Set[IR.ExternalId]
|
||||
invalidated: Set[UUID @ExternalID]
|
||||
)
|
||||
|
||||
/** Compute invalidated expressions.
|
||||
@ -120,7 +126,7 @@ final class ChangesetBuilder[A: TextEditor: IndexedSource](
|
||||
* @return the set of all IR nodes affected by the edit
|
||||
*/
|
||||
@throws[CompilerError]
|
||||
def compute(edits: Seq[TextEdit]): Set[IR.ExternalId] = {
|
||||
def compute(edits: Seq[TextEdit]): Set[UUID @ExternalID] = {
|
||||
val metadata = ir
|
||||
.unsafeGetMetadata(
|
||||
DataflowAnalysis,
|
||||
@ -131,7 +137,7 @@ final class ChangesetBuilder[A: TextEditor: IndexedSource](
|
||||
def go(
|
||||
queue: mutable.Queue[DataflowAnalysis.DependencyInfo.Type],
|
||||
visited: mutable.Set[DataflowAnalysis.DependencyInfo.Type]
|
||||
): Set[IR.ExternalId] =
|
||||
): Set[UUID @ExternalID] =
|
||||
if (queue.isEmpty) visited.flatMap(_.externalId).toSet
|
||||
else {
|
||||
val elem = queue.dequeue()
|
||||
@ -221,8 +227,8 @@ object ChangesetBuilder {
|
||||
* @param name optional node name
|
||||
*/
|
||||
case class NodeId(
|
||||
internalId: IR.Identifier,
|
||||
externalId: Option[IR.ExternalId],
|
||||
internalId: UUID @Identifier,
|
||||
externalId: Option[UUID @ExternalID],
|
||||
name: Option[Symbol]
|
||||
)
|
||||
|
||||
@ -237,9 +243,10 @@ object ChangesetBuilder {
|
||||
new NodeId(ir.getId, ir.getExternalId, getName(ir))
|
||||
|
||||
implicit val ordering: Ordering[NodeId] = (x: NodeId, y: NodeId) => {
|
||||
val cmpInternal = Ordering[UUID].compare(x.internalId, y.internalId)
|
||||
val cmpInternal =
|
||||
Ordering[UUID @Identifier].compare(x.internalId, y.internalId)
|
||||
if (cmpInternal == 0) {
|
||||
Ordering[Option[UUID]].compare(x.externalId, y.externalId)
|
||||
Ordering[Option[UUID @ExternalID]].compare(x.externalId, y.externalId)
|
||||
} else {
|
||||
cmpInternal
|
||||
}
|
||||
@ -512,7 +519,7 @@ object ChangesetBuilder {
|
||||
* @param id the node identifier
|
||||
* @return the node name
|
||||
*/
|
||||
private def getExpressionName(ir: IR, id: IR.Identifier): Option[String] =
|
||||
private def getExpressionName(ir: IR, id: UUID @Identifier): Option[String] =
|
||||
ir.preorder.find(_.getId == id).collect {
|
||||
case name: Name =>
|
||||
name.name
|
||||
|
@ -1,12 +1,14 @@
|
||||
package org.enso.interpreter.instrument.execution
|
||||
|
||||
import com.oracle.truffle.api.source.SourceSection
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.{ExternalID, IR, Identifier}
|
||||
import org.enso.compiler.core.ir.IdentifiedLocation
|
||||
import org.enso.interpreter.runtime.Module
|
||||
import org.enso.syntax.text.Location
|
||||
import org.enso.text.editing.{model, IndexedSource}
|
||||
|
||||
import java.util.UUID
|
||||
|
||||
/** Helper methods to convert between the `IR` and source locations, and
|
||||
* resolving the expression ids in the source text.
|
||||
*/
|
||||
@ -17,7 +19,10 @@ object LocationResolver {
|
||||
* @param internalId the internal node id
|
||||
* @param externalId the external node id
|
||||
*/
|
||||
case class ExpressionId(internalId: IR.Identifier, externalId: IR.ExternalId)
|
||||
case class ExpressionId(
|
||||
internalid: UUID @Identifier,
|
||||
externalId: UUID @ExternalID
|
||||
)
|
||||
|
||||
/** Resolve expression id of the given source section.
|
||||
*
|
||||
|
@ -4,6 +4,7 @@ import cats.implicits._
|
||||
import com.oracle.truffle.api.TruffleLogger
|
||||
import org.enso.compiler.CompilerResult
|
||||
import org.enso.compiler.context._
|
||||
import org.enso.compiler.core.Implicits.AsMetadata
|
||||
import org.enso.compiler.core.CompilerError
|
||||
import org.enso.compiler.core.ir.{Diagnostic, Warning}
|
||||
import org.enso.compiler.core.ir.expression.Error
|
||||
@ -304,7 +305,9 @@ final class EnsureCompiledJob(
|
||||
source: CharSequence
|
||||
): Seq[CacheInvalidation] = {
|
||||
val invalidateExpressionsCommand =
|
||||
CacheInvalidation.Command.InvalidateKeys(changeset.invalidated)
|
||||
CacheInvalidation.Command.InvalidateKeys(
|
||||
changeset.invalidated
|
||||
)
|
||||
val scopeIds = splitMeta(source.toString)._2.map(_._2)
|
||||
val invalidateStaleCommand =
|
||||
CacheInvalidation.Command.InvalidateStale(scopeIds)
|
||||
|
@ -1,6 +1,6 @@
|
||||
package org.enso.interpreter.instrument.job
|
||||
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.{ExternalID, IR}
|
||||
import org.enso.compiler.core.ir.Name
|
||||
import org.enso.compiler.refactoring.IRUtils
|
||||
import org.enso.interpreter.instrument.execution.RuntimeContext
|
||||
@ -191,13 +191,13 @@ final class RefactoringRenameJob(
|
||||
|
||||
object RefactoringRenameJob {
|
||||
|
||||
final private class ExpressionNotFound(val expressionId: IR.ExternalId)
|
||||
final private class ExpressionNotFound(val expressionId: UUID @ExternalID)
|
||||
extends Exception(s"Expression was not found by id [$expressionId].")
|
||||
|
||||
final private class FailedToApplyEdits(val module: String)
|
||||
extends Exception(s"Failed to apply edits to module [$module]")
|
||||
|
||||
final private class OperationNotSupported(val expressionId: IR.ExternalId)
|
||||
final private class OperationNotSupported(val expressionId: UUID @ExternalID)
|
||||
extends Exception(
|
||||
s"Operation not supported for expression [$expressionId]"
|
||||
)
|
||||
|
@ -2,6 +2,7 @@ package org.enso.interpreter.instrument.job
|
||||
|
||||
import cats.implicits._
|
||||
import com.oracle.truffle.api.TruffleLogger
|
||||
import org.enso.compiler.core.Implicits.AsMetadata
|
||||
import org.enso.compiler.core.ir.Function
|
||||
import org.enso.compiler.core.ir.Name
|
||||
import org.enso.compiler.core.ir.module.scope.definition
|
||||
@ -597,12 +598,13 @@ object UpsertVisualizationJob {
|
||||
module.getIr
|
||||
.getMetadata(DataflowAnalysis)
|
||||
.foreach { metadata =>
|
||||
val externalId = expressionId
|
||||
module.getIr.preorder
|
||||
.find(_.getExternalId.contains(expressionId))
|
||||
.find(_.getExternalId.contains(externalId))
|
||||
.collect {
|
||||
case name: Name.Literal =>
|
||||
DataflowAnalysis.DependencyInfo.Type
|
||||
.Dynamic(name.name, Some(expressionId))
|
||||
.Dynamic(name.name, Some(externalId))
|
||||
case ir =>
|
||||
DataflowAnalysis.DependencyInfo.Type
|
||||
.Static(ir.getId, ir.getExternalId)
|
||||
|
@ -7,7 +7,7 @@ import org.enso.compiler.context.{
|
||||
InlineContext,
|
||||
ModuleContext
|
||||
}
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.{ExternalID, IR, Identifier}
|
||||
import org.enso.compiler.core.ir.{CallArgument, Expression, Function}
|
||||
import org.enso.compiler.core.ir.expression.Application
|
||||
import org.enso.compiler.core.ir.expression.errors
|
||||
@ -206,7 +206,7 @@ class ChangesetBuilderTest extends CompilerTest {
|
||||
.get
|
||||
.asInstanceOf[Function.Lambda]
|
||||
val secondLine =
|
||||
ir.body.children(1).asInstanceOf[Application.Prefix]
|
||||
ir.body.children()(1).asInstanceOf[Application.Prefix]
|
||||
val y =
|
||||
secondLine.arguments(0).asInstanceOf[CallArgument.Specified].value
|
||||
val plus = secondLine.function
|
||||
@ -246,7 +246,7 @@ class ChangesetBuilderTest extends CompilerTest {
|
||||
.preprocessExpression(freshInlineContext)
|
||||
.get
|
||||
.asInstanceOf[Function.Lambda]
|
||||
val firstLine = ir.body.children(0).asInstanceOf[Expression.Binding]
|
||||
val firstLine = ir.body.children()(0).asInstanceOf[Expression.Binding]
|
||||
val five = firstLine.expression
|
||||
|
||||
invalidated(ir, code, edit) should contain theSameElementsAs Seq(
|
||||
@ -266,10 +266,10 @@ class ChangesetBuilderTest extends CompilerTest {
|
||||
.preprocessExpression(freshInlineContext)
|
||||
.get
|
||||
.asInstanceOf[Function.Lambda]
|
||||
val secondLine = ir.body.children(1).asInstanceOf[Expression.Binding]
|
||||
val secondLine = ir.body.children()(1).asInstanceOf[Expression.Binding]
|
||||
val z = secondLine.expression.asInstanceOf[Application.Force].target
|
||||
val thirdLine =
|
||||
ir.body.children(2).asInstanceOf[Application.Prefix]
|
||||
ir.body.children()(2).asInstanceOf[Application.Prefix]
|
||||
val y =
|
||||
thirdLine.arguments(0).asInstanceOf[CallArgument.Specified].value
|
||||
val plus = thirdLine.function
|
||||
@ -322,9 +322,9 @@ class ChangesetBuilderTest extends CompilerTest {
|
||||
.get
|
||||
.asInstanceOf[Expression.Binding]
|
||||
val body = ir.expression.asInstanceOf[Function.Lambda].body
|
||||
val secondLine = body.children(1).asInstanceOf[Expression.Binding]
|
||||
val secondLine = body.children()(1).asInstanceOf[Expression.Binding]
|
||||
val z = secondLine.expression.asInstanceOf[Application.Force].target
|
||||
val thirdLine = body.children(2).asInstanceOf[Application.Prefix]
|
||||
val thirdLine = body.children()(2).asInstanceOf[Application.Prefix]
|
||||
val y =
|
||||
thirdLine.arguments(0).asInstanceOf[CallArgument.Specified].value
|
||||
val plus = thirdLine.function
|
||||
@ -462,7 +462,11 @@ class ChangesetBuilderTest extends CompilerTest {
|
||||
}
|
||||
}
|
||||
|
||||
def invalidated(ir: IR, code: String, edits: TextEdit*): Set[IR.Identifier] =
|
||||
def invalidated(
|
||||
ir: IR,
|
||||
code: String,
|
||||
edits: TextEdit*
|
||||
): Set[UUID @Identifier] =
|
||||
new ChangesetBuilder(Rope(code), ir)
|
||||
.invalidated(edits)
|
||||
.map(n => n.externalId.getOrElse(n.internalId))
|
||||
@ -471,7 +475,7 @@ class ChangesetBuilderTest extends CompilerTest {
|
||||
ir: IR,
|
||||
code: String,
|
||||
edits: TextEdit*
|
||||
): Set[IR.ExternalId] =
|
||||
): Set[UUID @ExternalID] =
|
||||
new ChangesetBuilder(Rope(code), ir).compute(edits)
|
||||
|
||||
def freshModuleContext: ModuleContext =
|
||||
|
@ -0,0 +1,3 @@
|
||||
package org.enso.compiler.core;
|
||||
|
||||
public abstract class CompilerStub {}
|
@ -0,0 +1,10 @@
|
||||
package org.enso.compiler.core;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Documented
|
||||
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
|
||||
/** The type of external identifiers */
|
||||
public @interface ExternalID {}
|
@ -0,0 +1,180 @@
|
||||
package org.enso.compiler.core;
|
||||
|
||||
import com.oracle.truffle.api.source.Source;
|
||||
import java.io.Serializable;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
import org.enso.compiler.core.ir.DiagnosticStorage;
|
||||
import org.enso.compiler.core.ir.Expression;
|
||||
import org.enso.compiler.core.ir.IdentifiedLocation;
|
||||
import org.enso.compiler.core.ir.MetadataStorage;
|
||||
import org.enso.syntax.text.Debug;
|
||||
import scala.Option;
|
||||
import scala.collection.immutable.$colon$colon$;
|
||||
import scala.collection.immutable.List;
|
||||
|
||||
/**
|
||||
* [[IR]] is a temporary and fairly unsophisticated internal representation format for Enso
|
||||
* programs.
|
||||
*
|
||||
* <p>It is a purely tree-based representation to support basic desugaring and analysis passes that
|
||||
* do not rely on the ability to create cycles in the IR itself. Its existence is the natural
|
||||
* evolution of the older AstExpression format used during the initial development of the
|
||||
* interpreter.
|
||||
*
|
||||
* <p>Please note that all extensions of [[IR]] must reimplement `copy` to keep the id intact when
|
||||
* copying nodes. The copy implementation should provide a way to set the id for the copy, but
|
||||
* should default to being copied. Care must be taken to not end up with two nodes with the same ID.
|
||||
* When using `copy` to duplicate nodes, please ensure that a new ID is provided.
|
||||
*
|
||||
* <p>See also: Note [IR Equality and hashing]
|
||||
*/
|
||||
public interface IR extends Serializable {
|
||||
|
||||
long serialVersionUID = 8145L; // Scala to Java
|
||||
|
||||
/**
|
||||
* Storage for metadata that the node has been tagged with as the result of various compiler
|
||||
* passes.
|
||||
*/
|
||||
MetadataStorage passData();
|
||||
|
||||
/** The source location that the node corresponds to. */
|
||||
Option<IdentifiedLocation> location();
|
||||
|
||||
/**
|
||||
* Sets the location for an IR node.
|
||||
*
|
||||
* @param location the new location for the IR node
|
||||
* @return the IR node with its location set to `location`
|
||||
*/
|
||||
IR setLocation(Option<IdentifiedLocation> location);
|
||||
|
||||
/**
|
||||
* Gets the external identifier from an IR node, if it is present.
|
||||
*
|
||||
* @return the external identifier for this IR node
|
||||
*/
|
||||
default Option<@ExternalID UUID> getExternalId() {
|
||||
return location().flatMap(l -> l.id().map(id -> id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps the provided function over any expression defined as a child of the node this is called
|
||||
* on.
|
||||
*
|
||||
* @param fn the function to transform the expressions
|
||||
* @return `this`, potentially having had its children transformed by `fn`
|
||||
*/
|
||||
IR mapExpressions(Function<Expression, Expression> fn);
|
||||
|
||||
/**
|
||||
* Gets the list of all children IR nodes of this node.
|
||||
*
|
||||
* @return this node's children.
|
||||
*/
|
||||
List<IR> children();
|
||||
|
||||
/**
|
||||
* Lists all the nodes in the preorder walk of the tree of this node.
|
||||
*
|
||||
* @return all the descendants of this node.
|
||||
*/
|
||||
default List<IR> preorder() {
|
||||
List<IR> ordered = children().flatMap(c -> c.preorder());
|
||||
IR element = this;
|
||||
return $colon$colon$.MODULE$.apply(
|
||||
element, ordered); // ordered.prepended(element) is reporeted as ambiguous
|
||||
}
|
||||
|
||||
/**
|
||||
* Pretty prints the IR.
|
||||
*
|
||||
* @return a pretty-printed representation of the IR
|
||||
*/
|
||||
default String pretty() {
|
||||
return Debug.pretty(this.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the node's identifier.
|
||||
*
|
||||
* @return the node's identifier
|
||||
*/
|
||||
default @Identifier UUID getId() {
|
||||
return id();
|
||||
}
|
||||
|
||||
/** A unique identifier for a piece of IR. */
|
||||
@Identifier
|
||||
UUID id();
|
||||
|
||||
/** Storage for compiler diagnostics related to the IR node. */
|
||||
DiagnosticStorage diagnostics();
|
||||
|
||||
/**
|
||||
* Creates a deep structural copy of `this`, representing the same structure.
|
||||
*
|
||||
* <p>You can choose to keep the location, metadata and diagnostic information in the duplicated
|
||||
* copy, as well as whether you want to generate new node identifiers or not.
|
||||
*
|
||||
* @param keepLocations whether locations should be kept in the duplicated IR
|
||||
* @param keepMetadata whether the pass metadata should be kept in the duplicated IR
|
||||
* @param keepDiagnostics whether the diagnostics should be kept in the duplicated IR
|
||||
* @param keepIdentifiers whether the identifiers should be regenerated in the duplicated IR
|
||||
* @return a deep structural copy of `this`
|
||||
*/
|
||||
IR duplicate(
|
||||
boolean keepLocations,
|
||||
boolean keepMetadata,
|
||||
boolean keepDiagnostics,
|
||||
boolean keepIdentifiers);
|
||||
|
||||
/**
|
||||
* Shows the IR as code.
|
||||
*
|
||||
* @param indent the current indentation level
|
||||
* @return a string representation of `this`
|
||||
*/
|
||||
String showCode(int indent);
|
||||
|
||||
default String showCode() {
|
||||
return showCode(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a random identifier.
|
||||
*
|
||||
* @return a random identifier
|
||||
*/
|
||||
static @Identifier UUID randomId() {
|
||||
return UUID.randomUUID();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates an indent of `n` spaces.
|
||||
*
|
||||
* @param n the number of spaces
|
||||
* @return a string representing an `n`-space indent
|
||||
*/
|
||||
static String mkIndent(int n) {
|
||||
return " ".repeat(n);
|
||||
}
|
||||
|
||||
/** The size of a single indentation level. */
|
||||
int indentLevel = 4;
|
||||
|
||||
static String fileLocationFromSection(IdentifiedLocation loc, Source source) {
|
||||
var section = source.createSection(loc.location().start(), loc.location().length());
|
||||
var locStr =
|
||||
""
|
||||
+ section.getStartLine()
|
||||
+ ":"
|
||||
+ section.getStartColumn()
|
||||
+ "-"
|
||||
+ section.getEndLine()
|
||||
+ ":"
|
||||
+ section.getEndColumn();
|
||||
return source.getName() + "[" + locStr + "]";
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package org.enso.compiler.core;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Documented
|
||||
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
|
||||
/** The type of identifiers for IR nodes. */
|
||||
public @interface Identifier {}
|
@ -1,3 +0,0 @@
|
||||
package org.enso.compiler.core
|
||||
|
||||
abstract class CompilerStub {}
|
@ -1,340 +0,0 @@
|
||||
package org.enso.compiler.core
|
||||
|
||||
import com.oracle.truffle.api.source.Source
|
||||
|
||||
import org.enso.compiler.core.ir.MetadataStorage.MetadataPair
|
||||
import org.enso.compiler.core.ir.{
|
||||
Diagnostic,
|
||||
DiagnosticStorage,
|
||||
Expression,
|
||||
IdentifiedLocation,
|
||||
MetadataStorage,
|
||||
ProcessingPass
|
||||
}
|
||||
import org.enso.syntax.text.Debug
|
||||
|
||||
import java.util.UUID
|
||||
|
||||
/** [[IR]] is a temporary and fairly unsophisticated internal representation
|
||||
* format for Enso programs.
|
||||
*
|
||||
* It is a purely tree-based representation to support basic desugaring and
|
||||
* analysis passes that do not rely on the ability to create cycles in the IR
|
||||
* itself. Its existence is the natural evolution of the older AstExpression
|
||||
* format used during the initial development of the interpreter.
|
||||
*
|
||||
* In time, it will be replaced by [[Core]], but expediency dictates that we
|
||||
* retain and evolve this representation for the near future.
|
||||
*
|
||||
* Please note that all extensions of [[IR]] must reimplement `copy` to keep
|
||||
* the id intact when copying nodes. The copy implementation should provide a
|
||||
* way to set the id for the copy, but should default to being copied. Care
|
||||
* must be taken to not end up with two nodes with the same ID. When using
|
||||
* `copy` to duplicate nodes, please ensure that a new ID is provided.
|
||||
*
|
||||
* See also: Note [IR Equality and hashing]
|
||||
*/
|
||||
trait IR extends Serializable {
|
||||
|
||||
/** Storage for metadata that the node has been tagged with as the result of
|
||||
* various compiler passes.
|
||||
*/
|
||||
val passData: MetadataStorage
|
||||
|
||||
/** The source location that the node corresponds to. */
|
||||
val location: Option[IdentifiedLocation]
|
||||
|
||||
/** Sets the location for an IR node.
|
||||
*
|
||||
* @param location the new location for the IR node
|
||||
* @return the IR node with its location set to `location`
|
||||
*/
|
||||
def setLocation(location: Option[IdentifiedLocation]): IR
|
||||
|
||||
/** Gets the external identifier from an IR node, if it is present.
|
||||
*
|
||||
* @return the external identifier for this IR node
|
||||
*/
|
||||
def getExternalId: Option[IR.ExternalId] = {
|
||||
location.flatMap(l => l.id)
|
||||
}
|
||||
|
||||
/** Maps the provided function over any expression defined as a child of the
|
||||
* node this is called on.
|
||||
*
|
||||
* @param fn the function to transform the expressions
|
||||
* @return `this`, potentially having had its children transformed by `fn`
|
||||
*/
|
||||
def mapExpressions(fn: Expression => Expression): IR
|
||||
|
||||
/** Gets the list of all children IR nodes of this node.
|
||||
*
|
||||
* @return this node's children.
|
||||
*/
|
||||
def children: List[IR]
|
||||
|
||||
/** Lists all the nodes in the preorder walk of the tree of this node.
|
||||
*
|
||||
* @return all the descendants of this node.
|
||||
*/
|
||||
def preorder: List[IR] = this :: children.flatMap(_.preorder)
|
||||
|
||||
/** Pretty prints the IR.
|
||||
*
|
||||
* @return a pretty-printed representation of the IR
|
||||
*/
|
||||
def pretty: String = Debug.pretty(this.toString)
|
||||
|
||||
/** Gets the node's identifier.
|
||||
*
|
||||
* @return the node's identifier
|
||||
*/
|
||||
def getId: IR.Identifier = id
|
||||
|
||||
/** A unique identifier for a piece of IR. */
|
||||
protected var id: IR.Identifier
|
||||
|
||||
/** Storage for compiler diagnostics related to the IR node. */
|
||||
val diagnostics: DiagnosticStorage
|
||||
|
||||
/** Creates a deep structural copy of `this`, representing the same structure.
|
||||
*
|
||||
* You can choose to keep the location, metadata and diagnostic information
|
||||
* in the duplicated copy, as well as whether or not you want to generate new
|
||||
* node identifiers or not.
|
||||
*
|
||||
* @param keepLocations whether or not locations should be kept in the
|
||||
* duplicated IR
|
||||
* @param keepMetadata whether or not the pass metadata should be kept in the
|
||||
* duplicated IR
|
||||
* @param keepDiagnostics whether or not the diagnostics should be kept in
|
||||
* the duplicated IR
|
||||
* @param keepIdentifiers whether or not the identifiers should be
|
||||
* regenerated in the duplicated IR
|
||||
* @return a deep structural copy of `this`
|
||||
*/
|
||||
def duplicate(
|
||||
keepLocations: Boolean = true,
|
||||
keepMetadata: Boolean = true,
|
||||
keepDiagnostics: Boolean = true,
|
||||
keepIdentifiers: Boolean = false
|
||||
): IR
|
||||
|
||||
/** Shows the IR as code.
|
||||
*
|
||||
* @param indent the current indentation level
|
||||
* @return a string representation of `this`
|
||||
*/
|
||||
def showCode(indent: Int = 0): String
|
||||
}
|
||||
|
||||
/* Note [IR Equality and hashing]
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* As the IRs are implemented as case classes, their equality is determined by
|
||||
* the values included in the constructor. These include the MetadataStorage and
|
||||
* DiagnosticStorage. These two storages break the contract of `hashCode` by
|
||||
* overriding the `equals` method to compare for equality by their contents, but
|
||||
* not `hashCode` (because it would have to be mutable). As the case classes of
|
||||
* the IR use that to implement their own equality and hashing, their
|
||||
* implementation is also troubled by this. Instances of IR that are equal by
|
||||
* the `equals` function, may still return different `hashCode`.
|
||||
*
|
||||
* The MetadataStorage and DiagnosticStorage should not be used for checking
|
||||
* equality of the IR. This should be addressed when the IR is refactored to be
|
||||
* properly mutable.
|
||||
*/
|
||||
|
||||
object IR {
|
||||
|
||||
/** Creates a random identifier.
|
||||
*
|
||||
* @return a random identifier
|
||||
*/
|
||||
def randomId: IR.Identifier = {
|
||||
UUID.randomUUID()
|
||||
}
|
||||
|
||||
/** The type of identifiers for IR nodes. */
|
||||
type Identifier = UUID
|
||||
|
||||
/** The type of external identifiers */
|
||||
type ExternalId = UUID
|
||||
|
||||
/** Generates an indent of `n` spaces.
|
||||
*
|
||||
* @param n the number of spaces
|
||||
* @return a string representing an `n`-space indent
|
||||
*/
|
||||
def mkIndent(n: Int): String = {
|
||||
" " * n
|
||||
}
|
||||
|
||||
/** The size of a single indentation level. */
|
||||
val indentLevel: Int = 4
|
||||
|
||||
// ==========================================================================
|
||||
// === Extension Methods ====================================================
|
||||
// ==========================================================================
|
||||
|
||||
/** This class adds an extension method to control how the pass data element
|
||||
* of the IR is printed.
|
||||
*
|
||||
* @param ir the IR to print the pass data for
|
||||
*/
|
||||
implicit class ShowPassData(ir: IR) {
|
||||
|
||||
/** Creates a string representation of the pass data for a given IR node.
|
||||
*
|
||||
* @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"
|
||||
}
|
||||
}
|
||||
|
||||
/** Adds extension methods on strings to aid in writing custom to string
|
||||
* overrides.
|
||||
*
|
||||
* @param string the string to process
|
||||
*/
|
||||
implicit class ToStringHelper(string: String) {
|
||||
|
||||
/** Converts a multiline string to a single line
|
||||
*
|
||||
* @return [[string]], converted to a single line
|
||||
*/
|
||||
def toSingleLine: String = {
|
||||
val lines = string.stripMargin.split("\n").toList.filterNot(_ == "")
|
||||
|
||||
val body = lines.tail.dropRight(1).mkString(" ")
|
||||
|
||||
s"${lines.head}$body${lines.last}"
|
||||
}
|
||||
}
|
||||
|
||||
// ==========================================================================
|
||||
// === Useful Extension Methods =============================================
|
||||
// ==========================================================================
|
||||
|
||||
/** Adds extension methods for working directly with the diagnostics on the
|
||||
* IR.
|
||||
*
|
||||
* @param ir the IR to add the methods to
|
||||
* @tparam T the concrete type of the IR
|
||||
*/
|
||||
implicit class AsDiagnostics[T <: IR](ir: T) {
|
||||
|
||||
/** Adds a new diagnostic entity to [[IR]].
|
||||
*
|
||||
* @param diagnostic the diagnostic to add
|
||||
* @return [[ir]] with added diagnostics
|
||||
*/
|
||||
def addDiagnostic(diagnostic: Diagnostic): T = {
|
||||
ir.diagnostics.add(diagnostic)
|
||||
ir
|
||||
}
|
||||
}
|
||||
|
||||
/** Adds extension methods for working directly with the metadata on the IR.
|
||||
*
|
||||
* @param ir the IR to add the methods to
|
||||
* @tparam T the concrete type of the IR
|
||||
*/
|
||||
implicit class AsMetadata[T <: IR](ir: T) {
|
||||
|
||||
/** 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 updateMetadata[K <: ProcessingPass](
|
||||
metadataPair: MetadataPair[K]
|
||||
): T = {
|
||||
ir.passData.update(metadataPair)
|
||||
ir
|
||||
}
|
||||
|
||||
/** 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 getMetadata[K <: ProcessingPass](pass: K): Option[pass.Metadata] = {
|
||||
ir.passData.get(pass)
|
||||
}
|
||||
|
||||
/** 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
|
||||
*/
|
||||
@throws[CompilerError]
|
||||
def unsafeGetMetadata[K <: ProcessingPass](
|
||||
pass: ProcessingPass,
|
||||
msg: => String
|
||||
): pass.Metadata = {
|
||||
ir.passData.getUnsafe(pass)(msg)
|
||||
}
|
||||
}
|
||||
|
||||
/** Adds extension methods for working with lists of [[IR]].
|
||||
*
|
||||
* @param list the list
|
||||
* @tparam T the concrete IR type
|
||||
*/
|
||||
implicit class ListAsIr[T <: IR](list: List[T]) {
|
||||
|
||||
/** Calls [[IR.duplicate]] on the elements in [[list]].
|
||||
*
|
||||
* @param keepLocations whether or not locations should be kept in the
|
||||
* duplicated IR
|
||||
* @param keepMetadata whether or not the pass metadata should be kept in
|
||||
* the duplicated IR
|
||||
* @param keepDiagnostics whether or not the diagnostics should be kept in
|
||||
* the duplicated IR
|
||||
* @param keepIdentifiers whether or not the identifiers should be
|
||||
* regenerated in the duplicated IR
|
||||
* @return a duplicate of [[list]]
|
||||
*/
|
||||
def duplicate(
|
||||
keepLocations: Boolean = true,
|
||||
keepMetadata: Boolean = true,
|
||||
keepDiagnostics: Boolean = true,
|
||||
keepIdentifiers: Boolean = false
|
||||
): List[T] = {
|
||||
list
|
||||
.map(
|
||||
_.duplicate(
|
||||
keepLocations,
|
||||
keepMetadata,
|
||||
keepDiagnostics,
|
||||
keepIdentifiers
|
||||
)
|
||||
)
|
||||
.asInstanceOf[List[T]]
|
||||
}
|
||||
}
|
||||
|
||||
def fileLocationFromSection(
|
||||
loc: IdentifiedLocation,
|
||||
source: Source
|
||||
): String = {
|
||||
val section =
|
||||
source.createSection(loc.location.start, loc.location.length)
|
||||
val locStr =
|
||||
"" + section.getStartLine + ":" +
|
||||
section.getStartColumn + "-" +
|
||||
section.getEndLine + ":" +
|
||||
section.getEndColumn
|
||||
source.getName + "[" + locStr + "]"
|
||||
}
|
||||
}
|
@ -0,0 +1,152 @@
|
||||
package org.enso.compiler.core
|
||||
|
||||
import org.enso.compiler.core.ir.MetadataStorage.MetadataPair
|
||||
import org.enso.compiler.core.ir.{Diagnostic, ProcessingPass}
|
||||
|
||||
object Implicits {
|
||||
|
||||
/** This class adds an extension method to control how the pass data element
|
||||
* of the IR is printed.
|
||||
*
|
||||
* @param ir the IR to print the pass data for
|
||||
*/
|
||||
implicit class ShowPassData(ir: IR) {
|
||||
|
||||
/** Creates a string representation of the pass data for a given IR node.
|
||||
*
|
||||
* @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"
|
||||
}
|
||||
}
|
||||
|
||||
/** Adds extension methods on strings to aid in writing custom to string
|
||||
* overrides.
|
||||
*
|
||||
* @param string the string to process
|
||||
*/
|
||||
implicit class ToStringHelper(string: String) {
|
||||
|
||||
/** Converts a multiline string to a single line
|
||||
*
|
||||
* @return [[string]], converted to a single line
|
||||
*/
|
||||
def toSingleLine: String = {
|
||||
val lines = string.stripMargin.split("\n").toList.filterNot(_ == "")
|
||||
|
||||
val body = lines.tail.dropRight(1).mkString(" ")
|
||||
|
||||
s"${lines.head}$body${lines.last}"
|
||||
}
|
||||
}
|
||||
|
||||
/** Adds extension methods for working directly with the diagnostics on the
|
||||
* IR.
|
||||
*
|
||||
* @param ir the IR to add the methods to
|
||||
* @tparam T the concrete type of the IR
|
||||
*/
|
||||
implicit class AsDiagnostics[T <: IR](ir: T) {
|
||||
|
||||
/** Adds a new diagnostic entity to [[IR]].
|
||||
*
|
||||
* @param diagnostic the diagnostic to add
|
||||
* @return [[ir]] with added diagnostics
|
||||
*/
|
||||
def addDiagnostic(diagnostic: Diagnostic): T = {
|
||||
ir.diagnostics.add(diagnostic)
|
||||
ir
|
||||
}
|
||||
}
|
||||
|
||||
/** Adds extension methods for working directly with the metadata on the IR.
|
||||
*
|
||||
* @param ir the IR to add the methods to
|
||||
* @tparam T the concrete type of the IR
|
||||
*/
|
||||
implicit class AsMetadata[T <: IR](ir: T) {
|
||||
|
||||
/** 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 updateMetadata[K <: ProcessingPass](
|
||||
metadataPair: MetadataPair[K]
|
||||
): T = {
|
||||
ir.passData.update(metadataPair)
|
||||
ir
|
||||
}
|
||||
|
||||
/** 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 getMetadata[K <: ProcessingPass](pass: K): Option[pass.Metadata] = {
|
||||
ir.passData.get(pass)
|
||||
}
|
||||
|
||||
/** 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
|
||||
*/
|
||||
@throws[CompilerError]
|
||||
def unsafeGetMetadata[K <: ProcessingPass](
|
||||
pass: ProcessingPass,
|
||||
msg: => String
|
||||
): pass.Metadata = {
|
||||
ir.passData.getUnsafe(pass)(msg)
|
||||
}
|
||||
}
|
||||
|
||||
/** Adds extension methods for working with lists of [[IR]].
|
||||
*
|
||||
* @param list the list
|
||||
* @tparam T the concrete IR type
|
||||
*/
|
||||
implicit class ListAsIr[T <: IR](list: List[T]) {
|
||||
|
||||
/** Calls [[IR#duplicate]] on the elements in [[list]].
|
||||
*
|
||||
* @param keepLocations whether or not locations should be kept in the
|
||||
* duplicated IR
|
||||
* @param keepMetadata whether or not the pass metadata should be kept in
|
||||
* the duplicated IR
|
||||
* @param keepDiagnostics whether or not the diagnostics should be kept in
|
||||
* the duplicated IR
|
||||
* @param keepIdentifiers whether or not the identifiers should be
|
||||
* regenerated in the duplicated IR
|
||||
* @return a duplicate of [[list]]
|
||||
*/
|
||||
def duplicate(
|
||||
keepLocations: Boolean = true,
|
||||
keepMetadata: Boolean = true,
|
||||
keepDiagnostics: Boolean = true,
|
||||
keepIdentifiers: Boolean = false
|
||||
): List[T] = {
|
||||
list
|
||||
.map(
|
||||
_.duplicate(
|
||||
keepLocations,
|
||||
keepMetadata,
|
||||
keepDiagnostics,
|
||||
keepIdentifiers
|
||||
)
|
||||
)
|
||||
.asInstanceOf[List[T]]
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,10 @@
|
||||
package org.enso.compiler.core.ir
|
||||
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.IR.{randomId, Identifier, ToStringHelper}
|
||||
import org.enso.compiler.core.{IR, Identifier}
|
||||
import org.enso.compiler.core.IR.randomId
|
||||
import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper}
|
||||
|
||||
import java.util.UUID
|
||||
|
||||
/** Call-site arguments in Enso. */
|
||||
sealed trait CallArgument extends IR {
|
||||
@ -13,10 +16,9 @@ sealed trait CallArgument extends IR {
|
||||
val value: Expression
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): CallArgument
|
||||
|
||||
/** @inheritdoc */
|
||||
override def setLocation(location: Option[IdentifiedLocation]): CallArgument
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): CallArgument
|
||||
|
||||
/** @inheritdoc */
|
||||
override def duplicate(
|
||||
@ -43,12 +45,12 @@ object CallArgument {
|
||||
sealed case class Specified(
|
||||
override val name: Option[Name],
|
||||
override val value: Expression,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
location: Option[IdentifiedLocation],
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends CallArgument
|
||||
with IRKind.Primitive {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -68,7 +70,7 @@ object CallArgument {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Specified = {
|
||||
val res = Specified(
|
||||
name,
|
||||
@ -116,7 +118,9 @@ object CallArgument {
|
||||
): Specified = copy(location = location)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Specified = {
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Specified = {
|
||||
copy(name = name.map(n => n.mapExpressions(fn)), value = fn(value))
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,11 @@
|
||||
package org.enso.compiler.core.ir
|
||||
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.IR.{randomId, Identifier, ToStringHelper}
|
||||
import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper}
|
||||
import org.enso.compiler.core.{IR, Identifier}
|
||||
import org.enso.compiler.core.IR.randomId
|
||||
|
||||
import java.util.UUID
|
||||
import scala.jdk.FunctionConverters.enrichAsScalaFromFunction
|
||||
|
||||
/** Definition-site arguments in Enso. */
|
||||
sealed trait DefinitionArgument extends IR {
|
||||
@ -20,12 +24,7 @@ sealed trait DefinitionArgument extends IR {
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(
|
||||
fn: Expression => Expression
|
||||
): DefinitionArgument
|
||||
|
||||
/** @inheritdoc */
|
||||
override def setLocation(
|
||||
location: Option[IdentifiedLocation]
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): DefinitionArgument
|
||||
|
||||
/** @inheritdoc */
|
||||
@ -61,12 +60,12 @@ object DefinitionArgument {
|
||||
override val ascribedType: Option[Expression],
|
||||
override val defaultValue: Option[Expression],
|
||||
override val suspended: Boolean,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
location: Option[IdentifiedLocation],
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends DefinitionArgument
|
||||
with IRKind.Primitive {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -89,7 +88,7 @@ object DefinitionArgument {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Specified = {
|
||||
val res = Specified(
|
||||
name,
|
||||
@ -149,11 +148,13 @@ object DefinitionArgument {
|
||||
): Specified = copy(location = location)
|
||||
|
||||
/** @inheritdoc */
|
||||
def mapExpressions(fn: Expression => Expression): Specified = {
|
||||
def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Specified = {
|
||||
copy(
|
||||
name = name.mapExpressions(fn),
|
||||
ascribedType = ascribedType.map(fn),
|
||||
defaultValue = defaultValue.map(fn)
|
||||
ascribedType = ascribedType.map(fn.asScala),
|
||||
defaultValue = defaultValue.map(fn.asScala)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,11 @@
|
||||
package org.enso.compiler.core.ir
|
||||
|
||||
import com.oracle.truffle.api.source.Source
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.IR.{randomId, ToStringHelper}
|
||||
import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper}
|
||||
import org.enso.compiler.core.{IR, Identifier}
|
||||
import org.enso.compiler.core.IR.randomId
|
||||
|
||||
import java.util.UUID
|
||||
|
||||
/** A node representing an empty IR construct that can be used in any place.
|
||||
*
|
||||
@ -12,13 +15,13 @@ import org.enso.compiler.core.IR.{randomId, ToStringHelper}
|
||||
*/
|
||||
sealed case class Empty(
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends IR
|
||||
with Expression
|
||||
with Diagnostic
|
||||
with IRKind.Primitive {
|
||||
override protected var id: IR.Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`
|
||||
*
|
||||
@ -32,7 +35,7 @@ sealed case class Empty(
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: IR.Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Empty = {
|
||||
val res = Empty(location, passData, diagnostics)
|
||||
res.id = id
|
||||
@ -59,7 +62,9 @@ sealed case class Empty(
|
||||
copy(location = location)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Empty = this
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Empty = this
|
||||
|
||||
/** @inheritdoc */
|
||||
override def toString: String =
|
||||
|
@ -1,12 +1,12 @@
|
||||
package org.enso.compiler.core.ir
|
||||
|
||||
import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper}
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.IR.{
|
||||
indentLevel,
|
||||
mkIndent,
|
||||
randomId,
|
||||
ToStringHelper
|
||||
}
|
||||
import org.enso.compiler.core.Identifier
|
||||
import org.enso.compiler.core.IR.{indentLevel, mkIndent, randomId}
|
||||
|
||||
import java.util.UUID
|
||||
import scala.jdk.FunctionConverters.enrichAsScalaFromFunction
|
||||
|
||||
trait Expression extends IR {
|
||||
|
||||
@ -26,7 +26,9 @@ trait Expression extends IR {
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Expression
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Expression
|
||||
|
||||
/** @inheritdoc */
|
||||
override def setLocation(location: Option[IdentifiedLocation]): Expression
|
||||
@ -56,13 +58,13 @@ object Expression {
|
||||
sealed case class Block(
|
||||
expressions: List[Expression],
|
||||
returnValue: Expression,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
suspended: Boolean = false,
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
location: Option[IdentifiedLocation],
|
||||
suspended: Boolean = false,
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Expression
|
||||
with IRKind.Primitive {
|
||||
override protected var id: IR.Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -82,7 +84,7 @@ object Expression {
|
||||
suspended: Boolean = suspended,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: IR.Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Block = {
|
||||
val res = Block(
|
||||
expressions,
|
||||
@ -130,9 +132,11 @@ object Expression {
|
||||
copy(location = location)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Block = {
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Block = {
|
||||
copy(
|
||||
expressions = expressions.map(fn),
|
||||
expressions = expressions.map(fn.asScala),
|
||||
returnValue = fn(returnValue)
|
||||
)
|
||||
}
|
||||
@ -180,12 +184,13 @@ object Expression {
|
||||
sealed case class Binding(
|
||||
name: Name,
|
||||
expression: Expression,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
location: Option[IdentifiedLocation],
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Expression
|
||||
with IRKind.Primitive {
|
||||
override protected var id: IR.Identifier = randomId
|
||||
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -203,7 +208,7 @@ object Expression {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: IR.Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Binding = {
|
||||
val res = Binding(name, expression, location, passData, diagnostics)
|
||||
res.id = id
|
||||
@ -242,7 +247,9 @@ object Expression {
|
||||
copy(location = location)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Binding = {
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Binding = {
|
||||
copy(name = name.mapExpressions(fn), expression = fn(expression))
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,10 @@
|
||||
package org.enso.compiler.core.ir
|
||||
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.IR.{randomId, Identifier, ToStringHelper}
|
||||
import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper}
|
||||
import org.enso.compiler.core.{IR, Identifier}
|
||||
import org.enso.compiler.core.IR.randomId
|
||||
|
||||
import java.util.UUID
|
||||
|
||||
/** Functions in Enso. */
|
||||
sealed trait Function extends Expression {
|
||||
@ -23,19 +26,6 @@ sealed trait Function extends Expression {
|
||||
*/
|
||||
val canBeTCO: Boolean
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Function
|
||||
|
||||
/** @inheritdoc */
|
||||
override def setLocation(location: Option[IdentifiedLocation]): Function
|
||||
|
||||
/** @inheritdoc */
|
||||
override def duplicate(
|
||||
keepLocations: Boolean = true,
|
||||
keepMetadata: Boolean = true,
|
||||
keepDiagnostics: Boolean = true,
|
||||
keepIdentifiers: Boolean = false
|
||||
): Function
|
||||
}
|
||||
|
||||
object Function {
|
||||
@ -56,13 +46,13 @@ object Function {
|
||||
sealed case class Lambda(
|
||||
override val arguments: List[DefinitionArgument],
|
||||
override val body: Expression,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val canBeTCO: Boolean = true,
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
location: Option[IdentifiedLocation],
|
||||
override val canBeTCO: Boolean = true,
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Function
|
||||
with IRKind.Primitive {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -82,7 +72,7 @@ object Function {
|
||||
canBeTCO: Boolean = canBeTCO,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Lambda = {
|
||||
val res =
|
||||
Lambda(arguments, body, location, canBeTCO, passData, diagnostics)
|
||||
@ -124,7 +114,9 @@ object Function {
|
||||
copy(location = location)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Lambda = {
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Lambda = {
|
||||
copy(arguments = arguments.map(_.mapExpressions(fn)), body = fn(body))
|
||||
}
|
||||
|
||||
@ -172,13 +164,13 @@ object Function {
|
||||
name: Name,
|
||||
override val arguments: List[DefinitionArgument],
|
||||
override val body: Expression,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val canBeTCO: Boolean = true,
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
location: Option[IdentifiedLocation],
|
||||
override val canBeTCO: Boolean = true,
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Function
|
||||
with IRKind.Sugar {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -200,7 +192,7 @@ object Function {
|
||||
canBeTCO: Boolean = canBeTCO,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Binding = {
|
||||
val res =
|
||||
Binding(
|
||||
@ -256,7 +248,9 @@ object Function {
|
||||
copy(location = location)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Binding =
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Binding =
|
||||
copy(
|
||||
name = name.mapExpressions(fn),
|
||||
arguments = arguments.map(_.mapExpressions(fn)),
|
||||
|
@ -1,13 +1,18 @@
|
||||
package org.enso.compiler.core.ir
|
||||
|
||||
import org.enso.compiler.core.{CompilerError, IR}
|
||||
import org.enso.compiler.core.IR.{randomId, Identifier, ToStringHelper}
|
||||
import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper}
|
||||
import org.enso.compiler.core.{CompilerError, IR, Identifier}
|
||||
import org.enso.compiler.core.IR.randomId
|
||||
|
||||
import java.util.UUID
|
||||
|
||||
/** Enso literals. */
|
||||
sealed trait Literal extends Expression with IRKind.Primitive {
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Literal
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Literal
|
||||
|
||||
/** @inheritdoc */
|
||||
override def setLocation(location: Option[IdentifiedLocation]): Literal
|
||||
@ -34,11 +39,11 @@ object Literal {
|
||||
sealed case class Number(
|
||||
base: Option[String],
|
||||
value: String,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
location: Option[IdentifiedLocation],
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Literal {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -56,7 +61,7 @@ object Literal {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Number = {
|
||||
val res = Number(base, value, location, passData, diagnostics)
|
||||
res.id = id
|
||||
@ -83,7 +88,9 @@ object Literal {
|
||||
copy(location = location)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Number = this
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Number = this
|
||||
|
||||
/** @inheritdoc */
|
||||
override def toString: String =
|
||||
@ -158,11 +165,11 @@ object Literal {
|
||||
*/
|
||||
sealed case class Text(
|
||||
text: String,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
location: Option[IdentifiedLocation],
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Literal {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -178,7 +185,7 @@ object Literal {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Text = {
|
||||
val res = Text(text, location, passData, diagnostics)
|
||||
res.id = id
|
||||
@ -205,7 +212,9 @@ object Literal {
|
||||
copy(location = location)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Text = this
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Text = this
|
||||
|
||||
/** @inheritdoc */
|
||||
override def toString: String =
|
||||
|
@ -1,9 +1,12 @@
|
||||
package org.enso.compiler.core.ir
|
||||
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.IR.{randomId, Identifier, ToStringHelper}
|
||||
import org.enso.compiler.core.{IR, Identifier}
|
||||
import org.enso.compiler.core.IR.randomId
|
||||
import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper}
|
||||
import org.enso.compiler.core.ir.module.scope.{Definition, Export, Import}
|
||||
|
||||
import java.util.UUID
|
||||
|
||||
/** A representation of a top-level Enso module.
|
||||
*
|
||||
* Modules may only contain imports and top-level bindings, with no top-level
|
||||
@ -18,19 +21,19 @@ import org.enso.compiler.core.ir.module.scope.{Definition, Export, Import}
|
||||
* @param diagnostics compiler diagnostics for this node
|
||||
*/
|
||||
@SerialVersionUID(
|
||||
7833L // instrumentor
|
||||
8145L // Scala to Java
|
||||
) // prevents reading broken caches, see PR-3692 for details
|
||||
sealed case class Module(
|
||||
imports: List[Import],
|
||||
exports: List[Export],
|
||||
bindings: List[Definition],
|
||||
isPrivate: Boolean,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
location: Option[IdentifiedLocation],
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends IR
|
||||
with IRKind.Primitive {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -50,7 +53,7 @@ sealed case class Module(
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Module = {
|
||||
val res =
|
||||
Module(
|
||||
@ -102,7 +105,9 @@ sealed case class Module(
|
||||
copy(location = location)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Module = {
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Module = {
|
||||
copy(
|
||||
imports = imports.map(_.mapExpressions(fn)),
|
||||
exports = exports.map(_.mapExpressions(fn)),
|
||||
|
@ -1,15 +1,20 @@
|
||||
package org.enso.compiler.core.ir
|
||||
|
||||
import org.enso.compiler.core.{ConstantsNames, IR}
|
||||
import org.enso.compiler.core.IR.{randomId, Identifier, ToStringHelper}
|
||||
import org.enso.compiler.core.{ConstantsNames, IR, Identifier}
|
||||
import org.enso.compiler.core.IR.randomId
|
||||
import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper}
|
||||
import org.enso.syntax.text.Location
|
||||
|
||||
import java.util.UUID
|
||||
|
||||
/** Enso names. */
|
||||
trait Name extends Expression with IRKind.Primitive {
|
||||
val name: String
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Name
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Name
|
||||
|
||||
/** @inheritdoc */
|
||||
override def setLocation(location: Option[IdentifiedLocation]): Name
|
||||
@ -43,14 +48,14 @@ object Name {
|
||||
sealed case class MethodReference(
|
||||
typePointer: Option[Name],
|
||||
methodName: Name,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
location: Option[IdentifiedLocation],
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Name
|
||||
with IRKind.Sugar {
|
||||
|
||||
override val name: String = showCode()
|
||||
override protected var id: Identifier = randomId
|
||||
override val name: String = showCode()
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -68,7 +73,7 @@ object Name {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): MethodReference = {
|
||||
val res =
|
||||
MethodReference(
|
||||
@ -113,7 +118,7 @@ object Name {
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(
|
||||
fn: Expression => Expression
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): MethodReference =
|
||||
copy(
|
||||
typePointer = typePointer.map(_.mapExpressions(fn)),
|
||||
@ -203,15 +208,17 @@ object Name {
|
||||
*/
|
||||
sealed case class Qualified(
|
||||
parts: List[Name],
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
location: Option[IdentifiedLocation],
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Name
|
||||
with IRKind.Primitive {
|
||||
|
||||
override val name: String = parts.map(_.name).mkString(".")
|
||||
|
||||
override def mapExpressions(fn: Expression => Expression): Name = this
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Name = this
|
||||
|
||||
override def setLocation(location: Option[IdentifiedLocation]): Name =
|
||||
copy(location = location)
|
||||
@ -230,7 +237,7 @@ object Name {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Qualified = {
|
||||
val res =
|
||||
Qualified(
|
||||
@ -270,7 +277,7 @@ object Name {
|
||||
override def children: List[IR] = parts
|
||||
|
||||
/** @inheritdoc */
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** @inheritdoc */
|
||||
override def showCode(indent: Int): String = name
|
||||
@ -283,13 +290,13 @@ object Name {
|
||||
* @param diagnostics compiler diagnostics for this node
|
||||
*/
|
||||
sealed case class Blank(
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
location: Option[IdentifiedLocation],
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Name
|
||||
with IRKind.Sugar {
|
||||
override val name: String = "_"
|
||||
override protected var id: Identifier = randomId
|
||||
override val name: String = "_"
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -303,7 +310,7 @@ object Name {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Blank = {
|
||||
val res = Blank(location, passData, diagnostics)
|
||||
res.id = id
|
||||
@ -326,7 +333,9 @@ object Name {
|
||||
)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Blank =
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Blank =
|
||||
this
|
||||
|
||||
/** @inheritdoc */
|
||||
@ -353,13 +362,13 @@ object Name {
|
||||
|
||||
sealed case class Special(
|
||||
specialName: Special.Ident,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
location: Option[IdentifiedLocation],
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Name
|
||||
with IRKind.Sugar {
|
||||
override val name: String = s"<special::${specialName}>"
|
||||
override protected var id: Identifier = randomId
|
||||
override val name: String = s"<special::${specialName}>"
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -374,7 +383,7 @@ object Name {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Special = {
|
||||
val res = Special(specialName, location, passData, diagnostics)
|
||||
res.id = id
|
||||
@ -395,7 +404,9 @@ object Name {
|
||||
id = if (keepIdentifiers) id else randomId
|
||||
)
|
||||
|
||||
override def mapExpressions(fn: Expression => Expression): Special =
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Special =
|
||||
this
|
||||
|
||||
override def setLocation(location: Option[IdentifiedLocation]): Special =
|
||||
@ -443,12 +454,12 @@ object Name {
|
||||
sealed case class Literal(
|
||||
override val name: String,
|
||||
override val isMethod: Boolean,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
originalName: Option[Name] = None,
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
location: Option[IdentifiedLocation],
|
||||
originalName: Option[Name] = None,
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Name {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -468,7 +479,7 @@ object Name {
|
||||
originalName: Option[Name] = originalName,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Literal = {
|
||||
val res =
|
||||
Literal(name, isMethod, location, originalName, passData, diagnostics)
|
||||
@ -496,7 +507,9 @@ object Name {
|
||||
copy(location = location)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Literal = this
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Literal = this
|
||||
|
||||
/** @inheritdoc */
|
||||
override def toString: String =
|
||||
@ -522,7 +535,9 @@ object Name {
|
||||
sealed trait Annotation extends Name with module.scope.Definition {
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Annotation
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Annotation
|
||||
|
||||
/** @inheritdoc */
|
||||
override def setLocation(location: Option[IdentifiedLocation]): Annotation
|
||||
@ -545,12 +560,12 @@ object Name {
|
||||
*/
|
||||
sealed case class BuiltinAnnotation(
|
||||
override val name: String,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
location: Option[IdentifiedLocation],
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Annotation
|
||||
with IRKind.Primitive {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -566,7 +581,7 @@ object Name {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): BuiltinAnnotation = {
|
||||
val res = BuiltinAnnotation(name, location, passData, diagnostics)
|
||||
res.id = id
|
||||
@ -596,7 +611,7 @@ object Name {
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(
|
||||
fn: Expression => Expression
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): BuiltinAnnotation =
|
||||
this
|
||||
|
||||
@ -630,11 +645,11 @@ object Name {
|
||||
sealed case class GenericAnnotation(
|
||||
override val name: String,
|
||||
expression: Expression,
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
location: Option[IdentifiedLocation],
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Annotation {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -652,7 +667,7 @@ object Name {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): GenericAnnotation = {
|
||||
val res =
|
||||
GenericAnnotation(name, expression, location, passData, diagnostics)
|
||||
@ -683,7 +698,7 @@ object Name {
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(
|
||||
fn: Expression => Expression
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): GenericAnnotation =
|
||||
copy(expression = fn(expression))
|
||||
|
||||
@ -715,13 +730,13 @@ object Name {
|
||||
* @param diagnostics compiler diagnostics for this node
|
||||
*/
|
||||
sealed case class Self(
|
||||
override val location: Option[IdentifiedLocation],
|
||||
synthetic: Boolean = false,
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
location: Option[IdentifiedLocation],
|
||||
synthetic: Boolean = false,
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Name {
|
||||
override protected var id: Identifier = randomId
|
||||
override val name: String = ConstantsNames.SELF_ARGUMENT
|
||||
var id: UUID @Identifier = randomId
|
||||
override val name: String = ConstantsNames.SELF_ARGUMENT
|
||||
|
||||
/** Creates a copy of `self`.
|
||||
*
|
||||
@ -736,7 +751,7 @@ object Name {
|
||||
synthetic: Boolean = synthetic,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Self = {
|
||||
val res = Self(location, synthetic, passData, diagnostics)
|
||||
res.id = id
|
||||
@ -763,7 +778,9 @@ object Name {
|
||||
copy(location = location)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Self = this
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Self = this
|
||||
|
||||
/** @inheritdoc */
|
||||
override def toString: String =
|
||||
@ -791,12 +808,12 @@ object Name {
|
||||
* @param diagnostics compiler diagnostics for this node
|
||||
*/
|
||||
sealed case class SelfType(
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
location: Option[IdentifiedLocation],
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Name {
|
||||
override protected var id: Identifier = randomId
|
||||
override val name: String = ConstantsNames.SELF_TYPE_ARGUMENT
|
||||
var id: UUID @Identifier = randomId
|
||||
override val name: String = ConstantsNames.SELF_TYPE_ARGUMENT
|
||||
|
||||
/** Creates a copy of `Self`.
|
||||
*
|
||||
@ -810,7 +827,7 @@ object Name {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): SelfType = {
|
||||
val res = SelfType(location, passData, diagnostics)
|
||||
res.id = id
|
||||
@ -837,7 +854,9 @@ object Name {
|
||||
copy(location = location)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): SelfType = this
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): SelfType = this
|
||||
|
||||
/** @inheritdoc */
|
||||
override def toString: String =
|
||||
|
@ -1,15 +1,20 @@
|
||||
package org.enso.compiler.core.ir
|
||||
|
||||
import org.enso.compiler.core.{CompilerError, IR}
|
||||
import org.enso.compiler.core.ir.{Name => IRName, Literal => IRLiteral}
|
||||
import org.enso.compiler.core.{CompilerError, IR, Identifier}
|
||||
import org.enso.compiler.core.ir.{Literal => IRLiteral, Name => IRName}
|
||||
import org.enso.compiler.core.ir.expression.errors
|
||||
import org.enso.compiler.core.IR.{randomId, Identifier, ToStringHelper}
|
||||
import org.enso.compiler.core.IR.randomId
|
||||
import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper}
|
||||
|
||||
import java.util.UUID
|
||||
|
||||
/** The different types of patterns that can occur in a match. */
|
||||
trait Pattern extends IR {
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Pattern
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Pattern
|
||||
|
||||
/** @inheritdoc */
|
||||
override def setLocation(location: Option[IdentifiedLocation]): Pattern
|
||||
@ -42,7 +47,7 @@ object Pattern {
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Pattern {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -58,7 +63,7 @@ object Pattern {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Name = {
|
||||
val res = Name(name, location, passData, diagnostics)
|
||||
res.id = id
|
||||
@ -87,7 +92,9 @@ object Pattern {
|
||||
)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Name = {
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Name = {
|
||||
copy(name = name.mapExpressions(fn))
|
||||
}
|
||||
|
||||
@ -132,7 +139,7 @@ object Pattern {
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Pattern {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -150,7 +157,7 @@ object Pattern {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Constructor = {
|
||||
val res =
|
||||
Constructor(constructor, fields, location, passData, diagnostics)
|
||||
@ -229,7 +236,9 @@ object Pattern {
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Constructor =
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Constructor =
|
||||
copy(
|
||||
constructor = constructor.mapExpressions(fn),
|
||||
fields = fields.map(_.mapExpressions(fn))
|
||||
@ -280,7 +289,7 @@ object Pattern {
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Pattern {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -296,7 +305,7 @@ object Pattern {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Literal = {
|
||||
val res = Literal(literal, location, passData, diagnostics)
|
||||
res.id = id
|
||||
@ -325,7 +334,9 @@ object Pattern {
|
||||
)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Literal = {
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Literal = {
|
||||
copy(literal = literal.mapExpressions(fn))
|
||||
}
|
||||
|
||||
@ -372,7 +383,7 @@ object Pattern {
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Pattern {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -390,7 +401,7 @@ object Pattern {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Type = {
|
||||
val res = Type(name, tpe, location, passData, diagnostics)
|
||||
res.id = id
|
||||
@ -425,7 +436,9 @@ object Pattern {
|
||||
)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Type = {
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Type = {
|
||||
copy(name = name.mapExpressions(fn), tpe = tpe.mapExpressions(fn))
|
||||
}
|
||||
|
||||
@ -472,10 +485,12 @@ object Pattern {
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Pattern {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Documentation =
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Documentation =
|
||||
this
|
||||
|
||||
/** @inheritdoc */
|
||||
@ -498,7 +513,7 @@ object Pattern {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Documentation = {
|
||||
val res = Documentation(doc, location, passData, diagnostics)
|
||||
res.id = id
|
||||
|
@ -1,13 +1,19 @@
|
||||
package org.enso.compiler.core.ir
|
||||
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.IR.{randomId, Identifier, ToStringHelper}
|
||||
import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper}
|
||||
import org.enso.compiler.core.{IR, Identifier}
|
||||
import org.enso.compiler.core.IR.randomId
|
||||
|
||||
import java.util.UUID
|
||||
import scala.jdk.FunctionConverters.enrichAsScalaFromFunction
|
||||
|
||||
/** Constructs that operate on types. */
|
||||
trait Type extends Expression {
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Type
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Type
|
||||
|
||||
/** @inheritdoc */
|
||||
override def setLocation(location: Option[IdentifiedLocation]): Type
|
||||
@ -35,7 +41,7 @@ object Type {
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Type {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
def copy(
|
||||
args: List[Expression] = args,
|
||||
@ -43,7 +49,7 @@ object Type {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Function = {
|
||||
val res = Function(args, result, location, passData, diagnostics)
|
||||
res.id = id
|
||||
@ -85,8 +91,10 @@ object Type {
|
||||
): Function = copy(location = location)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Function = {
|
||||
copy(args = args.map(fn), result = fn(result))
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Function = {
|
||||
copy(args = args.map(fn.asScala), result = fn(result))
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@ -126,7 +134,7 @@ object Type {
|
||||
) extends Type
|
||||
with module.scope.Definition
|
||||
with IRKind.Primitive {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -144,7 +152,7 @@ object Type {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Ascription = {
|
||||
val res = Ascription(typed, signature, location, passData, diagnostics)
|
||||
res.id = id
|
||||
@ -184,7 +192,9 @@ object Type {
|
||||
): Ascription = copy(location = location)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Ascription = {
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Ascription = {
|
||||
copy(typed = fn(typed), signature = fn(signature))
|
||||
}
|
||||
|
||||
@ -229,7 +239,7 @@ object Type {
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Type
|
||||
with IRKind.Primitive {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates ac opy of `this`.
|
||||
*
|
||||
@ -247,7 +257,7 @@ object Type {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Context = {
|
||||
val res = Context(typed, context, location, passData, diagnostics)
|
||||
res.id = id
|
||||
@ -286,7 +296,9 @@ object Type {
|
||||
copy(location = location)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Context = {
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Context = {
|
||||
copy(typed = fn(typed), context = fn(context))
|
||||
}
|
||||
|
||||
@ -330,7 +342,7 @@ object Type {
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Type
|
||||
with IRKind.Primitive {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -348,7 +360,7 @@ object Type {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Error = {
|
||||
val res = Error(typed, error, location, passData, diagnostics)
|
||||
res.id = id
|
||||
@ -387,7 +399,9 @@ object Type {
|
||||
copy(location = location)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Error =
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Error =
|
||||
copy(typed = fn(typed), error = fn(error))
|
||||
|
||||
/** @inheritdoc */
|
||||
|
@ -1,26 +1,15 @@
|
||||
package org.enso.compiler.core.ir
|
||||
package expression
|
||||
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.IR.{randomId, Identifier, ToStringHelper}
|
||||
import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper}
|
||||
import org.enso.compiler.core.{IR, Identifier}
|
||||
import org.enso.compiler.core.IR.randomId
|
||||
|
||||
import java.util.UUID
|
||||
import scala.jdk.FunctionConverters.enrichAsScalaFromFunction
|
||||
|
||||
/** All function applications in Enso. */
|
||||
trait Application extends Expression {
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Application
|
||||
|
||||
/** @inheritdoc */
|
||||
override def setLocation(location: Option[IdentifiedLocation]): Application
|
||||
|
||||
/** @inheritdoc */
|
||||
override def duplicate(
|
||||
keepLocations: Boolean = true,
|
||||
keepMetadata: Boolean = true,
|
||||
keepDiagnostics: Boolean = true,
|
||||
keepIdentifiers: Boolean = false
|
||||
): Application
|
||||
}
|
||||
trait Application extends Expression
|
||||
|
||||
object Application {
|
||||
|
||||
@ -43,7 +32,7 @@ object Application {
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Application
|
||||
with IRKind.Primitive {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -64,7 +53,7 @@ object Application {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Prefix = {
|
||||
val res =
|
||||
Prefix(
|
||||
@ -113,7 +102,9 @@ object Application {
|
||||
copy(location = location)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Prefix = {
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Prefix = {
|
||||
copy(function = fn(function), arguments.map(_.mapExpressions(fn)))
|
||||
}
|
||||
|
||||
@ -156,7 +147,7 @@ object Application {
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Application
|
||||
with IRKind.Primitive {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -172,7 +163,7 @@ object Application {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Force = {
|
||||
val res = Force(target, location, passData, diagnostics)
|
||||
res.id = id
|
||||
@ -205,7 +196,9 @@ object Application {
|
||||
copy(location = location)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Force = {
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Force = {
|
||||
copy(target = fn(target))
|
||||
}
|
||||
|
||||
@ -233,7 +226,9 @@ object Application {
|
||||
sealed trait Literal extends Application {
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Literal
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Literal
|
||||
|
||||
/** @inheritdoc */
|
||||
override def setLocation(location: Option[IdentifiedLocation]): Literal
|
||||
@ -263,10 +258,12 @@ object Application {
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Literal
|
||||
with IRKind.Primitive {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
override def mapExpressions(fn: Expression => Expression): Typeset =
|
||||
copy(expression = expression.map(fn))
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Typeset =
|
||||
copy(expression = expression.map(fn.asScala))
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -282,7 +279,7 @@ object Application {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Typeset = {
|
||||
val res = Typeset(expression, location, passData, diagnostics)
|
||||
res.id = id
|
||||
@ -356,10 +353,12 @@ object Application {
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Literal
|
||||
with IRKind.Primitive {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
override def mapExpressions(fn: Expression => Expression): Sequence =
|
||||
copy(items = items.map(fn))
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Sequence =
|
||||
copy(items = items.map(fn.asScala))
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -375,7 +374,7 @@ object Application {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Sequence = {
|
||||
val res = Sequence(items, location, passData, diagnostics)
|
||||
res.id = id
|
||||
|
@ -1,20 +1,19 @@
|
||||
package org.enso.compiler.core.ir
|
||||
package expression
|
||||
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.IR.{
|
||||
indentLevel,
|
||||
mkIndent,
|
||||
randomId,
|
||||
Identifier,
|
||||
ToStringHelper
|
||||
}
|
||||
import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper}
|
||||
import org.enso.compiler.core.{IR, Identifier}
|
||||
import org.enso.compiler.core.IR.{indentLevel, mkIndent, randomId}
|
||||
|
||||
import java.util.UUID
|
||||
|
||||
/** The Enso case expression. */
|
||||
sealed trait Case extends Expression {
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Case
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Case
|
||||
|
||||
/** @inheritdoc */
|
||||
override def setLocation(location: Option[IdentifiedLocation]): Case
|
||||
@ -48,7 +47,7 @@ object Case {
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Case
|
||||
with IRKind.Primitive {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
def this(
|
||||
scrutinee: Expression,
|
||||
@ -78,7 +77,7 @@ object Case {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Expr = {
|
||||
val res =
|
||||
Expr(scrutinee, branches, isNested, location, passData, diagnostics)
|
||||
@ -121,7 +120,9 @@ object Case {
|
||||
copy(location = location)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Expr = {
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Expr = {
|
||||
copy(
|
||||
scrutinee = fn(scrutinee),
|
||||
branches.map(_.mapExpressions(fn))
|
||||
@ -198,7 +199,7 @@ object Case {
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Case
|
||||
with IRKind.Primitive {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
def this(
|
||||
pattern: Pattern,
|
||||
@ -227,7 +228,7 @@ object Case {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Branch = {
|
||||
val res = Branch(
|
||||
pattern,
|
||||
@ -274,7 +275,9 @@ object Case {
|
||||
copy(location = location)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Branch = {
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Branch = {
|
||||
copy(pattern = pattern.mapExpressions(fn), expression = fn(expression))
|
||||
}
|
||||
|
||||
|
@ -1,14 +1,19 @@
|
||||
package org.enso.compiler.core.ir
|
||||
package expression
|
||||
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.IR.{randomId, Identifier, ToStringHelper}
|
||||
import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper}
|
||||
import org.enso.compiler.core.{IR, Identifier}
|
||||
import org.enso.compiler.core.IR.randomId
|
||||
|
||||
import java.util.UUID
|
||||
|
||||
/** Enso comment entities. */
|
||||
sealed trait Comment extends Expression with module.scope.Definition {
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Comment
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Comment
|
||||
|
||||
/** @inheritdoc */
|
||||
override def setLocation(location: Option[IdentifiedLocation]): Comment
|
||||
@ -38,7 +43,7 @@ object Comment {
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Comment
|
||||
with IRKind.Primitive {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -54,7 +59,7 @@ object Comment {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Documentation = {
|
||||
val res = Documentation(doc, location, passData, diagnostics)
|
||||
res.id = id
|
||||
@ -83,7 +88,7 @@ object Comment {
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(
|
||||
fn: Expression => Expression
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Documentation = this
|
||||
|
||||
/** @inheritdoc */
|
||||
|
@ -2,15 +2,20 @@ package org.enso.compiler.core.ir
|
||||
package expression
|
||||
|
||||
import com.oracle.truffle.api.source.Source
|
||||
import org.enso.compiler.core.IR.{randomId, Identifier, ToStringHelper}
|
||||
import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper}
|
||||
import org.enso.compiler.core.IR.randomId
|
||||
import org.enso.compiler.core.ir.Expression
|
||||
import org.enso.compiler.core.{ir, IR}
|
||||
import org.enso.compiler.core.{ir, IR, Identifier}
|
||||
|
||||
import java.util.UUID
|
||||
|
||||
/** A trait for all errors in Enso's IR. */
|
||||
trait Error extends Expression with ir.module.scope.Definition with Diagnostic {
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Error
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Error
|
||||
|
||||
/** @inheritdoc */
|
||||
override def setLocation(location: Option[IdentifiedLocation]): Error
|
||||
@ -39,7 +44,7 @@ object Error {
|
||||
) extends Error
|
||||
with Diagnostic.Kind.Static
|
||||
with IRKind.Primitive {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -53,7 +58,7 @@ object Error {
|
||||
ir: IR = ir,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): InvalidIR = {
|
||||
val res = InvalidIR(ir, passData, diagnostics)
|
||||
res.id = id
|
||||
@ -89,7 +94,9 @@ object Error {
|
||||
override val location: Option[IdentifiedLocation] = ir.location
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): InvalidIR =
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): InvalidIR =
|
||||
this
|
||||
|
||||
/** @inheritdoc */
|
||||
|
@ -1,17 +1,22 @@
|
||||
package org.enso.compiler.core.ir
|
||||
package expression
|
||||
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.IR.{randomId, Identifier, ToStringHelper}
|
||||
import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper}
|
||||
import org.enso.compiler.core.{IR, Identifier}
|
||||
import org.enso.compiler.core.IR.randomId
|
||||
import org.enso.compiler.core.ir.MetadataStorage
|
||||
|
||||
import java.util.UUID
|
||||
|
||||
// === Foreign ==============================================================
|
||||
|
||||
/** Foreign code entities. */
|
||||
sealed trait Foreign extends Expression {
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Foreign
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Foreign
|
||||
|
||||
/** @inheritdoc */
|
||||
override def setLocation(location: Option[IdentifiedLocation]): Foreign
|
||||
@ -43,7 +48,7 @@ object Foreign {
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Foreign
|
||||
with IRKind.Primitive {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -61,7 +66,7 @@ object Foreign {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Definition = {
|
||||
val res = Definition(lang, code, location, passData, diagnostics)
|
||||
res.id = id
|
||||
@ -89,7 +94,9 @@ object Foreign {
|
||||
): Definition = copy(location = location)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Definition =
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Definition =
|
||||
this
|
||||
|
||||
/** @inheritdoc */
|
||||
|
@ -1,14 +1,19 @@
|
||||
package org.enso.compiler.core.ir
|
||||
package expression
|
||||
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.IR.{randomId, Identifier, ToStringHelper};
|
||||
import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper}
|
||||
import org.enso.compiler.core.{IR, Identifier}
|
||||
import org.enso.compiler.core.IR.randomId
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/** Operator applications in Enso. */
|
||||
trait Operator extends Application {
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Operator
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Operator
|
||||
|
||||
/** @inheritdoc */
|
||||
override def setLocation(location: Option[IdentifiedLocation]): Operator
|
||||
@ -42,7 +47,7 @@ object Operator {
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Operator
|
||||
with IRKind.Sugar {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -62,7 +67,7 @@ object Operator {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Binary = {
|
||||
val res =
|
||||
Binary(left, operator, right, location, passData, diagnostics)
|
||||
@ -108,7 +113,9 @@ object Operator {
|
||||
copy(location = location)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Binary = {
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Binary = {
|
||||
copy(left = left.mapExpressions(fn), right = right.mapExpressions(fn))
|
||||
}
|
||||
|
||||
|
@ -1,14 +1,19 @@
|
||||
package org.enso.compiler.core.ir
|
||||
package expression
|
||||
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.IR.{randomId, Identifier, ToStringHelper}
|
||||
import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper}
|
||||
import org.enso.compiler.core.{IR, Identifier}
|
||||
import org.enso.compiler.core.IR.randomId
|
||||
|
||||
import java.util.UUID
|
||||
|
||||
/** Operator sections. */
|
||||
sealed trait Section extends Operator {
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Section
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Section
|
||||
|
||||
/** @inheritdoc */
|
||||
override def setLocation(location: Option[IdentifiedLocation]): Section
|
||||
@ -40,7 +45,7 @@ object Section {
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Section
|
||||
with IRKind.Sugar {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -58,7 +63,7 @@ object Section {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: IR.Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Left = {
|
||||
val res = Left(arg, operator, location, passData, diagnostics)
|
||||
res.id = id
|
||||
@ -98,7 +103,9 @@ object Section {
|
||||
copy(location = location)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Section =
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Section =
|
||||
copy(
|
||||
arg = arg.mapExpressions(fn),
|
||||
operator = operator.mapExpressions(fn)
|
||||
@ -139,7 +146,7 @@ object Section {
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Section
|
||||
with IRKind.Sugar {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -155,7 +162,7 @@ object Section {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Sides = {
|
||||
val res = Sides(operator, location, passData, diagnostics)
|
||||
res.id = id
|
||||
@ -190,7 +197,9 @@ object Section {
|
||||
): Sides = copy(location = location)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Section =
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Section =
|
||||
copy(operator = operator.mapExpressions(fn))
|
||||
|
||||
/** @inheritdoc */
|
||||
@ -229,7 +238,7 @@ object Section {
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Section
|
||||
with IRKind.Sugar {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -247,7 +256,7 @@ object Section {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Right = {
|
||||
val res = Right(operator, arg, location, passData, diagnostics)
|
||||
res.id = id
|
||||
@ -288,7 +297,9 @@ object Section {
|
||||
): Right = copy(location = location)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Section = {
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Section = {
|
||||
copy(
|
||||
operator = operator.mapExpressions(fn),
|
||||
arg = arg.mapExpressions(fn)
|
||||
|
@ -3,8 +3,10 @@ package expression
|
||||
package errors
|
||||
|
||||
import com.oracle.truffle.api.source.Source
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.IR.{randomId, Identifier}
|
||||
import org.enso.compiler.core.{IR, Identifier}
|
||||
import org.enso.compiler.core.IR.randomId
|
||||
|
||||
import java.util.UUID
|
||||
|
||||
/** An error resulting from processing conversion methods.
|
||||
*
|
||||
@ -24,7 +26,9 @@ sealed case class Conversion(
|
||||
with Name {
|
||||
override val name: String = "conversion_error"
|
||||
|
||||
override def mapExpressions(fn: Expression => Expression): Conversion =
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Conversion =
|
||||
this
|
||||
|
||||
override def setLocation(
|
||||
@ -47,7 +51,7 @@ sealed case class Conversion(
|
||||
reason: Conversion.Reason = reason,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Conversion = {
|
||||
val res = Conversion(storedIr, reason, passData, diagnostics)
|
||||
res.id = id
|
||||
@ -79,7 +83,7 @@ sealed case class Conversion(
|
||||
override def children: List[IR] = List(storedIr)
|
||||
|
||||
/** @inheritdoc */
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** @inheritdoc */
|
||||
override def showCode(indent: Int): String =
|
||||
|
@ -3,14 +3,11 @@ package expression
|
||||
package errors
|
||||
|
||||
import com.oracle.truffle.api.source.Source
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.IR.{
|
||||
fileLocationFromSection,
|
||||
randomId,
|
||||
Identifier,
|
||||
ToStringHelper
|
||||
}
|
||||
import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper}
|
||||
import org.enso.compiler.core.{IR, Identifier}
|
||||
import org.enso.compiler.core.IR.{fileLocationFromSection, randomId}
|
||||
|
||||
import java.util.UUID
|
||||
import scala.annotation.unused
|
||||
|
||||
/** An erroneous import or export statement.
|
||||
@ -30,7 +27,7 @@ sealed case class ImportExport(
|
||||
with org.enso.compiler.core.ir.module.scope.Import
|
||||
with org.enso.compiler.core.ir.module.scope.Export
|
||||
with IRKind.Primitive {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -46,7 +43,7 @@ sealed case class ImportExport(
|
||||
reason: ImportExport.Reason = reason,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): ImportExport = {
|
||||
val res = ImportExport(ir, reason, passData, diagnostics)
|
||||
res.id = id
|
||||
@ -77,7 +74,9 @@ sealed case class ImportExport(
|
||||
override val location: Option[IdentifiedLocation] = ir.location
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): ImportExport =
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): ImportExport =
|
||||
this
|
||||
|
||||
/** @inheritdoc */
|
||||
|
@ -3,8 +3,10 @@ package expression
|
||||
package errors
|
||||
|
||||
import com.oracle.truffle.api.source.Source
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.IR.{randomId, Identifier}
|
||||
import org.enso.compiler.core.{IR, Identifier}
|
||||
import org.enso.compiler.core.IR.randomId
|
||||
|
||||
import java.util.UUID
|
||||
|
||||
/** A representation of an error resulting from wrong pattern matches.
|
||||
*
|
||||
@ -17,12 +19,14 @@ import org.enso.compiler.core.IR.{randomId, Identifier}
|
||||
sealed case class Pattern(
|
||||
originalPattern: org.enso.compiler.core.ir.Pattern,
|
||||
reason: Pattern.Reason,
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Error
|
||||
with Diagnostic.Kind.Interactive
|
||||
with org.enso.compiler.core.ir.Pattern {
|
||||
override def mapExpressions(fn: Expression => Expression): Pattern =
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Pattern =
|
||||
copy(originalPattern = originalPattern.mapExpressions(fn))
|
||||
|
||||
override def setLocation(location: Option[IdentifiedLocation]): Pattern =
|
||||
@ -42,7 +46,7 @@ sealed case class Pattern(
|
||||
reason: Pattern.Reason = reason,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Pattern = {
|
||||
val res = Pattern(originalPattern, reason, passData, diagnostics)
|
||||
res.id = id
|
||||
@ -79,7 +83,7 @@ sealed case class Pattern(
|
||||
|
||||
override def children: List[IR] = List(originalPattern)
|
||||
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
override def showCode(indent: Int): String =
|
||||
originalPattern.showCode(indent)
|
||||
|
@ -3,8 +3,11 @@ package expression
|
||||
package errors
|
||||
|
||||
import com.oracle.truffle.api.source.Source
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.IR.{randomId, Identifier}
|
||||
import org.enso.compiler.core.Implicits.ShowPassData
|
||||
import org.enso.compiler.core.{IR, Identifier}
|
||||
import org.enso.compiler.core.IR.randomId
|
||||
|
||||
import java.util.UUID
|
||||
|
||||
/** Errors pertaining to the redefinition of language constructs that are
|
||||
* not allowed to be.
|
||||
@ -12,7 +15,9 @@ import org.enso.compiler.core.IR.{randomId, Identifier}
|
||||
sealed trait Redefined extends Error {
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Redefined
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Redefined
|
||||
|
||||
/** @inheritdoc */
|
||||
override def setLocation(location: Option[IdentifiedLocation]): Redefined
|
||||
@ -42,7 +47,7 @@ object Redefined {
|
||||
) extends Redefined
|
||||
with Diagnostic.Kind.Interactive
|
||||
with IRKind.Primitive {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `self`.
|
||||
*
|
||||
@ -56,7 +61,7 @@ object Redefined {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): SelfArg = {
|
||||
val res = SelfArg(location, passData, diagnostics)
|
||||
res.id = id
|
||||
@ -84,7 +89,9 @@ object Redefined {
|
||||
): SelfArg = copy(location = location)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): SelfArg =
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): SelfArg =
|
||||
this
|
||||
|
||||
/** @inheritdoc */
|
||||
@ -122,7 +129,7 @@ object Redefined {
|
||||
with Diagnostic.Kind.Interactive
|
||||
with module.scope.Definition
|
||||
with IRKind.Primitive {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -142,7 +149,7 @@ object Redefined {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Conversion = {
|
||||
val res =
|
||||
Conversion(targetType, sourceType, location, passData, diagnostics)
|
||||
@ -197,7 +204,9 @@ object Redefined {
|
||||
.toArray
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Conversion =
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Conversion =
|
||||
this
|
||||
|
||||
/** @inheritdoc */
|
||||
@ -244,7 +253,7 @@ object Redefined {
|
||||
with Diagnostic.Kind.Interactive
|
||||
with module.scope.Definition
|
||||
with IRKind.Primitive {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -263,7 +272,7 @@ object Redefined {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Method = {
|
||||
val res =
|
||||
Method(atomName, methodName, location, passData, diagnostics)
|
||||
@ -318,7 +327,9 @@ object Redefined {
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Method = this
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Method = this
|
||||
|
||||
/** @inheritdoc */
|
||||
override def toString: String =
|
||||
@ -365,7 +376,7 @@ object Redefined {
|
||||
with Diagnostic.Kind.Interactive
|
||||
with module.scope.Definition
|
||||
with IRKind.Primitive {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -384,7 +395,7 @@ object Redefined {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): MethodClashWithAtom = {
|
||||
val res = MethodClashWithAtom(
|
||||
atomName,
|
||||
@ -441,7 +452,7 @@ object Redefined {
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(
|
||||
fn: Expression => Expression
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): MethodClashWithAtom =
|
||||
this
|
||||
|
||||
@ -483,7 +494,7 @@ object Redefined {
|
||||
with Diagnostic.Kind.Interactive
|
||||
with module.scope.Definition
|
||||
with IRKind.Primitive {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -501,7 +512,7 @@ object Redefined {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Type = {
|
||||
val res =
|
||||
Type(atomName, location, passData, diagnostics)
|
||||
@ -542,7 +553,9 @@ object Redefined {
|
||||
override def diagnosticKeys(): Array[Any] = Array(typeName.name)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Type = this
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Type = this
|
||||
|
||||
/** @inheritdoc */
|
||||
override def toString: String =
|
||||
@ -580,7 +593,7 @@ object Redefined {
|
||||
) extends Redefined
|
||||
with Diagnostic.Kind.Interactive
|
||||
with IRKind.Primitive {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -594,7 +607,7 @@ object Redefined {
|
||||
invalidBinding: Expression.Binding = invalidBinding,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Binding = {
|
||||
val res = Binding(invalidBinding, passData, diagnostics)
|
||||
res.id = id
|
||||
@ -632,7 +645,9 @@ object Redefined {
|
||||
invalidBinding.location
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Binding =
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Binding =
|
||||
this
|
||||
|
||||
/** @inheritdoc */
|
||||
|
@ -3,8 +3,10 @@ package expression
|
||||
package errors
|
||||
|
||||
import com.oracle.truffle.api.source.Source
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.IR.{randomId, Identifier}
|
||||
import org.enso.compiler.core.{IR, Identifier}
|
||||
import org.enso.compiler.core.IR.randomId
|
||||
|
||||
import java.util.UUID
|
||||
|
||||
/** A representation of an error resulting from name resolution.
|
||||
*
|
||||
@ -16,15 +18,17 @@ import org.enso.compiler.core.IR.{randomId, Identifier}
|
||||
sealed case class Resolution(
|
||||
originalName: Name,
|
||||
reason: Resolution.Reason,
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Error
|
||||
with Diagnostic.Kind.Interactive
|
||||
with IRKind.Primitive
|
||||
with Name {
|
||||
override val name: String = originalName.name
|
||||
|
||||
override def mapExpressions(fn: Expression => Expression): Resolution =
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Resolution =
|
||||
this
|
||||
|
||||
override def setLocation(
|
||||
@ -46,7 +50,7 @@ sealed case class Resolution(
|
||||
reason: Resolution.Reason = reason,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Resolution = {
|
||||
val res = Resolution(originalName, reason, passData, diagnostics)
|
||||
res.id = id
|
||||
@ -78,7 +82,7 @@ sealed case class Resolution(
|
||||
override def children: List[IR] = List(originalName)
|
||||
|
||||
/** @inheritdoc */
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** @inheritdoc */
|
||||
override def showCode(indent: Int): String = originalName.showCode(indent)
|
||||
|
@ -3,9 +3,11 @@ package expression
|
||||
package errors
|
||||
|
||||
import com.oracle.truffle.api.source.Source
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.IR.{randomId, Identifier, ToStringHelper}
|
||||
import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper}
|
||||
import org.enso.compiler.core.{IR, Identifier}
|
||||
import org.enso.compiler.core.IR.randomId
|
||||
|
||||
import java.util.UUID
|
||||
import scala.annotation.unused
|
||||
|
||||
/** A representation of an Enso syntax error.
|
||||
@ -18,15 +20,15 @@ import scala.annotation.unused
|
||||
sealed case class Syntax(
|
||||
at: IdentifiedLocation,
|
||||
reason: Syntax.Reason,
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Error
|
||||
with Diagnostic.Kind.Interactive
|
||||
with module.scope.Definition
|
||||
with module.scope.Export
|
||||
with module.scope.Import
|
||||
with IRKind.Primitive {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -42,7 +44,7 @@ sealed case class Syntax(
|
||||
reason: Syntax.Reason = reason,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Syntax = {
|
||||
val res = Syntax(at, reason, passData, diagnostics)
|
||||
res.id = id
|
||||
@ -71,7 +73,9 @@ sealed case class Syntax(
|
||||
override val location: Option[IdentifiedLocation] = Option(at)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Syntax = this
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Syntax = this
|
||||
|
||||
/** @inheritdoc */
|
||||
override def toString: String =
|
||||
|
@ -3,8 +3,10 @@ package expression
|
||||
package errors
|
||||
|
||||
import com.oracle.truffle.api.source.Source
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.IR.{randomId, Identifier}
|
||||
import org.enso.compiler.core.{IR, Identifier}
|
||||
import org.enso.compiler.core.IR.randomId
|
||||
|
||||
import java.util.UUID
|
||||
|
||||
/** A trait for errors about unexpected language constructs. */
|
||||
sealed trait Unexpected extends Error {
|
||||
@ -24,7 +26,9 @@ sealed trait Unexpected extends Error {
|
||||
override def diagnosticKeys(): Array[Any] = Array(entity)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Unexpected
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Unexpected
|
||||
|
||||
/** @inheritdoc */
|
||||
override def setLocation(location: Option[IdentifiedLocation]): Unexpected
|
||||
@ -49,14 +53,14 @@ object Unexpected {
|
||||
*/
|
||||
sealed case class TypeSignature(
|
||||
override val ir: IR,
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Unexpected
|
||||
with IRKind.Primitive
|
||||
with org.enso.compiler.core.ir.module.scope.Definition {
|
||||
override val entity: String = "type signature"
|
||||
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -70,7 +74,7 @@ object Unexpected {
|
||||
ir: IR = ir,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): TypeSignature = {
|
||||
val res = TypeSignature(ir, passData, diagnostics)
|
||||
res.id = id
|
||||
@ -79,7 +83,7 @@ object Unexpected {
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(
|
||||
fn: Expression => Expression
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): TypeSignature = this
|
||||
|
||||
/** @inheritdoc */
|
||||
|
@ -9,7 +9,9 @@ import org.enso.compiler.core.ir.{Expression, IdentifiedLocation}
|
||||
trait Scope extends IR {
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Scope
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Scope
|
||||
|
||||
/** @inheritdoc */
|
||||
override def setLocation(location: Option[IdentifiedLocation]): Scope
|
||||
|
@ -1,6 +1,6 @@
|
||||
package org.enso.compiler.core.ir.module.scope
|
||||
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.{IR, Identifier}
|
||||
import org.enso.compiler.core.ir.{
|
||||
DefinitionArgument,
|
||||
DiagnosticStorage,
|
||||
@ -11,19 +11,18 @@ import org.enso.compiler.core.ir.{
|
||||
Name
|
||||
}
|
||||
import org.enso.compiler.core.ir.module.Scope
|
||||
import org.enso.compiler.core.IR.{
|
||||
indentLevel,
|
||||
mkIndent,
|
||||
randomId,
|
||||
Identifier,
|
||||
ToStringHelper
|
||||
}
|
||||
import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper}
|
||||
import org.enso.compiler.core.IR.{indentLevel, mkIndent, randomId}
|
||||
|
||||
import java.util.UUID
|
||||
|
||||
/** A representation of top-level definitions. */
|
||||
trait Definition extends Scope {
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Definition
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Definition
|
||||
|
||||
/** @inheritdoc */
|
||||
override def setLocation(
|
||||
@ -57,12 +56,12 @@ object Definition {
|
||||
name: Name,
|
||||
params: List[DefinitionArgument],
|
||||
members: List[Data],
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
location: Option[IdentifiedLocation],
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Definition
|
||||
with IRKind.Primitive {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
def copy(
|
||||
name: Name = name,
|
||||
@ -71,7 +70,7 @@ object Definition {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Type = {
|
||||
val res =
|
||||
Type(name, params, members, location, passData, diagnostics)
|
||||
@ -115,7 +114,9 @@ object Definition {
|
||||
copy(location = location)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Type =
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Type =
|
||||
copy(
|
||||
params = params.map(_.mapExpressions(fn)),
|
||||
members = members.map(_.mapExpressions(fn))
|
||||
@ -159,12 +160,12 @@ object Definition {
|
||||
name: Name,
|
||||
arguments: List[DefinitionArgument],
|
||||
annotations: List[Name.GenericAnnotation],
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
location: Option[IdentifiedLocation],
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends IR
|
||||
with IRKind.Primitive {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -184,7 +185,7 @@ object Definition {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Data = {
|
||||
val res = Data(
|
||||
name,
|
||||
@ -232,7 +233,9 @@ object Definition {
|
||||
copy(location = location)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Data = {
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Data = {
|
||||
copy(
|
||||
name = name.mapExpressions(fn),
|
||||
arguments = arguments.map(_.mapExpressions(fn)),
|
||||
@ -279,12 +282,12 @@ object Definition {
|
||||
name: Name,
|
||||
arguments: List[DefinitionArgument],
|
||||
body: List[IR],
|
||||
override val location: Option[IdentifiedLocation],
|
||||
override val passData: MetadataStorage = MetadataStorage(),
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
location: Option[IdentifiedLocation],
|
||||
passData: MetadataStorage = MetadataStorage(),
|
||||
diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Definition
|
||||
with IRKind.Sugar {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -304,7 +307,7 @@ object Definition {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): SugaredType = {
|
||||
val res = SugaredType(
|
||||
name,
|
||||
@ -357,7 +360,7 @@ object Definition {
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(
|
||||
fn: Expression => Expression
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): SugaredType =
|
||||
copy(body = body.map(_.mapExpressions(fn)))
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
package org.enso.compiler.core.ir.module.scope
|
||||
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.IR.{randomId, Identifier, ToStringHelper}
|
||||
import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper}
|
||||
import org.enso.compiler.core.{IR, Identifier}
|
||||
import org.enso.compiler.core.IR.randomId
|
||||
import org.enso.compiler.core.ir.module.Scope
|
||||
import org.enso.compiler.core.ir.{
|
||||
DiagnosticStorage,
|
||||
@ -12,11 +13,15 @@ import org.enso.compiler.core.ir.{
|
||||
Name
|
||||
}
|
||||
|
||||
import java.util.UUID
|
||||
|
||||
/** An export statement */
|
||||
trait Export extends Scope {
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Export
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Export
|
||||
|
||||
/** @inheritdoc */
|
||||
override def setLocation(location: Option[IdentifiedLocation]): Export
|
||||
@ -57,7 +62,7 @@ object Export {
|
||||
) extends IR
|
||||
with IRKind.Primitive
|
||||
with Export {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -83,7 +88,7 @@ object Export {
|
||||
isSynthetic: Boolean = isSynthetic,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Module = {
|
||||
val res = Module(
|
||||
name,
|
||||
@ -123,7 +128,7 @@ object Export {
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(
|
||||
fn: Expression => Expression
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Module = this
|
||||
|
||||
/** @inheritdoc */
|
||||
|
@ -1,7 +1,8 @@
|
||||
package org.enso.compiler.core.ir.module.scope
|
||||
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.IR.{randomId, Identifier, ToStringHelper}
|
||||
import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper}
|
||||
import org.enso.compiler.core.{IR, Identifier}
|
||||
import org.enso.compiler.core.IR.randomId
|
||||
import org.enso.compiler.core.ir.module.Scope
|
||||
import org.enso.compiler.core.ir.{
|
||||
DiagnosticStorage,
|
||||
@ -12,11 +13,15 @@ import org.enso.compiler.core.ir.{
|
||||
Name
|
||||
}
|
||||
|
||||
import java.util.UUID
|
||||
|
||||
/** Module-level import statements. */
|
||||
trait Import extends Scope {
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Import
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Import
|
||||
|
||||
/** @inheritdoc */
|
||||
override def setLocation(location: Option[IdentifiedLocation]): Import
|
||||
@ -56,7 +61,7 @@ object Import {
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Import
|
||||
with IRKind.Primitive {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -82,7 +87,7 @@ object Import {
|
||||
isSynthetic: Boolean = isSynthetic,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Module = {
|
||||
val res = Module(
|
||||
name,
|
||||
@ -122,7 +127,7 @@ object Import {
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(
|
||||
fn: Expression => Expression
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Module = this
|
||||
|
||||
/** @inheritdoc */
|
||||
|
@ -3,8 +3,11 @@ package module
|
||||
package scope
|
||||
package definition
|
||||
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.IR.{randomId, Identifier, ToStringHelper}
|
||||
import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper}
|
||||
import org.enso.compiler.core.{IR, Identifier}
|
||||
import org.enso.compiler.core.IR.randomId
|
||||
|
||||
import java.util.UUID
|
||||
|
||||
/** A trait representing method definitions in Enso. */
|
||||
sealed trait Method extends Definition {
|
||||
@ -15,7 +18,9 @@ sealed trait Method extends Definition {
|
||||
override def setLocation(location: Option[IdentifiedLocation]): Method
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Method
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Method
|
||||
|
||||
/** @inheritdoc */
|
||||
override def duplicate(
|
||||
@ -50,7 +55,7 @@ object Method {
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Method
|
||||
with IRKind.Primitive {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -68,7 +73,7 @@ object Method {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Explicit = {
|
||||
val res = Explicit(
|
||||
methodReference,
|
||||
@ -117,7 +122,7 @@ object Method {
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(
|
||||
fn: Expression => Expression
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Explicit = {
|
||||
copy(
|
||||
methodReference = methodReference.mapExpressions(fn),
|
||||
@ -198,7 +203,7 @@ object Method {
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Method
|
||||
with IRKind.Sugar {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -218,7 +223,7 @@ object Method {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Binding = {
|
||||
val res = Binding(
|
||||
methodReference,
|
||||
@ -276,7 +281,7 @@ object Method {
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(
|
||||
fn: Expression => Expression
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Binding = {
|
||||
copy(
|
||||
methodReference = methodReference.mapExpressions(fn),
|
||||
@ -337,7 +342,7 @@ object Method {
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Method
|
||||
with IRKind.Primitive {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -359,7 +364,7 @@ object Method {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Conversion = {
|
||||
val res = Conversion(
|
||||
methodReference,
|
||||
@ -415,7 +420,7 @@ object Method {
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(
|
||||
fn: Expression => Expression
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Conversion = {
|
||||
copy(
|
||||
methodReference = methodReference.mapExpressions(fn),
|
||||
|
@ -1,7 +1,8 @@
|
||||
package org.enso.compiler.core.ir.module.scope.imports
|
||||
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.IR.{randomId, Identifier, ToStringHelper}
|
||||
import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper}
|
||||
import org.enso.compiler.core.{IR, Identifier}
|
||||
import org.enso.compiler.core.IR.randomId
|
||||
import org.enso.compiler.core.ir.module.scope.Import
|
||||
import org.enso.compiler.core.ir.{
|
||||
DiagnosticStorage,
|
||||
@ -11,6 +12,8 @@ import org.enso.compiler.core.ir.{
|
||||
MetadataStorage
|
||||
}
|
||||
|
||||
import java.util.UUID
|
||||
|
||||
/** An import of a polyglot class.
|
||||
*
|
||||
* @param entity language-specific information on the imported entity
|
||||
@ -28,7 +31,7 @@ sealed case class Polyglot(
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Import
|
||||
with IRKind.Primitive {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -47,7 +50,7 @@ sealed case class Polyglot(
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Polyglot = {
|
||||
val res =
|
||||
Polyglot(entity, rename, location, passData, diagnostics)
|
||||
@ -76,7 +79,9 @@ sealed case class Polyglot(
|
||||
): Polyglot = copy(location = location)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Polyglot =
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Polyglot =
|
||||
this
|
||||
|
||||
/** Returns the name this object is visible as from Enso code.
|
||||
|
@ -1,15 +1,21 @@
|
||||
package org.enso.compiler.core.ir
|
||||
package `type`
|
||||
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.IR.{randomId, Identifier, ToStringHelper}
|
||||
import org.enso.compiler.core.Implicits.{ShowPassData, ToStringHelper}
|
||||
import org.enso.compiler.core.{IR, Identifier}
|
||||
import org.enso.compiler.core.IR.randomId
|
||||
import org.enso.compiler.core.ir.Type.Info
|
||||
|
||||
import java.util.UUID
|
||||
import scala.jdk.FunctionConverters.enrichAsScalaFromFunction
|
||||
|
||||
/** IR nodes for dealing with typesets. */
|
||||
sealed trait Set extends Type {
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Set
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Set
|
||||
|
||||
/** @inheritdoc */
|
||||
override def setLocation(location: Option[IdentifiedLocation]): Set
|
||||
@ -43,7 +49,7 @@ object Set {
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Set
|
||||
with IRKind.Primitive {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -63,7 +69,7 @@ object Set {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Member = {
|
||||
val res =
|
||||
Member(label, memberType, value, location, passData, diagnostics)
|
||||
@ -110,7 +116,9 @@ object Set {
|
||||
copy(location = location)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Member = {
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Member = {
|
||||
copy(
|
||||
label = label.mapExpressions(fn),
|
||||
memberType = fn(memberType),
|
||||
@ -163,7 +171,7 @@ object Set {
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Set
|
||||
with IRKind.Primitive {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -181,7 +189,7 @@ object Set {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Subsumption = {
|
||||
val res = Subsumption(left, right, location, passData, diagnostics)
|
||||
res.id = id
|
||||
@ -222,7 +230,7 @@ object Set {
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(
|
||||
fn: Expression => Expression
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Subsumption = {
|
||||
copy(left = fn(left), right = fn(right))
|
||||
}
|
||||
@ -267,7 +275,7 @@ object Set {
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Set
|
||||
with IRKind.Primitive {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -285,7 +293,7 @@ object Set {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Equality = {
|
||||
val res = Equality(left, right, location, passData, diagnostics)
|
||||
res.id = id
|
||||
@ -325,7 +333,9 @@ object Set {
|
||||
): Equality = copy(location = location)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Equality = {
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Equality = {
|
||||
copy(left = fn(left), right = fn(right))
|
||||
}
|
||||
|
||||
@ -369,7 +379,7 @@ object Set {
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Set
|
||||
with IRKind.Primitive {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -387,7 +397,7 @@ object Set {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Concat = {
|
||||
val res = Concat(left, right, location, passData, diagnostics)
|
||||
res.id = id
|
||||
@ -426,7 +436,9 @@ object Set {
|
||||
copy(location = location)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Concat = {
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Concat = {
|
||||
copy(left = fn(left), right = fn(right))
|
||||
}
|
||||
|
||||
@ -468,7 +480,7 @@ object Set {
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Set
|
||||
with IRKind.Primitive {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -485,7 +497,7 @@ object Set {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Union = {
|
||||
val res = Union(operands, location, passData, diagnostics)
|
||||
res.id = id
|
||||
@ -520,8 +532,10 @@ object Set {
|
||||
copy(location = location)
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(fn: Expression => Expression): Union = {
|
||||
copy(operands = operands.map(fn))
|
||||
override def mapExpressions(
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Union = {
|
||||
copy(operands = operands.map(fn.asScala))
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@ -563,7 +577,7 @@ object Set {
|
||||
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
|
||||
) extends Set
|
||||
with IRKind.Primitive {
|
||||
override protected var id: Identifier = randomId
|
||||
var id: UUID @Identifier = randomId
|
||||
|
||||
/** Creates a copy of `this`.
|
||||
*
|
||||
@ -581,7 +595,7 @@ object Set {
|
||||
location: Option[IdentifiedLocation] = location,
|
||||
passData: MetadataStorage = passData,
|
||||
diagnostics: DiagnosticStorage = diagnostics,
|
||||
id: Identifier = id
|
||||
id: UUID @Identifier = id
|
||||
): Intersection = {
|
||||
val res = Intersection(left, right, location, passData, diagnostics)
|
||||
res.id = id
|
||||
@ -622,7 +636,7 @@ object Set {
|
||||
|
||||
/** @inheritdoc */
|
||||
override def mapExpressions(
|
||||
fn: Expression => Expression
|
||||
fn: java.util.function.Function[Expression, Expression]
|
||||
): Intersection = {
|
||||
copy(left = fn(left), right = fn(right))
|
||||
}
|
||||
|
@ -46,7 +46,6 @@ import org.enso.polyglot.CompilationStage;
|
||||
import org.enso.polyglot.LanguageInfo;
|
||||
import org.enso.polyglot.MethodNames;
|
||||
import org.enso.text.buffer.Rope;
|
||||
import scala.Function1;
|
||||
|
||||
/** Represents a source module with a known location. */
|
||||
@ExportLibrary(InteropLibrary.class)
|
||||
@ -258,8 +257,8 @@ public final class Module implements EnsoObject {
|
||||
}
|
||||
if (patchedValues.simpleUpdate(update)) {
|
||||
this.sources = this.sources.newWith(source);
|
||||
final Function1<Expression, Expression> fn =
|
||||
new Function1<Expression, Expression>() {
|
||||
final java.util.function.Function<Expression, Expression> fn =
|
||||
new java.util.function.Function<Expression, Expression>() {
|
||||
@Override
|
||||
public Expression apply(Expression v1) {
|
||||
if (v1 == change) {
|
||||
|
@ -10,6 +10,7 @@ import org.enso.compiler.context.{
|
||||
import org.enso.compiler.context.CompilerContext.Module
|
||||
import org.enso.compiler.core.CompilerError
|
||||
import org.enso.compiler.core.CompilerStub
|
||||
import org.enso.compiler.core.Implicits.AsMetadata
|
||||
import org.enso.compiler.core.ir.{
|
||||
Diagnostic,
|
||||
Expression,
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.enso.compiler
|
||||
|
||||
import com.oracle.truffle.api.source.Source
|
||||
import org.enso.compiler.core.Implicits.AsMetadata
|
||||
import org.enso.compiler.core.ir.{Module => IRModule}
|
||||
import org.enso.compiler.context.{ExportsBuilder, ExportsMap, SuggestionBuilder}
|
||||
import org.enso.compiler.context.CompilerContext.Module
|
||||
|
@ -3,6 +3,7 @@ package org.enso.compiler.codegen
|
||||
import com.oracle.truffle.api.source.{Source, SourceSection}
|
||||
import com.oracle.truffle.api.interop.InteropLibrary
|
||||
import org.enso.compiler.core.CompilerError
|
||||
import org.enso.compiler.core.Implicits.AsMetadata
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.ir.{
|
||||
CallArgument,
|
||||
|
@ -2,6 +2,7 @@ package org.enso.compiler.codegen
|
||||
|
||||
import org.enso.compiler.data.BindingsMap
|
||||
import org.enso.compiler.core.CompilerError
|
||||
import org.enso.compiler.core.Implicits.AsMetadata
|
||||
import org.enso.compiler.pass.analyse.BindingAnalysis
|
||||
import org.enso.interpreter.runtime.Module
|
||||
import org.enso.interpreter.runtime.builtin.Builtins
|
||||
|
@ -1,5 +1,6 @@
|
||||
package org.enso.compiler.context
|
||||
|
||||
import org.enso.compiler.core.Implicits.AsMetadata
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.data.BindingsMap
|
||||
import org.enso.compiler.pass.analyse.BindingAnalysis
|
||||
|
@ -2,7 +2,8 @@ package org.enso.compiler.context
|
||||
|
||||
import org.enso.compiler.Compiler
|
||||
import org.enso.compiler.context.CompilerContext
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.Implicits.AsMetadata
|
||||
import org.enso.compiler.core.{ExternalID, IR}
|
||||
import org.enso.compiler.core.ir.expression.{Application, Operator}
|
||||
import org.enso.compiler.core.ir.{
|
||||
DefinitionArgument,
|
||||
@ -31,6 +32,7 @@ import org.enso.polyglot.data.{Tree, TypeGraph}
|
||||
import org.enso.syntax.text.Location
|
||||
import org.enso.text.editing.IndexedSource
|
||||
|
||||
import java.util.UUID
|
||||
import scala.collection.mutable
|
||||
|
||||
/** Module that extracts [[Suggestion]] entries from the [[IR]].
|
||||
@ -242,7 +244,7 @@ final class SuggestionBuilder[A: IndexedSource](
|
||||
|
||||
/** Build a method suggestion. */
|
||||
private def buildMethod(
|
||||
externalId: Option[IR.ExternalId],
|
||||
externalId: Option[UUID @ExternalID],
|
||||
module: QualifiedName,
|
||||
name: String,
|
||||
selfType: QualifiedName,
|
||||
@ -287,7 +289,7 @@ final class SuggestionBuilder[A: IndexedSource](
|
||||
|
||||
/** Build a conversion suggestion. */
|
||||
private def buildConversion(
|
||||
externalId: Option[IR.ExternalId],
|
||||
externalId: Option[UUID @ExternalID],
|
||||
module: QualifiedName,
|
||||
selfType: Option[QualifiedName],
|
||||
args: Seq[DefinitionArgument],
|
||||
@ -314,7 +316,7 @@ final class SuggestionBuilder[A: IndexedSource](
|
||||
|
||||
/** Build a function suggestion. */
|
||||
private def buildFunction(
|
||||
externalId: Option[IR.ExternalId],
|
||||
externalId: Option[UUID @ExternalID],
|
||||
module: QualifiedName,
|
||||
name: Name,
|
||||
args: Seq[DefinitionArgument],
|
||||
@ -338,7 +340,7 @@ final class SuggestionBuilder[A: IndexedSource](
|
||||
|
||||
/** Build a local suggestion. */
|
||||
private def buildLocal(
|
||||
externalId: Option[IR.ExternalId],
|
||||
externalId: Option[UUID @ExternalID],
|
||||
module: QualifiedName,
|
||||
name: String,
|
||||
location: Location,
|
||||
|
@ -3,6 +3,7 @@ package org.enso.compiler.data
|
||||
import org.enso.compiler.{PackageRepository}
|
||||
import org.enso.compiler.PackageRepository.ModuleMap
|
||||
import org.enso.compiler.context.CompilerContext.Module
|
||||
import org.enso.compiler.core.Implicits.AsMetadata
|
||||
import org.enso.compiler.core.ir
|
||||
import org.enso.compiler.core.ir.expression.errors
|
||||
import org.enso.compiler.data.BindingsMap.{DefinedEntity, ModuleReference}
|
||||
@ -22,7 +23,7 @@ import scala.annotation.unused
|
||||
*/
|
||||
|
||||
@SerialVersionUID(
|
||||
7833L // instrumentor
|
||||
8145L // Scala to Java
|
||||
)
|
||||
case class BindingsMap(
|
||||
definedEntities: List[DefinedEntity],
|
||||
|
@ -1,11 +1,10 @@
|
||||
package org.enso.compiler.pass
|
||||
|
||||
import org.enso.compiler.context.{InlineContext, ModuleContext}
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.{CompilerError, IR, Identifier}
|
||||
import org.enso.compiler.core.ir.ProcessingPass
|
||||
import org.enso.compiler.core.ir.Module
|
||||
import org.enso.compiler.core.ir.Expression
|
||||
import org.enso.compiler.core.CompilerError
|
||||
import shapeless.=:!=
|
||||
|
||||
import java.util.UUID
|
||||
@ -24,7 +23,7 @@ import scala.reflect.ClassTag
|
||||
trait IRPass extends ProcessingPass {
|
||||
|
||||
/** An identifier for the pass. Useful for keying it in maps. */
|
||||
val key: IRPass.Identifier = IRPass.genId
|
||||
val key: UUID @Identifier = IRPass.genId
|
||||
|
||||
/** The type of the metadata object that the pass writes to the IR. */
|
||||
type Metadata <: ProcessingPass.Metadata
|
||||
@ -84,13 +83,11 @@ trait IRPass extends ProcessingPass {
|
||||
}
|
||||
object IRPass {
|
||||
|
||||
type Identifier = UUID
|
||||
|
||||
/** Generates a pass identifier.
|
||||
*
|
||||
* @return a new pass identifier
|
||||
*/
|
||||
def genId: Identifier = {
|
||||
def genId: UUID @Identifier = {
|
||||
UUID.randomUUID()
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
package org.enso.compiler.pass.analyse
|
||||
|
||||
import org.enso.compiler.context.{InlineContext, ModuleContext}
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.CompilerError
|
||||
import org.enso.compiler.core.Implicits.AsMetadata
|
||||
import org.enso.compiler.core.{CompilerError, ExternalID, IR, Identifier}
|
||||
import org.enso.compiler.core.ir.{
|
||||
CallArgument,
|
||||
DefinitionArgument,
|
||||
@ -34,6 +34,7 @@ import org.enso.compiler.pass.lint.UnusedBindings
|
||||
import org.enso.syntax.text.Debug
|
||||
|
||||
import java.io.Serializable
|
||||
import java.util.UUID
|
||||
import scala.collection.mutable
|
||||
import scala.reflect.ClassTag
|
||||
|
||||
@ -1558,8 +1559,8 @@ case object AliasAnalysis extends IRPass {
|
||||
sealed case class Def(
|
||||
override val id: Id,
|
||||
override val symbol: Graph.Symbol,
|
||||
identifier: IR.Identifier,
|
||||
externalId: Option[IR.ExternalId],
|
||||
identifier: UUID @Identifier,
|
||||
externalId: Option[UUID @ExternalID],
|
||||
isLazy: Boolean = false
|
||||
) extends Occurrence
|
||||
|
||||
@ -1578,8 +1579,8 @@ case object AliasAnalysis extends IRPass {
|
||||
sealed case class Use(
|
||||
override val id: Id,
|
||||
override val symbol: Graph.Symbol,
|
||||
identifier: IR.Identifier,
|
||||
externalId: Option[IR.ExternalId]
|
||||
identifier: UUID @Identifier,
|
||||
externalId: Option[UUID @ExternalID]
|
||||
) extends Occurrence
|
||||
|
||||
// TODO [AA] At some point the analysis should make use of these.
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.enso.compiler.pass.analyse
|
||||
|
||||
import org.enso.compiler.context.{InlineContext, ModuleContext}
|
||||
import org.enso.compiler.core.Implicits.{AsDiagnostics, AsMetadata}
|
||||
import org.enso.compiler.core.ir.{Expression, Module, Warning}
|
||||
import org.enso.compiler.core.ir.expression.errors
|
||||
import org.enso.compiler.core.ir.module.scope.Import
|
||||
|
@ -1,6 +1,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.{
|
||||
CallArgument,
|
||||
Expression,
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.enso.compiler.pass.analyse
|
||||
|
||||
import org.enso.compiler.context.{InlineContext, ModuleContext}
|
||||
import org.enso.compiler.core.Implicits.AsMetadata
|
||||
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
|
||||
|
@ -1,7 +1,8 @@
|
||||
package org.enso.compiler.pass.analyse
|
||||
|
||||
import org.enso.compiler.context.{InlineContext, ModuleContext}
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.Implicits.AsMetadata
|
||||
import org.enso.compiler.core.{CompilerError, ExternalID}
|
||||
import org.enso.compiler.core.ir.{
|
||||
DefinitionArgument,
|
||||
Expression,
|
||||
@ -13,11 +14,11 @@ import org.enso.compiler.core.ir.module.scope.Definition
|
||||
import org.enso.compiler.core.ir.module.scope.definition
|
||||
import org.enso.compiler.core.ir.expression.{Comment, Error}
|
||||
import org.enso.compiler.core.ir.MetadataStorage._
|
||||
import org.enso.compiler.core.CompilerError
|
||||
import org.enso.compiler.pass.IRPass
|
||||
import org.enso.compiler.pass.desugar._
|
||||
|
||||
import java.util
|
||||
import java.util.UUID
|
||||
import scala.collection.mutable
|
||||
import scala.jdk.CollectionConverters._
|
||||
|
||||
@ -185,7 +186,7 @@ case object CachePreferenceAnalysis extends IRPass {
|
||||
* @param weights the storage for weights of the program components
|
||||
*/
|
||||
sealed case class WeightInfo(
|
||||
weights: mutable.HashMap[IR.ExternalId, Double] = mutable.HashMap()
|
||||
weights: mutable.HashMap[UUID @ExternalID, Double] = mutable.HashMap()
|
||||
) extends IRPass.IRMetadata {
|
||||
|
||||
/** The name of the metadata as a string. */
|
||||
@ -204,20 +205,21 @@ case object CachePreferenceAnalysis extends IRPass {
|
||||
* @param id the external id
|
||||
* @param weight the assigned weight
|
||||
*/
|
||||
def update(id: IR.ExternalId, weight: Double): Unit =
|
||||
def update(id: UUID @ExternalID, weight: Double): Unit =
|
||||
weights.put(id, weight)
|
||||
|
||||
/** Get the weight associated with given id */
|
||||
def get(id: IR.ExternalId): Double =
|
||||
def get(id: UUID @ExternalID): Double =
|
||||
weights.getOrElse(id, Weight.Never)
|
||||
|
||||
/** Check if the weight is assigned to this id. */
|
||||
def contains(id: IR.ExternalId): Boolean =
|
||||
def contains(id: UUID @ExternalID): Boolean =
|
||||
weights.contains(id)
|
||||
|
||||
/** @return weights as the Java collection */
|
||||
def asJavaWeights: util.Map[IR.ExternalId, java.lang.Double] =
|
||||
weights.asJava.asInstanceOf[util.Map[IR.ExternalId, java.lang.Double]]
|
||||
def asJavaWeights: util.Map[UUID @ExternalID, java.lang.Double] =
|
||||
weights.asJava
|
||||
.asInstanceOf[util.Map[UUID @ExternalID, java.lang.Double]]
|
||||
|
||||
override def duplicate(): Option[IRPass.IRMetadata] =
|
||||
Some(copy(weights = this.weights))
|
||||
|
@ -1,7 +1,8 @@
|
||||
package org.enso.compiler.pass.analyse
|
||||
|
||||
import org.enso.compiler.context.{InlineContext, ModuleContext}
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.Implicits.AsMetadata
|
||||
import org.enso.compiler.core.{CompilerError, ExternalID, IR, Identifier}
|
||||
import org.enso.compiler.core.ir.module.scope.Definition
|
||||
import org.enso.compiler.core.ir.module.scope.definition
|
||||
import org.enso.compiler.core.ir.expression.{
|
||||
@ -26,12 +27,11 @@ import org.enso.compiler.core.ir.{
|
||||
Pattern,
|
||||
Type
|
||||
}
|
||||
import org.enso.compiler.core.IR.ExternalId
|
||||
import org.enso.compiler.core.ir.MetadataStorage._
|
||||
import org.enso.compiler.core.CompilerError
|
||||
import org.enso.compiler.pass.IRPass
|
||||
import org.enso.compiler.pass.analyse.DataflowAnalysis.DependencyInfo.Type.asStatic
|
||||
|
||||
import java.util.UUID
|
||||
import scala.collection.immutable.ListSet
|
||||
import scala.collection.mutable
|
||||
|
||||
@ -820,7 +820,7 @@ case object DataflowAnalysis extends IRPass {
|
||||
*/
|
||||
def getExternalDirect(
|
||||
key: DependencyInfo.Type
|
||||
): Option[Set[IR.ExternalId]] = {
|
||||
): Option[Set[UUID @ExternalID]] = {
|
||||
getDirect(key).map(_.flatMap(_.externalId))
|
||||
}
|
||||
|
||||
@ -884,7 +884,7 @@ case object DataflowAnalysis extends IRPass {
|
||||
* @return the set of all external identifiers of program components
|
||||
* associated with `key`, if it exists
|
||||
*/
|
||||
def getExternal(key: DependencyInfo.Type): Option[Set[IR.ExternalId]] = {
|
||||
def getExternal(key: DependencyInfo.Type): Option[Set[UUID @ExternalID]] = {
|
||||
get(key).map(_.flatMap(_.externalId))
|
||||
}
|
||||
|
||||
@ -992,15 +992,12 @@ case object DataflowAnalysis extends IRPass {
|
||||
}
|
||||
object DependencyInfo {
|
||||
|
||||
/** The type of identifiers in this analysis. */
|
||||
type Identifier = IR.Identifier
|
||||
|
||||
/** The type of symbols in this analysis. */
|
||||
type Symbol = String
|
||||
|
||||
/** The type of identification for a program component. */
|
||||
sealed trait Type {
|
||||
val externalId: Option[IR.ExternalId]
|
||||
val externalId: Option[UUID @ExternalID]
|
||||
}
|
||||
object Type {
|
||||
|
||||
@ -1011,8 +1008,8 @@ case object DataflowAnalysis extends IRPass {
|
||||
* component
|
||||
*/
|
||||
sealed case class Static(
|
||||
id: DependencyInfo.Identifier,
|
||||
override val externalId: Option[ExternalId]
|
||||
id: UUID @Identifier,
|
||||
override val externalId: Option[UUID @ExternalID]
|
||||
) extends Type
|
||||
|
||||
/** Program components identified by their symbol.
|
||||
@ -1023,7 +1020,7 @@ case object DataflowAnalysis extends IRPass {
|
||||
*/
|
||||
sealed case class Dynamic(
|
||||
name: DependencyInfo.Symbol,
|
||||
override val externalId: Option[ExternalId]
|
||||
override val externalId: Option[UUID @ExternalID]
|
||||
) extends Type
|
||||
|
||||
// === Utility Functions ================================================
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.enso.compiler.pass.analyse
|
||||
|
||||
import org.enso.compiler.context.{InlineContext, ModuleContext}
|
||||
import org.enso.compiler.core.Implicits.AsMetadata
|
||||
import org.enso.compiler.core.ir.{
|
||||
CallArgument,
|
||||
DefinitionArgument,
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.enso.compiler.pass.analyse
|
||||
|
||||
import org.enso.compiler.context.{InlineContext, ModuleContext}
|
||||
import org.enso.compiler.core.Implicits.AsMetadata
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.ir.{
|
||||
DefinitionArgument,
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.enso.compiler.pass.analyse
|
||||
|
||||
import org.enso.compiler.context.{InlineContext, ModuleContext}
|
||||
import org.enso.compiler.core.Implicits.AsMetadata
|
||||
import org.enso.compiler.core.ir.{Expression, Module, Name}
|
||||
import org.enso.compiler.core.ir.module.scope.Import
|
||||
import org.enso.compiler.core.ir.expression.errors
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.enso.compiler.pass.analyse
|
||||
|
||||
import org.enso.compiler.context.{InlineContext, ModuleContext}
|
||||
import org.enso.compiler.core.Implicits.{AsDiagnostics, AsMetadata}
|
||||
import org.enso.compiler.core.ir.MetadataStorage._
|
||||
import org.enso.compiler.core.ir.expression.{
|
||||
errors,
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.enso.compiler.pass.desugar
|
||||
|
||||
import org.enso.compiler.context.{InlineContext, ModuleContext}
|
||||
import org.enso.compiler.core.Implicits.AsMetadata
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.ir.{
|
||||
DefinitionArgument,
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.enso.compiler.pass.desugar
|
||||
|
||||
import org.enso.compiler.context.{InlineContext, ModuleContext}
|
||||
import org.enso.compiler.core.Implicits.AsMetadata
|
||||
import org.enso.compiler.core.ir.module.scope.Definition
|
||||
import org.enso.compiler.core.ir.module.scope.definition
|
||||
import org.enso.compiler.core.ir.expression.{errors, Comment, Error}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.enso.compiler.pass.desugar
|
||||
|
||||
import org.enso.compiler.context.{InlineContext, ModuleContext}
|
||||
import org.enso.compiler.core.Implicits.AsDiagnostics
|
||||
import org.enso.compiler.core.ir.{
|
||||
DefinitionArgument,
|
||||
Expression,
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.enso.compiler.pass.desugar
|
||||
|
||||
import org.enso.compiler.context.{FreshNameSupply, InlineContext, ModuleContext}
|
||||
import org.enso.compiler.core.Implicits.ListAsIr
|
||||
import org.enso.compiler.core.ir.{
|
||||
Expression,
|
||||
IdentifiedLocation,
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.enso.compiler.pass.lint
|
||||
|
||||
import org.enso.compiler.context.{InlineContext, ModuleContext}
|
||||
import org.enso.compiler.core.Implicits.AsDiagnostics
|
||||
import org.enso.compiler.core.ir.{Expression, Module}
|
||||
import org.enso.compiler.core.ir.expression.warnings
|
||||
import org.enso.compiler.core.ir.module.scope.Definition
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.enso.compiler.pass.lint
|
||||
|
||||
import org.enso.compiler.context.{InlineContext, ModuleContext}
|
||||
import org.enso.compiler.core.Implicits.AsDiagnostics
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.ir.{Expression, Module, Name, Pattern}
|
||||
import org.enso.compiler.core.ir.expression.{errors, warnings, Case}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.enso.compiler.pass.lint
|
||||
|
||||
import org.enso.compiler.context.{InlineContext, ModuleContext}
|
||||
import org.enso.compiler.core.Implicits.{AsDiagnostics, AsMetadata}
|
||||
import org.enso.compiler.core.ir.{
|
||||
DefinitionArgument,
|
||||
Expression,
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.enso.compiler.pass.optimise
|
||||
|
||||
import org.enso.compiler.context.{InlineContext, ModuleContext}
|
||||
import org.enso.compiler.core.Implicits.AsMetadata
|
||||
import org.enso.compiler.core.ir.{Expression, Module, Name}
|
||||
import org.enso.compiler.core.ir.MetadataStorage._
|
||||
import org.enso.compiler.core.CompilerError
|
||||
|
@ -1,7 +1,8 @@
|
||||
package org.enso.compiler.pass.optimise
|
||||
|
||||
import org.enso.compiler.context.{FreshNameSupply, InlineContext, ModuleContext}
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.Implicits.AsMetadata
|
||||
import org.enso.compiler.core.{CompilerError, IR, Identifier}
|
||||
import org.enso.compiler.core.ir.{
|
||||
DefinitionArgument,
|
||||
Empty,
|
||||
@ -13,7 +14,6 @@ import org.enso.compiler.core.ir.{
|
||||
}
|
||||
import org.enso.compiler.core.ir.expression.warnings
|
||||
import org.enso.compiler.core.ir.expression.errors
|
||||
import org.enso.compiler.core.CompilerError
|
||||
import org.enso.compiler.pass.IRPass
|
||||
import org.enso.compiler.pass.analyse.{
|
||||
AliasAnalysis,
|
||||
@ -25,6 +25,8 @@ import org.enso.compiler.pass.desugar._
|
||||
import org.enso.compiler.pass.resolve.IgnoredBindings
|
||||
import org.enso.syntax.text.Location
|
||||
|
||||
import java.util.UUID
|
||||
|
||||
/** This pass consolidates chains of lambdas into multi-argument lambdas
|
||||
* internally.
|
||||
*
|
||||
@ -268,7 +270,7 @@ case object LambdaConsolidate extends IRPass {
|
||||
body: Expression,
|
||||
defaults: List[Option[Expression]],
|
||||
argument: DefinitionArgument,
|
||||
toReplaceExpressionIds: Set[IR.Identifier]
|
||||
toReplaceExpressionIds: Set[UUID @Identifier]
|
||||
): (Expression, List[Option[Expression]]) = {
|
||||
(
|
||||
replaceInExpression(body, argument, toReplaceExpressionIds),
|
||||
@ -292,7 +294,7 @@ case object LambdaConsolidate extends IRPass {
|
||||
def replaceInExpression(
|
||||
expr: Expression,
|
||||
argument: DefinitionArgument,
|
||||
toReplaceExpressionIds: Set[IR.Identifier]
|
||||
toReplaceExpressionIds: Set[UUID @Identifier]
|
||||
): Expression = {
|
||||
expr.transformExpressions { case name: Name =>
|
||||
replaceInName(name, argument, toReplaceExpressionIds)
|
||||
@ -310,7 +312,7 @@ case object LambdaConsolidate extends IRPass {
|
||||
def replaceInName(
|
||||
name: Name,
|
||||
argument: DefinitionArgument,
|
||||
toReplaceExpressionIds: Set[IR.Identifier]
|
||||
toReplaceExpressionIds: Set[UUID @Identifier]
|
||||
): Name = {
|
||||
if (toReplaceExpressionIds.contains(name.getId)) {
|
||||
name match {
|
||||
@ -371,7 +373,7 @@ case object LambdaConsolidate extends IRPass {
|
||||
*/
|
||||
def usageIdsForShadowedArgs(
|
||||
argsWithShadowed: List[(DefinitionArgument, Boolean)]
|
||||
): List[Set[IR.Identifier]] = {
|
||||
): List[Set[UUID @Identifier]] = {
|
||||
argsWithShadowed.map {
|
||||
case (spec: DefinitionArgument.Specified, isShadowed) =>
|
||||
val aliasInfo =
|
||||
@ -395,7 +397,7 @@ case object LambdaConsolidate extends IRPass {
|
||||
) =>
|
||||
identifier
|
||||
}
|
||||
} else Set[IR.Identifier]()
|
||||
} else Set[UUID @Identifier]()
|
||||
|
||||
usageIds
|
||||
}
|
||||
@ -442,7 +444,7 @@ case object LambdaConsolidate extends IRPass {
|
||||
def computeReplacedExpressions(
|
||||
args: List[DefinitionArgument],
|
||||
body: Expression,
|
||||
usageIdsForShadowed: List[Set[IR.Identifier]]
|
||||
usageIdsForShadowed: List[Set[UUID @Identifier]]
|
||||
): (List[DefinitionArgument], Expression) = {
|
||||
var newBody = body
|
||||
var newDefaults = args.map(_.defaultValue)
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.enso.compiler.pass.optimise
|
||||
|
||||
import org.enso.compiler.context.{InlineContext, ModuleContext}
|
||||
import org.enso.compiler.core.Implicits.AsDiagnostics
|
||||
import org.enso.compiler.core.ir.{
|
||||
Expression,
|
||||
IdentifiedLocation,
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.enso.compiler.pass.resolve
|
||||
|
||||
import org.enso.compiler.context.{InlineContext, ModuleContext}
|
||||
import org.enso.compiler.core.Implicits.AsMetadata
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.ir.{
|
||||
CallArgument,
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.enso.compiler.pass.resolve
|
||||
|
||||
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
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.enso.compiler.pass.resolve
|
||||
|
||||
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.expression.Application
|
||||
|
@ -17,6 +17,7 @@ import org.enso.compiler.data.BindingsMap.{
|
||||
ResolvedType
|
||||
}
|
||||
import org.enso.compiler.core.CompilerError
|
||||
import org.enso.compiler.core.Implicits.{AsDiagnostics, AsMetadata}
|
||||
import org.enso.compiler.core.ir.expression.Application
|
||||
import org.enso.compiler.pass.IRPass
|
||||
import org.enso.compiler.pass.analyse.{AliasAnalysis, BindingAnalysis}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.enso.compiler.pass.resolve
|
||||
|
||||
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.module.scope.Definition
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.enso.compiler.pass.resolve
|
||||
|
||||
import org.enso.compiler.context.{FreshNameSupply, InlineContext, ModuleContext}
|
||||
import org.enso.compiler.core.Implicits.AsMetadata
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.ir.{
|
||||
CallArgument,
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.enso.compiler.pass.resolve
|
||||
|
||||
import org.enso.compiler.context.{FreshNameSupply, InlineContext, ModuleContext}
|
||||
import org.enso.compiler.core.Implicits.AsMetadata
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.ir.{
|
||||
DefinitionArgument,
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.enso.compiler.pass.resolve
|
||||
|
||||
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
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.enso.compiler.pass.resolve
|
||||
|
||||
import org.enso.compiler.context.{InlineContext, ModuleContext}
|
||||
import org.enso.compiler.core.Implicits.AsMetadata
|
||||
import org.enso.compiler.core.ir.{
|
||||
DefinitionArgument,
|
||||
Expression,
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.enso.compiler.pass.resolve
|
||||
|
||||
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.module.scope.Definition
|
||||
import org.enso.compiler.core.ir.Name
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.enso.compiler.pass.resolve
|
||||
|
||||
import org.enso.compiler.context.{InlineContext, ModuleContext}
|
||||
import org.enso.compiler.core.Implicits.AsMetadata
|
||||
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
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.enso.compiler.pass.resolve
|
||||
|
||||
import org.enso.compiler.context.{InlineContext, ModuleContext}
|
||||
import org.enso.compiler.core.Implicits.AsMetadata
|
||||
import org.enso.compiler.core.ir.{
|
||||
DefinitionArgument,
|
||||
Empty,
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.enso.compiler.pass.resolve
|
||||
|
||||
import org.enso.compiler.context.{InlineContext, ModuleContext}
|
||||
import org.enso.compiler.core.Implicits.AsMetadata
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.ir.{
|
||||
`type`,
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.enso.compiler.pass.resolve
|
||||
|
||||
import org.enso.compiler.context.{InlineContext, ModuleContext}
|
||||
import org.enso.compiler.core.Implicits.AsMetadata
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.ir.{Expression, Function, Module, Name}
|
||||
import org.enso.compiler.core.ir.expression.errors
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.enso.compiler.pass.resolve
|
||||
|
||||
import org.enso.compiler.context.{InlineContext, ModuleContext}
|
||||
import org.enso.compiler.core.Implicits.AsMetadata
|
||||
import org.enso.compiler.core.ir.module.scope.Definition
|
||||
import org.enso.compiler.core.ir.module.scope.definition
|
||||
import org.enso.compiler.core.ir.{
|
||||
|
@ -2,7 +2,7 @@ package org.enso.compiler.phase
|
||||
|
||||
import org.enso.compiler.Compiler
|
||||
import org.enso.compiler.context.CompilerContext.Module
|
||||
import org.enso.compiler.core.IR.AsMetadata
|
||||
import org.enso.compiler.core.Implicits.AsMetadata
|
||||
import org.enso.compiler.core.ir.{Module => IRModule}
|
||||
import org.enso.compiler.core.ir.Name
|
||||
import org.enso.compiler.core.ir.expression.errors
|
||||
|
@ -1,12 +1,15 @@
|
||||
package org.enso.compiler.refactoring
|
||||
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.Implicits.AsMetadata
|
||||
import org.enso.compiler.core.{ExternalID, IR, Identifier}
|
||||
import org.enso.compiler.core.ir.Name
|
||||
import org.enso.compiler.data.BindingsMap
|
||||
import org.enso.compiler.pass.analyse.DataflowAnalysis
|
||||
import org.enso.compiler.pass.resolve.MethodCalls
|
||||
import org.enso.pkg.QualifiedName
|
||||
|
||||
import java.util.UUID
|
||||
|
||||
trait IRUtils {
|
||||
|
||||
/** Find the node by external id.
|
||||
@ -15,7 +18,7 @@ trait IRUtils {
|
||||
* @param externalId the external id to look for
|
||||
* @return the first node with the given external id in `ir`
|
||||
*/
|
||||
def findByExternalId(ir: IR, externalId: IR.ExternalId): Option[IR] = {
|
||||
def findByExternalId(ir: IR, externalId: UUID @ExternalID): Option[IR] = {
|
||||
ir.preorder.find(_.getExternalId.contains(externalId))
|
||||
}
|
||||
|
||||
@ -129,7 +132,7 @@ trait IRUtils {
|
||||
* @param id the identifier to look for
|
||||
* @return the `ir` node with the given identifier
|
||||
*/
|
||||
private def findById(ir: IR, id: IR.Identifier): Option[IR] = {
|
||||
private def findById(ir: IR, id: UUID @Identifier): Option[IR] = {
|
||||
ir.preorder.find(_.getId == id)
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package org.enso.compiler.test
|
||||
|
||||
import org.enso.compiler.context.{FreshNameSupply, InlineContext, ModuleContext}
|
||||
import org.enso.compiler.core.EnsoParser
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.{EnsoParser, IR, Identifier}
|
||||
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
|
||||
@ -19,6 +19,8 @@ import org.enso.interpreter.runtime.scope.LocalScope
|
||||
import org.enso.pkg.QualifiedName
|
||||
import org.enso.polyglot.CompilationStage
|
||||
|
||||
import java.util.UUID
|
||||
|
||||
trait CompilerTest extends AnyWordSpecLike with Matchers with CompilerRunner
|
||||
trait CompilerRunner {
|
||||
// === IR Utilities =========================================================
|
||||
@ -133,7 +135,7 @@ trait CompilerRunner {
|
||||
*
|
||||
* @return a random identifier
|
||||
*/
|
||||
def genId: IR.Identifier = IR.randomId
|
||||
def genId: UUID @Identifier = IR.randomId
|
||||
|
||||
// === IR Testing Utils =====================================================
|
||||
|
||||
|
@ -2,6 +2,7 @@ package org.enso.compiler.test.pass.analyse
|
||||
|
||||
import org.enso.compiler.Passes
|
||||
import org.enso.compiler.context.{FreshNameSupply, InlineContext, ModuleContext}
|
||||
import org.enso.compiler.core.Implicits.AsMetadata
|
||||
import org.enso.compiler.core.ir.{
|
||||
CallArgument,
|
||||
Expression,
|
||||
|
@ -2,6 +2,7 @@ package org.enso.compiler.test.pass.analyse
|
||||
|
||||
import org.enso.compiler.Passes
|
||||
import org.enso.compiler.context.{FreshNameSupply, ModuleContext}
|
||||
import org.enso.compiler.core.Implicits.AsMetadata
|
||||
import org.enso.compiler.core.ir.Module
|
||||
import org.enso.compiler.data.BindingsMap
|
||||
import org.enso.compiler.data.BindingsMap.{
|
||||
|
@ -2,7 +2,8 @@ package org.enso.compiler.test.pass.analyse
|
||||
|
||||
import org.enso.compiler.Passes
|
||||
import org.enso.compiler.context.{FreshNameSupply, InlineContext, ModuleContext}
|
||||
import org.enso.compiler.core.IR
|
||||
import org.enso.compiler.core.Implicits.AsMetadata
|
||||
import org.enso.compiler.core.{ExternalID, IR, Identifier}
|
||||
import org.enso.compiler.core.ir.{
|
||||
CallArgument,
|
||||
DefinitionArgument,
|
||||
@ -30,6 +31,8 @@ import org.enso.interpreter.runtime.scope.LocalScope
|
||||
import org.enso.interpreter.test.Metadata
|
||||
import org.scalatest.Assertion
|
||||
|
||||
import java.util.UUID
|
||||
|
||||
class DataflowAnalysisTest extends CompilerTest {
|
||||
|
||||
// === Test Setup ===========================================================
|
||||
@ -61,7 +64,7 @@ class DataflowAnalysisTest extends CompilerTest {
|
||||
* @param id the identifier to use as the id
|
||||
* @return a static dependency on the node given by `id`
|
||||
*/
|
||||
def mkStaticDep(id: DependencyInfo.Identifier): DependencyInfo.Type = {
|
||||
def mkStaticDep(id: UUID @Identifier): DependencyInfo.Type = {
|
||||
mkStaticDep(id, None)
|
||||
}
|
||||
|
||||
@ -72,8 +75,8 @@ class DataflowAnalysisTest extends CompilerTest {
|
||||
* @return a static dependency on the node corresponding to `ir`, `extId`
|
||||
*/
|
||||
def mkStaticDep(
|
||||
id: DependencyInfo.Identifier,
|
||||
extId: Option[IR.ExternalId]
|
||||
id: UUID @Identifier,
|
||||
extId: Option[UUID @ExternalID]
|
||||
): DependencyInfo.Type = {
|
||||
DependencyInfo.Type.Static(id, extId)
|
||||
}
|
||||
@ -95,9 +98,12 @@ class DataflowAnalysisTest extends CompilerTest {
|
||||
*/
|
||||
def mkDynamicDep(
|
||||
str: String,
|
||||
extId: Option[IR.Identifier]
|
||||
extId: Option[UUID @Identifier]
|
||||
): DependencyInfo.Type = {
|
||||
DependencyInfo.Type.Dynamic(str, extId)
|
||||
DependencyInfo.Type.Dynamic(
|
||||
str,
|
||||
extId
|
||||
)
|
||||
}
|
||||
|
||||
/** Adds an extension method to run dataflow analysis on an [[Module]].
|
||||
@ -1513,7 +1519,9 @@ class DataflowAnalysisTest extends CompilerTest {
|
||||
}
|
||||
|
||||
"return the set of external identifiers for invalidation" in {
|
||||
metadata.dependents.getExternal(asStatic(aBindExpr)).get shouldEqual Set(
|
||||
metadata.dependents
|
||||
.getExternal(asStatic(aBindExpr))
|
||||
.get shouldEqual Set(
|
||||
lambdaId,
|
||||
aBindId
|
||||
)
|
||||
|
@ -2,6 +2,7 @@ package org.enso.compiler.test.pass.analyse
|
||||
|
||||
import org.enso.compiler.Passes
|
||||
import org.enso.compiler.context.{FreshNameSupply, ModuleContext}
|
||||
import org.enso.compiler.core.Implicits.AsMetadata
|
||||
import org.enso.compiler.core.ir.{
|
||||
CallArgument,
|
||||
DefinitionArgument,
|
||||
|
@ -2,6 +2,7 @@ package org.enso.compiler.test.pass.analyse
|
||||
|
||||
import org.enso.compiler.Passes
|
||||
import org.enso.compiler.context.{FreshNameSupply, InlineContext, ModuleContext}
|
||||
import org.enso.compiler.core.Implicits.AsMetadata
|
||||
import org.enso.compiler.core.ir.{
|
||||
Expression,
|
||||
Function,
|
||||
|
@ -2,6 +2,7 @@ package org.enso.compiler.test.pass.desugar
|
||||
|
||||
import org.enso.compiler.Passes
|
||||
import org.enso.compiler.context.{InlineContext, ModuleContext}
|
||||
import org.enso.compiler.core.Implicits.AsMetadata
|
||||
import org.enso.compiler.core.ir.{
|
||||
DefinitionArgument,
|
||||
Expression,
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user