You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by GitBox <gi...@apache.org> on 2021/04/06 22:30:46 UTC
[GitHub] [daffodil] jadams-tresys commented on a change in pull request #510: New variable instances should inherit external values
jadams-tresys commented on a change in pull request #510:
URL: https://github.com/apache/daffodil/pull/510#discussion_r608220936
##########
File path: daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/ExpressionEvaluatingUnparsers.scala
##########
@@ -103,13 +102,22 @@ class NewVariableInstanceStartUnparser(override val context: VariableRuntimeData
override lazy val childProcessors = Vector()
override def unparse(state: UState) = {
- state.variableMap.newVariableInstance(context)
+ val v = state.variableMap.newVariableInstance(context)
+
if (context.maybeDefaultValueExpr.isDefined) {
- val maybeVar = state.variableMap.find(context.globalQName)
- Assert.invariant(maybeVar.isDefined)
- maybeVar.get.setState(VariableInProcess)
- val suspendableExpression = new NewVariableInstanceSuspendableExpression(context.maybeDefaultValueExpr.get, context)
- suspendableExpression.run(state)
+ val dve = context.maybeDefaultValueExpr.get
+ dve match {
+ case constExpr: ConstantExpression[_] => // Do nothing, value has already been computed at schema compile time
+ case _ => {
+ v.setState(VariableInProcess)
+ val suspendableExpression = new NewVariableInstanceDefaultValueSuspendableExpression(dve, context)
+ suspendableExpression.run(state)
+ }
+ }
+ } else {
+ // The NVI will inherit the default value of the original variable instance
+ // This will also inherit any externally provided bindings.
+ v.setDefaultValue(v.firstInstanceInitialValue)
Review comment:
So we can actually just do a check to see if firstInstanceInitialValue is defined, which checks to see if it is something other than DataValue.NoValue. So no need for making it an Option.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org