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"); }
/** 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); } }
/** * 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); }
/** 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); } }
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); }
@Override public boolean hasSideEffects() { return expr.hasSideEffects(); }
/** * 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); }
public static JBinaryOperation createAssignment( SourceInfo info, JExpression lhs, JExpression rhs) { return new JBinaryOperation(info, lhs.getType(), JBinaryOperator.ASG, lhs, rhs); }
/** 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(); }