Example #1
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
Example #2
0
 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)
Example #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
Example #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)
Example #5
0
 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)
Example #6
0
File: rtuple.py Project: 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
Example #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
Example #8
0
 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)
Example #9
0
    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)
Example #10
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        
Example #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
Example #12
0
 def empty(self):
     return ootype.null(self.lowleveltype)
Example #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)
Example #14
0
File: rpbc.py Project: sota/pypy
 def null_instance(self):
     return ootype.null(PBCROOT)
Example #15
0
 def is_null(self):
     return self.value is ootype.null(self.value._TYPE)
Example #16
0
 def null_instance(self):
     return ootype.null(PBCROOT)
Example #17
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)
Example #18
0
 def null_const(self):
     return ootype.null(self.LIST)
Example #19
0
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)
Example #20
0
File: rclass.py Project: sota/pypy
 def null_instance(self):
     return ootype.null(self.lowleveltype)
Example #21
0
 def is_null(self):
     return self.value is ootype.null(self.value._TYPE)
Example #22
0
 def null_instance(self):
     return ootype.null(self.lowleveltype)
Example #23
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)