UNPKG

@lcap/nasl

Version:

NetEase Application Specific Language

29 lines 1.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.transform2Enum = void 0; const utils_1 = require("./utils"); const transform2TypeAnnotation_1 = require("./transform2TypeAnnotation"); function transform2Enum(node, leadingComments) { const enumeration = new utils_1.naslTypes.Enum(); enumeration.name = node.id.name; enumeration.description = (0, utils_1.fetchFromComments)(leadingComments); enumeration.valueType = (0, transform2TypeAnnotation_1.transform2TypeAnnotation)(node.superTypeParameters.params[0]); node.body.body.forEach((item) => { const enumItem = new utils_1.naslTypes.EnumItem(); if (item.type === 'ClassProperty') { if (item.value.type === "NewExpression") { const args = item.value.arguments; const value = args[0].value; const label = args[1].value; enumItem.value = String(value); enumItem.label = new utils_1.naslTypes.StaticString({ value: label, }); enumeration.enumItems.push(enumItem); } } }); return enumeration; } exports.transform2Enum = transform2Enum; //# sourceMappingURL=transform2Enum.js.map