mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Support build and target configurations
These changes add support for build and target configurations in the compiler. Build and target configurations, combined with the use of #if/#else/#endif allow for conditional compilation within declaration and statement contexts. Build configurations can be passed into the compiler via the new '-D' flag, or set within the LangOptions class. Target configurations are implicit, and currently only "os" and "arch" are supported. Swift SVN r14305
This commit is contained in:
@@ -39,6 +39,7 @@ static bool isResolvableScope(ScopeKind SK) {
|
||||
case ScopeKind::ConstructorBody:
|
||||
case ScopeKind::DestructorBody:
|
||||
case ScopeKind::Brace:
|
||||
case ScopeKind::ActiveConfigBlock:
|
||||
case ScopeKind::ForVars:
|
||||
case ScopeKind::ForeachVars:
|
||||
case ScopeKind::ClosureParams:
|
||||
@@ -56,13 +57,17 @@ Scope::Scope(Parser *P, ScopeKind SC):
|
||||
PrevResolvableDepth(SI.ResolvableDepth),
|
||||
Kind(SC) {
|
||||
assert(PrevScope || Kind == ScopeKind::TopLevel);
|
||||
if (SI.CurScope)
|
||||
Depth = SI.CurScope->Depth + 1;
|
||||
else
|
||||
Depth = 0;
|
||||
SI.CurScope = this;
|
||||
if (!isResolvableScope(Kind))
|
||||
SI.ResolvableDepth = Depth + 1;
|
||||
|
||||
// Active config blocks delegate to the enclosing scope.
|
||||
if (SC != ScopeKind::ActiveConfigBlock) {
|
||||
if (SI.CurScope)
|
||||
Depth = SI.CurScope->Depth + 1;
|
||||
else
|
||||
Depth = 0;
|
||||
SI.CurScope = this;
|
||||
if (!isResolvableScope(Kind))
|
||||
SI.ResolvableDepth = Depth + 1;
|
||||
}
|
||||
}
|
||||
|
||||
Scope::Scope(Parser *P, SavedScope &&SS):
|
||||
@@ -72,9 +77,13 @@ Scope::Scope(Parser *P, SavedScope &&SS):
|
||||
PrevResolvableDepth(SI.ResolvableDepth),
|
||||
Depth(SI.CurScope ? SI.CurScope->Depth + 1 : 0),
|
||||
Kind(SS.Kind) {
|
||||
SI.CurScope = this;
|
||||
if (!isResolvableScope(Kind))
|
||||
SI.ResolvableDepth = Depth + 1;
|
||||
|
||||
// Active config blocks delegate to the enclosing scope.
|
||||
if (SS.Kind != ScopeKind::ActiveConfigBlock) {
|
||||
SI.CurScope = this;
|
||||
if (!isResolvableScope(Kind))
|
||||
SI.ResolvableDepth = Depth + 1;
|
||||
}
|
||||
}
|
||||
|
||||
bool Scope::isResolvable() const {
|
||||
|
||||
Reference in New Issue
Block a user