Exemplo n.º 1
0
  public Block initializeVariable(LocalVariableDefinition variable) {
    ParameterizedType type = variable.getType();
    if (type.getType().length() == 1) {
      switch (type.getType().charAt(0)) {
        case 'B':
        case 'Z':
        case 'S':
        case 'C':
        case 'I':
          nodes.add(loadInt(0));
          break;
        case 'F':
          nodes.add(loadFloat(0));
          break;
        case 'D':
          nodes.add(loadDouble(0));
          break;
        case 'J':
          nodes.add(loadLong(0));
          break;
        default:
          checkArgument(false, "Unknown type '%s'", variable.getType());
      }
    } else {
      nodes.add(Constant.loadNull());
    }

    nodes.add(VariableInstruction.storeVariable(variable));

    return this;
  }
Exemplo n.º 2
0
 public Block incrementVariable(LocalVariableDefinition variable, byte increment) {
   String type = variable.getType().getClassName();
   Preconditions.checkArgument(
       ImmutableList.of("byte", "short", "int").contains(type),
       "variable must be an byte, short or int, but is %s",
       type);
   nodes.add(VariableInstruction.incrementVariable(variable, increment));
   return this;
 }
Exemplo n.º 3
0
 public Block putVariable(LocalVariableDefinition variable) {
   nodes.add(VariableInstruction.storeVariable(variable));
   return this;
 }
Exemplo n.º 4
0
 public Block getVariable(LocalVariableDefinition variable) {
   nodes.add(VariableInstruction.loadVariable(variable));
   return this;
 }