コード例 #1
0
ファイル: JForStatement.java プロジェクト: rosatonj/j---h4-
 public void writeToStdOut(PrettyPrinter p) {
   p.printf("<JForStatement line=\"%d\">\n", line());
   p.indentRight();
   p.printf("<Initialization>\n");
   p.indentRight();
   initialize.writeToStdOut(p);
   p.indentLeft();
   p.printf("</Initialization>\n");
   p.printf("<Termination>\n");
   p.indentRight();
   terminate.writeToStdOut(p);
   p.indentLeft();
   p.printf("</Termination>\n");
   p.printf("<Update>\n");
   p.indentRight();
   update.writeToStdOut(p);
   p.indentLeft();
   p.printf("</Update>\n");
   p.printf("<Consequent>\n");
   p.indentRight();
   block.writeToStdOut(p);
   p.indentLeft();
   p.printf("</Consequent>\n");
   p.indentLeft();
   p.printf("</JForStatement>\n");
 }
コード例 #2
0
 /** Accepts the specified visitor. */
 public void accept(KjcVisitor p) {
   if (p instanceof SLIRVisitor) {
     ((SLIRVisitor) p).visitPushExpression(this, tapeType, arg);
   } else {
     // otherwise, visit the argument
     arg.accept(p);
   }
 }
コード例 #3
0
 /**
  * Clones all fields of this into
  *
  * <pre>other</pre>
  */
 protected void deepCloneInto(at.dms.kjc.JMethodCallExpression other) {
   super.deepCloneInto(other);
   other.prefix = (at.dms.kjc.JExpression) at.dms.kjc.AutoCloner.cloneToplevel(this.prefix);
   other.ident = (java.lang.String) at.dms.kjc.AutoCloner.cloneToplevel(this.ident);
   other.args = (at.dms.kjc.JExpression[]) at.dms.kjc.AutoCloner.cloneToplevel(this.args);
   other.method = (at.dms.kjc.CMethod) at.dms.kjc.AutoCloner.cloneToplevel(this.method);
   other.tapeType = (at.dms.kjc.CType) at.dms.kjc.AutoCloner.cloneToplevel(this.tapeType);
 }
コード例 #4
0
  /** Optimize a bi-conditional expression */
  protected void genBranch(
      JExpression left,
      JExpression right,
      boolean cond,
      GenerationContext context,
      CodeLabel label) {
    CodeSequence code = context.getCodeSequence();

    if (cond) {
      CodeLabel skip = new CodeLabel();
      left.genBranch(false, context, skip);
      right.genBranch(true, context, label);
      code.plantLabel(skip);
    } else {
      left.genBranch(false, context, label);
      right.genBranch(false, context, label);
    }
  }
コード例 #5
0
  public TypedExpression buildVariable(
      InjectionBuilderContext injectionBuilderContext, InjectionNode injectionNode) {

    // build provider
    JDefinedClass providerClass = providerGenerator.generateProvider(injectionNode, true);
    JExpression provider = JExpr._new(providerClass).arg(injectionBuilderContext.getScopeVar());

    // build scope call
    // <T> T getScopedObject(Class<T> clazz, Provider<T> provider);
    TypedExpression contextScopeHolderExpression =
        injectionExpressionBuilder.buildVariable(injectionBuilderContext, this.contextScopeHolder);

    JExpression cast =
        invocationHelper.coerceType(ContextScopeHolder.class, contextScopeHolderExpression);
    JExpression scopeVar = cast.invoke(ContextScopeHolder.GET_SCOPE);

    JExpression expression =
        scopeVar.invoke(Scope.GET_SCOPED_OBJECT).arg(buildScopeKey(injectionNode)).arg(provider);

    return typedExpressionFactory.build(injectionNode.getASTType(), expression);
  }
コード例 #6
0
ファイル: JInstanceOf.java プロジェクト: ronggenliu/gwt
 @Override
 public boolean hasSideEffects() {
   return expr.hasSideEffects();
 }
コード例 #7
0
 /**
  * Clones all fields of this into
  *
  * <pre>other</pre>
  */
 protected void deepCloneInto(at.dms.kjc.sir.SIRPushExpression other) {
   super.deepCloneInto(other);
   other.arg = (at.dms.kjc.JExpression) at.dms.kjc.AutoCloner.cloneToplevel(this.arg);
   other.tapeType = (at.dms.kjc.CType) at.dms.kjc.AutoCloner.cloneToplevel(this.tapeType);
 }
コード例 #8
0
ファイル: JProgram.java プロジェクト: imatellan/gwt
 public static JBinaryOperation createAssignment(
     SourceInfo info, JExpression lhs, JExpression rhs) {
   return new JBinaryOperation(info, lhs.getType(), JBinaryOperator.ASG, lhs, rhs);
 }
コード例 #9
0
ファイル: JProgram.java プロジェクト: hammoum/gwt
 /** Helper to create an assignment, used to initalize fields, etc. */
 public static JExpressionStatement createAssignmentStmt(
     SourceInfo info, JExpression lhs, JExpression rhs) {
   JBinaryOperation assign =
       new JBinaryOperation(info, lhs.getType(), JBinaryOperator.ASG, lhs, rhs);
   return assign.makeStatement();
 }