UNPKG

decaffeinate-parser

Version:

A better AST for CoffeeScript, inspired by CoffeeScriptRedux.

20 lines (19 loc) 1.11 kB
"use strict"; exports.__esModule = true; var nodes_1 = require("../nodes"); var getLocation_1 = require("../util/getLocation"); var mapAny_1 = require("./mapAny"); var mapPossiblyEmptyBlock_1 = require("./mapPossiblyEmptyBlock"); function mapClass(context, node) { var _a = getLocation_1["default"](context, node), line = _a.line, column = _a.column, start = _a.start, end = _a.end, raw = _a.raw; var nameAssignee = node.variable ? mapAny_1["default"](context, node.variable) : null; var parent = node.parent ? mapAny_1["default"](context, node.parent) : null; var childContext = context.updateState(function (s) { return s.pushCurrentClass(); }); var body = mapPossiblyEmptyBlock_1["default"](childContext, node.body); var boundMethods = childContext.parseState.currentClassBoundMethods; if (!boundMethods) { throw new Error('Expected a non-null bound method name array.'); } return new nodes_1.Class(line, column, start, end, raw, nameAssignee, nameAssignee, body, boundMethods, parent, childContext.parseState.currentClassCtor); } exports["default"] = mapClass;