Exemplo n.º 1
0
    def popitem(space, w_d):
        goto = 1  # startblock
        while True:

            if goto == 1:
                w_0 = space.call_function(gdescriptor_dict_iterkeys, w_d)
                w_1 = space.iter(w_0)
                try:
                    w_k = space.next(w_1)
                    goto = 4
                except gOperationError, e:
                    e.normalize_exception(space)
                    if e.match(space, space.w_StopIteration):
                        goto = 2
                    else:
                        raise  # unhandled case, should not happen

            if goto == 2:
                w_2 = space.call_function(space.w_KeyError, gs_popitem____dictionary_is_empty)
                w_3 = space.type(w_2)
                w_4 = space.issubtype(w_3, space.w_type)
                v0 = space.is_true(w_4)
                if v0 == True:
                    goto = 3
                else:
                    goto = 5

            if goto == 3:
                w_5 = space.call_function(w_2)
                w_6 = space.type(w_5)
                w_etype, w_evalue = w_6, w_5
                goto = 6

            if goto == 4:
                w_7 = space.call_function(gdescriptor_dict___getitem__, w_d, w_k)
                w_8 = space.call_function(gdescriptor_dict___delitem__, w_d, w_k)
                w_9 = space.newtuple([w_k, w_7])
                goto = 7

            if goto == 5:
                w_10 = space.type(w_2)
                w_etype, w_evalue = w_10, w_2
                goto = 6

            if goto == 6:
                raise gOperationError(w_etype, w_evalue)

            if goto == 7:
                return w_9
Exemplo n.º 2
0
  def print_expr(space, w_1):
    goto = 1 # startblock
    while True:

        if goto == 1:
            try:
                w_0 = space.getattr(mod_sys, gs_displayhook)
                goto = 5
            except gOperationError, e:
                e.normalize_exception(space)
                if e.match(space, space.w_AttributeError):
                    goto = 2
                else:raise # unhandled case, should not happen

        if goto == 2:
            w_2 = space.call_function(space.w_RuntimeError, gs_lost_sys_displayhook)
            w_3 = space.type(w_2)
            w_4 = space.issubtype(w_3, space.w_type)
            v0 = space.is_true(w_4)
            if v0 == True:
                goto = 3
            else:
                goto = 4

        if goto == 3:
            w_5 = space.call_function(w_2, )
            w_6 = space.type(w_5)
            w_etype, w_evalue = w_6, w_5
            goto = 6

        if goto == 4:
            w_7 = space.type(w_2)
            w_etype, w_evalue = w_7, w_2
            goto = 6

        if goto == 5:
            w_8 = space.call_function(w_0, w_1)
            w_9 = space.w_None
            goto = 7

        if goto == 6:
            raise gOperationError(w_etype, w_evalue)

        if goto == 7:
            return w_9
Exemplo n.º 3
0
  def sys_stdout(space):
    goto = 1 # startblock
    while True:

        if goto == 1:
            try:
                w_0 = space.getattr(mod_sys, gs_stdout)
                goto = 6
            except gOperationError, e:
                e.normalize_exception(space)
                if e.match(space, space.w_AttributeError):
                    goto = 2
                else:raise # unhandled case, should not happen

        if goto == 2:
            w_1 = space.call_function(space.w_RuntimeError, gs_lost_sys_stdout)
            w_2 = space.type(w_1)
            w_3 = space.issubtype(w_2, space.w_type)
            v0 = space.is_true(w_3)
            if v0 == True:
                goto = 4
            else:
                goto = 3

        if goto == 3:
            w_4 = space.type(w_1)
            w_etype, w_evalue = w_4, w_1
            goto = 5

        if goto == 4:
            w_5 = space.call_function(w_1, )
            w_6 = space.type(w_5)
            w_etype, w_evalue = w_6, w_5
            goto = 5

        if goto == 5:
            raise gOperationError(w_etype, w_evalue)

        if goto == 6:
            return w_0
Exemplo n.º 4
0
            w_14 = space.eq(w_13, gs__)
            v2 = space.is_true(w_14)
            if v2 == True:
                goto = 8
                continue
            else:
                goto = 11

        if goto == 11:
            w_15 = space.getattr(w_module, w_name)
            w_16 = space.setitem(w_into_locals, w_name, w_15)
            goto = 8
            continue

        if goto == 12:
            raise gOperationError(w_etype, w_evalue)

        if goto == 13:
            return w_12

  fastf_import_all_from = import_all_from
  fastf_import_all_from.__name__ = 'fastf_import_all_from'

##SECTION##
  g4dict = space.newdict()
  gs___name__ = space.new_interned_str('__name__')
  gs___builtin__ = space.new_interned_str('__builtin__')
  space.setitem(g4dict, gs___name__, gs___builtin__)
  gs___file__ = space.new_interned_str('__file__')
  gs__Users_steve_Documents_MIT_TPP_2 = space.new_interned_str(
"""/Users/steve/Documents/MIT TPP/2009-2010/6.893/project/pypy-dist/pypy/interpreter/pyopcode.py""")
Exemplo n.º 5
0
def init__builtin__(space):
  """NOT_RPYTHON"""

  __doc__ = \
"""
Plain Python definition of the builtin functions related to run-time
program introspection.
"""

##SECTION##
## filename    'module/__builtin__/app_inspect.py'
## function    'globals'
## firstlineno 9
##SECTION##
# global declaration
# global object gs_f_globals

  def globals(space):
    """Return the dictionary containing the current scope's global variables."""
    goto = 1 # startblock
    while True:

        if goto == 1:
            w_0 = space.getattr(mod_sys, gs__getframe)
            w_1 = space.call_function(w_0, gi_0)
            w_2 = space.getattr(w_1, gs_f_globals)
            goto = 2

        if goto == 2:
            return w_2

  fastf_globals = globals
  fastf_globals.__name__ = 'fastf_globals'

##SECTION##
## filename    'module/__builtin__/app_inspect.py'
## function    'locals'
## firstlineno 13
##SECTION##
# global declarations
# global object g11dict
# global object gs__caller_locals
# global object gfunc__caller_locals
# global object gs_vars
# global object gfunc_vars
# global object gs___file__
# global object gs__Users_steve_Documents_MIT_TPP_2
# global object gs__classdir
# global object gfunc__classdir
# global object gs_sys
# global object mod_sys
# global object bltinmod_helper
# global object gs_globals
# global object gfunc_globals
# global object gs_dir
# global object gfunc_dir
# global object gs___name__
# global object gs___builtin__
# global object gs___doc__
# global object gs_locals
# global object gfunc_locals
# global object gs__getframe
# global object gi_0
# global object gs_f_locals

  def locals(space):
    """Return a dictionary containing the current scope's local variables.
Note that this may be the real dictionary of local variables, or a copy."""
    goto = 1 # startblock
    while True:

        if goto == 1:
            w_0 = space.getattr(mod_sys, gs__getframe)
            w_1 = space.call_function(w_0, gi_0)
            w_2 = space.getattr(w_1, gs_f_locals)
            goto = 2

        if goto == 2:
            return w_2

  fastf_locals = locals
  fastf_locals.__name__ = 'fastf_locals'

##SECTION##
## filename    'module/__builtin__/app_inspect.py'
## function    '_caller_locals'
## firstlineno 18
##SECTION##
  def _caller_locals(space):
    goto = 1 # startblock
    while True:

        if goto == 1:
            w_0 = space.getattr(mod_sys, gs__getframe)
            w_1 = space.call_function(w_0, gi_0)
            w_2 = space.getattr(w_1, gs_f_locals)
            goto = 2

        if goto == 2:
            return w_2

  fastf__caller_locals = _caller_locals
  fastf__caller_locals.__name__ = 'fastf__caller_locals'

##SECTION##
## filename    'module/__builtin__/app_inspect.py'
## function    'vars'
## firstlineno 21
##SECTION##
# global declarations
# global object gs_vars___takes_at_most_1_argument_
# global object gs_vars___argument_must_have___dict

  def vars(space, __args__):
    """Return a dictionary of all the attributes currently bound in obj.  If
    called with no argument, return the variables bound in local scope."""

    funcname = "vars"
    signature = [], 'obj', None
    defaults_w = []
    w_1, = __args__.parse(funcname, signature, defaults_w)
    return fastf_vars(space, w_1)

  f_vars = vars
  f_vars.__name__ = 'f_vars'

  def vars(space, w_1):
    """Return a dictionary of all the attributes currently bound in obj.  If
    called with no argument, return the variables bound in local scope."""
    goto = 1 # startblock
    while True:

        if goto == 1:
            w_0 = space.len(w_1)
            w_2 = space.eq(w_0, gi_0)
            v0 = space.is_true(w_2)
            if v0 == True:
                goto = 2
            else:
                goto = 3

        if goto == 2:
            w_3 = fastf__caller_locals(space, )
            w_4 = w_3
            goto = 9

        if goto == 3:
            w_5 = space.len(w_1)
            w_6 = space.ne(w_5, gi_1)
            v1 = space.is_true(w_6)
            if v1 == True:
                goto = 4
            else:
                goto = 5

        if goto == 4:
            w_7 = space.call_function(space.w_TypeError, gs_vars___takes_at_most_1_argument_)
            w_8 = space.type(w_7)
            w_etype, w_evalue = w_8, w_7
            goto = 8

        if goto == 5:
            try:
                w_9 = space.getitem(w_1, gi_0)
                goto = 6
            except gOperationError, e:
                e.normalize_exception(space)
                if e.match(space, space.w_AttributeError):
                    goto = 7
                elif e.match(space, space.w_Exception):
                    w_etype, w_evalue = e.w_type, e.w_value
                    goto = 8
                else:raise # unhandled case, should not happen

        if goto == 6:
            try:
                w_10 = space.getattr(w_9, gs___dict__)
                w_4 = w_10
                goto = 9
            except gOperationError, e:
                e.normalize_exception(space)
                if e.match(space, space.w_AttributeError):
                    goto = 7
                else:raise # unhandled case, should not happen

        if goto == 7:
            w_11 = space.call_function(space.w_TypeError, gs_vars___argument_must_have___dict)
            w_12 = space.type(w_11)
            w_etype, w_evalue = w_12, w_11
            goto = 8

        if goto == 8:
            raise gOperationError(w_etype, w_evalue)

        if goto == 9:
            return w_4
Exemplo n.º 6
0
def init__builtin__(space):
    """NOT_RPYTHON"""

    ##SECTION##
    ## filename    'objspace/std/dicttype.py'
    ## function    'update1'
    ## firstlineno 66
    ##SECTION##
    # global declarations
    # global object gs_hasattr
    # global object gdescriptor_dict___setitem__
    # global object gs___setitem__
    # global object gi_2

    def update1(space, w_d, w_1):
        goto = 1  # startblock
        while True:

            if goto == 1:
                w_0 = space.call_function((space.builtin.get(space.str_w(gs_hasattr))), w_1, gs_keys)
                v0 = space.is_true(w_0)
                if v0 == True:
                    goto = 2
                else:
                    goto = 7

            if goto == 2:
                w_2 = space.getattr(w_1, gs_keys)
                w_3 = space.call_function(w_2)
                w_4 = space.iter(w_3)
                goto = 5

            if goto == 3:
                w_5 = space.getitem(w_6, gi_0)
                w_7 = space.getitem(w_6, gi_1)
                w_8 = space.call_function(gdescriptor_dict___setitem__, w_d, w_5, w_7)
                goto = 8

            if goto == 4:
                w_evalue = space.call_function(space.w_ValueError)
                w_etype = space.type(w_evalue)
                goto = 10

            if goto == 5:
                try:
                    w_10 = space.next(w_4)
                    goto = 6
                except gOperationError, e:
                    e.normalize_exception(space)
                    if e.match(space, space.w_StopIteration):
                        w_11 = space.w_None
                        goto = 11
                    else:
                        raise  # unhandled case, should not happen

            if goto == 6:
                w_12 = space.getitem(w_1, w_10)
                w_13 = space.call_function(gdescriptor_dict___setitem__, w_d, w_10, w_12)
                goto = 5
                continue

            if goto == 7:
                w_9 = space.iter(w_1)
                goto = 8

            if goto == 8:
                try:
                    w_6 = space.next(w_9)
                    goto = 9
                except gOperationError, e:
                    e.normalize_exception(space)
                    if e.match(space, space.w_StopIteration):
                        w_11 = space.w_None
                        goto = 11
                    else:
                        raise  # unhandled case, should not happen

            if goto == 9:
                w_14 = space.len(w_6)
                w_15 = space.eq(w_14, gi_2)
                v1 = space.is_true(w_15)
                if v1 == True:
                    goto = 3
                    continue
                else:
                    goto = 4
                    continue

            if goto == 10:
                raise gOperationError(w_etype, w_evalue)

            if goto == 11:
                return w_11
Exemplo n.º 7
0
    def update(space, w_d, w_1, w_kwargs):
        goto = 1  # startblock
        while True:

            if goto == 1:
                w_0 = space.len(w_1)
                w_2 = space.eq(w_0, gi_1)
                v0 = space.is_true(w_2)
                if v0 == True:
                    goto = 2
                else:
                    goto = 3

            if goto == 2:
                w_3 = space.getitem(w_1, gi_0)
                w_4 = fastf_update1(space, w_d, w_3)
                goto = 6

            if goto == 3:
                w_5 = space.gt(w_0, gi_1)
                v1 = space.is_true(w_5)
                if v1 == True:
                    goto = 4
                else:
                    goto = 6

            if goto == 4:
                w_6 = space.call_function(space.w_TypeError, gs_update_takes_at_most_1__non_keyw)
                w_7 = space.type(w_6)
                w_8 = space.issubtype(w_7, space.w_type)
                v2 = space.is_true(w_8)
                if v2 == True:
                    goto = 5
                else:
                    goto = 8

            if goto == 5:
                w_9 = space.call_function(w_6)
                w_10 = space.type(w_9)
                w_etype, w_evalue = w_10, w_9
                goto = 9

            if goto == 6:
                v3 = space.is_true(w_kwargs)
                if v3 == True:
                    goto = 7
                else:
                    w_11 = space.w_None
                    goto = 10

            if goto == 7:
                w_12 = fastf_update1(space, w_d, w_kwargs)
                w_11 = space.w_None
                goto = 10

            if goto == 8:
                w_13 = space.type(w_6)
                w_etype, w_evalue = w_13, w_6
                goto = 9

            if goto == 9:
                raise gOperationError(w_etype, w_evalue)

            if goto == 10:
                return w_11