Class: Skeem::Primitive::PrimitiveProcedure
- Inherits:
-
Object
- Object
- Skeem::Primitive::PrimitiveProcedure
- Defined in:
- lib/skeem/primitive/primitive_procedure.rb
Instance Attribute Summary collapse
-
#arity ⇒ Object
readonly
Returns the value of attribute arity.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
Instance Method Summary collapse
-
#bound!(_frame) ⇒ Object
Notification that this procedure is bound to a variable.
-
#call(aRuntime, theActuals) ⇒ Object
Arguments are positional in a primitive procedure.
- #callable? ⇒ Boolean
-
#evaluate(_runtime) ⇒ PrimitiveProcedure
This method should be invoked when the procedure isn't explicitly called (with arguments).
-
#initialize(anId, anArity, aRubyLambda) ⇒ PrimitiveProcedure
constructor
param [anArity] Arity of the lambda code (ignoring the runtime object).
- #procedure? ⇒ Boolean
- #skm_equal?(other) ⇒ Boolean
Constructor Details
#initialize(anId, anArity, aRubyLambda) ⇒ PrimitiveProcedure
param [anArity] Arity of the lambda code (ignoring the runtime object)
11 12 13 14 15 |
# File 'lib/skeem/primitive/primitive_procedure.rb', line 11 def initialize(anId, anArity, aRubyLambda) @identifier = anId.kind_of?(String) ? SkmIdentifier.create(anId) : anId @code = code_validated(aRubyLambda) @arity = arity_validated(anArity) end |
Instance Attribute Details
#arity ⇒ Object (readonly)
Returns the value of attribute arity.
7 8 9 |
# File 'lib/skeem/primitive/primitive_procedure.rb', line 7 def arity @arity end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
8 9 10 |
# File 'lib/skeem/primitive/primitive_procedure.rb', line 8 def code @code end |
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
6 7 8 |
# File 'lib/skeem/primitive/primitive_procedure.rb', line 6 def identifier @identifier end |
Instance Method Details
#bound!(_frame) ⇒ Object
Notification that this procedure is bound to a variable
55 56 57 |
# File 'lib/skeem/primitive/primitive_procedure.rb', line 55 def bound!(_frame) # Do nothing end |
#call(aRuntime, theActuals) ⇒ Object
Arguments are positional in a primitive procedure.
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/skeem/primitive/primitive_procedure.rb', line 36 def call(aRuntime, theActuals) actuals = theActuals # $stderr.puts "--- Start of procedure #{identifier}" # actuals.each { |actual| $stderr.puts ' Actual: ' + actual.inspect } check_actual_count(actuals) # TODO: check that next line became useless # aProcedureCall.operands_consumed = true result = do_call(aRuntime, actuals) # $stderr.puts " Result: #{result.inspect}" # $stderr.puts "--- End of procedure #{identifier}" result end |
#callable? ⇒ Boolean
17 18 19 |
# File 'lib/skeem/primitive/primitive_procedure.rb', line 17 def callable? true end |
#evaluate(_runtime) ⇒ PrimitiveProcedure
This method should be invoked when the procedure isn't explicitly called (with arguments). In this case, the name of procedure just returns the procedure object itself.
30 31 32 |
# File 'lib/skeem/primitive/primitive_procedure.rb', line 30 def evaluate(_runtime) self end |
#procedure? ⇒ Boolean
21 22 23 |
# File 'lib/skeem/primitive/primitive_procedure.rb', line 21 def procedure? true end |
#skm_equal?(other) ⇒ Boolean
49 50 51 |
# File 'lib/skeem/primitive/primitive_procedure.rb', line 49 def skm_equal?(other) equal?(other) end |