示例#1
0
文件: d3s.py 项目: ctz/lighthouse
 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})
示例#2
0
 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
示例#3
0
 def to_c(self):
     return '*%s' % (to_c(self.thing))
示例#4
0
 def to_c(self):
     return '%s[%s]' % (to_c(self.array), to_c(self.index))
示例#5
0
 def to_c(self):
     return '%s.%s' % (to_c(self.struct), to_c(self.member))
示例#6
0
 def to_c(self):
     return '&' + to_c(self.of)
示例#7
0
 def cond_to_c(self):
     return ' '.join([to_c(x) for x in self.cond])
示例#8
0
 def to_c(self):
   rhs = ' '.join([to_c(x) for x in self.rhs])
   return '%s = %s' % \
     (to_c(self.lhs), rhs)
示例#9
0
 def to_c(self):
   if self.expr:
       return 'return %s' % ( to_c(self.expr) )
   else:
       return 'return'
示例#10
0
 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)