From feed0d1b84907955d3382f23db2c33eff7389792 Mon Sep 17 00:00:00 2001 From: Ben Gruver Date: Mon, 15 Apr 2013 21:54:16 -0700 Subject: [PATCH] Change syntax of const/high16 and const-wide/16 The literal is now specified as the post-shifted literal value, rather than the pre-shifted 16 bits --- smali/src/main/antlr3/smaliParser.g | 8 ++++---- smali/src/main/antlr3/smaliTreeWalker.g | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/smali/src/main/antlr3/smaliParser.g b/smali/src/main/antlr3/smaliParser.g index 51ebe819..47c9b051 100644 --- a/smali/src/main/antlr3/smaliParser.g +++ b/smali/src/main/antlr3/smaliParser.g @@ -939,13 +939,13 @@ insn_format21c_type returns [int size] insn_format21ih returns [int size] : //e.g. const/high16 v1, 1234 - INSTRUCTION_FORMAT21ih REGISTER COMMA integral_literal {$size = Format.Format21ih.size;} - -> ^(I_STATEMENT_FORMAT21ih[$start, "I_STATEMENT_FORMAT21ih"] INSTRUCTION_FORMAT21ih REGISTER integral_literal); + INSTRUCTION_FORMAT21ih REGISTER COMMA fixed_32bit_literal {$size = Format.Format21ih.size;} + -> ^(I_STATEMENT_FORMAT21ih[$start, "I_STATEMENT_FORMAT21ih"] INSTRUCTION_FORMAT21ih REGISTER fixed_32bit_literal); insn_format21lh returns [int size] : //e.g. const-wide/high16 v1, 1234 - INSTRUCTION_FORMAT21lh REGISTER COMMA integral_literal {$size = Format.Format21lh.size;} - -> ^(I_STATEMENT_FORMAT21lh[$start, "I_STATEMENT_FORMAT21lh"] INSTRUCTION_FORMAT21lh REGISTER integral_literal); + INSTRUCTION_FORMAT21lh REGISTER COMMA fixed_32bit_literal {$size = Format.Format21lh.size;} + -> ^(I_STATEMENT_FORMAT21lh[$start, "I_STATEMENT_FORMAT21lh"] INSTRUCTION_FORMAT21lh REGISTER fixed_32bit_literal); insn_format21s returns [int size] : //e.g. const/16 v1, 1234 diff --git a/smali/src/main/antlr3/smaliTreeWalker.g b/smali/src/main/antlr3/smaliTreeWalker.g index 5bcd435c..146e8829 100644 --- a/smali/src/main/antlr3/smaliTreeWalker.g +++ b/smali/src/main/antlr3/smaliTreeWalker.g @@ -933,26 +933,26 @@ insn_format21c_type[int totalMethodRegisters, int methodParameterRegisters, List insn_format21ih[int totalMethodRegisters, int methodParameterRegisters, List instructions] returns[int outRegisters] : //e.g. const/high16 v1, 1234 - ^(I_STATEMENT_FORMAT21ih INSTRUCTION_FORMAT21ih REGISTER short_integral_literal) + ^(I_STATEMENT_FORMAT21ih INSTRUCTION_FORMAT21ih REGISTER fixed_32bit_literal) { Opcode opcode = Opcode.getOpcodeByName($INSTRUCTION_FORMAT21ih.text); short regA = parseRegister_byte($REGISTER.text, $totalMethodRegisters, $methodParameterRegisters); - short litB = $short_integral_literal.value; + int litB = $fixed_32bit_literal.value; - instructions.add(new ImmutableInstruction21ih(opcode, regA, litB<<16)); + instructions.add(new ImmutableInstruction21ih(opcode, regA, litB)); }; insn_format21lh[int totalMethodRegisters, int methodParameterRegisters, List instructions] returns[int outRegisters] : //e.g. const-wide/high16 v1, 1234 - ^(I_STATEMENT_FORMAT21lh INSTRUCTION_FORMAT21lh REGISTER short_integral_literal) + ^(I_STATEMENT_FORMAT21lh INSTRUCTION_FORMAT21lh REGISTER fixed_64bit_literal) { Opcode opcode = Opcode.getOpcodeByName($INSTRUCTION_FORMAT21lh.text); short regA = parseRegister_byte($REGISTER.text, $totalMethodRegisters, $methodParameterRegisters); - short litB = $short_integral_literal.value; + long litB = $fixed_64bit_literal.value; - instructions.add(new ImmutableInstruction21lh(opcode, regA, ((long)litB)<<48)); + instructions.add(new ImmutableInstruction21lh(opcode, regA, litB)); }; insn_format21s[int totalMethodRegisters, int methodParameterRegisters, List instructions] returns[int outRegisters]