Class: Minjs::ECMA262::LexEnv
- Inherits:
-
Object
- Object
- Minjs::ECMA262::LexEnv
- Defined in:
- lib/minjs/ecma262/env.rb
Overview
class of Lexical Environment
Instance Attribute Summary collapse
-
#outer ⇒ Object
readonly
Returns the value of attribute outer.
-
#record ⇒ Object
Returns the value of attribute record.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
-
.new_declarative_env(e) ⇒ Object
NewDeclarativeEnvironment(E).
Instance Method Summary collapse
-
#debug ⇒ Object
debug.
-
#initialize(options = {}) ⇒ LexEnv
constructor
A new instance of LexEnv.
-
#new_declarative_env(outer = nil) ⇒ Object
NewDeclarativeEnvironment(E).
-
#new_object_env(object, outer = nil) ⇒ Object
NewObjectEnvironment(O, E).
Constructor Details
#initialize(options = {}) ⇒ LexEnv
Returns a new instance of LexEnv.
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/minjs/ecma262/env.rb', line 58 def initialize( = {}) @outer = [:outer] @type = ([:type] || :declarative) if [:record] @record = ObjectEnvRecord.new elsif [:type] == :declarative @record = DeclarativeEnvRecord.new elsif [:type] == :object or true @record = ObjectEnvRecord.new end end |
Instance Attribute Details
#outer ⇒ Object (readonly)
Returns the value of attribute outer.
55 56 57 |
# File 'lib/minjs/ecma262/env.rb', line 55 def outer @outer end |
#record ⇒ Object
Returns the value of attribute record.
54 55 56 |
# File 'lib/minjs/ecma262/env.rb', line 54 def record @record end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
56 57 58 |
# File 'lib/minjs/ecma262/env.rb', line 56 def type @type end |
Class Method Details
Instance Method Details
#debug ⇒ Object
debug
99 100 101 |
# File 'lib/minjs/ecma262/env.rb', line 99 def debug STDERR.puts @record.binding.keys.join(", ") end |
#new_declarative_env(outer = nil) ⇒ Object
NewDeclarativeEnvironment(E)
73 74 75 |
# File 'lib/minjs/ecma262/env.rb', line 73 def new_declarative_env(outer = nil) e = LexEnv.new(outer: (outer || self), type: :declarative) end |
#new_object_env(object, outer = nil) ⇒ Object
NewObjectEnvironment(O, E)
87 88 89 90 91 92 93 94 95 96 |
# File 'lib/minjs/ecma262/env.rb', line 87 def new_object_env(object, outer = nil)#TODO raise 'TODO' e = LexEnv.new(outer: (outer || self), type: :object) object.val.each do |k, v| if k.id_name? e.create_mutable_binding(k) e.set_mutable_binding(k, v) end end end |