Make resolve return top-level FunctionDesc.
Add compile template.
Add constant folding/reduction.