Пример #1
0
 def convert_subscript(self, value, slice, ctx, context):
     if isinstance(slice, ast.Index):
         return hm_ast.Multi_Apply(
             hm_ast.Ident('h' + self.OPERATOR_MAGIC_FUNCTIONS[type(slice)]), [
             self.convert_node(value, context),
             self.convert_node(slice.value)])
     else:
         return hm_ast.Multi_Apply(
             hm_ast.Ident('h' + self.OPERATOR_MAGIC_FUNCTIONS[type(slice)]), [
             self.convert_node(value, context),
             self.convert_node(slice.lower) if slice.lower else hm_ast.anInteger(0),
             self.convert_node(slice.upper) if slice.upper else hm_ast.Multi_Apply(
                 self.OPERATOR_MAGIC_FUNCTIONS[ast.Sub], [
                 hm_ast.Apply(hm_ast.Ident('len'), self.convert_node(value, context)),
                 hm_ast.anInteger(1)])])
Пример #2
0
 def convert_subscript(self, value, slice, ctx, context):
     if isinstance(slice, ast.Index):
         return hm_ast.Multi_Apply(
             hm_ast.Ident('h' + self.OPERATOR_MAGIC_FUNCTIONS[type(slice)]),
             [
                 self.convert_node(value, context),
                 self.convert_node(slice.value)
             ])
     else:
         return hm_ast.Multi_Apply(
             hm_ast.Ident('h' + self.OPERATOR_MAGIC_FUNCTIONS[type(slice)]),
             [
                 self.convert_node(value, context),
                 self.convert_node(slice.lower)
                 if slice.lower else hm_ast.anInteger(0),
                 self.convert_node(slice.upper)
                 if slice.upper else hm_ast.Multi_Apply(
                     self.OPERATOR_MAGIC_FUNCTIONS[ast.Sub], [
                         hm_ast.Apply(hm_ast.Ident('len'),
                                      self.convert_node(value, context)),
                         hm_ast.anInteger(1)
                     ])
             ])
Пример #3
0
 def convert_num(self, n, context):
     if type(n) == float:
         return hm_ast.aFloat(n)
     else:
         return hm_ast.anInteger(n)
Пример #4
0
 def convert_num(self, n, context):
     if type(n) == float:
         return hm_ast.aFloat(n)
     else:
         return hm_ast.anInteger(n)