Class: Nydp::Builtin::HashKeyPresent

Inherits:
Object
  • Object
show all
Includes:
Base, Helper, Singleton
Defined in:
lib/nydp/builtin/hash.rb

Instance Method Summary collapse

Methods included from Helper

#cons, #list, #literal?, #pair?, #sig, #sym, #sym?

Methods included from Converter

#n2r, #r2n

Methods included from Base

#builtin_invoke_1, #builtin_invoke_2, #builtin_invoke_3, #builtin_invoke_4, #handle_error, #inspect, #invoke, #invoke_1, #invoke_2, #invoke_3, #invoke_4, #nydp_type, #to_s

Instance Method Details

#builtin_invoke(vm, args) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/nydp/builtin/hash.rb', line 45

def builtin_invoke vm, args
  hash = args.car
  key  = args.cdr.car
  truth = case hash
          when Nydp::Hash
            hash.key? key
          else
            hash.key? n2r key
          end
  vm.push_arg(truth ? Nydp::T : Nydp::NIL)
end

#nameObject



56
# File 'lib/nydp/builtin/hash.rb', line 56

def name ; "hash-key?" ; end