Class: RVM::Interpreter::SetClassFunction

Inherits:
Element
  • Object
show all
Defined in:
lib/rvm/interpreter.rb

Overview

This sets a funciton on a Class (to be included in its objects)

To define class functions use ObjectContext and define the function normaly, nifty isn’t it?

This object may be subject to removal or change, don’t use it yet.


TODO: Work this over.

Instance Attribute Summary

Attributes inherited from Element

#pos

Instance Method Summary collapse

Constructor Details

#initialize(obj, name, function, pos = nil) ⇒ SetClassFunction

Returns a new instance of SetClassFunction.



148
149
150
151
152
153
# File 'lib/rvm/interpreter.rb', line 148

def initialize obj, name, function, pos = nil
  super(pos)
  @object = obj
  @name = name
  @function = function
end

Instance Method Details

#execute(env) ⇒ Object



155
156
157
158
# File 'lib/rvm/interpreter.rb', line 155

def execute env
  @object.object_functions[@name.execute(env)] = @function
  @function
end

#optimizeObject



160
161
162
163
164
# File 'lib/rvm/interpreter.rb', line 160

def optimize
  @object = @object.optimize
  @function = @function.optimize
  super
end