119370Spst//===--- Job.h - Commands to Execute ----------------------------*- C++ -*-===// 219370Spst// 319370Spst// The LLVM Compiler Infrastructure 498944Sobrien// 519370Spst// This file is distributed under the University of Illinois Open Source 698944Sobrien// License. See LICENSE.TXT for details. 798944Sobrien// 898944Sobrien//===----------------------------------------------------------------------===// 998944Sobrien 1019370Spst#ifndef CLANG_DRIVER_JOB_H_ 1198944Sobrien#define CLANG_DRIVER_JOB_H_ 1298944Sobrien 1398944Sobrien#include "clang/Basic/LLVM.h" 1498944Sobrien#include "clang/Driver/Util.h" 1519370Spst#include "llvm/ADT/SmallVector.h" 1698944Sobrien 1798944Sobriennamespace clang { 1898944Sobriennamespace driver { 1998944Sobrienclass Command; 2019370Spstclass Tool; 2119370Spst 2219370Spstclass Job { 2319370Spstpublic: 24130803Smarcel enum JobClass { 2519370Spst CommandClass, 2619370Spst JobListClass 27 }; 28 29private: 30 JobClass Kind; 31 32protected: 33 Job(JobClass _Kind) : Kind(_Kind) {} 34public: 35 virtual ~Job(); 36 37 JobClass getKind() const { return Kind; } 38 39 /// addCommand - Append a command to the current job, which must be 40 /// either a piped job or a job list. 41 void addCommand(Command *C); 42}; 43 44 /// Command - An executable path/name and argument vector to 45 /// execute. 46class Command : public Job { 47 virtual void anchor(); 48 49 /// Source - The action which caused the creation of this job. 50 const Action &Source; 51 52 /// Tool - The tool which caused the creation of this job. 53 const Tool &Creator; 54 55 /// The executable to run. 56 const char *Executable; 57 58 /// The list of program arguments (not including the implicit first 59 /// argument, which will be the executable). 60 ArgStringList Arguments; 61 62public: 63 Command(const Action &_Source, const Tool &_Creator, const char *_Executable, 64 const ArgStringList &_Arguments); 65 66 /// getSource - Return the Action which caused the creation of this job. 67 const Action &getSource() const { return Source; } 68 69 /// getCreator - Return the Tool which caused the creation of this job. 70 const Tool &getCreator() const { return Creator; } 71 72 const char *getExecutable() const { return Executable; } 73 74 const ArgStringList &getArguments() const { return Arguments; } 75 76 static bool classof(const Job *J) { 77 return J->getKind() == CommandClass; 78 } 79}; 80 81 /// JobList - A sequence of jobs to perform. 82class JobList : public Job { 83public: 84 typedef SmallVector<Job*, 4> list_type; 85 typedef list_type::size_type size_type; 86 typedef list_type::iterator iterator; 87 typedef list_type::const_iterator const_iterator; 88 89private: 90 list_type Jobs; 91 92public: 93 JobList(); 94 virtual ~JobList(); 95 96 /// Add a job to the list (taking ownership). 97 void addJob(Job *J) { Jobs.push_back(J); } 98 99 /// Clear the job list. 100 void clear(); 101 102 const list_type &getJobs() const { return Jobs; } 103 104 size_type size() const { return Jobs.size(); } 105 iterator begin() { return Jobs.begin(); } 106 const_iterator begin() const { return Jobs.begin(); } 107 iterator end() { return Jobs.end(); } 108 const_iterator end() const { return Jobs.end(); } 109 110 static bool classof(const Job *J) { 111 return J->getKind() == JobListClass; 112 } 113}; 114 115} // end namespace driver 116} // end namespace clang 117 118#endif 119