Class: NCPP::Block
- Inherits:
-
Struct
- Object
- Struct
- NCPP::Block
- Defined in:
- lib/ncpp/types.rb
Instance Attribute Summary collapse
-
#argns ⇒ Object
Returns the value of attribute argns.
-
#ast ⇒ Object
Returns the value of attribute ast.
-
#interpreter ⇒ Object
Returns the value of attribute interpreter.
-
#name ⇒ Object
Returns the value of attribute name.
-
#subs ⇒ Object
Returns the value of attribute subs.
Instance Method Summary collapse
- #arg_names ⇒ Object
- #call(*args) ⇒ Object
- #eval(args) ⇒ Object
- #pure? ⇒ Boolean
-
#return_type ⇒ Object
end.
Instance Attribute Details
#argns ⇒ Object
Returns the value of attribute argns
5 6 7 |
# File 'lib/ncpp/types.rb', line 5 def argns @argns end |
#ast ⇒ Object
Returns the value of attribute ast
5 6 7 |
# File 'lib/ncpp/types.rb', line 5 def ast @ast end |
#interpreter ⇒ Object
Returns the value of attribute interpreter
5 6 7 |
# File 'lib/ncpp/types.rb', line 5 def interpreter @interpreter end |
#name ⇒ Object
Returns the value of attribute name
5 6 7 |
# File 'lib/ncpp/types.rb', line 5 def name @name end |
#subs ⇒ Object
Returns the value of attribute subs
5 6 7 |
# File 'lib/ncpp/types.rb', line 5 def subs @subs end |
Instance Method Details
#arg_names ⇒ Object
32 |
# File 'lib/ncpp/types.rb', line 32 def arg_names = argns |
#call(*args) ⇒ Object
18 |
# File 'lib/ncpp/types.rb', line 18 def call(*args) = eval(args) |
#eval(args) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/ncpp/types.rb', line 6 def eval(args) result = nil ast.each do |node| if subs.nil? result = interpreter.eval_expr(node, args.empty? || argns.nil? ? nil : Hash[argns.zip(args)]) else result = interpreter.eval_expr(node, args.empty? || argns.nil? ? subs : subs.merge(Hash[argns.zip(args)])) end end result end |
#pure? ⇒ Boolean
34 35 36 37 |
# File 'lib/ncpp/types.rb', line 34 def pure? @pure unless @pure.nil? @pure = !ast.any? { |n| interpreter.node_impure?(n, name) } end |
#return_type ⇒ Object
end
30 |
# File 'lib/ncpp/types.rb', line 30 def return_type = Object |