Dotty Documentation


final class BCodeAsmCommon [ I ]
extends Object

This trait contains code shared between GenBCode and GenASM that depends on types defined in the compiler cake (Global).

[-] Constructors

BCodeAsmCommon ( interface: I )

[-] Members

[+] case class EnclosingMethodEntry
[+] val interface : I
[+] private def enclosingClassForEnclosingMethodAttribute ( classSym: Symbol ) : Symbol

The enclosing class for emitting the EnclosingMethod attribute. Since this is a source-level property, this method looks at the originalOwner chain. See doc in BTypes.

[+] def enclosingMethodAttribute ( classSym: Symbol , classDesc: Symbol => String , methodDesc: Symbol => String ) : Option [ EnclosingMethodEntry ]

Data for emitting an EnclosingMethod attribute. None if classSym is a member class (not an anonymous or local class). See doc in BTypes.

The class is parametrized by two functions to obtain a bytecode class descriptor for a class symbol, and to obtain a method signature descriptor fro a method symbol. These function depend on the implementation of GenASM / GenBCode, so they need to be passed in.

[+] private def enclosingMethodForEnclosingMethodAttribute ( classSym: Symbol ) : Option [ Symbol ]

Returns the enclosing method for non-member classes. In the following example

class A { def f = { class B { class C } } }

the method returns Some(f) for B, but None for C, because C is a member class. For non-member classes that are not enclosed by a method, it returns None:

class A { { class B } }

In this case, for B, we return None.

The EnclosingMethod attribute needs to be added to non-member classes (see doc in BTypes). This is a source-level property, so we need to use the originalOwner chain to reconstruct it.

[+] def isAnonymousOrLocalClass ( classSym: Symbol ) : Boolean

True if classSym is an anonymous class or a local class. I.e., false if classSym is a member class. This method is used to decide if we should emit an EnclosingMethod attribute. It is also used to decide whether the "owner" field in the InnerClass attribute should be null.