Module Ruva::VM::Helpers
In: lib/ruva/vm.rb

Provides a public interface to the VM. These methods are mostly useful when writing opcodes and ‘native’ method implementations.

This module is mixed into Ruva::JVM.

Methods

Public Instance methods

[Source]

     # File lib/ruva/vm.rb, line 128
128:       def build_stack_trace()
129:         strclz = find_class('java/lang/String')
130:         traceeleclz = find_class('java/lang/StackTraceElement')                
131:         
132:         # leave out bottom frame
133:         frames[1..-3].map do |frm|                       
134:           ref = init_new_object(traceeleclz, "(Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;Z)V",
135:                                 wrap_str(frm.clz.source), -1, wrap_str(frm.clz.name), 
136:                                 wrap_str(frm.method.name + frm.method.desc),
137:                                 frm.method.native? ? 1 : 0).pop;
138:           ref
139:         end.reverse   
140:       end

Convenience method. Calls through to the VM‘s Ruva::VM::ClassPoolManager

[Source]

    # File lib/ruva/vm.rb, line 93
93:       def find_class(class_name)
94:         class_pool_manager.find_class(class_name) || raise(NoClassDefFoundError, "No class definition found for #{class_name}")
95:       end

Convenience method. Calls through to the VM‘s Ruva::VM::ClassPoolManager

[Source]

     # File lib/ruva/vm.rb, line 98
 98:       def load_library(name, loader = nil)
 99:         class_pool_manager.load_library(name, loader)
100:       end

Create a new frame with the specified attributes. This *doesn‘t* push the new frame.

[Source]

     # File lib/ruva/vm.rb, line 103
103:       def new_frame(clz, method_idx, stack = [], locals = [], pc = 0)
104:         Ruva::VM::Stack::Frame.new(clz, method_idx, stack, locals, pc)
105:       end

Register a new Ruva::VM::ClassLoader with this VM‘s Ruva::VM::ClassPoolManager.

[Source]

    # File lib/ruva/vm.rb, line 88
88:       def register_classloader(loader)
89:         class_pool_manager.register_classloader(loader)
90:       end

[Source]

     # File lib/ruva/vm.rb, line 124
124:       def unwrap_str(jstr)
125:         unwrap_strs(jstr).first
126:       end

[Source]

     # File lib/ruva/vm.rb, line 118
118:       def unwrap_strs(*jstrs)
119:         jstrs.map do |jstr|
120:           Ruva::VM::Types::ConstStringRef.unwrap(jstr)
121:         end
122:       end

[Source]

     # File lib/ruva/vm.rb, line 114
114:       def wrap_str(str)
115:         wrap_strs(str).first
116:       end

Wrap the supplied Ruby string in a ConstStringRef

[Source]

     # File lib/ruva/vm.rb, line 108
108:       def wrap_strs(*strs)
109:         strs.map do |str|
110:           Ruva::VM::Types::ConstStringRef.wrap(self, str)
111:         end
112:       end

[Validate]