mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 21:30:12 +01:00
This ensures that equal forms always have equal representations (because the index depends on how the form is used, not on the value of the form itself). As a byproduct, also remove `NextCallParamIndex`. --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Nicholas Bishop <nicholasbishop@google.com> Co-authored-by: Jon Ross-Perkins <jperkins@google.com> Co-authored-by: Dana Jansens <danakj@orodu.net> Co-authored-by: Boaz Brickner <brickner@google.com> Co-authored-by: Richard Smith <richard@metafoo.co.uk> Co-authored-by: Carbon Infra Bot <carbon-external-infra@google.com> Co-authored-by: MK4070 <60286678+MK4070@users.noreply.github.com> Co-authored-by: Christopher Di Bella <cjdb@google.com>
65 lines
2.3 KiB
C++
65 lines
2.3 KiB
C++
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
#include "toolchain/check/context.h"
|
|
#include "toolchain/check/convert.h"
|
|
#include "toolchain/check/handle.h"
|
|
#include "toolchain/check/inst.h"
|
|
#include "toolchain/parse/node_category.h"
|
|
|
|
namespace Carbon::Check {
|
|
|
|
auto HandleParseNode(Context& context, Parse::RefPrimitiveFormId node_id)
|
|
-> bool {
|
|
auto [type_node_id, type_inst_id] = context.node_stack().PopExprWithNodeId();
|
|
auto type_expr = ExprAsType(context, type_node_id, type_inst_id);
|
|
auto inst_id =
|
|
AddInst<SemIR::RefForm>(context, node_id,
|
|
{.type_id = SemIR::FormType::TypeId,
|
|
.type_component_inst_id = type_expr.inst_id});
|
|
context.node_stack().Push(node_id, inst_id);
|
|
return true;
|
|
}
|
|
|
|
auto HandleParseNode(Context& context, Parse::ValPrimitiveFormId node_id)
|
|
-> bool {
|
|
auto [type_node_id, type_inst_id] = context.node_stack().PopExprWithNodeId();
|
|
auto type_expr = ExprAsType(context, type_node_id, type_inst_id);
|
|
auto inst_id =
|
|
AddInst<SemIR::ValueForm>(context, node_id,
|
|
{.type_id = SemIR::FormType::TypeId,
|
|
.type_component_inst_id = type_expr.inst_id});
|
|
context.node_stack().Push(node_id, inst_id);
|
|
return true;
|
|
}
|
|
|
|
auto HandleParseNode(Context& context, Parse::VarPrimitiveFormId node_id)
|
|
-> bool {
|
|
auto [type_node_id, type_inst_id] = context.node_stack().PopExprWithNodeId();
|
|
auto type_expr = ExprAsType(context, type_node_id, type_inst_id);
|
|
auto inst_id =
|
|
AddInst<SemIR::InitForm>(context, node_id,
|
|
{.type_id = SemIR::FormType::TypeId,
|
|
.type_component_inst_id = type_expr.inst_id});
|
|
context.node_stack().Push(node_id, inst_id);
|
|
return true;
|
|
}
|
|
|
|
auto HandleParseNode(Context& /*context*/,
|
|
Parse::FormLiteralKeywordId /*node_id*/) -> bool {
|
|
return true;
|
|
}
|
|
|
|
auto HandleParseNode(Context& /*context*/,
|
|
Parse::FormLiteralOpenParenId /*node_id*/) -> bool {
|
|
return true;
|
|
}
|
|
|
|
auto HandleParseNode(Context& /*context*/, Parse::FormLiteralId /*node_id*/)
|
|
-> bool {
|
|
return true;
|
|
}
|
|
|
|
} // namespace Carbon::Check
|