UNPKG

@abaplint/core

Version:
66 lines 4.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Catch = void 0; const Expressions = require("../../2_statements/expressions"); const _typed_identifier_1 = require("../../types/_typed_identifier"); const unknown_type_1 = require("../../types/basic/unknown_type"); const basic_1 = require("../../types/basic"); const target_1 = require("../expressions/target"); const _reference_1 = require("../_reference"); const _syntax_input_1 = require("../_syntax_input"); class Catch { runSyntax(node, input) { var _a, _b; const names = new Set(); for (const c of node.findDirectExpressions(Expressions.ClassName)) { const token = c.getFirstToken(); const className = token.getStr().toUpperCase(); const found = input.scope.existsObject(className); if (found === null || found === void 0 ? void 0 : found.id) { input.scope.addReference(token, found.id, _reference_1.ReferenceType.ObjectOrientedReference, input.filename); } else if (input.scope.getDDIC().inErrorNamespace(className) === false) { const extra = { ooName: className, ooType: "Void" }; input.scope.addReference(token, undefined, _reference_1.ReferenceType.ObjectOrientedVoidReference, input.filename, extra); } else { const message = "CATCH, unknown class " + className; input.issues.push((0, _syntax_input_1.syntaxIssue)(input, token, message)); return; } if (names.has(className)) { const message = "Duplicate class name in CATCH: " + className; input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message)); return; } names.add(className); } const target = node.findDirectExpression(Expressions.Target); const firstClassName = (_a = node.findDirectExpression(Expressions.ClassName)) === null || _a === void 0 ? void 0 : _a.getFirstToken().getStr(); if (target === null || target === void 0 ? void 0 : target.findDirectExpression(Expressions.InlineData)) { const token = (_b = target.findFirstExpression(Expressions.TargetField)) === null || _b === void 0 ? void 0 : _b.getFirstToken(); const found = input.scope.existsObject(firstClassName); if (token && firstClassName && (found === null || found === void 0 ? void 0 : found.id)) { const identifier = new _typed_identifier_1.TypedIdentifier(token, input.filename, new basic_1.ObjectReferenceType(found.id), ["inline" /* IdentifierMeta.InlineDefinition */]); input.scope.addIdentifier(identifier); input.scope.addReference(token, identifier, _reference_1.ReferenceType.DataWriteReference, input.filename); } else if (token && input.scope.getDDIC().inErrorNamespace(firstClassName) === false) { const identifier = new _typed_identifier_1.TypedIdentifier(token, input.filename, basic_1.VoidType.get(firstClassName), ["inline" /* IdentifierMeta.InlineDefinition */]); input.scope.addIdentifier(identifier); input.scope.addReference(token, identifier, _reference_1.ReferenceType.DataWriteReference, input.filename); } else if (token) { const message = "Catch, could not determine type for \"" + token.getStr() + "\""; const identifier = new _typed_identifier_1.TypedIdentifier(token, input.filename, new unknown_type_1.UnknownType(message), ["inline" /* IdentifierMeta.InlineDefinition */]); input.scope.addIdentifier(identifier); input.scope.addReference(token, identifier, _reference_1.ReferenceType.DataWriteReference, input.filename); } } else if (target) { target_1.Target.runSyntax(target, input); } } } exports.Catch = Catch; //# sourceMappingURL=catch.js.map