for i in range(len(self.args)):
arg = self.args[i]
self.args[i] = arg.coerce_to(base_type, env)
+ elif dst_type.is_struct:
+ if len(self.args) > len(dst_type.scope.var_entries):
+ error(self.pos, "Too may members for '%s'" % dst_type)
+ else:
+ if len(self.args) < len(dst_type.scope.var_entries):
+ warning(self.pos, "Too few members for '%s'" % dst_type, 1)
+ for i, (arg, member) in enumerate(zip(self.args, dst_type.scope.var_entries)):
+ self.args[i] = arg.coerce_to(member.type, env)
+ self.type = dst_type
else:
self.type = error_type
error(self.pos, "Cannot coerce list to type '%s'" % dst_type)
(self.result(),
i,
arg.py_result()))
- else:
+ elif self.type.is_ptr:
code.putln("%s = (%s[]) {" % (self.result(), self.type.base_type))
- for i, arg in enumerate(self.args):
+ for arg in self.args:
code.put(arg.result())
code.put(", ")
code.putln();
code.putln("};")
+ else:
+ for arg, member in zip(self.args, self.type.scope.var_entries):
+ code.putln("%s.%s = %s;" % (
+ self.result(),
+ member.cname,
+ arg.result()))
def generate_subexpr_disposal_code(self, code):
# We call generate_post_assignment_code here instead
# is_null_ptr boolean Is the type of NULL
# is_cfunction boolean Is a C function type
# is_struct_or_union boolean Is a C struct or union type
+ # is_struct boolean Is a C struct type
# is_enum boolean Is a C enum type
# is_typedef boolean Is a typedef type
# is_string boolean Is a C char * type
is_null_ptr = 0
is_cfunction = 0
is_struct_or_union = 0
+ is_struct = 0
is_enum = 0
is_typedef = 0
is_string = 0
self.kind = kind
self.scope = scope
self.typedef_flag = typedef_flag
+ self.is_struct = kind == 'struct'
def __repr__(self):
return "<CStructOrUnionType %s %s%s>" % (self.name, self.cname,