?? treemaker.java
字號:
/** * @(#)TreeMaker.java 1.32 03/01/23 * * Copyright 2003 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */package com.sun.tools.javac.v8.tree;import com.sun.tools.javac.v8.util.*;import com.sun.tools.javac.v8.code.*;import com.sun.tools.javac.v8.tree.Tree.*;import com.sun.tools.javac.v8.code.Symbol.*;import com.sun.tools.javac.v8.code.Type.*;/** * Factory class for trees */public class TreeMaker implements Tree.Factory, Kinds, Flags, TypeTags { /** * The context key for the tree factory. */ private static final Context.Key treeMakerKey = new Context.Key(); /** * Get the TreeMaker instance. */ public static TreeMaker instance(Context context) { TreeMaker instance = (TreeMaker) context.get(treeMakerKey); if (instance == null) instance = new TreeMaker(context); return instance; } /** * The position at which subsequent trees will be created. */ public int pos = Position.NOPOS; /** * The toplevel tree to which created trees belong. */ public TopLevel toplevel; /** * The current name table. */ private Name.Table names; /** * Create a tree maker with null toplevel and NOPOS as initial position. */ private TreeMaker(Context context) { super(); context.put(treeMakerKey, this); this.pos = Position.NOPOS; this.toplevel = null; this.names = Name.Table.instance(context); } /** * Create a tree maker with null toplevel and NOPOS as initial position. */ public TreeMaker(TopLevel toplevel) { super(); this.pos = Position.FIRSTPOS; this.toplevel = toplevel; this.names = toplevel.sourcefile.table; } /** * Reassign current position. */ public TreeMaker at(int pos) { this.pos = pos; return this; } /** * Create given tree node at current position. */ public TopLevel TopLevel(Tree pid, List defs) { TopLevel tree = new TopLevel(pid, defs, null, null, null, null); tree.pos = pos; return tree; } public Import Import(Tree qualid) { Import tree = new Import(qualid); tree.pos = pos; return tree; } public ClassDef ClassDef(long flags, Name name, List typarams, Tree extending, List implementing, List defs) { ClassDef tree = new ClassDef(flags, name, typarams, extending, implementing, defs, null); tree.pos = pos; return tree; } public MethodDef MethodDef(long flags, Name name, Tree restype, List typarams, List params, List thrown, Block body) { MethodDef tree = new MethodDef(flags, name, restype, typarams, params, thrown, body, null); tree.pos = pos; return tree; } public VarDef VarDef(long flags, Name name, Tree vartype, Tree init) { VarDef tree = new VarDef(flags, name, vartype, init, null); tree.pos = pos; return tree; } public Skip Skip() { Skip tree = new Skip(); tree.pos = pos; return tree; } public Block Block(long flags, List stats) { Block tree = new Block(flags, stats); tree.pos = pos; return tree; } public DoLoop DoLoop(Tree body, Tree cond) { DoLoop tree = new DoLoop(body, cond); tree.pos = pos; return tree; } public WhileLoop WhileLoop(Tree cond, Tree body) { WhileLoop tree = new WhileLoop(cond, body); tree.pos = pos; return tree; } public ForLoop ForLoop(List init, Tree cond, List step, Tree body) { ForLoop tree = new ForLoop(init, cond, step, body); tree.pos = pos; return tree; } public Labelled Labelled(Name label, Tree body) { Labelled tree = new Labelled(label, body); tree.pos = pos; return tree; } public Switch Switch(Tree selector, List cases) { Switch tree = new Switch(selector, cases); tree.pos = pos; return tree; } public Case Case(Tree pat, List stats) { Case tree = new Case(pat, stats); tree.pos = pos; return tree; } public Synchronized Synchronized(Tree lock, Tree body) { Synchronized tree = new Synchronized(lock, body); tree.pos = pos; return tree; } public Try Try(Tree body, List catchers, Tree finalizer) { Try tree = new Try(body, catchers, finalizer); tree.pos = pos; return tree; } public Catch Catch(VarDef param, Tree body) { Catch tree = new Catch(param, body); tree.pos = pos; return tree; } public Conditional Conditional(Tree cond, Tree thenpart, Tree elsepart) { Conditional tree = new Conditional(cond, thenpart, elsepart); tree.pos = pos; return tree; } public If If(Tree cond, Tree thenpart, Tree elsepart) { If tree = new If(cond, thenpart, elsepart); tree.pos = pos; return tree; } public Exec Exec(Tree expr) { Exec tree = new Exec(expr); tree.pos = pos; return tree; } public Break Break(Name label) { Break tree = new Break(label, null); tree.pos = pos; return tree; } public Continue Continue(Name label) { Continue tree = new Continue(label, null); tree.pos = pos; return tree; } public Return Return(Tree expr) { Return tree = new Return(expr); tree.pos = pos; return tree; } public Throw Throw(Tree expr) { Throw tree = new Throw(expr); tree.pos = pos; return tree; } public Assert Assert(Tree cond, Tree detail) { Assert tree = new Assert(cond, detail); tree.pos = pos; return tree; } public Apply Apply(Tree fn, List args) { Apply tree = new Apply(fn, args); tree.pos = pos; return tree; } public NewClass NewClass(Tree encl, Tree clazz, List args, ClassDef def) { NewClass tree = new NewClass(encl, clazz, args, def, null); tree.pos = pos; return tree; } public NewArray NewArray(Tree elemtype, List dims, List elems) { NewArray tree = new NewArray(elemtype, dims, elems); tree.pos = pos; return tree; } public Parens Parens(Tree expr) { Parens tree = new Parens(expr); tree.pos = pos; return tree; } public Assign Assign(Tree lhs, Tree rhs) { Assign tree = new Assign(lhs, rhs); tree.pos = pos; return tree; } public Assignop Assignop(int opcode, Tree lhs, Tree rhs) { Assignop tree = new Assignop(opcode, lhs, rhs, null); tree.pos = pos; return tree; } public Unary Unary(int opcode, Tree arg) { Unary tree = new Unary(opcode, arg, null); tree.pos = pos; return tree; } public Binary Binary(int opcode, Tree lhs, Tree rhs) { Binary tree = new Binary(opcode, lhs, rhs, null); tree.pos = pos; return tree; } public TypeCast TypeCast(Tree clazz, Tree expr) { TypeCast tree = new TypeCast(clazz, expr); tree.pos = pos; return tree;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -