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:
Jon Ross-Perkins
2022-12-20 10:10:23 -08:00
committed by GitHub
parent 9299e51511
commit 9d234aa7e7
28 changed files with 615 additions and 134 deletions
+5 -4
View File
@@ -10,16 +10,17 @@
// CHECK:STDOUT: node_xref1 = xref(ir0, block0, node1);
// CHECK:STDOUT: node_xref2 = xref(ir0, block0, node2);
// CHECK:STDOUT: node_xref3 = xref(ir0, block0, node3);
// CHECK:STDOUT: },
// CHECK:STDOUT: identifiers = {
// CHECK:STDOUT: ident0 = "Foo";
// CHECK:STDOUT: node_xref4 = xref(ir1, block0, node1);
// CHECK:STDOUT: },
// CHECK:STDOUT: integer_literals = {
// CHECK:STDOUT: },
// CHECK:STDOUT: strings = {
// CHECK:STDOUT: str0 = "Foo";
// CHECK:STDOUT: },
// CHECK:STDOUT: node_blocks = {
// CHECK:STDOUT: block0 = {
// CHECK:STDOUT: node0 = FunctionDeclaration();
// CHECK:STDOUT: node1 = BindName(ident0, node0);
// CHECK:STDOUT: node1 = BindName(str0, node0);
// CHECK:STDOUT: node2 = FunctionDefinition(node0, block1);
// CHECK:STDOUT: },
// CHECK:STDOUT: block1 = {