Class: PLang::VM::PLambda

Inherits:
Proc
  • Object
show all
Defined in:
lib/vm/plambda.rb

Instance Method Summary collapse

Instance Method Details

#_call?(params, form) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/vm/plambda.rb', line 9

def _call?(params, form)
  if form.length == params.length
    form.each_with_index do |f, i|
      if f
        case f.type
          when :integer, :decimal, :char, :string
            if f.type == params[i].id
              unless f.value == params[i].params[0]
                return false
              end
            end
          when :object
            unless f.id.value == params[i].id
              return false
            else
              unless _call?(params[i].params, f.params)
                return false
              end
            end
        end
      end
    end
    return true
  else
    return false
  end
end

#call?(params) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/vm/plambda.rb', line 5

def call?(params)
  _call?(params, @form||[])
end

#formObject



37
38
39
# File 'lib/vm/plambda.rb', line 37

def form
  @form ||= []
end