mbeckerle commented on a change in pull request #473:
URL: https://github.com/apache/incubator-daffodil/pull/473#discussion_r562041194



##########
File path: 
daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/ExpressionEvaluatingUnparsers.scala
##########
@@ -77,30 +76,52 @@ final class SetVariableUnparser(
 
 }
 
+final class NewVariableInstanceSuspendableExpression(
+  override val expr: CompiledExpression[AnyRef],
+  override val rd: VariableRuntimeData)
+  extends SuspendableExpression {
+
+  override protected def processExpressionResult(ustate: UState, v: 
DataValuePrimitive): Unit = {
+    ustate.variableMap.newVariableInstance(rd, v)
+  }
+
+  override protected def maybeKnownLengthInBits(ustate: UState) = MaybeULong(0)
+}
+

Review comment:
       An easier check could be if a given variable is used anywhere in the 
schema by a NVI statement having default value, and the variable has 
unparse-direction, that no setVariable is allowed anywhere for that variable. 
This eliminates the need for a precise roll-up of which setVariable statements 
are in scope of a particular NVI or not. 
   
   Such a variable is what we might call "bindable only" or non-settable. I 
think this fixes many things, and DFDL schemas that actually try to use 
setVariable with such variables can split a variable into two variables. Use 
one for binding via NVI with defaults, and the other for the setVariable 
purposes, it's NVIs would not have any default values. 




----------------------------------------------------------------
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:
[email protected]


Reply via email to