예제 #1
0
파일: generator.py 프로젝트: sota/pypy
    def push_primitive_constant(self, TYPE, value):

        if TYPE is ootype.Void:
            return
        elif isinstance(value, CDefinedIntSymbolic):
            self.emit(jvm.ICONST, self.DEFINED_INT_SYMBOLICS[value.expr])
        elif TYPE in (ootype.Bool, ootype.Signed):
            self.emit(jvm.ICONST, int(value))
        elif TYPE is ootype.Unsigned:
            # Converts the unsigned int into its corresponding signed value:
            if value > 0x7FFFFFFF:
                value = -((int(value) ^ 0xFFFFFFFF)+1)
            self.emit(jvm.ICONST, value)
        elif TYPE is ootype.Char or TYPE is ootype.UniChar:
            self.emit(jvm.ICONST, ord(value))
        elif TYPE is ootype.SignedLongLong:
            self._push_long_constant(long(value))
        elif TYPE is ootype.UnsignedLongLong:
            # Converts the unsigned long into its corresponding signed value:
            if value > 0x7FFFFFFFFFFFFFFF:
                value = -((long(value) ^ 0xFFFFFFFFFFFFFFFF)+1)
            self._push_long_constant(value)
        elif TYPE is ootype.Float:
            self._push_double_constant(float(value))
        elif TYPE in (ootype.String, ootype.Unicode):
            if value == ootype.null(TYPE):
                self.emit(jvm.ACONST_NULL)
            else:
                self.load_string(value._str)
        else:
            assert False, 'Unknown constant type: %s' % TYPE
예제 #2
0
파일: constant.py 프로젝트: sota/pypy
 def record_dependencies(self):
     if self.value is ootype.null(self.value._TYPE):
         self.delegate_impl = None
         return
     StaticMethodConst.record_dependencies(self)
     self.delegate_impl = self.db.record_delegate_standalone_func_impl(
         self.value.graph)
예제 #3
0
    def push_primitive_constant(self, TYPE, value):

        if TYPE is ootype.Void:
            return
        elif isinstance(value, CDefinedIntSymbolic):
            self.emit(jvm.ICONST, self.DEFINED_INT_SYMBOLICS[value.expr])
        elif TYPE in (ootype.Bool, ootype.Signed):
            self.emit(jvm.ICONST, int(value))
        elif TYPE is ootype.Unsigned:
            # Converts the unsigned int into its corresponding signed value:
            if value > 0x7FFFFFFF:
                value = -((int(value) ^ 0xFFFFFFFF) + 1)
            self.emit(jvm.ICONST, value)
        elif TYPE is ootype.Char or TYPE is ootype.UniChar:
            self.emit(jvm.ICONST, ord(value))
        elif TYPE is ootype.SignedLongLong:
            self._push_long_constant(long(value))
        elif TYPE is ootype.UnsignedLongLong:
            # Converts the unsigned long into its corresponding signed value:
            if value > 0x7FFFFFFFFFFFFFFF:
                value = -((long(value) ^ 0xFFFFFFFFFFFFFFFF) + 1)
            self._push_long_constant(value)
        elif TYPE is ootype.Float:
            self._push_double_constant(float(value))
        elif TYPE in (ootype.String, ootype.Unicode):
            if value == ootype.null(TYPE):
                self.emit(jvm.ACONST_NULL)
            else:
                self.load_string(value._str)
        else:
            assert False, 'Unknown constant type: %s' % TYPE
예제 #4
0
 def record_dependencies(self):
     if self.value is ootype.null(self.value._TYPE):
         return
     for f_name, (FIELD_TYPE,
                  f_default) in self.value._TYPE._fields.iteritems():
         value = self.value._items[f_name]
         self._record_const_if_complex(FIELD_TYPE, value)
예제 #5
0
파일: constant.py 프로젝트: sota/pypy-old
 def record_dependencies(self):
     if self.value is ootype.null(self.value._TYPE):
         self.delegate_impl = None
         return
     StaticMethodConst.record_dependencies(self)
     self.delegate_impl = self.db.record_delegate_standalone_func_impl(
         self.value.graph)
예제 #6
0
파일: rtuple.py 프로젝트: sota/pypy
def ll_tuplenext(iter):
    # for iterating over length 1 tuples only!
    t = iter.iterable
    if t:
        iter.iterable = ootype.null(ootype.typeOf(t))
        return t.item0
    else:
        raise StopIteration
예제 #7
0
def ll_tuplenext(iter):
    # for iterating over length 1 tuples only!
    t = iter.iterable
    if t:
        iter.iterable = ootype.null(ootype.typeOf(t))
        return t.item0
    else:
        raise StopIteration
예제 #8
0
파일: constant.py 프로젝트: sota/pypy
 def record_dependencies(self):
     # Near as I can tell, self.value is an ootype._custom_dict,
     # key_eq is a Python function and graph is, well, a method
     # graph that seems to be added to the function pointer
     # somewhere.  Adapted from cli/constant.py
     if self.value is ootype.null(self.value._TYPE):
         return
     self.eq_jcls = self.db.record_delegate_standalone_func_impl(
         self.value._dict.key_eq.graph)
     self.hash_jcls = self.db.record_delegate_standalone_func_impl(
         self.value._dict.key_hash.graph)
     
     CustomDictConst.record_dependencies(self)
예제 #9
0
파일: constant.py 프로젝트: sota/pypy-old
    def record_dependencies(self):
        # Near as I can tell, self.value is an ootype._custom_dict,
        # key_eq is a Python function and graph is, well, a method
        # graph that seems to be added to the function pointer
        # somewhere.  Adapted from cli/constant.py
        if self.value is ootype.null(self.value._TYPE):
            return
        self.eq_jcls = self.db.record_delegate_standalone_func_impl(
            self.value._dict.key_eq.graph)
        self.hash_jcls = self.db.record_delegate_standalone_func_impl(
            self.value._dict.key_hash.graph)

        CustomDictConst.record_dependencies(self)
예제 #10
0
파일: constant.py 프로젝트: sota/pypy
    def _create_complex_const(self, value):

        """ A helper method which creates a Constant wrapper object for
        the given value.  Uses the types defined in the sub-class. """

        # Determine if the static type differs from the dynamic type.
        if isinstance(value, ootype._view):
            static_type = value._TYPE
            value = value._inst
        else:
            static_type = None

        # Find the appropriate kind of Const object.
        genoo = self.genoo
        uniq = self.db.unique()
        if isinstance(value, ootype._instance):
            return genoo.InstanceConst(self.db, value, static_type, uniq)
        elif isinstance(value, ootype._record):
            return genoo.RecordConst(self.db, value, uniq)
        elif isinstance(value, ootype._class):
            return genoo.ClassConst(self.db, value, uniq)
        elif isinstance(value, ootype._list):
            return genoo.ListConst(self.db, value, uniq)
        elif isinstance(value, ootype._array):
            return genoo.ArrayConst(self.db, value, uniq)
        elif isinstance(value, ootype._static_meth):
            return genoo.StaticMethodConst(self.db, value, uniq)
        elif isinstance(value, ootype._custom_dict):
            return genoo.CustomDictConst(self.db, value, uniq)
        elif isinstance(value, ootype._dict):
            return genoo.DictConst(self.db, value, uniq)
        elif isinstance(value, ootype._weak_reference):
            return genoo.WeakRefConst(self.db, value, uniq)
        elif value is ootype.null(value._TYPE):
            # for NULL values, we can just use "NULL" const.  This is
            # a fallback since we sometimes have constants of
            # unhandled types which are equal to NULL.
            return genoo.NullConst(self.db, value, uniq)
        else:
            assert False, 'Unknown constant: %s' % value        
예제 #11
0
    def _create_complex_const(self, value):
        """ A helper method which creates a Constant wrapper object for
        the given value.  Uses the types defined in the sub-class. """

        # Determine if the static type differs from the dynamic type.
        if isinstance(value, ootype._view):
            static_type = value._TYPE
            value = value._inst
        else:
            static_type = None

        # Find the appropriate kind of Const object.
        genoo = self.genoo
        uniq = self.db.unique()
        if isinstance(value, ootype._instance):
            return genoo.InstanceConst(self.db, value, static_type, uniq)
        elif isinstance(value, ootype._record):
            return genoo.RecordConst(self.db, value, uniq)
        elif isinstance(value, ootype._class):
            return genoo.ClassConst(self.db, value, uniq)
        elif isinstance(value, ootype._list):
            return genoo.ListConst(self.db, value, uniq)
        elif isinstance(value, ootype._array):
            return genoo.ArrayConst(self.db, value, uniq)
        elif isinstance(value, ootype._static_meth):
            return genoo.StaticMethodConst(self.db, value, uniq)
        elif isinstance(value, ootype._custom_dict):
            return genoo.CustomDictConst(self.db, value, uniq)
        elif isinstance(value, ootype._dict):
            return genoo.DictConst(self.db, value, uniq)
        elif isinstance(value, ootype._weak_reference):
            return genoo.WeakRefConst(self.db, value, uniq)
        elif value is ootype.null(value._TYPE):
            # for NULL values, we can just use "NULL" const.  This is
            # a fallback since we sometimes have constants of
            # unhandled types which are equal to NULL.
            return genoo.NullConst(self.db, value, uniq)
        else:
            assert False, 'Unknown constant: %s' % value
예제 #12
0
파일: rbuilder.py 프로젝트: sota/pypy-old
 def empty(self):
     return ootype.null(self.lowleveltype)
예제 #13
0
 def record_dependencies(self):
     if self.value is ootype.null(self.value._TYPE):
         return
     if hasattr(self.value, 'graph'):
         self.db.pending_function(self.value.graph)
     self.delegate_type = self.db.record_delegate(self.value._TYPE)
예제 #14
0
파일: rpbc.py 프로젝트: sota/pypy
 def null_instance(self):
     return ootype.null(PBCROOT)
예제 #15
0
 def is_null(self):
     return self.value is ootype.null(self.value._TYPE)
예제 #16
0
파일: rpbc.py 프로젝트: sota/pypy-old
 def null_instance(self):
     return ootype.null(PBCROOT)
예제 #17
0
파일: constant.py 프로젝트: sota/pypy
 def record_dependencies(self):
     if self.value is ootype.null(self.value._TYPE):
         return
     if hasattr(self.value, 'graph'):
         self.db.pending_function(self.value.graph)
     self.delegate_type = self.db.record_delegate(self.value._TYPE)
예제 #18
0
 def null_const(self):
     return ootype.null(self.LIST)
예제 #19
0
파일: rbuiltin.py 프로젝트: sota/pypy-old
def rtype_null(hop):
    hop.exception_cannot_occur()
    assert hop.args_s[0].is_constant()
    TYPE = hop.args_s[0].const
    nullvalue = ootype.null(TYPE)
    return hop.inputconst(TYPE, nullvalue)
예제 #20
0
파일: rclass.py 프로젝트: sota/pypy
 def null_instance(self):
     return ootype.null(self.lowleveltype)
예제 #21
0
파일: constant.py 프로젝트: sota/pypy
 def is_null(self):
     return self.value is ootype.null(self.value._TYPE)
예제 #22
0
 def null_instance(self):
     return ootype.null(self.lowleveltype)
예제 #23
0
파일: constant.py 프로젝트: sota/pypy
 def record_dependencies(self):
     if self.value is ootype.null(self.value._TYPE):
         return
     for f_name, (FIELD_TYPE, f_default) in self.value._TYPE._fields.iteritems():
         value = self.value._items[f_name]            
         self._record_const_if_complex(FIELD_TYPE, value)