mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Also, give each class hierarchy at least 8 bits for the 'Kind' field. In practice, no class hierarchy has more than 256 nodes, so this optimizees code generation to make isa/dyn_cast faster.
51 lines
1.6 KiB
C++
51 lines
1.6 KiB
C++
//===--- PatternNodes.def - Swift Pattern AST Metaprogramming ---*- C++ -*-===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See https://swift.org/LICENSE.txt for license information
|
|
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file defines macros used for macro-metaprogramming with patterns.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// PATTERN(Id, Parent)
|
|
/// The pattern's enumerator value is PatternKind::Id. The pattern's
|
|
/// class name is Id##Pattern, and the name of its base class is Parent.
|
|
#ifndef PATTERN
|
|
# error Included PatternNodes.def without defining PATTERN!
|
|
#endif
|
|
|
|
/// REFUTABLE_PATTERN(Id, Parent)
|
|
/// Matching this pattern can fail. These patterns cannot appear syntactically
|
|
/// in variable declarations, assignments, or function declarations.
|
|
#ifndef REFUTABLE_PATTERN
|
|
# define REFUTABLE_PATTERN(Id, Parent) PATTERN(Id, Parent)
|
|
#endif
|
|
|
|
#ifndef LAST_PATTERN
|
|
#define LAST_PATTERN(Id)
|
|
#endif
|
|
|
|
PATTERN(Paren, Pattern)
|
|
PATTERN(Tuple, Pattern)
|
|
PATTERN(Named, Pattern)
|
|
PATTERN(Any, Pattern)
|
|
PATTERN(Typed, Pattern)
|
|
PATTERN(Var, Pattern)
|
|
REFUTABLE_PATTERN(Is, Pattern)
|
|
REFUTABLE_PATTERN(EnumElement, Pattern)
|
|
REFUTABLE_PATTERN(OptionalSome, Pattern)
|
|
REFUTABLE_PATTERN(Bool, Pattern)
|
|
REFUTABLE_PATTERN(Expr, Pattern)
|
|
LAST_PATTERN(Expr)
|
|
|
|
#undef REFUTABLE_PATTERN
|
|
#undef PATTERN
|
|
#undef LAST_PATTERN
|