Class: NScript::ExistenceNode

Inherits:
Node
  • Object
show all
Defined in:
lib/nscript/parser/nodes.rb

Constant Summary

Constants inherited from Node

Node::TAB

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#children, children, #compile, #compile_closure, #contains?, #idt, statement, #statement?, statement_only, #statement_only?, top_sensitive, #top_sensitive?, #unwrap, #write

Constructor Details

#initialize(expression) ⇒ ExistenceNode

Returns a new instance of ExistenceNode.



827
828
829
# File 'lib/nscript/parser/nodes.rb', line 827

def initialize(expression)
  @expression = expression
end

Class Method Details

.compile_test(o, variable) ⇒ Object



821
822
823
824
825
# File 'lib/nscript/parser/nodes.rb', line 821

def self.compile_test(o, variable)
  first, second = variable, variable
  first, second = *variable.compile_reference(o) if variable.is_a?(CallNode)
  "(typeof #{first.compile(o)} !== \"undefined\" && #{second.compile(o)} !== null)"
end

Instance Method Details

#compile_node(o) ⇒ Object



831
832
833
# File 'lib/nscript/parser/nodes.rb', line 831

def compile_node(o)
  write(ExistenceNode.compile_test(o, @expression))
end