1 //===--- Job.h - Commands to Execute ----------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef CLANG_DRIVER_JOB_H_
11 #define CLANG_DRIVER_JOB_H_
13 #include "clang/Driver/Util.h"
14 #include "llvm/ADT/SmallVector.h"
16 #include "llvm/Support/Casting.h"
19 using llvm::cast_or_null;
21 using llvm::dyn_cast_or_null;
39 Job(JobClass _Kind) : Kind(_Kind) {}
43 JobClass getKind() const { return Kind; }
45 /// addCommand - Append a command to the current job, which must be
46 /// either a piped job or a job list.
47 void addCommand(Command *C);
49 static bool classof(const Job *) { return true; }
52 /// Command - An executable path/name and argument vector to
54 class Command : public Job {
55 /// Source - The action which caused the creation of this job.
58 /// Tool - The tool which caused the creation of this job.
61 /// The executable to run.
62 const char *Executable;
64 /// The list of program arguments (not including the implicit first
65 /// argument, which will be the executable).
66 ArgStringList Arguments;
69 Command(const Action &_Source, const Tool &_Creator, const char *_Executable,
70 const ArgStringList &_Arguments);
72 /// getSource - Return the Action which caused the creation of this job.
73 const Action &getSource() const { return Source; }
75 /// getCreator - Return the Tool which caused the creation of this job.
76 const Tool &getCreator() const { return Creator; }
78 const char *getExecutable() const { return Executable; }
80 const ArgStringList &getArguments() const { return Arguments; }
82 static bool classof(const Job *J) {
83 return J->getKind() == CommandClass;
85 static bool classof(const Command *) { return true; }
88 /// JobList - A sequence of jobs to perform.
89 class JobList : public Job {
91 typedef llvm::SmallVector<Job*, 4> list_type;
92 typedef list_type::size_type size_type;
93 typedef list_type::iterator iterator;
94 typedef list_type::const_iterator const_iterator;
103 /// Add a job to the list (taking ownership).
104 void addJob(Job *J) { Jobs.push_back(J); }
106 const list_type &getJobs() const { return Jobs; }
108 size_type size() const { return Jobs.size(); }
109 iterator begin() { return Jobs.begin(); }
110 const_iterator begin() const { return Jobs.begin(); }
111 iterator end() { return Jobs.end(); }
112 const_iterator end() const { return Jobs.end(); }
114 static bool classof(const Job *J) {
115 return J->getKind() == JobListClass;
117 static bool classof(const JobList *) { return true; }
120 } // end namespace driver
121 } // end namespace clang