langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeCopier.java
changeset 26266 2d24bda701dc
parent 25874 83c19f00452c
child 33707 d74fef6b01e0
equal deleted inserted replaced
26265:46aacfffd3b5 26266:2d24bda701dc
    25 
    25 
    26 package com.sun.tools.javac.tree;
    26 package com.sun.tools.javac.tree;
    27 
    27 
    28 import com.sun.source.tree.*;
    28 import com.sun.source.tree.*;
    29 import com.sun.tools.javac.tree.JCTree.*;
    29 import com.sun.tools.javac.tree.JCTree.*;
       
    30 import com.sun.tools.javac.util.DefinedBy;
       
    31 import com.sun.tools.javac.util.DefinedBy.Api;
    30 import com.sun.tools.javac.util.List;
    32 import com.sun.tools.javac.util.List;
    31 import com.sun.tools.javac.util.ListBuffer;
    33 import com.sun.tools.javac.util.ListBuffer;
    32 
    34 
    33 /**
    35 /**
    34  * Creates a copy of a tree, using a given TreeMaker.
    36  * Creates a copy of a tree, using a given TreeMaker.
    69         for (T tree: trees)
    71         for (T tree: trees)
    70             lb.append(copy(tree, p));
    72             lb.append(copy(tree, p));
    71         return lb.toList();
    73         return lb.toList();
    72     }
    74     }
    73 
    75 
       
    76     @DefinedBy(Api.COMPILER_TREE)
    74     public JCTree visitAnnotatedType(AnnotatedTypeTree node, P p) {
    77     public JCTree visitAnnotatedType(AnnotatedTypeTree node, P p) {
    75         JCAnnotatedType t = (JCAnnotatedType) node;
    78         JCAnnotatedType t = (JCAnnotatedType) node;
    76         List<JCAnnotation> annotations = copy(t.annotations, p);
    79         List<JCAnnotation> annotations = copy(t.annotations, p);
    77         JCExpression underlyingType = copy(t.underlyingType, p);
    80         JCExpression underlyingType = copy(t.underlyingType, p);
    78         return M.at(t.pos).AnnotatedType(annotations, underlyingType);
    81         return M.at(t.pos).AnnotatedType(annotations, underlyingType);
    79     }
    82     }
    80 
    83 
       
    84     @DefinedBy(Api.COMPILER_TREE)
    81     public JCTree visitAnnotation(AnnotationTree node, P p) {
    85     public JCTree visitAnnotation(AnnotationTree node, P p) {
    82         JCAnnotation t = (JCAnnotation) node;
    86         JCAnnotation t = (JCAnnotation) node;
    83         JCTree annotationType = copy(t.annotationType, p);
    87         JCTree annotationType = copy(t.annotationType, p);
    84         List<JCExpression> args = copy(t.args, p);
    88         List<JCExpression> args = copy(t.args, p);
    85         if (t.getKind() == Tree.Kind.TYPE_ANNOTATION) {
    89         if (t.getKind() == Tree.Kind.TYPE_ANNOTATION) {
    91             newT.attribute = t.attribute;
    95             newT.attribute = t.attribute;
    92             return newT;
    96             return newT;
    93         }
    97         }
    94     }
    98     }
    95 
    99 
       
   100     @DefinedBy(Api.COMPILER_TREE)
    96     public JCTree visitAssert(AssertTree node, P p) {
   101     public JCTree visitAssert(AssertTree node, P p) {
    97         JCAssert t = (JCAssert) node;
   102         JCAssert t = (JCAssert) node;
    98         JCExpression cond = copy(t.cond, p);
   103         JCExpression cond = copy(t.cond, p);
    99         JCExpression detail = copy(t.detail, p);
   104         JCExpression detail = copy(t.detail, p);
   100         return M.at(t.pos).Assert(cond, detail);
   105         return M.at(t.pos).Assert(cond, detail);
   101     }
   106     }
   102 
   107 
       
   108     @DefinedBy(Api.COMPILER_TREE)
   103     public JCTree visitAssignment(AssignmentTree node, P p) {
   109     public JCTree visitAssignment(AssignmentTree node, P p) {
   104         JCAssign t = (JCAssign) node;
   110         JCAssign t = (JCAssign) node;
   105         JCExpression lhs = copy(t.lhs, p);
   111         JCExpression lhs = copy(t.lhs, p);
   106         JCExpression rhs = copy(t.rhs, p);
   112         JCExpression rhs = copy(t.rhs, p);
   107         return M.at(t.pos).Assign(lhs, rhs);
   113         return M.at(t.pos).Assign(lhs, rhs);
   108     }
   114     }
   109 
   115 
       
   116     @DefinedBy(Api.COMPILER_TREE)
   110     public JCTree visitCompoundAssignment(CompoundAssignmentTree node, P p) {
   117     public JCTree visitCompoundAssignment(CompoundAssignmentTree node, P p) {
   111         JCAssignOp t = (JCAssignOp) node;
   118         JCAssignOp t = (JCAssignOp) node;
   112         JCTree lhs = copy(t.lhs, p);
   119         JCTree lhs = copy(t.lhs, p);
   113         JCTree rhs = copy(t.rhs, p);
   120         JCTree rhs = copy(t.rhs, p);
   114         return M.at(t.pos).Assignop(t.getTag(), lhs, rhs);
   121         return M.at(t.pos).Assignop(t.getTag(), lhs, rhs);
   115     }
   122     }
   116 
   123 
       
   124     @DefinedBy(Api.COMPILER_TREE)
   117     public JCTree visitBinary(BinaryTree node, P p) {
   125     public JCTree visitBinary(BinaryTree node, P p) {
   118         JCBinary t = (JCBinary) node;
   126         JCBinary t = (JCBinary) node;
   119         JCExpression lhs = copy(t.lhs, p);
   127         JCExpression lhs = copy(t.lhs, p);
   120         JCExpression rhs = copy(t.rhs, p);
   128         JCExpression rhs = copy(t.rhs, p);
   121         return M.at(t.pos).Binary(t.getTag(), lhs, rhs);
   129         return M.at(t.pos).Binary(t.getTag(), lhs, rhs);
   122     }
   130     }
   123 
   131 
       
   132     @DefinedBy(Api.COMPILER_TREE)
   124     public JCTree visitBlock(BlockTree node, P p) {
   133     public JCTree visitBlock(BlockTree node, P p) {
   125         JCBlock t = (JCBlock) node;
   134         JCBlock t = (JCBlock) node;
   126         List<JCStatement> stats = copy(t.stats, p);
   135         List<JCStatement> stats = copy(t.stats, p);
   127         return M.at(t.pos).Block(t.flags, stats);
   136         return M.at(t.pos).Block(t.flags, stats);
   128     }
   137     }
   129 
   138 
       
   139     @DefinedBy(Api.COMPILER_TREE)
   130     public JCTree visitBreak(BreakTree node, P p) {
   140     public JCTree visitBreak(BreakTree node, P p) {
   131         JCBreak t = (JCBreak) node;
   141         JCBreak t = (JCBreak) node;
   132         return M.at(t.pos).Break(t.label);
   142         return M.at(t.pos).Break(t.label);
   133     }
   143     }
   134 
   144 
       
   145     @DefinedBy(Api.COMPILER_TREE)
   135     public JCTree visitCase(CaseTree node, P p) {
   146     public JCTree visitCase(CaseTree node, P p) {
   136         JCCase t = (JCCase) node;
   147         JCCase t = (JCCase) node;
   137         JCExpression pat = copy(t.pat, p);
   148         JCExpression pat = copy(t.pat, p);
   138         List<JCStatement> stats = copy(t.stats, p);
   149         List<JCStatement> stats = copy(t.stats, p);
   139         return M.at(t.pos).Case(pat, stats);
   150         return M.at(t.pos).Case(pat, stats);
   140     }
   151     }
   141 
   152 
       
   153     @DefinedBy(Api.COMPILER_TREE)
   142     public JCTree visitCatch(CatchTree node, P p) {
   154     public JCTree visitCatch(CatchTree node, P p) {
   143         JCCatch t = (JCCatch) node;
   155         JCCatch t = (JCCatch) node;
   144         JCVariableDecl param = copy(t.param, p);
   156         JCVariableDecl param = copy(t.param, p);
   145         JCBlock body = copy(t.body, p);
   157         JCBlock body = copy(t.body, p);
   146         return M.at(t.pos).Catch(param, body);
   158         return M.at(t.pos).Catch(param, body);
   147     }
   159     }
   148 
   160 
       
   161     @DefinedBy(Api.COMPILER_TREE)
   149     public JCTree visitClass(ClassTree node, P p) {
   162     public JCTree visitClass(ClassTree node, P p) {
   150         JCClassDecl t = (JCClassDecl) node;
   163         JCClassDecl t = (JCClassDecl) node;
   151         JCModifiers mods = copy(t.mods, p);
   164         JCModifiers mods = copy(t.mods, p);
   152         List<JCTypeParameter> typarams = copy(t.typarams, p);
   165         List<JCTypeParameter> typarams = copy(t.typarams, p);
   153         JCExpression extending = copy(t.extending, p);
   166         JCExpression extending = copy(t.extending, p);
   154         List<JCExpression> implementing = copy(t.implementing, p);
   167         List<JCExpression> implementing = copy(t.implementing, p);
   155         List<JCTree> defs = copy(t.defs, p);
   168         List<JCTree> defs = copy(t.defs, p);
   156         return M.at(t.pos).ClassDef(mods, t.name, typarams, extending, implementing, defs);
   169         return M.at(t.pos).ClassDef(mods, t.name, typarams, extending, implementing, defs);
   157     }
   170     }
   158 
   171 
       
   172     @DefinedBy(Api.COMPILER_TREE)
   159     public JCTree visitConditionalExpression(ConditionalExpressionTree node, P p) {
   173     public JCTree visitConditionalExpression(ConditionalExpressionTree node, P p) {
   160         JCConditional t = (JCConditional) node;
   174         JCConditional t = (JCConditional) node;
   161         JCExpression cond = copy(t.cond, p);
   175         JCExpression cond = copy(t.cond, p);
   162         JCExpression truepart = copy(t.truepart, p);
   176         JCExpression truepart = copy(t.truepart, p);
   163         JCExpression falsepart = copy(t.falsepart, p);
   177         JCExpression falsepart = copy(t.falsepart, p);
   164         return M.at(t.pos).Conditional(cond, truepart, falsepart);
   178         return M.at(t.pos).Conditional(cond, truepart, falsepart);
   165     }
   179     }
   166 
   180 
       
   181     @DefinedBy(Api.COMPILER_TREE)
   167     public JCTree visitContinue(ContinueTree node, P p) {
   182     public JCTree visitContinue(ContinueTree node, P p) {
   168         JCContinue t = (JCContinue) node;
   183         JCContinue t = (JCContinue) node;
   169         return M.at(t.pos).Continue(t.label);
   184         return M.at(t.pos).Continue(t.label);
   170     }
   185     }
   171 
   186 
       
   187     @DefinedBy(Api.COMPILER_TREE)
   172     public JCTree visitDoWhileLoop(DoWhileLoopTree node, P p) {
   188     public JCTree visitDoWhileLoop(DoWhileLoopTree node, P p) {
   173         JCDoWhileLoop t = (JCDoWhileLoop) node;
   189         JCDoWhileLoop t = (JCDoWhileLoop) node;
   174         JCStatement body = copy(t.body, p);
   190         JCStatement body = copy(t.body, p);
   175         JCExpression cond = copy(t.cond, p);
   191         JCExpression cond = copy(t.cond, p);
   176         return M.at(t.pos).DoLoop(body, cond);
   192         return M.at(t.pos).DoLoop(body, cond);
   177     }
   193     }
   178 
   194 
       
   195     @DefinedBy(Api.COMPILER_TREE)
   179     public JCTree visitErroneous(ErroneousTree node, P p) {
   196     public JCTree visitErroneous(ErroneousTree node, P p) {
   180         JCErroneous t = (JCErroneous) node;
   197         JCErroneous t = (JCErroneous) node;
   181         List<? extends JCTree> errs = copy(t.errs, p);
   198         List<? extends JCTree> errs = copy(t.errs, p);
   182         return M.at(t.pos).Erroneous(errs);
   199         return M.at(t.pos).Erroneous(errs);
   183     }
   200     }
   184 
   201 
       
   202     @DefinedBy(Api.COMPILER_TREE)
   185     public JCTree visitExpressionStatement(ExpressionStatementTree node, P p) {
   203     public JCTree visitExpressionStatement(ExpressionStatementTree node, P p) {
   186         JCExpressionStatement t = (JCExpressionStatement) node;
   204         JCExpressionStatement t = (JCExpressionStatement) node;
   187         JCExpression expr = copy(t.expr, p);
   205         JCExpression expr = copy(t.expr, p);
   188         return M.at(t.pos).Exec(expr);
   206         return M.at(t.pos).Exec(expr);
   189     }
   207     }
   190 
   208 
       
   209     @DefinedBy(Api.COMPILER_TREE)
   191     public JCTree visitEnhancedForLoop(EnhancedForLoopTree node, P p) {
   210     public JCTree visitEnhancedForLoop(EnhancedForLoopTree node, P p) {
   192         JCEnhancedForLoop t = (JCEnhancedForLoop) node;
   211         JCEnhancedForLoop t = (JCEnhancedForLoop) node;
   193         JCVariableDecl var = copy(t.var, p);
   212         JCVariableDecl var = copy(t.var, p);
   194         JCExpression expr = copy(t.expr, p);
   213         JCExpression expr = copy(t.expr, p);
   195         JCStatement body = copy(t.body, p);
   214         JCStatement body = copy(t.body, p);
   196         return M.at(t.pos).ForeachLoop(var, expr, body);
   215         return M.at(t.pos).ForeachLoop(var, expr, body);
   197     }
   216     }
   198 
   217 
       
   218     @DefinedBy(Api.COMPILER_TREE)
   199     public JCTree visitForLoop(ForLoopTree node, P p) {
   219     public JCTree visitForLoop(ForLoopTree node, P p) {
   200         JCForLoop t = (JCForLoop) node;
   220         JCForLoop t = (JCForLoop) node;
   201         List<JCStatement> init = copy(t.init, p);
   221         List<JCStatement> init = copy(t.init, p);
   202         JCExpression cond = copy(t.cond, p);
   222         JCExpression cond = copy(t.cond, p);
   203         List<JCExpressionStatement> step = copy(t.step, p);
   223         List<JCExpressionStatement> step = copy(t.step, p);
   204         JCStatement body = copy(t.body, p);
   224         JCStatement body = copy(t.body, p);
   205         return M.at(t.pos).ForLoop(init, cond, step, body);
   225         return M.at(t.pos).ForLoop(init, cond, step, body);
   206     }
   226     }
   207 
   227 
       
   228     @DefinedBy(Api.COMPILER_TREE)
   208     public JCTree visitIdentifier(IdentifierTree node, P p) {
   229     public JCTree visitIdentifier(IdentifierTree node, P p) {
   209         JCIdent t = (JCIdent) node;
   230         JCIdent t = (JCIdent) node;
   210         return M.at(t.pos).Ident(t.name);
   231         return M.at(t.pos).Ident(t.name);
   211     }
   232     }
   212 
   233 
       
   234     @DefinedBy(Api.COMPILER_TREE)
   213     public JCTree visitIf(IfTree node, P p) {
   235     public JCTree visitIf(IfTree node, P p) {
   214         JCIf t = (JCIf) node;
   236         JCIf t = (JCIf) node;
   215         JCExpression cond = copy(t.cond, p);
   237         JCExpression cond = copy(t.cond, p);
   216         JCStatement thenpart = copy(t.thenpart, p);
   238         JCStatement thenpart = copy(t.thenpart, p);
   217         JCStatement elsepart = copy(t.elsepart, p);
   239         JCStatement elsepart = copy(t.elsepart, p);
   218         return M.at(t.pos).If(cond, thenpart, elsepart);
   240         return M.at(t.pos).If(cond, thenpart, elsepart);
   219     }
   241     }
   220 
   242 
       
   243     @DefinedBy(Api.COMPILER_TREE)
   221     public JCTree visitImport(ImportTree node, P p) {
   244     public JCTree visitImport(ImportTree node, P p) {
   222         JCImport t = (JCImport) node;
   245         JCImport t = (JCImport) node;
   223         JCTree qualid = copy(t.qualid, p);
   246         JCTree qualid = copy(t.qualid, p);
   224         return M.at(t.pos).Import(qualid, t.staticImport);
   247         return M.at(t.pos).Import(qualid, t.staticImport);
   225     }
   248     }
   226 
   249 
       
   250     @DefinedBy(Api.COMPILER_TREE)
   227     public JCTree visitArrayAccess(ArrayAccessTree node, P p) {
   251     public JCTree visitArrayAccess(ArrayAccessTree node, P p) {
   228         JCArrayAccess t = (JCArrayAccess) node;
   252         JCArrayAccess t = (JCArrayAccess) node;
   229         JCExpression indexed = copy(t.indexed, p);
   253         JCExpression indexed = copy(t.indexed, p);
   230         JCExpression index = copy(t.index, p);
   254         JCExpression index = copy(t.index, p);
   231         return M.at(t.pos).Indexed(indexed, index);
   255         return M.at(t.pos).Indexed(indexed, index);
   232     }
   256     }
   233 
   257 
       
   258     @DefinedBy(Api.COMPILER_TREE)
   234     public JCTree visitLabeledStatement(LabeledStatementTree node, P p) {
   259     public JCTree visitLabeledStatement(LabeledStatementTree node, P p) {
   235         JCLabeledStatement t = (JCLabeledStatement) node;
   260         JCLabeledStatement t = (JCLabeledStatement) node;
   236         JCStatement body = copy(t.body, p);
   261         JCStatement body = copy(t.body, p);
   237         return M.at(t.pos).Labelled(t.label, body);
   262         return M.at(t.pos).Labelled(t.label, body);
   238     }
   263     }
   239 
   264 
       
   265     @DefinedBy(Api.COMPILER_TREE)
   240     public JCTree visitLiteral(LiteralTree node, P p) {
   266     public JCTree visitLiteral(LiteralTree node, P p) {
   241         JCLiteral t = (JCLiteral) node;
   267         JCLiteral t = (JCLiteral) node;
   242         return M.at(t.pos).Literal(t.typetag, t.value);
   268         return M.at(t.pos).Literal(t.typetag, t.value);
   243     }
   269     }
   244 
   270 
       
   271     @DefinedBy(Api.COMPILER_TREE)
   245     public JCTree visitMethod(MethodTree node, P p) {
   272     public JCTree visitMethod(MethodTree node, P p) {
   246         JCMethodDecl t  = (JCMethodDecl) node;
   273         JCMethodDecl t  = (JCMethodDecl) node;
   247         JCModifiers mods = copy(t.mods, p);
   274         JCModifiers mods = copy(t.mods, p);
   248         JCExpression restype = copy(t.restype, p);
   275         JCExpression restype = copy(t.restype, p);
   249         List<JCTypeParameter> typarams = copy(t.typarams, p);
   276         List<JCTypeParameter> typarams = copy(t.typarams, p);
   253         JCBlock body = copy(t.body, p);
   280         JCBlock body = copy(t.body, p);
   254         JCExpression defaultValue = copy(t.defaultValue, p);
   281         JCExpression defaultValue = copy(t.defaultValue, p);
   255         return M.at(t.pos).MethodDef(mods, t.name, restype, typarams, recvparam, params, thrown, body, defaultValue);
   282         return M.at(t.pos).MethodDef(mods, t.name, restype, typarams, recvparam, params, thrown, body, defaultValue);
   256     }
   283     }
   257 
   284 
       
   285     @DefinedBy(Api.COMPILER_TREE)
   258     public JCTree visitMethodInvocation(MethodInvocationTree node, P p) {
   286     public JCTree visitMethodInvocation(MethodInvocationTree node, P p) {
   259         JCMethodInvocation t = (JCMethodInvocation) node;
   287         JCMethodInvocation t = (JCMethodInvocation) node;
   260         List<JCExpression> typeargs = copy(t.typeargs, p);
   288         List<JCExpression> typeargs = copy(t.typeargs, p);
   261         JCExpression meth = copy(t.meth, p);
   289         JCExpression meth = copy(t.meth, p);
   262         List<JCExpression> args = copy(t.args, p);
   290         List<JCExpression> args = copy(t.args, p);
   263         return M.at(t.pos).Apply(typeargs, meth, args);
   291         return M.at(t.pos).Apply(typeargs, meth, args);
   264     }
   292     }
   265 
   293 
       
   294     @DefinedBy(Api.COMPILER_TREE)
   266     public JCTree visitModifiers(ModifiersTree node, P p) {
   295     public JCTree visitModifiers(ModifiersTree node, P p) {
   267         JCModifiers t = (JCModifiers) node;
   296         JCModifiers t = (JCModifiers) node;
   268         List<JCAnnotation> annotations = copy(t.annotations, p);
   297         List<JCAnnotation> annotations = copy(t.annotations, p);
   269         return M.at(t.pos).Modifiers(t.flags, annotations);
   298         return M.at(t.pos).Modifiers(t.flags, annotations);
   270     }
   299     }
   271 
   300 
       
   301     @DefinedBy(Api.COMPILER_TREE)
   272     public JCTree visitNewArray(NewArrayTree node, P p) {
   302     public JCTree visitNewArray(NewArrayTree node, P p) {
   273         JCNewArray t = (JCNewArray) node;
   303         JCNewArray t = (JCNewArray) node;
   274         JCExpression elemtype = copy(t.elemtype, p);
   304         JCExpression elemtype = copy(t.elemtype, p);
   275         List<JCExpression> dims = copy(t.dims, p);
   305         List<JCExpression> dims = copy(t.dims, p);
   276         List<JCExpression> elems = copy(t.elems, p);
   306         List<JCExpression> elems = copy(t.elems, p);
   277         return M.at(t.pos).NewArray(elemtype, dims, elems);
   307         return M.at(t.pos).NewArray(elemtype, dims, elems);
   278     }
   308     }
   279 
   309 
       
   310     @DefinedBy(Api.COMPILER_TREE)
   280     public JCTree visitNewClass(NewClassTree node, P p) {
   311     public JCTree visitNewClass(NewClassTree node, P p) {
   281         JCNewClass t = (JCNewClass) node;
   312         JCNewClass t = (JCNewClass) node;
   282         JCExpression encl = copy(t.encl, p);
   313         JCExpression encl = copy(t.encl, p);
   283         List<JCExpression> typeargs = copy(t.typeargs, p);
   314         List<JCExpression> typeargs = copy(t.typeargs, p);
   284         JCExpression clazz = copy(t.clazz, p);
   315         JCExpression clazz = copy(t.clazz, p);
   285         List<JCExpression> args = copy(t.args, p);
   316         List<JCExpression> args = copy(t.args, p);
   286         JCClassDecl def = copy(t.def, p);
   317         JCClassDecl def = copy(t.def, p);
   287         return M.at(t.pos).NewClass(encl, typeargs, clazz, args, def);
   318         return M.at(t.pos).NewClass(encl, typeargs, clazz, args, def);
   288     }
   319     }
   289 
   320 
       
   321     @DefinedBy(Api.COMPILER_TREE)
   290     public JCTree visitLambdaExpression(LambdaExpressionTree node, P p) {
   322     public JCTree visitLambdaExpression(LambdaExpressionTree node, P p) {
   291         JCLambda t = (JCLambda) node;
   323         JCLambda t = (JCLambda) node;
   292         List<JCVariableDecl> params = copy(t.params, p);
   324         List<JCVariableDecl> params = copy(t.params, p);
   293         JCTree body = copy(t.body, p);
   325         JCTree body = copy(t.body, p);
   294         return M.at(t.pos).Lambda(params, body);
   326         return M.at(t.pos).Lambda(params, body);
   295     }
   327     }
   296 
   328 
       
   329     @DefinedBy(Api.COMPILER_TREE)
   297     public JCTree visitParenthesized(ParenthesizedTree node, P p) {
   330     public JCTree visitParenthesized(ParenthesizedTree node, P p) {
   298         JCParens t = (JCParens) node;
   331         JCParens t = (JCParens) node;
   299         JCExpression expr = copy(t.expr, p);
   332         JCExpression expr = copy(t.expr, p);
   300         return M.at(t.pos).Parens(expr);
   333         return M.at(t.pos).Parens(expr);
   301     }
   334     }
   302 
   335 
       
   336     @DefinedBy(Api.COMPILER_TREE)
   303     public JCTree visitReturn(ReturnTree node, P p) {
   337     public JCTree visitReturn(ReturnTree node, P p) {
   304         JCReturn t = (JCReturn) node;
   338         JCReturn t = (JCReturn) node;
   305         JCExpression expr = copy(t.expr, p);
   339         JCExpression expr = copy(t.expr, p);
   306         return M.at(t.pos).Return(expr);
   340         return M.at(t.pos).Return(expr);
   307     }
   341     }
   308 
   342 
       
   343     @DefinedBy(Api.COMPILER_TREE)
   309     public JCTree visitMemberSelect(MemberSelectTree node, P p) {
   344     public JCTree visitMemberSelect(MemberSelectTree node, P p) {
   310         JCFieldAccess t = (JCFieldAccess) node;
   345         JCFieldAccess t = (JCFieldAccess) node;
   311         JCExpression selected = copy(t.selected, p);
   346         JCExpression selected = copy(t.selected, p);
   312         return M.at(t.pos).Select(selected, t.name);
   347         return M.at(t.pos).Select(selected, t.name);
   313     }
   348     }
   314 
   349 
       
   350     @DefinedBy(Api.COMPILER_TREE)
   315     public JCTree visitMemberReference(MemberReferenceTree node, P p) {
   351     public JCTree visitMemberReference(MemberReferenceTree node, P p) {
   316         JCMemberReference t = (JCMemberReference) node;
   352         JCMemberReference t = (JCMemberReference) node;
   317         JCExpression expr = copy(t.expr, p);
   353         JCExpression expr = copy(t.expr, p);
   318         List<JCExpression> typeargs = copy(t.typeargs, p);
   354         List<JCExpression> typeargs = copy(t.typeargs, p);
   319         return M.at(t.pos).Reference(t.mode, t.name, expr, typeargs);
   355         return M.at(t.pos).Reference(t.mode, t.name, expr, typeargs);
   320     }
   356     }
   321 
   357 
       
   358     @DefinedBy(Api.COMPILER_TREE)
   322     public JCTree visitEmptyStatement(EmptyStatementTree node, P p) {
   359     public JCTree visitEmptyStatement(EmptyStatementTree node, P p) {
   323         JCSkip t = (JCSkip) node;
   360         JCSkip t = (JCSkip) node;
   324         return M.at(t.pos).Skip();
   361         return M.at(t.pos).Skip();
   325     }
   362     }
   326 
   363 
       
   364     @DefinedBy(Api.COMPILER_TREE)
   327     public JCTree visitSwitch(SwitchTree node, P p) {
   365     public JCTree visitSwitch(SwitchTree node, P p) {
   328         JCSwitch t = (JCSwitch) node;
   366         JCSwitch t = (JCSwitch) node;
   329         JCExpression selector = copy(t.selector, p);
   367         JCExpression selector = copy(t.selector, p);
   330         List<JCCase> cases = copy(t.cases, p);
   368         List<JCCase> cases = copy(t.cases, p);
   331         return M.at(t.pos).Switch(selector, cases);
   369         return M.at(t.pos).Switch(selector, cases);
   332     }
   370     }
   333 
   371 
       
   372     @DefinedBy(Api.COMPILER_TREE)
   334     public JCTree visitSynchronized(SynchronizedTree node, P p) {
   373     public JCTree visitSynchronized(SynchronizedTree node, P p) {
   335         JCSynchronized t = (JCSynchronized) node;
   374         JCSynchronized t = (JCSynchronized) node;
   336         JCExpression lock = copy(t.lock, p);
   375         JCExpression lock = copy(t.lock, p);
   337         JCBlock body = copy(t.body, p);
   376         JCBlock body = copy(t.body, p);
   338         return M.at(t.pos).Synchronized(lock, body);
   377         return M.at(t.pos).Synchronized(lock, body);
   339     }
   378     }
   340 
   379 
       
   380     @DefinedBy(Api.COMPILER_TREE)
   341     public JCTree visitThrow(ThrowTree node, P p) {
   381     public JCTree visitThrow(ThrowTree node, P p) {
   342         JCThrow t = (JCThrow) node;
   382         JCThrow t = (JCThrow) node;
   343         JCExpression expr = copy(t.expr, p);
   383         JCExpression expr = copy(t.expr, p);
   344         return M.at(t.pos).Throw(expr);
   384         return M.at(t.pos).Throw(expr);
   345     }
   385     }
   346 
   386 
       
   387     @DefinedBy(Api.COMPILER_TREE)
   347     public JCTree visitCompilationUnit(CompilationUnitTree node, P p) {
   388     public JCTree visitCompilationUnit(CompilationUnitTree node, P p) {
   348         JCCompilationUnit t = (JCCompilationUnit) node;
   389         JCCompilationUnit t = (JCCompilationUnit) node;
   349         List<JCTree> defs = copy(t.defs, p);
   390         List<JCTree> defs = copy(t.defs, p);
   350         return M.at(t.pos).TopLevel(defs);
   391         return M.at(t.pos).TopLevel(defs);
   351     }
   392     }
   352 
   393 
       
   394     @DefinedBy(Api.COMPILER_TREE)
   353     public JCTree visitPackage(PackageTree node, P p) {
   395     public JCTree visitPackage(PackageTree node, P p) {
   354         JCPackageDecl t = (JCPackageDecl) node;
   396         JCPackageDecl t = (JCPackageDecl) node;
   355         List<JCAnnotation> annotations = copy(t.annotations, p);
   397         List<JCAnnotation> annotations = copy(t.annotations, p);
   356         JCExpression pid = copy(t.pid, p);
   398         JCExpression pid = copy(t.pid, p);
   357         return M.at(t.pos).PackageDecl(annotations, pid);
   399         return M.at(t.pos).PackageDecl(annotations, pid);
   358     }
   400     }
   359 
   401 
       
   402     @DefinedBy(Api.COMPILER_TREE)
   360     public JCTree visitTry(TryTree node, P p) {
   403     public JCTree visitTry(TryTree node, P p) {
   361         JCTry t = (JCTry) node;
   404         JCTry t = (JCTry) node;
   362         List<JCTree> resources = copy(t.resources, p);
   405         List<JCTree> resources = copy(t.resources, p);
   363         JCBlock body = copy(t.body, p);
   406         JCBlock body = copy(t.body, p);
   364         List<JCCatch> catchers = copy(t.catchers, p);
   407         List<JCCatch> catchers = copy(t.catchers, p);
   365         JCBlock finalizer = copy(t.finalizer, p);
   408         JCBlock finalizer = copy(t.finalizer, p);
   366         return M.at(t.pos).Try(resources, body, catchers, finalizer);
   409         return M.at(t.pos).Try(resources, body, catchers, finalizer);
   367     }
   410     }
   368 
   411 
       
   412     @DefinedBy(Api.COMPILER_TREE)
   369     public JCTree visitParameterizedType(ParameterizedTypeTree node, P p) {
   413     public JCTree visitParameterizedType(ParameterizedTypeTree node, P p) {
   370         JCTypeApply t = (JCTypeApply) node;
   414         JCTypeApply t = (JCTypeApply) node;
   371         JCExpression clazz = copy(t.clazz, p);
   415         JCExpression clazz = copy(t.clazz, p);
   372         List<JCExpression> arguments = copy(t.arguments, p);
   416         List<JCExpression> arguments = copy(t.arguments, p);
   373         return M.at(t.pos).TypeApply(clazz, arguments);
   417         return M.at(t.pos).TypeApply(clazz, arguments);
   374     }
   418     }
   375 
   419 
       
   420     @DefinedBy(Api.COMPILER_TREE)
   376     public JCTree visitUnionType(UnionTypeTree node, P p) {
   421     public JCTree visitUnionType(UnionTypeTree node, P p) {
   377         JCTypeUnion t = (JCTypeUnion) node;
   422         JCTypeUnion t = (JCTypeUnion) node;
   378         List<JCExpression> components = copy(t.alternatives, p);
   423         List<JCExpression> components = copy(t.alternatives, p);
   379         return M.at(t.pos).TypeUnion(components);
   424         return M.at(t.pos).TypeUnion(components);
   380     }
   425     }
   381 
   426 
       
   427     @DefinedBy(Api.COMPILER_TREE)
   382     public JCTree visitIntersectionType(IntersectionTypeTree node, P p) {
   428     public JCTree visitIntersectionType(IntersectionTypeTree node, P p) {
   383         JCTypeIntersection t = (JCTypeIntersection) node;
   429         JCTypeIntersection t = (JCTypeIntersection) node;
   384         List<JCExpression> bounds = copy(t.bounds, p);
   430         List<JCExpression> bounds = copy(t.bounds, p);
   385         return M.at(t.pos).TypeIntersection(bounds);
   431         return M.at(t.pos).TypeIntersection(bounds);
   386     }
   432     }
   387 
   433 
       
   434     @DefinedBy(Api.COMPILER_TREE)
   388     public JCTree visitArrayType(ArrayTypeTree node, P p) {
   435     public JCTree visitArrayType(ArrayTypeTree node, P p) {
   389         JCArrayTypeTree t = (JCArrayTypeTree) node;
   436         JCArrayTypeTree t = (JCArrayTypeTree) node;
   390         JCExpression elemtype = copy(t.elemtype, p);
   437         JCExpression elemtype = copy(t.elemtype, p);
   391         return M.at(t.pos).TypeArray(elemtype);
   438         return M.at(t.pos).TypeArray(elemtype);
   392     }
   439     }
   393 
   440 
       
   441     @DefinedBy(Api.COMPILER_TREE)
   394     public JCTree visitTypeCast(TypeCastTree node, P p) {
   442     public JCTree visitTypeCast(TypeCastTree node, P p) {
   395         JCTypeCast t = (JCTypeCast) node;
   443         JCTypeCast t = (JCTypeCast) node;
   396         JCTree clazz = copy(t.clazz, p);
   444         JCTree clazz = copy(t.clazz, p);
   397         JCExpression expr = copy(t.expr, p);
   445         JCExpression expr = copy(t.expr, p);
   398         return M.at(t.pos).TypeCast(clazz, expr);
   446         return M.at(t.pos).TypeCast(clazz, expr);
   399     }
   447     }
   400 
   448 
       
   449     @DefinedBy(Api.COMPILER_TREE)
   401     public JCTree visitPrimitiveType(PrimitiveTypeTree node, P p) {
   450     public JCTree visitPrimitiveType(PrimitiveTypeTree node, P p) {
   402         JCPrimitiveTypeTree t = (JCPrimitiveTypeTree) node;
   451         JCPrimitiveTypeTree t = (JCPrimitiveTypeTree) node;
   403         return M.at(t.pos).TypeIdent(t.typetag);
   452         return M.at(t.pos).TypeIdent(t.typetag);
   404     }
   453     }
   405 
   454 
       
   455     @DefinedBy(Api.COMPILER_TREE)
   406     public JCTree visitTypeParameter(TypeParameterTree node, P p) {
   456     public JCTree visitTypeParameter(TypeParameterTree node, P p) {
   407         JCTypeParameter t = (JCTypeParameter) node;
   457         JCTypeParameter t = (JCTypeParameter) node;
   408         List<JCAnnotation> annos = copy(t.annotations, p);
   458         List<JCAnnotation> annos = copy(t.annotations, p);
   409         List<JCExpression> bounds = copy(t.bounds, p);
   459         List<JCExpression> bounds = copy(t.bounds, p);
   410         return M.at(t.pos).TypeParameter(t.name, bounds, annos);
   460         return M.at(t.pos).TypeParameter(t.name, bounds, annos);
   411     }
   461     }
   412 
   462 
       
   463     @DefinedBy(Api.COMPILER_TREE)
   413     public JCTree visitInstanceOf(InstanceOfTree node, P p) {
   464     public JCTree visitInstanceOf(InstanceOfTree node, P p) {
   414         JCInstanceOf t = (JCInstanceOf) node;
   465         JCInstanceOf t = (JCInstanceOf) node;
   415         JCExpression expr = copy(t.expr, p);
   466         JCExpression expr = copy(t.expr, p);
   416         JCTree clazz = copy(t.clazz, p);
   467         JCTree clazz = copy(t.clazz, p);
   417         return M.at(t.pos).TypeTest(expr, clazz);
   468         return M.at(t.pos).TypeTest(expr, clazz);
   418     }
   469     }
   419 
   470 
       
   471     @DefinedBy(Api.COMPILER_TREE)
   420     public JCTree visitUnary(UnaryTree node, P p) {
   472     public JCTree visitUnary(UnaryTree node, P p) {
   421         JCUnary t = (JCUnary) node;
   473         JCUnary t = (JCUnary) node;
   422         JCExpression arg = copy(t.arg, p);
   474         JCExpression arg = copy(t.arg, p);
   423         return M.at(t.pos).Unary(t.getTag(), arg);
   475         return M.at(t.pos).Unary(t.getTag(), arg);
   424     }
   476     }
   425 
   477 
       
   478     @DefinedBy(Api.COMPILER_TREE)
   426     public JCTree visitVariable(VariableTree node, P p) {
   479     public JCTree visitVariable(VariableTree node, P p) {
   427         JCVariableDecl t = (JCVariableDecl) node;
   480         JCVariableDecl t = (JCVariableDecl) node;
   428         JCModifiers mods = copy(t.mods, p);
   481         JCModifiers mods = copy(t.mods, p);
   429         JCExpression vartype = copy(t.vartype, p);
   482         JCExpression vartype = copy(t.vartype, p);
   430         if (t.nameexpr == null) {
   483         if (t.nameexpr == null) {
   434             JCExpression nameexpr = copy(t.nameexpr, p);
   487             JCExpression nameexpr = copy(t.nameexpr, p);
   435             return M.at(t.pos).ReceiverVarDef(mods, nameexpr, vartype);
   488             return M.at(t.pos).ReceiverVarDef(mods, nameexpr, vartype);
   436         }
   489         }
   437     }
   490     }
   438 
   491 
       
   492     @DefinedBy(Api.COMPILER_TREE)
   439     public JCTree visitWhileLoop(WhileLoopTree node, P p) {
   493     public JCTree visitWhileLoop(WhileLoopTree node, P p) {
   440         JCWhileLoop t = (JCWhileLoop) node;
   494         JCWhileLoop t = (JCWhileLoop) node;
   441         JCStatement body = copy(t.body, p);
   495         JCStatement body = copy(t.body, p);
   442         JCExpression cond = copy(t.cond, p);
   496         JCExpression cond = copy(t.cond, p);
   443         return M.at(t.pos).WhileLoop(cond, body);
   497         return M.at(t.pos).WhileLoop(cond, body);
   444     }
   498     }
   445 
   499 
       
   500     @DefinedBy(Api.COMPILER_TREE)
   446     public JCTree visitWildcard(WildcardTree node, P p) {
   501     public JCTree visitWildcard(WildcardTree node, P p) {
   447         JCWildcard t = (JCWildcard) node;
   502         JCWildcard t = (JCWildcard) node;
   448         TypeBoundKind kind = M.at(t.kind.pos).TypeBoundKind(t.kind.kind);
   503         TypeBoundKind kind = M.at(t.kind.pos).TypeBoundKind(t.kind.kind);
   449         JCTree inner = copy(t.inner, p);
   504         JCTree inner = copy(t.inner, p);
   450         return M.at(t.pos).Wildcard(kind, inner);
   505         return M.at(t.pos).Wildcard(kind, inner);
   451     }
   506     }
   452 
   507 
       
   508     @DefinedBy(Api.COMPILER_TREE)
   453     public JCTree visitOther(Tree node, P p) {
   509     public JCTree visitOther(Tree node, P p) {
   454         JCTree tree = (JCTree) node;
   510         JCTree tree = (JCTree) node;
   455         switch (tree.getTag()) {
   511         switch (tree.getTag()) {
   456             case LETEXPR: {
   512             case LETEXPR: {
   457                 LetExpr t = (LetExpr) node;
   513                 LetExpr t = (LetExpr) node;