Module: Kl::Compiler
- Defined in:
- lib/kl/compiler.rb
Constant Summary collapse
- PRIMITIVE_ARITIES =
The K Lambda primitives are all Ruby functions and never use trampolines. They are all regarded as System Functions and therefore are not allowed to be redefined by the user at run time. Therefore, if all of their arguments have been supplied, it is safe to directly invoke them rather than going incurring the overhead of using __apply. This table holds the arities of the primitives and is used to determine whether direct invocation is possible. Kl::Primitives::Extensions is purposely omitted from this list so that it may be overridden by Shen.
{}
Class Method Summary collapse
Class Method Details
.compile(form, lexical_vars, in_tail_pos) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/kl/compiler.rb', line 26 def compile(form, lexical_vars, in_tail_pos) case form when Symbol if lexical_vars.has_key?(form) lexical_vars[form] else escape_symbol(form) end when String # Emit non-interpolating strings "'" + escape_string(form) + "'" when Kl::Cons compile_form(form, lexical_vars, in_tail_pos) when Kl::EmptyList "::Kl::EmptyList.instance" when Numeric form.to_s when true 'true' when false 'false' else raise Kl::InternalError, "unexpected form: #{form}" end end |