Package org.jboss.errai.codegen

Examples of org.jboss.errai.codegen.Variable


  public static Statement generate(final Context context, final Object o) {
    if (o instanceof VariableReference) {
      return context.getVariable(((VariableReference) o).getName());
    }
    else if (o instanceof Variable) {
      final Variable v = (Variable) o;
      if (context.isScoped(v)) {
        return v.getReference();
      }
      else {
        if (context.isPermissiveMode()) {
          return v.getReference();
        }
        else {
          throw new OutOfScopeException("variable cannot be referenced from this scope: " + v.getName());
        }
      }
    }
    else if (o instanceof Statement) {
      ((Statement) o).generate(context);
View Full Code Here


    appendCallElement(new DeferredCallElement(new DeferredCallback() {
      @Override
      public void doDeferred(CallWriter writer, Context context, Statement statement) {
          GenUtil.assertIsIterable(statement);
          final Variable loopVar = createForEachLoopVar(statement, loopVarName, loopVarType, context);
          final String collection = writer.getCallString();
          writer.reset();
          writer.append(new ForeachLoop(loopVar, collection, body).generate(Context.create(context)));
      }
    }));
View Full Code Here

    if (providedLoopVarType != null) {
      GenUtil.assertAssignableTypes(context, loopVarType, providedLoopVarType);
      loopVarType = providedLoopVarType;
    }

    Variable loopVar = Variable.create(loopVarName, loopVarType);
    context.addVariable(loopVar);
    return loopVar;
  }
View Full Code Here

  public static Statement generate(Context context, Object o) {
    if (o instanceof VariableReference) {
      return context.getVariable(((VariableReference) o).getName());
    }
    else if (o instanceof Variable) {
      Variable v = (Variable) o;
      if (context.isScoped(v)) {
        return v.getReference();
      }
      else {
        if (isPermissiveMode()) {
          return v.getReference();
        }
        else {
          throw new OutOfScopeException("variable cannot be referenced from this scope: " + v.getName());
        }
      }
    }
    else if (o instanceof Statement) {
      ((Statement) o).generate(context);
View Full Code Here

    appendCallElement(new DeferredCallElement(new DeferredCallback() {
      @Override
      public void doDeferred(CallWriter writer, Context context, Statement statement) {
          GenUtil.assertIsIterable(statement);
          Variable loopVar = createForEachLoopVar(statement, loopVarName, loopVarType, context);
          String collection = writer.getCallString();
          writer.reset();
          writer.append(new ForeachLoop(loopVar, collection, body).generate(Context.create(context)));
      }
    }));
View Full Code Here

    if (providedLoopVarType != null) {
      GenUtil.assertAssignableTypes(context, loopVarType, providedLoopVarType);
      loopVarType = providedLoopVarType;
    }

    Variable loopVar = Variable.create(loopVarName, loopVarType);
    context.addVariable(loopVar);
    return loopVar;
  }
View Full Code Here

  public static Statement generate(final Context context, final Object o) {
    if (o instanceof VariableReference) {
      return context.getVariable(((VariableReference) o).getName());
    }
    else if (o instanceof Variable) {
      final Variable v = (Variable) o;
      if (context.isScoped(v)) {
        return v.getReference();
      }
      else {
        if (context.isPermissiveMode()) {
          return v.getReference();
        }
        else {
          throw new OutOfScopeException("variable cannot be referenced from this scope: " + v.getName());
        }
      }
    }
    else if (o instanceof Statement) {
      ((Statement) o).generate(context);
View Full Code Here

  public static Statement generate(final Context context, final Object o) {
    if (o instanceof VariableReference) {
      return context.getVariable(((VariableReference) o).getName());
    }
    else if (o instanceof Variable) {
      final Variable v = (Variable) o;
      if (context.isScoped(v)) {
        return v.getReference();
      }
      else {
        if (context.isPermissiveMode()) {
          return v.getReference();
        }
        else {
          throw new OutOfScopeException("variable cannot be referenced from this scope: " + v.getName());
        }
      }
    }
    else if (o instanceof Statement) {
      ((Statement) o).generate(context);
View Full Code Here

  public static Statement generate(Context context, Object o) {
    if (o instanceof VariableReference) {
      return context.getVariable(((VariableReference) o).getName());
    }
    else if (o instanceof Variable) {
      Variable v = (Variable) o;
      if (context.isScoped(v)) {
        return v.getReference();
      }
      else {
        if (isPermissiveMode()) {
          return v.getReference();
        }
        else {
          throw new OutOfScopeException("variable cannot be referenced from this scope: " + v.getName());
        }
      }
    }
    else if (o instanceof Statement) {
      ((Statement) o).generate(context);
View Full Code Here

    return catch_(MetaClassFactory.get(exceptionType), variableName);
  }

  @Override
  public BlockBuilder<CatchBlockBuilder> catch_(MetaClass exceptionType, String variableName) {
    Variable exceptionVar = Variable.create(variableName, exceptionType);
    tryBlock.addCatchBlock(exceptionVar);

    return new BlockBuilderImpl<CatchBlockBuilder>(tryBlock.getCatchBlock(exceptionVar),
        new BuildCallback<CatchBlockBuilder>() {
          @Override
View Full Code Here

TOP

Related Classes of org.jboss.errai.codegen.Variable

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.