Skip to content

Commit

Permalink
switch to Reference for Expression
Browse files Browse the repository at this point in the history
  • Loading branch information
radeusgd committed Mar 8, 2024
1 parent 1d2758b commit 780442b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.enso.compiler.pass.analyse.BindingAnalysis$;
import org.enso.compiler.pass.analyse.JavaInteropHelpers;
import org.enso.compiler.pass.resolve.*;
import org.enso.persist.Persistance;
import org.enso.pkg.QualifiedName;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -470,6 +471,10 @@ private InferredType getInferredType(Expression expression) {
}
}

private TypeRepresentation resolveTypeExpression(Persistance.Reference<Expression> ref) {
return resolveTypeExpression(ref.get(Expression.class));
}

private TypeRepresentation resolveTypeExpression(Expression type) {
return switch (type) {
case Name.Literal name -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import org.enso.compiler.core.ir.module.scope.Definition
import org.enso.compiler.pass.IRPass
import org.enso.compiler.pass.analyse.BindingAnalysis
import org.enso.compiler.pass.resolve.MethodDefinitions
import org.enso.persist.Persistance.Reference
import org.enso.pkg.QualifiedName

import java.io.ObjectOutputStream
Expand Down Expand Up @@ -746,7 +747,7 @@ object BindingsMap {
def anyFieldsDefaulted: Boolean = arguments.exists(_.hasDefaultValue)
}

case class Argument(name: String, hasDefaultValue: Boolean, typ: Option[Expression])
case class Argument(name: String, hasDefaultValue: Boolean, typ: Option[Reference[Expression]])

/** A representation of a sum type
*
Expand Down Expand Up @@ -782,9 +783,13 @@ object BindingsMap {
ir.members.map(m =>
Cons(
m.name.name,
m.arguments.map(arg =>
BindingsMap.Argument(arg.name.name, arg.defaultValue.isDefined, arg.ascribedType)
)
m.arguments.map { arg =>
val ascribedType: Option[Reference[Expression]] = arg.ascribedType match {
case Some(value) => Some(Reference.of(value))
case None => None
}
BindingsMap.Argument(arg.name.name, arg.defaultValue.isDefined, ascribedType)
}
)
),
isBuiltinType
Expand Down

0 comments on commit 780442b

Please sign in to comment.