Class: Minjs::ECMA262::StForInVar
- Inherits:
-
St
- Object
- Base
- St
- Minjs::ECMA262::StForInVar
show all
- Defined in:
- lib/minjs/ecma262/st.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from St
#empty?, #priority, #to_exp?, #to_return?
Methods inherited from Base
#concat, #to_s
Constructor Details
#initialize(context, var_decl, exp2, statement) ⇒ StForInVar
Returns a new instance of StForInVar.
764
765
766
767
768
769
|
# File 'lib/minjs/ecma262/st.rb', line 764
def initialize(context, var_decl, exp2, statement)
@context = context
@var_decl = var_decl
@exp2 = exp2
@statement = statement
end
|
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
761
762
763
|
# File 'lib/minjs/ecma262/st.rb', line 761
def context
@context
end
|
#exp2 ⇒ Object
Returns the value of attribute exp2.
762
763
764
|
# File 'lib/minjs/ecma262/st.rb', line 762
def exp2
@exp2
end
|
#statement ⇒ Object
Returns the value of attribute statement.
762
763
764
|
# File 'lib/minjs/ecma262/st.rb', line 762
def statement
@statement
end
|
#var_decl ⇒ Object
Returns the value of attribute var_decl.
762
763
764
|
# File 'lib/minjs/ecma262/st.rb', line 762
def var_decl
@var_decl
end
|
Instance Method Details
#==(obj) ⇒ Object
801
802
803
804
805
806
|
# File 'lib/minjs/ecma262/st.rb', line 801
def ==(obj)
self.class == obj.class and
@var_decl == obj.var_decl and
@exp2 == obj.exp2 and
@statement == obj.statement
end
|
#add_paren ⇒ Object
834
835
836
|
# File 'lib/minjs/ecma262/st.rb', line 834
def add_paren
self
end
|
#deep_dup ⇒ Object
771
772
773
774
775
776
|
# File 'lib/minjs/ecma262/st.rb', line 771
def deep_dup
self.class.new(@context,
[@var_decl[0].deep_dup, @var_decl[1] ? @var_decl[1].deep_dup : nil],
@exp2.deep_dup,
@statement.deep_dup)
end
|
#remove_paren ⇒ Object
824
825
826
827
828
829
830
831
832
|
# File 'lib/minjs/ecma262/st.rb', line 824
def remove_paren
if @var_decl[1] and @var_decl[1].kind_of? ExpParen
@var_decl[1] = @var_decl[1].val
end
if @exp2.kind_of? ExpParen
@exp2 = @exp2.val
end
self
end
|
#replace(from, to) ⇒ Object
786
787
788
789
790
|
# File 'lib/minjs/ecma262/st.rb', line 786
def replace(from, to)
if from .eql? @statement
@statement = to
end
end
|
#to_js(options = {}) ⇒ Object
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
|
# File 'lib/minjs/ecma262/st.rb', line 808
def to_js(options = {})
if @statement.kind_of? StBlock and @statement.statement_list.length == 1
statement = @statement.statement_list.statement_list[0]
else
statement = @statement
end
if @var_decl[1]
_var_decl = concat(options, @var_decl[0], '=', @var_decl[1])
else
_var_decl = concat(options, @var_decl[0])
end
concat options, :for, "(", :var, _var_decl, :in, @exp2, ")", statement
end
|
#to_st_for_in ⇒ Object
792
793
794
795
796
797
798
799
|
# File 'lib/minjs/ecma262/st.rb', line 792
def to_st_for_in
if @var_decl[1]
t = ExpAssign.new(@var_decl[0], @var_decl[1])
else
t = @var_decl[0]
end
StForIn.new(t, @exp2, @statement)
end
|
#traverse(parent) {|_self, parent| ... } ⇒ Object
778
779
780
781
782
783
784
|
# File 'lib/minjs/ecma262/st.rb', line 778
def traverse(parent, &block)
@var_decl[0].traverse(self, &block)
@var_decl[1].traverse(self, &block) if @var_decl[1]
@exp2.traverse(self, &block)
@statement.traverse(self, &block)
yield self, parent
end
|