Support for dynamics

Overridden VisitDynamic to support dynamic expressions and added some modifications with ternary (added brackets to remove ambiguity)
The diff didn't work too well though.