[pypy-commit] pypy py3k: merge default (bf3e8fa831fd)
pjenvey
noreply at buildbot.pypy.org
Tue Aug 26 19:58:23 CEST 2014
Author: Philip Jenvey <pjenvey at underboss.org>
Branch: py3k
Changeset: r73066:9310ca287cdd
Date: 2014-08-24 15:54 -0700
http://bitbucket.org/pypy/pypy/changeset/9310ca287cdd/
Log: merge default (bf3e8fa831fd)
diff too long, truncating to 2000 out of 5869 lines
diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -354,6 +354,6 @@
See the License for the specific language governing permissions and
limitations under the License.
-Detailled license information is contained in the NOTICE file in the
+Detailed license information is contained in the NOTICE file in the
directory.
diff --git a/lib_pypy/pyrepl/reader.py b/lib_pypy/pyrepl/reader.py
--- a/lib_pypy/pyrepl/reader.py
+++ b/lib_pypy/pyrepl/reader.py
@@ -101,7 +101,7 @@
st = {}
for c in map(unichr, range(256)):
st[c] = SYNTAX_SYMBOL
- for c in [a for a in map(unichr, range(256)) if a.isalpha()]:
+ for c in [a for a in map(unichr, range(256)) if a.isalnum()]:
st[c] = SYNTAX_WORD
st[unicode('\n')] = st[unicode(' ')] = SYNTAX_WHITESPACE
return st
diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -54,3 +54,6 @@
.. branch: pytest-25
Update our copies of py.test and pylib to versions 2.5.2 and 1.4.20,
respectively.
+
+.. branch: split-ast-classes
+Classes in the ast module are now distinct from structures used by the compiler.
diff --git a/pypy/doc/windows.rst b/pypy/doc/windows.rst
--- a/pypy/doc/windows.rst
+++ b/pypy/doc/windows.rst
@@ -37,7 +37,7 @@
using a 32 bit Python and vice versa. By default pypy is built using the
Multi-threaded DLL (/MD) runtime environment.
-**Note:** PyPy is currently not supported for 64 bit Windows, and translation
+**Note:** PyPy is currently not supported for 64 bit Python, and translation
will fail in this case.
Python and a C compiler are all you need to build pypy, but it will miss some
@@ -136,7 +136,7 @@
cd zlib-1.2.3
nmake -f win32\Makefile.msc
- copy zlib1.lib <somewhere in LIB>
+ copy zlib.lib <somewhere in LIB>
copy zlib.h zconf.h <somewhere in INCLUDE>
The bz2 compression library
@@ -165,27 +165,29 @@
directory. Version 2.1.0 is known to pass tests. Then open the project
file ``expat.dsw`` with Visual
Studio; follow the instruction for converting the project files,
-switch to the "Release" configuration, reconfigure the runtime for
-Multi-threaded DLL (/MD) and build the solution (the ``expat`` project
-is actually enough for pypy).
+switch to the "Release" configuration, use the ``expat_static`` project,
+reconfigure the runtime for Multi-threaded DLL (/MD) and build.
-Then, copy the file ``win32\bin\release\libexpat.dll`` somewhere in
-your PATH, ``win32\bin\release\libexpat.lib`` somewhere in LIB, and
-both ``lib\expat.h`` and ``lib\expat_external.h`` somewhere in INCLUDE.
+Then, copy the file ``win32\bin\release\libexpat.lib`` somewhere in
+somewhere in LIB, and both ``lib\expat.h`` and ``lib\expat_external.h``
+somewhere in INCLUDE.
The OpenSSL library
~~~~~~~~~~~~~~~~~~~
OpenSSL needs a Perl interpreter to configure its makefile. You may
-use the one distributed by ActiveState, or the one from cygwin. In
-both case the perl interpreter must be found on the PATH.
+use the one distributed by ActiveState, or the one from cygwin.::
- svn export http://svn.python.org/projects/external/openssl-0.9.8y
- cd openssl-0.9.8y
- perl Configure VC-WIN32
+ svn export http://svn.python.org/projects/external/openssl-1.0.1i
+ cd openssl-1.0.1i
+ perl Configure VC-WIN32 no-idea no-mdc2
ms\do_ms.bat
nmake -f ms\nt.mak install
+Then, copy the files ``out32\*.lib`` somewhere in
+somewhere in LIB, and the entire ``include\openssl`` directory as-is somewhere
+in INCLUDE.
+
TkInter module support
~~~~~~~~~~~~~~~~~~~~~~
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
@@ -1,5 +1,4 @@
# Generated by tools/asdl_py.py
-from rpython.rlib.unroll import unrolling_iterable
from rpython.tool.pairtype import extendabletype
from rpython.tool.sourcetools import func_with_new_name
@@ -21,11 +20,15 @@
'AST string must be of type str or unicode'))
return w_obj
-
-class AST(W_Root):
-
- w_dict = None
-
+def get_field(space, w_node, name, optional):
+ w_obj = w_node.getdictvalue(space, name)
+ if w_obj is None and not optional:
+ raise oefmt(space.w_TypeError,
+ "required field \"%s\" missing from %T", name, w_node)
+ return w_obj
+
+
+class AST(object):
__metaclass__ = extendabletype
def walkabout(self, visitor):
@@ -34,8 +37,23 @@
def mutate_over(self, visitor):
raise AssertionError("mutate_over() implementation not provided")
- def sync_app_attrs(self, space):
- raise NotImplementedError
+
+class NodeVisitorNotImplemented(Exception):
+ pass
+
+
+class _FieldsWrapper(W_Root):
+ "Hack around the fact we can't store tuples on a TypeDef."
+
+ def __init__(self, fields):
+ self.fields = fields
+
+ def __spacebind__(self, space):
+ return space.newtuple([space.wrap(field) for field in self.fields])
+
+
+class W_AST(W_Root):
+ w_dict = None
def getdict(self, space):
if self.w_dict is None:
@@ -47,7 +65,7 @@
if w_dict is None:
w_dict = space.newdict()
w_type = space.type(self)
- w_fields = w_type.getdictvalue(space, "_fields")
+ w_fields = space.getattr(w_type, space.wrap("_fields"))
for w_name in space.fixedview(w_fields):
try:
space.setitem(w_dict, w_name,
@@ -71,79 +89,94 @@
space.setattr(self, w_name,
space.getitem(w_state, w_name))
- def missing_field(self, space, required, host):
- "Find which required field is missing."
- state = self.initialization_state
- for i in range(len(required)):
- if (state >> i) & 1:
- continue # field is present
- missing = required[i]
- if missing is None:
- continue # field is optional
- w_obj = self.getdictvalue(space, missing)
- if w_obj is None:
- raise oefmt(space.w_TypeError,
- "required field \"%s\" missing from %s",
- missing, host)
- else:
- raise oefmt(space.w_TypeError,
- "incorrect type for field \"%s\" in %s",
- missing, host)
- raise AssertionError("should not reach here")
-
-
-class NodeVisitorNotImplemented(Exception):
- pass
-
-
-class _FieldsWrapper(W_Root):
- "Hack around the fact we can't store tuples on a TypeDef."
-
- def __init__(self, fields):
- self.fields = fields
-
- def __spacebind__(self, space):
- return space.newtuple([space.wrap(field) for field in self.fields])
-
-
-def get_AST_new(node_class):
- def generic_AST_new(space, w_type, __args__):
- node = space.allocate_instance(node_class, w_type)
- node.initialization_state = 0
- return space.wrap(node)
- return func_with_new_name(generic_AST_new, "new_%s" % node_class.__name__)
-
-def AST_init(space, w_self, __args__):
+def W_AST_new(space, w_type, __args__):
+ node = space.allocate_instance(W_AST, w_type)
+ return space.wrap(node)
+
+def W_AST_init(space, w_self, __args__):
args_w, kwargs_w = __args__.unpack()
- if args_w and len(args_w) != 0:
- w_err = space.wrap("_ast.AST constructor takes 0 positional arguments")
- raise OperationError(space.w_TypeError, w_err)
+ fields_w = space.fixedview(space.getattr(space.type(w_self),
+ space.wrap("_fields")))
+ num_fields = len(fields_w) if fields_w else 0
+ if args_w and len(args_w) != num_fields:
+ if num_fields == 0:
+ raise oefmt(space.w_TypeError,
+ "%T constructor takes 0 positional arguments", w_self)
+ elif num_fields == 1:
+ raise oefmt(space.w_TypeError,
+ "%T constructor takes either 0 or %d positional argument", w_self, num_fields)
+ else:
+ raise oefmt(space.w_TypeError,
+ "%T constructor takes either 0 or %d positional arguments", w_self, num_fields)
+ if args_w:
+ for i, w_field in enumerate(fields_w):
+ space.setattr(w_self, w_field, args_w[i])
for field, w_value in kwargs_w.iteritems():
space.setattr(w_self, space.wrap(field), w_value)
-AST.typedef = typedef.TypeDef("_ast.AST",
+
+W_AST.typedef = typedef.TypeDef("_ast.AST",
_fields=_FieldsWrapper([]),
_attributes=_FieldsWrapper([]),
- __reduce__=interp2app(AST.reduce_w),
- __setstate__=interp2app(AST.setstate_w),
+ __reduce__=interp2app(W_AST.reduce_w),
+ __setstate__=interp2app(W_AST.setstate_w),
__dict__ = typedef.GetSetProperty(typedef.descr_get_dict,
- typedef.descr_set_dict, cls=AST),
- __new__=interp2app(get_AST_new(AST)),
- __init__=interp2app(AST_init),
-)
-
-
-
+ typedef.descr_set_dict, cls=W_AST),
+ __new__=interp2app(W_AST_new),
+ __init__=interp2app(W_AST_init),
+)
+
+class State:
+ AST_TYPES = []
+
+ @classmethod
+ def ast_type(cls, name, base, fields, attributes=None):
+ cls.AST_TYPES.append((name, base, fields, attributes))
+
+ def __init__(self, space):
+ self.w_AST = space.gettypeobject(W_AST.typedef)
+ for (name, base, fields, attributes) in self.AST_TYPES:
+ self.make_new_type(space, name, base, fields, attributes)
+
+ def make_new_type(self, space, name, base, fields, attributes):
+ w_base = getattr(self, 'w_%s' % base)
+ w_dict = space.newdict()
+ space.setitem_str(w_dict, '__module__', space.wrap('_ast'))
+ if fields is not None:
+ space.setitem_str(w_dict, "_fields",
+ space.newtuple([space.wrap(f) for f in fields]))
+ if attributes is not None:
+ space.setitem_str(w_dict, "_attributes",
+ space.newtuple([space.wrap(a) for a in attributes]))
+ w_type = space.call_function(
+ space.w_type,
+ space.wrap(name), space.newtuple([w_base]), w_dict)
+ setattr(self, 'w_%s' % name, w_type)
+
+def get(space):
+ return space.fromcache(State)
class mod(AST):
- pass
+ @staticmethod
+ 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_Module):
+ return Module.from_object(space, w_node)
+ if space.isinstance_w(w_node, get(space).w_Interactive):
+ return Interactive.from_object(space, w_node)
+ if space.isinstance_w(w_node, get(space).w_Expression):
+ return Expression.from_object(space, w_node)
+ if space.isinstance_w(w_node, get(space).w_Suite):
+ return Suite.from_object(space, w_node)
+ raise oefmt(space.w_TypeError,
+ "Expected mod node, got %T", w_node)
+State.ast_type('mod', 'AST', None, [])
class Module(mod):
def __init__(self, body):
self.body = body
- self.w_body = None
- self.initialization_state = 1
def walkabout(self, visitor):
visitor.visit_Module(self)
@@ -153,29 +186,30 @@
visitor._mutate_sequence(self.body)
return visitor.visit_Module(self)
- def sync_app_attrs(self, space):
- if (self.initialization_state & ~0) ^ 1:
- self.missing_field(space, ['body'], 'Module')
- else:
- pass
- 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_Module)
+ if self.body is None:
+ body_w = []
+ else:
+ body_w = [node.to_object(space) for node in self.body] # stmt
+ w_body = space.newlist(body_w)
+ space.setattr(w_node, space.wrap('body'), w_body)
+ return w_node
+
+ @staticmethod
+ def from_object(space, w_node):
+ w_body = get_field(space, w_node, 'body', False)
+ body_w = space.unpackiterable(w_body)
+ _body = [stmt.from_object(space, w_item) for w_item in body_w]
+ return Module(_body)
+
+State.ast_type('Module', 'mod', ['body'])
class Interactive(mod):
def __init__(self, body):
self.body = body
- self.w_body = None
- self.initialization_state = 1
def walkabout(self, visitor):
visitor.visit_Interactive(self)
@@ -185,28 +219,30 @@
visitor._mutate_sequence(self.body)
return visitor.visit_Interactive(self)
- def sync_app_attrs(self, space):
- if (self.initialization_state & ~0) ^ 1:
- self.missing_field(space, ['body'], 'Interactive')
- else:
- pass
- 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_Interactive)
+ if self.body is None:
+ body_w = []
+ else:
+ body_w = [node.to_object(space) for node in self.body] # stmt
+ w_body = space.newlist(body_w)
+ space.setattr(w_node, space.wrap('body'), w_body)
+ return w_node
+
+ @staticmethod
+ def from_object(space, w_node):
+ w_body = get_field(space, w_node, 'body', False)
+ body_w = space.unpackiterable(w_body)
+ _body = [stmt.from_object(space, w_item) for w_item in body_w]
+ return Interactive(_body)
+
+State.ast_type('Interactive', 'mod', ['body'])
class Expression(mod):
def __init__(self, body):
self.body = body
- self.initialization_state = 1
def walkabout(self, visitor):
visitor.visit_Expression(self)
@@ -215,20 +251,25 @@
self.body = self.body.mutate_over(visitor)
return visitor.visit_Expression(self)
- def sync_app_attrs(self, space):
- if (self.initialization_state & ~0) ^ 1:
- self.missing_field(space, ['body'], 'Expression')
- else:
- pass
- self.body.sync_app_attrs(space)
+ def to_object(self, space):
+ w_node = space.call_function(get(space).w_Expression)
+ w_body = self.body.to_object(space) # expr
+ space.setattr(w_node, space.wrap('body'), w_body)
+ return w_node
+
+ @staticmethod
+ def from_object(space, w_node):
+ w_body = get_field(space, w_node, 'body', False)
+ _body = expr.from_object(space, w_body)
+ return Expression(_body)
+
+State.ast_type('Expression', 'mod', ['body'])
class Suite(mod):
def __init__(self, body):
self.body = body
- self.w_body = None
- self.initialization_state = 1
def walkabout(self, visitor):
visitor.visit_Suite(self)
@@ -238,21 +279,24 @@
visitor._mutate_sequence(self.body)
return visitor.visit_Suite(self)
- def sync_app_attrs(self, space):
- if (self.initialization_state & ~0) ^ 1:
- self.missing_field(space, ['body'], 'Suite')
- else:
- pass
- 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_Suite)
+ if self.body is None:
+ body_w = []
+ else:
+ body_w = [node.to_object(space) for node in self.body] # stmt
+ w_body = space.newlist(body_w)
+ space.setattr(w_node, space.wrap('body'), w_body)
+ return w_node
+
+ @staticmethod
+ def from_object(space, w_node):
+ w_body = get_field(space, w_node, 'body', False)
+ body_w = space.unpackiterable(w_body)
+ _body = [stmt.from_object(space, w_item) for w_item in body_w]
+ return Suite(_body)
+
+State.ast_type('Suite', 'mod', ['body'])
class stmt(AST):
@@ -261,18 +305,77 @@
self.lineno = lineno
self.col_offset = col_offset
+ @staticmethod
+ 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_FunctionDef):
+ return FunctionDef.from_object(space, w_node)
+ if space.isinstance_w(w_node, get(space).w_ClassDef):
+ return ClassDef.from_object(space, w_node)
+ if space.isinstance_w(w_node, get(space).w_Return):
+ return Return.from_object(space, w_node)
+ if space.isinstance_w(w_node, get(space).w_Delete):
+ return Delete.from_object(space, w_node)
+ if space.isinstance_w(w_node, get(space).w_Assign):
+ 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):
+ return While.from_object(space, w_node)
+ if space.isinstance_w(w_node, get(space).w_If):
+ return If.from_object(space, w_node)
+ if space.isinstance_w(w_node, get(space).w_With):
+ return With.from_object(space, w_node)
+ if space.isinstance_w(w_node, get(space).w_Raise):
+ return Raise.from_object(space, w_node)
+ if space.isinstance_w(w_node, get(space).w_TryExcept):
+ return TryExcept.from_object(space, w_node)
+ if space.isinstance_w(w_node, get(space).w_TryFinally):
+ return TryFinally.from_object(space, w_node)
+ if space.isinstance_w(w_node, get(space).w_Assert):
+ return Assert.from_object(space, w_node)
+ if space.isinstance_w(w_node, get(space).w_Import):
+ 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_Expr):
+ return Expr.from_object(space, w_node)
+ if space.isinstance_w(w_node, get(space).w_Pass):
+ return Pass.from_object(space, w_node)
+ if space.isinstance_w(w_node, get(space).w_Break):
+ return Break.from_object(space, w_node)
+ if space.isinstance_w(w_node, get(space).w_Continue):
+ return Continue.from_object(space, w_node)
+ raise oefmt(space.w_TypeError,
+ "Expected stmt node, got %T", w_node)
+State.ast_type('stmt', 'AST', None, ['lineno', 'col_offset'])
+
class FunctionDef(stmt):
def __init__(self, name, args, body, decorator_list, returns, lineno, col_offset):
self.name = name
self.args = args
self.body = body
- self.w_body = None
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)
@@ -287,6 +390,7 @@
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')
@@ -316,6 +420,51 @@
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
+ space.setattr(w_node, space.wrap('name'), w_name)
+ w_args = self.args.to_object(space) # arguments
+ space.setattr(w_node, space.wrap('args'), w_args)
+ if self.body is None:
+ body_w = []
+ else:
+ body_w = [node.to_object(space) for node in self.body] # stmt
+ w_body = space.newlist(body_w)
+ space.setattr(w_node, space.wrap('body'), w_body)
+ if self.decorator_list is None:
+ decorator_list_w = []
+ else:
+ 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_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_name = get_field(space, w_node, 'name', False)
+ 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_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)
+ _args = arguments.from_object(space, w_args)
+ 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 FunctionDef(_name, _args, _body, _decorator_list, _lineno, _col_offset)
+
+State.ast_type('FunctionDef', 'stmt', ['name', 'args', 'body', 'decorator_list'])
+>>>>>>> theirs
class ClassDef(stmt):
@@ -323,17 +472,21 @@
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.w_body = None
self.decorator_list = decorator_list
- self.w_decorator_list = None
stmt.__init__(self, lineno, col_offset)
+<<<<<<< mine
self.initialization_state = 511
+=======
+>>>>>>> theirs
def walkabout(self, visitor):
visitor.visit_ClassDef(self)
@@ -353,6 +506,7 @@
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')
@@ -405,6 +559,56 @@
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
+ space.setattr(w_node, space.wrap('name'), w_name)
+ if self.bases is None:
+ bases_w = []
+ else:
+ 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.body is None:
+ body_w = []
+ else:
+ body_w = [node.to_object(space) for node in self.body] # stmt
+ w_body = space.newlist(body_w)
+ space.setattr(w_node, space.wrap('body'), w_body)
+ if self.decorator_list is None:
+ decorator_list_w = []
+ else:
+ 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_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_name = get_field(space, w_node, 'name', False)
+ w_bases = get_field(space, w_node, 'bases', False)
+ 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)
+ w_col_offset = get_field(space, w_node, 'col_offset', False)
+ _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]
+ 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
class Return(stmt):
@@ -412,7 +616,6 @@
def __init__(self, value, lineno, col_offset):
self.value = value
stmt.__init__(self, lineno, col_offset)
- self.initialization_state = 7
def walkabout(self, visitor):
visitor.visit_Return(self)
@@ -422,23 +625,34 @@
self.value = self.value.mutate_over(visitor)
return visitor.visit_Return(self)
- def sync_app_attrs(self, space):
- if (self.initialization_state & ~4) ^ 3:
- self.missing_field(space, ['lineno', 'col_offset', None], 'Return')
- else:
- if not self.initialization_state & 4:
- self.value = None
- if self.value:
- self.value.sync_app_attrs(space)
+ def to_object(self, space):
+ w_node = space.call_function(get(space).w_Return)
+ w_value = self.value.to_object(space) if self.value is not None else space.w_None # 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', True)
+ 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 Return(_value, _lineno, _col_offset)
+
+State.ast_type('Return', 'stmt', ['value'])
class Delete(stmt):
def __init__(self, targets, lineno, col_offset):
self.targets = targets
- self.w_targets = None
stmt.__init__(self, lineno, col_offset)
- self.initialization_state = 7
def walkabout(self, visitor):
visitor.visit_Delete(self)
@@ -448,31 +662,40 @@
visitor._mutate_sequence(self.targets)
return visitor.visit_Delete(self)
- def sync_app_attrs(self, space):
- if (self.initialization_state & ~0) ^ 7:
- self.missing_field(space, ['lineno', 'col_offset', 'targets'], 'Delete')
- else:
- pass
- w_list = self.w_targets
- if w_list is not None:
- list_w = space.listview(w_list)
- if list_w:
- self.targets = [space.interp_w(expr, w_obj) for w_obj in list_w]
- else:
- self.targets = None
- if self.targets is not None:
- for node in self.targets:
- node.sync_app_attrs(space)
+ def to_object(self, space):
+ w_node = space.call_function(get(space).w_Delete)
+ if self.targets is None:
+ targets_w = []
+ else:
+ targets_w = [node.to_object(space) for node in self.targets] # expr
+ w_targets = space.newlist(targets_w)
+ space.setattr(w_node, space.wrap('targets'), w_targets)
+ 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_targets = get_field(space, w_node, 'targets', False)
+ w_lineno = get_field(space, w_node, 'lineno', False)
+ w_col_offset = get_field(space, w_node, 'col_offset', False)
+ targets_w = space.unpackiterable(w_targets)
+ _targets = [expr.from_object(space, w_item) for w_item in targets_w]
+ _lineno = space.int_w(w_lineno)
+ _col_offset = space.int_w(w_col_offset)
+ return Delete(_targets, _lineno, _col_offset)
+
+State.ast_type('Delete', 'stmt', ['targets'])
class Assign(stmt):
def __init__(self, targets, value, lineno, col_offset):
self.targets = targets
- self.w_targets = None
self.value = value
stmt.__init__(self, lineno, col_offset)
- self.initialization_state = 15
def walkabout(self, visitor):
visitor.visit_Assign(self)
@@ -483,22 +706,36 @@
self.value = self.value.mutate_over(visitor)
return visitor.visit_Assign(self)
- def sync_app_attrs(self, space):
- if (self.initialization_state & ~0) ^ 15:
- self.missing_field(space, ['lineno', 'col_offset', 'targets', 'value'], 'Assign')
- else:
- pass
- w_list = self.w_targets
- if w_list is not None:
- list_w = space.listview(w_list)
- if list_w:
- self.targets = [space.interp_w(expr, w_obj) for w_obj in list_w]
- else:
- self.targets = None
- if self.targets is not None:
- for node in self.targets:
- node.sync_app_attrs(space)
- self.value.sync_app_attrs(space)
+ def to_object(self, space):
+ w_node = space.call_function(get(space).w_Assign)
+ if self.targets is None:
+ targets_w = []
+ else:
+ targets_w = [node.to_object(space) for node in self.targets] # expr
+ w_targets = space.newlist(targets_w)
+ space.setattr(w_node, space.wrap('targets'), w_targets)
+ 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_targets = get_field(space, w_node, 'targets', False)
+ 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)
+ targets_w = space.unpackiterable(w_targets)
+ _targets = [expr.from_object(space, w_item) for w_item in targets_w]
+ _value = expr.from_object(space, w_value)
+ _lineno = space.int_w(w_lineno)
+ _col_offset = space.int_w(w_col_offset)
+ return Assign(_targets, _value, _lineno, _col_offset)
+
+State.ast_type('Assign', 'stmt', ['targets', 'value'])
class AugAssign(stmt):
@@ -508,7 +745,6 @@
self.op = op
self.value = value
stmt.__init__(self, lineno, col_offset)
- self.initialization_state = 31
def walkabout(self, visitor):
visitor.visit_AugAssign(self)
@@ -518,26 +754,102 @@
self.value = self.value.mutate_over(visitor)
return visitor.visit_AugAssign(self)
- def sync_app_attrs(self, space):
- if (self.initialization_state & ~0) ^ 31:
- self.missing_field(space, ['lineno', 'col_offset', 'target', 'op', 'value'], 'AugAssign')
- else:
- pass
- self.target.sync_app_attrs(space)
- self.value.sync_app_attrs(space)
-
-
+ def to_object(self, space):
+ w_node = space.call_function(get(space).w_AugAssign)
+ w_target = self.target.to_object(space) # expr
+ space.setattr(w_node, space.wrap('target'), w_target)
+ w_op = operator_to_class[self.op - 1]().to_object(space) # operator
+ space.setattr(w_node, space.wrap('op'), w_op)
+ 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_target = get_field(space, w_node, 'target', False)
+ w_op = get_field(space, w_node, 'op', False)
+ 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)
+ _target = expr.from_object(space, w_target)
+ _op = operator.from_object(space, w_op)
+ _value = expr.from_object(space, w_value)
+ _lineno = space.int_w(w_lineno)
+ _col_offset = space.int_w(w_col_offset)
+ return AugAssign(_target, _op, _value, _lineno, _col_offset)
+
+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):
self.target = target
self.iter = iter
self.body = body
- self.w_body = None
self.orelse = orelse
- self.w_orelse = None
stmt.__init__(self, lineno, col_offset)
- self.initialization_state = 63
def walkabout(self, visitor):
visitor.visit_For(self)
@@ -551,33 +863,49 @@
visitor._mutate_sequence(self.orelse)
return visitor.visit_For(self)
- def sync_app_attrs(self, space):
- if (self.initialization_state & ~0) ^ 63:
- self.missing_field(space, ['lineno', 'col_offset', 'target', 'iter', 'body', 'orelse'], 'For')
- else:
- pass
- self.target.sync_app_attrs(space)
- self.iter.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_orelse
- if w_list is not None:
- list_w = space.listview(w_list)
- if list_w:
- self.orelse = [space.interp_w(stmt, w_obj) for w_obj in list_w]
- else:
- self.orelse = None
- if self.orelse is not None:
- for node in self.orelse:
- node.sync_app_attrs(space)
+ def to_object(self, space):
+ w_node = space.call_function(get(space).w_For)
+ w_target = self.target.to_object(space) # expr
+ space.setattr(w_node, space.wrap('target'), w_target)
+ w_iter = self.iter.to_object(space) # expr
+ space.setattr(w_node, space.wrap('iter'), w_iter)
+ if self.body is None:
+ body_w = []
+ else:
+ body_w = [node.to_object(space) for node in self.body] # stmt
+ w_body = space.newlist(body_w)
+ space.setattr(w_node, space.wrap('body'), w_body)
+ if self.orelse is None:
+ orelse_w = []
+ else:
+ orelse_w = [node.to_object(space) for node in self.orelse] # stmt
+ w_orelse = space.newlist(orelse_w)
+ space.setattr(w_node, space.wrap('orelse'), w_orelse)
+ 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_target = get_field(space, w_node, 'target', False)
+ w_iter = get_field(space, w_node, 'iter', False)
+ w_body = get_field(space, w_node, 'body', False)
+ w_orelse = get_field(space, w_node, 'orelse', False)
+ w_lineno = get_field(space, w_node, 'lineno', False)
+ w_col_offset = get_field(space, w_node, 'col_offset', False)
+ _target = expr.from_object(space, w_target)
+ _iter = expr.from_object(space, w_iter)
+ body_w = space.unpackiterable(w_body)
+ _body = [stmt.from_object(space, w_item) for w_item in body_w]
+ orelse_w = space.unpackiterable(w_orelse)
+ _orelse = [stmt.from_object(space, w_item) for w_item in orelse_w]
+ _lineno = space.int_w(w_lineno)
+ _col_offset = space.int_w(w_col_offset)
+ return For(_target, _iter, _body, _orelse, _lineno, _col_offset)
+
+State.ast_type('For', 'stmt', ['target', 'iter', 'body', 'orelse'])
class While(stmt):
@@ -585,11 +913,8 @@
def __init__(self, test, body, orelse, lineno, col_offset):
self.test = test
self.body = body
- self.w_body = None
self.orelse = orelse
- self.w_orelse = None
stmt.__init__(self, lineno, col_offset)
- self.initialization_state = 31
def walkabout(self, visitor):
visitor.visit_While(self)
@@ -602,32 +927,45 @@
visitor._mutate_sequence(self.orelse)
return visitor.visit_While(self)
- def sync_app_attrs(self, space):
- if (self.initialization_state & ~0) ^ 31:
- self.missing_field(space, ['lineno', 'col_offset', 'test', 'body', 'orelse'], 'While')
- else:
- pass
- self.test.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_orelse
- if w_list is not None:
- list_w = space.listview(w_list)
- if list_w:
- self.orelse = [space.interp_w(stmt, w_obj) for w_obj in list_w]
- else:
- self.orelse = None
- if self.orelse is not None:
- for node in self.orelse:
- node.sync_app_attrs(space)
+ def to_object(self, space):
+ w_node = space.call_function(get(space).w_While)
+ w_test = self.test.to_object(space) # expr
+ space.setattr(w_node, space.wrap('test'), w_test)
+ if self.body is None:
+ body_w = []
+ else:
+ body_w = [node.to_object(space) for node in self.body] # stmt
+ w_body = space.newlist(body_w)
+ space.setattr(w_node, space.wrap('body'), w_body)
+ if self.orelse is None:
+ orelse_w = []
+ else:
+ orelse_w = [node.to_object(space) for node in self.orelse] # stmt
+ w_orelse = space.newlist(orelse_w)
+ space.setattr(w_node, space.wrap('orelse'), w_orelse)
+ 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_test = get_field(space, w_node, 'test', False)
+ w_body = get_field(space, w_node, 'body', False)
+ w_orelse = get_field(space, w_node, 'orelse', False)
+ w_lineno = get_field(space, w_node, 'lineno', False)
+ w_col_offset = get_field(space, w_node, 'col_offset', False)
+ _test = expr.from_object(space, w_test)
+ body_w = space.unpackiterable(w_body)
+ _body = [stmt.from_object(space, w_item) for w_item in body_w]
+ orelse_w = space.unpackiterable(w_orelse)
+ _orelse = [stmt.from_object(space, w_item) for w_item in orelse_w]
+ _lineno = space.int_w(w_lineno)
+ _col_offset = space.int_w(w_col_offset)
+ return While(_test, _body, _orelse, _lineno, _col_offset)
+
+State.ast_type('While', 'stmt', ['test', 'body', 'orelse'])
class If(stmt):
@@ -635,11 +973,8 @@
def __init__(self, test, body, orelse, lineno, col_offset):
self.test = test
self.body = body
- self.w_body = None
self.orelse = orelse
- self.w_orelse = None
stmt.__init__(self, lineno, col_offset)
- self.initialization_state = 31
def walkabout(self, visitor):
visitor.visit_If(self)
@@ -652,32 +987,45 @@
visitor._mutate_sequence(self.orelse)
return visitor.visit_If(self)
- def sync_app_attrs(self, space):
- if (self.initialization_state & ~0) ^ 31:
- self.missing_field(space, ['lineno', 'col_offset', 'test', 'body', 'orelse'], 'If')
- else:
- pass
- self.test.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_orelse
- if w_list is not None:
- list_w = space.listview(w_list)
- if list_w:
- self.orelse = [space.interp_w(stmt, w_obj) for w_obj in list_w]
- else:
- self.orelse = None
- if self.orelse is not None:
- for node in self.orelse:
- node.sync_app_attrs(space)
+ def to_object(self, space):
+ w_node = space.call_function(get(space).w_If)
+ w_test = self.test.to_object(space) # expr
+ space.setattr(w_node, space.wrap('test'), w_test)
+ if self.body is None:
+ body_w = []
+ else:
+ body_w = [node.to_object(space) for node in self.body] # stmt
+ w_body = space.newlist(body_w)
+ space.setattr(w_node, space.wrap('body'), w_body)
+ if self.orelse is None:
+ orelse_w = []
+ else:
+ orelse_w = [node.to_object(space) for node in self.orelse] # stmt
+ w_orelse = space.newlist(orelse_w)
+ space.setattr(w_node, space.wrap('orelse'), w_orelse)
+ 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_test = get_field(space, w_node, 'test', False)
+ w_body = get_field(space, w_node, 'body', False)
+ w_orelse = get_field(space, w_node, 'orelse', False)
+ w_lineno = get_field(space, w_node, 'lineno', False)
+ w_col_offset = get_field(space, w_node, 'col_offset', False)
+ _test = expr.from_object(space, w_test)
+ body_w = space.unpackiterable(w_body)
+ _body = [stmt.from_object(space, w_item) for w_item in body_w]
+ orelse_w = space.unpackiterable(w_orelse)
+ _orelse = [stmt.from_object(space, w_item) for w_item in orelse_w]
+ _lineno = space.int_w(w_lineno)
+ _col_offset = space.int_w(w_col_offset)
+ return If(_test, _body, _orelse, _lineno, _col_offset)
+
+State.ast_type('If', 'stmt', ['test', 'body', 'orelse'])
class With(stmt):
@@ -686,9 +1034,7 @@
self.context_expr = context_expr
self.optional_vars = optional_vars
self.body = body
- self.w_body = None
stmt.__init__(self, lineno, col_offset)
- self.initialization_state = 31
def walkabout(self, visitor):
visitor.visit_With(self)
@@ -701,25 +1047,40 @@
visitor._mutate_sequence(self.body)
return visitor.visit_With(self)
- def sync_app_attrs(self, space):
- if (self.initialization_state & ~8) ^ 23:
- self.missing_field(space, ['lineno', 'col_offset', 'context_expr', None, 'body'], 'With')
- else:
- if not self.initialization_state & 8:
- self.optional_vars = None
- self.context_expr.sync_app_attrs(space)
- if self.optional_vars:
- self.optional_vars.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_With)
+ w_context_expr = self.context_expr.to_object(space) # expr
+ space.setattr(w_node, space.wrap('context_expr'), w_context_expr)
+ w_optional_vars = self.optional_vars.to_object(space) if self.optional_vars is not None else space.w_None # expr
+ space.setattr(w_node, space.wrap('optional_vars'), w_optional_vars)
+ if self.body is None:
+ body_w = []
+ else:
+ body_w = [node.to_object(space) for node in self.body] # stmt
+ w_body = space.newlist(body_w)
+ space.setattr(w_node, space.wrap('body'), w_body)
+ 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_context_expr = get_field(space, w_node, 'context_expr', False)
+ w_optional_vars = get_field(space, w_node, 'optional_vars', True)
+ w_body = get_field(space, w_node, 'body', False)
+ w_lineno = get_field(space, w_node, 'lineno', False)
+ w_col_offset = get_field(space, w_node, 'col_offset', False)
+ _context_expr = expr.from_object(space, w_context_expr)
+ _optional_vars = expr.from_object(space, w_optional_vars)
+ 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)
+ _col_offset = space.int_w(w_col_offset)
+ return With(_context_expr, _optional_vars, _body, _lineno, _col_offset)
+
+State.ast_type('With', 'stmt', ['context_expr', 'optional_vars', 'body'])
class Raise(stmt):
@@ -728,7 +1089,10 @@
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)
@@ -740,6 +1104,7 @@
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')
@@ -752,19 +1117,46 @@
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_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_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_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)
+ _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
class TryExcept(stmt):
def __init__(self, body, handlers, orelse, lineno, col_offset):
self.body = body
- self.w_body = None
self.handlers = handlers
- self.w_handlers = None
self.orelse = orelse
- self.w_orelse = None
stmt.__init__(self, lineno, col_offset)
- self.initialization_state = 31
def walkabout(self, visitor):
visitor.visit_TryExcept(self)
@@ -778,52 +1170,58 @@
visitor._mutate_sequence(self.orelse)
return visitor.visit_TryExcept(self)
- def sync_app_attrs(self, space):
- if (self.initialization_state & ~0) ^ 31:
- self.missing_field(space, ['lineno', 'col_offset', 'body', 'handlers', 'orelse'], 'TryExcept')
- else:
- pass
- 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_handlers
- if w_list is not None:
- list_w = space.listview(w_list)
- if list_w:
- self.handlers = [space.interp_w(excepthandler, w_obj) for w_obj in list_w]
- else:
- self.handlers = None
- if self.handlers is not None:
- for node in self.handlers:
- node.sync_app_attrs(space)
- w_list = self.w_orelse
- if w_list is not None:
- list_w = space.listview(w_list)
- if list_w:
- self.orelse = [space.interp_w(stmt, w_obj) for w_obj in list_w]
- else:
- self.orelse = None
- if self.orelse is not None:
- for node in self.orelse:
- node.sync_app_attrs(space)
+ def to_object(self, space):
+ w_node = space.call_function(get(space).w_TryExcept)
+ if self.body is None:
+ body_w = []
+ else:
+ body_w = [node.to_object(space) for node in self.body] # stmt
+ w_body = space.newlist(body_w)
+ space.setattr(w_node, space.wrap('body'), w_body)
+ if self.handlers is None:
+ handlers_w = []
+ else:
+ handlers_w = [node.to_object(space) for node in self.handlers] # excepthandler
+ w_handlers = space.newlist(handlers_w)
+ space.setattr(w_node, space.wrap('handlers'), w_handlers)
+ if self.orelse is None:
+ orelse_w = []
+ else:
+ orelse_w = [node.to_object(space) for node in self.orelse] # stmt
+ w_orelse = space.newlist(orelse_w)
+ space.setattr(w_node, space.wrap('orelse'), w_orelse)
+ 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_handlers = get_field(space, w_node, 'handlers', False)
+ w_orelse = get_field(space, w_node, 'orelse', False)
+ w_lineno = get_field(space, w_node, 'lineno', False)
+ w_col_offset = get_field(space, w_node, 'col_offset', False)
+ body_w = space.unpackiterable(w_body)
+ _body = [stmt.from_object(space, w_item) for w_item in body_w]
+ handlers_w = space.unpackiterable(w_handlers)
+ _handlers = [excepthandler.from_object(space, w_item) for w_item in handlers_w]
+ orelse_w = space.unpackiterable(w_orelse)
+ _orelse = [stmt.from_object(space, w_item) for w_item in orelse_w]
+ _lineno = space.int_w(w_lineno)
+ _col_offset = space.int_w(w_col_offset)
+ return TryExcept(_body, _handlers, _orelse, _lineno, _col_offset)
+
+State.ast_type('TryExcept', 'stmt', ['body', 'handlers', 'orelse'])
class TryFinally(stmt):
def __init__(self, body, finalbody, lineno, col_offset):
self.body = body
- self.w_body = None
self.finalbody = finalbody
- self.w_finalbody = None
stmt.__init__(self, lineno, col_offset)
- self.initialization_state = 15
def walkabout(self, visitor):
visitor.visit_TryFinally(self)
@@ -835,31 +1233,41 @@
visitor._mutate_sequence(self.finalbody)
return visitor.visit_TryFinally(self)
- def sync_app_attrs(self, space):
- if (self.initialization_state & ~0) ^ 15:
- self.missing_field(space, ['lineno', 'col_offset', 'body', 'finalbody'], 'TryFinally')
- else:
- pass
- 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_finalbody
- if w_list is not None:
- list_w = space.listview(w_list)
- if list_w:
- self.finalbody = [space.interp_w(stmt, w_obj) for w_obj in list_w]
- else:
- self.finalbody = None
- if self.finalbody is not None:
- for node in self.finalbody:
- node.sync_app_attrs(space)
+ def to_object(self, space):
+ w_node = space.call_function(get(space).w_TryFinally)
+ if self.body is None:
+ body_w = []
+ else:
+ body_w = [node.to_object(space) for node in self.body] # stmt
+ w_body = space.newlist(body_w)
+ space.setattr(w_node, space.wrap('body'), w_body)
+ if self.finalbody is None:
+ finalbody_w = []
+ else:
+ finalbody_w = [node.to_object(space) for node in self.finalbody] # stmt
+ w_finalbody = space.newlist(finalbody_w)
+ space.setattr(w_node, space.wrap('finalbody'), w_finalbody)
+ 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_finalbody = get_field(space, w_node, 'finalbody', False)
+ w_lineno = get_field(space, w_node, 'lineno', False)
+ w_col_offset = get_field(space, w_node, 'col_offset', False)
+ body_w = space.unpackiterable(w_body)
+ _body = [stmt.from_object(space, w_item) for w_item in body_w]
+ finalbody_w = space.unpackiterable(w_finalbody)
+ _finalbody = [stmt.from_object(space, w_item) for w_item in finalbody_w]
+ _lineno = space.int_w(w_lineno)
+ _col_offset = space.int_w(w_col_offset)
+ return TryFinally(_body, _finalbody, _lineno, _col_offset)
+
+State.ast_type('TryFinally', 'stmt', ['body', 'finalbody'])
class Assert(stmt):
@@ -868,7 +1276,6 @@
self.test = test
self.msg = msg
stmt.__init__(self, lineno, col_offset)
- self.initialization_state = 15
def walkabout(self, visitor):
visitor.visit_Assert(self)
@@ -879,95 +1286,137 @@
self.msg = self.msg.mutate_over(visitor)
return visitor.visit_Assert(self)
- def sync_app_attrs(self, space):
- if (self.initialization_state & ~8) ^ 7:
- self.missing_field(space, ['lineno', 'col_offset', 'test', None], 'Assert')
- else:
- if not self.initialization_state & 8:
- self.msg = None
- self.test.sync_app_attrs(space)
- if self.msg:
- self.msg.sync_app_attrs(space)
+ def to_object(self, space):
+ w_node = space.call_function(get(space).w_Assert)
+ w_test = self.test.to_object(space) # expr
+ space.setattr(w_node, space.wrap('test'), w_test)
+ w_msg = self.msg.to_object(space) if self.msg is not None else space.w_None # expr
+ space.setattr(w_node, space.wrap('msg'), w_msg)
+ 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_test = get_field(space, w_node, 'test', False)
+ w_msg = get_field(space, w_node, 'msg', True)
+ w_lineno = get_field(space, w_node, 'lineno', False)
+ w_col_offset = get_field(space, w_node, 'col_offset', False)
+ _test = expr.from_object(space, w_test)
+ _msg = expr.from_object(space, w_msg)
+ _lineno = space.int_w(w_lineno)
+ _col_offset = space.int_w(w_col_offset)
+ return Assert(_test, _msg, _lineno, _col_offset)
+
+State.ast_type('Assert', 'stmt', ['test', 'msg'])
class Import(stmt):
def __init__(self, names, lineno, col_offset):
self.names = names
+ stmt.__init__(self, lineno, col_offset)
+
+ def walkabout(self, visitor):
+ visitor.visit_Import(self)
+
+ def mutate_over(self, visitor):
+ if self.names:
+ visitor._mutate_sequence(self.names)
+ return visitor.visit_Import(self)
+
+ def to_object(self, space):
+ w_node = space.call_function(get(space).w_Import)
+ if self.names is None:
+ names_w = []
+ else:
+ names_w = [node.to_object(space) for node in self.names] # alias
+ 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 = [alias.from_object(space, w_item) for w_item in names_w]
+ _lineno = space.int_w(w_lineno)
+ _col_offset = space.int_w(w_col_offset)
+ return Import(_names, _lineno, _col_offset)
+
+State.ast_type('Import', 'stmt', ['names'])
+
+
+class ImportFrom(stmt):
+
+ def __init__(self, module, names, level, lineno, col_offset):
+ self.module = module
+ self.names = names
+ self.level = level
+ stmt.__init__(self, lineno, col_offset)
+
+ def walkabout(self, visitor):
+ visitor.visit_ImportFrom(self)
+
+ def mutate_over(self, visitor):
+ if self.names:
+ visitor._mutate_sequence(self.names)
+ return visitor.visit_ImportFrom(self)
+
+ def to_object(self, space):
+ w_node = space.call_function(get(space).w_ImportFrom)
+ w_module = space.wrap(self.module) # identifier
+ space.setattr(w_node, space.wrap('module'), w_module)
+ if self.names is None:
+ names_w = []
+ else:
+ names_w = [node.to_object(space) for node in self.names] # alias
+ w_names = space.newlist(names_w)
+ space.setattr(w_node, space.wrap('names'), w_names)
+ w_level = space.wrap(self.level) # int
+ space.setattr(w_node, space.wrap('level'), w_level)
+ 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_module = get_field(space, w_node, 'module', True)
+ w_names = get_field(space, w_node, 'names', False)
+ w_level = get_field(space, w_node, 'level', True)
+ w_lineno = get_field(space, w_node, 'lineno', False)
+ w_col_offset = get_field(space, w_node, 'col_offset', False)
+ _module = space.str_or_None_w(w_module)
+ names_w = space.unpackiterable(w_names)
+ _names = [alias.from_object(space, w_item) for w_item in names_w]
+ _level = space.int_w(w_level)
+ _lineno = space.int_w(w_lineno)
+ _col_offset = space.int_w(w_col_offset)
+ return ImportFrom(_module, _names, _level, _lineno, _col_offset)
+
+State.ast_type('ImportFrom', 'stmt', ['module', 'names', 'level'])
+
+
+class Global(stmt):
+
+ 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
-
- def walkabout(self, visitor):
- visitor.visit_Import(self)
-
- def mutate_over(self, visitor):
- if self.names:
- visitor._mutate_sequence(self.names)
- return visitor.visit_Import(self)
-
- def sync_app_attrs(self, space):
- if (self.initialization_state & ~0) ^ 7:
- self.missing_field(space, ['lineno', 'col_offset', 'names'], 'Import')
- 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.interp_w(alias, w_obj) for w_obj in list_w]
- else:
- self.names = None
- if self.names is not None:
- for node in self.names:
- node.sync_app_attrs(space)
-
-
-class ImportFrom(stmt):
-
- def __init__(self, module, names, level, lineno, col_offset):
- self.module = module
- self.names = names
- self.w_names = None
- self.level = level
- stmt.__init__(self, lineno, col_offset)
- self.initialization_state = 31
-
- def walkabout(self, visitor):
- visitor.visit_ImportFrom(self)
-
- def mutate_over(self, visitor):
- if self.names:
- visitor._mutate_sequence(self.names)
- return visitor.visit_ImportFrom(self)
-
- def sync_app_attrs(self, space):
- if (self.initialization_state & ~20) ^ 11:
- self.missing_field(space, ['lineno', 'col_offset', None, 'names', None], 'ImportFrom')
- else:
- if not self.initialization_state & 4:
- self.module = None
- if not self.initialization_state & 16:
- self.level = 0
- w_list = self.w_names
- if w_list is not None:
- list_w = space.listview(w_list)
- if list_w:
- self.names = [space.interp_w(alias, w_obj) for w_obj in list_w]
- else:
- self.names = None
- if self.names is not None:
- for node in self.names:
- node.sync_app_attrs(space)
-
-
-class Global(stmt):
-
- def __init__(self, names, lineno, col_offset):
- self.names = names
- self.w_names = None
- stmt.__init__(self, lineno, col_offset)
- self.initialization_state = 7
+=======
+>>>>>>> theirs
def walkabout(self, visitor):
visitor.visit_Global(self)
@@ -975,6 +1424,7 @@
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')
@@ -987,15 +1437,44 @@
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
- self.w_names = None
stmt.__init__(self, lineno, col_offset)
- self.initialization_state = 7
def walkabout(self, visitor):
visitor.visit_Nonlocal(self)
@@ -1003,6 +1482,7 @@
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')
@@ -1015,6 +1495,34 @@
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:
+ 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 Global(_names, _lineno, _col_offset)
+
+State.ast_type('Global', 'stmt', ['names'])
+>>>>>>> theirs
class Expr(stmt):
@@ -1022,7 +1530,6 @@
def __init__(self, value, lineno, col_offset):
self.value = value
stmt.__init__(self, lineno, col_offset)
- self.initialization_state = 7
def walkabout(self, visitor):
visitor.visit_Expr(self)
@@ -1031,19 +1538,33 @@
self.value = self.value.mutate_over(visitor)
return visitor.visit_Expr(self)
- def sync_app_attrs(self, space):
- if (self.initialization_state & ~0) ^ 7:
- self.missing_field(space, ['lineno', 'col_offset', 'value'], 'Expr')
- else:
- pass
- self.value.sync_app_attrs(space)
+ def to_object(self, space):
+ w_node = space.call_function(get(space).w_Expr)
+ 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 Expr(_value, _lineno, _col_offset)
+
+State.ast_type('Expr', 'stmt', ['value'])
class Pass(stmt):
def __init__(self, lineno, col_offset):
stmt.__init__(self, lineno, col_offset)
- self.initialization_state = 3
def walkabout(self, visitor):
visitor.visit_Pass(self)
@@ -1051,18 +1572,29 @@
def mutate_over(self, visitor):
return visitor.visit_Pass(self)
- def sync_app_attrs(self, space):
- if (self.initialization_state & ~0) ^ 3:
- self.missing_field(space, ['lineno', 'col_offset'], 'Pass')
- else:
- pass
+ def to_object(self, space):
+ w_node = space.call_function(get(space).w_Pass)
+ 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 Pass(_lineno, _col_offset)
+
+State.ast_type('Pass', 'stmt', [])
class Break(stmt):
def __init__(self, lineno, col_offset):
stmt.__init__(self, lineno, col_offset)
- self.initialization_state = 3
def walkabout(self, visitor):
visitor.visit_Break(self)
@@ -1070,18 +1602,29 @@
def mutate_over(self, visitor):
return visitor.visit_Break(self)
- def sync_app_attrs(self, space):
- if (self.initialization_state & ~0) ^ 3:
- self.missing_field(space, ['lineno', 'col_offset'], 'Break')
- else:
- pass
+ def to_object(self, space):
+ w_node = space.call_function(get(space).w_Break)
+ 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 Break(_lineno, _col_offset)
+
+State.ast_type('Break', 'stmt', [])
class Continue(stmt):
def __init__(self, lineno, col_offset):
stmt.__init__(self, lineno, col_offset)
- self.initialization_state = 3
def walkabout(self, visitor):
visitor.visit_Continue(self)
@@ -1089,11 +1632,23 @@
def mutate_over(self, visitor):
return visitor.visit_Continue(self)
- def sync_app_attrs(self, space):
- if (self.initialization_state & ~0) ^ 3:
- self.missing_field(space, ['lineno', 'col_offset'], 'Continue')
- else:
More information about the pypy-commit
mailing list