Class: EleetScript::ClassContext

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

Instance Attribute Summary

Attributes inherited from BaseContext

#constants, #current_class, #current_self, #global_vars, #local_vars, #namespaces

Instance Method Summary collapse

Methods inherited from BaseContext

#[], #[]=, #es_nil, init_with, #initialize, #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 Method Details

#class_varsObject



217
218
219
# File 'lib/lang/runtime/context.rb', line 217

def class_vars
  @current_class.class_vars
end

#instance_varsObject



221
222
223
# File 'lib/lang/runtime/context.rb', line 221

def instance_vars
  @parent_context ? @parent_context.instance_vars : {}
end

#namespace_contextObject



225
226
227
# File 'lib/lang/runtime/context.rb', line 225

def namespace_context
  @parent_context.namespace_context
end

#new_instance_context(instance_self, namespace) ⇒ Object



229
230
231
232
233
# File 'lib/lang/runtime/context.rb', line 229

def new_instance_context(instance_self, namespace)
  ctx = ClassInstanceContext.new(instance_self, current_class, namespace)
  ctx.parent_context = self
  ctx
end

#new_method_context(name, lambda_context = nil) ⇒ Object



235
236
237
238
239
# File 'lib/lang/runtime/context.rb', line 235

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