本文整理汇总了Java中com.sun.codemodel.JExpression.invoke方法的典型用法代码示例。如果您正苦于以下问题:Java JExpression.invoke方法的具体用法?Java JExpression.invoke怎么用?Java JExpression.invoke使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.codemodel.JExpression
的用法示例。
在下文中一共展示了JExpression.invoke方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: caseAClassMethodInvocation
import com.sun.codemodel.JExpression; //导入方法依赖的package包/类
@Override
public void caseAClassMethodInvocation(AClassMethodInvocation node) {
AClassName acname = (AClassName) node.getClassName();
String name = nameToString(acname.getName());
JClass jc = context.resolveType(acname.getName());
JExpression jcs = JExpr.dotsuper(jc);
JInvocation inv = jcs.invoke(node.getIdentifier().getText());
Argumentable ia = new InvocationArgumentable(inv);
for (PArgument arg : node.getArgument()) {
ArgumentAdapter aa = new ArgumentAdapter(ia, context);
arg.apply(aa);
}
expr = inv;
parent.addInvocation(inv);
}
示例2: getMethod_p
import com.sun.codemodel.JExpression; //导入方法依赖的package包/类
public JMethod getMethod_p(JDefinedClass klass, Type wanted)
{
JExpression get = JExpr._this().invoke(GET);
final JClass type;
if (wanted instanceof TypeInt) {
get = get.invoke("safeLongValue");
type = Long_t;
} else if (wanted instanceof TypeFloat) {
get = get.invoke("getValue");
type = Double_t;
} else if (wanted instanceof TypeBool) {
get = get.invoke("getValue");
type = Boolean_t;
} else if (wanted instanceof TypeBytes) {
get = get.invoke("getValue");
type = ByteSequence_t;
} else {
return null;
}
return _cacheMethod(klass, type, null, GET_P, get);
}
示例3: addToStringMethod
import com.sun.codemodel.JExpression; //导入方法依赖的package包/类
private void addToStringMethod() {
JMethod toString = this.pojo.method(JMod.PUBLIC, String.class, "toString");
toString.annotate(Override.class);
JExpression toReturn = JExpr._this().ref(valueField);
if (!valueField.type().fullName().equals(String.class.getName())) {
toReturn = toReturn.invoke("toString");
}
toString.body()._return(toReturn);
}
示例4: visit
import com.sun.codemodel.JExpression; //导入方法依赖的package包/类
@Override
public JExpression visit(Expression.Call fun, JExpression what, List<JExpression> args)
{
final JInvocation inv = what.invoke("call");
for (JExpression arg: args)
inv.arg(arg);
return inv;
}
示例5: idMethod
import com.sun.codemodel.JExpression; //导入方法依赖的package包/类
JMethod idMethod(JDefinedClass klass, ASTNode node, String theid)
{
final JMethod method = klass.method(JMod.PUBLIC, String_t, "id");
comment_stamp(method.body());
final JExpression ret;
if (node.id != null) {
final EvalVisitor valuator = EvalVisitor.create(node);
String value = valuator.quickEval(TypeString.I, node.id);
if (value != null) {
/*if (! isJavaIdentifier (value)) {
String valueOld = value;
value = value.replaceAll("([^A-Za-z0-9_])", "_");
log.info("idMethod(node id %s -> %s, class %s)", valueOld, value, klass);
assert isJavaIdentifier (value);
} else {
log.info("idMethod(node id %s, class %s)", value, klass);
}*/
ret = JExpr.lit(value);
} else {
JavaExprGen javagen = createExprGen(node, null);
JExpression jvalue = node.id.accept(javagen);
JExpression jcast = TypeString_I.invoke("make").arg(jvalue);
ret = jcast.invoke("getValue");
}
} else {
ret = JExpr.lit(theid);
}
method.body()._return(ret);
return method;
}
示例6: read
import com.sun.codemodel.JExpression; //导入方法依赖的package包/类
public static void read(CompleteType ct, JExpression vector, JBlock eval, HoldingContainer out, JCodeModel model,
JExpression indexVariable) {
MinorType type = ct.toMinorType();
final JInvocation getValueAccessor = vector.invoke("getAccessor");
eval.assign(out.getIsSet(), getValueAccessor.invoke("isSet").arg(indexVariable));
eval = eval._if(out.getIsSet().eq(JExpr.lit(1)))._then();
switch (type) {
case BIGINT:
case FLOAT4:
case FLOAT8:
case INT:
case MONEY:
case SMALLINT:
case TINYINT:
case UINT1:
case UINT2:
case UINT4:
case UINT8:
case INTERVALYEAR:
case DATE:
case TIME:
case TIMESTAMP:
case BIT:
eval.assign(out.getValue(), getValueAccessor.invoke("get").arg(indexVariable));
return;
case DECIMAL:
eval.assign(out.getHolder().ref("scale"), JExpr.lit(ct.getType(Decimal.class).getScale()));
eval.assign(out.getHolder().ref("precision"), JExpr.lit(ct.getType(Decimal.class).getPrecision()));
eval.assign(out.getHolder().ref("start"), JExpr.lit(TypeHelper.getSize(getArrowMinorType(type))).mul(indexVariable));
eval.assign(out.getHolder().ref("buffer"), vector.invoke("getBuffer"));
return;
case INTERVALDAY: {
JVar start = eval.decl(model.INT, "start", JExpr.lit(TypeHelper.getSize(getArrowMinorType(type))).mul(indexVariable));
eval.assign(out.getHolder().ref("days"), vector.invoke("getBuffer").invoke("getInt").arg(start));
eval.assign(out.getHolder().ref("milliseconds"), vector.invoke("getBuffer").invoke("getInt").arg(start.plus(JExpr.lit(4))));
return;
}
case VARBINARY:
case VARCHAR:
eval.assign(out.getHolder().ref("buffer"), vector.invoke("getBuffer"));
JVar se = eval.decl(model.LONG, "startEnd", getValueAccessor.invoke("getStartEnd").arg(indexVariable));
eval.assign(out.getHolder().ref("start"), JExpr.cast(model._ref(int.class), se));
eval.assign(out.getHolder().ref("end"), JExpr.cast(model._ref(int.class), se.shr(JExpr.lit(32))));
return;
}
// fallback.
eval.add(getValueAccessor.invoke("get").arg(indexVariable).arg(out.getHolder()));
}
示例7: lowerCase
import com.sun.codemodel.JExpression; //导入方法依赖的package包/类
private JExpression lowerCase(final JExpression type) {
return type.invoke("toLowerCase");
}