Class: Mirah::JVM::Compiler::JVMBytecode::ClosureCompiler

Inherits:
Mirah::JVM::Compiler::JVMBytecode show all
Defined in:
lib/mirah/jvm/compiler/jvm_bytecode.rb

Constant Summary

Constants inherited from Mirah::JVM::Compiler::JVMBytecode

Types

Instance Attribute Summary

Attributes inherited from Base

#class, #filename, #method, #static

Instance Method Summary collapse

Methods inherited from Mirah::JVM::Compiler::JVMBytecode

#_raise, #annotate, #annotation_value, #array, #begin_main, #binding_reference, #body, #boolean, #branch, #break, #build_string, #call, #captured_local, #captured_local_assign, #captured_local_declare, #cast, classname_from_filename, #constructor, #declare_field, #declare_local, #declare_locals, #declared?, #declared_fields, #declared_locals, #define_closure, #define_method, #define_optarg_chain, #empty_array, #ensure, #extract_method, #field, #field_assign, #field_declare, #file_builder, #find_ensures, #finish_main, #get_binding, #handle_ensures, #jump_if, #jump_if_not, #line, #local, #local_assign, #local_declare, log, #loop, #method_body, #next, #null, #output_type, #print, #push_jump_scope, #real_self, #redo, #regexp, #rescue, #return, #self_call, #string, #super_call, #to_string

Methods included from MethodLookup

#each_is_exact, #each_is_exact_or_subtype_or_convertible, #field_lookup, #find_jls, #find_method, #inner_class, #is_more_specific?, #log, #phase1, #phase2, #phase3, #primitive_convertible?

Methods inherited from Base

#base_define_method, #begin_main, #body, #compile, #compile_self, #constructor, #create_method_builder, #declare_argument, #define_class, #define_main, #error, #finish_main, #fixnum, #generate, #get_binding, #import, #log, #original_create_method_builder, #scoped_body, #scoped_local_name, #toplevel_class, #with

Constructor Details

#initialize(file, type, parent) ⇒ ClosureCompiler

Returns a new instance of ClosureCompiler.



820
821
822
823
824
825
# File 'lib/mirah/jvm/compiler/jvm_bytecode.rb', line 820

def initialize(file, type, parent)
  @file = file
  @type = type
  @jump_scope = []
  @parent = parent
end

Instance Method Details

#declared_capturesObject



844
845
846
# File 'lib/mirah/jvm/compiler/jvm_bytecode.rb', line 844

def declared_captures
  @parent.declared_captures(@binding)
end

#prepare_binding(scope) ⇒ Object



827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
# File 'lib/mirah/jvm/compiler/jvm_bytecode.rb', line 827

def prepare_binding(scope)
  if scope.has_binding?
    type = scope.binding_type
    @binding = @parent.get_binding(type)
    @method.aload 0
    @method.getfield(@class, 'binding', @binding)
    type.store(@method, @method.local('$binding', type))
  end
  begin
    yield
  ensure
    if scope.has_binding?
      @binding = nil
    end
  end
end