Package com.sun.codemodel

Examples of com.sun.codemodel.JBlock.assign()


      _for.body().invoke(list, "add").arg(JExpr._null());

      JVar element = body.decl(elementClass, "value", list.invoke("get").arg(index));
      JConditional _ifElementIsNull = body._if(element.eq(JExpr._null()));
      JBlock _ifElementIsNullThen = _ifElementIsNull._then();
      _ifElementIsNullThen.assign(element, JExpr._new(element.type()));
      _ifElementIsNullThen.invoke(list, "set").arg(index).arg(element);

      body._return(element);
   }
View Full Code Here


        final JFieldVar field = c.implClass.fields().get( p.getName( false ) );
        final JMethod setter = c.implClass.method( JMod.PUBLIC, cm.VOID, "set" + p.getName( true ) );
        final JVar valueParam = setter.param( JMod.FINAL, field.type(), "value" );
        final JBlock body = setter.body();
        body.directStatement( "// " + getMessage( "title" ) );
        body.assign( JExpr._this().ref( field ), valueParam );

        setter.javadoc().append( "Sets the value of the " + p.getName( false ) + " property." );
        setter.javadoc().addParam( valueParam ).append( "The new value of the " + p.getName( false ) + " property." );
    }
View Full Code Here

            event = b.decl(model._ref(int.class), "event", xsrVar.invoke("nextTagIgnoreAll"));
        }
       
       
       
        b.assign(depthVar, xsrVar.invoke("getDepth"));
       
//        JClass sysType = (JClass) model._ref(System.class);
//        if (depth != 1)
//            b.add(sysType.staticRef("out").invoke("println").arg(JExpr.lit("TD ").plus(targetDepthVar)
//                     .plus(JExpr.lit(" Depth: ")).plus(depthVar)
View Full Code Here

       
        //Loop through all workspace vectors, to get the minimum of size of all workspace vectors. 
        JVar sizeVar = setupBlock.decl(g.getModel().INT, "vectorSize", JExpr.lit(Integer.MAX_VALUE));
        JClass mathClass = g.getModel().ref(Math.class);
        for (int id = 0; id<workspaceVars.length; id ++) {
          setupBlock.assign(sizeVar,mathClass.staticInvoke("min").arg(sizeVar).arg(g.getWorkspaceVectors().get(workspaceVars[id]).invoke("getValueCapacity")));
        }
       
        for(int i =0 ; i < workspaceVars.length; i++) {    
          setupBlock.assign(workspaceJVars[i], JExpr._new(g.getHolderType(workspaceVars[i].majorType)));
        }
View Full Code Here

        for (int id = 0; id<workspaceVars.length; id ++) {
          setupBlock.assign(sizeVar,mathClass.staticInvoke("min").arg(sizeVar).arg(g.getWorkspaceVectors().get(workspaceVars[id]).invoke("getValueCapacity")));
        }
       
        for(int i =0 ; i < workspaceVars.length; i++) {    
          setupBlock.assign(workspaceJVars[i], JExpr._new(g.getHolderType(workspaceVars[i].majorType)));
        }
       
        //Use for loop to initialize entries in the workspace vectors.
        JForLoop forLoop = setupBlock._for();
        JVar ivar = forLoop.init(g.getModel().INT, "drill_internal_i", JExpr.lit(0));
View Full Code Here

    HoldingContainer out = g.declare(returnValue.type, false);
    JBlock sub = new JBlock();
    g.getEvalBlock().add(sub);
    JVar internalOutput = sub.decl(JMod.FINAL, g.getHolderType(returnValue.type), returnValue.name, JExpr._new(g.getHolderType(returnValue.type)));
    addProtectedBlock(g, sub, output, null, workspaceJVars, false);
    sub.assign(out.getHolder(), internalOutput);
        //hash aggregate uses workspace vectors. Initialization is done in "setup" and does not require "reset" block.
        if (!g.getMappingSet().isHashAggMapping()) {
          generateBody(g, BlockType.RESET, reset, null, workspaceJVars, false);
        }
       generateBody(g, BlockType.CLEANUP, cleanup, null, workspaceJVars, false);
View Full Code Here

      HoldingContainer thenExpr = c.expression.accept(this, generator);
      if (thenExpr.isOptional()) {
        JConditional newCond = jc._then()._if(thenExpr.getIsSet().ne(JExpr.lit(0)));
        JBlock b = newCond._then();
        b.assign(output.getHolder(), thenExpr.getHolder());
        //b.assign(output.getIsSet(), thenExpr.getIsSet());
      } else {
        jc._then().assign(output.getHolder(), thenExpr.getHolder());
      }
View Full Code Here

      HoldingContainer elseExpr = ifExpr.elseExpression.accept(this, generator);
      if (elseExpr.isOptional()) {
        JConditional newCond = jc._else()._if(elseExpr.getIsSet().ne(JExpr.lit(0)));
        JBlock b = newCond._then();
        b.assign(output.getHolder(), elseExpr.getHolder());
        //b.assign(output.getIsSet(), elseExpr.getIsSet());
      } else {
        jc._else().assign(output.getHolder(), elseExpr.getHolder());
      }
      local.add(conditionalBlock);
View Full Code Here

          setMeth = vv.invoke("getMutator").invoke(setMethod).arg(outIndex).arg(inputContainer.getValue());
        }

        if (e.isSafe()) {
          HoldingContainer outputContainer = generator.declare(Types.REQUIRED_BIT);
          block.assign(outputContainer.getValue(), JExpr.lit(1));
          if (inputContainer.isOptional()) {
            // block._if(vv.invoke("getMutator").invoke(setMethod).arg(outIndex).not())._then().assign(outputContainer.getValue(),
            // JExpr.lit(0));
            JConditional jc = block._if(inputContainer.getIsSet().eq(JExpr.lit(0)).not());
            block = jc._then();
View Full Code Here

        JInvocation getValueAccessor = vv1.invoke("getAccessor").invoke("get");
        JInvocation getValueAccessor2 = vv1.invoke("getAccessor");
        JBlock eval = new JBlock();

        if (primitive) {
          eval.assign(out.getValue(), getValueAccessor.arg(indexVariable));
        } else {
          eval.add(getValueAccessor.arg(indexVariable).arg(out.getHolder()));
        }

        if (out.isOptional()) {
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.