📄 transinner.java
字号:
* @param owner The class symbol's owner */ ClassSymbol makeEmptyClass(long flags, ClassSymbol owner) { ClassSymbol c = reader.defineClass(names.empty, owner); c.flatname = chk.localClassName(c); c.sourcefile = owner.sourcefile; c.completer = null; c.members_field = new Scope(c); c.flags_field = flags; ClassType ctype = (ClassType) c.type; ctype.supertype_field = syms.objectType; ctype.interfaces_field = Type.emptyList; ClassDef odef = classDef(owner); enterSynthetic(odef.pos, c, owner.members()); chk.compiled.put(c.flatname, c); ClassDef cdef = make.ClassDef(flags, names.empty, TypeParameter.emptyList, null, Tree.emptyList, Tree.emptyList); cdef.sym = c; cdef.type = c.type; odef.defs = odef.defs.prepend(cdef); return c; } /** * Report a conflict between a user symbol and a synthetic symbol. */ private void duplicateError(int pos, Symbol sym) { if (!sym.type.isErroneous()) { log.error(pos, "synthetic.name.conflict", sym.toJava(), sym.javaLocation()); } } /** * Enter a synthetic symbol in a given scope, but complain if there was already one there. * @param pos Position for error reporting. * @param sym The symbol. * @param s The scope. */ private void enterSynthetic(int pos, Symbol sym, Scope s) { if (sym.name != names.error && sym.name != names.empty) { for (Scope.Entry e = s.lookup(sym.name); e.scope == s; e = e.next()) { if (sym != e.sym && sym.kind == e.sym.kind) { if ((sym.kind & (MTH | VAR)) != 0 && !sym.type.erasure().equals(e.sym.type.erasure())) continue; duplicateError(pos, e.sym); break; } } } s.enter(sym); } /** * Look up a synthetic name in a given scope. * @param scope The scope. * @param name The name. */ private Symbol lookupSynthetic(Name name, Scope s) { Symbol sym = s.lookup(name).sym; return (sym == null || (sym.flags() & SYNTHETIC) == 0) ? null : sym; } /** * Access codes for dereferencing, assignment, * and pre/post increment/decrement. * Access codes for assignment operations are determined by method accessCode * below. * * All access codes for accesses to the current class are even. * If a member of the superclass should be accessed instead (because * access was via a qualified super), add one to the corresponding code * for the current class, making the number odd. * This numbering scheme is used by the backend to decide whether * to issue an invokevirtual or invokespecial call. * * @see Gen.visitSelect(Select tree) */ private static final int DEREFcode = 0; /** * Access codes for dereferencing, assignment, * and pre/post increment/decrement. * Access codes for assignment operations are determined by method accessCode * below. * * All access codes for accesses to the current class are even. * If a member of the superclass should be accessed instead (because * access was via a qualified super), add one to the corresponding code * for the current class, making the number odd. * This numbering scheme is used by the backend to decide whether * to issue an invokevirtual or invokespecial call. * * @see Gen.visitSelect(Select tree) */ private static final int ASSIGNcode = 2; /** * Access codes for dereferencing, assignment, * and pre/post increment/decrement. * Access codes for assignment operations are determined by method accessCode * below. * * All access codes for accesses to the current class are even. * If a member of the superclass should be accessed instead (because * access was via a qualified super), add one to the corresponding code * for the current class, making the number odd. * This numbering scheme is used by the backend to decide whether * to issue an invokevirtual or invokespecial call. * * @see Gen.visitSelect(Select tree) */ private static final int PREINCcode = 4; /** * Access codes for dereferencing, assignment, * and pre/post increment/decrement. * Access codes for assignment operations are determined by method accessCode * below. * * All access codes for accesses to the current class are even. * If a member of the superclass should be accessed instead (because * access was via a qualified super), add one to the corresponding code * for the current class, making the number odd. * This numbering scheme is used by the backend to decide whether * to issue an invokevirtual or invokespecial call. * * @see Gen.visitSelect(Select tree) */ private static final int PREDECcode = 6; /** * Access codes for dereferencing, assignment, * and pre/post increment/decrement. * Access codes for assignment operations are determined by method accessCode * below. * * All access codes for accesses to the current class are even. * If a member of the superclass should be accessed instead (because * access was via a qualified super), add one to the corresponding code * for the current class, making the number odd. * This numbering scheme is used by the backend to decide whether * to issue an invokevirtual or invokespecial call. * * @see Gen.visitSelect(Select tree) */ private static final int POSTINCcode = 8; /** * Access codes for dereferencing, assignment, * and pre/post increment/decrement. * Access codes for assignment operations are determined by method accessCode * below. * * All access codes for accesses to the current class are even. * If a member of the superclass should be accessed instead (because * access was via a qualified super), add one to the corresponding code * for the current class, making the number odd. * This numbering scheme is used by the backend to decide whether * to issue an invokevirtual or invokespecial call. * * @see Gen.visitSelect(Select tree) */ private static final int POSTDECcode = 10; /** * Access codes for dereferencing, assignment, * and pre/post increment/decrement. * Access codes for assignment operations are determined by method accessCode * below. * * All access codes for accesses to the current class are even. * If a member of the superclass should be accessed instead (because * access was via a qualified super), add one to the corresponding code * for the current class, making the number odd. * This numbering scheme is used by the backend to decide whether * to issue an invokevirtual or invokespecial call. * * @see Gen.visitSelect(Select tree) */ private static final int FIRSTASGOPcode = 12; /** * Number of access codes */ private static final int NCODES = accessCode(ByteCodes.lushrl) + 2; /** * A mapping from symbols to their access numbers. */ private Hashtable accessNums; /** * A mapping from symbols to an array of access symbols, indexed by * access code. */ private Hashtable accessSyms; /** * A mapping from (constructor) symbols to access constructor symbols. */ private Hashtable accessConstrs; /** * A queue for all accessed symbols. */ private ListBuffer accessed; /** * Map bytecode of binary operation to access code of corresponding * assignment operation. This is always an even number. */ private static int accessCode(int bytecode) { if (ByteCodes.iadd <= bytecode && bytecode <= ByteCodes.lxor) return (bytecode - iadd) * 2 + FIRSTASGOPcode; else if (bytecode == ByteCodes.string_add) return (ByteCodes.lxor + 1 - iadd) * 2 + FIRSTASGOPcode; else if (ByteCodes.ishll <= bytecode && bytecode <= ByteCodes.lushrl) return (bytecode - ishll + ByteCodes.lxor + 2 - iadd) * 2 + FIRSTASGOPcode; else return -1; } /** * return access code for identifier, * @param tree The tree representing the identifier use. * @param enclOp The closest enclosing operation node of tree, * null if tree is not a subtree of an operation. */ private static int accessCode(Tree tree, Tree enclOp) { if (enclOp == null) return DEREFcode; else if (enclOp.tag == Tree.ASSIGN && tree == TreeInfo.skipParens(((Assign) enclOp).lhs)) return ASSIGNcode; else if (Tree.PREINC <= enclOp.tag && enclOp.tag <= Tree.POSTDEC && tree == TreeInfo.skipParens(((Unary) enclOp).arg)) return (enclOp.tag - Tree.PREINC) * 2 + PREINCcode; else if (Tree.BITOR_ASG <= enclOp.tag && enclOp.tag <= Tree.MOD_ASG && tree == TreeInfo.skipParens(((Assignop) enclOp).lhs)) return accessCode(((OperatorSymbol)((Assignop) enclOp).operator).opcode); else return DEREFcode; } /** * Return binary operator that corresponds to given access code. */ private OperatorSymbol binaryAccessOperator(int acode) { for (Scope.Entry e = syms.predefClass.members().elems; e != null; e = e.sibling) { if (e.sym instanceof OperatorSymbol) { OperatorSymbol op = (OperatorSymbol) e.sym; if (accessCode(op.opcode) == acode) return op; } } return null; } /** * Return tree tag for assignment operation corresponding * to given binary operator. */ private static int treeTag(OperatorSymbol operator) { switch (operator.opcode) { case ByteCodes.ior: case ByteCodes.lor: return Tree.BITOR_ASG; case ByteCodes.ixor: case ByteCodes.lxor: return Tree.BITXOR_ASG; case ByteCodes.iand: case ByteCodes.land: return Tree.BITAND_ASG; case ByteCodes.ishl: case ByteCodes.lshl: case ByteCodes.ishll: case ByteCodes.lshll: return Tree.SL_ASG; case ByteCodes.ishr: case ByteCodes.lshr: case ByteCodes.ishrl: case ByteCodes.lshrl: return Tree.SR_ASG; case ByteCodes.iushr: case ByteCodes.lushr: case ByteCodes.iushrl: case ByteCodes.lushrl: return Tree.USR_ASG; case ByteCodes.iadd: case ByteCodes.ladd: case ByteCodes.fadd: case ByteCodes.dadd: case ByteCodes.string_add: return Tree.PLUS_ASG; case ByteCodes.isub: case ByteCodes.lsub: case ByteCodes.fsub: case ByteCodes.dsub: return Tree.MINUS_ASG; case ByteCodes.imul: case ByteCodes.lmul: case ByteCodes.fmul: case ByteCodes.dmul: return Tree.MUL_ASG; case ByteCodes.idiv: case ByteCodes.ldiv: case ByteCodes.fdiv: case ByteCodes.ddiv: return Tree.DIV_ASG; case ByteCodes.imod: case ByteCodes.lmod: case ByteCodes.fmod: case ByteCodes.dmod: return Tree.MOD_ASG; default:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -