Class: Nydp::Builtin::TypeOf

Inherits:
Object
  • Object
show all
Defined in:
lib/nydp/builtin/type_of.rb

Instance Method Summary collapse

Constructor Details

#initialize(ns) ⇒ TypeOf

Returns a new instance of TypeOf.



2
3
4
# File 'lib/nydp/builtin/type_of.rb', line 2

def initialize ns
  @ns = ns
end

Instance Method Details

#invoke(vm, args) ⇒ Object



6
7
8
9
10
# File 'lib/nydp/builtin/type_of.rb', line 6

def invoke vm, args
  arg = args.car
  type = Nydp::Symbol.mk(arg.nydp_type.to_sym, @ns) if arg.respond_to?(:nydp_type)
  vm.push_arg(type || Nydp.NIL)
end