Skip to content

[2/x] Translate basic wallet Wasm component #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Mar 15, 2024

Conversation

greenhat
Copy link
Contributor

@greenhat greenhat commented Feb 20, 2024

Close #109

This PR is stacked on top of #127 and should be merged after it

This PR implements missing pieces in the Wasm CM translation needed for basic wallet example translation.

Wasm tables translation is not yet implemented, along with the call_indirect op translation (ignored) and are extracted into #133.

This PR adds:

  • miden_hir::Type::Tuple to represent Wasm CM tuple types;
  • Wasm module instantiation arguments translation;;
  • FuncEnvironment for call op translation;
  • The bulk of the component translation is extracted into ComponentTranslator to make the overall algorithm and steps more clear and concise;

Type::split implementation for Tuple is temporarily plugged with todo!. Let me know if you want me to implement it.

@greenhat greenhat changed the title draft Translate basic wallet Wasm component Feb 20, 2024
@greenhat greenhat linked an issue Feb 20, 2024 that may be closed by this pull request
@greenhat greenhat force-pushed the greenhat/i109-basic-wallet-trans branch from 9920e70 to e650342 Compare February 28, 2024 07:07
@greenhat greenhat force-pushed the greenhat/i109-basic-wallet-trans branch 2 times, most recently from 1883b7a to 422b8f7 Compare February 29, 2024 13:09
@greenhat greenhat marked this pull request as ready for review February 29, 2024 13:23
@greenhat greenhat force-pushed the greenhat/wasmcm-itest-support branch from fe0cbde to 2d39974 Compare February 29, 2024 14:10
@greenhat greenhat force-pushed the greenhat/i109-basic-wallet-trans branch from cce1f5b to 5c2cc0d Compare February 29, 2024 14:34
@greenhat greenhat requested a review from bitwalker February 29, 2024 14:55
@greenhat greenhat changed the title Translate basic wallet Wasm component [2/x] Translate basic wallet Wasm component Feb 29, 2024
@bitwalker bitwalker force-pushed the greenhat/wasmcm-itest-support branch from 2d39974 to 1960cfd Compare March 15, 2024 04:19
Base automatically changed from greenhat/wasmcm-itest-support to main March 15, 2024 04:20
@@ -65,6 +65,8 @@ pub enum Type {
Struct(StructType),
/// A vector of fixed size
Array(Box<Type>, usize),
/// A tuple of values of the given types
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we actually need a Tuple type? A tuple is basically just an anonymous struct, there is no meaningful difference between them. I'd rather avoid introducing additional type-level abstractions if we can avoid it, since it requires handling that type in various places throughout the compiler, and we don't really want to do that unless it is actually semantically significant.

If there is a specific reason why StructType is insufficient, let me know, but for now I'm going to leave it out of the rebased changes and use structs instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably, not. I cannot find any reason why it cannot be represented as a struct.

Swap function calls to imported functions with the external function
passed as module arguments.
according to the instantiation order
in the final stage of the translation to make the overall algorithm and
steps more clear and concise.
Raise errors when an particular item translation is not(yet) implemented.
temporary use of u64 for Felt in WIT.
@bitwalker bitwalker force-pushed the greenhat/i109-basic-wallet-trans branch from 5c2cc0d to eb3c0c9 Compare March 15, 2024 07:01
@bitwalker bitwalker merged commit 9d62244 into main Mar 15, 2024
@bitwalker bitwalker deleted the greenhat/i109-basic-wallet-trans branch March 15, 2024 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Translate basic-wallet Wasm component
2 participants