Skip to content

Commit

Permalink
Remove unnecessary constructors: SEDamlException, SEImportValue, from…
Browse files Browse the repository at this point in the history
… SExpr{0,1} (#11668)

CHANGELOG_BEGIN
CHANGELOG_END
  • Loading branch information
nickchapman-da authored Nov 12, 2021
1 parent c109552 commit 8c46559
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,6 @@ private[lf] object Anf {
Bounce(() => transform(depth, atom, k))

case source.SEVal(x) => Bounce(() => transform(depth, target.SEVal(x), k))
case source.SEImportValue(ty, v) =>
Bounce(() => transform(depth, target.SEImportValue(ty, v), k))

case source.SEAppGeneral(func, args) =>
// It's safe to perform ANF if the func-expression has no effects when evaluated.
Expand Down Expand Up @@ -373,9 +371,6 @@ private[lf] object Anf {
case source.SEScopeExercise(body0) =>
val body: target.SExpr = flattenExp(depth, env, body0)(anf => Land(anf.wrapped)).bounce
Bounce(() => transform(depth, target.SEScopeExercise(body), k))

case _: source.SEDamlException =>
throw CompilationError(s"flatten: unexpected: $exp")
}

private[this] def atomizeExps[A](
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,6 @@ private[speedy] object ClosureConversion {

case source.SELet1General(bound, body) =>
target.SELet1General(closureConvert(remaps, bound), closureConvert(shift(remaps, 1), body))

case _: source.SEDamlException | _: source.SEImportValue =>
throw CompilationError(s"closureConvert: unexpected $expr")
}
}

Expand Down Expand Up @@ -184,7 +181,7 @@ private[speedy] object ClosureConversion {
case source.SEScopeExercise(body) =>
go(body, bound, free)

case _: source.SEDamlException | _: source.SEImportValue | _: source.SELet1General =>
case _: source.SELet1General =>
throw CompilationError(s"freeVars: unexpected $expr")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,19 @@ object SExpr {

/** We cannot crash in the engine call back.
* Rather, we set the control to this expression and then crash when executing.
*
* The SEDamlException form is never constructed when compiling user LF.
* It is only constructed at runtime by certain builtin-ops.
*/
final case class SEDamlException(error: interpretation.Error) extends SExpr {
def execute(machine: Machine): Unit = {
throw SErrorDamlException(error)
}
}

/** The SEImportValue form is never constructed when compiling user LF.
* It is only constructed at runtime by certain builtin-ops.
*/
final case class SEImportValue(typ: Ast.Type, value: V) extends SExpr {
def execute(machine: Machine): Unit = {
machine.importValue(typ, value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ package speedy
* Summary of which constructors are contained by: SExp0, SExpr1 and SExpr:
*
* - In SExpr{0,1,} (everywhere): SEAppGeneral, SEBuiltin, SEBuiltinRecursiveDefinition,
* SEDamlException, SEImportValue, SELabelClosure, SELet1General, SELocation,
* SELabelClosure, SELet1General, SELocation,
* SEScopeExercise, SETryCatch, SEVal, SEValue,
*
* - In SExpr0: SEAbs, SEVar
Expand All @@ -42,11 +42,11 @@ package speedy
*
* - In SExpr: SEAppAtomicFun, SEAppAtomicGeneral, SEAppAtomicSaturatedBuiltin,
* SECaseAtomic, SELet1Builtin, SELet1BuiltinArithmetic
*
* - In SExpr (runtime only, i.e. rejected by validate): SEDamlException, SEImportValue
*/

import com.daml.lf.data.Ref._
import com.daml.lf.language.Ast
import com.daml.lf.value.{Value => V}
import com.daml.lf.speedy.SValue._
import com.daml.lf.speedy.SExpr.{SDefinitionRef, SCasePat}
import com.daml.lf.speedy.{SExpr => runTime}
Expand Down Expand Up @@ -129,13 +129,6 @@ private[speedy] object SExpr0 {
*/
final case class SELabelClosure(label: Profile.Label, expr: SExpr) extends SExpr

/** We cannot crash in the engine call back.
* Rather, we set the control to this expression and then crash when executing.
*/
final case class SEDamlException(error: interpretation.Error) extends SExpr

final case class SEImportValue(typ: Ast.Type, value: V) extends SExpr

/** Exception handler */
final case class SETryCatch(body: SExpr, handler: SExpr) extends SExpr

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ package speedy
*/

import com.daml.lf.data.Ref._
import com.daml.lf.language.Ast
import com.daml.lf.value.{Value => V}
import com.daml.lf.speedy.SValue._
import com.daml.lf.speedy.SExpr.{SDefinitionRef, SCasePat}
import com.daml.lf.speedy.{SExpr => runTime}
Expand Down Expand Up @@ -101,13 +99,6 @@ private[speedy] object SExpr1 {
*/
final case class SELabelClosure(label: Profile.Label, expr: SExpr) extends SExpr

/** We cannot crash in the engine call back.
* Rather, we set the control to this expression and then crash when executing.
*/
final case class SEDamlException(error: interpretation.Error) extends SExpr

final case class SEImportValue(typ: Ast.Type, value: V) extends SExpr

/** Exception handler */
final case class SETryCatch(body: SExpr, handler: SExpr) extends SExpr

Expand Down

0 comments on commit 8c46559

Please sign in to comment.