Files
swift-mirror/include/swift/Serialization/SerializedSILLoader.h
Manman Ren eaad8df51a SILSerializer: handle SILWitnessTable.
We add two records in sil_block to specify a witness table record and a method
entry record. Out of the four entry types, only "Method" is handled in this
commit.

Two records are also added to sil_index_block to search for a specific witness
table given a unique identifier. The interface lookupWitnessTable is not
implemented yet.

Right now, we serialize a witness table only when sil-serialize-all is on and
deserialize all witness tables in the module when sil-link-all is on.

rdar://15722175


Swift SVN r13000
2014-01-27 19:30:43 +00:00

85 lines
2.8 KiB
C++

//===--- SerializedSILLoader.h - Handle SIL section in modules --*- 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
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_SERIALIZATION_SILLOADER_H
#define SWIFT_SERIALIZATION_SILLOADER_H
namespace swift {
class ASTContext;
class Module;
class SILDeserializer;
class SILFunction;
class SILGlobalVariable;
class SILModule;
class SILVTable;
class SILWitnessTable;
/// Maintains a list of SILDeserializer, one for each serialized modules
/// in ASTContext. It provides lookupSILFunction that will perform lookup
/// on each SILDeserializer.
class SerializedSILLoader {
public:
class Callback {
public:
/// Observe that we deserialized a function declaration.
virtual void didDeserialize(Module *M, SILFunction *fn) {}
/// Observe that we successfully deserialized a function body.
virtual void didDeserializeBody(Module *M, SILFunction *fn) {}
/// Observe that we deserialized a global variable declaration.
virtual void didDeserialize(Module *M, SILGlobalVariable *var) {}
/// Observe that we deserialized a v-table declaration.
virtual void didDeserialize(Module *M, SILVTable *vtable) {}
/// Observe that we deserialized a witness-table declaration.
virtual void didDeserialize(Module *M, SILWitnessTable *wtable) {}
virtual ~Callback() = default;
private:
virtual void _anchor();
};
private:
std::vector<std::unique_ptr<SILDeserializer> > LoadedSILSections;
explicit SerializedSILLoader(ASTContext &ctx, SILModule *SILMod,
Callback *callback);
public:
/// Create a new loader.
///
/// \param callback - not owned by the loader
static SerializedSILLoader *create(ASTContext &ctx, SILModule *SILMod,
Callback *callback) {
return new SerializedSILLoader(ctx, SILMod, callback);
}
~SerializedSILLoader();
SILFunction *lookupSILFunction(SILFunction *Callee);
SILVTable *lookupVTable(Identifier Name);
/// Deserialize all VTables in all SILModules.
void getAllVTables();
/// Deserialize all WitnessTables in all SILModules.
void getAllWitnessTables();
SerializedSILLoader(const SerializedSILLoader &) = delete;
SerializedSILLoader(SerializedSILLoader &&) = delete;
SerializedSILLoader &operator=(const SerializedSILLoader &) = delete;
SerializedSILLoader &operator=(SerializedSILLoader &&) = delete;
};
} // end namespace swift
#endif