[macruby-changes] [4076] MacRuby/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Tue May 11 18:32:27 PDT 2010
Revision: 4076
http://trac.macosforge.org/projects/ruby/changeset/4076
Author: lsansonetti at apple.com
Date: 2010-05-11 18:32:22 -0700 (Tue, 11 May 2010)
Log Message:
-----------
fixed a bug in the compilation of the alias keyword, some arguments can be interpolated symbols (not literals)
Modified Paths:
--------------
MacRuby/trunk/compiler.cpp
MacRuby/trunk/vm.cpp
Modified: MacRuby/trunk/compiler.cpp
===================================================================
--- MacRuby/trunk/compiler.cpp 2010-05-12 00:05:41 UTC (rev 4075)
+++ MacRuby/trunk/compiler.cpp 2010-05-12 01:32:22 UTC (rev 4076)
@@ -4686,26 +4686,21 @@
case NODE_ALIAS:
{
if (aliasFunc == NULL) {
- // void rb_vm_alias2(VALUE outer, ID from, ID to,
- // unsigned char dynamic_class);
+ // void rb_vm_alias2(VALUE outer, VALUE from_sym,
+ // VALUE to_sym, unsigned char dynamic_class);
aliasFunc = cast<Function>(module->getOrInsertFunction(
"rb_vm_alias2",
VoidTy, RubyObjTy, IntTy, IntTy, Int8Ty,
NULL));
}
- assert(nd_type(node->u1.node) == NODE_LIT);
- assert(nd_type(node->u2.node) == NODE_LIT);
- assert(TYPE(node->u1.node->nd_lit) == T_SYMBOL);
- assert(TYPE(node->u2.node->nd_lit) == T_SYMBOL);
+ assert(node->u1.node != NULL);
+ assert(node->u2.node != NULL);
- ID from = SYM2ID(node->u1.node->nd_lit);
- ID to = SYM2ID(node->u2.node->nd_lit);
-
std::vector<Value *> params;
params.push_back(compile_current_class());
- params.push_back(compile_id(from));
- params.push_back(compile_id(to));
+ params.push_back(compile_node(node->u1.node));
+ params.push_back(compile_node(node->u2.node));
params.push_back(ConstantInt::get(Int8Ty,
dynamic_class ? 1 : 0));
Modified: MacRuby/trunk/vm.cpp
===================================================================
--- MacRuby/trunk/vm.cpp 2010-05-12 00:05:41 UTC (rev 4075)
+++ MacRuby/trunk/vm.cpp 2010-05-12 01:32:22 UTC (rev 4076)
@@ -1609,7 +1609,7 @@
extern "C" void rb_print_undef(VALUE, ID, int);
static void
-rb_vm_alias_method(Class klass, Method method, ID name, bool noargs)
+vm_alias_method(Class klass, Method method, ID name, bool noargs)
{
IMP imp = method_getImplementation(method);
if (UNAVAILABLE_IMP(imp)) {
@@ -1638,41 +1638,15 @@
}
}
-extern "C"
-void
-rb_vm_alias2(VALUE outer, ID name, ID def, unsigned char dynamic_class)
+static void
+vm_alias(VALUE outer, ID name, ID def)
{
- if (dynamic_class) {
- Class k = GET_VM()->get_current_class();
- if (k != NULL) {
- outer = (VALUE)k;
- }
- }
rb_frozen_class_p(outer);
if (outer == rb_cObject) {
rb_secure(4);
}
VALUE dest = outer;
- // XXX this isn't quite working yet.
-#if 0
- // When aliasing a method on String, Array or Hash, we must be careful to
- // pick the implementation from the NSCF class and register it into the
- // non-mutable NS class, to make sure the machinery works.
- if (outer == rb_cNSMutableString || outer == rb_cNSString) {
- outer = rb_cCFString;
- dest = rb_cString;
- }
- else if (outer == rb_cNSMutableArray || outer == rb_cNSArray) {
- outer = rb_cCFArray;
- dest = rb_cArray;
- }
- else if (outer == rb_cNSMutableHash || outer == rb_cNSHash) {
- outer = rb_cCFHash;
- dest = rb_cHash;
- }
-#endif
-
Class klass = (Class)outer;
Class dest_klass = (Class)dest;
@@ -1691,18 +1665,36 @@
rb_print_undef((VALUE)klass, def, 0);
}
if (def_method1 != NULL) {
- rb_vm_alias_method(dest_klass, def_method1, name, true);
+ vm_alias_method(dest_klass, def_method1, name, true);
}
if (def_method2 != NULL) {
- rb_vm_alias_method(dest_klass, def_method2, name, false);
+ vm_alias_method(dest_klass, def_method2, name, false);
}
}
extern "C"
void
+rb_vm_alias2(VALUE outer, VALUE name, VALUE def, unsigned char dynamic_class)
+{
+ if (dynamic_class) {
+ Class k = GET_VM()->get_current_class();
+ if (k != NULL) {
+ outer = (VALUE)k;
+ }
+ }
+
+ // Given arguments should always be symbols (compiled as such).
+ assert(TYPE(name) == T_SYMBOL);
+ assert(TYPE(def) == T_SYMBOL);
+
+ vm_alias(outer, SYM2ID(name), SYM2ID(def));
+}
+
+extern "C"
+void
rb_vm_alias(VALUE outer, ID name, ID def)
{
- rb_vm_alias2(outer, name, def, false);
+ vm_alias(outer, name, def);
}
extern "C"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100511/98041415/attachment.html>
More information about the macruby-changes
mailing list