Fix and refactor decoder and translator #28
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes the problem with
UModelBase
ambiguity and refactors the whole decoding mechanism a little bit.Details
The problem
We analyze function
check
:a0 == 0
in emptyUModel
and it has emptym0: KModel
, soa0
evaluates to sample valuenull
, because register reading was not translated yet.r0 := mkConst("r0")
and for some reasonm0(r0)
equals to something different fromnull
.JcTest
and readr0
from the modelm0
, but now the model containsr0
, we get something non-null, and that is the problem.To fix that, we provide an expression translator in every component of
UModelBase
, so it first translates an expression and only then the expression is evaluated in aKModel
.Other
I decided to remove
UCachingExprTranslator
to simplify extension of our expressions and the total number of components. Now,UExprTranslator
cachesUExpr
s viaKNonRecursiveTransformer
and also caches initial values forURegionId
s explicitly.Lazy model components calls
translate
function, which takes an expression from a cache or explicitly transforms it.Also fixed cache usage in
UTreeMemoryUpdatesFolder
visitor a little bit.