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

refactor: builtins #33

Merged
merged 2 commits into from
Apr 12, 2024
Merged

refactor: builtins #33

merged 2 commits into from
Apr 12, 2024

Conversation

katat
Copy link
Collaborator

@katat katat commented Apr 11, 2024

The static and const builtins doesn't work for generic types. These changes are for adapting to different backends.


pub mod crypto;

pub static CRYPTO_MODULE: Lazy<BuiltinModule> = Lazy::new(|| {
let functions = parse_fn_sigs(&CRYPTO_FNS);
Copy link
Contributor

Choose a reason for hiding this comment

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

can you delete the parse_fn_sigs function now?

Copy link
Contributor

@mimoo mimoo left a comment

Choose a reason for hiding this comment

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

Nice! Looks good to me!

BUILTIN_FNS.get(&qualified.name)
} else {
self.functions.get(qualified)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm puzzled as to why this code existed before, I guess it was useless right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

My understanding is it was trying to differentiate the crypto builtin functions and native functions.
But since both the builtins and natives are stored in the same place now, this code seem deprecated.

@@ -154,8 +149,8 @@ impl TypeChecker {

// initialize it with the standard library
let crypto_module = ModulePath::Absolute(UserRepo::new("std/crypto"));
for (fn_name, fn_info) in CRYPTO_MODULE.functions.iter() {
let qualified = FullyQualified::new(&crypto_module, fn_name);
for fn_info in crypto_fns().iter() {
Copy link
Contributor

Choose a reason for hiding this comment

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

btw you should be able to write for fn_info in crypto_fns() no?

let functions = parse_fn_sigs(&CRYPTO_FNS);
BuiltinModule { functions }
});

pub fn get_std_fn(submodule: &str, fn_name: &str, span: Span) -> Result<FnInfo> {
Copy link
Contributor

@mimoo mimoo Apr 12, 2024

Choose a reason for hiding this comment

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

Is this function used anywhere? Maybe we can delete

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it seems no. may be dead code?

@katat katat force-pushed the refactor/builtins branch from ded71f1 to 7e5c974 Compare April 12, 2024 01:46
@katat katat force-pushed the refactor/builtins branch from 7e5c974 to fc65b02 Compare April 12, 2024 01:51
@katat katat merged commit 3d1c92a into zksecurity:main Apr 12, 2024
1 check failed
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.

2 participants