diff --git a/arkguard/src/configs/preset/es6_reserved_properties.json b/arkguard/src/configs/preset/es6_reserved_properties.json index cf3d2dd8710b6ce79148d5b14e82fa66990dc34a..3dea97490ee3c4382839120a219f039eeabd031d 100644 --- a/arkguard/src/configs/preset/es6_reserved_properties.json +++ b/arkguard/src/configs/preset/es6_reserved_properties.json @@ -3403,6 +3403,7 @@ "channelInterpretation", "char", "charAt", + "getCharByIndex", "charCode", "charCodeAt", "charIndex", @@ -7881,4 +7882,4 @@ "timeZone", "ResolvedDateTimeFormatOptions", "calendar" -] \ No newline at end of file +] diff --git a/ets2panda/compiler/scripts/signatures.yaml b/ets2panda/compiler/scripts/signatures.yaml index 35f30fef05a85fdd091786419c521dc594dc8bde..bff22d355dd93cf474d78a861ac1b3e6790e7eee 100644 --- a/ets2panda/compiler/scripts/signatures.yaml +++ b/ets2panda/compiler/scripts/signatures.yaml @@ -320,7 +320,7 @@ signatures: ref: BUILTIN_STRING_LENGTH - callee: BUILTIN_STRING - method_name: charAt + method_name: getCharByIndex params: [PRIMITIVE_INT] return_type: PRIMITIVE_CHAR ref: BUILTIN_STRING_CHAR_AT diff --git a/ets2panda/test/parser/ets/StringBase64.ets b/ets2panda/test/parser/ets/StringBase64.ets index 2b3c6fddbec43ef1f16c285e24dfcc82c39cd366..13ddc755157f771285b896898763d705dddd2d22 100644 --- a/ets2panda/test/parser/ets/StringBase64.ets +++ b/ets2panda/test/parser/ets/StringBase64.ets @@ -22,21 +22,21 @@ export class StringBase64 { let length : int = data.length(); let i : int ; for (i = 0; i < (length - 2); i += 3) { - result.append(StringBase64.TO_BASE64_TABLE.charAt(data.charAt(i) >> 2)); - result.append(StringBase64.TO_BASE64_TABLE.charAt(((data.charAt(i) & 0x03) << 4) + (data.charAt(i + 1) >> 4))); - result.append(StringBase64.TO_BASE64_TABLE.charAt(((data.charAt(i + 1) & 0x0f) << 2) + (data.charAt(i + 2) >> 6))); - result.append(StringBase64.TO_BASE64_TABLE.charAt(data.charAt(i + 2) & 0x3f)); + result.append(StringBase64.TO_BASE64_TABLE.getCharByIndex(data.getCharByIndex(i) >> 2)); + result.append(StringBase64.TO_BASE64_TABLE.getCharByIndex(((data.getCharByIndex(i) & 0x03) << 4) + (data.getCharByIndex(i + 1) >> 4))); + result.append(StringBase64.TO_BASE64_TABLE.getCharByIndex(((data.getCharByIndex(i + 1) & 0x0f) << 2) + (data.getCharByIndex(i + 2) >> 6))); + result.append(StringBase64.TO_BASE64_TABLE.getCharByIndex(data.getCharByIndex(i + 2) & 0x3f)); } if (length % 3 != 0) { i = length - (length % 3); - result.append(StringBase64.TO_BASE64_TABLE.charAt(data.charAt(i) >> 2)); + result.append(StringBase64.TO_BASE64_TABLE.getCharByIndex(data.getCharByIndex(i) >> 2)); if ((length % 3) == 2) { - result.append(StringBase64.TO_BASE64_TABLE.charAt(((data.charAt(i) & 0x03) << 4) + (data.charAt(i + 1) >> 4))); - result.append(StringBase64.TO_BASE64_TABLE.charAt((data.charAt(i + 1) & 0x0f) << 2)); + result.append(StringBase64.TO_BASE64_TABLE.getCharByIndex(((data.getCharByIndex(i) & 0x03) << 4) + (data.getCharByIndex(i + 1) >> 4))); + result.append(StringBase64.TO_BASE64_TABLE.getCharByIndex((data.getCharByIndex(i + 1) & 0x0f) << 2)); result.append(StringBase64.BASE64PAD); } else { - result.append(StringBase64.TO_BASE64_TABLE.charAt((data.charAt(i) & 0x03) << 4)); + result.append(StringBase64.TO_BASE64_TABLE.getCharByIndex((data.getCharByIndex(i) & 0x03) << 4)); result.append(StringBase64.BASE64PAD); result.append(StringBase64.BASE64PAD); } @@ -48,8 +48,8 @@ export class StringBase64 { let leftbits : int = 0; let leftdata : int = 0; for (let i : int = 0; i < data.length(); i++) { - let c : int = StringBase64.TO_BINARY_TABLE[data.charAt(i) & 0x7f]; - let padding : boolean = data.charAt(i) == StringBase64.BASE64PAD; + let c : int = StringBase64.TO_BINARY_TABLE[data.getCharByIndex(i) & 0x7f]; + let padding : boolean = data.getCharByIndex(i) == StringBase64.BASE64PAD; if (c == -1) { continue; } diff --git a/ets2panda/test/runtime/ets/RegisterSpiller.ets b/ets2panda/test/runtime/ets/RegisterSpiller.ets index e994742a8090c56b589c5f328021f69316278432..a0afe3a7af4ef7321b017283b5ae4da6b786d197 100644 --- a/ets2panda/test/runtime/ets/RegisterSpiller.ets +++ b/ets2panda/test/runtime/ets/RegisterSpiller.ets @@ -15,9 +15,9 @@ function main(): void { let str: String = "hello\nworld\n"; - assert str.charAt(2) == c'l'; + assert str.getCharByIndex(2) == c'l'; assert str.length() == 12; - assert str.charAt(str.length() - 1) == c'\n'; + assert str.getCharByIndex(str.length() - 1) == c'\n'; let a: String = "abc"; let b: String = "ace"; diff --git a/ets2panda/test/runtime/ets/StringBase64.ets b/ets2panda/test/runtime/ets/StringBase64.ets index 17e894db3d19df9f7cf25ab5aa797c8f813d13d0..87c5dcb8e676af4ba5f83bcb16d74b1e26489779 100644 --- a/ets2panda/test/runtime/ets/StringBase64.ets +++ b/ets2panda/test/runtime/ets/StringBase64.ets @@ -22,21 +22,21 @@ export class StringBase64 { let length : int = data.length(); let i : int ; for (i = 0; i < (length - 2); i += 3) { - result.append(StringBase64.TO_BASE64_TABLE.charAt(data.charAt(i) >> 2)); - result.append(StringBase64.TO_BASE64_TABLE.charAt(((data.charAt(i) & 0x03) << 4) + (data.charAt(i + 1) >> 4))); - result.append(StringBase64.TO_BASE64_TABLE.charAt(((data.charAt(i + 1) & 0x0f) << 2) + (data.charAt(i + 2) >> 6))); - result.append(StringBase64.TO_BASE64_TABLE.charAt(data.charAt(i + 2) & 0x3f)); + result.append(StringBase64.TO_BASE64_TABLE.getCharByIndex(data.getCharByIndex(i) >> 2)); + result.append(StringBase64.TO_BASE64_TABLE.getCharByIndex(((data.getCharByIndex(i) & 0x03) << 4) + (data.getCharByIndex(i + 1) >> 4))); + result.append(StringBase64.TO_BASE64_TABLE.getCharByIndex(((data.getCharByIndex(i + 1) & 0x0f) << 2) + (data.getCharByIndex(i + 2) >> 6))); + result.append(StringBase64.TO_BASE64_TABLE.getCharByIndex(data.getCharByIndex(i + 2) & 0x3f)); } if (length % 3 != 0) { i = length - (length % 3); - result.append(StringBase64.TO_BASE64_TABLE.charAt(data.charAt(i) >> 2)); + result.append(StringBase64.TO_BASE64_TABLE.getCharByIndex(data.getCharByIndex(i) >> 2)); if ((length % 3) == 2) { - result.append(StringBase64.TO_BASE64_TABLE.charAt(((data.charAt(i) & 0x03) << 4) + (data.charAt(i + 1) >> 4))); - result.append(StringBase64.TO_BASE64_TABLE.charAt((data.charAt(i + 1) & 0x0f) << 2)); + result.append(StringBase64.TO_BASE64_TABLE.getCharByIndex(((data.getCharByIndex(i) & 0x03) << 4) + (data.getCharByIndex(i + 1) >> 4))); + result.append(StringBase64.TO_BASE64_TABLE.getCharByIndex((data.getCharByIndex(i + 1) & 0x0f) << 2)); result.append(StringBase64.BASE64PAD); } else { - result.append(StringBase64.TO_BASE64_TABLE.charAt((data.charAt(i) & 0x03) << 4)); + result.append(StringBase64.TO_BASE64_TABLE.getCharByIndex((data.getCharByIndex(i) & 0x03) << 4)); result.append(StringBase64.BASE64PAD); result.append(StringBase64.BASE64PAD); } @@ -48,8 +48,8 @@ export class StringBase64 { let leftbits : int = 0; let leftdata : int = 0; for (let i : int = 0; i < data.length(); i++) { - let c : int = StringBase64.TO_BINARY_TABLE[data.charAt(i) & 0x7f]; - let padding : boolean = data.charAt(i) == StringBase64.BASE64PAD; + let c : int = StringBase64.TO_BINARY_TABLE[data.getCharByIndex(i) & 0x7f]; + let padding : boolean = data.getCharByIndex(i) == StringBase64.BASE64PAD; if (c == -1) { continue; } diff --git a/ets2panda/test/runtime/ets/skippedTest.ets b/ets2panda/test/runtime/ets/skippedTest.ets index f40252c2b43905e0402378b8090685f8a00f8795..07456579f61f99371b99a3f2061dd2b8667f8d03 100644 --- a/ets2panda/test/runtime/ets/skippedTest.ets +++ b/ets2panda/test/runtime/ets/skippedTest.ets @@ -24,7 +24,7 @@ function main(): void { let n5: double = 44.44; console.print(str); console.println(); - console.print(str.charAt(2)); + console.print(str.getCharByIndex(2)); console.println(); console.print(str.length()); console.println();