-
-
Save realjenius/1391901 to your computer and use it in GitHub Desktop.
AST Impls
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 | |
class LocalAssignment | |
def infer(typer) | |
type = @value.infer(typer) #value is the "functional" call. | |
if(!type) | |
typer.defer(self) | |
end | |
return type | |
end | |
end | |
class FunctionalCall | |
def infer(typer) | |
@parameters.each { |param| param.infer(typer) } | |
if #all parameters inferred, and method with params and scope is known | |
return typer.method_type(@method_name, method_scope, @parameters) | |
else | |
typer.defer(self) | |
return nil | |
end | |
end | |
end | |
class FixNum | |
def infer(typer) | |
return typer.fixnum_type(@literal) #literal is '5' | |
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 | |
class LocalAssignment | |
def infer(typer) | |
type = @value.infer(typer) #value is the "functional" call. | |
if(!type) | |
typer.defer(self) | |
end | |
return type | |
end | |
end | |
class FunctionalCall | |
def infer(typer) | |
@parameters.each { |param| param.infer(typer) } | |
if #all parameters inferred, and method with params and scope is known | |
return typer.method_type(@method_name, method_scope, @parameters) | |
else | |
typer.defer(self) | |
return nil | |
end | |
end | |
end | |
class FixNum | |
def infer(typer) | |
return typer.fixnum_type(@literal) #literal is '5' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment