Title: [477] trunk/jparsetree/lib/jparsetree.rb: Added source locations to jparsetree s-exprs
Revision
477
Author
murphee
Date
2007-04-23 16:48:49 -0400 (Mon, 23 Apr 2007)

Log Message

Added source locations to jparsetree s-exprs
(the locations are added as Ranges to each 
list/subnode).

Modified Paths

Diff

Modified: trunk/jparsetree/lib/jparsetree.rb (476 => 477)


--- trunk/jparsetree/lib/jparsetree.rb	2007-04-23 20:36:28 UTC (rev 476)
+++ trunk/jparsetree/lib/jparsetree.rb	2007-04-23 20:48:49 UTC (rev 477)
@@ -4,6 +4,17 @@
 module JParseTree
 
 
+module SourceLocations
+ def source_location
+   @location
+ end
+ def source_location=(location)
+   @location = location
+ end
+end
+
+
+
 def JParseTree.filter_nested_arrays(bl)
     if bl != nil
       while bl.is_a? Array 
@@ -24,7 +35,7 @@
 
 class ParseTree       
 
-VERSION = '0.9.8.199'
+VERSION = '0.9.8.371'
 
   ##
   # Main driver for ParseTree. Returns an array of arrays containing
@@ -181,7 +192,21 @@
 
   attr_accessor :sexpr
 
+  def location(obj, node)
+    obj.extend(SourceLocations)
+    location = node.position()
+    if location
+      obj.source_location = (location.start_offset()..location.end_offset())
+    else
+      # I'm not sure if this is the best way... it's either this or
+      # setting it to nil;
+      obj.source_location = (-1..-1)
+    end
+    obj
+  end
 
+
+
   def stackelements()
    @stackElements
   end
@@ -208,7 +233,7 @@
   
   def visitAliasNode(iVisited)
     #puts iVisited.to_s + " #{iVisited.old_name} #{iVisited.new_name}"    
-    @stackElements << [:alias,[:lit, iVisited.new_name.to_sym], [:lit, iVisited.old_name.to_sym]]
+    @stackElements << location([:alias,[:lit, iVisited.new_name.to_sym], [:lit, iVisited.old_name.to_sym]], iVisited)
     nil
   end
   
@@ -218,7 +243,7 @@
     first = @stackElements.pop
     visit(iVisited.second_node)
     second = @stackElements.pop
-    @stackElements << [:and, first, second]
+    @stackElements << location([:and, first, second], iVisited)
     nil
   end
   
@@ -260,9 +285,9 @@
     end
     
     if blockarg 
-      @stackElements << [:block_arg_available, tempArgs, blockarg]
+      @stackElements << location([:block_arg_available, tempArgs, blockarg], iVisited)
     else
-     @stackElements << tempArgs
+     @stackElements << location(tempArgs, iVisited)
     end
     nil
   end
@@ -274,7 +299,7 @@
     first = @stackElements.pop
     visit(iVisited.second_node)
     second = @stackElements.pop
-    @stackElements << [:argscat, first, second]
+    @stackElements << location([:argscat, first, second], iVisited)
     nil
   end
   
@@ -293,7 +318,7 @@
        end
       
     } 
-    @stackElements <<  temp
+    @stackElements <<  location(temp, iVisited)
     nil
   end
 
@@ -302,7 +327,7 @@
   first_node  = JParseTree.filter_nested_arrays(@stackElements.pop)
   visit(iVisited.second_node)
   second_node  = JParseTree.filter_nested_arrays(@stackElements.pop)
-  @stackElements << [:argspush, first_node, second_node]
+  @stackElements << location([:argspush, first_node, second_node], iVisited)
 
   nil
 end
@@ -314,9 +339,9 @@
     visit(iVisited.args_node)
     args = @stackElements.pop
     if args == nil
-      @stackElements << [:attrasgn , recv, iVisited.name.to_sym]
+      @stackElements << location([:attrasgn , recv, iVisited.name.to_sym], iVisited)
     else
-      @stackElements << [:attrasgn , recv, iVisited.name.to_sym, args]
+      @stackElements << location([:attrasgn , recv, iVisited.name.to_sym, args], iVisited)
     end
 #    @stackElements << [:call , recv, iVisited.name.to_sym]
     nil
@@ -327,7 +352,7 @@
 #   HACK: the type is a char/Fixnum ASCII value, so take it and add it to a string
     type = ""
     type << iVisited.type
-    @stackElements << [:back_ref, type.to_sym]
+    @stackElements << location([:back_ref, type.to_sym], iVisited)
     nil
   end
 
@@ -337,7 +362,7 @@
     #puts iVisited.to_s
     visit(iVisited.body_node)
     bl = JParseTree.filter_nested_arrays(@stackElements.pop)
-    @stackElements << [:begin, bl]
+    @stackElements << location([:begin, bl], iVisited)
     nil
   end
   
@@ -349,7 +374,7 @@
   def visitBlockArgNode(iVisited)
     #p "Block"
 #    puts iVisited.to_s + " " + iVisited.count
-    @stackElements <<  [:block_arg, iVisited.name.to_sym]
+    @stackElements <<  location([:block_arg, iVisited.name.to_sym], iVisited)
     nil
   end
   
@@ -366,7 +391,7 @@
        tempStack << JParseTree.filter_nested_arrays(@stackElements.pop)
     }
 
-    @stackElements << tempStack
+    @stackElements << location(tempStack, iVisited)
 
     nil
   end
@@ -377,7 +402,7 @@
     body = @stackElements.pop
     
     iter = visitIterNode_fromBlockPass(iVisited.iter_node, body)
-    @stackElements << [:block_pass,  body, iter]
+    @stackElements << location([:block_pass,  body, iter], iVisited)
     nil
   end
   
@@ -386,9 +411,9 @@
     visit(iVisited.value_node)
     temp = @stackElements.pop
     if temp == nil
-      @stackElements << [:break]
+      @stackElements << location([:break], iVisited)
     else 
-      @stackElements << [:break, temp]
+      @stackElements << location([:break, temp], iVisited)
     end
 
     nil
@@ -397,26 +422,26 @@
   def visitConstDeclNode(iVisited)
     # puts iVisited.to_s + " #{iVisited.name}"
     visit(iVisited.value_node)
-    @stackElements << [:cdecl, iVisited.name.to_sym,@stackElements.pop]
+    @stackElements << location([:cdecl, iVisited.name.to_sym,@stackElements.pop], iVisited)
     nil
   end
   
   def visitClassVarAsgnNode(iVisited)
     # puts iVisited.to_s + " #{iVisited.name}"
     visit(iVisited.value_node)
-    @stackElements << [:cvasgn, iVisited.name.to_sym, @stackElements.pop]
+    @stackElements << location([:cvasgn, iVisited.name.to_sym, @stackElements.pop], iVisited)
     nil
   end
   
   def visitClassVarDeclNode(iVisited)
     visit(iVisited.value_node)
-    @stackElements << [:cvdecl, iVisited.name.to_sym,@stackElements.pop]
+    @stackElements << location([:cvdecl, iVisited.name.to_sym,@stackElements.pop], iVisited)
     nil
   end
   
   def visitClassVarNode(iVisited)
     # puts iVisited.to_s + " @@#{iVisited.name}"
-    @stackElements << [:cvar, iVisited.name.to_sym]
+    @stackElements << location([:cvar, iVisited.name.to_sym], iVisited)
     nil 
   end
   
@@ -429,15 +454,15 @@
       args = @stackElements.pop
       tmp_elements = []
       if args == nil
-        tmp_elements = [:call , recv, iVisited.name.to_sym]
+        tmp_elements = location([:call , recv, iVisited.name.to_sym], iVisited)
       else
-        tmp_elements = [:call , recv, iVisited.name.to_sym, args]
+        tmp_elements = location([:call , recv, iVisited.name.to_sym, args], iVisited)
       end
       
       if iVisited.iter_node
         tmp_elements = visitIterNode_fromCall(iVisited.iter_node, tmp_elements)
       end
-      @stackElements << tmp_elements
+      @stackElements << location(tmp_elements, iVisited)
   #    @stackElements << [:call , recv, iVisited.name.to_sym]
     nil
   end
@@ -461,7 +486,7 @@
        end
       end
     }
-    @stackElements << [:case, node, @stackElements.pop]
+    @stackElements << location([:case, node, @stackElements.pop], iVisited)
     nil
   end
   
@@ -475,12 +500,12 @@
     visit(iVisited.super_node)
 
     if iVisited.super_node != nil 
-      superclazz = [:const, iVisited.super_node.name.to_sym]
+      superclazz = location([:const, iVisited.super_node.name.to_sym], iVisited.super_node)
     else 
       superclazz = nil
     end
     visit(iVisited.body_node)
-    klazz = [:class,clazzname, superclazz, [:scope, JParseTree.filter_nested_arrays(@stackElements.pop)]]
+    klazz = location([:class,clazzname, superclazz, [:scope, JParseTree.filter_nested_arrays(@stackElements.pop)]], iVisited)
     if @stackElements == nil
       @sexpr << klazz
     else
@@ -493,21 +518,21 @@
     # puts iVisited.to_s + " #{iVisited.name}"
     visit(iVisited.left_node) unless iVisited.left_node.nil?
     if iVisited.left_node.nil?
-     @stackElements << [:colon2, nil,  iVisited.name.to_sym]
+     @stackElements << location([:colon2, nil,  iVisited.name.to_sym], iVisited)
     else 
-     @stackElements << [:colon2, @stackElements.pop,  iVisited.name.to_sym]
+     @stackElements << location([:colon2, @stackElements.pop,  iVisited.name.to_sym], iVisited)
     end
     nil
   end
   
   def visitColon3Node(iVisited)
     # puts iVisited.to_s + " ::#{iVisited.name}"
-    @stackElements << [:colon3, iVisited.name.to_sym]
+    @stackElements << location([:colon3, iVisited.name.to_sym], iVisited)
   end
   
   def visitConstNode(iVisited)
     # puts iVisited.to_s + " #{iVisited.name}"
-    @stackElements << [:const, iVisited.name.to_sym]
+    @stackElements << location([:const, iVisited.name.to_sym], iVisited)
     nil
   end
   
@@ -516,13 +541,13 @@
     visit(iVisited.value_node)
     val = JParseTree.filter_nested_arrays(@stackElements.pop)
     if val == nil
-     @stackElements << [:dasgn_curr, iVisited.name.to_sym]
+     @stackElements << location([:dasgn_curr, iVisited.name.to_sym], iVisited)
 #      @stackElements << [:lasgn, iVisited.name.to_sym]
     else
 
 #     TODO: not a bug; for some reason, putting :lasgn here causes
 #     less test failures thatn putting :dasgn 
-    @stackElements <<[:lasgn, iVisited.name.to_sym, JParseTree.filter_nested_arrays(val)]   
+    @stackElements <<  location([:lasgn, iVisited.name.to_sym, JParseTree.filter_nested_arrays(val)], iVisited)   
 
       
       #p "made it past"
@@ -547,14 +572,14 @@
      temp[0] = :dregx 
     end
     
-    @stackElements << temp
+    @stackElements << location(temp, iVisited)
     nil
   end
   
   def visitDStrNode(iVisited)
     # puts iVisited.to_s
     # TODO: bug in parsetree? it returns the first string as string literal, instead of [:str, ..]
-    @stackElements << [:dstr]
+    @stackElements << location([:dstr], iVisited)
     
     count = 1
     iVisited.child_nodes.each {|n| 
@@ -591,7 +616,7 @@
     temp = JParseTree.filter_nested_arrays(temp)
     temp[0] = :dsym
     
-    @stackElements << temp 
+    @stackElements << location(temp, iVisited) 
     if iVisited.child_nodes.size > 1
      iVisited.child_nodes.each {|n| 
         if !n.nil?
@@ -609,7 +634,7 @@
   def visitDVarNode(iVisited)
     # puts iVisited.to_s + " #{iVisited.name}"
     # TODO: PROBLEM here?
-    @stackElements << [:dvar, iVisited.name.to_sym]
+    @stackElements << location([:dvar, iVisited.name.to_sym], iVisited)
     nil
   end
   
@@ -621,7 +646,7 @@
   def visitDXStrNode(iVisited)
     # puts iVisited.to_s
     # TODO: bug in parsetree? it returns the first string as string literal, instead of [:str, ..]
-    @stackElements << [:dxstr]
+    @stackElements << location([:dxstr], iVisited)
     
     count = 1
     iVisited.child_nodes.each {|n| 
@@ -662,7 +687,7 @@
   def visitDefinedNode(iVisited)
     # puts iVisited.to_s
     visit(iVisited.expression_node)
-    @stackElements << [:defined, @stackElements.pop]
+    @stackElements << location([:defined, @stackElements.pop], iVisited)
     nil
   end
   
@@ -718,9 +743,9 @@
         the_block = [:block, args, body]
        end
       end
-      @stackElements << [:defn, iVisited.name.to_sym,[:scope, the_block ] ]
+      @stackElements << location([:defn, iVisited.name.to_sym,[:scope, the_block ] ], iVisited)
      else
-      @stackElements << [:defn, iVisited.name.to_sym,[:scope, [:block,[:args], [:nil] ] ] ]
+      @stackElements << location([:defn, iVisited.name.to_sym,[:scope, [:block,[:args], [:nil] ] ] ], iVisited)
      end
      
 
@@ -739,7 +764,7 @@
     visit(iVisited.body_node)
     body =  JParseTree.filter_nested_arrays(@stackElements.pop)
     # TODO: handle block args as in :defn
-    @stackElements << [:defs, recv, iVisited.name.to_sym, [:scope, [:block, args, body] ]]
+    @stackElements << location([:defs, recv, iVisited.name.to_sym, [:scope, [:block, args, body] ]],iVisited)
     nil
   end
 
@@ -761,18 +786,18 @@
     
     if beginNode.first == :lit && endNode.first == :lit 
      if symbol == :dot2
-      @stackElements << [:lit, beginValue..endValue ]
+      @stackElements << location([:lit, beginValue..endValue ], iVisited)
      else 
-       @stackElements << [:lit, beginValue...endValue]
+       @stackElements << location([:lit, beginValue...endValue], iVisited)
      end
     else
       
 #     @stackElements << [iVisited.exclusive ? :dot3 : :dot2, beginNode, @stackElements.pop ]
      
     if symbol == :dot2
-     @stackElements << [:dot2, beginNode, endNode ]
+     @stackElements << location([:dot2, beginNode, endNode ], iVisited)
      else 
-      @stackElements << [:dot3, beginNode, endNode]
+      @stackElements << location([:dot3, beginNode, endNode], iVisited)
      end
     end
     nil
@@ -783,7 +808,7 @@
     visit(iVisited.ensure_node)
     ensureNode = @stackElements.pop
     visit(iVisited.body_node)
-    @stackElements << [:ensure,  @stackElements.pop, JParseTree.filter_nested_arrays(ensureNode)]
+    @stackElements << location([:ensure,  @stackElements.pop, JParseTree.filter_nested_arrays(ensureNode)], iVisited)
     nil
   end
   
@@ -798,9 +823,9 @@
     visit(iVisited.args_node)
     args =  @stackElements.pop
     if args == nil 
-      tmp_elements = [:fcall, iVisited.name.to_sym] 
+      tmp_elements = location([:fcall, iVisited.name.to_sym], iVisited) 
     else 
-      tmp_elements = [:fcall, iVisited.name.to_sym, args] 
+      tmp_elements = location([:fcall, iVisited.name.to_sym, args], iVisited)
     end
     if iVisited.iter_node
       tmp_elements = visitIterNode_fromCall(iVisited.iter_node, tmp_elements)
@@ -816,7 +841,7 @@
   end
   
   def visitFixnumNode(iVisited)
-    @stackElements << [:lit, iVisited.value]
+    @stackElements << location([:lit, iVisited.value],iVisited)
     
     # puts iVisited.to_s + " " + iVisited.value.to_s
     nil
@@ -830,16 +855,16 @@
     end_node = @stackElements.pop
     # TODO: make this more elegant without an if and without the duplication of code
     if iVisited.exclusive?
-     @stackElements << [:flip3, begin_node, end_node]
+     @stackElements << location([:flip3, begin_node, end_node], iVisited)
     else
-     @stackElements << [:flip2, begin_node, end_node]
+     @stackElements << location([:flip2, begin_node, end_node], iVisited)
     end
     nil
   end
   
   def visitFloatNode(iVisited)
     # puts iVisited.to_s + " " + iVisited.value.to_s
-    @stackElements << [:lit, iVisited.value]
+    @stackElements << location([:lit, iVisited.value], iVisited)
     nil
   end
   
@@ -851,26 +876,26 @@
     iter = @stackElements.pop
     visit(iVisited.body_node)
     body = JParseTree.filter_nested_arrays(@stackElements.pop)
-    @stackElements << [:for, iter,var,body]
+    @stackElements << location([:for, iter,var,body], iVisited)
     nil
   end
   
   def visitGlobalAsgnNode(iVisited)
     # puts iVisited.to_s + " " + iVisited.name
     visit(iVisited.value_node)
-    @stackElements << [:gasgn, iVisited.name.to_sym, @stackElements.pop]
+    @stackElements << location([:gasgn, iVisited.name.to_sym, @stackElements.pop], iVisited)
     nil
   end
   
   def visitGlobalVarNode(iVisited)
     # puts "GlobalVar " + iVisited.to_s + " " + iVisited.name
-    @stackElements << [:gvar, iVisited.name.to_sym ]
+    @stackElements << location([:gvar, iVisited.name.to_sym ], iVisited)
     nil
   end
   
   def visitHashNode(iVisited)
     # puts iVisited.to_s    
-    result = [:hash]
+    result = location([:hash], iVisited)
     visit(iVisited.list_node)
     temp = @stackElements.pop
     if temp.first == :array
@@ -884,14 +909,14 @@
   def visitInstAsgnNode(iVisited)
 #    visitGlobalAsgnNode(iVisited)
     visit(iVisited.value_node)
-    @stackElements << [:iasgn, iVisited.name.to_sym, @stackElements.pop]
+    @stackElements << location([:iasgn, iVisited.name.to_sym, @stackElements.pop], iVisited)
     nil
   end
   
   def visitInstVarNode(iVisited)
 #    visitGlobalVarNode(iVisited)
 #    @stackElements << [:ivar, iVisited.name.to_sym]
-    @stackElements << [iVisited.name.to_sym]
+    @stackElements << location([iVisited.name.to_sym], iVisited)
     nil
   end
   
@@ -912,7 +937,7 @@
     else
       temp << nil
     end
-    @stackElements << temp
+    @stackElements << location(temp, iVisited)
     nil
   end
 
@@ -924,9 +949,9 @@
     visit(iVisited.iter_node)
     cond = JParseTree.filter_nested_arrays(@stackElements.pop)
     if body != nil
-     @stackElements << [:iter, cond , var, body]
+     @stackElements << location([:iter, cond , var, body], iVisited)
     else
-     @stackElements << [:iter, cond , var]
+     @stackElements << location([:iter, cond , var], iVisited)
     end
     nil
   end
@@ -934,7 +959,7 @@
   def visitIterNode_fromBlockPass(iVisited, cond)
     visit(iVisited)
     body = JParseTree.filter_nested_arrays(@stackElements.pop)
-    tmp_elements = [:block_pass, body, cond]
+    tmp_elements = location([:block_pass, body, cond], iVisited)
     tmp_elements
   end
   
@@ -950,9 +975,9 @@
   
       tmp_elements = []
       if body != nil
-       tmp_elements = [:iter, cond, var, body]
+       tmp_elements = location([:iter, cond, var, body], iVisited)
       else
-       tmp_elements = [:iter, cond, var]
+       tmp_elements = location([:iter, cond, var], iVisited)
       end
       tmp_elements
     end
@@ -965,9 +990,9 @@
     visit(iVisited.value_node)
     temp = @stackElements.pop
     if temp == nil
-      @stackElements << [:lasgn, iVisited.name.to_sym]
+      @stackElements << location([:lasgn, iVisited.name.to_sym], iVisited)
     else
-        @stackElements << [:lasgn, iVisited.name.to_sym, JParseTree.filter_nested_arrays(temp)]
+        @stackElements << location([:lasgn, iVisited.name.to_sym, JParseTree.filter_nested_arrays(temp)], iVisited)
     end
 
     nil
@@ -975,7 +1000,7 @@
   
   def visitLocalVarNode(iVisited)
 
-           @stackElements << [:lvar, iVisited.name.to_sym]
+           @stackElements << location([:lvar, iVisited.name.to_sym], iVisited)
 #     @stackElements << iVisited.name.to_sym
      nil
   end
@@ -989,7 +1014,7 @@
     # TODO: find out how to do this!
     # TODO: handle all elements!
 #    @stackElements << [:masgn, head, @stackElements.pop]
-    @stackElements << [:masgn, head,  @stackElements.pop]
+    @stackElements << location([:masgn, head,  @stackElements.pop], iVisited)
     nil
   end
   
@@ -999,7 +1024,7 @@
     recv = @stackElements.pop
     visit(iVisited.value_node)
     val = @stackElements.pop
-    @stackElements << [:match2, recv, val ]
+    @stackElements << location([:match2, recv, val ], iVisited)
     nil
   end
   
@@ -1013,7 +1038,7 @@
   def visitMatchNode(iVisited)
     # puts iVisited.to_s
     visit(iVisited.regexp_node)
-    @stackElements << [:match, @stackElements.pop]
+    @stackElements << location([:match, @stackElements.pop], iVisited)
     nil
   end
   
@@ -1023,7 +1048,9 @@
     visit(iVisited.body_node)
     body = @stackElements.pop
     #puts "[EMAIL PROTECTED]"
-    @stackElements << [:module, iVisited.CPath.name.to_sym, [:scope, JParseTree.filter_nested_arrays(body)]]
+    @stackElements << location([:module, iVisited.CPath.name.to_sym, 
+                                  location([:scope, JParseTree.filter_nested_arrays(body)], iVisited.body_node) 
+                               ], iVisited)
 
 
     nil
@@ -1033,7 +1060,7 @@
 #     puts iVisited.to_s
  #    puts iVisited.next_node.to_s
     visit(iVisited.next_node)
-    @stackElements << [EMAIL PROTECTED] # unless @stackElements.size < 1
+    @stackElements << location([EMAIL PROTECTED], iVisited) # unless @stackElements.size < 1
 
     nil
   end
@@ -1043,9 +1070,9 @@
     visit(iVisited.value_node)
     temp =  @stackElements.pop
     if temp == nil 
-    @stackElements << [:next]
+    @stackElements << location([:next], iVisited)
     else 
-    @stackElements << [:next, temp]
+    @stackElements << location([:next, temp], iVisited)
     end
     nil
   end
@@ -1060,13 +1087,13 @@
   def visitNotNode(iVisited)
     # puts iVisited.to_s
     visit(iVisited.condition_node)
-    @stackElements << [:not, JParseTree.filter_nested_arrays([EMAIL PROTECTED])]
+    @stackElements << location([:not, JParseTree.filter_nested_arrays([EMAIL PROTECTED])], iVisited)
     nil
   end
   
   def visitNthRefNode(iVisited)
     # puts iVisited.to_s + " match number " + iVisited.match_number.to_s
-    @stackElements << [:nth_ref, iVisited.match_number]
+    @stackElements << location([:nth_ref, iVisited.match_number], iVisited)
     nil
   end
   
@@ -1078,7 +1105,7 @@
     args = @stackElements.pop
     visit(iVisited.value_node)
     val = @stackElements.pop
-    @stackElements << [:op_asgn1, recv, args, iVisited.operator_name.to_sym,val]
+    @stackElements << location([:op_asgn1, recv, args, iVisited.operator_name.to_sym,val], iVisited)
     nil
   end
    
@@ -1093,7 +1120,7 @@
      operator_name = iVisited.operator_name.to_sym 
 
 #    @stackElements << [op_symbol, recv, iVisited.variable_name,val]
-     @stackElements << [op_symbol, recv, iVisited.variable_name_asgn.to_sym, operator_name, val]
+     @stackElements << location([op_symbol, recv, iVisited.variable_name_asgn.to_sym, operator_name, val], iVisited)
     nil
   end
   
@@ -1103,7 +1130,7 @@
     recv = @stackElements.pop
     visit(iVisited.second_node)
     val = @stackElements.pop
-    @stackElements << [op_symbol, recv, val]
+    @stackElements << location([op_symbol, recv, val], iVisited)
   end
 
   def visitOpAsgnAndNode(iVisited)
@@ -1126,26 +1153,26 @@
     visit(iVisited.first_node)
     first = @stackElements.pop
     visit(iVisited.second_node)
-    @stackElements << [:or, first, @stackElements.pop]
+    @stackElements << location([:or, first, @stackElements.pop], iVisited)
     nil
   end
   
   def visitPostExeNode(iVisited)
     # puts iVisited.to_s
     @stackElements ||= [] 
-    @stackElements << [:postexe]
+    @stackElements << location([:postexe], iVisited)
     nil
   end
   
   def visitRedoNode(iVisited)
     # puts iVisited.to_s
-    @stackElements << [:redo]
+    @stackElements << location([:redo], iVisited)
     nil
   end
   
   def visitRegexpNode(iVisited)
     
-      @stackElements << [:lit, Regexp.new(iVisited.value)]
+      @stackElements << location([:lit, Regexp.new(iVisited.value)], iVisited)
     nil
   end
   
@@ -1158,11 +1185,11 @@
     visit(iVisited.opt_rescue_node)
     rescue_node = @stackElements.pop
     if body == nil && rescue_node == nil
-      @stackElements << [:resbody, excNodes]
+      @stackElements << location([:resbody, excNodes], iVisited)
     else  if rescue_node == nil
-      @stackElements << [:resbody, excNodes, JParseTree.filter_nested_arrays(body)]
+      @stackElements << location([:resbody, excNodes, JParseTree.filter_nested_arrays(body)], iVisited)
      else
-     @stackElements << [:resbody, excNodes, body, JParseTree.filter_nested_arrays(rescue_node)]
+     @stackElements << location([:resbody, excNodes, body, JParseTree.filter_nested_arrays(rescue_node)], iVisited)
      end
     end
     nil
@@ -1177,9 +1204,9 @@
     visit(iVisited.else_node)
     else_node = @stackElements.pop
     if else_node == nil
-     @stackElements << [:rescue, JParseTree.filter_nested_arrays(body), rescueNode]
+     @stackElements << location([:rescue, JParseTree.filter_nested_arrays(body), rescueNode], iVisited)
     else 
-     @stackElements << [:rescue, JParseTree.filter_nested_arrays(body), rescueNode, JParseTree.filter_nested_arrays(else_node)]
+     @stackElements << location([:rescue, JParseTree.filter_nested_arrays(body), rescueNode, JParseTree.filter_nested_arrays(else_node)], iVisited)
     end
     nil
   end
@@ -1189,7 +1216,7 @@
   
   def visitRetryNode(iVisited)
     # puts iVisited.to_s
-    @stackElements << [:retry]
+    @stackElements << location([:retry], iVisited)
     nil
   end
   
@@ -1198,7 +1225,7 @@
     visit(iVisited.value_node)
     temp = @stackElements.pop
     
-    @stackElements << [:return, temp]
+    @stackElements << location([:return, temp], iVisited)
     nil
   end
   
@@ -1211,27 +1238,27 @@
     visit(iVisited.body_node)
     body = JParseTree.filter_nested_arrays(@stackElements.pop)
 
-    @stackElements << [:sclass, recv, [:scope, body] ]
+    @stackElements << location([:sclass, recv, [:scope, body] ], iVisited)
     nil
   end
   
     
   def visitSelfNode(iVisited)
     # puts iVisited.to_s
-    @stackElements << [:self]
+    @stackElements << location([:self], iVisited)
     nil
   end
   
   def visitSplatNode(iVisited)
     # puts iVisited.to_s
     visit(iVisited.value)
-    @stackElements << [:splat, @stackElements.pop]
+    @stackElements << location([:splat, @stackElements.pop], iVisited)
     nil
   end
   
   def visitStrNode(iVisited)
     # puts iVisited.to_s + "\"" + iVisited.value + "\""
-    @stackElements << [:str, iVisited.value]
+    @stackElements << location([:str, iVisited.value], iVisited)
     nil
   end
   
@@ -1242,13 +1269,13 @@
     args = @stackElements.pop
     if args != nil
      if args.size > 0
-       @stackElements << [:super, args]
+       @stackElements << location([:super, args], iVisited)
      else 
-      @stackElements << [:zsuper]     
+      @stackElements << location([:zsuper], iVisited)     
      end
     else
     # TODO: remove redundancy and check when zsuper happens
-     @stackElements << [:zsuper]     
+     @stackElements << location([:zsuper], iVisited)     
     end
 
     nil
@@ -1257,20 +1284,20 @@
   def visitSValueNode(iVisited)
     # puts iVisited.to_s
     visit(iVisited.value)
-    @stackElements << [:svalue, @stackElements.pop]
+    @stackElements << location([:svalue, @stackElements.pop], iVisited)
     nil
   end
   
   def visitSymbolNode(iVisited)
     # puts iVisited.to_s + " " + iVisited.name
-    @stackElements << [:lit, iVisited.name.to_sym]
+    @stackElements << location([:lit, iVisited.name.to_sym], iVisited)
     nil
   end
   
   def visitToAryNode(iVisited)
     # puts iVisited.to_s
     visit(iVisited.value)
-    @stackElements << [:to_ary, @stackElements.pop]
+    @stackElements << location([:to_ary, @stackElements.pop], iVisited)
     nil
   end
   
@@ -1282,7 +1309,7 @@
   
   def visitUndefNode(iVisited)
     # puts iVisited.to_s + " " + iVisited.name
-    @stackElements << [:undef, [:lit, iVisited.name.to_sym]]
+    @stackElements << location([:undef, [:lit, iVisited.name.to_sym]], iVisited)
    # p "[EMAIL PROTECTED]"
     nil
   end
@@ -1294,14 +1321,14 @@
     visit(iVisited.body_node)
     body = JParseTree.filter_nested_arrays(@stackElements.pop)
     # TODO: ask about the last element "true"
-    @stackElements << [:until, cond, body, true]
+    @stackElements << location([:until, cond, body, true], iVisited)
     nil
   end
   
   def visitVAliasNode(iVisited)
      
     # puts iVisited.to_s + " aliasing " + iVisited.old_name + " as " + iVisited.new_name
-    @stackElements << [:valias, iVisited.new_name.to_sym, iVisited.old_name.to_sym]
+    @stackElements << location([:valias, iVisited.new_name.to_sym, iVisited.old_name.to_sym], iVisited)
     nil
   end
   
@@ -1312,7 +1339,7 @@
   def visitVCallNode(iVisited)
     # puts iVisited.to_s + " " + iVisited.method_name
 #    visit(iVisited.args_node)
-    @stackElements << [:vcall, iVisited.name.to_sym]
+    @stackElements << location([:vcall, iVisited.name.to_sym], iVisited)
     nil
   end
   
@@ -1324,7 +1351,7 @@
     body = @stackElements.pop
     visit(iVisited.next_case)
     next_case =  @stackElements.pop unless @stackElements.size < 1
-    @stackElements << [:when, expr, body,next_case]
+    @stackElements << location([:when, expr, body,next_case], iVisited)
     nil
   end
   
@@ -1337,13 +1364,13 @@
     end
     visit(iVisited.body_node)
     body = JParseTree.filter_nested_arrays(@stackElements.pop)
-    @stackElements << [:while, condNode, body, iVisited.evaluateAtStart]
+    @stackElements << location([:while, condNode, body, iVisited.evaluateAtStart], iVisited)
     nil
   end
   
   def visitXStrNode(iVisited)
     # puts iVisited.to_s + " \"" + iVisited.value + "\""
-    @stackElements << [:xstr, iVisited.value]
+    @stackElements << location([:xstr, iVisited.value], iVisited)
     nil
   end
   
@@ -1352,22 +1379,22 @@
     visit(iVisited.args_node)
     temp = @stackElements.pop
     if temp == nil
-     @stackElements << [:yield]
+     @stackElements << location([:yield], iVisited)
     else 
-     @stackElements << [:yield, temp]
+     @stackElements << location([:yield, temp], iVisited)
     end    
     nil
   end
   
   def visitZArrayNode(iVisited)
     # puts iVisited.to_s
-    @stackElements << [:zarray]
+    @stackElements << location([:zarray], iVisited)
     nil
   end
   
   def visitZSuperNode(iVisited)
     # puts iVisited.to_s
-    @stackElements << [:zsuper]
+    @stackElements << location([:zsuper], iVisited)
     nil
   end
 
_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel

Reply via email to