Beispiel #1
0
def len_expander(type, message, args):
    receiver_type = args[0]['pseudo_type']
    if isinstance(receiver_type, list):
        a = receiver_type[0]
    else:
        a = receiver_type
    # print(a, message, args[0], args[1:])
    # input(0)
    if message == 'len' and 'special' in args[0]:  # len(sys.argv)
        return {
            'type': 'standard_call',
            'namespace': 'system',
            'function': 'arg_count',
            'args': [],
            'pseudo_type': 'Int'
        }
    else:
        q = builtin_type_check(a, message, args[0], args[1:])
        return {
            'type': 'standard_method_call',
            'receiver': args[0],
            'args': [],
            'message': message,
            'pseudo_type': q[-1]
        }
Beispiel #2
0
 def expand(self, args):
     if len(args) < 2:
         raise PseudoCythonTypeCheckError('%s expects more args' %
                                          self.message)
     q = builtin_type_check(self.type, self.message, args[1], [args[0]])[-1]
     return {
         'type': 'standard_method_call',
         'receiver': args[1],
         'args': [args[0]],
         'message': self.message,
         'pseudo_type': q
     }
Beispiel #3
0
 def expand(self, args):
     if not self.expander:
         q = builtin_type_check(self.namespace, self.function, None,
                                args)[-1]
         return {
             'type': 'standard_call',
             'namespace': self.namespace,
             'function': self.function,
             'args': args,
             'pseudo_type': q
         }
     else:
         return self.expander(self.namespace, self.function, args)
Beispiel #4
0
 def expand(self, args):
     if self.default and len(args) - 1 in self.default:
         args += self.default[len(args) - 1]
     if not self.expander:
         q = builtin_type_check(self.type, self.message, args[0],
                                args[1:])[-1]
         return {
             'type': 'standard_method_call',
             'receiver': args[0],
             'message': self.message,
             'args': args[1:],
             'pseudo_type': q
         }
     else:
         return self.expander(self.type, self.message, args)