Kaydet (Commit) bfb0cf82 authored tarafından Jeremy Hylton's avatar Jeremy Hylton

Revise handling of tuple arguments so that the variables names match

those used by compile.c.  (test_grammar now depends on the names)
üst e20bd19f
...@@ -495,7 +495,7 @@ class TupleArg: ...@@ -495,7 +495,7 @@ class TupleArg:
def __repr__(self): def __repr__(self):
return "TupleArg(%s, %s)" % (self.count, self.names) return "TupleArg(%s, %s)" % (self.count, self.names)
def getName(self): def getName(self):
return ".nested%d" % self.count return ".%d" % self.count
def getArgCount(args): def getArgCount(args):
argcount = len(args) argcount = len(args)
......
...@@ -1101,11 +1101,10 @@ class AbstractFunctionCode: ...@@ -1101,11 +1101,10 @@ class AbstractFunctionCode:
self.emit('RETURN_VALUE') self.emit('RETURN_VALUE')
def generateArgUnpack(self, args): def generateArgUnpack(self, args):
count = 0 for i in range(len(args)):
for arg in args: arg = args[i]
if type(arg) == types.TupleType: if type(arg) == types.TupleType:
self.emit('LOAD_FAST', '.nested%d' % count) self.emit('LOAD_FAST', '.%d' % (i * 2))
count = count + 1
self.unpackSequence(arg) self.unpackSequence(arg)
def unpackSequence(self, tup): def unpackSequence(self, tup):
...@@ -1184,13 +1183,14 @@ def generateArgList(arglist): ...@@ -1184,13 +1183,14 @@ def generateArgList(arglist):
args = [] args = []
extra = [] extra = []
count = 0 count = 0
for elt in arglist: for i in range(len(arglist)):
elt = arglist[i]
if type(elt) == types.StringType: if type(elt) == types.StringType:
args.append(elt) args.append(elt)
elif type(elt) == types.TupleType: elif type(elt) == types.TupleType:
args.append(TupleArg(count, elt)) args.append(TupleArg(i * 2, elt))
count = count + 1
extra.extend(misc.flatten(elt)) extra.extend(misc.flatten(elt))
count = count + 1
else: else:
raise ValueError, "unexpect argument type:", elt raise ValueError, "unexpect argument type:", elt
return args + extra, count return args + extra, count
......
...@@ -495,7 +495,7 @@ class TupleArg: ...@@ -495,7 +495,7 @@ class TupleArg:
def __repr__(self): def __repr__(self):
return "TupleArg(%s, %s)" % (self.count, self.names) return "TupleArg(%s, %s)" % (self.count, self.names)
def getName(self): def getName(self):
return ".nested%d" % self.count return ".%d" % self.count
def getArgCount(args): def getArgCount(args):
argcount = len(args) argcount = len(args)
......
...@@ -1101,11 +1101,10 @@ class AbstractFunctionCode: ...@@ -1101,11 +1101,10 @@ class AbstractFunctionCode:
self.emit('RETURN_VALUE') self.emit('RETURN_VALUE')
def generateArgUnpack(self, args): def generateArgUnpack(self, args):
count = 0 for i in range(len(args)):
for arg in args: arg = args[i]
if type(arg) == types.TupleType: if type(arg) == types.TupleType:
self.emit('LOAD_FAST', '.nested%d' % count) self.emit('LOAD_FAST', '.%d' % (i * 2))
count = count + 1
self.unpackSequence(arg) self.unpackSequence(arg)
def unpackSequence(self, tup): def unpackSequence(self, tup):
...@@ -1184,13 +1183,14 @@ def generateArgList(arglist): ...@@ -1184,13 +1183,14 @@ def generateArgList(arglist):
args = [] args = []
extra = [] extra = []
count = 0 count = 0
for elt in arglist: for i in range(len(arglist)):
elt = arglist[i]
if type(elt) == types.StringType: if type(elt) == types.StringType:
args.append(elt) args.append(elt)
elif type(elt) == types.TupleType: elif type(elt) == types.TupleType:
args.append(TupleArg(count, elt)) args.append(TupleArg(i * 2, elt))
count = count + 1
extra.extend(misc.flatten(elt)) extra.extend(misc.flatten(elt))
count = count + 1
else: else:
raise ValueError, "unexpect argument type:", elt raise ValueError, "unexpect argument type:", elt
return args + extra, count return args + extra, count
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment