fixes
[oweals/gnunet.git] / src / monkey / seaspider / org / gnunet / seaspider / ExpressionExtractorVisitor.java
index f0e1044869b2824bec54089218257cc36e5b1e06..b93b19d3d7b43fcc8c6bf9e834766958fb06bafa 100644 (file)
@@ -3,6 +3,7 @@ package org.gnunet.seaspider;
 import org.gnunet.seaspider.parser.nodes.ANDExpression;
 import org.gnunet.seaspider.parser.nodes.AdditiveExpression;
 import org.gnunet.seaspider.parser.nodes.ArgumentExpressionList;
+import org.gnunet.seaspider.parser.nodes.AssignmentExpression;
 import org.gnunet.seaspider.parser.nodes.AssignmentOperator;
 import org.gnunet.seaspider.parser.nodes.CastExpression;
 import org.gnunet.seaspider.parser.nodes.CompoundStatement;
@@ -117,11 +118,13 @@ public class ExpressionExtractorVisitor extends DepthFirstVisitor {
                        ExpressionBuilder old = current_expression;
                        current_expression = new ExpressionBuilder();
                        n.f0.accept(this);
+                       LineNumberInfo lin = LineNumberInfo.get(n);
                        if (old != null) {
                                old.push(current_expression.expression);
-                               LineNumberInfo lin = LineNumberInfo.get(n);
                                old.commit(lin.lineEnd);
-                       }
+                       } else {
+                               current_expression.commit(lin.lineEnd);
+                       }                       
                        current_expression = old;
                        skip_mode = old_mode;
                } else {
@@ -297,13 +300,41 @@ public class ExpressionExtractorVisitor extends DepthFirstVisitor {
                }
                old.push(current_expression.expression);
                current_expression = old;
-       }
-
+       }       
+       
        public void visit(AssignmentOperator n) {
                operator = true;
                super.visit(n);
                operator = false;
        }
+       
+       public void visit(AssignmentExpression n)
+       {
+               if (0 == n.f0.which)
+               {
+                       NodeSequence ns = (NodeSequence) n.f0.choice;
+                       UnaryExpression u = (UnaryExpression) ns.elementAt(0);
+                       AssignmentOperator ao = (AssignmentOperator) ns.elementAt(1);
+                       AssignmentExpression ae = (AssignmentExpression) ns.elementAt(2);
+                       LineNumberInfo lin = LineNumberInfo.get(n);
+
+                       ExpressionBuilder old = current_expression;
+                       current_expression = new ExpressionBuilder();
+                       u.accept(this);
+                       current_expression.commit(lin.lineEnd);
+                       ao.accept (this);
+                       old.push(current_expression.expression);
+                       current_expression = new ExpressionBuilder();
+                       ae.accept(this);
+                       current_expression.commit(lin.lineEnd);
+                       old.push(current_expression.expression);
+                       current_expression = old;
+               }
+               else
+               {
+                       n.f0.choice.accept (this);
+               }
+       }
 
        public void visit(ConditionalExpression n) {
                ExpressionBuilder old = current_expression;
@@ -380,11 +411,19 @@ public class ExpressionExtractorVisitor extends DepthFirstVisitor {
                current_expression = new ExpressionBuilder();
                n.f0.accept(this);
                if (n.f1.present()) {
+                       LineNumberInfo lin = LineNumberInfo.get(n.f0);
+                       current_expression.commit(lin.lineEnd);
                        operator = true;
                        NodeSequence ns = (NodeSequence) n.f1.node;
                        ns.nodes.get(0).accept(this);
                        operator = false;
+                       ExpressionBuilder tmp = current_expression;
+                       current_expression = new ExpressionBuilder();                           
                        ns.nodes.get(1).accept(this);
+                       lin = LineNumberInfo.get(ns.nodes.get(1));
+                       current_expression.commit(lin.lineEnd);
+                       tmp.push (current_expression.expression);
+                       current_expression = tmp;
                }
                old.push(current_expression.expression);
                current_expression = old;
@@ -396,11 +435,19 @@ public class ExpressionExtractorVisitor extends DepthFirstVisitor {
                current_expression = new ExpressionBuilder();
                n.f0.accept(this);
                if (n.f1.present()) {
+                       LineNumberInfo lin = LineNumberInfo.get(n.f0);
+                       current_expression.commit(lin.lineEnd);
                        operator = true;
                        NodeSequence ns = (NodeSequence) n.f1.node;
                        ns.nodes.get(0).accept(this);
                        operator = false;
+                       ExpressionBuilder tmp = current_expression;
+                       current_expression = new ExpressionBuilder();                           
                        ns.nodes.get(1).accept(this);
+                       lin = LineNumberInfo.get(ns.nodes.get(1));
+                       current_expression.commit(lin.lineEnd);
+                       tmp.push (current_expression.expression);
+                       current_expression = tmp;
                }
                old.push(current_expression.expression);
                current_expression = old;
@@ -412,11 +459,19 @@ public class ExpressionExtractorVisitor extends DepthFirstVisitor {
                current_expression = new ExpressionBuilder();
                n.f0.accept(this);
                if (n.f1.present()) {
+                       LineNumberInfo lin = LineNumberInfo.get(n.f0);
+                       current_expression.commit(lin.lineEnd);
                        operator = true;
                        NodeSequence ns = (NodeSequence) n.f1.node;
                        ns.nodes.get(0).accept(this);
                        operator = false;
+                       ExpressionBuilder tmp = current_expression;
+                       current_expression = new ExpressionBuilder();                           
                        ns.nodes.get(1).accept(this);
+                       lin = LineNumberInfo.get(ns.nodes.get(1));
+                       current_expression.commit(lin.lineEnd);
+                       tmp.push (current_expression.expression);
+                       current_expression = tmp;
                }
                old.push(current_expression.expression);
                current_expression = old;
@@ -451,11 +506,16 @@ public class ExpressionExtractorVisitor extends DepthFirstVisitor {
                current_expression = new ExpressionBuilder();
                n.f0.accept(this);
                if (n.f1.present()) {
+                       LineNumberInfo lin = LineNumberInfo.get(n);
+                       current_expression.commit(lin.lineEnd);
                        operator = true;
                        NodeSequence ns = (NodeSequence) n.f1.node;
                        ns.nodes.get(0).accept(this);
                        operator = false;
+                       old.push(current_expression.expression);
+                       current_expression = new ExpressionBuilder();
                        ns.nodes.get(1).accept(this);
+                       current_expression.commit(lin.lineEnd);
                }
                old.push(current_expression.expression);
                current_expression = old;
@@ -467,11 +527,19 @@ public class ExpressionExtractorVisitor extends DepthFirstVisitor {
                current_expression = new ExpressionBuilder();
                n.f0.accept(this);
                if (n.f1.present()) {
+                       LineNumberInfo lin = LineNumberInfo.get(n.f0);
+                       current_expression.commit(lin.lineEnd);
                        operator = true;
                        NodeSequence ns = (NodeSequence) n.f1.node;
                        ns.nodes.get(0).accept(this);
                        operator = false;
+                       ExpressionBuilder tmp = current_expression;
+                       current_expression = new ExpressionBuilder();                           
                        ns.nodes.get(1).accept(this);
+                       lin = LineNumberInfo.get(ns.nodes.get(1));
+                       current_expression.commit(lin.lineEnd);
+                       tmp.push (current_expression.expression);
+                       current_expression = tmp;
                }
                old.push(current_expression.expression);
                current_expression = old;
@@ -483,11 +551,19 @@ public class ExpressionExtractorVisitor extends DepthFirstVisitor {
                current_expression = new ExpressionBuilder();
                n.f0.accept(this);
                if (n.f1.present()) {
+                       LineNumberInfo lin = LineNumberInfo.get(n.f0);
+                       current_expression.commit(lin.lineEnd);
                        operator = true;
                        NodeSequence ns = (NodeSequence) n.f1.node;
                        ns.nodes.get(0).accept(this);
                        operator = false;
+                       ExpressionBuilder tmp = current_expression;
+                       current_expression = new ExpressionBuilder();                           
                        ns.nodes.get(1).accept(this);
+                       lin = LineNumberInfo.get(ns.nodes.get(1));
+                       current_expression.commit(lin.lineEnd);
+                       tmp.push (current_expression.expression);
+                       current_expression = tmp;
                }
                old.push(current_expression.expression);
                current_expression = old;
@@ -499,11 +575,19 @@ public class ExpressionExtractorVisitor extends DepthFirstVisitor {
                current_expression = new ExpressionBuilder();
                n.f0.accept(this);
                if (n.f1.present()) {
+                       LineNumberInfo lin = LineNumberInfo.get(n.f0);
+                       current_expression.commit(lin.lineEnd);
                        operator = true;
                        NodeSequence ns = (NodeSequence) n.f1.node;
                        ns.nodes.get(0).accept(this);
                        operator = false;
+                       ExpressionBuilder tmp = current_expression;
+                       current_expression = new ExpressionBuilder();                           
                        ns.nodes.get(1).accept(this);
+                       lin = LineNumberInfo.get(ns.nodes.get(1));
+                       current_expression.commit(lin.lineEnd);
+                       tmp.push (current_expression.expression);
+                       current_expression = tmp;
                }
                old.push(current_expression.expression);
                current_expression = old;
@@ -545,7 +629,7 @@ public class ExpressionExtractorVisitor extends DepthFirstVisitor {
                                NodeSequence ns = (NodeSequence) nc.choice;
                                ns.elementAt(1).accept(this);
                                LineNumberInfo lin = LineNumberInfo.get(n);
-                               current_expression.commit(lin.colEnd);
+                               current_expression.commit(lin.lineEnd);
                                old.push("[");
                                old.push(current_expression.expression);
                                old.push("]");
@@ -557,6 +641,8 @@ public class ExpressionExtractorVisitor extends DepthFirstVisitor {
                                current_expression = new ExpressionBuilder();
                                NodeSequence ns = (NodeSequence) nc.choice;
                                ns.elementAt(1).accept(this);
+                               LineNumberInfo lin = LineNumberInfo.get (ns.elementAt(1));
+                               current_expression.commit(lin.lineEnd);
                                old.push("(");
                                old.push(current_expression.expression);
                                old.push(")");
@@ -596,6 +682,8 @@ public class ExpressionExtractorVisitor extends DepthFirstVisitor {
                        current_expression = new ExpressionBuilder();
                        NodeSequence ns = (NodeSequence) n.f0.choice;
                        ns.elementAt(1).accept(this);
+                       LineNumberInfo lin1 = LineNumberInfo.get (ns.elementAt(1));
+                       current_expression.commit(lin1.lineEnd);
                        old.push("(");
                        old.push(current_expression.expression);
                        old.push(")");