forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConstraintGraphScope.h
58 lines (49 loc) · 2.08 KB
/
ConstraintGraphScope.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//===--- ConstraintGraphScope.h - Constraint Graph Scope --------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2016 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 the \c ConstraintGraphScope class, an RAII object that
// introduces a new scope in which changes to the constraint graph are
// capture and will be reverted when the scope disappears.
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_SEMA_CONSTRAINT_GRAPH_SCOPE_H
#define SWIFT_SEMA_CONSTRAINT_GRAPH_SCOPE_H
namespace swift {
namespace constraints {
class ConstraintGraph;
/// RAII object that introduces a new constraint graph scope to capture
/// modifications made to the constraint graph.
///
/// Scopes are arranged in a stack, where the active scope is the top of the
/// stack. All changes made to the constraint graph are recorded in the
/// active scope. When the scope is popped (via the RAII object destructor),
/// those changes are reverted.
class ConstraintGraphScope {
ConstraintGraph &CG;
/// The parent scope, or null if this is the topmost scope.
ConstraintGraphScope *ParentScope;
/// The number of recorded changes that existed at the time this scope was
/// formed.
///
/// When this scope exits, any changes beyond this will be reverted to
/// bring the graph back to its state prior to the introduction of this
/// variable.
unsigned NumChanges;
ConstraintGraphScope(const ConstraintGraphScope&) = delete;
ConstraintGraphScope &operator=(const ConstraintGraphScope&) = delete;
public:
explicit ConstraintGraphScope(ConstraintGraph &CG);
~ConstraintGraphScope();
};
} // end namespace swift::constraints
} // end namespace swift
#endif // LLVM_SWIFT_SEMA_CONSTRAINT_GRAPH_SCOPE_H