UNPKG

@abaplint/core

Version:
51 lines 2.36 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Move = void 0; const Expressions = require("../../2_statements/expressions"); const source_1 = require("../expressions/source"); const target_1 = require("../expressions/target"); const inline_data_1 = require("../expressions/inline_data"); const _type_utils_1 = require("../_type_utils"); const _syntax_input_1 = require("../_syntax_input"); class Move { runSyntax(node, input) { const targets = node.findDirectExpressions(Expressions.Target); const firstTarget = targets[0]; const inline = firstTarget === null || firstTarget === void 0 ? void 0 : firstTarget.findDirectExpression(Expressions.InlineData); let targetType = undefined; if (inline === undefined) { targetType = firstTarget ? target_1.Target.runSyntax(firstTarget, input) : undefined; for (const t of targets) { if (t === firstTarget) { continue; } target_1.Target.runSyntax(t, input); } } const source = node.findDirectExpression(Expressions.Source); const sourceType = source ? source_1.Source.runSyntax(source, input, targetType) : undefined; if (sourceType === undefined) { const message = "No source type determined"; input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message)); return; } if (inline) { inline_data_1.InlineData.runSyntax(inline, input, sourceType); targetType = sourceType; } if (node.findDirectTokenByText("?=")) { if (new _type_utils_1.TypeUtils(input.scope).isCastable(sourceType, targetType) === false) { const message = "Incompatible types"; input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message)); return; } } else if (new _type_utils_1.TypeUtils(input.scope).isAssignable(sourceType, targetType) === false) { const message = "Incompatible types"; input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message)); return; } } } exports.Move = Move; //# sourceMappingURL=move.js.map