1 //===- lld/Core/Node.h - Input file class -----------------------*- C++ -*-===//
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
12 /// The classes in this file represents inputs to the linker.
14 //===----------------------------------------------------------------------===//
16 #ifndef LLD_CORE_NODE_H
17 #define LLD_CORE_NODE_H
19 #include "lld/Core/File.h"
25 // A Node represents a FileNode or other type of Node. In the latter case,
26 // the node contains meta information about the input file list.
27 // Currently only GroupEnd node is defined as a meta node.
30 enum class Kind { File, GroupEnd };
32 explicit Node(Kind type) : _kind(type) {}
33 virtual ~Node() = default;
35 virtual Kind kind() const { return _kind; }
41 // This is a marker for --end-group. getSize() returns the number of
42 // files between the corresponding --start-group and this marker.
43 class GroupEnd : public Node {
45 explicit GroupEnd(int size) : Node(Kind::GroupEnd), _size(size) {}
47 int getSize() const { return _size; }
49 static bool classof(const Node *a) {
50 return a->kind() == Kind::GroupEnd;
57 // A container of File.
58 class FileNode : public Node {
60 explicit FileNode(std::unique_ptr<File> f)
61 : Node(Node::Kind::File), _file(std::move(f)) {}
63 static bool classof(const Node *a) {
64 return a->kind() == Node::Kind::File;
67 File *getFile() { return _file.get(); }
70 std::unique_ptr<File> _file;
73 } // end namespace lld
75 #endif // LLD_CORE_NODE_H