From 04d2eeb8414339856822d0543400c34de289fdde Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 31 Oct 2014 15:23:50 -0400 Subject: these don't need to be global --- mop/__init__.py | 66 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/mop/__init__.py b/mop/__init__.py index eb43fa8..de649e4 100644 --- a/mop/__init__.py +++ b/mop/__init__.py @@ -35,43 +35,41 @@ def python_install_method(c, name, method): lambda self, *args, **kwargs: method.execute(self, args, kwargs) ) -# and finally, bootstrap helpers to create hardcoded structures during the -# bootstrap (which we will inflate into real structures at the end) -def bootstrap_create_class(name, superclass): - c = BasicInstance( - globals().get("Class"), - { - "name": name, - "superclass": superclass, - "methods": {}, - "attributes": {}, - }, - ) - # need to make sure we call this explicitly with the class name during the - # bootstrap, since we won't have get_name() yet - python_class_for(c, name) - return c - -def bootstrap_create_method(name, body): - return BasicInstance( - globals().get("Method"), - { - "name": name, - "body": body, - } - ) - -def bootstrap_create_attribute(name): - return BasicInstance( - globals().get("Attribute"), - { - "name": name, - } - ) - def bootstrap(): # Phase 1: construct the core classes + def bootstrap_create_class(name, superclass): + c = BasicInstance( + globals().get("Class"), + { + "name": name, + "superclass": superclass, + "methods": {}, + "attributes": {}, + }, + ) + # need to make sure we call this explicitly with the class name during + # the bootstrap, since we won't have get_name() yet + python_class_for(c, name) + return c + + def bootstrap_create_method(name, body): + return BasicInstance( + globals().get("Method"), + { + "name": name, + "body": body, + } + ) + + def bootstrap_create_attribute(name): + return BasicInstance( + globals().get("Attribute"), + { + "name": name, + } + ) + global Class, Object, Method, Attribute Class = bootstrap_create_class('Class', None) -- cgit v1.2.3