Skip to content

Commit

Permalink
more replaceable pattern (put surround code instead of just start)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwunderl committed Feb 4, 2021
1 parent 7fd8c82 commit db107f0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 21 deletions.
2 changes: 1 addition & 1 deletion pxtblocks/blocklycompiler.ts
Expand Up @@ -1137,7 +1137,7 @@ namespace pxt.blocks {
if (PICTOGRAPHIC_REGEX) {
return name.replace(
PICTOGRAPHIC_REGEX,
s => `Ex${s.codePointAt(0).toString(16)}`
s => `E${s.codePointAt(0).toString(16)}X`
);
}
return name;
Expand Down
4 changes: 2 additions & 2 deletions pxtcompiler/emitter/decompiler.ts
Expand Up @@ -3490,8 +3490,8 @@ ${output}</xml>`;

function unescapeVarName(name: string) {
return name.replace(
/Ex([0-9a-f]{4,6})/g,
s => String.fromCodePoint(+`0x${s.slice(2)}`)
/E([0-9a-f]{4,6})X/g,
s => String.fromCodePoint(+`0x${s.slice(1, s.length - 1)}`)
);
}

Expand Down
7 changes: 1 addition & 6 deletions tests/decompile-test/baselines/emojis.blocks
Expand Up @@ -48,7 +48,7 @@
<field name="VAR">😃</field>
<value name="VALUE">
<shadow type="math_number">
<field name="NUM">25</field>
<field name="NUM">28</field>
</shadow>
</value>
<next>
Expand All @@ -59,11 +59,6 @@
<field name="VAR">😃</field>
</block>
</value>
<next>
<block type="typescript_statement">
<mutation numlines="1" error="Unsupported syntax kind for output expression block: NullKeyword" line0="Ex1f603 = null;" />
</block>
</next>
</block>
</next>
</block>
Expand Down
21 changes: 9 additions & 12 deletions tests/decompile-test/cases/emojis.ts
@@ -1,19 +1,16 @@
function Ex1f4d6 () {
function E1f4d6X () {

}
function Ex1f469‍Ex2764️‍Ex1f48b‍Ex1f469 () {
function E1f469X‍E2764X️‍E1f48bX‍E1f469X () {

}
function Ex1f4da () {
function E1f4daX () {

}
Ex1f4da()
Ex1f4d6()
Ex1f469‍Ex2764️‍Ex1f48b‍Ex1f469()
E1f4daX()
E1f4d6X()
E1f469X‍E2764X️‍E1f48bX‍E1f469X()
let a = 10
let Ex1f603 = 2
Ex1f603 += 25

testNamespace.numberWithEnumShadow(Ex1f603)

Ex1f603 = null;
let E1f603X = 2
E1f603X += 28
testNamespace.numberWithEnumShadow(E1f603X)

0 comments on commit db107f0

Please sign in to comment.