Skip to content

Commit

Permalink
fix tuple copy
Browse files Browse the repository at this point in the history
  • Loading branch information
izgzhen committed Oct 25, 2018
1 parent 266151a commit 809b9ef
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions cozy/codegen/cxx.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,11 @@ def visit_Type(self, t, name):
def visit_TRecord(self, t, name):
return "{} {}".format(self.typename(t), name)

def visit_TTuple(self, t, name):
return "{} {}".format(self.typename(t), name)
def visit_TTuple(self, t, name=None):
if name:
return "{} {}".format(self.typename(t), name)
else:
return "{}".format(self.typename(t))

def visit_TEnum(self, enum, name):
return "{} {}".format(self.typename(enum), name)
Expand Down Expand Up @@ -278,7 +281,7 @@ def construct_concrete(self, t : Type, e : Exp, out : Exp):
x = self.fv(t, "x")
indices = range(len(t.ts))
return SSeq(
SEscape("{indent}{rv} = {rhs};\n", ["rv", "rhs"], [x, e]),
SEscape("{indent}" + self.visit(t, x.id) + " = {rhs};\n", ("rhs",), (e,)),
SEscape("{indent}{lhs} = {rv};\n", ["lhs", "rv"],
[out, ETuple([ETupleGet(x, i).with_type(t.ts[i]) for i in indices]).with_type(t)]),
)
Expand Down

0 comments on commit 809b9ef

Please sign in to comment.