mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-16 17:28:11 +00:00
Refactor type canonicalization so that we can reuse the same code for building a `T*` expression and for forming the type of an `&x` expression. Add basic computation of expression category in order to check that we only take the address of durable reference expressions. This is currently computed on demand rather than being tracked as part of the semantics node, but in most cases can be determined by looking at only a single expression, so caching it in the node doesn't seem worthwhile yet. This decision should be revisited if we start doing more complex category calculations. Also add trivial lowering support, but it doesn't work properly yet because lowering doesn't yet take the expression category into account.
63 lines
2.5 KiB
Modula-2
63 lines
2.5 KiB
Modula-2
// 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
|
|
//
|
|
// This is an X-macro header. It does not use `#include` guards, and instead is
|
|
// designed to be `#include`ed after the x-macro is defined in order for its
|
|
// inclusion to expand to the desired output. Macro definitions are cleaned up
|
|
// at the end of this file.
|
|
//
|
|
// Supported x-macros are:
|
|
// - CARBON_SEMANTICS_NODE_KIND(Name)
|
|
// Defines a node kind.
|
|
// - CARBON_SEMANTICS_NODE_KIND_WITH_TERMINATOR_KIND(Name, TerminatorKind)
|
|
// Defines a node kind for a terminator node.
|
|
|
|
#ifndef CARBON_SEMANTICS_NODE_KIND
|
|
#error "Must define the x-macro to use this file."
|
|
#endif
|
|
|
|
#ifndef CARBON_SEMANTICS_NODE_KIND_WITH_TERMINATOR_KIND
|
|
#define CARBON_SEMANTICS_NODE_KIND_WITH_TERMINATOR_KIND(Name, TerminatorKind) \
|
|
CARBON_SEMANTICS_NODE_KIND(Name)
|
|
#endif
|
|
|
|
CARBON_SEMANTICS_NODE_KIND(Invalid)
|
|
|
|
// A cross-reference between IRs.
|
|
CARBON_SEMANTICS_NODE_KIND(CrossReference)
|
|
|
|
CARBON_SEMANTICS_NODE_KIND(AddressOf)
|
|
CARBON_SEMANTICS_NODE_KIND(Assign)
|
|
CARBON_SEMANTICS_NODE_KIND(BinaryOperatorAdd)
|
|
CARBON_SEMANTICS_NODE_KIND(BindName)
|
|
CARBON_SEMANTICS_NODE_KIND(BlockArg)
|
|
CARBON_SEMANTICS_NODE_KIND(BoolLiteral)
|
|
CARBON_SEMANTICS_NODE_KIND_WITH_TERMINATOR_KIND(Branch, Terminator)
|
|
CARBON_SEMANTICS_NODE_KIND_WITH_TERMINATOR_KIND(BranchIf, TerminatorSequence)
|
|
CARBON_SEMANTICS_NODE_KIND_WITH_TERMINATOR_KIND(BranchWithArg, Terminator)
|
|
CARBON_SEMANTICS_NODE_KIND(Builtin)
|
|
CARBON_SEMANTICS_NODE_KIND(Call)
|
|
CARBON_SEMANTICS_NODE_KIND(ConstType)
|
|
CARBON_SEMANTICS_NODE_KIND(FunctionDeclaration)
|
|
CARBON_SEMANTICS_NODE_KIND(Index)
|
|
CARBON_SEMANTICS_NODE_KIND(IntegerLiteral)
|
|
CARBON_SEMANTICS_NODE_KIND(Namespace)
|
|
CARBON_SEMANTICS_NODE_KIND(PointerType)
|
|
CARBON_SEMANTICS_NODE_KIND(RealLiteral)
|
|
CARBON_SEMANTICS_NODE_KIND_WITH_TERMINATOR_KIND(Return, Terminator)
|
|
CARBON_SEMANTICS_NODE_KIND_WITH_TERMINATOR_KIND(ReturnExpression, Terminator)
|
|
CARBON_SEMANTICS_NODE_KIND(StringLiteral)
|
|
CARBON_SEMANTICS_NODE_KIND(StructMemberAccess)
|
|
CARBON_SEMANTICS_NODE_KIND(StructType)
|
|
CARBON_SEMANTICS_NODE_KIND(StructTypeField)
|
|
CARBON_SEMANTICS_NODE_KIND(StructValue)
|
|
CARBON_SEMANTICS_NODE_KIND(StubReference)
|
|
CARBON_SEMANTICS_NODE_KIND(TupleType)
|
|
CARBON_SEMANTICS_NODE_KIND(TupleValue)
|
|
CARBON_SEMANTICS_NODE_KIND(UnaryOperatorNot)
|
|
CARBON_SEMANTICS_NODE_KIND(VarStorage)
|
|
|
|
#undef CARBON_SEMANTICS_NODE_KIND_WITH_TERMINATOR_KIND
|
|
#undef CARBON_SEMANTICS_NODE_KIND
|