UNPKG

@abaplint/core

Version:
68 lines 4.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Assign = void 0; const Expressions = require("../../2_statements/expressions"); const source_1 = require("../expressions/source"); const fstarget_1 = require("../expressions/fstarget"); const basic_1 = require("../../types/basic"); const dynamic_1 = require("../expressions/dynamic"); const _type_utils_1 = require("../_type_utils"); const _syntax_input_1 = require("../_syntax_input"); class Assign { runSyntax(node, input) { var _a, _b; const assignSource = node.findDirectExpression(Expressions.AssignSource); const sources = (assignSource === null || assignSource === void 0 ? void 0 : assignSource.findDirectExpressionsMulti([Expressions.Source, Expressions.SimpleSource3])) || []; const theSource = sources[sources.length - 1]; let sourceType = undefined; const firstAssign = assignSource === null || assignSource === void 0 ? void 0 : assignSource.getChildren()[0]; const secondAssign = assignSource === null || assignSource === void 0 ? void 0 : assignSource.getChildren()[1]; const thirdAssign = assignSource === null || assignSource === void 0 ? void 0 : assignSource.getChildren()[2]; if ((secondAssign === null || secondAssign === void 0 ? void 0 : secondAssign.concatTokens()) === "=>" && firstAssign && (thirdAssign === null || thirdAssign === void 0 ? void 0 : thirdAssign.get()) instanceof Expressions.Dynamic) { const name = firstAssign.concatTokens(); const found = input.scope.findClassDefinition(name) || input.scope.findVariable(name); if (found === undefined && input.scope.getDDIC().inErrorNamespace(name) && name.startsWith("(") === false) { const message = name + " not found, dynamic"; input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message)); return; } sourceType = basic_1.VoidType.get("Dynamic"); } else { sourceType = source_1.Source.runSyntax(theSource, input, undefined, false, true); } if ((assignSource === null || assignSource === void 0 ? void 0 : assignSource.getChildren().length) === 5 && ((_a = assignSource === null || assignSource === void 0 ? void 0 : assignSource.getFirstChild()) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase()) === "COMPONENT") { const componentSource = sources[sources.length - 2]; const componentType = source_1.Source.runSyntax(componentSource, input); if (new _type_utils_1.TypeUtils(input.scope).isAssignable(componentType, new basic_1.CharacterType(30)) === false) { const message = "component name must be charlike"; input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message)); return; } } if (sourceType === undefined || (assignSource === null || assignSource === void 0 ? void 0 : assignSource.findDirectExpression(Expressions.Dynamic))) { sourceType = basic_1.AnyType.get(); } for (const d of (assignSource === null || assignSource === void 0 ? void 0 : assignSource.findAllExpressions(Expressions.Dynamic)) || []) { dynamic_1.Dynamic.runSyntax(d, input); } const target = node.findDirectExpression(Expressions.FSTarget); if (target) { if (((_b = assignSource === null || assignSource === void 0 ? void 0 : assignSource.getFirstChild()) === null || _b === void 0 ? void 0 : _b.concatTokens().toUpperCase()) === "COMPONENT") { fstarget_1.FSTarget.runSyntax(target, input, basic_1.AnyType.get()); } else { fstarget_1.FSTarget.runSyntax(target, input, sourceType); } } for (const s of node.findAllExpressions(Expressions.Source)) { if (s === theSource) { continue; } source_1.Source.runSyntax(s, input); } } } exports.Assign = Assign; //# sourceMappingURL=assign.js.map