UNPKG

@abaplint/core

Version:
66 lines 2.58 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ReduceBody = void 0; const Expressions = require("../../2_statements/expressions"); const for_1 = require("./for"); const source_1 = require("./source"); const inline_field_definition_1 = require("./inline_field_definition"); const unknown_type_1 = require("../../types/basic/unknown_type"); const reduce_next_1 = require("./reduce_next"); const let_1 = require("./let"); const _scope_type_1 = require("../_scope_type"); class ReduceBody { static runSyntax(node, input, targetType) { if (node === undefined) { return; } let scoped = false; const letNode = node.findDirectExpression(Expressions.Let); if (letNode) { scoped = let_1.Let.runSyntax(letNode, input); } let first = undefined; for (const i of node.findDirectExpressions(Expressions.InlineFieldDefinition)) { if (scoped === false) { input.scope.push(_scope_type_1.ScopeType.Let, "LET", node.getFirstToken().getStart(), input.filename); scoped = true; } let foundType = targetType; const source = i.findDirectExpression(Expressions.Source); if (source) { foundType = source_1.Source.runSyntax(source, input, targetType); } const found = inline_field_definition_1.InlineFieldDefinition.runSyntax(i, input, foundType); if (found && first === undefined) { first = found; } } let forScopes = 0; for (const forNode of node.findDirectExpressions(Expressions.For) || []) { const scoped = for_1.For.runSyntax(forNode, input); if (scoped === true) { forScopes++; } } for (const s of node.findDirectExpressions(Expressions.Source)) { source_1.Source.runSyntax(s, input); } for (const s of node.findDirectExpressions(Expressions.ReduceNext)) { reduce_next_1.ReduceNext.runSyntax(s, input); } if (scoped === true) { input.scope.pop(node.getLastToken().getEnd()); } for (let i = 0; i < forScopes; i++) { input.scope.pop(node.getLastToken().getEnd()); } if (first) { return first; } else { return new unknown_type_1.UnknownType("todo, ReduceBody"); } } } exports.ReduceBody = ReduceBody; //# sourceMappingURL=reduce_body.js.map