Github user mbeckerle commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/12#discussion_r153948953
--- Diff:
daffodil-core/src/main/scala/edu/illinois/ncsa/daffodil/grammar/EncodingChangeMixin.scala
---
@@ -30,44 +30,44 @@
* SOFTWARE.
*/
-package edu.illinois.ncsa.daffodil.grammar
-
-import edu.illinois.ncsa.daffodil.processors._
-import edu.illinois.ncsa.daffodil.dsom.Term
-import edu.illinois.ncsa.daffodil.equality._
-import edu.illinois.ncsa.daffodil.grammar.primitives.EncodingChange
-
-trait EncodingChangeMixin extends GrammarMixin { self: Term =>
-
- private lazy val enclosingEncoding = enclosingTerm.map(_.encodingEv)
- private lazy val priorSiblingEncoding = priorSibling.map(_.encodingEv)
- private lazy val encodingBefore: Evaluatable[String] =
priorSiblingEncoding.getOrElse(enclosingEncoding.getOrElse(encodingEv))
-
- protected lazy val isKnownSameEncoding: Boolean = {
- if (enclosingTerm.isEmpty) false // root always gets a encoding change.
- else {
- val thisEncoding = encodingEv
- val otherEncoding = encodingBefore
- if (thisEncoding.isConstant && otherEncoding.isConstant &&
- thisEncoding.optConstant.get =:= otherEncoding.optConstant.get) {
- if (priorSiblingEncoding.isDefined) {
- // in addition to having the same encoding as the prior sibling,
all
- // children of that prior sibling must have the same encoding.
- // Otherwise, a child could change the encoding and it might not
be
- // the same as ours.
- priorSibling.get.hasUniformEncodingThroughout
- } else {
- true
- }
- } else {
- false
- }
- }
- }
-
- protected lazy val hasUniformEncodingThroughout: Boolean =
termChildren.map { t => t.isKnownSameEncoding && t.hasUniformEncodingThroughout
}.forall(x => x)
-
- protected final lazy val encodingChange = prod("encodingChange",
- !isKnownSameEncoding ||
- (isArray && !hasUniformEncodingThroughout)) { EncodingChange(this) }
-}
+//package edu.illinois.ncsa.daffodil.grammar
--- End diff --
file can be deleted.
However, until this whole approach of calling back to the FormatInfo object
is shown to be acceptable performance-wise, it is worth keeping these.
---