This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MethodDefinition | |
def infer(typer) | |
forced_type = @return_type | |
inferred_type = @body.infer(typer) | |
actual_type = if forced_type.nil? | |
inferred_type | |
else | |
forced_type | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// With: | |
public class SomeClass extends java.lang.Object { | |
public java.util.Map singleton_map(java.lang.String a, java.lang.String b) { | |
java.util.HashMap map = new java.util.HashMap(); | |
map.put(a, b); | |
return map; | |
} | |
} | |
// Without: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Map | |
import java.util.HashMap | |
class SomeClass | |
def singleton_map(a:string, b:string):Map | |
map = HashMap.new | |
map.put(a,b) | |
return map | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LocalDeclaration | |
def infer(typer) | |
type = @type_node.infer(typer) #type_node is the local assignment | |
if(!type) | |
typer.defer(self) | |
end | |
return type | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Typer | |
def resolve | |
old_len = @deferred_nodes.length | |
while true | |
@deferred_nodes.each do |node| | |
type = infer(node) | |
if type != nil | |
@deferred_nodes.remove(node) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Typer | |
def defer(node) | |
@deferred_nodes << node | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Typer | |
def infer(node) | |
node.infer(self) | |
# error handling business | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typer = Typer.new | |
asts.each { |ast| typer.infer(ast) } | |
typer.resolve |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def method_a() | |
return method_b(5) + method_b(6) | |
end | |
def method_b(x:int) | |
return x * -1 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myMap = new HashMap<String,String>(); |
NewerOlder