[macruby-changes] [4986] MacRuby/trunk

source_changes at macosforge.org source_changes at macosforge.org
Mon Dec 6 14:42:49 PST 2010


Revision: 4986
          http://trac.macosforge.org/projects/ruby/changeset/4986
Author:   lsansonetti at apple.com
Date:     2010-12-06 14:42:46 -0800 (Mon, 06 Dec 2010)
Log Message:
-----------
implement last_line $_ VM variable (patch by Ben Mitchell <warpflyght at telltales.net>)

Modified Paths:
--------------
    MacRuby/trunk/vm.cpp
    MacRuby/trunk/vm.h

Modified: MacRuby/trunk/vm.cpp
===================================================================
--- MacRuby/trunk/vm.cpp	2010-12-06 22:06:17 UTC (rev 4985)
+++ MacRuby/trunk/vm.cpp	2010-12-06 22:42:46 UTC (rev 4986)
@@ -393,6 +393,7 @@
     safe_level = 0;
     backref = Qnil;
     broken_with = Qundef;
+    last_line = Qnil;
     last_status = Qnil;
     errinfo = Qnil;
     parse_in_eval = false;
@@ -459,6 +460,7 @@
 
     backref = Qnil;
     broken_with = Qundef;
+    last_line = Qnil;
     last_status = Qnil;
     errinfo = Qnil;
     parse_in_eval = false;
@@ -4146,15 +4148,19 @@
 VALUE
 rb_lastline_get(void)
 {
-    // TODO
-    return Qnil;
+    return GET_VM()->get_last_line();
 }
 
 extern "C"
 void
 rb_lastline_set(VALUE val)
 {
-    // TODO
+    VALUE old = GET_VM()->get_last_line();
+    if (old != val) {
+	GC_RELEASE(old);
+	GET_VM()->set_last_line(val);
+	GC_RETAIN(val);
+    }
 }
 
 extern "C"

Modified: MacRuby/trunk/vm.h
===================================================================
--- MacRuby/trunk/vm.h	2010-12-06 22:06:17 UTC (rev 4985)
+++ MacRuby/trunk/vm.h	2010-12-06 22:42:46 UTC (rev 4986)
@@ -1025,6 +1025,7 @@
 	VALUE current_top_object;
 	VALUE backref;
 	VALUE broken_with;
+	VALUE last_line;
 	VALUE last_status;
 	VALUE errinfo;
 	int safe_level;
@@ -1052,6 +1053,7 @@
 	ACCESSOR(current_top_object, VALUE);
 	ACCESSOR(backref, VALUE);
 	ACCESSOR(broken_with, VALUE);
+	ACCESSOR(last_line, VALUE);
 	ACCESSOR(last_status, VALUE);
 	ACCESSOR(errinfo, VALUE);
 	ACCESSOR(safe_level, int);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101206/d80ef855/attachment-0001.html>


More information about the macruby-changes mailing list