UNPKG

@abaplint/core

Version:
45 lines 2.38 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Parameter = void 0; const Expressions = require("../../2_statements/expressions"); const _typed_identifier_1 = require("../../types/_typed_identifier"); const basic_1 = require("../../types/basic"); const basic_types_1 = require("../basic_types"); const _syntax_input_1 = require("../_syntax_input"); const tokens_1 = require("../../1_lexer/tokens"); class Parameter { runSyntax(node, input) { const nameExpression = node.findFirstExpression(Expressions.FieldSub); if (nameExpression === undefined) { return; } let nameToken = nameExpression.getFirstToken(); // FieldSub can include dashes and optional length, eg p-tcode or p_table(4). if (nameExpression.getChildren().length > 1) { const fullName = nameExpression.concatTokens().replace(/\(.+$/, "").replace(/\[\]$/, ""); nameToken = new tokens_1.Identifier(nameToken.getStart(), fullName); } if (nameToken && nameToken.getStr().length > 8) { const message = "Parameter name too long, " + nameToken.getStr(); input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message)); return; } if (node.findDirectTokenByText("RADIOBUTTON") && node.findDirectTokenByText("LENGTH")) { const message = "RADIOBUTTON and LENGTH not possible together"; input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message)); return; } const bfound = new basic_types_1.BasicTypes(input).parseType(node); if (bfound) { input.scope.addIdentifier(new _typed_identifier_1.TypedIdentifier(nameToken, input.filename, bfound)); } else { input.scope.addIdentifier(new _typed_identifier_1.TypedIdentifier(nameToken, input.filename, new basic_1.UnknownType("Parameter, fallback"))); } const magicName = "%_" + nameToken.getStr() + "_%_app_%"; const magicToken = new tokens_1.Identifier(nameToken.getStart(), magicName); input.scope.addIdentifier(new _typed_identifier_1.TypedIdentifier(magicToken, input.filename, basic_1.VoidType.get("PARAMETER-MAGIC"))); } } exports.Parameter = Parameter; //# sourceMappingURL=parameter.js.map