Permalink
Browse files

Added Self#init() method which creates the static singleton instance …

…instead of doing so within Self#node()
  • Loading branch information...
1 parent 49a9cd6 commit f1b90a867247a95405e2504f81b0c07d8c885863 @bakkdoor committed Sep 8, 2010
Showing with 12 additions and 1 deletion.
  1. +6 −0 src/bootstrap/core_classes.cc
  2. +5 −1 src/parser/nodes/self.cc
  3. +1 −0 src/parser/nodes/self.h
@@ -7,6 +7,9 @@
#include "../nil.h"
#include "../true.h"
+#include "../parser/nodes/self.h"
+
+
namespace fancy {
/**
@@ -142,6 +145,9 @@ namespace fancy {
global_scope->define("true", t);
// a hack for "def NATIVE" method definitions:
global_scope->define("NATIVE", new FancyObject(ObjectClass));
+
+ // initialize Self node singleton instance
+ Self::init();
}
}
View
@@ -8,10 +8,14 @@ namespace fancy {
Self* Self::_self_node = NULL;
Self* Self::node()
{
+ return _self_node;
+ }
+
+ void Self::init()
+ {
if(!_self_node) {
_self_node = new Self();
}
- return _self_node;
}
Self::Self() : Identifier("self")
View
@@ -11,6 +11,7 @@ namespace fancy {
{
public:
static Self* node();
+ static void init();
private:
Self();
virtual ~Self() {}

0 comments on commit f1b90a8

Please sign in to comment.