Class: Skeem::SkmProcedureExec

Inherits:
Object
  • Object
show all
Defined in:
lib/skeem/skm_procedure_exec.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(aLambda) ⇒ SkmProcedureExec

Returns a new instance of SkmProcedureExec.



13
14
15
16
17
18
19
# File 'lib/skeem/skm_procedure_exec.rb', line 13

def initialize(aLambda)
  @definition = aLambda
  @frame = SkmFrame.new(definition.environment)
  # $stderr.puts "New SkmProcedureExec"
  # $stderr.puts "  frame = #{frame.object_id.to_s(16)}"
  # $stderr.puts "  Lambda = #{aLambda.object_id.to_s(16)}"
end

Instance Attribute Details

#definitionSkmLambda (readonly)

Returns:



11
12
13
# File 'lib/skeem/skm_procedure_exec.rb', line 11

def definition
  @definition
end

#frameSkmFrame (readonly)

Returns:



8
9
10
# File 'lib/skeem/skm_procedure_exec.rb', line 8

def frame
  @frame
end

Instance Method Details

#run!(aRuntime, theActuals) ⇒ Object

Parameters:



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/skeem/skm_procedure_exec.rb', line 22

def run!(aRuntime, theActuals)
  runtime = aRuntime
  runtime.push(frame)
  definition.bind_locals(runtime, theActuals)
  evaluate_defs(aRuntime)
  # $stderr.puts "Locals"
  # frame.bindings.each_pair do |key, elem|
    # $stderr.print key.to_s + ' => '
    # $stderr.puts  elem.kind_of?(SkmLambda) ? "  Lambda = #{elem.object_id.to_s(16)}" : elem.inspect
  # end
  result = definition.evaluate_sequence(runtime)
  runtime.pop
  # $stderr.puts "Lambda result: #{result.object_id.to_s(16)}" if result.kind_of?(SkmLambda)

  result
end