mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
A concrete conformance may involve conditional conformances, which are witness tables that we can access from the original conformance's one. We need to track metadata and be able to follow it in a metadata path.
47 lines
1.4 KiB
C++
47 lines
1.4 KiB
C++
//===--- WitnessIndex.h - Index into a witness table ------------*- 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 the WitnessIndex type, used for drilling into a
|
|
// protocol witness table or value witness table.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef SWIFT_IRGEN_WITNESSINDEX_H
|
|
#define SWIFT_IRGEN_WITNESSINDEX_H
|
|
|
|
#include "swift/IRGen/ValueWitness.h"
|
|
|
|
namespace swift {
|
|
namespace irgen {
|
|
|
|
/// A class which encapsulates an index into a witness table.
|
|
class WitnessIndex {
|
|
// Negative values are indexing into the private area of a protocol witness
|
|
// table.
|
|
int Value : 31;
|
|
unsigned IsPrefix : 1;
|
|
public:
|
|
WitnessIndex() = default;
|
|
WitnessIndex(ValueWitness index) : Value(int(index)) {}
|
|
explicit WitnessIndex(int index, bool isPrefix)
|
|
: Value(index), IsPrefix(isPrefix) {}
|
|
|
|
int getValue() const { return Value; }
|
|
|
|
bool isPrefix() const { return IsPrefix; }
|
|
};
|
|
|
|
} // end namespace irgen
|
|
} // end namespace swift
|
|
|
|
#endif
|