treecopier.java
来自「是一款用JAVA 编写的编译器 具有很强的编译功能」· Java 代码 · 共 416 行 · 第 1/2 页
JAVA
416 行
JCImport t = (JCImport) node; JCTree qualid = copy(t.qualid, p); return M.at(t.pos).Import(qualid, t.staticImport); } public JCTree visitArrayAccess(ArrayAccessTree node, P p) { JCArrayAccess t = (JCArrayAccess) node; JCExpression indexed = copy(t.indexed, p); JCExpression index = copy(t.index, p); return M.at(t.pos).Indexed(indexed, index); } public JCTree visitLabeledStatement(LabeledStatementTree node, P p) { JCLabeledStatement t = (JCLabeledStatement) node; JCStatement body = copy(t.body, p); return M.at(t.pos).Labelled(t.label, t.body); } public JCTree visitLiteral(LiteralTree node, P p) { JCLiteral t = (JCLiteral) node; return M.at(t.pos).Literal(t.typetag, t.value); } public JCTree visitMethod(MethodTree node, P p) { JCMethodDecl t = (JCMethodDecl) node; JCModifiers mods = copy(t.mods, p); JCExpression restype = copy(t.restype, p); List<JCTypeParameter> typarams = copy(t.typarams, p); List<JCVariableDecl> params = copy(t.params, p); List<JCExpression> thrown = copy(t.thrown, p); JCBlock body = copy(t.body, p); JCExpression defaultValue = copy(t.defaultValue, p); return M.at(t.pos).MethodDef(mods, t.name, restype, typarams, params, thrown, body, defaultValue); } public JCTree visitMethodInvocation(MethodInvocationTree node, P p) { JCMethodInvocation t = (JCMethodInvocation) node; List<JCExpression> typeargs = copy(t.typeargs, p); JCExpression meth = copy(t.meth, p); List<JCExpression> args = copy(t.args, p); return M.at(t.pos).Apply(typeargs, meth, args); } public JCTree visitModifiers(ModifiersTree node, P p) { JCModifiers t = (JCModifiers) node; List<JCAnnotation> annotations = copy(t.annotations, p); return M.at(t.pos).Modifiers(t.flags, annotations); } public JCTree visitNewArray(NewArrayTree node, P p) { JCNewArray t = (JCNewArray) node; JCExpression elemtype = copy(t.elemtype, p); List<JCExpression> dims = copy(t.dims, p); List<JCExpression> elems = copy(t.elems, p); return M.at(t.pos).NewArray(elemtype, dims, elems); } public JCTree visitNewClass(NewClassTree node, P p) { JCNewClass t = (JCNewClass) node; JCExpression encl = copy(t.encl, p); List<JCExpression> typeargs = copy(t.typeargs, p); JCExpression clazz = copy(t.clazz, p); List<JCExpression> args = copy(t.args, p); JCClassDecl def = copy(t.def, p); return M.at(t.pos).NewClass(encl, typeargs, clazz, args, def); } public JCTree visitParenthesized(ParenthesizedTree node, P p) { JCParens t = (JCParens) node; JCExpression expr = copy(t.expr, p); return M.at(t.pos).Parens(expr); } public JCTree visitReturn(ReturnTree node, P p) { JCReturn t = (JCReturn) node; JCExpression expr = copy(t.expr, p); return M.at(t.pos).Return(expr); } public JCTree visitMemberSelect(MemberSelectTree node, P p) { JCFieldAccess t = (JCFieldAccess) node; JCExpression selected = copy(t.selected, p); return M.at(t.pos).Select(selected, t.name); } public JCTree visitEmptyStatement(EmptyStatementTree node, P p) { JCSkip t = (JCSkip) node; return M.at(t.pos).Skip(); } public JCTree visitSwitch(SwitchTree node, P p) { JCSwitch t = (JCSwitch) node; JCExpression selector = copy(t.selector, p); List<JCCase> cases = copy(t.cases, p); return M.at(t.pos).Switch(selector, cases); } public JCTree visitSynchronized(SynchronizedTree node, P p) { JCSynchronized t = (JCSynchronized) node; JCExpression lock = copy(t.lock, p); JCBlock body = copy(t.body, p); return M.at(t.pos).Synchronized(lock, body); } public JCTree visitThrow(ThrowTree node, P p) { JCThrow t = (JCThrow) node; JCTree expr = copy(t.expr, p); return M.at(t.pos).Throw(expr); } public JCTree visitCompilationUnit(CompilationUnitTree node, P p) { JCCompilationUnit t = (JCCompilationUnit) node; List<JCAnnotation> packageAnnotations = copy(t.packageAnnotations, p); JCExpression pid = copy(t.pid, p); List<JCTree> defs = copy(t.defs, p); return M.at(t.pos).TopLevel(packageAnnotations, pid, defs); } public JCTree visitTry(TryTree node, P p) { JCTry t = (JCTry) node; JCBlock body = copy(t.body, p); List<JCCatch> catchers = copy(t.catchers, p); JCBlock finalizer = copy(t.finalizer, p); return M.at(t.pos).Try(body, catchers, finalizer); } public JCTree visitParameterizedType(ParameterizedTypeTree node, P p) { JCTypeApply t = (JCTypeApply) node; JCExpression clazz = copy(t.clazz, p); List<JCExpression> arguments = copy(t.arguments, p); return M.at(t.pos).TypeApply(clazz, arguments); } public JCTree visitArrayType(ArrayTypeTree node, P p) { JCArrayTypeTree t = (JCArrayTypeTree) node; JCExpression elemtype = copy(t.elemtype, p); return M.at(t.pos).TypeArray(elemtype); } public JCTree visitTypeCast(TypeCastTree node, P p) { JCTypeCast t = (JCTypeCast) node; JCTree clazz = copy(t.clazz, p); JCExpression expr = copy(t.expr, p); return M.at(t.pos).TypeCast(clazz, expr); } public JCTree visitPrimitiveType(PrimitiveTypeTree node, P p) { JCPrimitiveTypeTree t = (JCPrimitiveTypeTree) node; return M.at(t.pos).TypeIdent(t.typetag); } public JCTree visitTypeParameter(TypeParameterTree node, P p) { JCTypeParameter t = (JCTypeParameter) node; List<JCExpression> bounds = copy(t.bounds, p); return M.at(t.pos).TypeParameter(t.name, t.bounds); } public JCTree visitInstanceOf(InstanceOfTree node, P p) { JCInstanceOf t = (JCInstanceOf) node; JCExpression expr = copy(t.expr, p); JCTree clazz = copy(t.clazz, p); return M.at(t.pos).TypeTest(expr, clazz); } public JCTree visitUnary(UnaryTree node, P p) { JCUnary t = (JCUnary) node; JCExpression arg = copy(t.arg, p); return M.at(t.pos).Unary(t.getTag(), arg); } public JCTree visitVariable(VariableTree node, P p) { JCVariableDecl t = (JCVariableDecl) node; JCModifiers mods = copy(t.mods, p); JCExpression vartype = copy(t.vartype, p); JCExpression init = copy(t.init, p); return M.at(t.pos).VarDef(mods, t.name, vartype, init); } public JCTree visitWhileLoop(WhileLoopTree node, P p) { JCWhileLoop t = (JCWhileLoop) node; JCStatement body = copy(t.body, p); JCExpression cond = copy(t.cond, p); return M.at(t.pos).WhileLoop(cond, body); } public JCTree visitWildcard(WildcardTree node, P p) { JCWildcard t = (JCWildcard) node; TypeBoundKind kind = M.at(t.kind.pos).TypeBoundKind(t.kind.kind); JCTree inner = copy(t.inner, p); return M.at(t.pos).Wildcard(kind, inner); } public JCTree visitOther(Tree node, P p) { JCTree tree = (JCTree) node; switch (tree.getTag()) { case JCTree.LETEXPR: { LetExpr t = (LetExpr) node; List<JCVariableDecl> defs = copy(t.defs, p); JCTree expr = copy(t.expr, p); return M.at(t.pos).LetExpr(defs, expr); } default: throw new AssertionError("unknown tree tag: " + tree.getTag()); } } }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?