UNPKG

@abaplint/core

Version:
46 lines 2.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Constants = void 0; const Expressions = require("../../2_statements/expressions"); const Statements = require("../../2_statements/statements"); const Structures = require("../../3_structures/structures"); const nodes_1 = require("../../nodes"); const _typed_identifier_1 = require("../../types/_typed_identifier"); const Basic = require("../../types/basic"); const constant_1 = require("../statements/constant"); const assert_error_1 = require("../assert_error"); class Constants { runSyntax(node, input) { var _a; const name = (_a = node.findFirstExpression(Expressions.DefinitionName)) === null || _a === void 0 ? void 0 : _a.getFirstToken(); if (name === undefined) { throw new assert_error_1.AssertError("Constants, structure, unexpected node"); } const components = []; const values = {}; for (const c of node.getChildren()) { const ctyp = c.get(); if (c instanceof nodes_1.StatementNode && ctyp instanceof Statements.Constant) { const found = new constant_1.Constant().runSyntax(c, input); if (found) { components.push({ name: found.getName(), type: found.getType() }); values[found.getName()] = found.getValue(); } } else if (c instanceof nodes_1.StructureNode && ctyp instanceof Structures.Constants) { const { type: found, values: val } = new Constants().runSyntax(c, input); if (found) { components.push({ name: found.getName(), type: found.getType() }); values[found.getName()] = val; } } } if (components.length === 0) { return { type: undefined, values }; } const type = new _typed_identifier_1.TypedIdentifier(name, input.filename, new Basic.StructureType(components), ["read_only" /* IdentifierMeta.ReadOnly */, "static" /* IdentifierMeta.Static */]); return { type, values }; } } exports.Constants = Constants; //# sourceMappingURL=constants.js.map