|
@@ -33,7 +33,8 @@ struct SemanticsNodeId : public IndexBase {
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-constexpr SemanticsNodeId SemanticsNodeId::Invalid = SemanticsNodeId();
|
|
|
|
|
|
|
+constexpr SemanticsNodeId SemanticsNodeId::Invalid =
|
|
|
|
|
+ SemanticsNodeId(SemanticsNodeId::InvalidIndex);
|
|
|
|
|
|
|
|
// Uses the cross-reference node ID for a builtin. This relies on SemanticsIR
|
|
// Uses the cross-reference node ID for a builtin. This relies on SemanticsIR
|
|
|
// guarantees for builtin cross-reference placement.
|
|
// guarantees for builtin cross-reference placement.
|
|
@@ -88,7 +89,7 @@ struct SemanticsNodeBlockId : public IndexBase {
|
|
|
constexpr SemanticsNodeBlockId SemanticsNodeBlockId::Empty =
|
|
constexpr SemanticsNodeBlockId SemanticsNodeBlockId::Empty =
|
|
|
SemanticsNodeBlockId(0);
|
|
SemanticsNodeBlockId(0);
|
|
|
constexpr SemanticsNodeBlockId SemanticsNodeBlockId::Invalid =
|
|
constexpr SemanticsNodeBlockId SemanticsNodeBlockId::Invalid =
|
|
|
- SemanticsNodeBlockId();
|
|
|
|
|
|
|
+ SemanticsNodeBlockId(SemanticsNodeBlockId::InvalidIndex);
|
|
|
|
|
|
|
|
// Type-safe storage of strings.
|
|
// Type-safe storage of strings.
|
|
|
struct SemanticsStringId : public IndexBase {
|
|
struct SemanticsStringId : public IndexBase {
|
|
@@ -144,8 +145,8 @@ class SemanticsNode {
|
|
|
SemanticsNodeId type) -> SemanticsNode {
|
|
SemanticsNodeId type) -> SemanticsNode {
|
|
|
// Builtins won't have a ParseTree node associated, so we provide the
|
|
// Builtins won't have a ParseTree node associated, so we provide the
|
|
|
// default invalid one.
|
|
// default invalid one.
|
|
|
- return SemanticsNode(ParseTree::Node(), SemanticsNodeKind::Builtin, type,
|
|
|
|
|
- builtin_kind.AsInt());
|
|
|
|
|
|
|
+ return SemanticsNode(ParseTree::Node::Invalid, SemanticsNodeKind::Builtin,
|
|
|
|
|
+ type, builtin_kind.AsInt());
|
|
|
}
|
|
}
|
|
|
auto GetAsBuiltin() const -> SemanticsBuiltinKind {
|
|
auto GetAsBuiltin() const -> SemanticsBuiltinKind {
|
|
|
CARBON_CHECK(kind_ == SemanticsNodeKind::Builtin);
|
|
CARBON_CHECK(kind_ == SemanticsNodeKind::Builtin);
|
|
@@ -155,7 +156,7 @@ class SemanticsNode {
|
|
|
static auto MakeCodeBlock(ParseTree::Node parse_node,
|
|
static auto MakeCodeBlock(ParseTree::Node parse_node,
|
|
|
SemanticsNodeBlockId node_block) -> SemanticsNode {
|
|
SemanticsNodeBlockId node_block) -> SemanticsNode {
|
|
|
return SemanticsNode(parse_node, SemanticsNodeKind::CodeBlock,
|
|
return SemanticsNode(parse_node, SemanticsNodeKind::CodeBlock,
|
|
|
- SemanticsNodeId(), node_block.index);
|
|
|
|
|
|
|
+ SemanticsNodeId::Invalid, node_block.index);
|
|
|
}
|
|
}
|
|
|
auto GetAsCodeBlock() const -> SemanticsNodeBlockId {
|
|
auto GetAsCodeBlock() const -> SemanticsNodeBlockId {
|
|
|
CARBON_CHECK(kind_ == SemanticsNodeKind::CodeBlock);
|
|
CARBON_CHECK(kind_ == SemanticsNodeKind::CodeBlock);
|
|
@@ -180,7 +181,7 @@ class SemanticsNode {
|
|
|
SemanticsCallableId signature)
|
|
SemanticsCallableId signature)
|
|
|
-> SemanticsNode {
|
|
-> SemanticsNode {
|
|
|
return SemanticsNode(parse_node, SemanticsNodeKind::FunctionDeclaration,
|
|
return SemanticsNode(parse_node, SemanticsNodeKind::FunctionDeclaration,
|
|
|
- SemanticsNodeId(), signature.index);
|
|
|
|
|
|
|
+ SemanticsNodeId::Invalid, signature.index);
|
|
|
}
|
|
}
|
|
|
auto GetAsFunctionDeclaration() const -> SemanticsCallableId {
|
|
auto GetAsFunctionDeclaration() const -> SemanticsCallableId {
|
|
|
CARBON_CHECK(kind_ == SemanticsNodeKind::FunctionDeclaration);
|
|
CARBON_CHECK(kind_ == SemanticsNodeKind::FunctionDeclaration);
|
|
@@ -192,7 +193,8 @@ class SemanticsNode {
|
|
|
SemanticsNodeBlockId node_block)
|
|
SemanticsNodeBlockId node_block)
|
|
|
-> SemanticsNode {
|
|
-> SemanticsNode {
|
|
|
return SemanticsNode(parse_node, SemanticsNodeKind::FunctionDefinition,
|
|
return SemanticsNode(parse_node, SemanticsNodeKind::FunctionDefinition,
|
|
|
- SemanticsNodeId(), decl.index, node_block.index);
|
|
|
|
|
|
|
+ SemanticsNodeId::Invalid, decl.index,
|
|
|
|
|
+ node_block.index);
|
|
|
}
|
|
}
|
|
|
auto GetAsFunctionDefinition() const
|
|
auto GetAsFunctionDefinition() const
|
|
|
-> std::pair<SemanticsNodeId, SemanticsNodeBlockId> {
|
|
-> std::pair<SemanticsNodeId, SemanticsNodeBlockId> {
|
|
@@ -225,7 +227,7 @@ class SemanticsNode {
|
|
|
// understand the type without checking, so it's not necessary but could be
|
|
// understand the type without checking, so it's not necessary but could be
|
|
|
// specified if needed.
|
|
// specified if needed.
|
|
|
return SemanticsNode(parse_node, SemanticsNodeKind::Return,
|
|
return SemanticsNode(parse_node, SemanticsNodeKind::Return,
|
|
|
- SemanticsNodeId());
|
|
|
|
|
|
|
+ SemanticsNodeId::Invalid);
|
|
|
}
|
|
}
|
|
|
auto GetAsReturn() const -> NoArgs {
|
|
auto GetAsReturn() const -> NoArgs {
|
|
|
CARBON_CHECK(kind_ == SemanticsNodeKind::Return);
|
|
CARBON_CHECK(kind_ == SemanticsNodeKind::Return);
|
|
@@ -253,8 +255,8 @@ class SemanticsNode {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
SemanticsNode()
|
|
SemanticsNode()
|
|
|
- : SemanticsNode(ParseTree::Node(), SemanticsNodeKind::Invalid,
|
|
|
|
|
- SemanticsNodeId()) {}
|
|
|
|
|
|
|
+ : SemanticsNode(ParseTree::Node::Invalid, SemanticsNodeKind::Invalid,
|
|
|
|
|
+ SemanticsNodeId::Invalid) {}
|
|
|
|
|
|
|
|
auto parse_node() const -> ParseTree::Node { return parse_node_; }
|
|
auto parse_node() const -> ParseTree::Node { return parse_node_; }
|
|
|
auto kind() const -> SemanticsNodeKind { return kind_; }
|
|
auto kind() const -> SemanticsNodeKind { return kind_; }
|