Class: Duby::Compiler::JVM::ClosureCompiler

Inherits:
Duby::Compiler::JVM show all
Defined in:
lib/duby/jvm/compiler.rb

Constant Summary

Constants inherited from Duby::Compiler::JVM

Types

Instance Attribute Summary

Attributes inherited from Duby::Compiler::JVMCompilerBase

#class, #filename, #method, #static

Instance Method Summary collapse

Methods inherited from Duby::Compiler::JVM

#_raise, #annotate, #annotation_value, #array, #begin_main, #binding_reference, #body, #boolean, #bootstrap_dynamic, #branch, #break, #build_string, #call, #captured_local, #captured_local_assign, #captured_local_declare, #cast, classname_from_filename, #compile_self, #constructor, #declare_argument, #declare_field, #declare_local, #declared_fields, #declared_locals, #define_closure, #define_method, #define_optarg_chain, #empty_array, #ensure, #field, #field_assign, #field_declare, #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, #redo, #regexp, #rescue, #return, #self_call, #string, #super_call, #to_string

Methods included from JVM::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 Duby::Compiler::JVMCompilerBase

#begin_main, #body, #compile, #constructor, #declare_argument, #define_class, #define_main, #define_method, #finish_main, #generate, #get_binding, #import, #log, #scoped_body, #scoped_local_name, #toplevel_class, #with

Constructor Details

#initialize(file, type, parent) ⇒ ClosureCompiler

Returns a new instance of ClosureCompiler.



794
795
796
797
798
799
# File 'lib/duby/jvm/compiler.rb', line 794

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

Instance Method Details

#declared_capturesObject



818
819
820
# File 'lib/duby/jvm/compiler.rb', line 818

def declared_captures
  @parent.declared_captures(@binding)
end

#prepare_binding(scope) ⇒ Object



801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
# File 'lib/duby/jvm/compiler.rb', line 801

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