-
Notifications
You must be signed in to change notification settings - Fork 59
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
Conversation
|
||
pub mod crypto; | ||
|
||
pub static CRYPTO_MODULE: Lazy<BuiltinModule> = Lazy::new(|| { | ||
let functions = parse_fn_sigs(&CRYPTO_FNS); |
There was a problem hiding this comment.
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?
There was a problem hiding this 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) | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
src/type_checker/mod.rs
Outdated
@@ -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() { |
There was a problem hiding this comment.
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?
src/stdlib/mod.rs
Outdated
let functions = parse_fn_sigs(&CRYPTO_FNS); | ||
BuiltinModule { functions } | ||
}); | ||
|
||
pub fn get_std_fn(submodule: &str, fn_name: &str, span: Span) -> Result<FnInfo> { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
ded71f1
to
7e5c974
Compare
7e5c974
to
fc65b02
Compare
The static and const builtins doesn't work for generic types. These changes are for adapting to different backends.