コード例 #1
0
 def lowlevelspecialize(funcdesc, args_s, key_for_args):
     args_s, key1, ignored, builder = flatten_star_args(funcdesc, args_s)
     key = []
     new_args_s = []
     for i, s_obj in enumerate(args_s):
         if i in key_for_args:
             key.append(key_for_args[i])
             new_args_s.append(s_obj)
         elif isinstance(s_obj, annmodel.SomePBC):
             assert s_obj.is_constant(), "ambiguous low-level helper specialization"
             key.append(KeyComp(s_obj.const))
             new_args_s.append(s_obj)
         else:
             new_args_s.append(annmodel.not_const(s_obj))
             try:
                 key.append(annmodel.annotation_to_lltype(s_obj))
             except ValueError:
                 # passing non-low-level types to a ll_* function is allowed
                 # for module/ll_*
                 key.append(s_obj.__class__)
     key = (tuple(key),)
     if key1 is not None:
         key += (key1,)
     flowgraph = funcdesc.cachedgraph(key, builder=builder)
     args_s[:] = new_args_s
     return flowgraph
コード例 #2
0
ファイル: dotnet.py プロジェクト: TheDunn/flex-pypy
 def annotation_to_lltype(cls, ann):
     if isinstance(ann, SomeChar):
         return ootype.Char
     elif isinstance(ann, SomeString):
         return ootype.String
     else:
         return annotation_to_lltype(ann)
コード例 #3
0
 def call(p, args):
     args_s, kwds_s = args.unpack()
     if kwds_s:
         raise Exception("keyword arguments to call to a low-level fn ptr")
     info = "argument to ll function pointer call"
     llargs = [annotation_to_lltype(s_arg, info)._defl() for s_arg in args_s]
     v = p.ll_ptrtype._example()(*llargs)
     return ll_to_annotation(v)
コード例 #4
0
 def call(m, args):
     args_s, kwds_s = args.unpack()
     if kwds_s:
         raise Exception("keyword arguments to call to a low-level static method")
     info = "argument to ll static method call"
     llargs = [annotation_to_lltype(s_arg, info)._defl() for s_arg in args_s]
     v = m.method._example()(*llargs)
     return ll_to_annotation(v)
コード例 #5
0
ファイル: annlowlevel.py プロジェクト: TheDunn/flex-pypy
 def default_specialize(funcdesc, args_s):
     key = []
     new_args_s = []
     for s_obj in args_s:
         if isinstance(s_obj, annmodel.SomePBC):
             assert s_obj.is_constant(), "ambiguous low-level helper specialization"
             key.append(KeyComp(s_obj.const))
             new_args_s.append(s_obj)
         else:
             new_args_s.append(annmodel.not_const(s_obj))
             try:
                 key.append(annmodel.annotation_to_lltype(s_obj))
             except ValueError:
                 # passing non-low-level types to a ll_* function is allowed
                 # for module/ll_*
                 key.append(s_obj.__class__)
     flowgraph = funcdesc.cachedgraph(tuple(key))
     args_s[:] = new_args_s
     return flowgraph
コード例 #6
0
ファイル: builtin.py プロジェクト: alkorzt/pypy
def cast_primitive(T, s_v):
    assert T.is_constant()
    return ll_to_annotation(lltype.cast_primitive(T.const, annotation_to_lltype(s_v)._defl()))
コード例 #7
0
 def specialize__genconst(pol, funcdesc, args_s, i):
     # XXX this is specific to the JIT
     TYPE = annmodel.annotation_to_lltype(args_s[i], 'genconst')
     args_s[i] = annmodel.lltype_to_annotation(TYPE)
     alt_name = funcdesc.name + "__%s" % (TYPE._short_name(),)
     return funcdesc.cachedgraph(TYPE, alt_name=valid_identifier(alt_name))
コード例 #8
0
ファイル: unaryop.py プロジェクト: TheDunn/flex-pypy
 def simple_call(m, *args_s):
     llargs = [annotation_to_lltype(arg_s)._example() for arg_s in args_s]
     smeth = m.method._example()
     v = smeth(*llargs)
     return ll_to_annotation(v)
コード例 #9
0
ファイル: builtin.py プロジェクト: alkorzt/pypy
def typeOf(s_val):
    lltype = annotation_to_lltype(s_val, info="in typeOf(): ")
    return immutablevalue(lltype)
コード例 #10
0
 def specialize__genconst(pol, funcdesc, args_s, i):
     # XXX this is specific to the JIT
     TYPE = annmodel.annotation_to_lltype(args_s[i], 'genconst')
     args_s[i] = annmodel.lltype_to_annotation(TYPE)
     alt_name = funcdesc.name + "__%s" % (TYPE._short_name(), )
     return funcdesc.cachedgraph(TYPE, alt_name=valid_identifier(alt_name))
コード例 #11
0
 def setattr(r, s_attr, s_value):
     assert s_attr.is_constant(), "setattr on ref %r with non-constant field-name" % r.ootype
     v = annotation_to_lltype(s_value)
     example = r.ootype._example()
     if example is not None:
         setattr(r.ootype._example(), s_attr.const, v._example())
コード例 #12
0
 def annotation_to_cts(self, _tp):
     s_tp = annotation(_tp)
     TP = annotation_to_lltype(s_tp)
     return self.lltype_to_cts(TP)
コード例 #13
0
 def setattr(p, s_attr, s_value):  # just doing checking
     assert s_attr.is_constant(), "setattr on ptr %r with non-constant field-name" % p.ll_ptrtype
     example = p.ll_ptrtype._example()
     if getattr(example, s_attr.const) is not None:  # ignore Void s_value
         v_lltype = annotation_to_lltype(s_value)
         setattr(example, s_attr.const, v_lltype._defl())
コード例 #14
0
 def simple_call(m, *args_s):
     llargs = [annotation_to_lltype(arg_s)._example() for arg_s in args_s]
     smeth = m.method._example()
     v = smeth(*llargs)
     return ll_to_annotation(v)
コード例 #15
0
ファイル: ootype.py プロジェクト: antoine1fr/pygirl
 def annotation_to_lltype(cls, ann):
     from pypy.annotation import model as annmodel
     return annmodel.annotation_to_lltype(ann)
コード例 #16
0
def cast_primitive(T, s_v):
    assert T.is_constant()
    return ll_to_annotation(
        lltype.cast_primitive(T.const,
                              annotation_to_lltype(s_v)._defl()))
コード例 #17
0
def typeOf(s_val):
    lltype = annotation_to_lltype(s_val, info="in typeOf(): ")
    return immutablevalue(lltype)
コード例 #18
0
ファイル: database.py プロジェクト: Debug-Orz/Sypy
 def annotation_to_cts(self, _tp):
     s_tp = annotation(_tp)
     TP = annotation_to_lltype(s_tp)
     return self.lltype_to_cts(TP)