Start adding builtins to SemanticsIR (#2356)

This starts adding builtins with TypeType and IntegerLiteralType. Note, structurally that's all they are, and not directly accessible in any way.

Adds a type field to SemanticsNode. Now, IntegerLiteralType can be identified as having type=TypeType, and IntegerLiteral as type=IntegerLiteralType. The current iteration doesn't do anything for type propagation, because I wanted to avoid making this too big.

This also switches the Identifier IR to instead BindName, with some side-effects. I'd been trying to think how to provide a name for TypeType, and switching around how things worked seemed like a better approach. And while I think it's the right direction (e.g., alias should just be a BindName), I also realized I don't need to name TypeType: there's probably a keyword to refer to the builtin, so it shouldn't use regular name lookup.
This commit is contained in:
Jon Ross-Perkins
2022-10-28 14:16:51 -07:00
committed by GitHub
parent 0219218b01
commit 57090142e8
18 changed files with 410 additions and 81 deletions
@@ -5,7 +5,6 @@
#ifndef CARBON_TOOLCHAIN_SEMANTICS_SEMANTICS_PARSE_TREE_HANDLER_H_
#define CARBON_TOOLCHAIN_SEMANTICS_SEMANTICS_PARSE_TREE_HANDLER_H_
#include "common/check.h"
#include "toolchain/parser/parse_tree.h"
#include "toolchain/semantics/semantics_ir.h"
#include "toolchain/semantics/semantics_node.h"
@@ -30,6 +29,9 @@ class SemanticsParseTreeHandler {
llvm::Optional<SemanticsNodeId> result_id;
};
// Adds an identifier for a DeclaredName node, returning its reference.
auto AddIdentifier(ParseTree::Node decl_node) -> SemanticsIdentifierId;
// Adds a node to the current block, returning the produced ID.
auto AddNode(SemanticsNode node) -> SemanticsNodeId;