Skip to content

Commit

Permalink
start converting to implicit casting in block arg defs
Browse files Browse the repository at this point in the history
  • Loading branch information
baroquebobcat committed Aug 31, 2014
1 parent 6a814e6 commit 7a47048
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 38 deletions.
4 changes: 2 additions & 2 deletions examples/rosettacode/100-doors.mirah
Expand Up @@ -47,8 +47,8 @@ end

1.upto(100) do |multiplier|
index = 0
doors.each do |door|
Door(door).toggle if (index+1)%multiplier == 0
doors.each do |door: Door|
door.toggle if (index+1)%multiplier == 0
index += 1
end
end
Expand Down
2 changes: 1 addition & 1 deletion examples/sort_closure.mirah
Expand Up @@ -18,5 +18,5 @@ import java.util.ArrayList

list = ArrayList.new [9,5,2,6,8,5,0,3,6,1,8,3,6,4,7,5,0,8,5,6,7,2,3]
puts "unsorted: #{list}"
Collections.sort(list) {|a,b| Integer(a).compareTo(Integer(b))}
Collections.sort(list) {|a: Integer, b: Integer| a.compareTo(b)}
puts "sorted: #{list}"
4 changes: 2 additions & 2 deletions src/org/mirah/jvm/compiler/annotation_compiler.mirah
Expand Up @@ -153,8 +153,8 @@ class AnnotationCompiler < BaseCompiler
return
end
child = visitor.visitArray(name)
values.each do |n|
compileValue(child, nil, Node(n), type)
values.each do |n: Node|
compileValue(child, nil, n, type)
end
child.visitEnd
end
Expand Down
2 changes: 1 addition & 1 deletion src/org/mirah/jvm/compiler/base_compiler.mirah
Expand Up @@ -198,7 +198,7 @@ class BaseCompiler < SimpleNodeVisitor
end

def visitUnquote(node, arg)
node.nodes.each {|n| visit(Node(n), arg)}
node.nodes.each {|n: Node| visit(n, arg)}
end

def findType(name:String):JVMType
Expand Down
4 changes: 2 additions & 2 deletions src/org/mirah/jvm/compiler/bytecode.mirah
Expand Up @@ -73,8 +73,8 @@ class Bytecode < GeneratorAdapter

def arguments
args = LinkedList.new
@locals.values.each do |info|
if LocalInfo(info).index < @firstLocal
@locals.values.each do |info: LocalInfo|
if info.index < @firstLocal
args.add(info)
else
break
Expand Down
11 changes: 5 additions & 6 deletions src/org/mirah/jvm/compiler/class_cleanup.mirah
Expand Up @@ -64,8 +64,7 @@ class ClassCleanup < NodeScanner
@typer.infer(@cinit, false)
end
nodes = NodeList.new
@static_init_nodes.each do |n|
node = Node(n)
@static_init_nodes.each do |node: Node|
node.parent.removeChild(node)
node.setParent(nil) # TODO: ast bug
nodes.add(node)
Expand All @@ -85,13 +84,13 @@ class ClassCleanup < NodeScanner
NodeList.new(@init_nodes)
end
cleanup = ConstructorCleanup.new(@context)
@constructors.each do |n|
cleanup.clean(ConstructorDefinition(n), init)
@constructors.each do |n: ConstructorDefinition|
cleanup.clean(n, init)
end

declareFields
@methods.each do |m|
addOptionalMethods(MethodDefinition(m))
@methods.each do |m: MethodDefinition|
addOptionalMethods(m)
end
end

Expand Down
3 changes: 1 addition & 2 deletions src/org/mirah/jvm/compiler/closure_transformer.mirah
Expand Up @@ -652,8 +652,7 @@ end


def self.inject_nodes body: NodeList, nodes: List, typer: Typer
nodes.each do |arg|
node = Node(arg)
nodes.each do |node: Node|
Utils.insert_in_front body, node
typer.infer node
end
Expand Down
3 changes: 1 addition & 2 deletions src/org/mirah/jvm/compiler/method_compiler.mirah
Expand Up @@ -145,8 +145,7 @@ class MethodCompiler < BaseCompiler
@builder.dup
args = AsmType[0]
@builder.invokeConstructor(type.getAsmType, AsmMethod.new("<init>", AsmType.getType("V"), args))
@builder.arguments.each do |_arg|
arg = LocalInfo(_arg)
@builder.arguments.each do |arg: LocalInfo|
# Save any captured method arguments into the binding
if scope.isCaptured(arg.name)
@builder.dup
Expand Down
6 changes: 2 additions & 4 deletions src/org/mirah/jvm/compiler/script_cleanup.mirah
Expand Up @@ -61,8 +61,7 @@ class ScriptCleanup < NodeScanner
klass = getOrCreateClass(script)
unless @main_code.isEmpty
main = @parser.quote { def self.main(ARGV:String[]):void; end }
@main_code.each do |n|
node = Node(n)
@main_code.each do |node: Node|
node.parent.removeChild(node)
node.setParent(nil) # TODO: ast bug
main.body.add(node)
Expand All @@ -73,8 +72,7 @@ class ScriptCleanup < NodeScanner
end
unless @methods.isEmpty
nodes = @parser.quote { class << self; end }
@methods.each do |n|
mdef = Node(n)
@methods.each do |mdef: Node|
mdef.parent.removeChild(mdef)
mdef.setParent(nil) # TODO: ast bug
nodes.body.add(mdef)
Expand Down
12 changes: 6 additions & 6 deletions src/org/mirah/jvm/mirrors/base_type.mirah
Expand Up @@ -105,8 +105,8 @@ class BaseType implements MirrorType, DeclaredType, MethodListener
def notifyOfIncompatibleChange:void
@cached_supertypes = List(nil)
listeners = ArrayList.new(@compatibility_listeners)
listeners.each do |l|
Runnable(l).run()
listeners.each do |l: Runnable|
l.run()
end
methods = HashSet.new(@method_listeners.keySet)
methods.each do |n|
Expand Down Expand Up @@ -180,8 +180,8 @@ class BaseType implements MirrorType, DeclaredType, MethodListener
def getAllDeclaredMethods
@methods_loaded ||= load_methods
methods = ArrayList.new
@members.values.each do |list|
List(list).each do |m|
@members.values.each do |list: List|
list.each do |m|
methods.add(m)
end
end
Expand Down Expand Up @@ -224,8 +224,8 @@ class BaseType implements MirrorType, DeclaredType, MethodListener
def invalidateMethod(name:String)
listeners = Set(@method_listeners[name])
if listeners
HashSet.new(listeners).each do |l|
MethodListener(l).methodChanged(self, name)
HashSet.new(listeners).each do |l: MethodListener|
l.methodChanged(self, name)
end
end
end
Expand Down
14 changes: 6 additions & 8 deletions src/org/mirah/jvm/mirrors/bytecode_mirror.mirah
Expand Up @@ -135,8 +135,7 @@ class BytecodeMirror < AsyncMirror implements DeclaredMirrorType
# CLASS is the default retention policy http://docs.oracle.com/javase/7/docs/api/java/lang/annotation/RetentionPolicy.html#CLASS
return "CLASS" unless @annotations

@annotations.each do |n|
anno = AnnotationNode(n)
@annotations.each do |anno: AnnotationNode|
if "Ljava/lang/annotation/Retention;".equals(anno.desc)
# anno.values should be
# ["value", ["Ljava/lang/annotation/RetentionPolicy;", policy]]
Expand All @@ -149,12 +148,12 @@ class BytecodeMirror < AsyncMirror implements DeclaredMirrorType
attr_reader signature:String

def load_methods:boolean
@methods.each do |m|
addMethod(MethodNode(m))
@methods.each do |m: MethodNode|
addMethod(m)
end if @methods
@methods = nil
@innerClassNodes.each do |n|
addInnerClass(InnerClassNode(n))
@innerClassNodes.each do |n: InnerClassNode|
addInnerClass(n)
end
true
end
Expand Down Expand Up @@ -198,8 +197,7 @@ class BytecodeMirror < AsyncMirror implements DeclaredMirrorType
@methods_loaded ||= load_methods
members = getMembers(name)
if members
members.each do |m|
member = Member(m)
members.each do |member: Member|
if member.argumentTypes.equals(params)
return member
end
Expand Down
2 changes: 1 addition & 1 deletion src/org/mirah/jvm/mirrors/jvm_scope.mirah
Expand Up @@ -92,7 +92,7 @@ class JVMScope < SimpleScope
elsif @parent && @parent.hasLocal(name)
return true
else
return @children.any? {|child| JVMScope(child).hasLocal(name, false)}
return @children.any? {|child: JVMScope| child.hasLocal(name, false)}
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/org/mirah/jvm/mirrors/member.mirah
Expand Up @@ -135,7 +135,7 @@ class AsyncMember < Member
@futures = argumentTypes
@resolvedArguments = ArrayList.new(argumentTypes.size)
@returnType = returnType
argumentTypes.each {|a| setupArgumentListener(TypeFuture(a)) }
argumentTypes.each {|a: TypeFuture| setupArgumentListener(a) }
end

def argumentTypes
Expand Down

0 comments on commit 7a47048

Please sign in to comment.