clang API Documentation
00001 //===--- Job.h - Commands to Execute ----------------------------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 00010 #ifndef CLANG_DRIVER_JOB_H_ 00011 #define CLANG_DRIVER_JOB_H_ 00012 00013 #include "clang/Driver/Util.h" 00014 #include "llvm/ADT/SmallVector.h" 00015 #include "clang/Basic/LLVM.h" 00016 00017 namespace clang { 00018 namespace driver { 00019 class Command; 00020 class Tool; 00021 00022 class Job { 00023 public: 00024 enum JobClass { 00025 CommandClass, 00026 JobListClass 00027 }; 00028 00029 private: 00030 JobClass Kind; 00031 00032 protected: 00033 Job(JobClass _Kind) : Kind(_Kind) {} 00034 public: 00035 virtual ~Job(); 00036 00037 JobClass getKind() const { return Kind; } 00038 00039 /// addCommand - Append a command to the current job, which must be 00040 /// either a piped job or a job list. 00041 void addCommand(Command *C); 00042 00043 static bool classof(const Job *) { return true; } 00044 }; 00045 00046 /// Command - An executable path/name and argument vector to 00047 /// execute. 00048 class Command : public Job { 00049 virtual void anchor(); 00050 00051 /// Source - The action which caused the creation of this job. 00052 const Action &Source; 00053 00054 /// Tool - The tool which caused the creation of this job. 00055 const Tool &Creator; 00056 00057 /// The executable to run. 00058 const char *Executable; 00059 00060 /// The list of program arguments (not including the implicit first 00061 /// argument, which will be the executable). 00062 ArgStringList Arguments; 00063 00064 public: 00065 Command(const Action &_Source, const Tool &_Creator, const char *_Executable, 00066 const ArgStringList &_Arguments); 00067 00068 /// getSource - Return the Action which caused the creation of this job. 00069 const Action &getSource() const { return Source; } 00070 00071 /// getCreator - Return the Tool which caused the creation of this job. 00072 const Tool &getCreator() const { return Creator; } 00073 00074 const char *getExecutable() const { return Executable; } 00075 00076 const ArgStringList &getArguments() const { return Arguments; } 00077 00078 static bool classof(const Job *J) { 00079 return J->getKind() == CommandClass; 00080 } 00081 static bool classof(const Command *) { return true; } 00082 }; 00083 00084 /// JobList - A sequence of jobs to perform. 00085 class JobList : public Job { 00086 public: 00087 typedef SmallVector<Job*, 4> list_type; 00088 typedef list_type::size_type size_type; 00089 typedef list_type::iterator iterator; 00090 typedef list_type::const_iterator const_iterator; 00091 00092 private: 00093 list_type Jobs; 00094 00095 public: 00096 JobList(); 00097 virtual ~JobList(); 00098 00099 /// Add a job to the list (taking ownership). 00100 void addJob(Job *J) { Jobs.push_back(J); } 00101 00102 /// Clear the job list. 00103 void clear(); 00104 00105 const list_type &getJobs() const { return Jobs; } 00106 00107 size_type size() const { return Jobs.size(); } 00108 iterator begin() { return Jobs.begin(); } 00109 const_iterator begin() const { return Jobs.begin(); } 00110 iterator end() { return Jobs.end(); } 00111 const_iterator end() const { return Jobs.end(); } 00112 00113 static bool classof(const Job *J) { 00114 return J->getKind() == JobListClass; 00115 } 00116 static bool classof(const JobList *) { return true; } 00117 }; 00118 00119 } // end namespace driver 00120 } // end namespace clang 00121 00122 #endif