-
Notifications
You must be signed in to change notification settings - Fork 100
Add function support to nameof keyword #674
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
base: staging
Are you sure you want to change the base?
Conversation
... I guess we forbid The alternative is compiling variants in a "turntable" function which would be returned by Or a special syntax to denote the expected argument set, like |
I've also taken the liberty of changing the merge base from |
Ah found an issue: this |
Rewrote the bash wrapper script into Amber This temporarily introduces a hard dependency on bc and sed, at least until amber-lang/amber#366 is fixed, and the script is built with amber-lang/amber#674 applied to the compiler.
src/modules/builtin/nameof.rs
Outdated
use crate::modules::variable::variable_name_extensions; | ||
use crate::translate::module::TranslateModule; | ||
use crate::utils::{ParserMetadata, TranslateMetadata}; | ||
use crate::modules::function::invocation_utils::handle_function_parameters; |
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.
Please sort use
statements alphabetically, to simplify future maintenance.
src/modules/builtin/nameof.rs
Outdated
self.name = format!("{}__{}_v0", fun_decl.name, fun_decl.id); | ||
|
||
// Create an empty call to ensure referenced function gets built | ||
let fun_decl2 = fun_decl.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.
Since you're not using fun_decl
after this, it would be cleaner to shadow the variable name:
let fun_decl = fun_decl.clone();
I'm still not entirely happy with the hard-coded "v0" in your code change. However, I suggest that we defer further review on this PR until @Ph0enixKM's PR is merged, because AIUI it touches Bash variable name generation, and will consequently have an impact on this PR. |
}; | ||
Ok(()) | ||
} else if let Some(fun_decl) = meta.get_fun_declaration(&name) { | ||
self.name = format!("{}__{}_v0", fun_decl.name, fun_decl.id); |
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.
@Ph0enixKM is there even a way to properly select a variation of a function? i honestly have no idea how to go around this. hardcoding is definitely not the way for obvious reasons
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.
Yeah. Now since we're on a different architecture, we can slowly start to build centralized system that names these functions a certain way and only ask the system for the appropriate name here
@Thesola10 can you update with the feedback and the latest changes? |
Fixes #673.
Proof-of-concept, feedback is welcome!