Sha256: 31792c9638202a7a1bbcb7fbdcce7a206b1bfa907d0c0b8745c5c3ce1a97b0c9
Contents?: true
Size: 1.57 KB
Versions: 1
Compression:
Stored size: 1.57 KB
Contents
module Duby::AST class LocalDeclaration < Node include Named include Typed include Scoped def initialize(parent, line_number, name, &block) super(parent, line_number, &block) @name = name @type = children[0] end def infer(typer) unless resolved? resolved! @inferred_type = typer.known_types[type] || type if @inferred_type resolved! typer.learn_local_type(scope, name, @inferred_type) else typer.defer(self) end end @inferred_type end end class LocalAssignment < Node include Named include Valued include Scoped def initialize(parent, line_number, name, &block) super(parent, line_number, children, &block) @value = children[0] @name = name end def to_s "LocalAssignment(name = #{name}, scope = #{scope})" end def infer(typer) unless @inferred_type @inferred_type = typer.learn_local_type(scope, name, typer.infer(value)) @inferred_type ? resolved! : typer.defer(self) end @inferred_type end end class Local < Node include Named include Scoped def initialize(parent, line_number, name) super(parent, line_number, []) @name = name end def to_s "Local(name = #{name}, scope = #{scope})" end def infer(typer) unless @inferred_type @inferred_type = typer.local_type(scope, name) @inferred_type ? resolved! : typer.defer(self) end @inferred_type end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
duby-0.0.1 | lib/duby/ast/local.rb |