Files
carbon-lang/toolchain/semantics/semantics_node_kind.def
T
Jon Ross-Perkins 1f8508204b Rewrite semantics towards a more pure instruction model (#2320)
This rewrites semantics towards a more pure instruction model, in pursuit of the simple instruction-style output.

I think I can get this approach to type-check as it goes along, but obviously this change doesn't prove that yet. I'm separating it out because it's a large rewrite of the semantics structure, tossing out a lot of what was there before. But I think it does help towards several requests, like setting up a clear path for consolidating duplicate identifiers and making the node style more standardized.

I expect to need to pass multiple args to function calls, that'd probably be storing vectors of args similar to how I'm showing identifiers and integer literals stored.

This removes the semantics namespace because (a) it was getting annoying writing the `::` everywhere, and (b) I think the leaning with Carbon is to avoid namespaces (@chandlerc asked not to put SemanticsIR/SemanticsFactory in a namespace, which is the crux of the issue). But, it's still necessary to avoid name conflicts so I just prefix everything with "Semantics" (still a lot of typing, but no `::`).
2022-10-20 12:50:10 -07:00

51 lines
1.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
//
// Note that 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. The x-macro for this header is `CARBON_PARSE_NODE_KIND`. The
// definition provided will be removed at the end of this file to clean up.
#ifndef CARBON_SEMANTICS_NODE_KIND
#error "Must define the x-macro to use this file."
#endif
// No args.
CARBON_SEMANTICS_NODE_KIND(Invalid, no_args)
// Two nodes: lhs and rhs.
CARBON_SEMANTICS_NODE_KIND(BinaryOperatorAdd, two_nodes)
// No args.
CARBON_SEMANTICS_NODE_KIND(CodeBlockStart, no_args)
// No args.
CARBON_SEMANTICS_NODE_KIND(CodeBlockEnd, no_args)
// One node: the name.
// TODO: Add a declaration scope as a second arg.
CARBON_SEMANTICS_NODE_KIND(FunctionDeclaration, one_node)
// One node: the FunctionDeclaration.
CARBON_SEMANTICS_NODE_KIND(FunctionDefinitionStart, one_node)
// No args.
CARBON_SEMANTICS_NODE_KIND(FunctionDefinitionEnd, no_args)
// The decalred IdentifierId.
CARBON_SEMANTICS_NODE_KIND(Identifier, identifier)
// The declared IntegerLiteralId.
CARBON_SEMANTICS_NODE_KIND(IntegerLiteral, integer_literal)
// No args.
CARBON_SEMANTICS_NODE_KIND(Return, no_args)
// One node: the return expression.
CARBON_SEMANTICS_NODE_KIND(ReturnExpression, one_node)
#undef CARBON_SEMANTICS_NODE_KIND