diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2018-11-11 15:25:25 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2018-11-11 15:26:30 -0800 |
| commit | 5f38d73004f0fcf259acfa12d46feff4c6170273 (patch) | |
| tree | 28bcef232efeded6c2cdff15ab6542e056d23515 /nomsu_decompiler.moon | |
| parent | 9a75d25c843b03e3671b71384fd48deb0607db43 (diff) | |
Now preserving hex numbers with "0xF00" -> parse -> decompile ->
"0xF00", fix for (compile error at ...)
Diffstat (limited to 'nomsu_decompiler.moon')
| -rw-r--r-- | nomsu_decompiler.moon | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/nomsu_decompiler.moon b/nomsu_decompiler.moon index 99dce3e..5b72823 100644 --- a/nomsu_decompiler.moon +++ b/nomsu_decompiler.moon @@ -4,7 +4,7 @@ re = require 're' MAX_LINE = 80 -GOLDEN_RATIO = ((1+math.sqrt(5))/2) +GOLDEN_RATIO = ((math.sqrt(5)-1)/2) -- Parsing helper functions utf8_char_patt = ( @@ -130,7 +130,12 @@ tree_to_inline_nomsu = (tree)-> return nomsu when "Number" - return NomsuCode\from(tree.source, tostring(tree[1])) + s = if tree.hex and tree[1] < 0 + ("-0x%X")\format(-tree[1]) + elseif tree.hex + ("0x%X")\format(tree[1]) + else tostring(tree[1]) + return NomsuCode\from(tree.source, s) when "Var" return NomsuCode\from(tree.source, "%", tree[1]) |
