Module: Klam::CompilationStages::KlToInternalRepresentation

Includes:
Klam::Converters::List, Primitives::Lists
Included in:
Klam::Compiler
Defined in:
lib/klam/compilation_stages/kl_to_internal_representation.rb

Overview

Kl to Internal Represenation

To simplify coding and improve performance, the compiler uses arrays rather than Kl lists to represent nested s-expressions. This stage performs the conversion.

Constant Summary

Constants included from Primitives::Lists

Primitives::Lists::EMPTY_LIST

Instance Method Summary collapse

Methods included from Klam::Converters::List

#arrayToList, #listToArray

Methods included from Primitives::Lists

#cons, #cons?, #hd, #tl

Instance Method Details

#kl_to_internal_representation(kl) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/klam/compilation_stages/kl_to_internal_representation.rb', line 12

def kl_to_internal_representation(kl)
  if cons?(kl) || kl == Klam::Primitives::Lists::EMPTY_LIST
    listToArray(kl)
  else
    kl
  end
end