class Klam::Compiler
Public Class Methods
new(environment)
click to toggle source
# File lib/klam/compiler.rb, line 23 def initialize(environment) @environment = environment @constant_generator = Klam::ConstantGenerator.new @variable_generator = Klam::VariableGenerator.new @ruby_interop_syntax_enabled = false end
Public Instance Methods
compile(kl)
click to toggle source
# File lib/klam/compiler.rb, line 30 def compile(kl) stages = [ :kl_to_internal_representation, :strip_type_declarations, :make_abstractions_variadic, :convert_lexical_variables, :convert_freezes_to_lambdas, :simplify_boolean_operations, :convert_partial_applications_to_lambdas, :curry_abstraction_applications, :make_abstractions_monadic, :constantize_constructed_constants, :convert_self_tail_calls_to_loops, :emit_ruby ] apply_stages(stages, kl) end
disable_ruby_interop_syntax!()
click to toggle source
# File lib/klam/compiler.rb, line 52 def disable_ruby_interop_syntax! @ruby_interop_syntax_enabled = false end
enable_ruby_interop_syntax!()
click to toggle source
# File lib/klam/compiler.rb, line 48 def enable_ruby_interop_syntax! @ruby_interop_syntax_enabled = true end
ruby_interop_syntax_enabled?()
click to toggle source
# File lib/klam/compiler.rb, line 56 def ruby_interop_syntax_enabled? @ruby_interop_syntax_enabled end
Private Instance Methods
apply_stages(stages, kl)
click to toggle source
# File lib/klam/compiler.rb, line 62 def apply_stages(stages, kl) stages.reduce(kl) do |exp, stage| send(stage, exp) end end
arity(sym)
click to toggle source
# File lib/klam/compiler.rb, line 68 def arity(sym) @environment.__arity(sym) end
fresh_constant()
click to toggle source
# File lib/klam/compiler.rb, line 72 def fresh_constant @constant_generator.next end
fresh_variable()
click to toggle source
# File lib/klam/compiler.rb, line 76 def fresh_variable @variable_generator.next end