mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-16 04:08:13 +00:00
Semantic handling for use of `T*` and `const T` as types.
There's no way to form values of these types yet, and no conversions for
them are supported.
Factor out the common code to canonicalize types using a folding set,
and switch to using the same folding set for all kinds of type by adding
the kind as part of the folding set key.
Improve type printing to not include the `as type` portion when the type
is printed in a context within another type where a conversion to `type`
is implied, as in `{}*` and pre-existing cases like `({}, {}) as type`
(which we used to print as `({} as type, {} as type}) as type`.
61 lines
2.4 KiB
Modula-2
61 lines
2.4 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(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(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
|