[cfe-commits] r66985 - in /cfe/trunk: include/clang/Driver/Job.h lib/Driver/Job.cpp
Daniel Dunbar
daniel at zuster.org
Fri Mar 13 16:36:34 PDT 2009
Author: ddunbar
Date: Fri Mar 13 18:36:33 2009
New Revision: 66985
URL: http://llvm.org/viewvc/llvm-project?rev=66985&view=rev
Log:
Driver: Add simple Job classes, simple wrappers for information about
what processes to execute during a compilation.
Added:
cfe/trunk/include/clang/Driver/Job.h
cfe/trunk/lib/Driver/Job.cpp
Added: cfe/trunk/include/clang/Driver/Job.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Job.h?rev=66985&view=auto
==============================================================================
--- cfe/trunk/include/clang/Driver/Job.h (added)
+++ cfe/trunk/include/clang/Driver/Job.h Fri Mar 13 18:36:33 2009
@@ -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<Command*, 4> 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<Job*, 4> 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
Added: cfe/trunk/lib/Driver/Job.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Job.cpp?rev=66985&view=auto
==============================================================================
--- cfe/trunk/lib/Driver/Job.cpp (added)
+++ cfe/trunk/lib/Driver/Job.cpp Fri Mar 13 18:36:33 2009
@@ -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 <cassert>
+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) {}
More information about the cfe-commits
mailing list