Examples of BlockStatement


Examples of org.jboss.errai.codegen.BlockStatement

  private static Statement generateInterceptorStackProceedMethod(
          final GeneratorContext context,
          final Class<? extends RemoteCallContext> callContextType,
          final Statement proceed, final List<Class<?>> interceptors) {
    final BlockStatement proceedLogic = new BlockStatement();
    proceedLogic.addStatement(Stmt.loadVariable("status").invoke("proceed"));

    final BlockBuilder<ElseBlockBuilder> interceptorStack =
              If.isNotNull(Stmt.loadVariable("status").invoke("getNextInterceptor"));

    for (final Class<?> interceptor : interceptors) {
      interceptorStack.append(If.cond(Bool.equals(
              Stmt.loadVariable("status").invoke("getNextInterceptor"), interceptor))
              .append(Stmt.declareFinalVariable("ctx", callContextType, Stmt.loadVariable("this")))
              .append(
                  Stmt.declareVariable(CreationalCallback.class).asFinal().named("icc")
                      .initializeWith(
                          Stmt.newObject(CreationalCallback.class).extend()
                              .publicOverridesMethod("callback", Parameter.of(Object.class, "beanInstance", true))
                              .append(Stmt.loadVariable("status").invoke("setProceeding", false))
                              .append(
                                  Stmt.castTo(interceptor, Stmt.loadVariable("beanInstance")).invoke("aroundInvoke",
                                      Variable.get("ctx")))
                              .append(
                                  If.not(Stmt.loadVariable("status").invoke("isProceeding"))
                                      .append(
                                          Stmt.loadVariable("remoteCallback").invoke("callback",
                                              Stmt.loadVariable("ctx").invoke("getResult")))
                                      .finish())
                              .finish() // finish the method override body
                              .finish() // finish the anonymous CreationalCallback class body
                      ))
              .append(generateAsyncInterceptorCreation(context, interceptor))
              .finish()
          );
    }
    proceedLogic.addStatement(interceptorStack.finish().else_().append(proceed).finish());
    return proceedLogic;
  }
View Full Code Here

Examples of org.jboss.errai.codegen.BlockStatement

    return foreach(loopVarName, MetaClassFactory.get(loopVarType));
  }

  @Override
  public BlockBuilder<StatementEnd> foreach(final String loopVarName, final MetaClass loopVarType) {
    final BlockStatement body = new BlockStatement();

    appendCallElement(new DeferredCallElement(new DeferredCallback() {
      @Override
      public void doDeferred(CallWriter writer, Context context, Statement statement) {
          GenUtil.assertIsIterable(statement);
View Full Code Here

Examples of org.jboss.errai.codegen.BlockStatement

  }

  // do while loop
  @Override
  public BlockBuilder<WhileBuilder> do_() {
    final BlockStatement body = new BlockStatement();

    return new BlockBuilderImpl<WhileBuilder>(body, new BuildCallback<WhileBuilder>() {
      @Override
      public WhileBuilder callback(Statement statement) {
        return new WhileBuilder() {
View Full Code Here

Examples of org.jboss.errai.codegen.BlockStatement

    return while_(new BooleanExpressionBuilder(rhs, op));
  }

  @Override
  public BlockBuilder<StatementEnd> while_(final BooleanExpression condition) {
    final BlockStatement body = new BlockStatement();
    appendCallElement(new ConditionalBlockCallElement(new WhileLoop(condition, body)));
    return createLoopBody(body);
  }
View Full Code Here

Examples of org.jboss.errai.codegen.BlockStatement

  @Override
  public BlockBuilder<StatementEnd> for_(final Statement initializer, final BooleanExpression condition,
      final Statement countingExpression) {

    final BlockStatement body = new BlockStatement();
    appendCallElement(new ConditionalBlockCallElement(new ForLoop(condition, body, initializer, countingExpression)));
    return createLoopBody(body);
  }
View Full Code Here

Examples of org.jboss.errai.codegen.BlockStatement

    if (_constructorsCache != null) return _constructorsCache;

    if (constructors.isEmpty()) {
      // add an empty no-arg constructor
      final BuildMetaConstructor buildMetaConstructor =
          new BuildMetaConstructor(this, new BlockStatement(), DefParameters.none());

      buildMetaConstructor.setScope(Scope.Public);
      return _constructorsCache = new MetaConstructor[]{buildMetaConstructor};
    }
    else {
View Full Code Here

Examples of org.jboss.errai.codegen.BlockStatement

    if (_constructorsCache != null) return _constructorsCache;

    if (constructors.isEmpty()) {
      // add an empty no-arg constructor
      final BuildMetaConstructor buildMetaConstructor =
          new BuildMetaConstructor(this, new BlockStatement(), DefParameters.none());

      buildMetaConstructor.setScope(Scope.Public);
      return _constructorsCache = new MetaConstructor[]{buildMetaConstructor};
    }
    else {
View Full Code Here

Examples of org.jboss.errai.codegen.framework.BlockStatement

    if (_constructorsCache != null) return _constructorsCache;

    if (constructors.isEmpty()) {
      // add an empty no-arg constructor
      BuildMetaConstructor buildMetaConstructor =
              new BuildMetaConstructor(this, new BlockStatement(), DefParameters.none());

      buildMetaConstructor.setScope(Scope.Public);
      return _constructorsCache = new MetaConstructor[]{buildMetaConstructor};
    }
    else {
View Full Code Here

Examples of org.jboss.errai.ioc.rebind.ioc.codegen.BlockStatement

  @Override
  public MetaConstructor[] getConstructors() {
    if (constructors.isEmpty()) {
      // add an empty no-arg constructor
      BuildMetaConstructor buildMetaConstructor =
        new BuildMetaConstructor(this, new BlockStatement(), DefParameters.none());
     
      buildMetaConstructor.setScope(Scope.Public);
      return new MetaConstructor[] {buildMetaConstructor};
    }
    else {
View Full Code Here

Examples of org.lilystudio.javascript.statement.BlockStatement

   */
  public static IStatement createStatement(Node node, ScriptOrFnNode root,
      Scope scope) {
    switch (node.getType()) {
    case Token.BLOCK: {
      BlockStatement blockStatement = new BlockStatement(node, root, scope);
      StatementList statements = blockStatement.getStatementList();
      for (int i = statements.size() - 1; i >= 0; i--) {
        IStatement statement = statements.get(i);
        if (statement instanceof EmptyStatement) {
          statements.remove(i);
        }
      }

      IStatement statement;
      switch (statements.size()) {
      case 0:
        // 块语句没有内容等同于空语句
        statement = new EmptyStatement(node, root, scope);
        statement.setNext(blockStatement.getNext());
        statement.setParent(blockStatement.getParent());
        return statement;
      case 1:
        // 块语句只有一条语句等同于那一条语句
        statement = statements.get(0);
        statement.setNext(blockStatement.getNext());
        statement.setParent(blockStatement.getParent());
        return statement;
      default:
        return blockStatement;
      }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.