       js: ''
     }
   else
-    module = lookupCompiledModule moduleName
-    {modules, ctx} = contextWithDependencies moduleDependencies moduleName
     [expression] = _terms ast
-    compilationFn = (topLevelExpressionInModule importsFor moduleDependencies moduleName)
-    {js} = compileCtxAstToJs compilationFn, ctx, expression
-    (finalizeTypes ctx, expression)
-    js: library + immutable + (listOfLines map lookupJs, (setToArray runtimeDependencies moduleName)) + '\n;' + js
-    ast: ast
-    errors: checkTypes ctx
-    malformed: ctx.isMalformed
+    result = compileExpressionFromAst expression, moduleName
+    result.ast = ast
+    result
+
+compileExpressionFromAst = (expression, moduleName) ->
+  module = lookupCompiledModule moduleName
+  {modules, ctx} = contextWithDependencies moduleDependencies moduleName
+  compilationFn = (topLevelExpressionInModule importsFor moduleDependencies moduleName)
+  {js} = compileCtxAstToJs compilationFn, ctx, expression
+  (finalizeTypes ctx, expression)
+  js: library + immutable + (listOfLines map lookupJs, (setToArray runtimeDependencies moduleName)) + '\n;' + js
+  errors: checkTypes ctx
+  malformed: ctx.isMalformed
 
 importsFor = (moduleSet) ->
   lookupDefinitions = (name) ->

#   exports"""

exports.library = library

exports.originOf = originOf
exports.sortedArgs = sortedArgs

        compiled = termCompile ctx, term
        (irJsCompatible term.tea, compiled))
      (jsCall "js#{jsMethod[0].toUpperCase()}#{jsMethod[1...]}", compatibles)

ms['parse-shem'] = ms_parse_shem = (ctx, call) ->
  [string] = _arguments call
  compiledString = termCompile ctx, string
  call.tea = toConstrained markOrigin expressionType, call
  assignCompile ctx, call, (jsMethod 'runtime', 'parseShem', [compiledString])

ms['eval-shem'] = ms_eval_shem = (ctx, call) ->
  [source] = _arguments call
  compiledSource = termCompile ctx, source
  call.tea = toConstrained markOrigin jsType, call
  fucked = eval translateToJs translateIr ctx, compiledSource
  compiled = termCompile ctx, fucked
  assignCompile ctx, call, compiled

ms['=='] = ms_eq = (ctx, call) ->
    [a, b] = _arguments call
