mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-15 10:58:29 +00:00
Initial support for fn expressions. (#7893)
Support for `fn` expressions with the same feature set as `fn` declarations. In particular, there is no support for captures, positional parameters, `=>` bodies, or `auto` return types. Note that this results in two parse nodes for each `=>` token. That's a bug, but it matches the behavior of function declarations, and will be fixed in a follow-up change. Assisted-by: Gemini via Antigravity
This commit is contained in:
1 parent
66bf1415ac
commit
1b0a5709e6
24 files changed
+2015
-308
No files matched your search
@@ -158,6 +158,10 @@ class StepStack {
|
||||
|
||||
// Pushes all components of a qualified name (`A.B.C`) onto the stack.
|
||||
auto PushQualifiedName(NameScopeId name_scope_id, NameId name_id) -> void {
|
||||
if (!name_id.has_value()) {
|
||||
PushString("<unnamed>");
|
||||
return;
|
||||
}
|
||||
PushNameId(name_id);
|
||||
if (!qualified_names_) {
|
||||
return;
|
||||
@@ -671,8 +675,17 @@ class Stringifier {
|
||||
*out_ << "<C++ type " << clang_type.getAsString() << ">";
|
||||
}
|
||||
|
||||
auto StringifyInst(InstId /*inst_id*/, FunctionDecl inst) -> void {
|
||||
const auto& fn = sem_ir_->functions().Get(inst.function_id);
|
||||
step_stack_->PushQualifiedName(fn.parent_scope_id, fn.name_id);
|
||||
}
|
||||
|
||||
auto StringifyInst(InstId /*inst_id*/, FunctionType inst) -> void {
|
||||
const auto& fn = sem_ir_->functions().Get(inst.function_id);
|
||||
if (!fn.name_id.has_value()) {
|
||||
*out_ << "<type of function expression>";
|
||||
return;
|
||||
}
|
||||
*out_ << "<type of ";
|
||||
step_stack_->Push(
|
||||
StepStack::QualifiedNameItem{fn.parent_scope_id, fn.name_id}, ">");
|
||||
|
||||
Reference in new issue
Block a user