[cfe-commits] r61846 - /cfe/trunk/tools/ccc/ccclib/Arguments.py
Daniel Dunbar
daniel at zuster.org
Tue Jan 6 17:57:39 PST 2009
Author: ddunbar
Date: Tue Jan 6 19:57:39 2009
New Revision: 61846
URL: http://llvm.org/viewvc/llvm-project?rev=61846&view=rev
Log:
ccc: Extend ArgList to support indexing into a synthetic arg array
(for killing off DerivedArg).
Modified:
cfe/trunk/tools/ccc/ccclib/Arguments.py
Modified: cfe/trunk/tools/ccc/ccclib/Arguments.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/ccclib/Arguments.py?rev=61846&r1=61845&r2=61846&view=diff
==============================================================================
--- cfe/trunk/tools/ccc/ccclib/Arguments.py (original)
+++ cfe/trunk/tools/ccc/ccclib/Arguments.py Tue Jan 6 19:57:39 2009
@@ -206,20 +206,44 @@
def render(self, args):
return [self.value]
+###
+
+class InputIndex:
+ def __init__(self, sourceId, pos):
+ self.sourceId = sourceId
+ self.pos = pos
+
+ def __repr__(self):
+ return 'InputIndex(%d, %d)' % (self.sourceId, self.pos)
+
class ArgList:
"""ArgList - Collect an input argument vector along with a set of parsed Args
and supporting information."""
def __init__(self, argv):
self.argv = list(argv)
- self.args = []
+ self.syntheticArgv = []
self.lastArgs = {}
+ self.args = []
def getLastArg(self, option):
return self.lastArgs.get(option)
def getInputString(self, index, offset=0):
- return self.argv[index + offset]
+ # Source 0 is argv.
+ if index.sourceId == 0:
+ return self.argv[index.pos + offset]
+
+ # Source 1 is synthetic argv.
+ if index.sourceId == 1:
+ return self.syntheticArgv[index.pos + offset]
+
+ raise RuntimeError,'Unknown source ID for index.'
+
+ def getSyntheticIndex(self, *strings):
+ pos = len(self.syntheticArgv)
+ self.syntheticArgv.extend(strings)
+ return InputIndex(1, pos)
# Support use as a simple arg list.
@@ -460,7 +484,8 @@
iargs = enumerate(argv)
it = iter(iargs)
args = ArgList(argv)
- for i,a in it:
+ for pos,a in it:
+ i = InputIndex(0, pos)
# FIXME: Handle '@'
if not a:
# gcc's handling of empty arguments doesn't make
More information about the cfe-commits
mailing list