go over, refactor, and rewrite IR compiler

been a long time, going over approach in IR compiler.
refactor to convert huge if elseif dispatch to function dispatch.
also add some tests