Skip to content
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

Add support for constants #39

Open
Sword-Smith opened this issue Aug 28, 2023 · 0 comments
Open

Add support for constants #39

Sword-Smith opened this issue Aug 28, 2023 · 0 comments

Comments

@Sword-Smith
Copy link
Contributor

Goal: To be allowed to write this

const MEMORY_ADDRESS: u64 = 100;
let memory_address = BFieldElement::new(MEMORY_ADDRESS);

instead of that:

let memory_address = BFieldElement::new(100);

We can probably use a similar technique to what we did with the struct definitions: Add a literal variant "Unresolved" which must then be matched with the content of the associated constant declarations an appropriate place in the compiler pipeline, probably in types.rs where we are doing this match for structs.

Just like DataType has a method for resolve_type that takes the declared structs and maps any unresolved type to one of those, so too could resolve_literal map unresolved literals to those from a constant list stored in the type checkers CheckState struct.

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

No branches or pull requests

1 participant