Module: Duby

Included in:
Typer::BaseTyper
Defined in:
lib/duby.rb,
lib/duby/ast.rb,
lib/duby/env.rb,
lib/duby/typer.rb,
lib/duby/ast/flow.rb,
lib/duby/compiler.rb,
lib/duby/jvm/base.rb,
lib/duby/jvm/typer.rb,
lib/duby/jvm/types.rb,
lib/duby/transform.rb,
lib/duby/nbcompiler.rb,
lib/duby/plugin/java.rb,
lib/duby/jvm/compiler.rb,
lib/duby/jvm/method_lookup.rb,
lib/duby/jvm/source_compiler.rb,
lib/duby/jvm/source_generator/typer.rb,
lib/duby/jvm/source_generator/builder.rb

Defined Under Namespace

Modules: AST, Compiler, Env, JVM, JavaSource, Transform, Typer Classes: CompilationState, NbCompiler

Constant Summary collapse

TransformError =
Transform::Error

Class Method Summary collapse

Class Method Details

.compile(*args) ⇒ Object



24
25
26
# File 'lib/duby.rb', line 24

def self.compile(*args)
  DubyImpl.new.compile(*args)
end

.parse(*args) ⇒ Object



28
29
30
# File 'lib/duby.rb', line 28

def self.parse(*args)
  DubyImpl.new.parse(*args)
end

.pluginsObject



32
33
34
# File 'lib/duby.rb', line 32

def self.plugins
  @plugins ||= []
end


40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/duby.rb', line 40

def self.print_error(message, position)
  puts "#{position.file}:#{position.start_line + 1}: #{message}"
  file_offset = 0
  startline = position.start_line
  endline = position.end_line
  start_offset = position.start_offset
  end_offset = position.end_offset
  # don't try to search dash_e
  # TODO: show dash_e source the same way
  if File.exist? position.file
    File.open(position.file).each_with_index do |line, lineno|
      line_end = file_offset + line.size
      skip = [start_offset - file_offset, line.size].min
      if lineno >= startline && lineno <= endline
        puts line.chomp
        if skip > 0
          print ' ' * (skip)
        else
          skip = 0
        end
        if line_end <= end_offset
          puts '^' * (line.size - skip)
        else
          puts '^' * [end_offset - skip - file_offset, 1].max
        end
      end
      file_offset = line_end
    end
  end
end

.resetObject



36
37
38
# File 'lib/duby.rb', line 36

def self.reset
  @plugins.each {|x| x.reset if x.respond_to?(:reset)}
end

.run(*args) ⇒ Object



20
21
22
# File 'lib/duby.rb', line 20

def self.run(*args)
  DubyImpl.new.run(*args)
end

.typer_pluginsObject



375
376
377
# File 'lib/duby/typer.rb', line 375

def self.typer_plugins
  @typer_plugins ||= []
end