コード例 #1
0
ファイル: objspace.py プロジェクト: sk-/hippyvm
    def setup_constants(self):
        dct = OrderedDict()
        for modulename, lst in get_constants_by_module(self):
            for k, w_obj in lst:
                dct[k] = w_obj
        dct['PHP_INT_MAX'] = self.wrap(sys.maxint)
        dct['PHP_INT_SIZE'] = self.wrap(4 if sys.maxint < 2 ** 32 else 8)

        self._setup_constant_any_case('true', self.w_True, dct)
        self._setup_constant_any_case('false', self.w_False, dct)
        self._setup_constant_any_case('null', self.w_Null, dct)

        self.prebuilt_constants = dct.keys()
        self.global_constant_cache = GlobalImmutCache(self, dct,
                                                      force_lowcase=False)
コード例 #2
0
    def setup_constants(self):
        dct = OrderedDict()
        for modulename, lst in get_constants_by_module(self):
            for k, w_obj in lst:
                dct[k] = w_obj
        dct['PHP_INT_MAX'] = self.wrap(sys.maxint)
        dct['PHP_INT_SIZE'] = self.wrap(4 if sys.maxint < 2**32 else 8)

        self._setup_constant_any_case('true', self.w_True, dct)
        self._setup_constant_any_case('false', self.w_False, dct)
        self._setup_constant_any_case('null', self.w_Null, dct)

        self.prebuilt_constants = dct.keys()
        self.global_constant_cache = GlobalImmutCache(self,
                                                      dct,
                                                      force_lowcase=False)
コード例 #3
0
def get_defined_constants(interp, categorize=False):
    from hippy.constants import get_constants_by_module
    if not categorize:
        od = OrderedDict()
        for name in (interp.space.prebuilt_constants + interp.constant_names):
            od[name] = interp.lookup_constant(name)
        return interp.space.new_array_from_rdict(od)
    else:
        rdct_w = OrderedDict()
        for module, lst in get_constants_by_module(interp.space):
            inner_rdct_w = OrderedDict()
            for k, w_obj in lst:
                inner_rdct_w[k] = w_obj
            rdct_w[module] = interp.space.new_array_from_rdict(inner_rdct_w)
        inner_rdct_w = OrderedDict()
        for name in interp.constant_names:
            inner_rdct_w[name] = interp.lookup_constant(name)
        rdct_w['user'] = interp.space.new_array_from_rdict(inner_rdct_w)
        return interp.space.new_array_from_rdict(rdct_w)
コード例 #4
0
ファイル: funcs.py プロジェクト: cklein/hippyvm
def get_defined_constants(interp, categorize=False):
    from hippy.constants import get_constants_by_module
    if not categorize:
        od = OrderedDict()
        for name in (interp.space.prebuilt_constants +
                     interp.constant_names):
            od[name] = interp.lookup_constant(name)
        return interp.space.new_array_from_rdict(od)
    else:
        rdct_w = OrderedDict()
        for module, lst in get_constants_by_module(interp.space):
            inner_rdct_w = OrderedDict()
            for k, w_obj in lst:
                inner_rdct_w[k] = w_obj
            rdct_w[module] = interp.space.new_array_from_rdict(inner_rdct_w)
        inner_rdct_w = OrderedDict()
        for name in interp.constant_names:
            inner_rdct_w[name] = interp.lookup_constant(name)
        rdct_w['user'] = interp.space.new_array_from_rdict(inner_rdct_w)
        return interp.space.new_array_from_rdict(rdct_w)