Class: EleetScript::NamespaceContext

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

Instance Attribute Summary collapse

Attributes inherited from BaseContext

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

Instance Method Summary collapse

Methods inherited from BaseContext

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

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

#global_varsObject (readonly)

Returns the value of attribute global_vars.



151
152
153
# File 'lib/lang/runtime/context.rb', line 151

def global_vars
  @global_vars
end

Instance Method Details

#add_namespace(name, value) ⇒ Object



163
164
165
# File 'lib/lang/runtime/context.rb', line 163

def add_namespace(name, value)
  @namespaces[name] = value
end

#es_nilObject



175
176
177
# File 'lib/lang/runtime/context.rb', line 175

def es_nil
  @root_ns["nil"]
end

#namespace(name) ⇒ Object



155
156
157
158
159
160
161
# File 'lib/lang/runtime/context.rb', line 155

def namespace(name)
  ns = @namespaces[name]
  if ns.nil? && @parent_context
    ns = @parent_context.namespaces[ns]
  end
  ns
end

#namespace_contextObject



183
184
185
# File 'lib/lang/runtime/context.rb', line 183

def namespace_context
  self
end

#new_class_context(current_self, current_class = nil) ⇒ Object



187
188
189
190
191
# File 'lib/lang/runtime/context.rb', line 187

def new_class_context(current_self, current_class = nil)
  ctx = ClassContext.new(current_self, current_class)
  ctx.parent_context = self
  ctx
end

#new_namespace_contextObject



193
194
195
196
197
198
199
# File 'lib/lang/runtime/context.rb', line 193

def new_namespace_context
  ctx = NamespaceContext.new(nil, nil, @root_ns)
  ctx.current_self = @root_ns["Object"].new(ctx)
  ctx.current_class = current_self.runtime_class
  ctx.parent_context = self
  ctx
end

#root_nsObject



179
180
181
# File 'lib/lang/runtime/context.rb', line 179

def root_ns
  @root_ns
end