mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Start doing name lookup for references (#2472)
When binding a name, add it to name lookup. On NameReference nodes, use name lookup. - Switches from "identifiers" to the more generic "strings". Not strictly necessary here, but it's the overall direction I think we've agreed upon and wanted to do it while building more support out. - Starts doing deduplication of strings. - On BindName, registers names with name lookup. - Does name lookup based on the deduplicated string. - Per discussion with zygoloid, design is intended to be constant-time lookup regardless of the number of parent scopes. - Adds scopes so that we can track names which will be deregistered from lookup.
This commit is contained in:
@@ -87,13 +87,6 @@ auto SemanticsIR::Print(llvm::raw_ostream& out) const -> void {
|
||||
}
|
||||
out << "},\n";
|
||||
|
||||
out << "identifiers = {\n";
|
||||
for (int32_t i = 0; i < static_cast<int32_t>(identifiers_.size()); ++i) {
|
||||
out.indent(Indent);
|
||||
out << SemanticsIdentifierId(i) << " = \"" << identifiers_[i] << "\";\n";
|
||||
}
|
||||
out << "},\n";
|
||||
|
||||
out << "integer_literals = {\n";
|
||||
for (int32_t i = 0; i < static_cast<int32_t>(integer_literals_.size()); ++i) {
|
||||
out.indent(Indent);
|
||||
@@ -102,6 +95,13 @@ auto SemanticsIR::Print(llvm::raw_ostream& out) const -> void {
|
||||
}
|
||||
out << "},\n";
|
||||
|
||||
out << "strings = {\n";
|
||||
for (int32_t i = 0; i < static_cast<int32_t>(strings_.size()); ++i) {
|
||||
out.indent(Indent);
|
||||
out << SemanticsStringId(i) << " = \"" << strings_[i] << "\";\n";
|
||||
}
|
||||
out << "},\n";
|
||||
|
||||
out << "node_blocks = {\n";
|
||||
for (int32_t i = 0; i < static_cast<int32_t>(node_blocks_.size()); ++i) {
|
||||
out.indent(Indent);
|
||||
|
||||
Reference in New Issue
Block a user