Class: Pione::Lang::Message

Inherits:
Expr
  • Object
show all
Defined in:
lib/pione/lang/message.rb

Overview

Message represents method callers in PIONE language.

Instance Method Summary collapse

Methods inherited from Expr

inherited, pione_type, set_pione_type, #to_s

Methods included from Util::Positionable

#line_and_column, #pos, #set_source_position

Instance Method Details

#eval(env) ⇒ Object

Evaluate the application expression and returns application result.



19
20
21
22
23
24
25
26
27
28
# File 'lib/pione/lang/message.rb', line 19

def eval(env)
  # evaluate the receiver in the environment
  _receiver = receiver.eval(env)
  if _receiver.is_a?(Variable)
    _receiver = _receiver.eval(env)
  end

  # send a message to it
  _receiver.call_pione_method(env, name, arguments)
end

#eval!(env) ⇒ Object



30
31
32
# File 'lib/pione/lang/message.rb', line 30

def eval!(env)
  eval(env).eval!(env)
end

#pione_type(env) ⇒ Object

Return PIONE model type of the message result according to type interface.



10
11
12
13
14
15
16
# File 'lib/pione/lang/message.rb', line 10

def pione_type(env)
  if pione_method = receiver.pione_type(env).find_method(env, name, receiver, arguments)
    pione_method.get_output_type(env, receiver)
  else
    raise MethodNotFound.new(env, name.to_s, receiver, arguments)
  end
end

#textizeObject

Convert to text string.



35
36
37
38
# File 'lib/pione/lang/message.rb', line 35

def textize
  args = arguments.map {|arg| arg.textize}
  "#%s{name: %s, receiver: %s, arguments: %s}" % [Message, name, receiver.textize, args]
end