-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import * as abaplint from "@abaplint/core"; | ||
import {IStatementTranspiler} from "./_statement_transpiler"; | ||
import {Traversal} from "../traversal"; | ||
import {Chunk} from "../chunk"; | ||
|
||
export class EnhancementPointTranspiler implements IStatementTranspiler { | ||
|
||
public transpile(_node: abaplint.Nodes.StatementNode, _traversal: Traversal): Chunk { | ||
// for now, do nothing, but leave a comment | ||
|
||
// ENHANCEMENT-POINT enh_id SPOTS spot1 spot2 ... [STATIC] [INCLUDE BOUND]. | ||
let enhId: string = ""; | ||
const spots: string[] = []; | ||
for (const tn of _node.getTokenNodes()) { | ||
if (tn instanceof abaplint.Nodes.TokenNodeRegex) { | ||
if (!enhId) { | ||
enhId = tn.get().getStr(); | ||
} else { | ||
spots.push(tn.get().getStr()); | ||
} | ||
} | ||
} | ||
|
||
// [Transpiler] EnhancementPoint not implemented. Ignoring 'enh_id' spots 'spot1', 'spot2' ... | ||
return new Chunk(`// [Transpiler] EnhancementPoint not implemented. Ignoring '${enhId}' spots '${ spots.join("', '") }'`); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import {expect} from "chai"; | ||
import {ABAP, MemoryConsole} from "../../packages/runtime/src"; | ||
import {AsyncFunction, runFiles} from "../_utils"; | ||
|
||
let abap: ABAP; | ||
|
||
async function run(contents: string) { | ||
return runFiles(abap, [{filename: "zfoobar.prog.abap", contents}]); | ||
} | ||
|
||
describe("Running statements - ENHANCEMENT POINT", () => { | ||
|
||
beforeEach(async () => { | ||
abap = new ABAP({console: new MemoryConsole()}); | ||
}); | ||
|
||
it("enhancement point", async () => { | ||
const code = ` | ||
WRITE 'hello'. | ||
ENHANCEMENT-POINT foo SPOTS bar. | ||
WRITE 'hi'.`; | ||
const js = await run(code); | ||
const f = new AsyncFunction("abap", js); | ||
await f(abap); | ||
expect(abap.console.get()).to.equal("hellohi"); | ||
}); | ||
|
||
}); |