Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MethodContext#locals returns an array of local variables.

  • Loading branch information...
commit 990463d6ed32fe3bda7efd6902e8e3f037ab5990 1 parent 63471ac
@vincentlu vincentlu authored
View
2  AUTHORS
@@ -163,7 +163,7 @@
- Trotter Cashion:
- Tyler McMullen:
- Victor Hugo Borja:
-- Vincent Lu:
+- Vincent Lu: { irc: vlu }
- Vitaliy Geraymovych:
- Vladimir Sizikov: { irc: VVSiz }
- Warren Seen:
View
3  kernel/bootstrap/context.rb
@@ -54,7 +54,8 @@ def receiver=(val)
end
def locals
- _get_field(8)
+ Ruby.primitive :context_locals
+ raise PrimitiveFailure, "primitive failed"
end
def locals=(val)
View
9 vm/builtin/contexts.cpp
@@ -300,6 +300,15 @@ namespace rubinius {
return Qnil;
}
+ Array* MethodContext::locals(STATE) {
+ int n = this->vmm->number_of_locals;
+ Array* ary = Array::create(state, n);
+ for(int i = 0; i < n; i++) {
+ ary->set(state, i, this->get_local(i));
+ }
+ return ary;
+ }
+
/* Return a new +BlockContext+ object, which needs +stack_size+ fields
* worth of stack. */
BlockContext* BlockContext::create(STATE, size_t stack_size) {
View
4 vm/builtin/contexts.hpp
@@ -1,6 +1,7 @@
#ifndef RBX_BUILTIN_CONTEXTS_HPP
#define RBX_BUILTIN_CONTEXTS_HPP
+#include "builtin/array.hpp"
#include "builtin/object.hpp"
#include "type_info.hpp"
#include "vmmethod.hpp"
@@ -87,6 +88,9 @@ namespace rubinius {
// Ruby.primitive :context_get_field
Object* get_internal_data(STATE, Fixnum* type);
+ // Ruby.primitive :context_locals
+ Array* locals(STATE);
+
// Ruby.primitive :context_dup
MethodContext* dup(STATE);
Please sign in to comment.
Something went wrong with that request. Please try again.