mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 07:54:41 +01:00
Bare-bones support for forward-declared classes. (#3294)
This is mostly scaffolding, but is just about enough for pointers to classes to work properly as types.
This commit is contained in:
@@ -108,6 +108,11 @@ class NodeStack {
|
||||
RequireParseKind<RequiredParseKind>(back.first);
|
||||
return back;
|
||||
}
|
||||
if constexpr (RequiredIdKind == IdKind::ClassId) {
|
||||
auto back = PopWithParseNode<SemIR::ClassId>();
|
||||
RequireParseKind<RequiredParseKind>(back.first);
|
||||
return back;
|
||||
}
|
||||
if constexpr (RequiredIdKind == IdKind::StringId) {
|
||||
auto back = PopWithParseNode<SemIR::StringId>();
|
||||
RequireParseKind<RequiredParseKind>(back.first);
|
||||
@@ -154,6 +159,9 @@ class NodeStack {
|
||||
if constexpr (RequiredIdKind == IdKind::FunctionId) {
|
||||
return back.id<SemIR::FunctionId>();
|
||||
}
|
||||
if constexpr (RequiredIdKind == IdKind::ClassId) {
|
||||
return back.id<SemIR::ClassId>();
|
||||
}
|
||||
if constexpr (RequiredIdKind == IdKind::StringId) {
|
||||
return back.id<SemIR::StringId>();
|
||||
}
|
||||
@@ -177,6 +185,7 @@ class NodeStack {
|
||||
NodeId,
|
||||
NodeBlockId,
|
||||
FunctionId,
|
||||
ClassId,
|
||||
StringId,
|
||||
TypeId,
|
||||
// No associated ID type.
|
||||
@@ -272,6 +281,7 @@ class NodeStack {
|
||||
case Parse::NodeKind::Name:
|
||||
return IdKind::StringId;
|
||||
case Parse::NodeKind::ArrayExpressionSemi:
|
||||
case Parse::NodeKind::ClassIntroducer:
|
||||
case Parse::NodeKind::CodeBlockStart:
|
||||
case Parse::NodeKind::FunctionIntroducer:
|
||||
case Parse::NodeKind::IfStatementElse:
|
||||
@@ -302,6 +312,9 @@ class NodeStack {
|
||||
if constexpr (std::is_same_v<IdT, SemIR::FunctionId>) {
|
||||
return IdKind::FunctionId;
|
||||
}
|
||||
if constexpr (std::is_same_v<IdT, SemIR::ClassId>) {
|
||||
return IdKind::ClassId;
|
||||
}
|
||||
if constexpr (std::is_same_v<IdT, SemIR::StringId>) {
|
||||
return IdKind::StringId;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user