diff --git a/include/clang/Driver/Job.h b/include/clang/Driver/Job.h new file mode 100644 index 0000000000..b2552b036c --- /dev/null +++ b/include/clang/Driver/Job.h @@ -0,0 +1,104 @@ +//===--- Job.h - Commands to Execute ----------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef CLANG_DRIVER_JOB_H_ +#define CLANG_DRIVER_JOB_H_ + +#include "clang/Driver/Util.h" +#include "llvm/ADT/SmallVector.h" + +namespace clang { +namespace driver { + +class Job { +public: + enum JobClass { + CommandClass, + PipedJobClass, + JobListClass + }; + +private: + JobClass Kind; + +protected: + Job(JobClass _Kind) : Kind(_Kind) {} +public: + virtual ~Job(); + + JobClass getKind() const { return Kind; } + + static bool classof(const Job *) { return true; } +}; + + /// Command - An executable path/name and argument vector to + /// execute. +class Command : public Job { + const char *Executable; + ArgStringList Argv; + +public: + Command(const char *_Executable, const ArgStringList &_Argv); + + const char *getExecutable() const { return Executable; } + const ArgStringList &getArgv() const { return Argv; } + + static bool classof(const Job *J) { + return J->getKind() == CommandClass; + } + static bool classof(const Command *) { return true; } +}; + + /// PipedJob - A list of Commands which should be executed together + /// with their standard inputs and outputs connected. +class PipedJob : public Job { +public: + typedef llvm::SmallVector list_type; + +private: + list_type Commands; + +public: + PipedJob(); + + void addCommand(Command *C) { Commands.push_back(C); } + + const list_type &getCommands() const { return Commands; } + + static bool classof(const Job *J) { + return J->getKind() == PipedJobClass; + } + static bool classof(const PipedJob *) { return true; } +}; + + /// JobList - A sequence of jobs to perform. +class JobList : public Job { +public: + typedef llvm::SmallVector list_type; + +private: + list_type Jobs; + +public: + JobList(); + + void addJob(Job *J) { Jobs.push_back(J); } + + const list_type &getJobs() const { return Jobs; } + + static bool classof(const Job *J) { + return J->getKind() == JobListClass; + } + static bool classof(const JobList *) { return true; } +}; + +} // end namespace driver +} // end namespace clang + +#endif diff --git a/lib/Driver/Job.cpp b/lib/Driver/Job.cpp new file mode 100644 index 0000000000..3cc8b29178 --- /dev/null +++ b/lib/Driver/Job.cpp @@ -0,0 +1,23 @@ +//===--- Job.cpp - Command to Execute -----------------------------------*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "clang/Driver/Job.h" + +#include +using namespace clang::driver; + +Job::~Job() {} + +Command::Command(const char *_Executable, const ArgStringList &_Argv) + : Job(CommandClass), Executable(_Executable), Argv(_Argv) { +} + +PipedJob::PipedJob() : Job(PipedJobClass) {} + +JobList::JobList() : Job(JobListClass) {}