当前位置: 首页>>代码示例>>Java>>正文


Java JOp.cond方法代码示例

本文整理汇总了Java中com.sun.codemodel.JOp.cond方法的典型用法代码示例。如果您正苦于以下问题:Java JOp.cond方法的具体用法?Java JOp.cond怎么用?Java JOp.cond使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.codemodel.JOp的用法示例。


在下文中一共展示了JOp.cond方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: caseAQmarkExpressionNoName

import com.sun.codemodel.JOp; //导入方法依赖的package包/类
@Override
public void caseAQmarkExpressionNoName(AQmarkExpressionNoName node) {
    ExpressionAdapter eaCond = new ExpressionAdapter(new JExprParent(), context);
    node.getCond().apply(eaCond);
    ExpressionAdapter eaTrue = new ExpressionAdapter(new JExprParent(), context);
    node.getTrue().apply(eaTrue);
    ExpressionAdapter eaFalse = new ExpressionAdapter(new JExprParent(), context);
    node.getFalse().apply(eaFalse);
    expr = JOp.cond(eaCond.expr, eaTrue.expr, eaFalse.expr);
}
 
开发者ID:kompics,项目名称:kola,代码行数:11,代码来源:ExpressionAdapter.java

示例2: visit

import com.sun.codemodel.JOp; //导入方法依赖的package包/类
@Override
public JExpression visit(Expression.BinaryOp op,
			 JExpression left, JExpression right)
{
	if (op.op.javaMethod == "cmp") {
		final JExpression cmp_res =
			left.invoke("compareTo").arg(right);

		final JExpression cond;
		switch(op.op){
		case EQ: cond = cmp_res.eq(JExpr.lit(0)); break;
		case NE: cond = cmp_res.ne(JExpr.lit(0)); break;
		case LT: cond = cmp_res.lt(JExpr.lit(0)); break;
		case GT: cond = cmp_res.gt(JExpr.lit(0)); break;
		case LE: cond = cmp_res.lte(JExpr.lit(0)); break;
		case GE: cond = cmp_res.gte(JExpr.lit(0)); break;
		default: throw new RuntimeException();
		}

		return JOp.cond(cond,
				TypeInt_t.staticRef("True"),
				TypeInt_t.staticRef("False"));
	} else {
		return left.invoke(op.op.javaMethod).arg(right);
	}

}
 
开发者ID:BrainTech,项目名称:jsignalml,代码行数:28,代码来源:JavaExprGen.java

示例3: visit

import com.sun.codemodel.JOp; //导入方法依赖的package包/类
@Override
public JExpression visit(Expression.BinaryOp op,
			 JExpression left, JExpression right)
{
	if (op.left.type instanceof TypeInt &&
	    op.right.type instanceof TypeInt) {
		JExpression expr = binaryOp_int_int(op, left, right);
		if (expr != null)
			return expr;
	}

	if (op.op.javaMethod == "cmp") {
		final JExpression cmp_res =
			left.invoke("compareTo").arg(right);

		final JExpression cond;
		switch(op.op){
		case EQ: cond = cmp_res.eq(JExpr.lit(0)); break;
		case NE: cond = cmp_res.ne(JExpr.lit(0)); break;
		case LT: cond = cmp_res.lt(JExpr.lit(0)); break;
		case GT: cond = cmp_res.gt(JExpr.lit(0)); break;
		case LE: cond = cmp_res.lte(JExpr.lit(0)); break;
		case GE: cond = cmp_res.gte(JExpr.lit(0)); break;
		default: throw new RuntimeException();
		}

		JClass int_t = this.model.ref(TypeInt.class);
		return JOp.cond(cond, int_t.staticRef("True"),
				      int_t.staticRef("False"));
	} else {
		return left.invoke(op.op.javaMethod).arg(right);
	}

}
 
开发者ID:BrainTech,项目名称:jsignalml,代码行数:35,代码来源:JavaPrimitiveGen.java

示例4: getIncludeCondition

import com.sun.codemodel.JOp; //导入方法依赖的package包/类
private JExpression getIncludeCondition(final JVar fieldPathVar) {
	return JOp.cond(
			PartialCopyGenerator.this.propertyTreeUseParam.eq(PartialCopyGenerator.this.pluginContext.includeConst),
			fieldPathVar.ne(JExpr._null()),
			fieldPathVar.eq(JExpr._null()).cor(fieldPathVar.invoke("isLeaf").not())
	);
}
 
开发者ID:mklemm,项目名称:jaxb2-rich-contract-plugin,代码行数:8,代码来源:PartialCopyGenerator.java

示例5: generateEvalBody

import com.sun.codemodel.JOp; //导入方法依赖的package包/类
protected HoldingContainer generateEvalBody(ClassGenerator<?> g, CompleteType resolvedOutput, HoldingContainer[] inputVariables, String body, JVar[] workspaceJVars) {

    g.getEvalBlock().directStatement(String.format("//---- start of eval portion of %s function. ----//", registeredNames[0]));

    JBlock sub = new JBlock(true, true);
    JBlock topSub = sub;
    HoldingContainer out = null;


    // add outside null handling if it is defined.
    if (nullHandling == NullHandling.NULL_IF_NULL) {
      JExpression e = null;
      for (HoldingContainer v : inputVariables) {
        final JExpression isNullExpr;
        if (v.isReader()) {
          isNullExpr = JOp.cond(v.getHolder().invoke("isSet"), JExpr.lit(1), JExpr.lit(0));
        } else {
          isNullExpr = v.getIsSet();
        }
        if (e == null) {
          e = isNullExpr;
        } else {
          e = e.mul(isNullExpr);
        }
      }

      if (e != null) {
        // if at least one expression must be checked, set up the conditional.
        out = g.declare(resolvedOutput);
        e = e.eq(JExpr.lit(0));
        JConditional jc = sub._if(e);
        jc._then().assign(out.getIsSet(), JExpr.lit(0));
        sub = jc._else();
      }
    }

    if (out == null) {
      out = g.declare(resolvedOutput);
    }

    // add the subblock after the out declaration.
    g.getEvalBlock().add(topSub);


    JVar internalOutput = sub.decl(JMod.FINAL, resolvedOutput.getHolderType(g.getModel()), getReturnName(), JExpr._new(resolvedOutput.getHolderType(g.getModel())));
    addProtectedBlock(g, sub, body, inputVariables, workspaceJVars, false);

    if (sub != topSub || inputVariables.length == 0) {
      sub.assign(internalOutput.ref("isSet"), JExpr.lit(1));// Assign null if NULL_IF_NULL mode
    }
    sub.assign(out.getHolder(), internalOutput);

    g.getEvalBlock().directStatement(String.format("//---- end of eval portion of %s function. ----//", registeredNames[0]));

    return out;
  }
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:57,代码来源:SimpleFunctionHolder.java

示例6: generateEvalBody

import com.sun.codemodel.JOp; //导入方法依赖的package包/类
protected HoldingContainer generateEvalBody(ClassGenerator<?> g, HoldingContainer[] inputVariables, String body,
                                            JVar[] workspaceJVars, FieldReference ref) {

  g.getEvalBlock().directStatement(String.format("//---- start of eval portion of %s function. ----//", getRegisteredNames()[0]));

  JBlock sub = new JBlock(true, true);
  JBlock topSub = sub;
  HoldingContainer out = null;
  MajorType returnValueType = getReturnType();

  // add outside null handling if it is defined.
  if (getNullHandling() == NullHandling.NULL_IF_NULL) {
    JExpression e = null;
    for (HoldingContainer v : inputVariables) {
      if (v.isOptional()) {
        JExpression isNullExpr;
        if (v.isReader()) {
         isNullExpr = JOp.cond(v.getHolder().invoke("isSet"), JExpr.lit(1), JExpr.lit(0));
        } else {
          isNullExpr = v.getIsSet();
        }
        if (e == null) {
          e = isNullExpr;
        } else {
          e = e.mul(isNullExpr);
        }
      }
    }

    if (e != null) {
      // if at least one expression must be checked, set up the conditional.
      returnValueType = getReturnType().toBuilder().setMode(DataMode.OPTIONAL).build();
      out = g.declare(returnValueType);
      e = e.eq(JExpr.lit(0));
      JConditional jc = sub._if(e);
      jc._then().assign(out.getIsSet(), JExpr.lit(0));
      sub = jc._else();
    }
  }

  if (out == null) {
    out = g.declare(returnValueType);
  }

  // add the subblock after the out declaration.
  g.getEvalBlock().add(topSub);


  JVar internalOutput = sub.decl(JMod.FINAL, g.getHolderType(returnValueType), getReturnValue().getName(), JExpr._new(g.getHolderType(returnValueType)));
  addProtectedBlock(g, sub, body, inputVariables, workspaceJVars, false);
  if (sub != topSub) {
    sub.assign(internalOutput.ref("isSet"),JExpr.lit(1));// Assign null if NULL_IF_NULL mode
  }
  sub.assign(out.getHolder(), internalOutput);
  if (sub != topSub) {
    sub.assign(internalOutput.ref("isSet"),JExpr.lit(1));// Assign null if NULL_IF_NULL mode
  }

  g.getEvalBlock().directStatement(String.format("//---- end of eval portion of %s function. ----//", getRegisteredNames()[0]));

  return out;
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:63,代码来源:DrillSimpleFuncHolder.java

示例7: count

import com.sun.codemodel.JOp; //导入方法依赖的package包/类
public JExpression count() {
    return JOp.cond( field.eq(JExpr._null()), JExpr.lit(0), field.invoke("size") );
}
 
开发者ID:highsource,项目名称:hyperjaxb3,代码行数:4,代码来源:AbstractListField.java

示例8: unwrap

import com.sun.codemodel.JOp; //导入方法依赖的package包/类
@Override
protected JExpression unwrap(JExpression source) {
	return JOp.cond(source.eq(JExpr._null()), JExpr._null(), source
			.invoke("value"));
}
 
开发者ID:highsource,项目名称:hyperjaxb3,代码行数:6,代码来源:SingleEnumValueWrappingField.java

示例9: wrap

import com.sun.codemodel.JOp; //导入方法依赖的package包/类
@Override
protected JExpression wrap(JExpression target) {
	return JOp.cond(target.eq(JExpr._null()), JExpr._null(), this.enumClass
			.staticInvoke("fromValue").arg(target));
}
 
开发者ID:highsource,项目名称:hyperjaxb3,代码行数:6,代码来源:SingleEnumValueWrappingField.java

示例10: nullSafe

import com.sun.codemodel.JOp; //导入方法依赖的package包/类
public static JExpression nullSafe(final JExpression test, final JExpression source) {
	return JOp.cond(test.eq(JExpr._null()), JExpr._null(), source);
}
 
开发者ID:mklemm,项目名称:jaxb2-rich-contract-plugin,代码行数:4,代码来源:PluginUtil.java


注:本文中的com.sun.codemodel.JOp.cond方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。