Exemplo n.º 1
0
  /**
   * @ast method
   * @aspect Expressions
   * @declaredat
   *     /Users/eric/Documents/workspaces/clara-soot/JastAddExtensions/JimpleBackend/Expressions.jrag:84
   */
  public soot.Value eval(Body b) {
    TypeDecl dest = getDest().type();
    TypeDecl source = getSource().type();
    if (dest.isString()) {

      Value lvalue = getDest().eval(b);

      Value v = asImmediate(b, lvalue);

      // new StringBuffer(left)
      Local local =
          b.newTemp(b.newNewExpr(lookupType("java.lang", "StringBuffer").sootRef(), this));
      b.setLine(this);
      b.add(
          b.newInvokeStmt(
              b.newSpecialInvokeExpr(
                  local,
                  Scene.v()
                      .getMethod("<java.lang.StringBuffer: void <init>(java.lang.String)>")
                      .makeRef(),
                  v,
                  this),
              this));

      // append right
      Local rightResult =
          b.newTemp(
              b.newVirtualInvokeExpr(
                  local,
                  lookupType("java.lang", "StringBuffer")
                      .methodWithArgs("append", new TypeDecl[] {source.stringPromotion()})
                      .sootRef(),
                  asImmediate(b, getSource().eval(b)),
                  this));

      // toString
      Local result =
          b.newTemp(
              b.newVirtualInvokeExpr(
                  rightResult,
                  Scene.v()
                      .getMethod("<java.lang.StringBuffer: java.lang.String toString()>")
                      .makeRef(),
                  this));

      Value v2 = lvalue instanceof Local ? lvalue : (Value) lvalue.clone();
      getDest().emitStore(b, v2, result, this);
      return result;
    } else {
      return super.eval(b);
    }
  }
Exemplo n.º 2
0
    public final void write() {
      List<EnumConstantInfo> options = fieldAnnotationEnumArray("options");

      StringBuilder format = new StringBuilder();
      format(format);
      formatOptions(format, options);
      format.append(")");

      List<Object> args = new ArrayList<>();
      args(args);
      args.add(fieldAnnotationIntValue("precision"));
      args.add(fieldAnnotationIntValue("scale"));
      argsOptions(args, options);

      body.add(format.toString(), args.toArray());
    }
Exemplo n.º 3
0
 /**
  * @ast method
  * @aspect Statements
  * @declaredat
  *     /Users/eric/Documents/workspaces/clara-soot/JastAddExtensions/JimpleBackend/Statements.jrag:312
  */
 public void jimplify2(Body b) {
   b.setLine(this);
   b.add(b.newThrowStmt(asImmediate(b, getExpr().eval(b)), this));
 }
Exemplo n.º 4
0
 @Override
 void recordWriterCode(Body body) {
   body.add(".fixed($L)", property.name());
 }