Class: NativeFn

Inherits:
DataType show all
Defined in:
lib/sdx/vm/datatypes.rb

Instance Attribute Summary

Attributes inherited from DataType

#fields, #internal

Instance Method Summary collapse

Constructor Details

#initialize(arity, val) ⇒ NativeFn

Returns a new instance of NativeFn.



34
35
36
37
38
39
40
41
42
43
# File 'lib/sdx/vm/datatypes.rb', line 34

def initialize(arity, val)
    @internal = val
    @fields = {
        "__call" => (NativeFnInternal.new (lambda do |args, scope|
            args.reverse!
            @internal.call *args
        end)),
        "__arity" => (Int.new arity)
    }
end