Class: Minjs::ECMA262::ExpLogicalAnd

Inherits:
Expression show all
Includes:
BinaryOperation
Defined in:
lib/minjs/ecma262/expression.rb

Overview

Class of the Bitwise Logical And operator expression element.

See Also:

Instance Attribute Summary

Attributes included from BinaryOperation

#val, #val2

Attributes inherited from Base

#parent

Instance Method Summary collapse

Methods included from BinaryOperation

#==, #add_paren, #deep_dup, #remove_paren, #replace, #to_js, #traverse

Methods inherited from Expression

#left_hand_side_exp?, #reduce, #side_effect?

Methods inherited from Base

#==, #add_remove_paren, #concat, #deep_dup, #replace, #to_js, #traverse

Constructor Details

#initialize(val, val2) ⇒ ExpLogicalAnd

Returns a new instance of ExpLogicalAnd.



1791
1792
1793
1794
# File 'lib/minjs/ecma262/expression.rb', line 1791

def initialize(val, val2)
  @val = val
  @val2 = val2
end

Instance Method Details

#ecma262_typeofSymbol

return results of ‘typeof’ operator.

Returns:

  • (Symbol)

    typeof val if typeof val equals to val2



1827
1828
1829
1830
1831
1832
1833
1834
# File 'lib/minjs/ecma262/expression.rb', line 1827

def ecma262_typeof
  if @val.respond_to? :ecma262_typeof and @val2.respond_to? :ecma262_typeof
     if @val.ecma262_typeof == @val2.ecma262_typeof
       return @val.ecma262_typeof
     end
  end
  nil
end

#priorityFixnum

Returns expression priority.

Returns:

  • (Fixnum)

    expression priority



1802
1803
1804
# File 'lib/minjs/ecma262/expression.rb', line 1802

def priority
  PRIORITY_LOGICAL_AND
end

#symObject

symbol of expression



1797
1798
1799
# File 'lib/minjs/ecma262/expression.rb', line 1797

def sym
  "&&"
end

#to_ecma262_booleanBoolean

Returns results of ToBoolean()

Returns true or false if trivial, otherwise nil.

Returns:

See Also:



1814
1815
1816
1817
1818
1819
1820
1821
1822
# File 'lib/minjs/ecma262/expression.rb', line 1814

def to_ecma262_boolean
  return nil if !(@val.respond_to? :to_ecma262_boolean)
  return nil if @val.to_ecma262_boolean == nil
  return false if @val.to_ecma262_boolean == false
  return nil if !(@val2.respond_to? :to_ecma262_boolean)
  return nil if @val2.to_ecma262_boolean == nil
  return false if @val2.to_ecma262_boolean == false
  true
end