# Path: nolang/opcodes.py
# class Opcode(object):
#     def __init__(self, name, numargs, stack_effect, description):
#     def __repr__(self):
# def setup():
# 
# Path: nolang/function.py
# class W_Function(W_Root):
#     def __init__(self, name, bytecode):
#         self.name = name
#         self.bytecode = bytecode
# 
#     def setup(self, space):
#         self.bytecode.setup(space)
# 
#     def call(self, space, interpreter, args_w, kwargs):
#         frame = Frame(self.bytecode, self.name)
#         args_w = prepare_args(space, self.name, self.bytecode, args_w, kwargs)
#         frame.populate_args(args_w)
#         return interpreter.interpret(space, self.bytecode, frame)
# 
#     def bind(self, space, w_obj):
#         return W_BoundMethod(w_obj, self)
# 
# Path: nolang/objects/usertype.py
# class W_UserType(W_Root):
#     def __init__(self, allocate, name, class_elements_w, w_parent,
#                  default_alloc=True, force_names=None):
#         self.name = name
#         self.allocate = allocate
#         self.class_elements_w = class_elements_w
#         self.default_alloc = default_alloc
#         if w_parent is not None:
#             self._dict_w = w_parent._dict_w.copy()
#         else:
#             self._dict_w = {}
#         for item in class_elements_w:
#             self._dict_w[item.name] = item
#         self.w_parent = w_parent
#         if force_names is None:
#             self.force_names = None
#         else:
#             self.force_names = {}
#             for elem in force_names:
#                 self.force_names[elem] = None
# 
#     def setup(self, space):
#         for item in self.class_elements_w:
#             item.setup(space)
# 
#     def call(self, space, interpreter, args_w, kwargs):
#         if self.allocate is None:
#             raise Exception("cannot be called like that")
#         w_obj = space.call(self.allocate, [self] + args_w, kwargs)
#         if '__init__' in self._dict_w:
#             space.call(self._dict_w['__init__'], [w_obj] + args_w, kwargs)
#         elif self.default_alloc:
#             if len(args_w) != 0:
#                 raise space.apperr(space.w_argerror, "Default constructor"
#                     " expecting no arguments")
#         return w_obj
# 
#     def getattr(self, space, attrname):
#         try:
#             return self._dict_w[attrname]
#         except KeyError:
#             return space.w_NotImplemented
# 
#     def issubclass(self, w_type):
#         cur = self
#         while cur is not None:
#             if cur is w_type:
#                 return True
#             cur = cur.w_parent
#         return False
# 
#     def __repr__(self):
#         return "<UserType %s>" % (self.name,)
# 
# Path: nolang/bytecode.py
# def compile_bytecode(ast, source, w_mod, arglist=[], startlineno=0):
#     """ Compile the bytecode from produced AST.
#     """
#     builder = _BytecodeBuilder(w_mod, arglist[:])
#     ast.compile(builder)
#     # hack to enable building for now
#     builder.emit(ast.getendidx(), opcodes.LOAD_NONE)
#     builder.emit(ast.getendidx(), opcodes.RETURN)
#     return builder.build(w_mod.name, source)
# 
# Path: nolang/compiler.py
# def compile_class(space, source, ast, w_mod, parent=None):
#     if parent is not None:
#         w_parent = w_mod.functions[w_mod.name2index[parent]]
#     else:
#         w_parent = None
#     if w_parent is not None:
#         alloc = w_parent.allocate
#         default_alloc = w_parent.default_alloc
#     else:
#         alloc = get_alloc(space)
#         default_alloc = True
#     class_elements_w = []
#     for item in ast.get_element_list():
#         item.add_global_symbols(space, class_elements_w, source, w_mod)
#     return alloc, class_elements_w, w_parent, default_alloc


from nolang import opcodes
from nolang.function import W_Function
from nolang.objects.usertype import W_UserType
from nolang.bytecode import compile_bytecode
from nolang.compiler import compile_class
from rply.token import BaseBox
    def add_missing_imports(self, space, w_mod, globals_w, importer):
        pass

    def __repr__(self):
        return "%s(%s)" % (self.__class__.__name__, ", ".join([
            "%s=%s" % (k, v) for k, v in self.__dict__.iteritems()
            if k != '_srcpos']))

    def __eq__(self, other):
        if self.__class__ != other.__class__:
            return False
        to_compare = self.__dict__.copy()
        other = other.__dict__.copy()
        del to_compare['_startidx']
        del to_compare['_endidx']
        del other['_startidx']
        del other['_endidx']
        return to_compare == other

    def __ne__(self, other):
        return not self == other


class Number(AstNode):
    def __init__(self, value, srcpos=None):
        AstNode.__init__(self, srcpos)
        self.value = value

    def compile(self, state):
        no = state.add_int_constant(self.value)

# Path: nolang/opcodes.py
# class Opcode(object):
#     def __init__(self, name, numargs, stack_effect, description):
#     def __repr__(self):
# def setup():
# 
# Path: nolang/function.py
# class W_Function(W_Root):
#     def __init__(self, name, bytecode):
#         self.name = name
#         self.bytecode = bytecode
# 
#     def setup(self, space):
#         self.bytecode.setup(space)
# 
#     def call(self, space, interpreter, args_w, kwargs):
#         frame = Frame(self.bytecode, self.name)
#         args_w = prepare_args(space, self.name, self.bytecode, args_w, kwargs)
#         frame.populate_args(args_w)
#         return interpreter.interpret(space, self.bytecode, frame)
# 
#     def bind(self, space, w_obj):
#         return W_BoundMethod(w_obj, self)
# 
# Path: nolang/objects/usertype.py
# class W_UserType(W_Root):
#     def __init__(self, allocate, name, class_elements_w, w_parent,
#                  default_alloc=True, force_names=None):
#         self.name = name
#         self.allocate = allocate
#         self.class_elements_w = class_elements_w
#         self.default_alloc = default_alloc
#         if w_parent is not None:
#             self._dict_w = w_parent._dict_w.copy()
#         else:
#             self._dict_w = {}
#         for item in class_elements_w:
#             self._dict_w[item.name] = item
#         self.w_parent = w_parent
#         if force_names is None:
#             self.force_names = None
#         else:
#             self.force_names = {}
#             for elem in force_names:
#                 self.force_names[elem] = None
# 
#     def setup(self, space):
#         for item in self.class_elements_w:
#             item.setup(space)
# 
#     def call(self, space, interpreter, args_w, kwargs):
#         if self.allocate is None:
#             raise Exception("cannot be called like that")
#         w_obj = space.call(self.allocate, [self] + args_w, kwargs)
#         if '__init__' in self._dict_w:
#             space.call(self._dict_w['__init__'], [w_obj] + args_w, kwargs)
#         elif self.default_alloc:
#             if len(args_w) != 0:
#                 raise space.apperr(space.w_argerror, "Default constructor"
#                     " expecting no arguments")
#         return w_obj
# 
#     def getattr(self, space, attrname):
#         try:
#             return self._dict_w[attrname]
#         except KeyError:
#             return space.w_NotImplemented
# 
#     def issubclass(self, w_type):
#         cur = self
#         while cur is not None:
#             if cur is w_type:
#                 return True
#             cur = cur.w_parent
#         return False
# 
#     def __repr__(self):
#         return "<UserType %s>" % (self.name,)
# 
# Path: nolang/bytecode.py
# def compile_bytecode(ast, source, w_mod, arglist=[], startlineno=0):
#     """ Compile the bytecode from produced AST.
#     """
#     builder = _BytecodeBuilder(w_mod, arglist[:])
#     ast.compile(builder)
#     # hack to enable building for now
#     builder.emit(ast.getendidx(), opcodes.LOAD_NONE)
#     builder.emit(ast.getendidx(), opcodes.RETURN)
#     return builder.build(w_mod.name, source)
# 
# Path: nolang/compiler.py
# def compile_class(space, source, ast, w_mod, parent=None):
#     if parent is not None:
#         w_parent = w_mod.functions[w_mod.name2index[parent]]
#     else:
#         w_parent = None
#     if w_parent is not None:
#         alloc = w_parent.allocate
#         default_alloc = w_parent.default_alloc
#     else:
#         alloc = get_alloc(space)
#         default_alloc = True
#     class_elements_w = []
#     for item in ast.get_element_list():
#         item.add_global_symbols(space, class_elements_w, source, w_mod)
#     return alloc, class_elements_w, w_parent, default_alloc


# Path: nolang/astnodes.py
from nolang import opcodes
from nolang.function import W_Function
from nolang.objects.usertype import W_UserType
from nolang.bytecode import compile_bytecode
from nolang.compiler import compile_class
from rply.token import BaseBox

    def add_missing_imports(self, space, w_mod, globals_w, importer):
        pass

    def __repr__(self):
        return "%s(%s)" % (self.__class__.__name__, ", ".join([
            "%s=%s" % (k, v) for k, v in self.__dict__.iteritems()
            if k != '_srcpos']))

    def __eq__(self, other):
        if self.__class__ != other.__class__:
            return False
        to_compare = self.__dict__.copy()
        other = other.__dict__.copy()
        del to_compare['_startidx']
        del to_compare['_endidx']
        del other['_startidx']
        del other['_endidx']
        return to_compare == other

    def __ne__(self, other):
        return not self == other


class Number(AstNode):
    def __init__(self, value, srcpos=None):
        AstNode.__init__(self, srcpos)
        self.value = value

    def compile(self, state):
        no = state.add_int_constant(self.value)

        state.emit(self.getstartidx(), opcodes.LOAD_CONSTANT, no)