Class: Nydp::Builtin::HashSlice

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, #name, #nydp_type, #to_s

Instance Method Details

#builtin_invoke(vm, args) ⇒ Object



73
74
75
76
77
78
79
80
# File 'lib/nydp/builtin/hash.rb', line 73

def builtin_invoke vm, args
  old   = args.car
  h     = old.class.new
  slice = args.cdr.car
  slice = slice.map { |k| n2r k } unless old.is_a? Nydp::Hash
  slice.each { |k| h[k] = old[k] if old.key?(k) }
  vm.push_arg h
end