UNPKG

@abaplint/transpiler

Version:
34 lines 1.46 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CastTranspiler = void 0; const core_1 = require("@abaplint/core"); const chunk_1 = require("../chunk"); const type_name_or_infer_1 = require("./type_name_or_infer"); const transpile_types_1 = require("../transpile_types"); class CastTranspiler { transpile(node, traversal) { const ret = new chunk_1.Chunk(); const source = node.findDirectExpression(core_1.Expressions.Source); if (source === undefined) { throw new Error("CastTranspiler, Source not found"); } const tni = node.findDirectExpression(core_1.Expressions.TypeNameOrInfer); if (tni === undefined) { throw new Error("CastTranspiler, TypeNameOrInfer not found"); } const type = new type_name_or_infer_1.TypeNameOrInfer().findType(tni, traversal); const target = transpile_types_1.TranspileTypes.toType(type); const lett = node.findDirectExpression(core_1.Expressions.Let); if (lett !== undefined) { throw new Error("CastTranspiler, Let todo"); } ret.appendString("(await abap.statements.cast(") .appendString(target) .appendString(", ") .appendChunk(traversal.traverse(source)) .append("))", node.getLastToken(), traversal); return ret; } } exports.CastTranspiler = CastTranspiler; //# sourceMappingURL=cast.js.map