[cfe-commits] r61844 - in /cfe/trunk/tools/ccc/ccclib: Arguments.py Driver.py Jobs.py Tools.py
Daniel Dunbar
daniel at zuster.org
Tue Jan 6 17:29:28 PST 2009
Author: ddunbar
Date: Tue Jan 6 19:29:28 2009
New Revision: 61844
URL: http://llvm.org/viewvc/llvm-project?rev=61844&view=rev
Log:
ccc: Refactor so that all accesses to actual input strings go through
the ArgList.
Modified:
cfe/trunk/tools/ccc/ccclib/Arguments.py
cfe/trunk/tools/ccc/ccclib/Driver.py
cfe/trunk/tools/ccc/ccclib/Jobs.py
cfe/trunk/tools/ccc/ccclib/Tools.py
Modified: cfe/trunk/tools/ccc/ccclib/Arguments.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/ccclib/Arguments.py?rev=61844&r1=61843&r2=61844&view=diff
==============================================================================
--- cfe/trunk/tools/ccc/ccclib/Arguments.py (original)
+++ cfe/trunk/tools/ccc/ccclib/Arguments.py Tue Jan 6 19:29:28 2009
@@ -135,17 +135,17 @@
"""PositionalArg - A simple positional argument."""
def getValue(self, args):
- return args[self.index]
+ return args.getInputString(self.index)
def render(self, args):
- return [args[self.index]]
+ return [args.getInputString(self.index)]
class JoinedValueArg(ValueArg):
"""JoinedValueArg - A single value argument where the value is
joined (suffixed) to the option."""
def getValue(self, args):
- return args[self.index][len(self.opt.name):]
+ return args.getInputString(self.index)[len(self.opt.name):]
def render(self, args):
return [self.opt.name + self.getValue(args)]
@@ -155,7 +155,7 @@
follows the option in the argument vector."""
def getValue(self, args):
- return args[self.index+1]
+ return args.getInputString(self.index, offset=1)
def render(self, args):
return [self.opt.name, self.getValue(args)]
@@ -167,7 +167,8 @@
# FIXME: Should we unify this with SeparateValueArg?
def getValues(self, args):
- return args[self.index + 1:self.index + 1 + self.opt.numArgs]
+ return [args.getInputString(self.index, offset=1+i)
+ for i in range(self.opt.numArgs)]
def render(self, args):
return [self.opt.name] + self.getValues(args)
@@ -179,17 +180,10 @@
separate values."""
def getJoinedValue(self, args):
- return args[self.index][len(self.opt.name):]
+ return args.getInputString(self.index)[len(self.opt.name):]
def getSeparateValue(self, args):
- return args[self.index+1]
-
- def setJoinedValue(self, args, value):
- assert self.opt.name == args[self.index][:len(self.opt.name)]
- args[self.index] = self.opt.name + value
-
- def setSeparateValue(self, args, vaue):
- args[self.index+1] = value
+ return args.getInputString(self.index, offset=1)
def render(self, args):
return ([self.opt.name + self.getJoinedValue(args)] +
@@ -224,6 +218,9 @@
def getLastArg(self, option):
return self.lastArgs.get(option)
+ def getInputString(self, index, offset=0):
+ return self.argv[index + offset]
+
# Support use as a simple arg list.
def __iter__(self):
@@ -234,18 +231,23 @@
self.lastArgs[arg.opt] = arg
# Forwarding methods.
+ #
+ # FIXME: Clean this up once restructuring is done.
+
+ def render(self, arg):
+ return arg.render(self)
def getValue(self, arg):
- return arg.getValue(self.argv)
+ return arg.getValue(self)
def getValues(self, arg):
- return arg.getValues(self.argv)
+ return arg.getValues(self)
def getSeparateValue(self, arg):
- return arg.getSeparateValue(self.argv)
+ return arg.getSeparateValue(self)
def getJoinedValue(self, arg):
- return arg.getJoinedValue(self.argv)
+ return arg.getJoinedValue(self)
###
Modified: cfe/trunk/tools/ccc/ccclib/Driver.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/ccclib/Driver.py?rev=61844&r1=61843&r2=61844&view=diff
==============================================================================
--- cfe/trunk/tools/ccc/ccclib/Driver.py (original)
+++ cfe/trunk/tools/ccc/ccclib/Driver.py Tue Jan 6 19:29:28 2009
@@ -104,10 +104,10 @@
self.claim(hasHashHashHash)
for j in jobs.iterjobs():
if isinstance(j, Jobs.Command):
- print '"%s"' % '" "'.join(j.render(argv))
+ print '"%s"' % '" "'.join(j.render(args))
elif isinstance(j, Jobs.PipedJob):
for c in j.commands:
- print '"%s" %c' % ('" "'.join(c.render(argv)),
+ print '"%s" %c' % ('" "'.join(c.render(args)),
"| "[c is j.commands[-1]])
elif not isinstance(j, JobList):
raise ValueError,'Encountered unknown job.'
@@ -115,7 +115,7 @@
for j in jobs.iterjobs():
if isinstance(j, Jobs.Command):
- cmd_args = j.render(argv)
+ cmd_args = j.render(args)
res = os.spawnvp(os.P_WAIT, cmd_args[0], cmd_args)
if res:
sys.exit(res)
Modified: cfe/trunk/tools/ccc/ccclib/Jobs.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/ccclib/Jobs.py?rev=61844&r1=61843&r2=61844&view=diff
==============================================================================
--- cfe/trunk/tools/ccc/ccclib/Jobs.py (original)
+++ cfe/trunk/tools/ccc/ccclib/Jobs.py Tue Jan 6 19:29:28 2009
@@ -23,7 +23,7 @@
def render(self, args):
argv = [self.executable]
for arg in self.args:
- argv.extend(arg.render(args))
+ argv.extend(args.render(arg))
return argv
def iterjobs(self):
Modified: cfe/trunk/tools/ccc/ccclib/Tools.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/ccclib/Tools.py?rev=61844&r1=61843&r2=61844&view=diff
==============================================================================
--- cfe/trunk/tools/ccc/ccclib/Tools.py (original)
+++ cfe/trunk/tools/ccc/ccclib/Tools.py Tue Jan 6 19:29:28 2009
@@ -139,7 +139,7 @@
if arg.opt.name in ('-framework',):
cmd_args.append(arg)
for input in inputs:
- cmd_args.append(input.source)
+ cmd_args.append(input.source)
if isinstance(output, Arguments.DerivedArg):
cmd_args.extend([Arguments.DerivedArg('-o'), output])
else:
More information about the cfe-commits
mailing list