Class: Minjs::ECMA262::ExpLogicalOr

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

Overview

Class of the Bitwise Logical Or 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) ⇒ ExpLogicalOr

Returns a new instance of ExpLogicalOr.



1841
1842
1843
1844
# File 'lib/minjs/ecma262/expression.rb', line 1841

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



1877
1878
1879
1880
1881
1882
1883
1884
# File 'lib/minjs/ecma262/expression.rb', line 1877

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



1852
1853
1854
# File 'lib/minjs/ecma262/expression.rb', line 1852

def priority
  PRIORITY_LOGICAL_OR
end

#symObject

symbol of expression



1847
1848
1849
# File 'lib/minjs/ecma262/expression.rb', line 1847

def sym
  "||"
end

#to_ecma262_booleanBoolean

Returns results of ToBoolean()

Returns true or false if trivial, otherwise nil.

Returns:

See Also:



1864
1865
1866
1867
1868
1869
1870
1871
1872
# File 'lib/minjs/ecma262/expression.rb', line 1864

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