Files
swift-mirror/include/swift/AST/StmtNodes.def
Joe Groff cb1f81db84 Make assignment an expression.
Change AssignStmt into AssignExpr; this will make assignment behave more consistently with assignment-like operators, and is a first step toward integrating '=' parsing with SequenceExpr resolution so that '=' can obey precedence rules. This also nicely simplifies the AST representation of c-style ForStmts; the initializer and increment need only be Expr* instead of awkward Expr*/AssignStmt* unions.

This doesn't actually change any user-visible behavior yet; AssignExpr is still only parsed at statement scope, and typeCheckAssignment is still segregrated from the constraint checker at large. (In particular, a PipeClosureExpr containing a single assign expr in its body still doesn't use the assign expr to resolve its own type.) The parsing issue will be addressed by handling '=' during SequenceExpr resolution. typeCheckAssignment can hopefully be reworked to work within the constraint checker too.

Swift SVN r5500
2013-06-06 22:18:54 +00:00

47 lines
1.5 KiB
C++

//===--- StmtNodes.def - Swift Statement AST Metaprogramming ----*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This file defines macros used for macro-metaprogramming with statements.
//
//===----------------------------------------------------------------------===//
/// STMT(Id, Parent)
/// If the statement node is not abstract, its enumerator value is
/// StmtKind::Id. The node's class name is Id##Stmt, and the name of
/// its base class (in the Stmt hierarchy) is Parent.
/// An abstract statement node is an abstract base class in the hierarchy;
/// it is never a most-derived type, and it does not have an enumerator in
/// StmtKind.
///
/// Most metaprograms do not care about abstract statements, so the default
/// is to ignore them.
#ifndef ABSTRACT_STMT
#define ABSTRACT_STMT(Id, Parent)
#endif
STMT(Brace, Stmt)
STMT(Return, Stmt)
STMT(If, Stmt)
STMT(While, Stmt)
STMT(DoWhile, Stmt)
STMT(For, Stmt)
STMT(ForEach, Stmt)
STMT(Switch, Stmt)
STMT(Case, Stmt)
STMT(Break, Stmt)
STMT(Continue, Stmt)
STMT(Fallthrough, Stmt)
#undef ABSTRACT_STMT
#undef STMT