mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-02 17:52:58 +01:00
Add semantic analysis and semantics IR building for `if` expressions, and add the first parts of control flow handling to semantics IR. After discussion with @chandlerc, use [block arguments](https://en.wikipedia.org/wiki/Static_single-assignment_form#Block_arguments) to convey values from the two arms of the `if` to the result. For now, only a single block argument is supported, but we should revisit this as we explore more of the requirements of the Semantics IR form. Functions can now contain multiple code blocks, so grab the entry block up-front instead of assuming the entry block will be at the top of the block stack when we reach the end of function emission. Add trivial support for `bool` type literal, because without it we can't write testcases.
47 lines
1.6 KiB
Modula-2
47 lines
1.6 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.
|
|
|
|
#ifndef CARBON_SEMANTICS_NODE_KIND
|
|
#error "Must define the x-macro to use this file."
|
|
#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(Branch)
|
|
CARBON_SEMANTICS_NODE_KIND(BranchIf)
|
|
CARBON_SEMANTICS_NODE_KIND(BranchWithArg)
|
|
CARBON_SEMANTICS_NODE_KIND(Builtin)
|
|
CARBON_SEMANTICS_NODE_KIND(Call)
|
|
CARBON_SEMANTICS_NODE_KIND(CodeBlock)
|
|
CARBON_SEMANTICS_NODE_KIND(FunctionDeclaration)
|
|
CARBON_SEMANTICS_NODE_KIND(IntegerLiteral)
|
|
CARBON_SEMANTICS_NODE_KIND(RealLiteral)
|
|
CARBON_SEMANTICS_NODE_KIND(Return)
|
|
CARBON_SEMANTICS_NODE_KIND(ReturnExpression)
|
|
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(VarStorage)
|
|
|
|
#undef CARBON_SEMANTICS_NODE_KIND
|