[macruby-changes] [1162] MacRuby/branches/experimental/roxor.cpp

source_changes at macosforge.org source_changes at macosforge.org
Wed Mar 25 23:00:40 PDT 2009


Revision: 1162
          http://trac.macosforge.org/projects/ruby/changeset/1162
Author:   lsansonetti at apple.com
Date:     2009-03-25 23:00:39 -0700 (Wed, 25 Mar 2009)
Log Message:
-----------
fixed a bug + added some comments

Modified Paths:
--------------
    MacRuby/branches/experimental/roxor.cpp

Modified: MacRuby/branches/experimental/roxor.cpp
===================================================================
--- MacRuby/branches/experimental/roxor.cpp	2009-03-26 05:19:24 UTC (rev 1161)
+++ MacRuby/branches/experimental/roxor.cpp	2009-03-26 06:00:39 UTC (rev 1162)
@@ -309,6 +309,9 @@
 	    }
 	    std::map<ID, int *>::iterator iter = ivar_slots_cache.find(id);
 	    if (iter == ivar_slots_cache.end()) {
+#if ROXOR_COMPILER_DEBUG
+		printf("allocating a new slot for ivar %s\n", rb_id2name(id));
+#endif
 		int *slot = (int *)malloc(sizeof(int));
 		*slot = -1;
 		ivar_slots_cache[id] = slot;
@@ -3902,7 +3905,6 @@
 	    {
 		std::map<ID, Value *> old_dvars = dvars;
 
-		current_block = true;
 		BasicBlock *old_current_loop_begin_bb = current_loop_begin_bb;
 		BasicBlock *old_current_loop_body_bb = current_loop_body_bb;
 		BasicBlock *old_current_loop_end_bb = current_loop_end_bb;
@@ -3910,7 +3912,9 @@
 		Function *old_current_block_func = current_block_func;
 		NODE *old_current_block_node = current_block_node;
 		ID old_current_mid = current_mid;
+		bool old_current_block = current_block;
 		current_mid = 0;
+		current_block = true;
 
 		assert(node->nd_body != NULL);
 		Value *block = compile_node(node->nd_body);	
@@ -3919,8 +3923,8 @@
 		current_loop_begin_bb = old_current_loop_begin_bb;
 		current_loop_body_bb = old_current_loop_body_bb;
 		current_loop_end_bb = old_current_loop_end_bb;
-		current_block = false;
 		current_mid = old_current_mid;
+		current_block = old_current_block;
 
 		current_block_func = cast<Function>(block);
 		current_block_node = node->nd_body;
@@ -4149,6 +4153,7 @@
 static inline VALUE
 rb_const_get_direct(VALUE klass, ID id)
 {
+    // Search the given class.
     CFDictionaryRef iv_dict = rb_class_ivar_dict(klass);
     if (iv_dict != NULL) {
 	VALUE value;
@@ -4157,6 +4162,7 @@
 	    return value;
 	}
     }
+    // Search the included modules.
     VALUE mods = rb_attr_get(klass, idIncludedModules);
     if (mods != Qnil) {
 	int i, count = RARRAY_LEN(mods);
@@ -4174,6 +4180,8 @@
 rb_vm_const_lookup(VALUE outer, ID path, bool lexical, bool defined)
 {
     if (lexical) {
+	// Let's do a lexical lookup before a hierarchical one, by looking for
+	// the given constant in all modules under the given outer.
 	struct rb_vm_outer *o = GET_VM()->get_outer((Class)outer);
 	while (o != NULL && o->klass != (Class)rb_cNSObject) {
 	    VALUE val = rb_const_get_direct((VALUE)o->klass, path);
@@ -4184,6 +4192,7 @@
 	}
     }
 
+    // Nothing was found earlier so here we do a hierarchical lookup.
     return defined ? rb_const_defined(outer, path) : rb_const_get(outer, path);
 }
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090325/1f08d656/attachment.html>


More information about the macruby-changes mailing list