def check_unpack(self, fn, stmt, lhs, args): assert len(args) >= 4, 'not enough args to ' + fn format = args[3] format = format.string_literal() if format is None: self.warn('Call to %s has variable format string. Verify it will always correspond with the passed in types.' % fn, location = {'call-site': stmt}) return specifiers = self.decompose_format_string(stmt, format, unpack) varargs = args[4:] for i, spec in enumerate(specifiers): if fn == 'dsUnpackMap': symbol = self.pop_or_error(stmt, varargs) if to_c(symbol.get_type()) != symbol_type: self.error('Symbol argument (index %d) to %s is not a DSSymbol, but a "%s".' % (i, fn, to_c(symbol.get_type())), location = {'call-site': stmt}) if spec is None: continue item = self.pop_or_error(stmt, varargs) if to_c(item.get_type()) != spec: self.error('Value argument (index %d) to %s is not a "%s" as specified, but a "%s".' % (i, fn, spec, to_c(item.get_type())), location = {'call-site': stmt})
def convolve_simple_assignments(self): # assignments without an operator (either binary or unary) # and an unnamed bound variable (ie, a temporary) if len(self.rhs) == 1 and isinstance(self.lhs, expression.Bound) and \ self.lhs.decl and self.lhs.decl.binding.name is None: self.lhs.decl.binding.constant_temporary_value = to_c(self.rhs[0]) return True else: return False
def to_c(self): return '*%s' % (to_c(self.thing))
def to_c(self): return '%s[%s]' % (to_c(self.array), to_c(self.index))
def to_c(self): return '%s.%s' % (to_c(self.struct), to_c(self.member))
def to_c(self): return '&' + to_c(self.of)
def cond_to_c(self): return ' '.join([to_c(x) for x in self.cond])
def to_c(self): rhs = ' '.join([to_c(x) for x in self.rhs]) return '%s = %s' % \ (to_c(self.lhs), rhs)
def to_c(self): if self.expr: return 'return %s' % ( to_c(self.expr) ) else: return 'return'
def to_c(self): fn = to_c(self.fnexpr) lhs = to_c(self.lhs) args = ', '.join([to_c(x) for x in self.args]) return '%s = %s(%s)' % (lhs, fn, args)