Skip to content

Commit

Permalink
Re-enable hash_test.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Brown committed Apr 20, 2012
1 parent c43ce7a commit 6223111
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 75 deletions.
1 change: 0 additions & 1 deletion lib/mirah/compiler.rb
Expand Up @@ -36,7 +36,6 @@ def compile_asts(nodes, scoper, typer)
end

def compile_ast(ast, scoper, typer, &block)
typer.verifier.scan(ast, ast)
@compiler = compiler_class.new(scoper, typer)
compiler.visit(ast, nil)
compiler.generate(&block)
Expand Down
2 changes: 0 additions & 2 deletions lib/mirah/generator.rb
Expand Up @@ -65,8 +65,6 @@ def infer_asts(nodes, should_raise=false)
end
process_inference_errors(@typer, nodes, &error_handler)
rescue NativeException => ex
ex.cause.printStackTrace
sleep(1)
log("Caught exception during type inference", ex.cause)
raise ex
ensure
Expand Down
2 changes: 1 addition & 1 deletion lib/mirah/jvm/types/boolean.rb
Expand Up @@ -35,7 +35,7 @@ def add_intrinsics
end

def math_type
Boolean
@type_system.type(nil, 'boolean')
end

# same as NumberType's
Expand Down
4 changes: 2 additions & 2 deletions lib/mirah/jvm/types/factory.rb
Expand Up @@ -80,9 +80,9 @@ def maybe_initialize_builtins(compiler)
begin
Builtins.initialize_builtins(compiler)
rescue NativeException => ex
log("Error initializing builtins", ex.cause)
error("Error initializing builtins", ex.cause)
rescue => ex
log("Error initializing builtins: #{ex.message}\n\t#{ex.backtrace.join("\n\t")}")
error("Error initializing builtins: #{ex.message}\n\t#{ex.backtrace.join("\n\t")}")
end
else
warning "Unable to initialize builtins"
Expand Down
30 changes: 0 additions & 30 deletions src/org/mirah/typer/futures.mirah
Expand Up @@ -251,36 +251,6 @@ class AssignableTypeFuture < BaseTypeFuture
end
end

class MaybeInline < BaseTypeFuture
def initialize(n:Node, type:TypeFuture, altNode:Node, altType:TypeFuture)
super(n.position)
node = n
@inlined = false
me = self
altType.onUpdate do |x, value|
if me.inlined || value.name != ':error'
unless me.inlined
me.inlined = true
node.parent.replaceChild(node, altNode)
end
me.resolved(value)
end
end
type.onUpdate do |x, value|
unless me.inlined
me.resolved(value)
end
end
end

def inlined=(inlined:boolean):void
@inlined = inlined
end
def inlined:boolean
@inlined
end
end

interface PickerListener do
def picked(selection:TypeFuture, value:Object):void; end
end
Expand Down
33 changes: 0 additions & 33 deletions src/org/mirah/typer/typer.mirah
Expand Up @@ -43,7 +43,6 @@ class Typer < SimpleNodeVisitor
@scopes = scopes
@closures = ClosureBuilder.new(self)
@macros = MacroBuilder.new(self, jvm_backend)
@verifier = AstVerifier.new
end

def macro_compiler
Expand All @@ -58,10 +57,6 @@ class Typer < SimpleNodeVisitor
@scopes
end

def verifier:NodeScanner
@verifier
end

def getInferredType(node:Node)
TypeFuture(@futures[node])
end
Expand Down Expand Up @@ -153,7 +148,6 @@ class Typer < SimpleNodeVisitor
typer.logger.fine("Unable to replace #{current_node} with #{node}")
else
node = current_node.parent.replaceChild(current_node, node)
typer.verifier.scan(node, node)
future.type = typer.infer(node, expression != nil)
end
current_node = node
Expand All @@ -178,7 +172,6 @@ class Typer < SimpleNodeVisitor
typer.logger.fine("Expanding macro #{call}")
node = InlineCode(resolvedType).expand(call, typer)
node = call.parent.replaceChild(call, node)
typer.verifier.scan(node, node)
delegate.type = typer.infer(node, expression != nil)
else
delegate.type = methodType
Expand All @@ -199,7 +192,6 @@ class Typer < SimpleNodeVisitor
if arg != nil
# We chose the cast.
call.parent.replaceChild(call, cast)
typer.verifier.scan(cast, cast)
typer.infer(cast, expression != nil)
end
end)
Expand All @@ -224,7 +216,6 @@ class Typer < SimpleNodeVisitor
newNode = Node(call)
end
newNode = assignment.parent.replaceChild(assignment, newNode)
@verifier.scan(newNode, newNode)
infer(newNode)
end

Expand All @@ -242,7 +233,6 @@ class Typer < SimpleNodeVisitor
typer.logger.fine("Expanding macro #{call}")
node = InlineCode(resolvedType).expand(call, typer)
node = call.parent.replaceChild(call, node)
typer.verifier.scan(node, node)
delegate.type = typer.infer(node, expression != nil)
else
delegate.type = methodType
Expand Down Expand Up @@ -278,7 +268,6 @@ class Typer < SimpleNodeVisitor
TypeFuture(PickFirst.new(items) do |type, arg|
if arg != nil
call.parent.replaceChild(call, newNode)
typer.verifier.scan(newNode, newNode)
typer.infer(newNode, expression != nil)
end
end)
Expand Down Expand Up @@ -675,12 +664,10 @@ class Typer < SimpleNodeVisitor
end

def visitScript(script, expression)
@verifier.scan(script, script)
scope = @scopes.addScope(script)
@types.addDefaultImports(scope)
scope.selfType = @types.getMainType(scope, script)
type = infer(script.body, false)
@verifier.scan(script, script)
type
end

Expand Down Expand Up @@ -731,7 +718,6 @@ class Typer < SimpleNodeVisitor
NodeList.new(node.position, nodes)
end
replacement = node.parent.replaceChild(node, replacement)
@verifier.scan(replacement, replacement)
infer(replacement, expression != nil)
end

Expand All @@ -745,7 +731,6 @@ class Typer < SimpleNodeVisitor
replacement = LocalAssignment.new(node.position, node.name, node.value)
end
replacement = node.parent.replaceChild(node, replacement)
@verifier.scan(replacement, replacement)
infer(replacement, expression != nil)
end

Expand Down Expand Up @@ -921,7 +906,6 @@ class Typer < SimpleNodeVisitor
else
new_node.setParent(nil)
parent.replaceChild(block, new_node)
typer.verifier.scan(parent, parent)
end
typer.infer(new_node)
end
Expand All @@ -934,20 +918,3 @@ class Typer < SimpleNodeVisitor
@types.getVoidType()
end
end

class AstVerifier < NodeScanner
def enterScript(node, arg)
raise IllegalArgumentException, "#{node.parent} -> #{node} " unless node.parent.nil?
true
end
def enterDefault(node, arg)
if node == arg
raise IllegalArgumentException, "#{node}" if node.parent.nil?
true
else
raise IllegalArgumentException, "#{node}.parent should be #{arg}, got #{node.parent}" unless node.parent == arg
scan(node, node)
false
end
end
end
11 changes: 11 additions & 0 deletions test.sh
@@ -0,0 +1,11 @@
#!/bin/bash
# For some reason the builtins have to be on the JVM classpath to load properly.
# This script runs rake with the right classpath
if [ ! -e javalib/mirah-builtins.jar ]; then
jruby -S rake bootstrap
fi
CLASSPATH=javalib/mirah-parser.jar:javalib/mirah-bootstrap.jar:javalib/mirah-builtins.jar
if [ $# = 0 ]; then
EXTRA_ARGS=test
fi
exec jruby -S rake "$@" $EXTRA_ARGS
6 changes: 0 additions & 6 deletions test/jvm/hash_test.rb
Expand Up @@ -14,11 +14,6 @@
# limitations under the License.

class HashTest < Test::Unit::TestCase
if true
def test_hashes
raise "Hashes not implemented"
end
else
def test_hashes
cls, = compile(<<-EOF)
def foo1
Expand Down Expand Up @@ -247,4 +242,3 @@ def test_bool_inequality
end
end
end
end

0 comments on commit 6223111

Please sign in to comment.