text: "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  const ts = require("typescript");
  const lua = require("../../LuaAST");
  const errors_1 = require("../utils/errors");
  const lua_ast_1 = require("../utils/lua-ast");
  const scope_1 = require("../utils/scope");
  const typescript_1 = require("../utils/typescript");
  exports.transformSourceFileNode = (node, context) => {
      let statements = [];
      if (node.flags & ts.NodeFlags.JsonFile) {
          const [statement] = node.statements;
          if (!statement || !ts.isExpressionStatement(statement)) {
              throw errors_1.InvalidJsonFileContent(node);
          }
          statements.push(lua.createReturnStatement([context.transformExpression(statement.expression)]));
      }
      else {
          scope_1.pushScope(context, scope_1.ScopeType.File);
          statements = scope_1.performHoisting(context, context.transformStatements(node.statements));
          scope_1.popScope(context);
          if (context.isModule) {
              // If export equals was not used. Create the exports table.
              // local ____exports = {}
              if (!typescript_1.hasExportEquals(node)) {
                  statements.unshift(lua.createVariableDeclarationStatement(lua_ast_1.createExportsIdentifier(), lua.createTableExpression()));
              }
              // return ____exports
              statements.push(lua.createReturnStatement([lua_ast_1.createExportsIdentifier()]));
          }
      }
      return lua.createBlock(statements, node);
  };
  //# sourceMappingURL=sourceFile.js.map