Example #1
0
 def render(self, generator, op):
     func = op.args[0]
     # XXX we need to sort out stuff here at some point
     if is_external(func):
         func_name = func.value._name.split("__")[0]
         try:
             return self.builtins.builtin_map[func_name](generator, op)
         except KeyError:
             return self.class_map['CallBuiltin'](func_name)(generator, op)
     return self.class_map['Call'].render(generator, op)
Example #2
0
 def render(self, generator, op):
     func = op.args[0]
     # XXX we need to sort out stuff here at some point
     if is_external(func):
         func_name = func.value._name.split("__")[0]
         try:
             return self.builtins.builtin_map[func_name](generator, op)
         except KeyError:
             return self.class_map['CallBuiltin'](func_name)(generator, op)
     return self.class_map['Call'].render(generator, op)
Example #3
0
 def primitive_repr(self, _type, v):
     if _type is Bool:
         if v == False:
             val = 'false'
         else:
             val = 'true'
     elif _type is Void:
         val = 'undefined'
     elif isinstance(_type, String.__class__):
         val = '%r' % v._str
     elif isinstance(_type, List):
         # FIXME: It's not ok to use always empty list
         val = "[]"
     elif isinstance(_type, StaticMethod):
         if hasattr(v, 'graph') and not is_external(v):
             self.db.pending_function(v.graph)
         else:
             self.db.pending_abstract_function(v)
         val = v._name
         val = val.replace('.', '_')
         if val == '?':
             val = 'undefined'
     elif _type is UniChar or _type is Char:
         #log("Constant %r"%v)
         s = repr(v)
         if s.startswith('u'):
             s = s[1:]
         if s != "'\''":
             s.replace("'", '"')
         val = s
     elif isinstance(v, Symbolic):
         val = v.expr
     elif isinstance(_type, Primitive):
         #log("Type: %r"%_type)
         val = str(v)
     else:
         assert False, "Unknown constant %r" % _type
         val = str(v)
     return val
Example #4
0
 def primitive_repr(self, _type, v):
     if _type is Bool:
         if v == False:
             val = 'false'
         else:
             val = 'true'
     elif _type is Void:
         val = 'undefined'
     elif isinstance(_type,String.__class__):
         val = '%r'%v._str
     elif isinstance(_type,List):
         # FIXME: It's not ok to use always empty list
         val = "[]"
     elif isinstance(_type,StaticMethod):
         if hasattr(v, 'graph') and not is_external(v):
             self.db.pending_function(v.graph)
         else:
             self.db.pending_abstract_function(v)
         val = v._name
         val = val.replace('.', '_')
         if val == '?':
             val = 'undefined'
     elif _type is UniChar or _type is Char:
         #log("Constant %r"%v)
         s = repr(v)
         if s.startswith('u'):
             s = s[1:]
         if s != "'\''":
             s.replace("'", '"')
         val = s
     elif isinstance(v, Symbolic):
         val = v.expr
     elif isinstance(_type, Primitive):
         #log("Type: %r"%_type)
         val = str(v)
     else:
         assert False, "Unknown constant %r"%_type
         val = str(v)
     return val