@abaplint/transpiler
Version:
34 lines • 1.71 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ValueBodyLineTranspiler = void 0;
const core_1 = require("@abaplint/core");
const chunk_1 = require("../chunk");
const transpile_types_1 = require("../transpile_types");
const field_assignment_1 = require("./field_assignment");
const source_1 = require("./source");
class ValueBodyLineTranspiler {
transpile(rowType, line, traversal, extraFields) {
const ret = new chunk_1.Chunk();
ret.appendString(`.appendThis(${transpile_types_1.TranspileTypes.toType(rowType)}`);
for (const child of line.getChildren()) {
if (child instanceof core_1.Nodes.TokenNode) {
// last or first parenthesis
continue;
}
else if (child.get() instanceof core_1.Expressions.FieldAssignment && child instanceof core_1.Nodes.ExpressionNode) {
ret.appendString(new field_assignment_1.FieldAssignmentTranspiler().transpile(child, traversal).getCode());
}
else if (child.get() instanceof core_1.Expressions.Source && child instanceof core_1.Nodes.ExpressionNode) {
// then its a non structured/ table line kind of thing
ret.appendString(".set(" + new source_1.SourceTranspiler().transpile(child, traversal).getCode() + ")");
}
else {
throw new Error("ValueBodyLineTranspiler, unknown " + child.get().constructor.name + " " + line.concatTokens());
}
}
ret.appendString(extraFields + `)`);
return ret;
}
}
exports.ValueBodyLineTranspiler = ValueBodyLineTranspiler;
//# sourceMappingURL=value_body_line.js.map