Files
swift-mirror/include/swift/AST/AvailabilitySpec.h
Devin Coughlin 5a9ccc5ab2 Add ASTDumper support for AvailabilityQueryExpr
This patch also moves some static utility methods involving PlatformKind out of Attr.h and into PlatformKind.h.


Swift SVN r21896
2014-09-12 00:13:48 +00:00

81 lines
2.8 KiB
C++

//===--- AvailabilitySpec.h - Swift Availability Query ASTs -----*- 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 the availability specification AST classes.
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_AST_AVAILABILITY_SPEC_H
#define SWIFT_AST_AVAILABILITY_SPEC_H
#include "swift/AST/Identifier.h"
#include "swift/Basic/SourceLoc.h"
#include "swift/AST/PlatformKind.h"
#include "clang/Basic/VersionTuple.h"
namespace swift {
class ASTContext;
enum class VersionComparison { GreaterThanEqual };
/// \brief An availability specification that guards execution based on the
/// run-time platform and version, e.g., OSX >= 10.10.
class VersionConstraintAvailabilitySpec {
PlatformKind Platform;
SourceLoc PlatformLoc;
VersionComparison Comparison;
SourceLoc ComparisonLoc;
clang::VersionTuple Version;
SourceRange VersionSrcRange;
public:
VersionConstraintAvailabilitySpec(PlatformKind Platform,
SourceLoc PlatformLoc,
VersionComparison Comparison,
SourceLoc ComparisonLoc,
clang::VersionTuple Version,
SourceRange VersionSrcRange)
: Platform(Platform), PlatformLoc(PlatformLoc), Comparison(Comparison),
ComparisonLoc(ComparisonLoc), Version(Version),
VersionSrcRange(VersionSrcRange) {}
/// The required platform.
PlatformKind getPlatform() const { return Platform; }
SourceLoc getPlatformLoc() const { return PlatformLoc; }
/// The comparison operator for the specified version.
VersionComparison getComparison() const { return Comparison; }
SourceLoc getConstraintLoc() const { return ComparisonLoc; }
StringRef getComparisonAsString() const;
// The platform version to compare against.
clang::VersionTuple getVersion() const { return Version; }
SourceRange getVersionSrcRange() const { return VersionSrcRange; }
SourceRange getSourceRange() const;
void print(raw_ostream &OS, unsigned Indent) const;
void *
operator new(size_t Bytes, ASTContext &C,
unsigned Alignment = alignof(VersionConstraintAvailabilitySpec));
void *operator new(size_t Bytes) throw() = delete;
void operator delete(void *Data) throw() = delete;
};
} // end namespace swift
#endif