Skip to content

Instantly share code, notes, and snippets.

@ribrdb
Created April 12, 2012 17:26
Show Gist options
  • Select an option

  • Save ribrdb/2369351 to your computer and use it in GitHub Desktop.

Select an option

Save ribrdb/2369351 to your computer and use it in GitHub Desktop.
diff --git a/lib/mirah/ast/flow.rb b/lib/mirah/ast/flow.rb
index d204727..f62bce1 100644
--- a/lib/mirah/ast/flow.rb
+++ b/lib/mirah/ast/flow.rb
@@ -292,7 +292,7 @@ module Mirah
@type = types.size == 1 ? types[0] : AST.type(nil, 'java.lang.Throwable')
typer.learn_local_type(static_scope, name, @type)
end
- @inferred_type = typer.infer(body, true)
+ @inferred_type = typer.infer(body, expression)
(@inferred_type && body.resolved?) ? resolved! : typer.defer(self)
end
diff --git a/lib/mirah/ast/intrinsics.rb b/lib/mirah/ast/intrinsics.rb
index 8f2b5cd..5f459d0 100644
--- a/lib/mirah/ast/intrinsics.rb
+++ b/lib/mirah/ast/intrinsics.rb
@@ -413,7 +413,6 @@ module Mirah::AST
position, 'expand', node_type)
pos = parent.position
args = []
- puts self.arguments.inspect
expand_call = FunctionalCall.new(nil, pos, '_expand')
self.arguments.each_with_index do |arg, i|
# TODO optional args
@@ -430,15 +429,12 @@ module Mirah::AST
cast
end
end
- puts self.arguments.inspect
expand_call.parameters = args
- puts self.arguments.inspect
expand.body = transformer.eval(<<-end)
args = @call.arguments
nil
end
expand.body << expand_call
- puts self.arguments.inspect
actual_args = arguments.map do |arg|
type = if arg.kind_of?(BlockArgument)
Mirah::AST.type(nil, 'duby.lang.compiler.Block')
diff --git a/lib/mirah/jvm/types/factory.rb b/lib/mirah/jvm/types/factory.rb
index 9c03ae0..1a3d25a 100644
--- a/lib/mirah/jvm/types/factory.rb
+++ b/lib/mirah/jvm/types/factory.rb
@@ -239,6 +239,7 @@ module Mirah::JVM::Types
end
def bootstrap_loader
+ return JRuby.runtime.jruby_class_loader unless bootclasspath
@bootstrap_loader ||= begin
parent = if bootclasspath
Mirah::Util::IsolatedResourceLoader.new(make_urls(bootclasspath))
diff --git a/lib/mirah/typer/simple.rb b/lib/mirah/typer/simple.rb
index c436bb6..706df4c 100644
--- a/lib/mirah/typer/simple.rb
+++ b/lib/mirah/typer/simple.rb
@@ -192,7 +192,12 @@ module Mirah
# allow plugins a go if we're in the inference phase
simple_type = plugins do |plugin|
- plugin.method_type(self, target_type, name, parameter_types)
+ begin
+ plugin.method_type(self, target_type, name, parameter_types)
+ rescue NoMethodError => ex
+ raise ex unless ex.message =~ /#{name}/
+ nil
+ end
end
end
@@ -232,10 +237,10 @@ module Mirah
@cycling = true
count.times do |i|
begin
- log "[Cycle #{i}]: Started... (#{@deferred_nodes.size} nodes to resolve)"
+ puts "[Cycle #{i}]: Started... (#{@deferred_nodes.size} nodes to resolve)"
yield i
ensure
- log "[Cycle #{i}]: Complete!"
+ puts "[Cycle #{i}]: Complete!"
end
end
ensure
@@ -276,8 +281,8 @@ module Mirah
rescue InferenceError => ex
ex.node ||= node
error(node, ex)
- rescue Exception => ex
- raise Mirah::InternalCompilerError.wrap(ex, node)
+ # rescue Exception => ex
+ # raise Mirah::InternalCompilerError.wrap(ex, node)
end
end
@@ -331,14 +336,17 @@ module Mirah
end
if @deferred_nodes.empty?
- log "[Cycle #{i}]: Resolved all types, exiting"
+ puts "[Cycle #{i}]: Resolved all types, exiting"
break
elsif old_deferred == @deferred_nodes
if @error_next || retried
- log "[Cycle #{i}]: Made no progress, bailing out"
+ puts "[Cycle #{i}]: Made no progress, bailing out"
break
elsif @last_chance
- break unless @errors.empty?
+ unless @errors.size < 16
+ puts "errors; bailing out"
+ break
+ end
# Retry this iteration, and mark the first deferred
# type as an error.
retried = true
@@ -355,12 +363,12 @@ module Mirah
redo
end
elsif @errors.size > 15
- log "Too many errors, giving up"
+ puts "Too many errors, giving up"
break
end
retried = false
end
-
+ puts "marking remaining nodes as errors (#{raise})"
# done with n sweeps, if any remain mark them as errors
error_nodes = @errors.map {|e| e.node}
if error_nodes.empty?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment