Index: /trunk/Decompiler.class.php
===================================================================
--- /trunk/Decompiler.class.php	(revision 756)
+++ /trunk/Decompiler.class.php	(revision 757)
@@ -162,13 +162,20 @@
 	function toCode($indent)
 	{
+		$opstr = $this->parent->binops[$this->opc];
+
 		$op1 = foldToCode($this->op1, $indent);
 		if (is_a($this->op1, 'Decompiler_Binop') && $this->op1->opc != $this->opc) {
-			$op1 = "($op1)";
-		}
-		$opstr = $this->parent->binops[$this->opc];
-		if ($op1 == '0' && $this->opc == XC_SUB) {
-			return $opstr . str($this->op2, $indent);
-		}
-		return str($op1) . ' ' . $opstr . ' ' . str($this->op2, $indent);
+			$op1 = "(" . str($op1, $indent) . ")";
+		}
+		$op2 = foldToCode($this->op2, $indent);
+		if (is_a($this->op2, 'Decompiler_Binop') && $this->op2->opc != $this->opc && substr($opstr, -1) != '=') {
+			$op2 = "(" . str($op2, $indent) . ")";
+		}
+
+		if (str($op1) == '0' && ($this->opc == XC_ADD || $this->opc == XC_SUB)) {
+			return $opstr . str($op2, $indent);
+		}
+
+		return str($op1) . ' ' . $opstr . ' ' . str($op2);
 	}
 }
@@ -900,5 +907,5 @@
 				$op1val = $this->getOpVal($op1, $EX);
 				$myop = $this->unaryops[$opc];
-				$rvalue = "$myop$op1val";
+				$rvalue = $myop . str($op1val);
 				$resvar = $rvalue;
 				// }}}
