Class: Duby::Compiler::JavaSource::ClosureCompiler

Inherits:
Duby::Compiler::JavaSource show all
Defined in:
lib/duby/jvm/source_compiler.rb

Constant Summary

Constants inherited from Duby::Compiler::JavaSource

ArrayOps, JVMTypes, Operators

Instance Attribute Summary

Attributes inherited from Duby::Compiler::JavaSource

#lvalue

Attributes inherited from Duby::Compiler::JVMCompilerBase

#class, #filename, #method, #static

Instance Method Summary collapse

Methods inherited from Duby::Compiler::JavaSource

#_raise, #annotate, #array, #array_op, #assign, #binding_reference, #body, #boolean, #branch, #branch_expression, #break, #build_string, #call, #captured_local, #captured_local_assign, #captured_local_declare, #compile_args, #compile_self, #constructor, #declare_field, #declare_local, #define_closure, #define_method, #define_optarg_chain, #empty_array, #ensure, #expr?, #field, #field_assign, #field_declare, #line, #local, #local_assign, #local_declare, #loop, #maybe_store, #method_call, #next, #null, #operator, #output_type, #precompile_nodes, #print, #redo, #regexp, #rescue, #return, #scoped_body, #self_call, #self_type, #store_value, #string, #super_call, #super_method_call, #temp, #this, #to_string

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.



671
672
673
674
675
# File 'lib/duby/jvm/source_compiler.rb', line 671

def initialize(file, type, parent)
  @file = file
  @type = type
  @parent = parent
end

Instance Method Details

#declared_capturesObject



692
693
694
# File 'lib/duby/jvm/source_compiler.rb', line 692

def declared_captures
  @parent.declared_captures(@binding)
end

#prepare_binding(scope) ⇒ Object



677
678
679
680
681
682
683
684
685
686
687
688
689
690
# File 'lib/duby/jvm/source_compiler.rb', line 677

def prepare_binding(scope)
  if scope.has_binding?
    type = scope.binding_type
    @binding = @parent.get_binding(type)
    @method.puts("#{type.name} $binding = this.binding;")
  end
  begin
    yield
  ensure
    if scope.has_binding?
      @binding = nil
    end
  end
end