forked from aptos-labs/aptos-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[move-prover] allow
ExpTranslator
to recognize generics in expressions
The `ExpTranslator` now accepts two forms of generics: - `type_params / type_params_table` represent the generic types in the enclosing function when translating this expression. For example, if the expression is associated with a `fun foo<T>()`, then `T` is captured as a `Type::TypeParameter` in the `type_params` store. - `type_locals / type_locals_table` represent the generic types in the expression itself. For example, the expression is a generic invariant `invariant<t> is_operating() => exists<S<t>>(0x1)`, then the `t` is captured as a `Type::TypeLocal` in the `type_locals` store. The reason we need to separate them is that the genericity come from different sources. We use `TypeParameter` to track that the genericity is introduced in the Move code, and re-purpose `TypeLocal` to indicate that the genericity is introduced by the Spec code. Besides signaling different origins, it seems necessary (or rather, makes our lives much easier) to assign different `Type`s for generic types coming from different sources. Consider the following example: ``` fun foo<T>() { borrow_global_mut<S<T>>(@0x1, ...); } spec { invariant<T> exists<S<T>>(0x1) ==> ...; } ``` The `T` in `foo<T>` and `invariant<T>` are essentially two different things although they share the same symbol and positional index in the genericity type list.
- Loading branch information
1 parent
834439f
commit d032ad9
Showing
3 changed files
with
120 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters