Refactor optimize

Refactoring of visitors in optimize.c to simplify (perhaps) and remove boiler plate code. A lot of the visitors uses the exact same code pattern to optimize and check for errors.

In commit baef3a1 a fail compilation test fails but the change should provide a more correct solution. Both lhs and rhs should be checked for errors in a "foo || bar" expression.
I have to admit  I have not fully figured out what name would be most suitable. That variable is the one sent to Expression::optimize which is a mix of `result`, `WANTflags`and `WANTvalue`. In that method it is called `result`. In what way differ `result` from the other two? Does it mean that you want to have a result returned or similar?