Package org.renjin.compiler.ir.tac.expressions

Examples of org.renjin.compiler.ir.tac.expressions.Expression


  }

  private void search(BasicBlock X) {
   
    for(Statement stmt : X.getStatements()) {
      Expression rhs = stmt.getRHS();
      if(!(rhs instanceof PhiFunction)) {
        for(Variable V : rhs.variables()) {
          int i = Top(V);
          rhs = rhs.replaceVariable(V, new SsaVariable(V, i));
        }
        stmt = X.replaceStatement(stmt, stmt.withRHS(rhs));
      }
     
      if(stmt instanceof Assignment) {
        Assignment assignment = (Assignment)stmt;
        if(assignment.getLHS() instanceof Variable) {
          Variable V = (Variable)assignment.getLHS();
          int i = C.get(V);
          X.replaceStatement(assignment, assignment.withLHS(new SsaVariable(V, i)));
          S.get(V).push(i);
          C.put(V, i + 1);
        }
      }
    }
   
    for(BasicBlock Y : cfg.getSuccessors(X)) {
      int j = whichPred(Y,X);
      for (Assignment A : Lists.newArrayList(Y.phiAssignments())) {
        PhiFunction rhs = (PhiFunction) A.getRHS();
        Variable V = rhs.getArgument(j);
        int i = Top(V);
        rhs = rhs.replaceVariable(j, i);
        Y.replaceStatement(A, new Assignment(A.getLHS(), rhs));
        // replace the j-th operand V in RHS(F) by V_i where i = Top(S(V))
      }
    }
    for(BasicBlock Y : dtree.getChildren(X)) {
View Full Code Here


  @Override
  public Expression translateToExpression(IRBodyBuilder builder,
      TranslationContext context, FunctionCall call) {
   
    Expression object = builder.translateExpression(context, call.getArgument(0));
    Symbol index = call.getArgument(1);
    Expression replacement = builder.translateExpression(context, call.getArgument(2));
   
    return new PrimitiveCall(call, "$<-", builder.simplify(object), new Constant(index), replacement);
  }
View Full Code Here

  @Override
  public Expression translateToSetterExpression(IRBodyBuilder builder,
      TranslationContext context, FunctionCall call, Expression rhs) {
   
    Expression object = builder.translateExpression(context, call.getArgument(0));
    Symbol index = call.getArgument(1);
   
    return new PrimitiveCall(call, "$<-", object, new Constant(index), builder.simplify(rhs));
 
  }
View Full Code Here


  private void embed(TreeNode treeNode) {
    List<Expression> children = treeNode.getChildren();
    for(int i=0;i!=children.size();++i) {
      Expression child = children.get(i);
      if(usedOnce.contains(child)) {
        Assignment assignment = definition.get(child);
        if(assignment != null) {
          treeNode.setChild(i, assignment.getRHS());
          embeded.add(assignment);
View Full Code Here

  }

  @Override
  public Expression translateToExpression(IRBodyBuilder builder,
      TranslationContext context, FunctionCall call) {
    Expression object = builder.translateExpression(context, call.getArgument(0));
    Symbol index = toSymbol(call.getArgument(1));
   
    return new PrimitiveCall(call, "$", builder.simplify(object), new Constant(index) );
  }
View Full Code Here

   
    // pass the argument to switch unevaluated, we'll implement
    // tranlsation into IR later when we upgrade to 2.14 base package,
    // in which switch() is not internal.
   
    Expression expr = builder.translateSimpleExpression(context, call.getArgument(0));
   
    return new PrimitiveCall(call, "switch", expr, new EnvironmentVariable(Symbols.ELLIPSES));
           
  }
View Full Code Here

    IfStatement jump = new IfStatement(condition, trueTarget, falseTarget);
    builder.addStatement(jump);
   
    // evaluate "if true" expression
    builder.addLabel(trueTarget);
    Expression ifTrueResult = builder.translateExpression(context, call.getArgument(1));
   
    // assign this result to our temp value
    builder.addStatement(new Assignment(ifResult, ifTrueResult));

    builder.addStatement(new GotoStatement(endLabel));
   
    builder.addLabel(falseTarget);
   
    // next evaluate "if false" expression
    // if the false clause is absent, it evaluates to
    // NULL
    Expression ifFalseResult;
    if(hasElse(call)) {
      ifFalseResult = builder.translateSimpleExpression(context, call.getArgument(2));
    } else {
      ifFalseResult = new Constant(Null.INSTANCE);
    }
View Full Code Here

    LocalVariable counter = factory.newLocalVariable();
    Temp length = factory.newTemp();
   
    Variable elementVariable = new EnvironmentVariable(symbol);
   
    Expression vector =
        factory.translateSimpleExpression(context, call.getArgument(1));
   
    SEXP body = call.getArgument(2);

    IRLabel counterLabel = factory.newLabel();
View Full Code Here

TOP

Related Classes of org.renjin.compiler.ir.tac.expressions.Expression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.