@abaplint/transpiler-cli 2.2.6 → 2.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/bundle.js +3 -3
- package/package.json +2 -2
package/build/bundle.js
CHANGED
|
@@ -13205,7 +13205,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
|
|
|
13205
13205
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
13206
13206
|
|
|
13207
13207
|
"use strict";
|
|
13208
|
-
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.DatabaseSetup = void 0;\r\n/* eslint-disable max-len */\r\nconst abaplint = __webpack_require__(/*! @abaplint/core */ \"./node_modules/@abaplint/core/build/src/index.js\");\r\nconst sqlite_database_schema_1 = __webpack_require__(/*! ./sqlite_database_schema */ \"./node_modules/@abaplint/transpiler/build/src/db/sqlite_database_schema.js\");\r\nclass DatabaseSetup {\r\n constructor(reg) {\r\n this.reg = reg;\r\n }\r\n run() {\r\n return {\r\n schemas: {\r\n sqlite: new sqlite_database_schema_1.SQLiteDatabaseSchema(this.reg).run(),\r\n hdb: [\"todo\"],\r\n pg: [\"todo\"],\r\n },\r\n insert: this.buildInsert(),\r\n };\r\n }\r\n ////////////////////\r\n buildInsert() {\r\n // note: avoid hitting maximum statement size by splitting into multiple statements\r\n const insert = [];\r\n // INSERT data\r\n for (const obj of this.reg.getObjects()) {\r\n if (obj instanceof abaplint.Objects.MessageClass) {\r\n insert.push(this.insertT100(obj));\r\n }\r\n else if (obj instanceof abaplint.Objects.Class\r\n || obj instanceof abaplint.Objects.Interface) {\r\n insert.push(this.insertREPOSRC(obj));\r\n }\r\n }\r\n insert.push(this.insertT000());\r\n return insert;\r\n }\r\n insertREPOSRC(obj) {\r\n var _a;\r\n if (this.reg.getObject(\"TABL\", \"REPOSRC\") === undefined) {\r\n return \"\";\r\n }\r\n const name = obj.getName().toUpperCase();\r\n const raw = (_a = obj.getMainABAPFile()) === null || _a === void 0 ? void 0 : _a.getRaw();\r\n if (raw === undefined) {\r\n return \"\";\r\n }\r\n return `INSERT INTO reposrc ('PROGNAME', 'DATA') VALUES ('${name}', '${this.escape(raw)}');`;\r\n }\r\n insertT000() {\r\n const tabl = this.reg.getObject(\"TABL\", \"T000\");\r\n if (tabl === undefined) {\r\n return \"\";\r\n }\r\n const type = tabl.parseType(this.reg);\r\n if (type instanceof abaplint.BasicTypes.StructureType && type.getComponents().length >= 3) {\r\n // todo, this should take the client number from the settings\r\n return `INSERT INTO t000 ('MANDT', 'CCCATEGORY', 'CCNOCLIIND') VALUES ('123', '', '');`;\r\n }\r\n else {\r\n return \"\";\r\n }\r\n }\r\n insertT100(msag) {\r\n // ignore if T100 is unknown\r\n if (this.reg.getObject(\"TABL\", \"T100\") === undefined) {\r\n return \"\";\r\n }\r\n let ret = \"\";\r\n for (const m of msag.getMessages()) {\r\n ret += `INSERT INTO t100 ('SPRSL', 'ARBGB', 'MSGNR', 'TEXT') VALUES ('E', '${msag.getName()}', '${m.getNumber()}', '${this.escape(m.getMessage())}');`;\r\n }\r\n return ret;\r\n }\r\n escape(value) {\r\n let ret = value.replace(/\\'/g, \"''\");\r\n // statements are inside a javascript string stemplate\r\n ret = ret.replace(/\\\\/g, \"\\\\\\\\\");\r\n ret = ret.replace(/`/g, \"\\\\`\");\r\n return ret;\r\n }\r\n}\r\nexports.DatabaseSetup = DatabaseSetup;\r\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@abaplint/transpiler-cli/./node_modules/@abaplint/transpiler/build/src/db/index.js?");
|
|
13208
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.DatabaseSetup = void 0;\r\n/* eslint-disable max-len */\r\nconst abaplint = __webpack_require__(/*! @abaplint/core */ \"./node_modules/@abaplint/core/build/src/index.js\");\r\nconst sqlite_database_schema_1 = __webpack_require__(/*! ./sqlite_database_schema */ \"./node_modules/@abaplint/transpiler/build/src/db/sqlite_database_schema.js\");\r\nclass DatabaseSetup {\r\n constructor(reg) {\r\n this.reg = reg;\r\n }\r\n run() {\r\n return {\r\n schemas: {\r\n sqlite: new sqlite_database_schema_1.SQLiteDatabaseSchema(this.reg).run(),\r\n hdb: [\"todo\"],\r\n pg: [\"todo\"],\r\n },\r\n insert: this.buildInsert(),\r\n };\r\n }\r\n ////////////////////\r\n buildInsert() {\r\n // note: avoid hitting maximum statement size by splitting into multiple statements\r\n const insert = [];\r\n // INSERT data\r\n for (const obj of this.reg.getObjects()) {\r\n if (obj instanceof abaplint.Objects.MessageClass) {\r\n insert.push(this.insertT100(obj));\r\n }\r\n else if (obj instanceof abaplint.Objects.Class\r\n || obj instanceof abaplint.Objects.Interface) {\r\n insert.push(this.insertREPOSRC(obj));\r\n }\r\n }\r\n insert.push(this.insertT000());\r\n return insert;\r\n }\r\n insertREPOSRC(obj) {\r\n var _a;\r\n if (this.reg.getObject(\"TABL\", \"REPOSRC\") === undefined) {\r\n return \"\";\r\n }\r\n const name = obj.getName().toUpperCase();\r\n const raw = (_a = obj.getMainABAPFile()) === null || _a === void 0 ? void 0 : _a.getRaw();\r\n if (raw === undefined) {\r\n return \"\";\r\n }\r\n return `INSERT INTO reposrc ('PROGNAME', 'DATA') VALUES ('${name}', '${this.escape(raw)}');`;\r\n }\r\n insertT000() {\r\n const tabl = this.reg.getObject(\"TABL\", \"T000\");\r\n if (tabl === undefined) {\r\n return \"\";\r\n }\r\n const type = tabl.parseType(this.reg);\r\n if (type instanceof abaplint.BasicTypes.StructureType && type.getComponents().length >= 3) {\r\n // todo, this should take the client number from the settings\r\n return `INSERT INTO t000 ('MANDT', 'CCCATEGORY', 'CCNOCLIIND') VALUES ('123', '', '');`;\r\n }\r\n else {\r\n return \"\";\r\n }\r\n }\r\n insertT100(msag) {\r\n // ignore if T100 is unknown\r\n if (this.reg.getObject(\"TABL\", \"T100\") === undefined) {\r\n return \"\";\r\n }\r\n let ret = \"\";\r\n for (const m of msag.getMessages()) {\r\n ret += `INSERT INTO t100 ('SPRSL', 'ARBGB', 'MSGNR', 'TEXT') VALUES ('E', '${msag.getName()}', '${m.getNumber()}', '${this.escape(m.getMessage())}');`;\r\n }\r\n return ret;\r\n }\r\n escape(value) {\r\n let ret = value.replace(/\\'/g, \"''\");\r\n // statements are inside a javascript string stemplate\r\n ret = ret.replace(/\\\\/g, \"\\\\\\\\\");\r\n ret = ret.replace(/`/g, \"\\\\`\");\r\n ret = ret.replace(/\\${/g, \"\\\\${\");\r\n return ret;\r\n }\r\n}\r\nexports.DatabaseSetup = DatabaseSetup;\r\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@abaplint/transpiler-cli/./node_modules/@abaplint/transpiler/build/src/db/index.js?");
|
|
13209
13209
|
|
|
13210
13210
|
/***/ }),
|
|
13211
13211
|
|
|
@@ -13216,7 +13216,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
|
|
|
13216
13216
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
13217
13217
|
|
|
13218
13218
|
"use strict";
|
|
13219
|
-
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.SQLiteDatabaseSchema = void 0;\r\nconst abaplint = __webpack_require__(/*! @abaplint/core */ \"./node_modules/@abaplint/core/build/src/index.js\");\r\nclass SQLiteDatabaseSchema {\r\n constructor(reg) {\r\n this.reg = reg;\r\n }\r\n run() {\r\n const statements = [];\r\n // CREATE TABLEs\r\n for (const obj of this.reg.getObjects()) {\r\n if (obj instanceof abaplint.Objects.Table\r\n && obj.getTableCategory() === abaplint.Objects.TableCategory.Transparent) {\r\n statements.push(this.buildTABL(obj).trim());\r\n }\r\n }\r\n // CREATE VIEWs after TABLEs\r\n // todo: what if the view is based on another view?\r\n for (const obj of this.reg.getObjects()) {\r\n if (obj instanceof abaplint.Objects.View) {\r\n statements.push(this.buildVIEW(obj).trim());\r\n }\r\n }\r\n return statements;\r\n }\r\n //////////////////\r\n // https://www.sqlite.org/lang_createview.html\r\n buildVIEW(view) {\r\n const fields = view.getFields();\r\n const columns = fields === null || fields === void 0 ? void 0 : fields.map((f) => f.TABNAME.toLowerCase() + \".\" + f.FIELDNAME.toLowerCase() + \" AS \" + f.VIEWFIELD.toLowerCase()).join(\", \");\r\n let from = \"\";\r\n let previous = \"\";\r\n for (const j of view.getJoin() || []) {\r\n if (previous === \"\") {\r\n from += j.LTAB.toLowerCase() + \" INNER JOIN \" + j.RTAB.toLowerCase() + \" ON \" + j.LTAB.toLowerCase() + \".\" + j.LFIELD.toLowerCase() + \" = \" + j.RTAB.toLowerCase() + \".\" + j.RFIELD.toLowerCase();\r\n }\r\n else if (previous === j.LTAB + \",\" + j.RTAB) {\r\n from += \" AND \" + j.LTAB.toLowerCase() + \".\" + j.LFIELD.toLowerCase() + \" = \" + j.RTAB.toLowerCase() + \".\" + j.RFIELD.toLowerCase();\r\n }\r\n else {\r\n from += \" INNER JOIN \" + j.RTAB.toLowerCase() + \" ON \" + j.LTAB.toLowerCase() + \".\" + j.LFIELD.toLowerCase() + \" = \" + j.RTAB.toLowerCase() + \".\" + j.RFIELD.toLowerCase();\r\n }\r\n previous = j.LTAB + \",\" + j.RTAB;\r\n }\r\n from = from.trim();\r\n return `CREATE VIEW ${view.getName().toLowerCase()} AS SELECT ${columns} FROM ${from};\\n`;\r\n }\r\n buildTABL(tabl) {\r\n const type = tabl.parseType(this.reg);\r\n if (!(type instanceof abaplint.BasicTypes.StructureType)) {\r\n return \"\";\r\n }\r\n const fields = [];\r\n for (const field of type.getComponents()) {\r\n fields.push(\"'\" + field.name.toLowerCase() + \"' \" + this.toType(field.type, field.name, tabl.getName()));\r\n }\r\n // assumption: all transparent tables have primary keys\r\n // add single quotes to field names to allow for keywords as field names\r\n const key = \", PRIMARY KEY(\" + tabl.listKeys().map(e => \"'\" + e.toLowerCase() + \"'\").join(\",\") + \")\";\r\n return `CREATE TABLE ${tabl.getName().toLowerCase()} (${fields.join(\", \")}${key});\\n`;\r\n }\r\n toType(type, fieldname, errorInfo) {\r\n if (type instanceof abaplint.BasicTypes.CharacterType) {\r\n return `NCHAR(${type.getLength()})`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.TimeType) {\r\n return `NCHAR(6)`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.DateType) {\r\n return `NCHAR(8)`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.NumericType) {\r\n // it will be fine, the runtime representation of numc is also text\r\n return `NCHAR(${type.getLength()})`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.StringType) {\r\n return `TEXT`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.XStringType) {\r\n // it will be fine, the runtime representation of xstring is also text\r\n return `TEXT`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.HexType) {\r\n return `NCHAR(${type.getLength() * 2})`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.IntegerType) {\r\n return `INT`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.FloatType\r\n || type instanceof abaplint.BasicTypes.FloatingPointType) {\r\n return `REAL`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.PackedType) {\r\n return `DECIMAL(${type.getLength()},${type.getDecimals()})`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.VoidType) {\r\n throw `Type of ${errorInfo}-${fieldname} is VoidType(${type.getVoided()}), make sure the type is known, enable strict syntax checking`;\r\n }\r\n else {\r\n throw \"database_setup: \" + errorInfo + \"-\" + fieldname + \", todo toType handle: \" + type.constructor.name;\r\n }\r\n }\r\n}\r\nexports.SQLiteDatabaseSchema = SQLiteDatabaseSchema;\r\n//# sourceMappingURL=sqlite_database_schema.js.map\n\n//# sourceURL=webpack://@abaplint/transpiler-cli/./node_modules/@abaplint/transpiler/build/src/db/sqlite_database_schema.js?");
|
|
13219
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.SQLiteDatabaseSchema = void 0;\r\nconst abaplint = __webpack_require__(/*! @abaplint/core */ \"./node_modules/@abaplint/core/build/src/index.js\");\r\nclass SQLiteDatabaseSchema {\r\n constructor(reg) {\r\n this.reg = reg;\r\n }\r\n run() {\r\n const statements = [];\r\n // CREATE TABLEs\r\n for (const obj of this.reg.getObjects()) {\r\n if (obj instanceof abaplint.Objects.Table\r\n && obj.getTableCategory() === abaplint.Objects.TableCategory.Transparent) {\r\n statements.push(this.buildTABL(obj).trim());\r\n }\r\n }\r\n // CREATE VIEWs after TABLEs\r\n // todo: what if the view is based on another view?\r\n for (const obj of this.reg.getObjects()) {\r\n if (obj instanceof abaplint.Objects.View) {\r\n statements.push(this.buildVIEW(obj).trim());\r\n }\r\n }\r\n return statements;\r\n }\r\n //////////////////\r\n // https://www.sqlite.org/lang_createview.html\r\n buildVIEW(view) {\r\n const fields = view.getFields();\r\n const columns = fields === null || fields === void 0 ? void 0 : fields.map((f) => f.TABNAME.toLowerCase() + \".\" + f.FIELDNAME.toLowerCase() + \" AS \" + f.VIEWFIELD.toLowerCase()).join(\", \");\r\n let from = \"\";\r\n let previous = \"\";\r\n for (const j of view.getJoin() || []) {\r\n if (previous === \"\") {\r\n from += j.LTAB.toLowerCase() + \" INNER JOIN \" + j.RTAB.toLowerCase() + \" ON \" + j.LTAB.toLowerCase() + \".\" + j.LFIELD.toLowerCase() + \" = \" + j.RTAB.toLowerCase() + \".\" + j.RFIELD.toLowerCase();\r\n }\r\n else if (previous === j.LTAB + \",\" + j.RTAB) {\r\n from += \" AND \" + j.LTAB.toLowerCase() + \".\" + j.LFIELD.toLowerCase() + \" = \" + j.RTAB.toLowerCase() + \".\" + j.RFIELD.toLowerCase();\r\n }\r\n else {\r\n from += \" INNER JOIN \" + j.RTAB.toLowerCase() + \" ON \" + j.LTAB.toLowerCase() + \".\" + j.LFIELD.toLowerCase() + \" = \" + j.RTAB.toLowerCase() + \".\" + j.RFIELD.toLowerCase();\r\n }\r\n previous = j.LTAB + \",\" + j.RTAB;\r\n }\r\n from = from.trim();\r\n return `CREATE VIEW '${view.getName().toLowerCase()}' AS SELECT ${columns} FROM ${from};\\n`;\r\n }\r\n buildTABL(tabl) {\r\n const type = tabl.parseType(this.reg);\r\n if (!(type instanceof abaplint.BasicTypes.StructureType)) {\r\n return \"\";\r\n }\r\n const fields = [];\r\n for (const field of type.getComponents()) {\r\n fields.push(\"'\" + field.name.toLowerCase() + \"' \" + this.toType(field.type, field.name, tabl.getName()));\r\n }\r\n // assumption: all transparent tables have primary keys\r\n // add single quotes to field names to allow for keywords as field names\r\n const key = \", PRIMARY KEY(\" + tabl.listKeys().map(e => \"'\" + e.toLowerCase() + \"'\").join(\",\") + \")\";\r\n return `CREATE TABLE '${tabl.getName().toLowerCase()}' (${fields.join(\", \")}${key});\\n`;\r\n }\r\n toType(type, fieldname, errorInfo) {\r\n if (type instanceof abaplint.BasicTypes.CharacterType) {\r\n return `NCHAR(${type.getLength()})`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.TimeType) {\r\n return `NCHAR(6)`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.DateType) {\r\n return `NCHAR(8)`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.NumericType) {\r\n // it will be fine, the runtime representation of numc is also text\r\n return `NCHAR(${type.getLength()})`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.StringType) {\r\n return `TEXT`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.XStringType) {\r\n // it will be fine, the runtime representation of xstring is also text\r\n return `TEXT`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.HexType) {\r\n return `NCHAR(${type.getLength() * 2})`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.IntegerType) {\r\n return `INT`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.FloatType\r\n || type instanceof abaplint.BasicTypes.FloatingPointType) {\r\n return `REAL`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.PackedType) {\r\n return `DECIMAL(${type.getLength()},${type.getDecimals()})`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.VoidType) {\r\n throw `Type of ${errorInfo}-${fieldname} is VoidType(${type.getVoided()}), make sure the type is known, enable strict syntax checking`;\r\n }\r\n else {\r\n throw \"database_setup: \" + errorInfo + \"-\" + fieldname + \", todo toType handle: \" + type.constructor.name;\r\n }\r\n }\r\n}\r\nexports.SQLiteDatabaseSchema = SQLiteDatabaseSchema;\r\n//# sourceMappingURL=sqlite_database_schema.js.map\n\n//# sourceURL=webpack://@abaplint/transpiler-cli/./node_modules/@abaplint/transpiler/build/src/db/sqlite_database_schema.js?");
|
|
13220
13220
|
|
|
13221
13221
|
/***/ }),
|
|
13222
13222
|
|
|
@@ -15295,7 +15295,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
|
|
|
15295
15295
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
15296
15296
|
|
|
15297
15297
|
"use strict";
|
|
15298
|
-
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.TryTranspiler = void 0;\r\nconst abaplint = __webpack_require__(/*! @abaplint/core */ \"./node_modules/@abaplint/core/build/src/index.js\");\r\nconst chunk_1 = __webpack_require__(/*! ../chunk */ \"./node_modules/@abaplint/transpiler/build/src/chunk.js\");\r\nclass TryTranspiler {\r\n transpile(node, traversal) {\r\n const ret = new chunk_1.Chunk();\r\n const catches = node.findDirectStructures(abaplint.Structures.Catch);\r\n let catchCode = this.buildCatchCode(catches, traversal);\r\n for (const c of node.getChildren()) {\r\n if (c.get() instanceof abaplint.Structures.Catch) {\r\n if (catchCode) {\r\n ret.appendChunk(catchCode);\r\n }\r\n catchCode = undefined;\r\n }\r\n else if (c.get() instanceof abaplint.Structures.Cleanup) {\r\n ret.appendString(`} finally {\\n// Transpiler todo: CLEANUP ignored\\n`);\r\n }\r\n else {\r\n ret.appendChunk(traversal.traverse(c));\r\n }\r\n }\r\n return ret;\r\n }\r\n buildCatchCode(nodes, traversal) {\r\n let ret = \"\";\r\n let first = true;\r\n if (nodes.length === 0) {\r\n return new chunk_1.Chunk(ret);\r\n }\r\n ret += `} catch (e) {\\n`;\r\n for (const n of nodes) {\r\n const catchStatement = n.findDirectStatement(abaplint.Statements.Catch);\r\n if (catchStatement === undefined) {\r\n throw \"TryTranspiler, unexpected structure\";\r\n }\r\n const catchNames = catchStatement.findDirectExpressions(abaplint.Expressions.ClassName).map(e => traversal.lookupClassOrInterface(e.concatTokens(), e.getFirstToken()));\r\n ret += first ? \"\" : \" else \";\r\n first = false;\r\n ret += \"if (\" + (catchNames === null || catchNames === void 0 ? void 0 : catchNames.map(n => \"e instanceof \" + n).join(\" || \")) + \") {\\n\";\r\n const intoNode = catchStatement.findExpressionAfterToken(\"INTO\");\r\n if (intoNode) {\r\n ret += traversal.traverse(intoNode).getCode() + \".set(e);\\n\";\r\n }\r\n const body = n.findDirectStructure(abaplint.Structures.Body);\r\n if (body) {\r\n ret += traversal.traverse(body).getCode();\r\n }\r\n ret += \"}\";\r\n }\r\n // \"else\" unhandled in this TRY-CATCH, or a javascript runtime error\r\n ret += ` else {\\n` +\r\n `throw e;\\n` +\r\n `}\\n`;\r\n return new chunk_1.Chunk(ret);\r\n }\r\n}\r\nexports.TryTranspiler = TryTranspiler;\r\n//# sourceMappingURL=try.js.map\n\n//# sourceURL=webpack://@abaplint/transpiler-cli/./node_modules/@abaplint/transpiler/build/src/structures/try.js?");
|
|
15298
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.TryTranspiler = void 0;\r\nconst abaplint = __webpack_require__(/*! @abaplint/core */ \"./node_modules/@abaplint/core/build/src/index.js\");\r\nconst chunk_1 = __webpack_require__(/*! ../chunk */ \"./node_modules/@abaplint/transpiler/build/src/chunk.js\");\r\nclass TryTranspiler {\r\n transpile(node, traversal) {\r\n const ret = new chunk_1.Chunk();\r\n const catches = node.findDirectStructures(abaplint.Structures.Catch);\r\n const cleanup = node.findDirectStructures(abaplint.Structures.Cleanup);\r\n let catchCode = this.buildCatchCode(catches, traversal);\r\n for (const c of node.getChildren()) {\r\n if (c.get() instanceof abaplint.Structures.Catch) {\r\n if (catchCode) {\r\n ret.appendChunk(catchCode);\r\n }\r\n catchCode = undefined;\r\n }\r\n else if (c.get() instanceof abaplint.Structures.Cleanup) {\r\n ret.appendString(`} finally {\\n// Transpiler todo: CLEANUP ignored\\n`);\r\n }\r\n else if (c.get() instanceof abaplint.Statements.Try\r\n || c.get() instanceof abaplint.Statements.EndTry) {\r\n if (catches.length === 0 && cleanup.length === 0) {\r\n continue;\r\n }\r\n ret.appendChunk(traversal.traverse(c));\r\n }\r\n else {\r\n ret.appendChunk(traversal.traverse(c));\r\n }\r\n }\r\n return ret;\r\n }\r\n /////////////////////\r\n buildCatchCode(nodes, traversal) {\r\n let ret = \"\";\r\n let first = true;\r\n if (nodes.length === 0) {\r\n return new chunk_1.Chunk(ret);\r\n }\r\n ret += `} catch (e) {\\n`;\r\n for (const n of nodes) {\r\n const catchStatement = n.findDirectStatement(abaplint.Statements.Catch);\r\n if (catchStatement === undefined) {\r\n throw \"TryTranspiler, unexpected structure\";\r\n }\r\n const catchNames = catchStatement.findDirectExpressions(abaplint.Expressions.ClassName).map(e => traversal.lookupClassOrInterface(e.concatTokens(), e.getFirstToken()));\r\n ret += first ? \"\" : \" else \";\r\n first = false;\r\n ret += \"if (\" + (catchNames === null || catchNames === void 0 ? void 0 : catchNames.map(n => \"e instanceof \" + n).join(\" || \")) + \") {\\n\";\r\n const intoNode = catchStatement.findExpressionAfterToken(\"INTO\");\r\n if (intoNode) {\r\n ret += traversal.traverse(intoNode).getCode() + \".set(e);\\n\";\r\n }\r\n const body = n.findDirectStructure(abaplint.Structures.Body);\r\n if (body) {\r\n ret += traversal.traverse(body).getCode();\r\n }\r\n ret += \"}\";\r\n }\r\n // \"else\" unhandled in this TRY-CATCH, or a javascript runtime error\r\n ret += ` else {\\n` +\r\n `throw e;\\n` +\r\n `}\\n`;\r\n return new chunk_1.Chunk(ret);\r\n }\r\n}\r\nexports.TryTranspiler = TryTranspiler;\r\n//# sourceMappingURL=try.js.map\n\n//# sourceURL=webpack://@abaplint/transpiler-cli/./node_modules/@abaplint/transpiler/build/src/structures/try.js?");
|
|
15299
15299
|
|
|
15300
15300
|
/***/ }),
|
|
15301
15301
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/transpiler-cli",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.8",
|
|
4
4
|
"description": "Transpiler - Command Line Interface",
|
|
5
5
|
"bin": {
|
|
6
6
|
"abap_transpile": "./abap_transpile"
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"author": "abaplint",
|
|
26
26
|
"license": "MIT",
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@abaplint/transpiler": "^2.2.
|
|
28
|
+
"@abaplint/transpiler": "^2.2.8",
|
|
29
29
|
"@types/glob": "^7.2.0",
|
|
30
30
|
"glob": "=7.2.0",
|
|
31
31
|
"@types/progress": "^2.0.5",
|