-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,13 @@ use crate::{ | |
cli::packages::UserRepo, | ||
constants::{Field, Span}, | ||
error::{Error, ErrorKind, Result}, | ||
imports::{FnKind, BUILTIN_FNS}, | ||
imports::FnKind, | ||
name_resolution::NAST, | ||
parser::{ | ||
types::{FuncOrMethod, FunctionDef, ModulePath, RootKind, Ty, TyKind}, | ||
CustomType, Expr, StructDef, | ||
}, | ||
stdlib::{CRYPTO_MODULE, QUALIFIED_BUILTINS}, | ||
stdlib::{builtin_fns, crypto::crypto_fns, QUALIFIED_BUILTINS}, | ||
}; | ||
|
||
pub use checker::{FnInfo, StructInfo}; | ||
|
@@ -91,12 +91,7 @@ impl TypeChecker { | |
} | ||
|
||
pub(crate) fn fn_info(&self, qualified: &FullyQualified) -> Option<&FnInfo> { | ||
if qualified.module == Some(UserRepo::new("std/builtins")) { | ||
// if it's a built-in: get it from a global | ||
BUILTIN_FNS.get(&qualified.name) | ||
} else { | ||
self.functions.get(qualified) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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. |
||
self.functions.get(qualified) | ||
} | ||
|
||
pub(crate) fn const_info(&self, qualified: &FullyQualified) -> Option<&ConstInfo> { | ||
|
@@ -141,8 +136,8 @@ impl TypeChecker { | |
|
||
// initialize it with the builtins | ||
let builtin_module = ModulePath::Absolute(UserRepo::new(QUALIFIED_BUILTINS)); | ||
for (fn_name, fn_info) in BUILTIN_FNS.iter() { | ||
let qualified = FullyQualified::new(&builtin_module, fn_name); | ||
for fn_info in builtin_fns() { | ||
let qualified = FullyQualified::new(&builtin_module, &fn_info.sig().name.value); | ||
if type_checker | ||
.functions | ||
.insert(qualified, fn_info.clone()) | ||
|
@@ -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() { | ||
let qualified = FullyQualified::new(&crypto_module, &fn_info.sig().name.value); | ||
if type_checker | ||
.functions | ||
.insert(qualified, fn_info.clone()) | ||
|
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?