Class: Minjs::ECMA262::Prog

Inherits:
Base
  • Object
show all
Defined in:
lib/minjs/ecma262/base.rb

Overview

Class of ECMA262 Program

See Also:

Instance Attribute Summary collapse

Attributes inherited from Base

#parent

Instance Method Summary collapse

Methods inherited from Base

#add_remove_paren, #concat

Constructor Details

#initialize(var_env, source_elements) ⇒ Prog

Returns a new instance of Prog.



324
325
326
327
# File 'lib/minjs/ecma262/base.rb', line 324

def initialize(var_env, source_elements)
  @source_elements = source_elements
  @var_env = var_env
end

Instance Attribute Details

#exe_contextObject

Returns the value of attribute exe_context.



322
323
324
# File 'lib/minjs/ecma262/base.rb', line 322

def exe_context
  @exe_context
end

#source_elementsObject (readonly)

Returns the value of attribute source_elements.



320
321
322
# File 'lib/minjs/ecma262/base.rb', line 320

def source_elements
  @source_elements
end

#var_envObject (readonly)

Returns the value of attribute var_env.



321
322
323
# File 'lib/minjs/ecma262/base.rb', line 321

def var_env
  @var_env
end

Instance Method Details

#==(obj) ⇒ Object

compare object



351
352
353
# File 'lib/minjs/ecma262/base.rb', line 351

def ==(obj)
  self.class == obj.class and self.source_elements == obj.source_elements
end

#deep_dupObject

duplicate object

See Also:



331
332
333
# File 'lib/minjs/ecma262/base.rb', line 331

def deep_dup
  self.class.new(var_env, source_elements.deep_dup)
end

#replace(from, to) ⇒ Object

Replaces children object

See Also:



337
338
339
340
341
# File 'lib/minjs/ecma262/base.rb', line 337

def replace(from, to)
  if from == @source_elements
    @source_elements = to
  end
end

#to_js(options = {}) ⇒ Object

Returns a ECMAScript string containg the representation of element.

See Also:



357
358
359
# File 'lib/minjs/ecma262/base.rb', line 357

def to_js(options = {})
  concat options, @source_elements
end

#traverse(parent) {|parent, _self| ... } ⇒ Object

Traverses this children and itself with given block.

Yields:

Yield Parameters:

See Also:



345
346
347
348
# File 'lib/minjs/ecma262/base.rb', line 345

def traverse(parent, &block)
  @source_elements.traverse(self, &block)
  yield parent, self
end