Class: Sol::CallNode

Inherits:
Struct
  • Object
show all
Defined in:
lib/sol/nodes.rb,
lib/sol/interpreter.rb

Overview

Node of a method call or local variable access, can take any of these forms:

method # this form can also be a local variable
method(argument1, argument2)
receiver.method
receiver.method(argument1, argument2)

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#argumentsObject

Returns the value of attribute arguments

Returns:

  • (Object)

    the current value of arguments



61
62
63
# File 'lib/sol/nodes.rb', line 61

def arguments
  @arguments
end

#methodObject

Returns the value of attribute method

Returns:

  • (Object)

    the current value of method



61
62
63
# File 'lib/sol/nodes.rb', line 61

def method
  @method
end

#receiverObject

Returns the value of attribute receiver

Returns:

  • (Object)

    the current value of receiver



61
62
63
# File 'lib/sol/nodes.rb', line 61

def receiver
  @receiver
end

Instance Method Details

#eval(context) ⇒ Object



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/sol/interpreter.rb', line 97

def eval(context)

	if receiver.nil? && arguments.empty? && RuntimeModel::Runtime.locals[method]

		return context::Runtime.locals[method]

	else

		if receiver

			value = receiver.eval(context)

		else

			value = RuntimeModel::Runtime.current_self # I think this works

		end

		eval_arguments = arguments.map do |arg| 

			arg.eval(context) 

		end

		value.call(method, eval_arguments)

	end

end