Class: EleetScript::ClassInstanceContext

Inherits:
BaseContext show all
Defined in:
lib/lang/runtime/context.rb

Instance Attribute Summary collapse

Attributes inherited from BaseContext

#constants, #current_self, #global_vars, #namespaces

Instance Method Summary collapse

Methods inherited from BaseContext

#[]=, #class_vars, #es_nil, init_with, #initialize, #instance_vars, #local_constant, #local_var, #method_missing, #respond_to_missing?, #root_ns

Constructor Details

This class inherits a constructor from EleetScript::BaseContext

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class EleetScript::BaseContext

Instance Attribute Details

#ns_contextObject

Returns the value of attribute ns_context.



243
244
245
# File 'lib/lang/runtime/context.rb', line 243

def ns_context
  @ns_context
end

Instance Method Details

#[](key) ⇒ Object



254
255
256
257
258
259
260
261
# File 'lib/lang/runtime/context.rb', line 254

def [](key)
  value = ns_context[key]
  if value == es_nil
    super
  else
    value
  end
end

#current_classObject



246
247
248
# File 'lib/lang/runtime/context.rb', line 246

def current_class
  @parent_context.current_class
end

#local_varsObject



250
251
252
# File 'lib/lang/runtime/context.rb', line 250

def local_vars
  {}
end

#namespace_contextObject



263
264
265
# File 'lib/lang/runtime/context.rb', line 263

def namespace_context
  ns_context
end

#new_method_context(name, lambda_context = nil) ⇒ Object



267
268
269
270
271
# File 'lib/lang/runtime/context.rb', line 267

def new_method_context(name, lambda_context = nil)
  MethodContext.new(current_self, current_class, name, lambda_context).tap do |ctx|
    ctx.parent_context = self
  end
end