Java Code Examples for com.sun.tools.javac.tree.TreeMaker#at()

The following examples show how to use com.sun.tools.javac.tree.TreeMaker#at() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExtensionTransformer.java    From manifold with Apache License 2.0 6 votes vote down vote up
/** Unbox an object to a primitive value. */
private JCExpression unbox( Types types, TreeMaker make, Names names, JCExpression tree, Type primitive ) {
  Type unboxedType = types.unboxedType(tree.type);
  if (unboxedType.hasTag(NONE)) {
    unboxedType = primitive;
    if (!unboxedType.isPrimitive())
      throw new AssertionError(unboxedType);
    make.at(tree.pos());
    tree = make.TypeCast(types.boxedClass(unboxedType).type, tree);
  } else {
    // There must be a conversion from unboxedType to primitive.
    if (!types.isSubtype(unboxedType, primitive))
      throw new AssertionError(tree);
  }
  make.at(tree.pos());
  Symbol valueSym = resolveMethod(tree.pos(),
    unboxedType.tsym.name.append(names.Value), // x.intValue()
    tree.type,
    List.<Type>nil());
  return make.App(make.Select(tree, valueSym));
}
 
Example 2
Source File: ExtensionTransformer.java    From manifold with Apache License 2.0 5 votes vote down vote up
/** Box up a single primitive expression. */
private JCExpression boxPrimitive( Types types, TreeMaker make, Names names, JCExpression tree, Type box ) {
  make.at(tree.pos());
  Symbol valueOfSym = resolveMethod(tree.pos(),
    names.valueOf,
    box,
    List.<Type>nil()
      .prepend(tree.type));
  return make.App(make.QualIdent(valueOfSym), List.of(tree));
}