Пример #1
0
            def build_seq(self, instr):
                # TOS  v_0
                # ...
                # TOSn v_n

                yield instructions.BUILD_TUPLE(instr.arg).steal(instr)
                # TOS  (v_0, ..., v_n)

                yield instructions.LOAD_CONST(partial(thunk_type, type_))
                # TOS  partial(thunk_type, type_)
                # TOS1 (v_0, ..., v_n)

                yield instructions.ROT_TWO()
                # TOS  (v_0, ..., v_n)
                # TOS1 partial(thunk_type, type_)

                yield instructions.CALL_FUNCTION(1)
Пример #2
0
        def _build_const_map(self, keys, instr):
            yield instructions.BUILD_TUPLE(len(keys.arg)).steal(keys)
            # TOS  = (v0, v1, ..., vn)

            yield keys
            # TOS  = (k0, k1, ..., kn)
            # TOS1 = (v0, v1, ..., vn)

            yield instructions.LOAD_CONST(self._construct_const_map)
            # TOS  = self._construct_const_map
            # TOS1 = (k0, k1, ..., kn)
            # TOS2 = (v0, v1, ..., vn)

            yield instructions.ROT_THREE()
            # TOS  = (k0, k1, ..., kn)
            # TOS1 = (v0, v1, ..., vn)
            # TOS2 = self._construct_const_map

            yield instructions.CALL_FUNCTION(2)
Пример #3
0
        def _build_map(self, instr):
            # TOS      = vn
            # TOS1     = kn
            # ...
            # TOSN     = v0
            # TOSN + 1 = k0
            # Construct a tuple of (k0, v0, k1, v1, ..., kn, vn) for
            # each of the key: value pairs in the dictionary.
            yield instructions.BUILD_TUPLE(instr.arg * 2).steal(instr)
            # TOS  = (k0, v0, k1, v1, ..., kn, vn)

            yield instructions.LOAD_CONST(self._construct_map)
            # TOS  = self._construct_map
            # TOS1 = (k0, v0, k1, v1, ..., kn, vn)

            yield instructions.ROT_TWO()
            # TOS  = (k0, v0, k1, v1, ..., kn, vn)
            # TOS1 = self._construct_map

            yield instructions.CALL_FUNCTION(1)