Author: Philip Jenvey <pjen...@underboss.org> Branch: py3k Changeset: r73067:276f1b668967 Date: 2014-08-24 15:55 -0700 http://bitbucket.org/pypy/pypy/changeset/276f1b668967/
Log: regenerate ast.py diff too long, truncating to 2000 out of 6594 lines diff --git a/pypy/interpreter/astcompiler/ast.py b/pypy/interpreter/astcompiler/ast.py --- a/pypy/interpreter/astcompiler/ast.py +++ b/pypy/interpreter/astcompiler/ast.py @@ -321,8 +321,6 @@ return Assign.from_object(space, w_node) if space.isinstance_w(w_node, get(space).w_AugAssign): return AugAssign.from_object(space, w_node) - if space.isinstance_w(w_node, get(space).w_Print): - return Print.from_object(space, w_node) if space.isinstance_w(w_node, get(space).w_For): return For.from_object(space, w_node) if space.isinstance_w(w_node, get(space).w_While): @@ -343,10 +341,10 @@ return Import.from_object(space, w_node) if space.isinstance_w(w_node, get(space).w_ImportFrom): return ImportFrom.from_object(space, w_node) - if space.isinstance_w(w_node, get(space).w_Exec): - return Exec.from_object(space, w_node) if space.isinstance_w(w_node, get(space).w_Global): return Global.from_object(space, w_node) + if space.isinstance_w(w_node, get(space).w_Nonlocal): + return Nonlocal.from_object(space, w_node) if space.isinstance_w(w_node, get(space).w_Expr): return Expr.from_object(space, w_node) if space.isinstance_w(w_node, get(space).w_Pass): @@ -366,16 +364,8 @@ self.args = args self.body = body self.decorator_list = decorator_list -<<<<<<< mine - self.w_decorator_list = None self.returns = returns -======= ->>>>>>> theirs stmt.__init__(self, lineno, col_offset) -<<<<<<< mine - self.initialization_state = 127 -======= ->>>>>>> theirs def walkabout(self, visitor): visitor.visit_FunctionDef(self) @@ -390,37 +380,6 @@ self.returns = self.returns.mutate_over(visitor) return visitor.visit_FunctionDef(self) -<<<<<<< mine - def sync_app_attrs(self, space): - if (self.initialization_state & ~64) ^ 63: - self.missing_field(space, ['lineno', 'col_offset', 'name', 'args', 'body', 'decorator_list', None], 'FunctionDef') - else: - if not self.initialization_state & 64: - self.returns = None - self.args.sync_app_attrs(space) - w_list = self.w_body - if w_list is not None: - list_w = space.listview(w_list) - if list_w: - self.body = [space.interp_w(stmt, w_obj) for w_obj in list_w] - else: - self.body = None - if self.body is not None: - for node in self.body: - node.sync_app_attrs(space) - w_list = self.w_decorator_list - if w_list is not None: - list_w = space.listview(w_list) - if list_w: - self.decorator_list = [space.interp_w(expr, w_obj) for w_obj in list_w] - else: - self.decorator_list = None - if self.decorator_list is not None: - for node in self.decorator_list: - node.sync_app_attrs(space) - if self.returns: - self.returns.sync_app_attrs(space) -======= def to_object(self, space): w_node = space.call_function(get(space).w_FunctionDef) w_name = space.wrap(self.name) # identifier @@ -439,6 +398,8 @@ decorator_list_w = [node.to_object(space) for node in self.decorator_list] # expr w_decorator_list = space.newlist(decorator_list_w) space.setattr(w_node, space.wrap('decorator_list'), w_decorator_list) + w_returns = self.returns.to_object(space) if self.returns is not None else space.w_None # expr + space.setattr(w_node, space.wrap('returns'), w_returns) w_lineno = space.wrap(self.lineno) # int space.setattr(w_node, space.wrap('lineno'), w_lineno) w_col_offset = space.wrap(self.col_offset) # int @@ -451,6 +412,7 @@ w_args = get_field(space, w_node, 'args', False) w_body = get_field(space, w_node, 'body', False) w_decorator_list = get_field(space, w_node, 'decorator_list', False) + w_returns = get_field(space, w_node, 'returns', True) w_lineno = get_field(space, w_node, 'lineno', False) w_col_offset = get_field(space, w_node, 'col_offset', False) _name = space.realstr_w(w_name) @@ -459,12 +421,12 @@ _body = [stmt.from_object(space, w_item) for w_item in body_w] decorator_list_w = space.unpackiterable(w_decorator_list) _decorator_list = [expr.from_object(space, w_item) for w_item in decorator_list_w] + _returns = expr.from_object(space, w_returns) _lineno = space.int_w(w_lineno) _col_offset = space.int_w(w_col_offset) - return FunctionDef(_name, _args, _body, _decorator_list, _lineno, _col_offset) - -State.ast_type('FunctionDef', 'stmt', ['name', 'args', 'body', 'decorator_list']) ->>>>>>> theirs + return FunctionDef(_name, _args, _body, _decorator_list, _returns, _lineno, _col_offset) + +State.ast_type('FunctionDef', 'stmt', ['name', 'args', 'body', 'decorator_list', 'returns']) class ClassDef(stmt): @@ -472,21 +434,12 @@ def __init__(self, name, bases, keywords, starargs, kwargs, body, decorator_list, lineno, col_offset): self.name = name self.bases = bases -<<<<<<< mine - self.w_bases = None self.keywords = keywords - self.w_keywords = None self.starargs = starargs self.kwargs = kwargs -======= ->>>>>>> theirs self.body = body self.decorator_list = decorator_list stmt.__init__(self, lineno, col_offset) -<<<<<<< mine - self.initialization_state = 511 -======= ->>>>>>> theirs def walkabout(self, visitor): visitor.visit_ClassDef(self) @@ -506,60 +459,6 @@ visitor._mutate_sequence(self.decorator_list) return visitor.visit_ClassDef(self) -<<<<<<< mine - def sync_app_attrs(self, space): - if (self.initialization_state & ~96) ^ 415: - self.missing_field(space, ['lineno', 'col_offset', 'name', 'bases', 'keywords', None, None, 'body', 'decorator_list'], 'ClassDef') - else: - if not self.initialization_state & 32: - self.starargs = None - if not self.initialization_state & 64: - self.kwargs = None - w_list = self.w_bases - if w_list is not None: - list_w = space.listview(w_list) - if list_w: - self.bases = [space.interp_w(expr, w_obj) for w_obj in list_w] - else: - self.bases = None - if self.bases is not None: - for node in self.bases: - node.sync_app_attrs(space) - w_list = self.w_keywords - if w_list is not None: - list_w = space.listview(w_list) - if list_w: - self.keywords = [space.interp_w(keyword, w_obj) for w_obj in list_w] - else: - self.keywords = None - if self.keywords is not None: - for node in self.keywords: - node.sync_app_attrs(space) - if self.starargs: - self.starargs.sync_app_attrs(space) - if self.kwargs: - self.kwargs.sync_app_attrs(space) - w_list = self.w_body - if w_list is not None: - list_w = space.listview(w_list) - if list_w: - self.body = [space.interp_w(stmt, w_obj) for w_obj in list_w] - else: - self.body = None - if self.body is not None: - for node in self.body: - node.sync_app_attrs(space) - w_list = self.w_decorator_list - if w_list is not None: - list_w = space.listview(w_list) - if list_w: - self.decorator_list = [space.interp_w(expr, w_obj) for w_obj in list_w] - else: - self.decorator_list = None - if self.decorator_list is not None: - for node in self.decorator_list: - node.sync_app_attrs(space) -======= def to_object(self, space): w_node = space.call_function(get(space).w_ClassDef) w_name = space.wrap(self.name) # identifier @@ -570,6 +469,16 @@ bases_w = [node.to_object(space) for node in self.bases] # expr w_bases = space.newlist(bases_w) space.setattr(w_node, space.wrap('bases'), w_bases) + if self.keywords is None: + keywords_w = [] + else: + keywords_w = [node.to_object(space) for node in self.keywords] # keyword + w_keywords = space.newlist(keywords_w) + space.setattr(w_node, space.wrap('keywords'), w_keywords) + w_starargs = self.starargs.to_object(space) if self.starargs is not None else space.w_None # expr + space.setattr(w_node, space.wrap('starargs'), w_starargs) + w_kwargs = self.kwargs.to_object(space) if self.kwargs is not None else space.w_None # expr + space.setattr(w_node, space.wrap('kwargs'), w_kwargs) if self.body is None: body_w = [] else: @@ -592,6 +501,9 @@ def from_object(space, w_node): w_name = get_field(space, w_node, 'name', False) w_bases = get_field(space, w_node, 'bases', False) + w_keywords = get_field(space, w_node, 'keywords', False) + w_starargs = get_field(space, w_node, 'starargs', True) + w_kwargs = get_field(space, w_node, 'kwargs', True) w_body = get_field(space, w_node, 'body', False) w_decorator_list = get_field(space, w_node, 'decorator_list', False) w_lineno = get_field(space, w_node, 'lineno', False) @@ -599,16 +511,19 @@ _name = space.realstr_w(w_name) bases_w = space.unpackiterable(w_bases) _bases = [expr.from_object(space, w_item) for w_item in bases_w] + keywords_w = space.unpackiterable(w_keywords) + _keywords = [keyword.from_object(space, w_item) for w_item in keywords_w] + _starargs = expr.from_object(space, w_starargs) + _kwargs = expr.from_object(space, w_kwargs) body_w = space.unpackiterable(w_body) _body = [stmt.from_object(space, w_item) for w_item in body_w] decorator_list_w = space.unpackiterable(w_decorator_list) _decorator_list = [expr.from_object(space, w_item) for w_item in decorator_list_w] _lineno = space.int_w(w_lineno) _col_offset = space.int_w(w_col_offset) - return ClassDef(_name, _bases, _body, _decorator_list, _lineno, _col_offset) - -State.ast_type('ClassDef', 'stmt', ['name', 'bases', 'body', 'decorator_list']) ->>>>>>> theirs + return ClassDef(_name, _bases, _keywords, _starargs, _kwargs, _body, _decorator_list, _lineno, _col_offset) + +State.ast_type('ClassDef', 'stmt', ['name', 'bases', 'keywords', 'starargs', 'kwargs', 'body', 'decorator_list']) class Return(stmt): @@ -785,63 +700,6 @@ State.ast_type('AugAssign', 'stmt', ['target', 'op', 'value']) -<<<<<<< mine -======= -class Print(stmt): - - def __init__(self, dest, values, nl, lineno, col_offset): - self.dest = dest - self.values = values - self.nl = nl - stmt.__init__(self, lineno, col_offset) - - def walkabout(self, visitor): - visitor.visit_Print(self) - - def mutate_over(self, visitor): - if self.dest: - self.dest = self.dest.mutate_over(visitor) - if self.values: - visitor._mutate_sequence(self.values) - return visitor.visit_Print(self) - - def to_object(self, space): - w_node = space.call_function(get(space).w_Print) - w_dest = self.dest.to_object(space) if self.dest is not None else space.w_None # expr - space.setattr(w_node, space.wrap('dest'), w_dest) - if self.values is None: - values_w = [] - else: - values_w = [node.to_object(space) for node in self.values] # expr - w_values = space.newlist(values_w) - space.setattr(w_node, space.wrap('values'), w_values) - w_nl = space.wrap(self.nl) # bool - space.setattr(w_node, space.wrap('nl'), w_nl) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) - return w_node - - @staticmethod - def from_object(space, w_node): - w_dest = get_field(space, w_node, 'dest', True) - w_values = get_field(space, w_node, 'values', False) - w_nl = get_field(space, w_node, 'nl', False) - w_lineno = get_field(space, w_node, 'lineno', False) - w_col_offset = get_field(space, w_node, 'col_offset', False) - _dest = expr.from_object(space, w_dest) - values_w = space.unpackiterable(w_values) - _values = [expr.from_object(space, w_item) for w_item in values_w] - _nl = space.bool_w(w_nl) - _lineno = space.int_w(w_lineno) - _col_offset = space.int_w(w_col_offset) - return Print(_dest, _values, _nl, _lineno, _col_offset) - -State.ast_type('Print', 'stmt', ['dest', 'values', 'nl']) - - ->>>>>>> theirs class For(stmt): def __init__(self, target, iter, body, orelse, lineno, col_offset): @@ -1089,10 +947,6 @@ self.exc = exc self.cause = cause stmt.__init__(self, lineno, col_offset) -<<<<<<< mine - self.initialization_state = 15 -======= ->>>>>>> theirs def walkabout(self, visitor): visitor.visit_Raise(self) @@ -1104,28 +958,12 @@ self.cause = self.cause.mutate_over(visitor) return visitor.visit_Raise(self) -<<<<<<< mine - def sync_app_attrs(self, space): - if (self.initialization_state & ~12) ^ 3: - self.missing_field(space, ['lineno', 'col_offset', None, None], 'Raise') - else: - if not self.initialization_state & 4: - self.exc = None - if not self.initialization_state & 8: - self.cause = None - if self.exc: - self.exc.sync_app_attrs(space) - if self.cause: - self.cause.sync_app_attrs(space) -======= def to_object(self, space): w_node = space.call_function(get(space).w_Raise) - w_type = self.type.to_object(space) if self.type is not None else space.w_None # expr - space.setattr(w_node, space.wrap('type'), w_type) - w_inst = self.inst.to_object(space) if self.inst is not None else space.w_None # expr - space.setattr(w_node, space.wrap('inst'), w_inst) - w_tback = self.tback.to_object(space) if self.tback is not None else space.w_None # expr - space.setattr(w_node, space.wrap('tback'), w_tback) + w_exc = self.exc.to_object(space) if self.exc is not None else space.w_None # expr + space.setattr(w_node, space.wrap('exc'), w_exc) + w_cause = self.cause.to_object(space) if self.cause is not None else space.w_None # expr + space.setattr(w_node, space.wrap('cause'), w_cause) w_lineno = space.wrap(self.lineno) # int space.setattr(w_node, space.wrap('lineno'), w_lineno) w_col_offset = space.wrap(self.col_offset) # int @@ -1134,20 +972,17 @@ @staticmethod def from_object(space, w_node): - w_type = get_field(space, w_node, 'type', True) - w_inst = get_field(space, w_node, 'inst', True) - w_tback = get_field(space, w_node, 'tback', True) + w_exc = get_field(space, w_node, 'exc', True) + w_cause = get_field(space, w_node, 'cause', True) w_lineno = get_field(space, w_node, 'lineno', False) w_col_offset = get_field(space, w_node, 'col_offset', False) - _type = expr.from_object(space, w_type) - _inst = expr.from_object(space, w_inst) - _tback = expr.from_object(space, w_tback) + _exc = expr.from_object(space, w_exc) + _cause = expr.from_object(space, w_cause) _lineno = space.int_w(w_lineno) _col_offset = space.int_w(w_col_offset) - return Raise(_type, _inst, _tback, _lineno, _col_offset) - -State.ast_type('Raise', 'stmt', ['type', 'inst', 'tback']) ->>>>>>> theirs + return Raise(_exc, _cause, _lineno, _col_offset) + +State.ast_type('Raise', 'stmt', ['exc', 'cause']) class TryExcept(stmt): @@ -1411,12 +1246,7 @@ def __init__(self, names, lineno, col_offset): self.names = names - self.w_names = None stmt.__init__(self, lineno, col_offset) -<<<<<<< mine - self.initialization_state = 7 -======= ->>>>>>> theirs def walkabout(self, visitor): visitor.visit_Global(self) @@ -1424,78 +1254,6 @@ def mutate_over(self, visitor): return visitor.visit_Global(self) -<<<<<<< mine - def sync_app_attrs(self, space): - if (self.initialization_state & ~0) ^ 7: - self.missing_field(space, ['lineno', 'col_offset', 'names'], 'Global') - else: - pass - w_list = self.w_names - if w_list is not None: - list_w = space.listview(w_list) - if list_w: - self.names = [space.identifier_w(w_obj) for w_obj in list_w] - else: - self.names = None -======= - def to_object(self, space): - w_node = space.call_function(get(space).w_Exec) - w_body = self.body.to_object(space) # expr - space.setattr(w_node, space.wrap('body'), w_body) - w_globals = self.globals.to_object(space) if self.globals is not None else space.w_None # expr - space.setattr(w_node, space.wrap('globals'), w_globals) - w_locals = self.locals.to_object(space) if self.locals is not None else space.w_None # expr - space.setattr(w_node, space.wrap('locals'), w_locals) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) - return w_node - - @staticmethod - def from_object(space, w_node): - w_body = get_field(space, w_node, 'body', False) - w_globals = get_field(space, w_node, 'globals', True) - w_locals = get_field(space, w_node, 'locals', True) - w_lineno = get_field(space, w_node, 'lineno', False) - w_col_offset = get_field(space, w_node, 'col_offset', False) - _body = expr.from_object(space, w_body) - _globals = expr.from_object(space, w_globals) - _locals = expr.from_object(space, w_locals) - _lineno = space.int_w(w_lineno) - _col_offset = space.int_w(w_col_offset) - return Exec(_body, _globals, _locals, _lineno, _col_offset) - -State.ast_type('Exec', 'stmt', ['body', 'globals', 'locals']) ->>>>>>> theirs - - -class Nonlocal(stmt): - - def __init__(self, names, lineno, col_offset): - self.names = names - stmt.__init__(self, lineno, col_offset) - - def walkabout(self, visitor): - visitor.visit_Nonlocal(self) - - def mutate_over(self, visitor): - return visitor.visit_Nonlocal(self) - -<<<<<<< mine - def sync_app_attrs(self, space): - if (self.initialization_state & ~0) ^ 7: - self.missing_field(space, ['lineno', 'col_offset', 'names'], 'Nonlocal') - else: - pass - w_list = self.w_names - if w_list is not None: - list_w = space.listview(w_list) - if list_w: - self.names = [space.identifier_w(w_obj) for w_obj in list_w] - else: - self.names = None -======= def to_object(self, space): w_node = space.call_function(get(space).w_Global) if self.names is None: @@ -1522,7 +1280,46 @@ return Global(_names, _lineno, _col_offset) State.ast_type('Global', 'stmt', ['names']) ->>>>>>> theirs + + +class Nonlocal(stmt): + + def __init__(self, names, lineno, col_offset): + self.names = names + stmt.__init__(self, lineno, col_offset) + + def walkabout(self, visitor): + visitor.visit_Nonlocal(self) + + def mutate_over(self, visitor): + return visitor.visit_Nonlocal(self) + + def to_object(self, space): + w_node = space.call_function(get(space).w_Nonlocal) + if self.names is None: + names_w = [] + else: + names_w = [space.wrap(node) for node in self.names] # identifier + w_names = space.newlist(names_w) + space.setattr(w_node, space.wrap('names'), w_names) + w_lineno = space.wrap(self.lineno) # int + space.setattr(w_node, space.wrap('lineno'), w_lineno) + w_col_offset = space.wrap(self.col_offset) # int + space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + return w_node + + @staticmethod + def from_object(space, w_node): + w_names = get_field(space, w_node, 'names', False) + w_lineno = get_field(space, w_node, 'lineno', False) + w_col_offset = get_field(space, w_node, 'col_offset', False) + names_w = space.unpackiterable(w_names) + _names = [space.realstr_w(w_item) for w_item in names_w] + _lineno = space.int_w(w_lineno) + _col_offset = space.int_w(w_col_offset) + return Nonlocal(_names, _lineno, _col_offset) + +State.ast_type('Nonlocal', 'stmt', ['names']) class Expr(stmt): @@ -1689,16 +1486,20 @@ return Compare.from_object(space, w_node) if space.isinstance_w(w_node, get(space).w_Call): return Call.from_object(space, w_node) - if space.isinstance_w(w_node, get(space).w_Repr): - return Repr.from_object(space, w_node) if space.isinstance_w(w_node, get(space).w_Num): return Num.from_object(space, w_node) if space.isinstance_w(w_node, get(space).w_Str): return Str.from_object(space, w_node) + if space.isinstance_w(w_node, get(space).w_Bytes): + return Bytes.from_object(space, w_node) + if space.isinstance_w(w_node, get(space).w_Ellipsis): + return Ellipsis.from_object(space, w_node) if space.isinstance_w(w_node, get(space).w_Attribute): return Attribute.from_object(space, w_node) if space.isinstance_w(w_node, get(space).w_Subscript): return Subscript.from_object(space, w_node) + if space.isinstance_w(w_node, get(space).w_Starred): + return Starred.from_object(space, w_node) if space.isinstance_w(w_node, get(space).w_Name): return Name.from_object(space, w_node) if space.isinstance_w(w_node, get(space).w_List): @@ -2411,56 +2212,6 @@ def mutate_over(self, visitor): return visitor.visit_Num(self) -<<<<<<< mine - def sync_app_attrs(self, space): - if (self.initialization_state & ~0) ^ 7: - self.missing_field(space, ['lineno', 'col_offset', 'n'], 'Num') - else: - pass -======= - def to_object(self, space): - w_node = space.call_function(get(space).w_Repr) - w_value = self.value.to_object(space) # expr - space.setattr(w_node, space.wrap('value'), w_value) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) - return w_node - - @staticmethod - def from_object(space, w_node): - w_value = get_field(space, w_node, 'value', False) - w_lineno = get_field(space, w_node, 'lineno', False) - w_col_offset = get_field(space, w_node, 'col_offset', False) - _value = expr.from_object(space, w_value) - _lineno = space.int_w(w_lineno) - _col_offset = space.int_w(w_col_offset) - return Repr(_value, _lineno, _col_offset) - -State.ast_type('Repr', 'expr', ['value']) ->>>>>>> theirs - - -class Str(expr): - - def __init__(self, s, lineno, col_offset): - self.s = s - expr.__init__(self, lineno, col_offset) - - def walkabout(self, visitor): - visitor.visit_Str(self) - - def mutate_over(self, visitor): - return visitor.visit_Str(self) - -<<<<<<< mine - def sync_app_attrs(self, space): - if (self.initialization_state & ~0) ^ 7: - self.missing_field(space, ['lineno', 'col_offset', 's'], 'Str') - else: - pass -======= def to_object(self, space): w_node = space.call_function(get(space).w_Num) w_n = self.n # object @@ -2482,47 +2233,20 @@ return Num(_n, _lineno, _col_offset) State.ast_type('Num', 'expr', ['n']) ->>>>>>> theirs - - -class Bytes(expr): + + +class Str(expr): def __init__(self, s, lineno, col_offset): self.s = s expr.__init__(self, lineno, col_offset) def walkabout(self, visitor): - visitor.visit_Bytes(self) + visitor.visit_Str(self) def mutate_over(self, visitor): - return visitor.visit_Bytes(self) - -<<<<<<< mine - def sync_app_attrs(self, space): - if (self.initialization_state & ~0) ^ 7: - self.missing_field(space, ['lineno', 'col_offset', 's'], 'Bytes') - else: - pass - - -class Ellipsis(expr): - - def __init__(self, lineno, col_offset): - expr.__init__(self, lineno, col_offset) - self.initialization_state = 3 - - def walkabout(self, visitor): - visitor.visit_Ellipsis(self) - - def mutate_over(self, visitor): - return visitor.visit_Ellipsis(self) - - def sync_app_attrs(self, space): - if (self.initialization_state & ~0) ^ 3: - self.missing_field(space, ['lineno', 'col_offset'], 'Ellipsis') - else: - pass -======= + return visitor.visit_Str(self) + def to_object(self, space): w_node = space.call_function(get(space).w_Str) w_s = self.s # string @@ -2544,7 +2268,71 @@ return Str(_s, _lineno, _col_offset) State.ast_type('Str', 'expr', ['s']) ->>>>>>> theirs + + +class Bytes(expr): + + def __init__(self, s, lineno, col_offset): + self.s = s + expr.__init__(self, lineno, col_offset) + + def walkabout(self, visitor): + visitor.visit_Bytes(self) + + def mutate_over(self, visitor): + return visitor.visit_Bytes(self) + + def to_object(self, space): + w_node = space.call_function(get(space).w_Bytes) + w_s = self.s # string + space.setattr(w_node, space.wrap('s'), w_s) + w_lineno = space.wrap(self.lineno) # int + space.setattr(w_node, space.wrap('lineno'), w_lineno) + w_col_offset = space.wrap(self.col_offset) # int + space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + return w_node + + @staticmethod + def from_object(space, w_node): + w_s = get_field(space, w_node, 's', False) + w_lineno = get_field(space, w_node, 'lineno', False) + w_col_offset = get_field(space, w_node, 'col_offset', False) + _s = check_string(space, w_s) + _lineno = space.int_w(w_lineno) + _col_offset = space.int_w(w_col_offset) + return Bytes(_s, _lineno, _col_offset) + +State.ast_type('Bytes', 'expr', ['s']) + + +class Ellipsis(expr): + + def __init__(self, lineno, col_offset): + expr.__init__(self, lineno, col_offset) + + def walkabout(self, visitor): + visitor.visit_Ellipsis(self) + + def mutate_over(self, visitor): + return visitor.visit_Ellipsis(self) + + def to_object(self, space): + w_node = space.call_function(get(space).w_Ellipsis) + w_lineno = space.wrap(self.lineno) # int + space.setattr(w_node, space.wrap('lineno'), w_lineno) + w_col_offset = space.wrap(self.col_offset) # int + space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + return w_node + + @staticmethod + def from_object(space, w_node): + w_lineno = get_field(space, w_node, 'lineno', False) + w_col_offset = get_field(space, w_node, 'col_offset', False) + _lineno = space.int_w(w_lineno) + _col_offset = space.int_w(w_col_offset) + return Ellipsis(_lineno, _col_offset) + +State.ast_type('Ellipsis', 'expr', []) class Attribute(expr): @@ -2646,7 +2434,6 @@ self.value = value self.ctx = ctx expr.__init__(self, lineno, col_offset) - self.initialization_state = 15 def walkabout(self, visitor): visitor.visit_Starred(self) @@ -2655,12 +2442,31 @@ self.value = self.value.mutate_over(visitor) return visitor.visit_Starred(self) - def sync_app_attrs(self, space): - if (self.initialization_state & ~0) ^ 15: - self.missing_field(space, ['lineno', 'col_offset', 'value', 'ctx'], 'Starred') - else: - pass - self.value.sync_app_attrs(space) + def to_object(self, space): + w_node = space.call_function(get(space).w_Starred) + w_value = self.value.to_object(space) # expr + space.setattr(w_node, space.wrap('value'), w_value) + w_ctx = expr_context_to_class[self.ctx - 1]().to_object(space) # expr_context + space.setattr(w_node, space.wrap('ctx'), w_ctx) + w_lineno = space.wrap(self.lineno) # int + space.setattr(w_node, space.wrap('lineno'), w_lineno) + w_col_offset = space.wrap(self.col_offset) # int + space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + return w_node + + @staticmethod + def from_object(space, w_node): + w_value = get_field(space, w_node, 'value', False) + w_ctx = get_field(space, w_node, 'ctx', False) + w_lineno = get_field(space, w_node, 'lineno', False) + w_col_offset = get_field(space, w_node, 'col_offset', False) + _value = expr.from_object(space, w_value) + _ctx = expr_context.from_object(space, w_ctx) + _lineno = space.int_w(w_lineno) + _col_offset = space.int_w(w_col_offset) + return Starred(_value, _ctx, _lineno, _col_offset) + +State.ast_type('Starred', 'expr', ['value', 'ctx']) class Name(expr): @@ -2902,8 +2708,6 @@ def from_object(space, w_node): if space.is_w(w_node, space.w_None): return None - if space.isinstance_w(w_node, get(space).w_Ellipsis): - return Ellipsis.from_object(space, w_node) if space.isinstance_w(w_node, get(space).w_Slice): return Slice.from_object(space, w_node) if space.isinstance_w(w_node, get(space).w_ExtSlice): @@ -2914,29 +2718,6 @@ "Expected slice node, got %T", w_node) State.ast_type('slice', 'AST', None, []) -<<<<<<< mine -======= -class Ellipsis(slice): - - - def walkabout(self, visitor): - visitor.visit_Ellipsis(self) - - def mutate_over(self, visitor): - return visitor.visit_Ellipsis(self) - - def to_object(self, space): - w_node = space.call_function(get(space).w_Ellipsis) - return w_node - - @staticmethod - def from_object(space, w_node): - return Ellipsis() - -State.ast_type('Ellipsis', 'slice', []) - - ->>>>>>> theirs class Slice(slice): def __init__(self, lower, upper, step): @@ -3413,33 +3194,11 @@ visitor._mutate_sequence(self.body) return visitor.visit_ExceptHandler(self) -<<<<<<< mine - def sync_app_attrs(self, space): - if (self.initialization_state & ~12) ^ 19: - self.missing_field(space, ['lineno', 'col_offset', None, None, 'body'], 'ExceptHandler') - else: - if not self.initialization_state & 4: - self.type = None - if not self.initialization_state & 8: - self.name = None - if self.type: - self.type.sync_app_attrs(space) - w_list = self.w_body - if w_list is not None: - list_w = space.listview(w_list) - if list_w: - self.body = [space.interp_w(stmt, w_obj) for w_obj in list_w] - else: - self.body = None - if self.body is not None: - for node in self.body: - node.sync_app_attrs(space) -======= def to_object(self, space): w_node = space.call_function(get(space).w_ExceptHandler) w_type = self.type.to_object(space) if self.type is not None else space.w_None # expr space.setattr(w_node, space.wrap('type'), w_type) - w_name = self.name.to_object(space) if self.name is not None else space.w_None # expr + w_name = space.wrap(self.name) # identifier space.setattr(w_node, space.wrap('name'), w_name) if self.body is None: body_w = [] @@ -3461,7 +3220,7 @@ w_lineno = get_field(space, w_node, 'lineno', False) w_col_offset = get_field(space, w_node, 'col_offset', False) _type = expr.from_object(space, w_type) - _name = expr.from_object(space, w_name) + _name = space.str_or_None_w(w_name) body_w = space.unpackiterable(w_body) _body = [stmt.from_object(space, w_item) for w_item in body_w] _lineno = space.int_w(w_lineno) @@ -3469,7 +3228,6 @@ return ExceptHandler(_type, _name, _body, _lineno, _col_offset) State.ast_type('ExceptHandler', 'excepthandler', ['type', 'name', 'body']) ->>>>>>> theirs class arguments(AST): @@ -3479,17 +3237,10 @@ self.vararg = vararg self.varargannotation = varargannotation self.kwonlyargs = kwonlyargs - self.w_kwonlyargs = None self.kwarg = kwarg self.kwargannotation = kwargannotation self.defaults = defaults -<<<<<<< mine - self.w_defaults = None self.kw_defaults = kw_defaults - self.w_kw_defaults = None - self.initialization_state = 255 -======= ->>>>>>> theirs def mutate_over(self, visitor): if self.args: @@ -3509,125 +3260,99 @@ def walkabout(self, visitor): visitor.visit_arguments(self) -<<<<<<< mine - def sync_app_attrs(self, space): - if (self.initialization_state & ~54) ^ 201: - self.missing_field(space, ['args', None, None, 'kwonlyargs', None, None, 'defaults', 'kw_defaults'], 'arguments') - else: - if not self.initialization_state & 2: - self.vararg = None - if not self.initialization_state & 4: - self.varargannotation = None - if not self.initialization_state & 16: - self.kwarg = None - if not self.initialization_state & 32: - self.kwargannotation = None - w_list = self.w_args - if w_list is not None: - list_w = space.listview(w_list) - if list_w: - self.args = [space.interp_w(arg, w_obj) for w_obj in list_w] - else: - self.args = None - if self.args is not None: - for node in self.args: - node.sync_app_attrs(space) - if self.varargannotation: - self.varargannotation.sync_app_attrs(space) - w_list = self.w_kwonlyargs - if w_list is not None: - list_w = space.listview(w_list) - if list_w: - self.kwonlyargs = [space.interp_w(arg, w_obj) for w_obj in list_w] - else: - self.kwonlyargs = None - if self.kwonlyargs is not None: - for node in self.kwonlyargs: - node.sync_app_attrs(space) - if self.kwargannotation: - self.kwargannotation.sync_app_attrs(space) - w_list = self.w_defaults - if w_list is not None: - list_w = space.listview(w_list) - if list_w: - self.defaults = [space.interp_w(expr, w_obj) for w_obj in list_w] - else: - self.defaults = None - if self.defaults is not None: - for node in self.defaults: - node.sync_app_attrs(space) - w_list = self.w_kw_defaults - if w_list is not None: - list_w = space.listview(w_list) - if list_w: - self.kw_defaults = [space.interp_w(expr, w_obj) for w_obj in list_w] - else: - self.kw_defaults = None - if self.kw_defaults is not None: - for node in self.kw_defaults: - if node: - node.sync_app_attrs(space) - -class arg(AST): - - def __init__(self, arg, annotation): - self.arg = arg - self.annotation = annotation - self.initialization_state = 3 - - def mutate_over(self, visitor): - if self.annotation: - self.annotation = self.annotation.mutate_over(visitor) - return visitor.visit_arg(self) - - def walkabout(self, visitor): - visitor.visit_arg(self) - - def sync_app_attrs(self, space): - if (self.initialization_state & ~2) ^ 1: - self.missing_field(space, ['arg', None], 'arg') - else: - if not self.initialization_state & 2: - self.annotation = None - if self.annotation: - self.annotation.sync_app_attrs(space) -======= def to_object(self, space): w_node = space.call_function(get(space).w_arguments) if self.args is None: args_w = [] else: - args_w = [node.to_object(space) for node in self.args] # expr + args_w = [node.to_object(space) for node in self.args] # arg w_args = space.newlist(args_w) space.setattr(w_node, space.wrap('args'), w_args) w_vararg = space.wrap(self.vararg) # identifier space.setattr(w_node, space.wrap('vararg'), w_vararg) + w_varargannotation = self.varargannotation.to_object(space) if self.varargannotation is not None else space.w_None # expr + space.setattr(w_node, space.wrap('varargannotation'), w_varargannotation) + if self.kwonlyargs is None: + kwonlyargs_w = [] + else: + kwonlyargs_w = [node.to_object(space) for node in self.kwonlyargs] # arg + w_kwonlyargs = space.newlist(kwonlyargs_w) + space.setattr(w_node, space.wrap('kwonlyargs'), w_kwonlyargs) w_kwarg = space.wrap(self.kwarg) # identifier space.setattr(w_node, space.wrap('kwarg'), w_kwarg) + w_kwargannotation = self.kwargannotation.to_object(space) if self.kwargannotation is not None else space.w_None # expr + space.setattr(w_node, space.wrap('kwargannotation'), w_kwargannotation) if self.defaults is None: defaults_w = [] else: defaults_w = [node.to_object(space) for node in self.defaults] # expr w_defaults = space.newlist(defaults_w) space.setattr(w_node, space.wrap('defaults'), w_defaults) + if self.kw_defaults is None: + kw_defaults_w = [] + else: + kw_defaults_w = [node.to_object(space) for node in self.kw_defaults] # expr + w_kw_defaults = space.newlist(kw_defaults_w) + space.setattr(w_node, space.wrap('kw_defaults'), w_kw_defaults) return w_node @staticmethod def from_object(space, w_node): w_args = get_field(space, w_node, 'args', False) w_vararg = get_field(space, w_node, 'vararg', True) + w_varargannotation = get_field(space, w_node, 'varargannotation', True) + w_kwonlyargs = get_field(space, w_node, 'kwonlyargs', False) w_kwarg = get_field(space, w_node, 'kwarg', True) + w_kwargannotation = get_field(space, w_node, 'kwargannotation', True) w_defaults = get_field(space, w_node, 'defaults', False) + w_kw_defaults = get_field(space, w_node, 'kw_defaults', False) args_w = space.unpackiterable(w_args) - _args = [expr.from_object(space, w_item) for w_item in args_w] + _args = [arg.from_object(space, w_item) for w_item in args_w] _vararg = space.str_or_None_w(w_vararg) + _varargannotation = expr.from_object(space, w_varargannotation) + kwonlyargs_w = space.unpackiterable(w_kwonlyargs) + _kwonlyargs = [arg.from_object(space, w_item) for w_item in kwonlyargs_w] _kwarg = space.str_or_None_w(w_kwarg) + _kwargannotation = expr.from_object(space, w_kwargannotation) defaults_w = space.unpackiterable(w_defaults) _defaults = [expr.from_object(space, w_item) for w_item in defaults_w] - return arguments(_args, _vararg, _kwarg, _defaults) - -State.ast_type('arguments', 'AST', ['args', 'vararg', 'kwarg', 'defaults']) ->>>>>>> theirs + kw_defaults_w = space.unpackiterable(w_kw_defaults) + _kw_defaults = [expr.from_object(space, w_item) for w_item in kw_defaults_w] + return arguments(_args, _vararg, _varargannotation, _kwonlyargs, _kwarg, _kwargannotation, _defaults, _kw_defaults) + +State.ast_type('arguments', 'AST', ['args', 'vararg', 'varargannotation', 'kwonlyargs', 'kwarg', 'kwargannotation', 'defaults', 'kw_defaults']) + +class arg(AST): + + def __init__(self, arg, annotation): + self.arg = arg + self.annotation = annotation + + def mutate_over(self, visitor): + if self.annotation: + self.annotation = self.annotation.mutate_over(visitor) + return visitor.visit_arg(self) + + def walkabout(self, visitor): + visitor.visit_arg(self) + + def to_object(self, space): + w_node = space.call_function(get(space).w_arg) + w_arg = space.wrap(self.arg) # identifier + space.setattr(w_node, space.wrap('arg'), w_arg) + w_annotation = self.annotation.to_object(space) if self.annotation is not None else space.w_None # expr + space.setattr(w_node, space.wrap('annotation'), w_annotation) + return w_node + + @staticmethod + def from_object(space, w_node): + w_arg = get_field(space, w_node, 'arg', False) + w_annotation = get_field(space, w_node, 'annotation', True) + _arg = space.realstr_w(w_arg) + _annotation = expr.from_object(space, w_annotation) + return arg(_arg, _annotation) + +State.ast_type('arg', 'AST', ['arg', 'annotation']) class keyword(AST): @@ -4083,5518 +3808,3 @@ pass -<<<<<<< mine -mod.typedef = typedef.TypeDef("mod", - AST.typedef, - __module__='_ast', - _attributes=_FieldsWrapper([]), - __new__=interp2app(get_AST_new(mod)), -) -mod.typedef.heaptype = True - -def Module_get_body(space, w_self): - if not w_self.initialization_state & 1: - raise_attriberr(space, w_self, 'body') - if w_self.w_body is None: - if w_self.body is None: - list_w = [] - else: - list_w = [space.wrap(node) for node in w_self.body] - w_list = space.newlist(list_w) - w_self.w_body = w_list - return w_self.w_body - -def Module_set_body(space, w_self, w_new_value): - w_self.w_body = w_new_value - w_self.initialization_state |= 1 - -def Module_del_body(space, w_self): - # Check if the element exists, raise appropriate exceptions - Module_get_body(space, w_self) - w_self.deldictvalue(space, 'body') - w_self.initialization_state &= ~1 - -_Module_field_unroller = unrolling_iterable(['body']) -def Module_init(space, w_self, __args__): - w_self = space.descr_self_interp_w(Module, w_self) - w_self.w_body = None - args_w, kwargs_w = __args__.unpack() - if args_w: - if len(args_w) != 1: - w_err = space.wrap("Module constructor takes either 0 or 1 positional argument") - raise OperationError(space.w_TypeError, w_err) - i = 0 - for field in _Module_field_unroller: - space.setattr(w_self, space.wrap(field), args_w[i]) - i += 1 - for field, w_value in kwargs_w.iteritems(): - space.setattr(w_self, space.wrap(field), w_value) - -Module.typedef = typedef.TypeDef("Module", - mod.typedef, - __module__='_ast', - _fields=_FieldsWrapper(['body']), - body=typedef.GetSetProperty(Module_get_body, Module_set_body, Module_del_body, cls=Module), - __new__=interp2app(get_AST_new(Module)), - __init__=interp2app(Module_init), -) -Module.typedef.heaptype = True - -def Interactive_get_body(space, w_self): - if not w_self.initialization_state & 1: - raise_attriberr(space, w_self, 'body') - if w_self.w_body is None: - if w_self.body is None: - list_w = [] - else: - list_w = [space.wrap(node) for node in w_self.body] - w_list = space.newlist(list_w) - w_self.w_body = w_list - return w_self.w_body - -def Interactive_set_body(space, w_self, w_new_value): - w_self.w_body = w_new_value - w_self.initialization_state |= 1 - -def Interactive_del_body(space, w_self): - # Check if the element exists, raise appropriate exceptions - Interactive_get_body(space, w_self) - w_self.deldictvalue(space, 'body') - w_self.initialization_state &= ~1 - -_Interactive_field_unroller = unrolling_iterable(['body']) -def Interactive_init(space, w_self, __args__): - w_self = space.descr_self_interp_w(Interactive, w_self) - w_self.w_body = None - args_w, kwargs_w = __args__.unpack() - if args_w: - if len(args_w) != 1: - w_err = space.wrap("Interactive constructor takes either 0 or 1 positional argument") - raise OperationError(space.w_TypeError, w_err) - i = 0 - for field in _Interactive_field_unroller: - space.setattr(w_self, space.wrap(field), args_w[i]) - i += 1 - for field, w_value in kwargs_w.iteritems(): - space.setattr(w_self, space.wrap(field), w_value) - -Interactive.typedef = typedef.TypeDef("Interactive", - mod.typedef, - __module__='_ast', - _fields=_FieldsWrapper(['body']), - body=typedef.GetSetProperty(Interactive_get_body, Interactive_set_body, Interactive_del_body, cls=Interactive), - __new__=interp2app(get_AST_new(Interactive)), - __init__=interp2app(Interactive_init), -) -Interactive.typedef.heaptype = True - -def Expression_get_body(space, w_self): - if w_self.w_dict is not None: - w_obj = w_self.getdictvalue(space, 'body') - if w_obj is not None: - return w_obj - if not w_self.initialization_state & 1: - raise_attriberr(space, w_self, 'body') - return space.wrap(w_self.body) - -def Expression_set_body(space, w_self, w_new_value): - try: - w_self.body = space.interp_w(expr, w_new_value, False) - if type(w_self.body) is expr: - raise OperationError(space.w_TypeError, space.w_None) - except OperationError, e: - if not e.match(space, space.w_TypeError): - raise - w_self.setdictvalue(space, 'body', w_new_value) - w_self.initialization_state &= ~1 - return - w_self.deldictvalue(space, 'body') - w_self.initialization_state |= 1 - -def Expression_del_body(space, w_self): - # Check if the element exists, raise appropriate exceptions - Expression_get_body(space, w_self) - w_self.deldictvalue(space, 'body') - w_self.initialization_state &= ~1 - -_Expression_field_unroller = unrolling_iterable(['body']) -def Expression_init(space, w_self, __args__): - w_self = space.descr_self_interp_w(Expression, w_self) - args_w, kwargs_w = __args__.unpack() - if args_w: - if len(args_w) != 1: - w_err = space.wrap("Expression constructor takes either 0 or 1 positional argument") - raise OperationError(space.w_TypeError, w_err) - i = 0 - for field in _Expression_field_unroller: - space.setattr(w_self, space.wrap(field), args_w[i]) - i += 1 - for field, w_value in kwargs_w.iteritems(): - space.setattr(w_self, space.wrap(field), w_value) - -Expression.typedef = typedef.TypeDef("Expression", - mod.typedef, - __module__='_ast', - _fields=_FieldsWrapper(['body']), - body=typedef.GetSetProperty(Expression_get_body, Expression_set_body, Expression_del_body, cls=Expression), - __new__=interp2app(get_AST_new(Expression)), - __init__=interp2app(Expression_init), -) -Expression.typedef.heaptype = True - -def Suite_get_body(space, w_self): - if not w_self.initialization_state & 1: - raise_attriberr(space, w_self, 'body') - if w_self.w_body is None: - if w_self.body is None: - list_w = [] - else: - list_w = [space.wrap(node) for node in w_self.body] - w_list = space.newlist(list_w) - w_self.w_body = w_list - return w_self.w_body - -def Suite_set_body(space, w_self, w_new_value): - w_self.w_body = w_new_value - w_self.initialization_state |= 1 - -def Suite_del_body(space, w_self): - # Check if the element exists, raise appropriate exceptions - Suite_get_body(space, w_self) - w_self.deldictvalue(space, 'body') - w_self.initialization_state &= ~1 - -_Suite_field_unroller = unrolling_iterable(['body']) -def Suite_init(space, w_self, __args__): - w_self = space.descr_self_interp_w(Suite, w_self) - w_self.w_body = None - args_w, kwargs_w = __args__.unpack() - if args_w: - if len(args_w) != 1: - w_err = space.wrap("Suite constructor takes either 0 or 1 positional argument") - raise OperationError(space.w_TypeError, w_err) - i = 0 - for field in _Suite_field_unroller: - space.setattr(w_self, space.wrap(field), args_w[i]) - i += 1 - for field, w_value in kwargs_w.iteritems(): - space.setattr(w_self, space.wrap(field), w_value) - -Suite.typedef = typedef.TypeDef("Suite", - mod.typedef, - __module__='_ast', - _fields=_FieldsWrapper(['body']), - body=typedef.GetSetProperty(Suite_get_body, Suite_set_body, Suite_del_body, cls=Suite), - __new__=interp2app(get_AST_new(Suite)), - __init__=interp2app(Suite_init), -) -Suite.typedef.heaptype = True - -def stmt_get_lineno(space, w_self): - if w_self.w_dict is not None: - w_obj = w_self.getdictvalue(space, 'lineno') - if w_obj is not None: - return w_obj - if not w_self.initialization_state & 1: - raise_attriberr(space, w_self, 'lineno') - return space.wrap(w_self.lineno) - -def stmt_set_lineno(space, w_self, w_new_value): - try: - w_self.lineno = space.int_w(w_new_value) - except OperationError, e: - if not e.match(space, space.w_TypeError): - raise - w_self.setdictvalue(space, 'lineno', w_new_value) - w_self.initialization_state &= ~1 - return - # need to save the original object too - w_self.setdictvalue(space, 'lineno', w_new_value) - w_self.initialization_state |= 1 - -def stmt_del_lineno(space, w_self): - # Check if the element exists, raise appropriate exceptions - stmt_get_lineno(space, w_self) - w_self.deldictvalue(space, 'lineno') - w_self.initialization_state &= ~1 - -def stmt_get_col_offset(space, w_self): - if w_self.w_dict is not None: - w_obj = w_self.getdictvalue(space, 'col_offset') - if w_obj is not None: - return w_obj - if not w_self.initialization_state & 2: - raise_attriberr(space, w_self, 'col_offset') - return space.wrap(w_self.col_offset) - -def stmt_set_col_offset(space, w_self, w_new_value): - try: - w_self.col_offset = space.int_w(w_new_value) - except OperationError, e: - if not e.match(space, space.w_TypeError): - raise - w_self.setdictvalue(space, 'col_offset', w_new_value) - w_self.initialization_state &= ~2 - return - # need to save the original object too - w_self.setdictvalue(space, 'col_offset', w_new_value) - w_self.initialization_state |= 2 - -def stmt_del_col_offset(space, w_self): - # Check if the element exists, raise appropriate exceptions - stmt_get_col_offset(space, w_self) - w_self.deldictvalue(space, 'col_offset') - w_self.initialization_state &= ~2 - -stmt.typedef = typedef.TypeDef("stmt", - AST.typedef, - __module__='_ast', - _attributes=_FieldsWrapper(['lineno', 'col_offset']), - lineno=typedef.GetSetProperty(stmt_get_lineno, stmt_set_lineno, stmt_del_lineno, cls=stmt), - col_offset=typedef.GetSetProperty(stmt_get_col_offset, stmt_set_col_offset, stmt_del_col_offset, cls=stmt), - __new__=interp2app(get_AST_new(stmt)), -) -stmt.typedef.heaptype = True - -def FunctionDef_get_name(space, w_self): - if w_self.w_dict is not None: - w_obj = w_self.getdictvalue(space, 'name') - if w_obj is not None: - return w_obj - if not w_self.initialization_state & 4: - raise_attriberr(space, w_self, 'name') - if w_self.name is None: - return space.w_None - return space.wrap(w_self.name.decode('utf-8')) - -def FunctionDef_set_name(space, w_self, w_new_value): - try: - w_self.name = space.identifier_w(w_new_value) - except OperationError, e: - if not e.match(space, space.w_TypeError): - raise - w_self.setdictvalue(space, 'name', w_new_value) - w_self.initialization_state &= ~4 - return - # need to save the original object too - w_self.setdictvalue(space, 'name', w_new_value) - w_self.initialization_state |= 4 - -def FunctionDef_del_name(space, w_self): - # Check if the element exists, raise appropriate exceptions - FunctionDef_get_name(space, w_self) - w_self.deldictvalue(space, 'name') - w_self.initialization_state &= ~4 - -def FunctionDef_get_args(space, w_self): - if w_self.w_dict is not None: - w_obj = w_self.getdictvalue(space, 'args') - if w_obj is not None: - return w_obj - if not w_self.initialization_state & 8: - raise_attriberr(space, w_self, 'args') - return space.wrap(w_self.args) - -def FunctionDef_set_args(space, w_self, w_new_value): - try: - w_self.args = space.interp_w(arguments, w_new_value, False) - except OperationError, e: - if not e.match(space, space.w_TypeError): - raise - w_self.setdictvalue(space, 'args', w_new_value) - w_self.initialization_state &= ~8 - return - w_self.deldictvalue(space, 'args') - w_self.initialization_state |= 8 - -def FunctionDef_del_args(space, w_self): - # Check if the element exists, raise appropriate exceptions - FunctionDef_get_args(space, w_self) - w_self.deldictvalue(space, 'args') - w_self.initialization_state &= ~8 - -def FunctionDef_get_body(space, w_self): - if not w_self.initialization_state & 16: - raise_attriberr(space, w_self, 'body') - if w_self.w_body is None: - if w_self.body is None: - list_w = [] - else: - list_w = [space.wrap(node) for node in w_self.body] - w_list = space.newlist(list_w) - w_self.w_body = w_list - return w_self.w_body - -def FunctionDef_set_body(space, w_self, w_new_value): - w_self.w_body = w_new_value - w_self.initialization_state |= 16 - -def FunctionDef_del_body(space, w_self): - # Check if the element exists, raise appropriate exceptions - FunctionDef_get_body(space, w_self) - w_self.deldictvalue(space, 'body') - w_self.initialization_state &= ~16 - -def FunctionDef_get_decorator_list(space, w_self): - if not w_self.initialization_state & 32: - raise_attriberr(space, w_self, 'decorator_list') - if w_self.w_decorator_list is None: - if w_self.decorator_list is None: - list_w = [] - else: - list_w = [space.wrap(node) for node in w_self.decorator_list] - w_list = space.newlist(list_w) - w_self.w_decorator_list = w_list - return w_self.w_decorator_list - -def FunctionDef_set_decorator_list(space, w_self, w_new_value): - w_self.w_decorator_list = w_new_value - w_self.initialization_state |= 32 - -def FunctionDef_del_decorator_list(space, w_self): - # Check if the element exists, raise appropriate exceptions - FunctionDef_get_decorator_list(space, w_self) - w_self.deldictvalue(space, 'decorator_list') - w_self.initialization_state &= ~32 - -def FunctionDef_get_returns(space, w_self): - if w_self.w_dict is not None: - w_obj = w_self.getdictvalue(space, 'returns') - if w_obj is not None: - return w_obj - if not w_self.initialization_state & 64: - raise_attriberr(space, w_self, 'returns') - return space.wrap(w_self.returns) - -def FunctionDef_set_returns(space, w_self, w_new_value): - try: - w_self.returns = space.interp_w(expr, w_new_value, True) - if type(w_self.returns) is expr: - raise OperationError(space.w_TypeError, space.w_None) - except OperationError, e: - if not e.match(space, space.w_TypeError): - raise - w_self.setdictvalue(space, 'returns', w_new_value) - w_self.initialization_state &= ~64 - return - w_self.deldictvalue(space, 'returns') - w_self.initialization_state |= 64 - -def FunctionDef_del_returns(space, w_self): - # Check if the element exists, raise appropriate exceptions - FunctionDef_get_returns(space, w_self) - w_self.deldictvalue(space, 'returns') - w_self.initialization_state &= ~64 - -_FunctionDef_field_unroller = unrolling_iterable(['name', 'args', 'body', 'decorator_list', 'returns']) -def FunctionDef_init(space, w_self, __args__): - w_self = space.descr_self_interp_w(FunctionDef, w_self) - w_self.w_body = None - w_self.w_decorator_list = None - args_w, kwargs_w = __args__.unpack() - if args_w: - if len(args_w) != 5: - w_err = space.wrap("FunctionDef constructor takes either 0 or 5 positional arguments") - raise OperationError(space.w_TypeError, w_err) - i = 0 - for field in _FunctionDef_field_unroller: - space.setattr(w_self, space.wrap(field), args_w[i]) - i += 1 - for field, w_value in kwargs_w.iteritems(): - space.setattr(w_self, space.wrap(field), w_value) - -FunctionDef.typedef = typedef.TypeDef("FunctionDef", - stmt.typedef, - __module__='_ast', - _fields=_FieldsWrapper(['name', 'args', 'body', 'decorator_list', 'returns']), - name=typedef.GetSetProperty(FunctionDef_get_name, FunctionDef_set_name, FunctionDef_del_name, cls=FunctionDef), - args=typedef.GetSetProperty(FunctionDef_get_args, FunctionDef_set_args, FunctionDef_del_args, cls=FunctionDef), - body=typedef.GetSetProperty(FunctionDef_get_body, FunctionDef_set_body, FunctionDef_del_body, cls=FunctionDef), - decorator_list=typedef.GetSetProperty(FunctionDef_get_decorator_list, FunctionDef_set_decorator_list, FunctionDef_del_decorator_list, cls=FunctionDef), - returns=typedef.GetSetProperty(FunctionDef_get_returns, FunctionDef_set_returns, FunctionDef_del_returns, cls=FunctionDef), - __new__=interp2app(get_AST_new(FunctionDef)), - __init__=interp2app(FunctionDef_init), -) -FunctionDef.typedef.heaptype = True - -def ClassDef_get_name(space, w_self): - if w_self.w_dict is not None: - w_obj = w_self.getdictvalue(space, 'name') - if w_obj is not None: - return w_obj - if not w_self.initialization_state & 4: - raise_attriberr(space, w_self, 'name') - if w_self.name is None: - return space.w_None - return space.wrap(w_self.name.decode('utf-8')) - -def ClassDef_set_name(space, w_self, w_new_value): - try: - w_self.name = space.identifier_w(w_new_value) - except OperationError, e: - if not e.match(space, space.w_TypeError): - raise - w_self.setdictvalue(space, 'name', w_new_value) - w_self.initialization_state &= ~4 - return - # need to save the original object too - w_self.setdictvalue(space, 'name', w_new_value) - w_self.initialization_state |= 4 - -def ClassDef_del_name(space, w_self): - # Check if the element exists, raise appropriate exceptions - ClassDef_get_name(space, w_self) - w_self.deldictvalue(space, 'name') - w_self.initialization_state &= ~4 - -def ClassDef_get_bases(space, w_self): - if not w_self.initialization_state & 8: - raise_attriberr(space, w_self, 'bases') - if w_self.w_bases is None: - if w_self.bases is None: - list_w = [] - else: - list_w = [space.wrap(node) for node in w_self.bases] - w_list = space.newlist(list_w) - w_self.w_bases = w_list - return w_self.w_bases - -def ClassDef_set_bases(space, w_self, w_new_value): - w_self.w_bases = w_new_value - w_self.initialization_state |= 8 - -def ClassDef_del_bases(space, w_self): - # Check if the element exists, raise appropriate exceptions - ClassDef_get_bases(space, w_self) - w_self.deldictvalue(space, 'bases') - w_self.initialization_state &= ~8 - -def ClassDef_get_keywords(space, w_self): - if not w_self.initialization_state & 16: - raise_attriberr(space, w_self, 'keywords') - if w_self.w_keywords is None: - if w_self.keywords is None: - list_w = [] - else: - list_w = [space.wrap(node) for node in w_self.keywords] - w_list = space.newlist(list_w) - w_self.w_keywords = w_list - return w_self.w_keywords - -def ClassDef_set_keywords(space, w_self, w_new_value): - w_self.w_keywords = w_new_value - w_self.initialization_state |= 16 - -def ClassDef_del_keywords(space, w_self): - # Check if the element exists, raise appropriate exceptions - ClassDef_get_keywords(space, w_self) - w_self.deldictvalue(space, 'keywords') - w_self.initialization_state &= ~16 - -def ClassDef_get_starargs(space, w_self): - if w_self.w_dict is not None: - w_obj = w_self.getdictvalue(space, 'starargs') - if w_obj is not None: - return w_obj - if not w_self.initialization_state & 32: - raise_attriberr(space, w_self, 'starargs') - return space.wrap(w_self.starargs) - -def ClassDef_set_starargs(space, w_self, w_new_value): - try: - w_self.starargs = space.interp_w(expr, w_new_value, True) - if type(w_self.starargs) is expr: - raise OperationError(space.w_TypeError, space.w_None) - except OperationError, e: - if not e.match(space, space.w_TypeError): - raise - w_self.setdictvalue(space, 'starargs', w_new_value) - w_self.initialization_state &= ~32 - return - w_self.deldictvalue(space, 'starargs') - w_self.initialization_state |= 32 - -def ClassDef_del_starargs(space, w_self): - # Check if the element exists, raise appropriate exceptions - ClassDef_get_starargs(space, w_self) - w_self.deldictvalue(space, 'starargs') - w_self.initialization_state &= ~32 - -def ClassDef_get_kwargs(space, w_self): - if w_self.w_dict is not None: - w_obj = w_self.getdictvalue(space, 'kwargs') - if w_obj is not None: - return w_obj - if not w_self.initialization_state & 64: - raise_attriberr(space, w_self, 'kwargs') - return space.wrap(w_self.kwargs) - -def ClassDef_set_kwargs(space, w_self, w_new_value): - try: - w_self.kwargs = space.interp_w(expr, w_new_value, True) - if type(w_self.kwargs) is expr: - raise OperationError(space.w_TypeError, space.w_None) - except OperationError, e: - if not e.match(space, space.w_TypeError): - raise - w_self.setdictvalue(space, 'kwargs', w_new_value) - w_self.initialization_state &= ~64 - return - w_self.deldictvalue(space, 'kwargs') - w_self.initialization_state |= 64 - -def ClassDef_del_kwargs(space, w_self): - # Check if the element exists, raise appropriate exceptions - ClassDef_get_kwargs(space, w_self) - w_self.deldictvalue(space, 'kwargs') - w_self.initialization_state &= ~64 - -def ClassDef_get_body(space, w_self): - if not w_self.initialization_state & 128: - raise_attriberr(space, w_self, 'body') - if w_self.w_body is None: - if w_self.body is None: - list_w = [] - else: - list_w = [space.wrap(node) for node in w_self.body] - w_list = space.newlist(list_w) - w_self.w_body = w_list - return w_self.w_body - -def ClassDef_set_body(space, w_self, w_new_value): - w_self.w_body = w_new_value - w_self.initialization_state |= 128 - -def ClassDef_del_body(space, w_self): - # Check if the element exists, raise appropriate exceptions - ClassDef_get_body(space, w_self) - w_self.deldictvalue(space, 'body') - w_self.initialization_state &= ~128 - -def ClassDef_get_decorator_list(space, w_self): - if not w_self.initialization_state & 256: - raise_attriberr(space, w_self, 'decorator_list') - if w_self.w_decorator_list is None: - if w_self.decorator_list is None: - list_w = [] - else: - list_w = [space.wrap(node) for node in w_self.decorator_list] - w_list = space.newlist(list_w) - w_self.w_decorator_list = w_list - return w_self.w_decorator_list - -def ClassDef_set_decorator_list(space, w_self, w_new_value): - w_self.w_decorator_list = w_new_value - w_self.initialization_state |= 256 - -def ClassDef_del_decorator_list(space, w_self): - # Check if the element exists, raise appropriate exceptions - ClassDef_get_decorator_list(space, w_self) - w_self.deldictvalue(space, 'decorator_list') - w_self.initialization_state &= ~256 - -_ClassDef_field_unroller = unrolling_iterable(['name', 'bases', 'keywords', 'starargs', 'kwargs', 'body', 'decorator_list']) -def ClassDef_init(space, w_self, __args__): - w_self = space.descr_self_interp_w(ClassDef, w_self) - w_self.w_bases = None - w_self.w_keywords = None - w_self.w_body = None - w_self.w_decorator_list = None - args_w, kwargs_w = __args__.unpack() - if args_w: - if len(args_w) != 7: - w_err = space.wrap("ClassDef constructor takes either 0 or 7 positional arguments") - raise OperationError(space.w_TypeError, w_err) - i = 0 - for field in _ClassDef_field_unroller: - space.setattr(w_self, space.wrap(field), args_w[i]) - i += 1 - for field, w_value in kwargs_w.iteritems(): - space.setattr(w_self, space.wrap(field), w_value) - -ClassDef.typedef = typedef.TypeDef("ClassDef", - stmt.typedef, - __module__='_ast', - _fields=_FieldsWrapper(['name', 'bases', 'keywords', 'starargs', 'kwargs', 'body', 'decorator_list']), - name=typedef.GetSetProperty(ClassDef_get_name, ClassDef_set_name, ClassDef_del_name, cls=ClassDef), - bases=typedef.GetSetProperty(ClassDef_get_bases, ClassDef_set_bases, ClassDef_del_bases, cls=ClassDef), - keywords=typedef.GetSetProperty(ClassDef_get_keywords, ClassDef_set_keywords, ClassDef_del_keywords, cls=ClassDef), - starargs=typedef.GetSetProperty(ClassDef_get_starargs, ClassDef_set_starargs, ClassDef_del_starargs, cls=ClassDef), - kwargs=typedef.GetSetProperty(ClassDef_get_kwargs, ClassDef_set_kwargs, ClassDef_del_kwargs, cls=ClassDef), - body=typedef.GetSetProperty(ClassDef_get_body, ClassDef_set_body, ClassDef_del_body, cls=ClassDef), - decorator_list=typedef.GetSetProperty(ClassDef_get_decorator_list, ClassDef_set_decorator_list, ClassDef_del_decorator_list, cls=ClassDef), - __new__=interp2app(get_AST_new(ClassDef)), - __init__=interp2app(ClassDef_init), -) -ClassDef.typedef.heaptype = True - -def Return_get_value(space, w_self): - if w_self.w_dict is not None: - w_obj = w_self.getdictvalue(space, 'value') - if w_obj is not None: - return w_obj - if not w_self.initialization_state & 4: - raise_attriberr(space, w_self, 'value') - return space.wrap(w_self.value) - -def Return_set_value(space, w_self, w_new_value): - try: - w_self.value = space.interp_w(expr, w_new_value, True) - if type(w_self.value) is expr: - raise OperationError(space.w_TypeError, space.w_None) - except OperationError, e: - if not e.match(space, space.w_TypeError): - raise - w_self.setdictvalue(space, 'value', w_new_value) - w_self.initialization_state &= ~4 - return - w_self.deldictvalue(space, 'value') - w_self.initialization_state |= 4 - -def Return_del_value(space, w_self): - # Check if the element exists, raise appropriate exceptions - Return_get_value(space, w_self) - w_self.deldictvalue(space, 'value') - w_self.initialization_state &= ~4 - -_Return_field_unroller = unrolling_iterable(['value']) -def Return_init(space, w_self, __args__): - w_self = space.descr_self_interp_w(Return, w_self) - args_w, kwargs_w = __args__.unpack() - if args_w: - if len(args_w) != 1: - w_err = space.wrap("Return constructor takes either 0 or 1 positional argument") - raise OperationError(space.w_TypeError, w_err) - i = 0 - for field in _Return_field_unroller: - space.setattr(w_self, space.wrap(field), args_w[i]) - i += 1 - for field, w_value in kwargs_w.iteritems(): - space.setattr(w_self, space.wrap(field), w_value) - -Return.typedef = typedef.TypeDef("Return", - stmt.typedef, - __module__='_ast', - _fields=_FieldsWrapper(['value']), - value=typedef.GetSetProperty(Return_get_value, Return_set_value, Return_del_value, cls=Return), - __new__=interp2app(get_AST_new(Return)), - __init__=interp2app(Return_init), -) -Return.typedef.heaptype = True - -def Delete_get_targets(space, w_self): - if not w_self.initialization_state & 4: - raise_attriberr(space, w_self, 'targets') - if w_self.w_targets is None: - if w_self.targets is None: - list_w = [] - else: - list_w = [space.wrap(node) for node in w_self.targets] - w_list = space.newlist(list_w) - w_self.w_targets = w_list - return w_self.w_targets - -def Delete_set_targets(space, w_self, w_new_value): - w_self.w_targets = w_new_value - w_self.initialization_state |= 4 - -def Delete_del_targets(space, w_self): - # Check if the element exists, raise appropriate exceptions - Delete_get_targets(space, w_self) - w_self.deldictvalue(space, 'targets') - w_self.initialization_state &= ~4 - -_Delete_field_unroller = unrolling_iterable(['targets']) -def Delete_init(space, w_self, __args__): - w_self = space.descr_self_interp_w(Delete, w_self) - w_self.w_targets = None - args_w, kwargs_w = __args__.unpack() - if args_w: - if len(args_w) != 1: - w_err = space.wrap("Delete constructor takes either 0 or 1 positional argument") - raise OperationError(space.w_TypeError, w_err) - i = 0 - for field in _Delete_field_unroller: - space.setattr(w_self, space.wrap(field), args_w[i]) - i += 1 - for field, w_value in kwargs_w.iteritems(): - space.setattr(w_self, space.wrap(field), w_value) - -Delete.typedef = typedef.TypeDef("Delete", - stmt.typedef, - __module__='_ast', - _fields=_FieldsWrapper(['targets']), - targets=typedef.GetSetProperty(Delete_get_targets, Delete_set_targets, Delete_del_targets, cls=Delete), - __new__=interp2app(get_AST_new(Delete)), - __init__=interp2app(Delete_init), -) -Delete.typedef.heaptype = True - -def Assign_get_targets(space, w_self): - if not w_self.initialization_state & 4: - raise_attriberr(space, w_self, 'targets') - if w_self.w_targets is None: - if w_self.targets is None: - list_w = [] - else: - list_w = [space.wrap(node) for node in w_self.targets] - w_list = space.newlist(list_w) - w_self.w_targets = w_list - return w_self.w_targets - -def Assign_set_targets(space, w_self, w_new_value): - w_self.w_targets = w_new_value - w_self.initialization_state |= 4 - -def Assign_del_targets(space, w_self): - # Check if the element exists, raise appropriate exceptions - Assign_get_targets(space, w_self) - w_self.deldictvalue(space, 'targets') - w_self.initialization_state &= ~4 - -def Assign_get_value(space, w_self): - if w_self.w_dict is not None: - w_obj = w_self.getdictvalue(space, 'value') - if w_obj is not None: - return w_obj - if not w_self.initialization_state & 8: - raise_attriberr(space, w_self, 'value') - return space.wrap(w_self.value) - -def Assign_set_value(space, w_self, w_new_value): - try: - w_self.value = space.interp_w(expr, w_new_value, False) - if type(w_self.value) is expr: - raise OperationError(space.w_TypeError, space.w_None) - except OperationError, e: - if not e.match(space, space.w_TypeError): - raise - w_self.setdictvalue(space, 'value', w_new_value) - w_self.initialization_state &= ~8 - return - w_self.deldictvalue(space, 'value') - w_self.initialization_state |= 8 - -def Assign_del_value(space, w_self): - # Check if the element exists, raise appropriate exceptions - Assign_get_value(space, w_self) - w_self.deldictvalue(space, 'value') - w_self.initialization_state &= ~8 - -_Assign_field_unroller = unrolling_iterable(['targets', 'value']) -def Assign_init(space, w_self, __args__): - w_self = space.descr_self_interp_w(Assign, w_self) - w_self.w_targets = None - args_w, kwargs_w = __args__.unpack() - if args_w: - if len(args_w) != 2: - w_err = space.wrap("Assign constructor takes either 0 or 2 positional arguments") - raise OperationError(space.w_TypeError, w_err) - i = 0 - for field in _Assign_field_unroller: - space.setattr(w_self, space.wrap(field), args_w[i]) - i += 1 - for field, w_value in kwargs_w.iteritems(): - space.setattr(w_self, space.wrap(field), w_value) - -Assign.typedef = typedef.TypeDef("Assign", - stmt.typedef, - __module__='_ast', - _fields=_FieldsWrapper(['targets', 'value']), - targets=typedef.GetSetProperty(Assign_get_targets, Assign_set_targets, Assign_del_targets, cls=Assign), - value=typedef.GetSetProperty(Assign_get_value, Assign_set_value, Assign_del_value, cls=Assign), - __new__=interp2app(get_AST_new(Assign)), - __init__=interp2app(Assign_init), -) -Assign.typedef.heaptype = True - -def AugAssign_get_target(space, w_self): - if w_self.w_dict is not None: - w_obj = w_self.getdictvalue(space, 'target') - if w_obj is not None: - return w_obj - if not w_self.initialization_state & 4: - raise_attriberr(space, w_self, 'target') - return space.wrap(w_self.target) - -def AugAssign_set_target(space, w_self, w_new_value): - try: - w_self.target = space.interp_w(expr, w_new_value, False) - if type(w_self.target) is expr: - raise OperationError(space.w_TypeError, space.w_None) - except OperationError, e: - if not e.match(space, space.w_TypeError): - raise - w_self.setdictvalue(space, 'target', w_new_value) - w_self.initialization_state &= ~4 - return - w_self.deldictvalue(space, 'target') - w_self.initialization_state |= 4 - -def AugAssign_del_target(space, w_self): - # Check if the element exists, raise appropriate exceptions - AugAssign_get_target(space, w_self) - w_self.deldictvalue(space, 'target') - w_self.initialization_state &= ~4 - -def AugAssign_get_op(space, w_self): - if w_self.w_dict is not None: - w_obj = w_self.getdictvalue(space, 'op') - if w_obj is not None: - return w_obj - if not w_self.initialization_state & 8: - raise_attriberr(space, w_self, 'op') - return operator_to_class[w_self.op - 1]() - -def AugAssign_set_op(space, w_self, w_new_value): - try: - obj = space.interp_w(operator, w_new_value) - w_self.op = obj.to_simple_int(space) - except OperationError, e: - if not e.match(space, space.w_TypeError): - raise - w_self.setdictvalue(space, 'op', w_new_value) - w_self.initialization_state &= ~8 - return - # need to save the original object too - w_self.setdictvalue(space, 'op', w_new_value) - w_self.initialization_state |= 8 - -def AugAssign_del_op(space, w_self): - # Check if the element exists, raise appropriate exceptions - AugAssign_get_op(space, w_self) - w_self.deldictvalue(space, 'op') - w_self.initialization_state &= ~8 - -def AugAssign_get_value(space, w_self): - if w_self.w_dict is not None: - w_obj = w_self.getdictvalue(space, 'value') - if w_obj is not None: - return w_obj - if not w_self.initialization_state & 16: - raise_attriberr(space, w_self, 'value') - return space.wrap(w_self.value) - -def AugAssign_set_value(space, w_self, w_new_value): - try: - w_self.value = space.interp_w(expr, w_new_value, False) - if type(w_self.value) is expr: - raise OperationError(space.w_TypeError, space.w_None) - except OperationError, e: - if not e.match(space, space.w_TypeError): - raise - w_self.setdictvalue(space, 'value', w_new_value) - w_self.initialization_state &= ~16 - return - w_self.deldictvalue(space, 'value') - w_self.initialization_state |= 16 - -def AugAssign_del_value(space, w_self): - # Check if the element exists, raise appropriate exceptions - AugAssign_get_value(space, w_self) - w_self.deldictvalue(space, 'value') - w_self.initialization_state &= ~16 - -_AugAssign_field_unroller = unrolling_iterable(['target', 'op', 'value']) -def AugAssign_init(space, w_self, __args__): - w_self = space.descr_self_interp_w(AugAssign, w_self) - args_w, kwargs_w = __args__.unpack() - if args_w: - if len(args_w) != 3: - w_err = space.wrap("AugAssign constructor takes either 0 or 3 positional arguments") - raise OperationError(space.w_TypeError, w_err) - i = 0 _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit