Class: JSE::Ast::SymbolNode

Inherits:
AstNode
  • Object
show all
Defined in:
lib/jse/ast/nodes.rb

Instance Attribute Summary collapse

Attributes inherited from AstNode

#env

Instance Method Summary collapse

Constructor Details

#initialize(name, env) ⇒ SymbolNode

Returns a new instance of SymbolNode.



21
22
23
24
# File 'lib/jse/ast/nodes.rb', line 21

def initialize(name, env)
  super(env)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



26
27
28
# File 'lib/jse/ast/nodes.rb', line 26

def name
  @name
end

Instance Method Details

#apply(call_env) ⇒ Object

Raises:

  • (NameError)


28
29
30
31
32
# File 'lib/jse/ast/nodes.rb', line 28

def apply(call_env)
  val = call_env.resolve(@name)
  raise NameError, "Symbol '#{@name}' not found" if val.nil?
  val
end

#to_jsonObject



34
35
36
# File 'lib/jse/ast/nodes.rb', line 34

def to_json
  @name
end