Class: Minjs::ECMA262::EnvRecord

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

Overview

class of Environment Record

See Also:

Direct Known Subclasses

DeclarativeEnvRecord, ObjectEnvRecord

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ EnvRecord

Returns a new instance of EnvRecord.



11
12
13
14
# File 'lib/minjs/ecma262/env.rb', line 11

def initialize(options = {})
  @binding = {}
  @options = {}
end

Instance Attribute Details

#bindingObject (readonly)

Returns the value of attribute binding.



8
9
10
# File 'lib/minjs/ecma262/env.rb', line 8

def binding
  @binding
end

#optionsObject (readonly)

Returns the value of attribute options.



9
10
11
# File 'lib/minjs/ecma262/env.rb', line 9

def options
  @options
end

Instance Method Details

#create_mutable_binding(n, d, options = {}) ⇒ Object

CreateMutableBinding(N, D)

See Also:



19
20
21
22
23
24
# File 'lib/minjs/ecma262/env.rb', line 19

def create_mutable_binding(n, d, options = {})
  if n.kind_of? IdentifierName
    n = n.val
  end
  @binding[n] = {:value => nil}
end

#set_mutable_binding(n, v, s, options = {}) ⇒ Object

SetMutableBinding(N, V, S)

See Also:



29
30
31
32
33
34
35
# File 'lib/minjs/ecma262/env.rb', line 29

def set_mutable_binding(n, v, s, options = {})
  if n.kind_of? IdentifierName
    n = n.val
  end
  @binding[n][:value] = v
  @binding[n].merge!(options || {})
end