Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions as/testcase/useUtf8Transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ export const obj: C2 = {

export const arr: C1[] = [new C1(utf8.build("test2"), 4)];

function foo(str: utf8.ConstStr): void {
str;
}

export function _start(): void {
const str = utf8.build("test3");
log(str.addr, str.size);
foo(utf8.build("test4"));
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@schleifner/assemblyscript-transform",
"version": "0.1.0",
"version": "0.1.1",
"author": "",
"description": "const utf8 string literal in AssemblyScript",
"type": "module",
Expand Down
1 change: 1 addition & 0 deletions tests/transform.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ test("transform convert utf8 success", () => {
expect(watContent).toContain("test1");
expect(watContent).toContain("test2");
expect(watContent).toContain("test3");
expect(watContent).toContain("test4");
});

test("transform not string literal", () => {
Expand Down
4 changes: 4 additions & 0 deletions transform/transformBuildUtf8ConstStr.mts
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,12 @@ export default class TransformBuildUtf8ConstStr extends Transform {

if (this.isUtf8BuildCall(leftExpression, propertyAccessExpression)) {
this.handleUtf8BuildCall(node, propertyAccessExpression);
return;
}
}
for (const arg of node.args) {
this.visitNode(arg);
}
}

private isUtf8BuildCall(leftExpression: Node, propertyAccessExpression: PropertyAccessExpression): boolean {
Expand Down