Minor refactoring in CodegenAnnotatingVisitor
Create a private helper method
This commit is contained in:
+20
-11
@@ -176,11 +176,11 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
|
|||||||
ClassDescriptor classDescriptor = bindingContext.get(CLASS, classObject.getObjectDeclaration());
|
ClassDescriptor classDescriptor = bindingContext.get(CLASS, classObject.getObjectDeclaration());
|
||||||
assert classDescriptor != null;
|
assert classDescriptor != null;
|
||||||
|
|
||||||
JvmClassName name = JvmClassName.byInternalName(peekFromStack(nameStack) + JvmAbi.CLASS_OBJECT_SUFFIX);
|
String name = peekFromStack(nameStack) + JvmAbi.CLASS_OBJECT_SUFFIX;
|
||||||
recordClosure(bindingTrace, classObject, classDescriptor, peekFromStack(classStack), name, false);
|
recordClosure(classObject, classDescriptor, name, false);
|
||||||
|
|
||||||
classStack.push(classDescriptor);
|
classStack.push(classDescriptor);
|
||||||
nameStack.push(name.getInternalName());
|
nameStack.push(name);
|
||||||
super.visitClassObject(classObject);
|
super.visitClassObject(classObject);
|
||||||
nameStack.pop();
|
nameStack.pop();
|
||||||
classStack.pop();
|
classStack.pop();
|
||||||
@@ -197,7 +197,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
|
|||||||
if (classDescriptor == null) return;
|
if (classDescriptor == null) return;
|
||||||
|
|
||||||
String name = getName(classDescriptor);
|
String name = getName(classDescriptor);
|
||||||
recordClosure(bindingTrace, declaration, classDescriptor, peekFromStack(classStack), JvmClassName.byInternalName(name), false);
|
recordClosure(declaration, classDescriptor, name, false);
|
||||||
|
|
||||||
classStack.push(classDescriptor);
|
classStack.push(classDescriptor);
|
||||||
nameStack.push(name);
|
nameStack.push(name);
|
||||||
@@ -214,7 +214,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
|
|||||||
if (classDescriptor == null) return;
|
if (classDescriptor == null) return;
|
||||||
|
|
||||||
String name = getName(classDescriptor);
|
String name = getName(classDescriptor);
|
||||||
recordClosure(bindingTrace, klass, classDescriptor, peekFromStack(classStack), JvmClassName.byInternalName(name), false);
|
recordClosure(klass, classDescriptor, name, false);
|
||||||
|
|
||||||
classStack.push(classDescriptor);
|
classStack.push(classDescriptor);
|
||||||
nameStack.push(name);
|
nameStack.push(name);
|
||||||
@@ -239,7 +239,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String name = inventAnonymousClassName(expression.getObjectDeclaration());
|
String name = inventAnonymousClassName(expression.getObjectDeclaration());
|
||||||
recordClosure(bindingTrace, expression.getObjectDeclaration(), classDescriptor, peekFromStack(classStack), JvmClassName.byInternalName(name), false);
|
recordClosure(expression.getObjectDeclaration(), classDescriptor, name, false);
|
||||||
|
|
||||||
classStack.push(classDescriptor);
|
classStack.push(classDescriptor);
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
@@ -259,7 +259,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
|
|||||||
|
|
||||||
String name = inventAnonymousClassName(expression);
|
String name = inventAnonymousClassName(expression);
|
||||||
ClassDescriptor classDescriptor = recordClassForFunction(functionDescriptor);
|
ClassDescriptor classDescriptor = recordClassForFunction(functionDescriptor);
|
||||||
recordClosure(bindingTrace, functionLiteral, classDescriptor, peekFromStack(classStack), JvmClassName.byInternalName(name), true);
|
recordClosure(functionLiteral, classDescriptor, name, true);
|
||||||
|
|
||||||
classStack.push(classDescriptor);
|
classStack.push(classDescriptor);
|
||||||
nameStack.push(name);
|
nameStack.push(name);
|
||||||
@@ -276,7 +276,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
|
|||||||
|
|
||||||
String name = inventAnonymousClassName(expression);
|
String name = inventAnonymousClassName(expression);
|
||||||
ClassDescriptor classDescriptor = recordClassForFunction(functionDescriptor);
|
ClassDescriptor classDescriptor = recordClassForFunction(functionDescriptor);
|
||||||
recordClosure(bindingTrace, expression, classDescriptor, peekFromStack(classStack), JvmClassName.byInternalName(name), true);
|
recordClosure(expression, classDescriptor, name, true);
|
||||||
|
|
||||||
classStack.push(classDescriptor);
|
classStack.push(classDescriptor);
|
||||||
nameStack.push(name);
|
nameStack.push(name);
|
||||||
@@ -285,6 +285,16 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
|
|||||||
classStack.pop();
|
classStack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void recordClosure(
|
||||||
|
@NotNull JetElement element,
|
||||||
|
@NotNull ClassDescriptor classDescriptor,
|
||||||
|
@NotNull String name,
|
||||||
|
boolean functionLiteral
|
||||||
|
) {
|
||||||
|
CodegenBinding.recordClosure(bindingTrace, element, classDescriptor, peekFromStack(classStack),
|
||||||
|
JvmClassName.byInternalName(name), functionLiteral);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitProperty(JetProperty property) {
|
public void visitProperty(JetProperty property) {
|
||||||
DeclarationDescriptor propertyDescriptor = bindingContext.get(DECLARATION_TO_DESCRIPTOR, property);
|
DeclarationDescriptor propertyDescriptor = bindingContext.get(DECLARATION_TO_DESCRIPTOR, property);
|
||||||
@@ -304,8 +314,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitNamedFunction(JetNamedFunction function) {
|
public void visitNamedFunction(JetNamedFunction function) {
|
||||||
FunctionDescriptor functionDescriptor =
|
FunctionDescriptor functionDescriptor = (FunctionDescriptor) bindingContext.get(DECLARATION_TO_DESCRIPTOR, function);
|
||||||
(FunctionDescriptor) bindingContext.get(DECLARATION_TO_DESCRIPTOR, function);
|
|
||||||
// working around a problem with shallow analysis
|
// working around a problem with shallow analysis
|
||||||
if (functionDescriptor == null) return;
|
if (functionDescriptor == null) return;
|
||||||
|
|
||||||
@@ -318,7 +327,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
|
|||||||
else {
|
else {
|
||||||
String name = inventAnonymousClassName(function);
|
String name = inventAnonymousClassName(function);
|
||||||
ClassDescriptor classDescriptor = recordClassForFunction(functionDescriptor);
|
ClassDescriptor classDescriptor = recordClassForFunction(functionDescriptor);
|
||||||
recordClosure(bindingTrace, function, classDescriptor, peekFromStack(classStack), JvmClassName.byInternalName(name), true);
|
recordClosure(function, classDescriptor, name, true);
|
||||||
|
|
||||||
classStack.push(classDescriptor);
|
classStack.push(classDescriptor);
|
||||||
nameStack.push(name);
|
nameStack.push(name);
|
||||||
|
|||||||
Reference in New Issue
Block a user