def pycode(self): global _in_pro, _in_function, _classes_used pars = [] keys = [] extra = [] method = False # import ipdb; ipdb.set_trace() plist = self.subroutine_body.parameter_list if self.subroutine_body.method_name.DCOLON is None: name = pycode(self.subroutine_body.method_name) if name[-8:].lower() == '__define': # class definition if plist: print "Class definition with parameters -- probably not allowed!" return ClassDefinition(name[:-8], find_structure_body(self)) else: # Method definition classname, name = map(pycode, self.subroutine_body.method_name.IDENTIFIER) # methodname = pycode(methodname) # classname = pycode(classname) method = True if plist: for p in plist.get_items(): if p.EXTRA: extra = pycode(p.IDENTIFIER) if p.IDENTIFIER else "extra" continue if p.EQUALS: keys.append((pycode(p.IDENTIFIER[0]), pycode(p.IDENTIFIER[1]))) else: pars.append(pycode(p.IDENTIFIER)) fmap = i2py_map.get_subroutine_map(name) if not fmap: inpars = range(1, len(pars)+1) outpars = inpars inkeys = [ k[0] for k in keys ] outkeys = inkeys if self.PRO: _in_pro = True if not fmap: fmap = i2py_map.map_pro(name, inpars=inpars, outpars=outpars, inkeys=inkeys, outkeys=outkeys, method=method) elif self.FUNCTION: _in_function = True if not fmap: fmap = i2py_map.map_func(name, inpars=inpars, inkeys=inkeys, method=method) else: raise RuntimeError("not PRO, not FUNCTION, then what?") try: header, body = fmap.pydef(pars, keys, extra=extra) except i2py_map.Error, e: error.mapping_error(str(e), self.lineno) header, body = '', ''
def pycode(self): if self.DOT and self.LPAREN: # import ipdb; ipdb.set_trace() return "%s[%s]" % (pycode( self.postfix_expression), pycode(self.expression)) if self.ARROW: return "%s.%s" % (pycode(self.postfix_expression[0]), pycode(self.postfix_expression[1])) if self.DOT or (not self.method_or_proc): return Node.pycode(self) if self.argument_list: pars, keys, extra = self.argument_list.get_pars_and_keys() else: pars = [] keys = [] extra = [] name = str(self.method_or_proc) fmap = i2py_map.get_subroutine_map(name) if not fmap: keys = ['%s=%s' % (k[0], k[1]) for k in keys] return '%s(%s)' % (pycode( self.method_or_proc), ', '.join(pars + keys + extra)) try: return fmap.pycall(pars, keys) except i2py_map.Error, e: error.mapping_error(str(e), self.lineno) return ''
def pycode(self): if self.DOT and self.LPAREN: # import ipdb; ipdb.set_trace() return "%s[%s]" % (pycode(self.postfix_expression), pycode(self.expression)) if self.ARROW: return "%s.%s" % (pycode(self.postfix_expression[0]), pycode(self.postfix_expression[1])) if self.DOT or (not self.method_or_proc): return Node.pycode(self) if self.argument_list: pars, keys, extra = self.argument_list.get_pars_and_keys() else: pars = [] keys = [] extra = [] name = str(self.method_or_proc) fmap = i2py_map.get_subroutine_map(name) if not fmap: keys = [ '%s=%s' % (k[0], k[1]) for k in keys ] return '%s(%s)' % (pycode(self.method_or_proc), ', '.join(pars + keys + extra)) try: return fmap.pycall(pars, keys) except i2py_map.Error, e: error.mapping_error(str(e), self.lineno) return ''
def pycode(self): if self.DOT and self.LPAREN: # FIXME: implement this! error.conversion_error( "can't handle '<struct>.(<field_index>)' yet", self.lineno) return '' if self.DOT or (not self.IDENTIFIER): return Node.pycode(self) if self.argument_list: pars, keys = self.argument_list.get_pars_and_keys() else: pars = [] keys = [] name = str(self.IDENTIFIER) fmap = map.get_subroutine_map(name) if not fmap: keys = ['%s=%s' % (k[0], k[1]) for k in keys] return '%s(%s)' % (pycode(self.IDENTIFIER), ', '.join(pars + keys)) try: return fmap.pycall(pars, keys) except map.Error, e: error.mapping_error(str(e), self.lineno) return ''
def pycode(self): global _in_pro, _in_function pars = [] keys = [] plist = self.subroutine_body.parameter_list if plist: for p in plist.get_items(): if p.EXTRA: # FIXME: implement this! error.conversion_error("can't handle _EXTRA yet", self.lineno) return '' if p.EQUALS: keys.append( (pycode(p.IDENTIFIER[0]), pycode(p.IDENTIFIER[1]))) else: pars.append(pycode(p.IDENTIFIER)) name = str(self.subroutine_body.IDENTIFIER) fmap = map.get_subroutine_map(name) if not fmap: inpars = range(1, len(pars) + 1) outpars = inpars inkeys = [k[0] for k in keys] outkeys = inkeys if self.PRO: _in_pro = True if not fmap: fmap = map.map_pro(name, inpars=inpars, outpars=outpars, inkeys=inkeys, outkeys=outkeys) else: _in_function = True if not fmap: fmap = map.map_func(name, inpars=inpars, inkeys=inkeys) try: header, body = fmap.pydef(pars, keys) except map.Error, e: error.mapping_error(str(e), self.lineno) header, body = '', ''
def pycode(self): if self.argument_list: pars, keys = self.argument_list.get_pars_and_keys() else: pars = [] keys = [] name = str(self.IDENTIFIER) fmap = map.get_subroutine_map(name) if not fmap: keys = ['%s=%s' % (k[0], k[1]) for k in keys] return '%s(%s)' % (pycode(self.IDENTIFIER), ', '.join(pars + keys)) try: return fmap.pycall(pars, keys) except map.Error, e: error.mapping_error(str(e), self.lineno) return ''
def pycode(self): if self.argument_list: pars, keys, extra = self.argument_list.get_pars_and_keys() else: pars = [] keys = [] extra = [] name = str(self.method_or_proc) fmap = i2py_map.get_subroutine_map(name) if not fmap: keys = [ '%s=%s' % (k[0], k[1]) for k in keys ] return '%s(%s)' % (pycode(self.method_or_proc), ', '.join(pars + keys + extra)) try: return fmap.pycall(pars, keys) except i2py_map.Error, e: error.mapping_error(str(e), self.lineno) return ''