mirror of
https://github.com/revanced/smali.git
synced 2025-04-30 06:34:25 +02:00
Revert "Add lambda experimental dalvik opcodes"
This reverts commit 144951a9e9e6c87866245f2bdeebf0ebedaa0e38.
This commit is contained in:
parent
afc1f15939
commit
99b80bbc5a
@ -330,11 +330,6 @@ public class InstructionMethodItem<T extends Instruction> extends MethodItem {
|
||||
writer.write(", ");
|
||||
writeThirdRegister(writer);
|
||||
break;
|
||||
case Format25x:
|
||||
writeOpcode(writer);
|
||||
writer.write(' ');
|
||||
writeInvoke25xRegisters(writer); // vC, {vD, ...}
|
||||
break;
|
||||
case Format35c:
|
||||
writeOpcode(writer);
|
||||
writer.write(' ');
|
||||
@ -478,43 +473,6 @@ public class InstructionMethodItem<T extends Instruction> extends MethodItem {
|
||||
writer.write('}');
|
||||
}
|
||||
|
||||
protected void writeInvoke25xRegisters(IndentingWriter writer) throws IOException {
|
||||
OneFixedFourParameterRegisterInstruction instruction =
|
||||
(OneFixedFourParameterRegisterInstruction)this.instruction;
|
||||
final int parameterRegCount = instruction.getParameterRegisterCount();
|
||||
|
||||
writeRegister(writer, instruction.getRegisterFixedC()); // fixed register always present
|
||||
|
||||
writer.write(", {");
|
||||
switch (parameterRegCount) {
|
||||
case 1:
|
||||
writeRegister(writer, instruction.getRegisterParameterD());
|
||||
break;
|
||||
case 2:
|
||||
writeRegister(writer, instruction.getRegisterParameterD());
|
||||
writer.write(", ");
|
||||
writeRegister(writer, instruction.getRegisterParameterE());
|
||||
break;
|
||||
case 3:
|
||||
writeRegister(writer, instruction.getRegisterParameterD());
|
||||
writer.write(", ");
|
||||
writeRegister(writer, instruction.getRegisterParameterE());
|
||||
writer.write(", ");
|
||||
writeRegister(writer, instruction.getRegisterParameterF());
|
||||
break;
|
||||
case 4:
|
||||
writeRegister(writer, instruction.getRegisterParameterD());
|
||||
writer.write(", ");
|
||||
writeRegister(writer, instruction.getRegisterParameterE());
|
||||
writer.write(", ");
|
||||
writeRegister(writer, instruction.getRegisterParameterF());
|
||||
writer.write(", ");
|
||||
writeRegister(writer, instruction.getRegisterParameterG());
|
||||
break;
|
||||
}
|
||||
writer.write('}');
|
||||
}
|
||||
|
||||
protected void writeInvokeRangeRegisters(IndentingWriter writer) throws IOException {
|
||||
RegisterRangeInstruction instruction = (RegisterRangeInstruction)this.instruction;
|
||||
|
||||
|
@ -1,55 +0,0 @@
|
||||
.class public LHelloWorldLambda;
|
||||
|
||||
#Ye olde hello world application (with lambdas!)
|
||||
#To assemble and run this on a phone or emulator:
|
||||
#
|
||||
#java -jar smali.jar -o classes.dex HelloWorldLambda.smali HelloWorldFunctionalInterface.smali
|
||||
#zip HelloWorld.zip classes.dex
|
||||
#adb push HelloWorld.zip /data/local
|
||||
#adb shell dalvikvm -cp /data/local/HelloWorld.zip HelloWorld
|
||||
#
|
||||
#if you get out of memory type errors when running smali.jar, try
|
||||
#java -Xmx512m -jar smali.jar HelloWorldLambda.smali
|
||||
#instead
|
||||
|
||||
.super Ljava/lang/Object;
|
||||
|
||||
.method public static doHelloWorld(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
|
||||
.registers 6 # 4 parameters, 2 locals
|
||||
liberate-variable v0, p0, "helloworld"
|
||||
|
||||
sget-object v1, Ljava/lang/System;->out:Ljava/io/PrintStream;
|
||||
invoke-virtual {v1, v0}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V
|
||||
|
||||
return-void
|
||||
.end method
|
||||
|
||||
.method public static main([Ljava/lang/String;)V
|
||||
.registers 9 # 1 parameter, 8 locals
|
||||
|
||||
sget-object v0, Ljava/lang/System;->out:Ljava/io/PrintStream;
|
||||
|
||||
const-string v1, "Hello World!"
|
||||
const-string v2, "How" # vD
|
||||
const-string v3, "are" # vE
|
||||
const-string v4, "you" # vF
|
||||
const-string v5, "doing?" # vG
|
||||
|
||||
capture-variable v1, "helloworld"
|
||||
|
||||
# TODO: do I need to pass the type of the lambda's functional interface here as a type id?
|
||||
create-lambda v1, LHelloWorldLambda;->doHelloWorld(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
|
||||
# Method descriptor is not required here, because only the single-abstract method is ever invoked.
|
||||
invoke-lambda v1, {v2, v3, v4, v5}
|
||||
|
||||
box-lambda v6, v1
|
||||
invoke-virtual {v6, v2, v3, v4, v5}, LHelloWorldFunctionalInterface;->applyFourStrings(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
|
||||
|
||||
# FIXME: should be \HelloWorldFunctionalInterface; instead of L...;
|
||||
|
||||
# TODO: do we really need the type descriptor here at all?
|
||||
unbox-lambda v7, v6, LHelloWorldFunctionalInterface;
|
||||
invoke-lambda v7, {v2, v3, v4, v5}
|
||||
|
||||
return-void
|
||||
.end method
|
@ -51,7 +51,6 @@ public enum Format {
|
||||
Format22t(4),
|
||||
Format22x(4),
|
||||
Format23x(4),
|
||||
Format25x(4),
|
||||
Format30t(6),
|
||||
Format31c(6),
|
||||
Format31i(6),
|
||||
|
@ -305,15 +305,6 @@ public enum Opcode
|
||||
SPARSE_SWITCH_PAYLOAD(0x200, "sparse-switch-payload", ReferenceType.NONE, Format.SparseSwitchPayload, 0),
|
||||
ARRAY_PAYLOAD(0x300, "array-payload", ReferenceType.NONE, Format.ArrayPayload, 0),
|
||||
|
||||
// Reuse the deprecated f3-ff opcodes in Art:
|
||||
INVOKE_LAMBDA(allArtVersions(0xf3),"invoke-lambda", ReferenceType.NONE, Format.Format25x, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT | Opcode.EXPERIMENTAL),
|
||||
// TODO: What about JUMBO support if the string ID is too large?
|
||||
CAPTURE_VARIABLE(allArtVersions(0xf5), "capture-variable", ReferenceType.STRING, Format.Format21c, Opcode.EXPERIMENTAL),
|
||||
CREATE_LAMBDA(allArtVersions(0xf6), "create-lambda", ReferenceType.METHOD, Format.Format21c, Opcode.SETS_REGISTER | Opcode.EXPERIMENTAL),
|
||||
// TODO: do we need a capture/liberate wide?
|
||||
LIBERATE_VARIABLE(allArtVersions(0xf7), "liberate-variable", ReferenceType.STRING, Format.Format22c, Opcode.SETS_REGISTER | Opcode.EXPERIMENTAL),
|
||||
BOX_LAMBDA(allArtVersions(0xf8), "box-lambda", ReferenceType.NONE, Format.Format22x, Opcode.SETS_REGISTER | Opcode.EXPERIMENTAL),
|
||||
UNBOX_LAMBDA(allArtVersions(0xf9), "unbox-lambda", ReferenceType.TYPE, Format.Format22c, Opcode.SETS_REGISTER | Opcode.EXPERIMENTAL),
|
||||
INVOKE_POLYMORPHIC(firstApi(0xfa, 26), "invoke-polymorphic", ReferenceType.METHOD, ReferenceType.METHOD_PROTO, Format.Format45cc, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT),
|
||||
INVOKE_POLYMORPHIC_RANGE(firstApi(0xfb, 26), "invoke-polymorphic/range", ReferenceType.METHOD, ReferenceType.METHOD_PROTO, Format.Format4rcc, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT);
|
||||
|
||||
|
@ -615,9 +615,6 @@ public class MutableMethodImplementation implements MethodImplementation {
|
||||
case Format23x:
|
||||
setInstruction(location, newBuilderInstruction23x((Instruction23x) instruction));
|
||||
return;
|
||||
case Format25x:
|
||||
setInstruction(location, newBuilderInstruction25x((Instruction25x) instruction));
|
||||
return;
|
||||
case Format30t:
|
||||
setInstruction(location, newBuilderInstruction30t(location.codeAddress,
|
||||
codeAddressToIndex,
|
||||
@ -871,18 +868,6 @@ public class MutableMethodImplementation implements MethodImplementation {
|
||||
instruction.getReference());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private BuilderInstruction25x newBuilderInstruction25x(@Nonnull Instruction25x instruction) {
|
||||
return new BuilderInstruction25x(
|
||||
instruction.getOpcode(),
|
||||
instruction.getParameterRegisterCount(),
|
||||
instruction.getRegisterFixedC(),
|
||||
instruction.getRegisterParameterD(),
|
||||
instruction.getRegisterParameterE(),
|
||||
instruction.getRegisterParameterF(),
|
||||
instruction.getRegisterParameterG());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private BuilderInstruction3rc newBuilderInstruction3rc(@Nonnull Instruction3rc instruction) {
|
||||
return new BuilderInstruction3rc(
|
||||
|
@ -1,82 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015, Google Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.jf.dexlib2.builder.instruction;
|
||||
|
||||
import org.jf.dexlib2.Format;
|
||||
import org.jf.dexlib2.Opcode;
|
||||
import org.jf.dexlib2.builder.BuilderInstruction;
|
||||
import org.jf.dexlib2.iface.instruction.formats.Instruction25x;
|
||||
import org.jf.dexlib2.util.Preconditions;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class BuilderInstruction25x extends BuilderInstruction implements Instruction25x {
|
||||
public static final Format FORMAT = Format.Format25x;
|
||||
|
||||
protected final int parameterRegisterCount;
|
||||
protected final int registerClosure;
|
||||
protected final int registerD;
|
||||
protected final int registerE;
|
||||
protected final int registerF;
|
||||
protected final int registerG;
|
||||
|
||||
public BuilderInstruction25x(@Nonnull Opcode opcode,
|
||||
int parameterRegisterCount,
|
||||
int registerClosure,
|
||||
int registerD,
|
||||
int registerE,
|
||||
int registerF,
|
||||
int registerG) {
|
||||
super(opcode);
|
||||
this.parameterRegisterCount =
|
||||
Preconditions.check25xParameterRegisterCount(parameterRegisterCount);
|
||||
this.registerClosure = Preconditions.checkNibbleRegister(registerClosure); //at least 1 reg
|
||||
this.registerD = (parameterRegisterCount>0) ?
|
||||
Preconditions.checkNibbleRegister(registerD) : 0;
|
||||
this.registerE = (parameterRegisterCount>1) ?
|
||||
Preconditions.checkNibbleRegister(registerE) : 0;
|
||||
this.registerF = (parameterRegisterCount>2) ?
|
||||
Preconditions.checkNibbleRegister(registerF) : 0;
|
||||
this.registerG = (parameterRegisterCount>3) ?
|
||||
Preconditions.checkNibbleRegister(registerG) : 0;
|
||||
}
|
||||
|
||||
@Override public int getRegisterCount() { return parameterRegisterCount + 1; }
|
||||
@Override public int getParameterRegisterCount() { return parameterRegisterCount; }
|
||||
@Override public int getRegisterFixedC() { return registerClosure; }
|
||||
@Override public int getRegisterParameterD() { return registerD; }
|
||||
@Override public int getRegisterParameterE() { return registerE; }
|
||||
@Override public int getRegisterParameterF() { return registerF; }
|
||||
@Override public int getRegisterParameterG() { return registerG; }
|
||||
|
||||
@Override public Format getFormat() { return FORMAT; }
|
||||
}
|
@ -115,8 +115,6 @@ public abstract class DexBackedInstruction implements Instruction {
|
||||
return new DexBackedInstruction22x(dexFile, opcode, instructionStartOffset);
|
||||
case Format23x:
|
||||
return new DexBackedInstruction23x(dexFile, opcode, instructionStartOffset);
|
||||
case Format25x:
|
||||
return new DexBackedInstruction25x(dexFile, opcode, instructionStartOffset);
|
||||
case Format30t:
|
||||
return new DexBackedInstruction30t(dexFile, opcode, instructionStartOffset);
|
||||
case Format31c:
|
||||
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015, Google Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.jf.dexlib2.dexbacked.instruction;
|
||||
|
||||
import org.jf.dexlib2.Opcode;
|
||||
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||
import org.jf.dexlib2.iface.instruction.formats.Instruction25x;
|
||||
import org.jf.util.NibbleUtils;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class DexBackedInstruction25x extends DexBackedInstruction implements Instruction25x {
|
||||
public DexBackedInstruction25x(@Nonnull DexBackedDexFile dexFile,
|
||||
@Nonnull Opcode opcode,
|
||||
int instructionStart) {
|
||||
super(dexFile, opcode, instructionStart);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRegisterCount() {
|
||||
return getParameterRegisterCount() + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getParameterRegisterCount() {
|
||||
return NibbleUtils.extractHighUnsignedNibble(dexFile.readUbyte(instructionStart + 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRegisterFixedC() {
|
||||
return NibbleUtils.extractLowUnsignedNibble(dexFile.readUbyte(instructionStart + 2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRegisterParameterD() {
|
||||
return NibbleUtils.extractHighUnsignedNibble(dexFile.readUbyte(instructionStart + 2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRegisterParameterE() {
|
||||
return NibbleUtils.extractLowUnsignedNibble(dexFile.readUbyte(instructionStart + 3));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRegisterParameterF() {
|
||||
return NibbleUtils.extractHighUnsignedNibble(dexFile.readUbyte(instructionStart + 3));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRegisterParameterG() {
|
||||
return NibbleUtils.extractLowUnsignedNibble(dexFile.readUbyte(instructionStart + 1));
|
||||
}
|
||||
|
||||
}
|
@ -129,9 +129,6 @@ public class CodeItem {
|
||||
case Format10x:
|
||||
annotateInstruction10x(out, instruction);
|
||||
break;
|
||||
case Format25x:
|
||||
annotateInstruction25x(out, (Instruction25x) instruction);
|
||||
break;
|
||||
case Format35c:
|
||||
annotateInstruction35c(out, (Instruction35c)instruction);
|
||||
break;
|
||||
@ -285,30 +282,6 @@ public class CodeItem {
|
||||
instruction.getOpcode().name, Joiner.on(", ").join(args), reference));
|
||||
}
|
||||
|
||||
private void annotateInstruction25x(@Nonnull AnnotatedBytes out,
|
||||
@Nonnull Instruction25x instruction) {
|
||||
List<String> args = Lists.newArrayList();
|
||||
|
||||
int registerCount = instruction.getRegisterCount(); //at least 1.
|
||||
if (registerCount == 2) {
|
||||
args.add(formatRegister(instruction.getRegisterParameterD()));
|
||||
} else if (registerCount == 3) {
|
||||
args.add(formatRegister(instruction.getRegisterParameterD()));
|
||||
args.add(formatRegister(instruction.getRegisterParameterE()));
|
||||
} else if (registerCount == 4) {
|
||||
args.add(formatRegister(instruction.getRegisterParameterD()));
|
||||
args.add(formatRegister(instruction.getRegisterParameterE()));
|
||||
args.add(formatRegister(instruction.getRegisterParameterF()));
|
||||
} else if (registerCount == 5) {
|
||||
args.add(formatRegister(instruction.getRegisterParameterD()));
|
||||
args.add(formatRegister(instruction.getRegisterParameterE()));
|
||||
args.add(formatRegister(instruction.getRegisterParameterF()));
|
||||
args.add(formatRegister(instruction.getRegisterParameterG()));
|
||||
}
|
||||
out.annotate(6, String.format("%s %s, {%s}",
|
||||
instruction.getOpcode().name, instruction.getRegisterFixedC(), Joiner.on(", ").join(args)));
|
||||
}
|
||||
|
||||
private void annotateInstruction3rc(@Nonnull AnnotatedBytes out, @Nonnull Instruction3rc instruction) {
|
||||
int startRegister = instruction.getStartRegister();
|
||||
int endRegister = startRegister + instruction.getRegisterCount() - 1;
|
||||
|
@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015, Google Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.jf.dexlib2.iface.instruction;
|
||||
|
||||
public interface OneFixedFourParameterRegisterInstruction extends VariableRegisterInstruction {
|
||||
int getRegisterFixedC();
|
||||
int getRegisterParameterD();
|
||||
int getRegisterParameterE();
|
||||
int getRegisterParameterF();
|
||||
int getRegisterParameterG();
|
||||
|
||||
/** Returns the count of just the parameter register counts; in range of [0, 4] */
|
||||
int getParameterRegisterCount();
|
||||
|
||||
/** Includes the total sum of both fixed and parameter register counts; at least 1 */
|
||||
@Override
|
||||
int getRegisterCount();
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015, Google Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.jf.dexlib2.iface.instruction.formats;
|
||||
|
||||
import org.jf.dexlib2.iface.instruction.OneFixedFourParameterRegisterInstruction;
|
||||
|
||||
public interface Instruction25x extends OneFixedFourParameterRegisterInstruction {
|
||||
}
|
@ -97,8 +97,6 @@ public abstract class ImmutableInstruction implements Instruction {
|
||||
return ImmutableInstruction22x.of((Instruction22x)instruction);
|
||||
case Format23x:
|
||||
return ImmutableInstruction23x.of((Instruction23x)instruction);
|
||||
case Format25x:
|
||||
return ImmutableInstruction25x.of((Instruction25x) instruction);
|
||||
case Format30t:
|
||||
return ImmutableInstruction30t.of((Instruction30t)instruction);
|
||||
case Format31c:
|
||||
|
@ -1,97 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015, Google Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.jf.dexlib2.immutable.instruction;
|
||||
|
||||
import org.jf.dexlib2.Format;
|
||||
import org.jf.dexlib2.Opcode;
|
||||
import org.jf.dexlib2.iface.instruction.formats.Instruction25x;
|
||||
import org.jf.dexlib2.util.Preconditions;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ImmutableInstruction25x extends ImmutableInstruction implements Instruction25x {
|
||||
public static final Format FORMAT = Format.Format25x;
|
||||
|
||||
protected final int parameterRegisterCount;
|
||||
protected final int registerClosure;
|
||||
protected final int registerD;
|
||||
protected final int registerE;
|
||||
protected final int registerF;
|
||||
protected final int registerG;
|
||||
|
||||
public ImmutableInstruction25x(@Nonnull Opcode opcode,
|
||||
int parameterRegisterCount,
|
||||
int registerClosure,
|
||||
int registerD,
|
||||
int registerE,
|
||||
int registerF,
|
||||
int registerG) {
|
||||
super(opcode);
|
||||
this.parameterRegisterCount =
|
||||
Preconditions.check25xParameterRegisterCount(parameterRegisterCount);
|
||||
this.registerClosure = Preconditions.checkNibbleRegister(registerClosure);
|
||||
this.registerD = (parameterRegisterCount>0) ?
|
||||
Preconditions.checkNibbleRegister(registerD) : 0;
|
||||
this.registerE = (parameterRegisterCount>1) ?
|
||||
Preconditions.checkNibbleRegister(registerE) : 0;
|
||||
this.registerF = (parameterRegisterCount>2) ?
|
||||
Preconditions.checkNibbleRegister(registerF) : 0;
|
||||
this.registerG = (parameterRegisterCount>3) ?
|
||||
Preconditions.checkNibbleRegister(registerG) : 0;
|
||||
}
|
||||
|
||||
public static ImmutableInstruction25x of(Instruction25x instruction) {
|
||||
if (instruction instanceof ImmutableInstruction25x) {
|
||||
return (ImmutableInstruction25x)instruction;
|
||||
}
|
||||
return new ImmutableInstruction25x(
|
||||
instruction.getOpcode(),
|
||||
instruction.getRegisterCount(),
|
||||
instruction.getRegisterFixedC(),
|
||||
instruction.getRegisterParameterD(),
|
||||
instruction.getRegisterParameterE(),
|
||||
instruction.getRegisterParameterF(),
|
||||
instruction.getRegisterParameterG());
|
||||
}
|
||||
|
||||
|
||||
@Override public int getParameterRegisterCount() { return parameterRegisterCount; }
|
||||
@Override public int getRegisterCount() { return parameterRegisterCount + 1; }
|
||||
|
||||
@Override public int getRegisterFixedC() { return registerClosure; }
|
||||
@Override public int getRegisterParameterD() { return registerD; }
|
||||
@Override public int getRegisterParameterE() { return registerE; }
|
||||
@Override public int getRegisterParameterF() { return registerF; }
|
||||
@Override public int getRegisterParameterG() { return registerG; }
|
||||
|
||||
@Override public Format getFormat() { return FORMAT; }
|
||||
}
|
@ -133,15 +133,6 @@ public class Preconditions {
|
||||
return registerCount;
|
||||
}
|
||||
|
||||
public static int check25xParameterRegisterCount(int registerCount) {
|
||||
if (registerCount < 0 || registerCount > 4) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format("Invalid parameter register count: %d. " +
|
||||
"Must be between 0 and 4, inclusive.", registerCount));
|
||||
}
|
||||
return registerCount;
|
||||
}
|
||||
|
||||
public static int checkRegisterRangeCount(int registerCount) {
|
||||
if ((registerCount & 0xFFFFFF00) != 0) {
|
||||
throw new IllegalArgumentException(
|
||||
|
@ -1006,9 +1006,6 @@ public abstract class DexWriter<
|
||||
case Format23x:
|
||||
instructionWriter.write((Instruction23x)instruction);
|
||||
break;
|
||||
case Format25x:
|
||||
instructionWriter.write((Instruction25x)instruction);
|
||||
break;
|
||||
case Format30t:
|
||||
instructionWriter.write((Instruction30t)instruction);
|
||||
break;
|
||||
|
@ -343,20 +343,6 @@ public class InstructionWriter<StringRef extends StringReference, TypeRef extend
|
||||
}
|
||||
}
|
||||
|
||||
public void write(@Nonnull Instruction25x instruction) {
|
||||
try {
|
||||
writer.write(getOpcodeValue(instruction.getOpcode()));
|
||||
writer.write(packNibbles(
|
||||
instruction.getRegisterParameterG(), instruction.getParameterRegisterCount()));
|
||||
writer.write(packNibbles(
|
||||
instruction.getRegisterFixedC(), instruction.getRegisterParameterD()));
|
||||
writer.write(packNibbles(
|
||||
instruction.getRegisterParameterE(), instruction.getRegisterParameterF()));
|
||||
} catch (IOException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void write(@Nonnull Instruction3rc instruction) {
|
||||
try {
|
||||
writer.write(getOpcodeValue(instruction.getOpcode()));
|
||||
|
@ -1,8 +0,0 @@
|
||||
# Functional interface used by HelloWorld.smali
|
||||
# Required in order to reify the lambda with create-lambda or unbox-lambda instructions
|
||||
|
||||
.class public abstract interface LHelloWorldFunctionalInterface;
|
||||
.super Ljava/lang/Object;
|
||||
|
||||
.method public abstract applyFourStrings(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
|
||||
.end method
|
@ -1,57 +0,0 @@
|
||||
.class public LHelloWorldLambda;
|
||||
|
||||
#Ye olde hello world application (with lambdas!)
|
||||
#To assemble and run this on a phone or emulator:
|
||||
#
|
||||
#java -jar smali.jar -o classes.dex HelloWorldLambda.smali HelloWorldFunctionalInterface.smali
|
||||
#zip HelloWorld.zip classes.dex
|
||||
#adb push HelloWorld.zip /data/local
|
||||
#adb shell dalvikvm -cp /data/local/HelloWorld.zip HelloWorld
|
||||
#
|
||||
#if you get out of memory type errors when running smali.jar, try
|
||||
#java -Xmx512m -jar smali.jar HelloWorldLambda.smali
|
||||
#instead
|
||||
|
||||
.super Ljava/lang/Object;
|
||||
|
||||
.method public static main([Ljava/lang/String;)V
|
||||
.registers 9 # 1 parameter, 8 locals
|
||||
|
||||
sget-object v0, Ljava/lang/System;->out:Ljava/io/PrintStream;
|
||||
|
||||
const-string v1, "Hello World!"
|
||||
const-string v2, "How" # vD
|
||||
const-string v3, "are" # vE
|
||||
const-string v4, "you" # vF
|
||||
const-string v5, "doing?" # vG
|
||||
|
||||
capture-variable v1, "helloworld"
|
||||
|
||||
# TODO: do I need to pass the type of the lambda's functional interface here as a type id?
|
||||
create-lambda v1, LHelloWorldLambda;->doHelloWorld(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
|
||||
# Method descriptor is not required here, because only the single-abstract method is ever invoked.
|
||||
invoke-lambda v1, {v2, v3, v4, v5}
|
||||
|
||||
box-lambda v6, v1 # The type of v6 is now 'LHelloWorldFunctionalInterface;'
|
||||
invoke-virtual {v6, v2, v3, v4, v5}, LHelloWorldFunctionalInterface;->applyFourStrings(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
|
||||
|
||||
# FIXME: should be \HelloWorldFunctionalInterface; instead of L...;
|
||||
|
||||
# TODO: do we really need the type descriptor here at all?
|
||||
unbox-lambda v7, v6, LHelloWorldFunctionalInterface; # The type of v7 is now \HelloWorldFunctionalInterface;
|
||||
invoke-lambda v7, {v2, v3, v4, v5}
|
||||
|
||||
return-void
|
||||
.end method
|
||||
|
||||
.method public static doHelloWorld(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
|
||||
.registers 6 # 4 parameters, 2 locals
|
||||
|
||||
# This helloworld variable is brought to you by the variable liberation front
|
||||
liberate-variable v0, p0, "helloworld"
|
||||
|
||||
sget-object v1, Ljava/lang/System;->out:Ljava/io/PrintStream;
|
||||
invoke-virtual {v1, v0}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V
|
||||
|
||||
return-void
|
||||
.end method
|
@ -86,8 +86,6 @@ tokens {
|
||||
INSTRUCTION_FORMAT21c_FIELD_ODEX;
|
||||
INSTRUCTION_FORMAT21c_STRING;
|
||||
INSTRUCTION_FORMAT21c_TYPE;
|
||||
INSTRUCTION_FORMAT21c_LAMBDA;
|
||||
INSTRUCTION_FORMAT21c_METHOD;
|
||||
INSTRUCTION_FORMAT21ih;
|
||||
INSTRUCTION_FORMAT21lh;
|
||||
INSTRUCTION_FORMAT21s;
|
||||
@ -96,14 +94,12 @@ tokens {
|
||||
INSTRUCTION_FORMAT22c_FIELD;
|
||||
INSTRUCTION_FORMAT22c_FIELD_ODEX;
|
||||
INSTRUCTION_FORMAT22c_TYPE;
|
||||
INSTRUCTION_FORMAT22c_STRING;
|
||||
INSTRUCTION_FORMAT22cs_FIELD;
|
||||
INSTRUCTION_FORMAT22s;
|
||||
INSTRUCTION_FORMAT22s_OR_ID;
|
||||
INSTRUCTION_FORMAT22t;
|
||||
INSTRUCTION_FORMAT22x;
|
||||
INSTRUCTION_FORMAT23x;
|
||||
INSTRUCTION_FORMAT25x;
|
||||
INSTRUCTION_FORMAT30t;
|
||||
INSTRUCTION_FORMAT31c;
|
||||
INSTRUCTION_FORMAT31i;
|
||||
@ -212,8 +208,6 @@ tokens {
|
||||
I_STATEMENT_FORMAT21c_TYPE;
|
||||
I_STATEMENT_FORMAT21c_FIELD;
|
||||
I_STATEMENT_FORMAT21c_STRING;
|
||||
I_STATEMENT_FORMAT21c_LAMBDA;
|
||||
I_STATEMENT_FORMAT21c_METHOD;
|
||||
I_STATEMENT_FORMAT21ih;
|
||||
I_STATEMENT_FORMAT21lh;
|
||||
I_STATEMENT_FORMAT21s;
|
||||
@ -221,12 +215,10 @@ tokens {
|
||||
I_STATEMENT_FORMAT22b;
|
||||
I_STATEMENT_FORMAT22c_FIELD;
|
||||
I_STATEMENT_FORMAT22c_TYPE;
|
||||
I_STATEMENT_FORMAT22c_STRING;
|
||||
I_STATEMENT_FORMAT22s;
|
||||
I_STATEMENT_FORMAT22t;
|
||||
I_STATEMENT_FORMAT22x;
|
||||
I_STATEMENT_FORMAT23x;
|
||||
I_STATEMENT_FORMAT25x;
|
||||
I_STATEMENT_FORMAT30t;
|
||||
I_STATEMENT_FORMAT31c;
|
||||
I_STATEMENT_FORMAT31i;
|
||||
@ -566,18 +558,14 @@ simple_name
|
||||
| INSTRUCTION_FORMAT21c_FIELD_ODEX -> SIMPLE_NAME[$INSTRUCTION_FORMAT21c_FIELD_ODEX]
|
||||
| INSTRUCTION_FORMAT21c_STRING -> SIMPLE_NAME[$INSTRUCTION_FORMAT21c_STRING]
|
||||
| INSTRUCTION_FORMAT21c_TYPE -> SIMPLE_NAME[$INSTRUCTION_FORMAT21c_TYPE]
|
||||
| INSTRUCTION_FORMAT21c_LAMBDA -> SIMPLE_NAME[$INSTRUCTION_FORMAT21c_LAMBDA]
|
||||
| INSTRUCTION_FORMAT21c_METHOD -> SIMPLE_NAME[$INSTRUCTION_FORMAT21c_METHOD]
|
||||
| INSTRUCTION_FORMAT21t -> SIMPLE_NAME[$INSTRUCTION_FORMAT21t]
|
||||
| INSTRUCTION_FORMAT22c_FIELD -> SIMPLE_NAME[$INSTRUCTION_FORMAT22c_FIELD]
|
||||
| INSTRUCTION_FORMAT22c_FIELD_ODEX -> SIMPLE_NAME[$INSTRUCTION_FORMAT22c_FIELD_ODEX]
|
||||
| INSTRUCTION_FORMAT22c_TYPE -> SIMPLE_NAME[$INSTRUCTION_FORMAT22c_TYPE]
|
||||
| INSTRUCTION_FORMAT22c_STRING -> SIMPLE_NAME[$INSTRUCTION_FORMAT22c_STRING]
|
||||
| INSTRUCTION_FORMAT22cs_FIELD -> SIMPLE_NAME[$INSTRUCTION_FORMAT22cs_FIELD]
|
||||
| INSTRUCTION_FORMAT22s_OR_ID -> SIMPLE_NAME[$INSTRUCTION_FORMAT22s_OR_ID]
|
||||
| INSTRUCTION_FORMAT22t -> SIMPLE_NAME[$INSTRUCTION_FORMAT22t]
|
||||
| INSTRUCTION_FORMAT23x -> SIMPLE_NAME[$INSTRUCTION_FORMAT23x]
|
||||
| INSTRUCTION_FORMAT25x -> SIMPLE_NAME[$INSTRUCTION_FORMAT25x]
|
||||
| INSTRUCTION_FORMAT31i_OR_ID -> SIMPLE_NAME[$INSTRUCTION_FORMAT31i_OR_ID]
|
||||
| INSTRUCTION_FORMAT31t -> SIMPLE_NAME[$INSTRUCTION_FORMAT31t]
|
||||
| INSTRUCTION_FORMAT35c_METHOD -> SIMPLE_NAME[$INSTRUCTION_FORMAT35c_METHOD]
|
||||
@ -823,8 +811,6 @@ instruction
|
||||
| insn_format21c_field_odex
|
||||
| insn_format21c_string
|
||||
| insn_format21c_type
|
||||
| insn_format21c_lambda
|
||||
| insn_format21c_method
|
||||
| insn_format21ih
|
||||
| insn_format21lh
|
||||
| insn_format21s
|
||||
@ -833,13 +819,11 @@ instruction
|
||||
| insn_format22c_field
|
||||
| insn_format22c_field_odex
|
||||
| insn_format22c_type
|
||||
| insn_format22c_string
|
||||
| insn_format22cs_field
|
||||
| insn_format22s
|
||||
| insn_format22t
|
||||
| insn_format22x
|
||||
| insn_format23x
|
||||
| insn_format25x
|
||||
| insn_format30t
|
||||
| insn_format31c
|
||||
| insn_format31i
|
||||
@ -935,16 +919,6 @@ insn_format21c_type
|
||||
INSTRUCTION_FORMAT21c_TYPE REGISTER COMMA nonvoid_type_descriptor
|
||||
-> ^(I_STATEMENT_FORMAT21c_TYPE[$start, "I_STATEMENT_FORMAT21c"] INSTRUCTION_FORMAT21c_TYPE REGISTER nonvoid_type_descriptor);
|
||||
|
||||
insn_format21c_lambda
|
||||
: //e.g. capture-variable v1, "foobar"
|
||||
INSTRUCTION_FORMAT21c_LAMBDA REGISTER COMMA STRING_LITERAL
|
||||
-> ^(I_STATEMENT_FORMAT21c_LAMBDA[$start, "I_STATEMENT_FORMAT21c_LAMBDA"] INSTRUCTION_FORMAT21c_LAMBDA REGISTER STRING_LITERAL);
|
||||
|
||||
insn_format21c_method
|
||||
: //e.g. create-lambda v1, java/io/PrintStream/print(Ljava/lang/Stream;)V
|
||||
INSTRUCTION_FORMAT21c_METHOD REGISTER COMMA method_reference
|
||||
-> ^(I_STATEMENT_FORMAT21c_METHOD[$start, "I_STATEMENT_FORMAT21c_METHOD"] INSTRUCTION_FORMAT21c_METHOD REGISTER method_reference);
|
||||
|
||||
insn_format21ih
|
||||
: //e.g. const/high16 v1, 1234
|
||||
INSTRUCTION_FORMAT21ih REGISTER COMMA fixed_32bit_literal
|
||||
@ -990,11 +964,6 @@ insn_format22c_type
|
||||
INSTRUCTION_FORMAT22c_TYPE REGISTER COMMA REGISTER COMMA nonvoid_type_descriptor
|
||||
-> ^(I_STATEMENT_FORMAT22c_TYPE[$start, "I_STATEMENT_FORMAT22c_TYPE"] INSTRUCTION_FORMAT22c_TYPE REGISTER REGISTER nonvoid_type_descriptor);
|
||||
|
||||
insn_format22c_string
|
||||
: //e.g. liberate-variable v0, v1, "baz"
|
||||
INSTRUCTION_FORMAT22c_STRING REGISTER COMMA REGISTER COMMA STRING_LITERAL
|
||||
-> ^(I_STATEMENT_FORMAT22c_STRING[$start, "I_STATEMENT_FORMAT22c_STRING"] INSTRUCTION_FORMAT22c_STRING REGISTER REGISTER STRING_LITERAL);
|
||||
|
||||
insn_format22cs_field
|
||||
: //e.g. iget-quick v0, v1, field@0xc
|
||||
INSTRUCTION_FORMAT22cs_FIELD REGISTER COMMA REGISTER COMMA FIELD_OFFSET
|
||||
@ -1022,11 +991,6 @@ insn_format23x
|
||||
INSTRUCTION_FORMAT23x REGISTER COMMA REGISTER COMMA REGISTER
|
||||
-> ^(I_STATEMENT_FORMAT23x[$start, "I_STATEMENT_FORMAT23x"] INSTRUCTION_FORMAT23x REGISTER REGISTER REGISTER);
|
||||
|
||||
insn_format25x
|
||||
: //e.g. invoke-lambda vClosure, {vA, vB, vC, vD} -- up to 4 parameters + the closure.
|
||||
INSTRUCTION_FORMAT25x REGISTER COMMA OPEN_BRACE register_list CLOSE_BRACE
|
||||
-> ^(I_STATEMENT_FORMAT25x[$start, "I_STATEMENT_FORMAT25x"] INSTRUCTION_FORMAT25x REGISTER register_list);
|
||||
|
||||
insn_format30t
|
||||
: //e.g. goto/32 endloop:
|
||||
INSTRUCTION_FORMAT30t label_ref
|
||||
|
@ -675,22 +675,6 @@ register_list returns[byte[\] registers, byte registerCount]
|
||||
$registers[$registerCount++] = parseRegister_nibble($REGISTER.text);
|
||||
})*);
|
||||
|
||||
register_list4 returns[byte[\] registers, byte registerCount]
|
||||
@init
|
||||
{
|
||||
$registers = new byte[4];
|
||||
$registerCount = 0;
|
||||
}
|
||||
: ^(I_REGISTER_LIST
|
||||
(REGISTER
|
||||
{
|
||||
if ($registerCount == 4) {
|
||||
throw new SemanticException(input, $I_REGISTER_LIST, "A list4 of registers can only have a maximum of 4 " +
|
||||
"registers. Use the <op>/range alternate opcode instead.");
|
||||
}
|
||||
$registers[$registerCount++] = parseRegister_nibble($REGISTER.text);
|
||||
})*);
|
||||
|
||||
register_range returns[int startRegister, int endRegister]
|
||||
: ^(I_REGISTER_RANGE (startReg=REGISTER endReg=REGISTER?)?)
|
||||
{
|
||||
@ -743,8 +727,6 @@ instruction
|
||||
| insn_format21c_field
|
||||
| insn_format21c_string
|
||||
| insn_format21c_type
|
||||
| insn_format21c_lambda
|
||||
| insn_format21c_method
|
||||
| insn_format21ih
|
||||
| insn_format21lh
|
||||
| insn_format21s
|
||||
@ -752,12 +734,10 @@ instruction
|
||||
| insn_format22b
|
||||
| insn_format22c_field
|
||||
| insn_format22c_type
|
||||
| insn_format22c_string
|
||||
| insn_format22s
|
||||
| insn_format22t
|
||||
| insn_format22x
|
||||
| insn_format23x
|
||||
| insn_format25x
|
||||
| insn_format30t
|
||||
| insn_format31c
|
||||
| insn_format31i
|
||||
@ -884,30 +864,6 @@ insn_format21c_type
|
||||
dexBuilder.internTypeReference($nonvoid_type_descriptor.type)));
|
||||
};
|
||||
|
||||
insn_format21c_lambda
|
||||
: //e.g. capture-variable v1, "foobar"
|
||||
^(I_STATEMENT_FORMAT21c_LAMBDA INSTRUCTION_FORMAT21c_LAMBDA REGISTER string_literal)
|
||||
{
|
||||
Opcode opcode = opcodes.getOpcodeByName($INSTRUCTION_FORMAT21c_LAMBDA.text);
|
||||
short regA = parseRegister_byte($REGISTER.text);
|
||||
|
||||
$method::methodBuilder.addInstruction(new BuilderInstruction21c(opcode, regA,
|
||||
dexBuilder.internStringReference($string_literal.value)));
|
||||
};
|
||||
|
||||
insn_format21c_method
|
||||
: //e.g. create-lambda v1, java/io/PrintStream/print(Ljava/lang/Stream;)V
|
||||
^(I_STATEMENT_FORMAT21c_METHOD INSTRUCTION_FORMAT21c_METHOD REGISTER method_reference)
|
||||
{
|
||||
Opcode opcode = opcodes.getOpcodeByName($INSTRUCTION_FORMAT21c_METHOD.text);
|
||||
short regA = parseRegister_byte($REGISTER.text);
|
||||
|
||||
ImmutableMethodReference methodReference = $method_reference.methodReference;
|
||||
|
||||
$method::methodBuilder.addInstruction(new BuilderInstruction21c(opcode, regA,
|
||||
dexBuilder.internMethodReference(methodReference)));
|
||||
};
|
||||
|
||||
insn_format21ih
|
||||
: //e.g. const/high16 v1, 1234
|
||||
^(I_STATEMENT_FORMAT21ih INSTRUCTION_FORMAT21ih REGISTER fixed_32bit_literal)
|
||||
@ -994,18 +950,6 @@ insn_format22c_type
|
||||
dexBuilder.internTypeReference($nonvoid_type_descriptor.type)));
|
||||
};
|
||||
|
||||
insn_format22c_string
|
||||
: //e.g. liberate-variable v0, v1, "baz"
|
||||
^(I_STATEMENT_FORMAT22c_STRING INSTRUCTION_FORMAT22c_STRING registerA=REGISTER registerB=REGISTER string_literal)
|
||||
{
|
||||
Opcode opcode = opcodes.getOpcodeByName($INSTRUCTION_FORMAT22c_STRING.text);
|
||||
byte regA = parseRegister_nibble($registerA.text);
|
||||
byte regB = parseRegister_nibble($registerB.text);
|
||||
|
||||
$method::methodBuilder.addInstruction(new BuilderInstruction22c(opcode, regA, regB,
|
||||
dexBuilder.internStringReference($string_literal.value)));
|
||||
};
|
||||
|
||||
insn_format22s
|
||||
: //e.g. add-int/lit16 v0, v1, 12345
|
||||
^(I_STATEMENT_FORMAT22s INSTRUCTION_FORMAT22s registerA=REGISTER registerB=REGISTER short_integral_literal)
|
||||
@ -1053,23 +997,6 @@ insn_format23x
|
||||
$method::methodBuilder.addInstruction(new BuilderInstruction23x(opcode, regA, regB, regC));
|
||||
};
|
||||
|
||||
insn_format25x
|
||||
: //e.g. invoke-lambda vClosure, {vD, vE, vF, vG} -- up to 4 parameters + the closure.
|
||||
^(I_STATEMENT_FORMAT25x INSTRUCTION_FORMAT25x REGISTER register_list4)
|
||||
{
|
||||
Opcode opcode = opcodes.getOpcodeByName($INSTRUCTION_FORMAT25x.text);
|
||||
|
||||
byte closureRegister = parseRegister_nibble($REGISTER.text);
|
||||
|
||||
//this depends on the fact that register_list4 returns a byte[4]
|
||||
byte[] registers = $register_list4.registers;
|
||||
int parameterRegisterCount = $register_list4.registerCount; // don't count closure register
|
||||
|
||||
$method::methodBuilder.addInstruction(new BuilderInstruction25x(opcode,
|
||||
parameterRegisterCount, closureRegister, registers[0], registers[1],
|
||||
registers[2], registers[3]));
|
||||
};
|
||||
|
||||
insn_format30t
|
||||
: //e.g. goto/32 endloop:
|
||||
^(I_STATEMENT_FORMAT30t INSTRUCTION_FORMAT30t label_ref)
|
||||
|
@ -476,14 +476,6 @@ Type = {PrimitiveType} | {ClassDescriptor} | {ArrayPrefix} ({ClassDescriptor} |
|
||||
return newToken(INSTRUCTION_FORMAT21c_TYPE);
|
||||
}
|
||||
|
||||
"capture-variable" { // e.g. 'capture-variable vB, <string id>'
|
||||
return newToken(INSTRUCTION_FORMAT21c_LAMBDA);
|
||||
}
|
||||
|
||||
"create-lambda" { // e.g. 'create-lambda vClosure, <method id>'
|
||||
return newToken(INSTRUCTION_FORMAT21c_METHOD);
|
||||
}
|
||||
|
||||
"const/high16" {
|
||||
return newToken(INSTRUCTION_FORMAT21ih);
|
||||
}
|
||||
@ -515,14 +507,10 @@ Type = {PrimitiveType} | {ClassDescriptor} | {ArrayPrefix} ({ClassDescriptor} |
|
||||
return newToken(INSTRUCTION_FORMAT22c_FIELD_ODEX);
|
||||
}
|
||||
|
||||
"instance-of" | "new-array" | "unbox-lambda" {
|
||||
"instance-of" | "new-array" {
|
||||
return newToken(INSTRUCTION_FORMAT22c_TYPE);
|
||||
}
|
||||
|
||||
"liberate-variable" {
|
||||
return newToken(INSTRUCTION_FORMAT22c_STRING);
|
||||
}
|
||||
|
||||
"iget-quick" | "iget-wide-quick" | "iget-object-quick" | "iput-quick" | "iput-wide-quick" | "iput-object-quick" |
|
||||
"iput-boolean-quick" | "iput-byte-quick" | "iput-char-quick" | "iput-short-quick" {
|
||||
return newToken(INSTRUCTION_FORMAT22cs_FIELD);
|
||||
@ -541,7 +529,7 @@ Type = {PrimitiveType} | {ClassDescriptor} | {ArrayPrefix} ({ClassDescriptor} |
|
||||
return newToken(INSTRUCTION_FORMAT22t);
|
||||
}
|
||||
|
||||
"move/from16" | "move-wide/from16" | "move-object/from16" | "box-lambda" {
|
||||
"move/from16" | "move-wide/from16" | "move-object/from16" {
|
||||
return newToken(INSTRUCTION_FORMAT22x);
|
||||
}
|
||||
|
||||
@ -555,10 +543,6 @@ Type = {PrimitiveType} | {ClassDescriptor} | {ArrayPrefix} ({ClassDescriptor} |
|
||||
return newToken(INSTRUCTION_FORMAT23x);
|
||||
}
|
||||
|
||||
"invoke-lambda" { // e.g. invoke-lambda vClosure, {vD, vE, vF, vG} -- at most 4 params
|
||||
return newToken(INSTRUCTION_FORMAT25x);
|
||||
}
|
||||
|
||||
"goto/32" {
|
||||
return newToken(INSTRUCTION_FORMAT30t);
|
||||
}
|
||||
|
@ -85,8 +85,6 @@ const-string
|
||||
check-cast
|
||||
new-instance
|
||||
const-class
|
||||
capture-variable
|
||||
create-lambda
|
||||
const/high16
|
||||
const-wide/high16
|
||||
const/16
|
||||
@ -125,8 +123,6 @@ iput-wide-volatile
|
||||
iput-object-volatile
|
||||
instance-of
|
||||
new-array
|
||||
unbox-lambda
|
||||
liberate-variable
|
||||
iget-quick
|
||||
iget-wide-quick
|
||||
iget-object-quick
|
||||
@ -153,7 +149,6 @@ if-le
|
||||
move/from16
|
||||
move-wide/from16
|
||||
move-object/from16
|
||||
box-lambda
|
||||
cmpl-float
|
||||
cmpg-float
|
||||
cmpl-double
|
||||
@ -204,7 +199,6 @@ add-double
|
||||
sub-double
|
||||
mul-double
|
||||
div-double
|
||||
invoke-lambda
|
||||
goto/32
|
||||
const-string/jumbo
|
||||
const
|
||||
|
@ -85,8 +85,6 @@ INSTRUCTION_FORMAT21c_STRING("const-string")
|
||||
INSTRUCTION_FORMAT21c_TYPE("check-cast")
|
||||
INSTRUCTION_FORMAT21c_TYPE("new-instance")
|
||||
INSTRUCTION_FORMAT21c_TYPE("const-class")
|
||||
INSTRUCTION_FORMAT21c_LAMBDA("capture-variable")
|
||||
INSTRUCTION_FORMAT21c_METHOD("create-lambda")
|
||||
INSTRUCTION_FORMAT21ih("const/high16")
|
||||
INSTRUCTION_FORMAT21lh("const-wide/high16")
|
||||
INSTRUCTION_FORMAT21s("const/16")
|
||||
@ -125,8 +123,6 @@ INSTRUCTION_FORMAT22c_FIELD_ODEX("iput-wide-volatile")
|
||||
INSTRUCTION_FORMAT22c_FIELD_ODEX("iput-object-volatile")
|
||||
INSTRUCTION_FORMAT22c_TYPE("instance-of")
|
||||
INSTRUCTION_FORMAT22c_TYPE("new-array")
|
||||
INSTRUCTION_FORMAT22c_TYPE("unbox-lambda")
|
||||
INSTRUCTION_FORMAT22c_STRING("liberate-variable")
|
||||
INSTRUCTION_FORMAT22cs_FIELD("iget-quick")
|
||||
INSTRUCTION_FORMAT22cs_FIELD("iget-wide-quick")
|
||||
INSTRUCTION_FORMAT22cs_FIELD("iget-object-quick")
|
||||
@ -153,7 +149,6 @@ INSTRUCTION_FORMAT22t("if-le")
|
||||
INSTRUCTION_FORMAT22x("move/from16")
|
||||
INSTRUCTION_FORMAT22x("move-wide/from16")
|
||||
INSTRUCTION_FORMAT22x("move-object/from16")
|
||||
INSTRUCTION_FORMAT22x("box-lambda")
|
||||
INSTRUCTION_FORMAT23x("cmpl-float")
|
||||
INSTRUCTION_FORMAT23x("cmpg-float")
|
||||
INSTRUCTION_FORMAT23x("cmpl-double")
|
||||
@ -204,7 +199,6 @@ INSTRUCTION_FORMAT23x("add-double")
|
||||
INSTRUCTION_FORMAT23x("sub-double")
|
||||
INSTRUCTION_FORMAT23x("mul-double")
|
||||
INSTRUCTION_FORMAT23x("div-double")
|
||||
INSTRUCTION_FORMAT25x("invoke-lambda")
|
||||
INSTRUCTION_FORMAT30t("goto/32")
|
||||
INSTRUCTION_FORMAT31c("const-string/jumbo")
|
||||
INSTRUCTION_FORMAT31i_OR_ID("const")
|
||||
|
Loading…
x
Reference in New Issue
Block a user