Class: NCPP::Block

Inherits:
Struct
  • Object
show all
Defined in:
lib/ncpp/types.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#argnsObject

Returns the value of attribute argns

Returns:

  • (Object)

    the current value of argns



5
6
7
# File 'lib/ncpp/types.rb', line 5

def argns
  @argns
end

#astObject

Returns the value of attribute ast

Returns:

  • (Object)

    the current value of ast



5
6
7
# File 'lib/ncpp/types.rb', line 5

def ast
  @ast
end

#interpreterObject

Returns the value of attribute interpreter

Returns:

  • (Object)

    the current value of interpreter



5
6
7
# File 'lib/ncpp/types.rb', line 5

def interpreter
  @interpreter
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



5
6
7
# File 'lib/ncpp/types.rb', line 5

def name
  @name
end

#subsObject

Returns the value of attribute subs

Returns:

  • (Object)

    the current value of subs



5
6
7
# File 'lib/ncpp/types.rb', line 5

def subs
  @subs
end

Instance Method Details

#arg_namesObject



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

Returns:



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_typeObject

end



30
# File 'lib/ncpp/types.rb', line 30

def return_type = Object