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

source_changes at macosforge.org source_changes at macosforge.org
Fri Mar 27 12:17:09 PDT 2009


Revision: 1208
          http://trac.macosforge.org/projects/ruby/changeset/1208
Author:   lsansonetti at apple.com
Date:     2009-03-27 12:17:09 -0700 (Fri, 27 Mar 2009)
Log Message:
-----------
implemented the compiler side of 'undef'

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

Modified: MacRuby/branches/experimental/roxor.cpp
===================================================================
--- MacRuby/branches/experimental/roxor.cpp	2009-03-27 19:01:45 UTC (rev 1207)
+++ MacRuby/branches/experimental/roxor.cpp	2009-03-27 19:17:09 UTC (rev 1208)
@@ -214,6 +214,7 @@
 	Function *getIvarFunc;
 	Function *setIvarFunc;
 	Function *definedFunc;
+	Function *undefFunc;
 	Function *aliasFunc;
 	Function *valiasFunc;
 	Function *newHashFunc;
@@ -550,6 +551,7 @@
     getIvarFunc = NULL;
     setIvarFunc = NULL;
     definedFunc = NULL;
+    undefFunc = NULL;
     aliasFunc = NULL;
     valiasFunc = NULL;
     newHashFunc = NULL;
@@ -3725,6 +3727,29 @@
 	    }
 	    break;
 
+	case NODE_UNDEF:
+	    {
+		if (undefFunc == NULL) {
+		    // VALUE rb_vm_undef(VALUE klass, ID name);
+		    undefFunc =
+			cast<Function>(module->getOrInsertFunction(
+				"rb_vm_undef",
+				Type::VoidTy, RubyObjTy, IntTy, NULL));
+		}
+
+		assert(node->u2.node != NULL);
+		ID name = node->u2.node->u1.id;
+
+		std::vector<Value *> params;
+		params.push_back(compile_current_class());
+		params.push_back(ConstantInt::get(IntTy, name));
+
+		compile_protected_call(undefFunc, params);
+
+		return nilVal;
+	    }
+	    break;
+
 	case NODE_TRUE:
 	    return trueVal;
 
@@ -4538,6 +4563,17 @@
 }
 
 extern "C"
+void
+rb_vm_undef(VALUE klass, ID name)
+{
+    if (GET_VM()->current_class != NULL) {
+	klass = (VALUE)GET_VM()->current_class;
+    }
+
+    rb_undef(klass, name);
+}
+
+extern "C"
 VALUE
 rb_vm_defined(VALUE self, int type, VALUE what, VALUE what2)
 {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090327/dcd5f027/attachment-0001.html>


More information about the macruby-changes mailing list