Skip to content

Instantly share code, notes, and snippets.

@realjenius
Created November 24, 2011 17:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save realjenius/1391901 to your computer and use it in GitHub Desktop.
Save realjenius/1391901 to your computer and use it in GitHub Desktop.
AST Impls
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
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