langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java
changeset 14359 d4099818ab70
parent 13845 bbb35ad7a9c1
child 14725 65836e833f59
equal deleted inserted replaced
14358:9eda9239cba0 14359:d4099818ab70
    33 
    33 
    34 import com.sun.tools.javac.tree.JCTree.*;
    34 import com.sun.tools.javac.tree.JCTree.*;
    35 
    35 
    36 import static com.sun.tools.javac.code.Flags.*;
    36 import static com.sun.tools.javac.code.Flags.*;
    37 import static com.sun.tools.javac.code.Kinds.*;
    37 import static com.sun.tools.javac.code.Kinds.*;
    38 import static com.sun.tools.javac.code.TypeTags.*;
    38 import static com.sun.tools.javac.code.TypeTag.*;
    39 
    39 
    40 /** Factory class for trees.
    40 /** Factory class for trees.
    41  *
    41  *
    42  *  <p><b>This is NOT part of any supported API.
    42  *  <p><b>This is NOT part of any supported API.
    43  *  If you write code that depends on this, you do so at your own risk.
    43  *  If you write code that depends on this, you do so at your own risk.
   424         JCIdent tree = new JCIdent(name, null);
   424         JCIdent tree = new JCIdent(name, null);
   425         tree.pos = pos;
   425         tree.pos = pos;
   426         return tree;
   426         return tree;
   427     }
   427     }
   428 
   428 
   429     public JCLiteral Literal(int tag, Object value) {
   429     public JCLiteral Literal(TypeTag tag, Object value) {
   430         JCLiteral tree = new JCLiteral(tag, value);
   430         JCLiteral tree = new JCLiteral(tag, value);
   431         tree.pos = pos;
   431         tree.pos = pos;
   432         return tree;
   432         return tree;
   433     }
   433     }
   434 
   434 
   435     public JCPrimitiveTypeTree TypeIdent(int typetag) {
   435     public JCPrimitiveTypeTree TypeIdent(TypeTag typetag) {
   436         JCPrimitiveTypeTree tree = new JCPrimitiveTypeTree(typetag);
   436         JCPrimitiveTypeTree tree = new JCPrimitiveTypeTree(typetag);
   437         tree.pos = pos;
   437         tree.pos = pos;
   438         return tree;
   438         return tree;
   439     }
   439     }
   440 
   440 
   627     /** Create a tree representing given type.
   627     /** Create a tree representing given type.
   628      */
   628      */
   629     public JCExpression Type(Type t) {
   629     public JCExpression Type(Type t) {
   630         if (t == null) return null;
   630         if (t == null) return null;
   631         JCExpression tp;
   631         JCExpression tp;
   632         switch (t.tag) {
   632         switch (t.getTag()) {
   633         case BYTE: case CHAR: case SHORT: case INT: case LONG: case FLOAT:
   633         case BYTE: case CHAR: case SHORT: case INT: case LONG: case FLOAT:
   634         case DOUBLE: case BOOLEAN: case VOID:
   634         case DOUBLE: case BOOLEAN: case VOID:
   635             tp = TypeIdent(t.tag);
   635             tp = TypeIdent(t.getTag());
   636             break;
   636             break;
   637         case TYPEVAR:
   637         case TYPEVAR:
   638             tp = Ident(t.tsym);
   638             tp = Ident(t.tsym);
   639             break;
   639             break;
   640         case WILDCARD: {
   640         case WILDCARD: {
   642             tp = Wildcard(TypeBoundKind(a.kind), Type(a.type));
   642             tp = Wildcard(TypeBoundKind(a.kind), Type(a.type));
   643             break;
   643             break;
   644         }
   644         }
   645         case CLASS:
   645         case CLASS:
   646             Type outer = t.getEnclosingType();
   646             Type outer = t.getEnclosingType();
   647             JCExpression clazz = outer.tag == CLASS && t.tsym.owner.kind == TYP
   647             JCExpression clazz = outer.hasTag(CLASS) && t.tsym.owner.kind == TYP
   648                 ? Select(Type(outer), t.tsym)
   648                 ? Select(Type(outer), t.tsym)
   649                 : QualIdent(t.tsym);
   649                 : QualIdent(t.tsym);
   650             tp = t.getTypeArguments().isEmpty()
   650             tp = t.getTypeArguments().isEmpty()
   651                 ? clazz
   651                 ? clazz
   652                 : TypeApply(clazz, Types(t.getTypeArguments()));
   652                 : TypeApply(clazz, Types(t.getTypeArguments()));
   847 
   847 
   848     /** Wrap a method invocation in an expression statement or return statement,
   848     /** Wrap a method invocation in an expression statement or return statement,
   849      *  depending on whether the method invocation expression's type is void.
   849      *  depending on whether the method invocation expression's type is void.
   850      */
   850      */
   851     public JCStatement Call(JCExpression apply) {
   851     public JCStatement Call(JCExpression apply) {
   852         return apply.type.tag == VOID ? Exec(apply) : Return(apply);
   852         return apply.type.hasTag(VOID) ? Exec(apply) : Return(apply);
   853     }
   853     }
   854 
   854 
   855     /** Construct an assignment from a variable symbol and a right hand side.
   855     /** Construct an assignment from a variable symbol and a right hand side.
   856      */
   856      */
   857     public JCStatement Assignment(Symbol v, JCExpression rhs) {
   857     public JCStatement Assignment(Symbol v, JCExpression rhs) {