org.jetbrains.jet.codegen
Class ExpressionCodegen

java.lang.Object
  extended by com.intellij.psi.PsiElementVisitor
      extended by org.jetbrains.jet.lang.psi.JetVisitor<StackValue,StackValue>
          extended by org.jetbrains.jet.codegen.ExpressionCodegen
All Implemented Interfaces:
LocalLookup

public class ExpressionCodegen
extends JetVisitor<StackValue,StackValue>
implements LocalLookup


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jetbrains.jet.codegen.context.LocalLookup
LocalLookup.LocalLookupCase
 
Field Summary
static java.util.Set<DeclarationDescriptor> INTEGRAL_RANGES
           
 
Constructor Summary
ExpressionCodegen(org.jetbrains.asm4.MethodVisitor v, FrameMap myMap, org.jetbrains.asm4.Type returnType, MethodContext context, GenerationState state)
           
 
Method Summary
protected  FunctionDescriptor accessibleFunctionDescriptor(FunctionDescriptor fd)
           
protected  org.jetbrains.asm4.commons.InstructionAdapter createInstructionAdapter(org.jetbrains.asm4.MethodVisitor mv)
           
 org.jetbrains.asm4.Type expressionType(JetExpression expr)
           
 StackValue gen(JetElement expr)
           
 void gen(JetElement expr, org.jetbrains.asm4.Type type)
           
 void generateFromResolvedCall(ReceiverValue descriptor, org.jetbrains.asm4.Type type)
           
 void generateNewArray(JetCallExpression expression)
           
 CalculatedClosure generateObjectLiteral(GenerationState state, JetObjectLiteralExpression literal)
           
 StackValue generateThisOrOuter(ClassDescriptor calleeContainingClass, boolean isSuper)
           
 StackValue generateTryExpression(JetTryExpression expression, boolean isStatement)
           
 StackValue generateWhenExpression(JetWhenExpression expression, boolean isStatement)
           
 StackValue genQualified(StackValue receiver, JetElement selector)
           
 void genToJVMStack(JetExpression expr)
           
 void genVarargs(ValueParameterDescriptor valueParameterDescriptor, VarargValueArgument valueArgument)
           
 BindingContext getBindingContext()
           
 java.util.Collection<java.lang.String> getLocalVariableNamesForExpression()
           
 GenerationState getState()
           
 int indexOfLocal(JetReferenceExpression lhs)
           
 StackValue intermediateValueForProperty(PropertyDescriptor propertyDescriptor, boolean forceField, JetSuperExpression superExpression)
           
 StackValue.StackValueWithSimpleReceiver intermediateValueForProperty(PropertyDescriptor propertyDescriptor, boolean forceField, JetSuperExpression superExpression, MethodKind methodKind)
           
 void invokeAppend(JetExpression expr)
           
 StackValue invokeFunction(Call call, StackValue receiver, ResolvedCall<? extends CallableDescriptor> resolvedCall)
           
 void invokeMethodWithArguments(CallableMethod callableMethod, ResolvedCall<? extends CallableDescriptor> resolvedCall, Call callToGenerateCallee, StackValue receiver)
           
 boolean lookupLocal(DeclarationDescriptor descriptor)
           
 int lookupLocalIndex(DeclarationDescriptor descriptor)
           
protected  void pushClosureOnStack(CalculatedClosure closure, boolean ignoreThisAndReceiver)
           
 int pushMethodArguments(JetCallElement expression, java.util.List<org.jetbrains.asm4.Type> valueParameterTypes)
           
 void returnExpression(JetExpression expr)
           
 java.lang.String toString()
           
 StackValue visitAnnotatedExpression(JetAnnotatedExpression expression, StackValue receiver)
           
 StackValue visitArrayAccessExpression(JetArrayAccessExpression expression, StackValue receiver)
           
 StackValue visitBinaryExpression(JetBinaryExpression expression, StackValue receiver)
           
 StackValue visitBinaryWithTypeRHSExpression(JetBinaryExpressionWithTypeRHS expression, StackValue receiver)
           
 StackValue visitBlockExpression(JetBlockExpression expression, StackValue receiver)
           
 StackValue visitBreakExpression(JetBreakExpression expression, StackValue receiver)
           
 StackValue visitCallableReferenceExpression(JetCallableReferenceExpression expression, StackValue data)
           
 StackValue visitCallExpression(JetCallExpression expression, StackValue receiver)
           
 StackValue visitClass(JetClass klass, StackValue data)
           
 StackValue visitConstantExpression(JetConstantExpression expression, StackValue receiver)
           
 StackValue visitContinueExpression(JetContinueExpression expression, StackValue receiver)
           
 StackValue visitDotQualifiedExpression(JetDotQualifiedExpression expression, StackValue receiver)
           
 StackValue visitDoWhileExpression(JetDoWhileExpression expression, StackValue receiver)
           
 StackValue visitExpression(JetExpression expression, StackValue receiver)
           
 StackValue visitForExpression(JetForExpression forExpression, StackValue receiver)
           
 StackValue visitFunctionLiteralExpression(JetFunctionLiteralExpression expression, StackValue receiver)
           
 StackValue visitIfExpression(JetIfExpression expression, StackValue receiver)
           
 StackValue visitIsExpression(JetIsExpression expression, StackValue receiver)
           
 StackValue visitMultiDeclaration(JetMultiDeclaration multiDeclaration, StackValue receiver)
           
 StackValue visitNamedFunction(JetNamedFunction function, StackValue data)
           
 StackValue visitObjectDeclaration(JetObjectDeclaration declaration, StackValue data)
           
 StackValue visitObjectLiteralExpression(JetObjectLiteralExpression expression, StackValue receiver)
           
 StackValue visitParenthesizedExpression(JetParenthesizedExpression expression, StackValue receiver)
           
 StackValue visitPostfixExpression(JetPostfixExpression expression, StackValue receiver)
           
 StackValue visitPrefixExpression(JetPrefixExpression expression, StackValue receiver)
           
 StackValue visitProperty(JetProperty property, StackValue receiver)
           
 StackValue visitReturnExpression(JetReturnExpression expression, StackValue receiver)
           
 StackValue visitSafeQualifiedExpression(JetSafeQualifiedExpression expression, StackValue receiver)
           
 StackValue visitSimpleNameExpression(JetSimpleNameExpression expression, StackValue receiver)
           
 StackValue visitStringTemplateExpression(JetStringTemplateExpression expression, StackValue receiver)
           
 StackValue visitSuperExpression(JetSuperExpression expression, StackValue data)
           
 StackValue visitThisExpression(JetThisExpression expression, StackValue receiver)
           
 StackValue visitThrowExpression(JetThrowExpression expression, StackValue receiver)
           
 StackValue visitTryExpression(JetTryExpression expression, StackValue receiver)
           
 StackValue visitWhenExpression(JetWhenExpression expression, StackValue receiver)
           
 StackValue visitWhileExpression(JetWhileExpression expression, StackValue receiver)
           
 
Methods inherited from class org.jetbrains.jet.lang.psi.JetVisitor
visitAnnotation, visitAnnotationEntry, visitAnonymousInitializer, visitArgument, visitBlockStringTemplateEntry, visitCatchSection, visitClassBody, visitClassObject, visitDeclaration, visitDelegationByExpressionSpecifier, visitDelegationSpecifier, visitDelegationSpecifierList, visitDelegationToSuperCallSpecifier, visitDelegationToSuperClassSpecifier, visitDelegationToThisCall, visitEnumEntry, visitEscapeStringTemplateEntry, visitFinallySection, visitFunctionType, visitIdeTemplate, visitImportDirective, visitInitializerList, visitJetElement, visitJetFile, visitLabelQualifiedExpression, visitLiteralStringTemplateEntry, visitLoopExpression, visitModifierList, visitMultiDeclarationEntry, visitNamedDeclaration, visitNullableType, visitObjectDeclarationName, visitParameter, visitParameterList, visitPropertyAccessor, visitPropertyDelegate, visitQualifiedExpression, visitReferenceExpression, visitRootNamespaceExpression, visitScript, visitSelfType, visitSimpleNameStringTemplateEntry, visitStringTemplateEntry, visitStringTemplateEntryWithExpression, visitTypeArgumentList, visitTypeConstraint, visitTypeConstraintList, visitTypedef, visitTypeParameter, visitTypeParameterList, visitTypeProjection, visitTypeReference, visitUnaryExpression, visitUserType, visitValueArgumentList, visitWhenConditionExpression, visitWhenConditionInRange, visitWhenConditionIsPattern, visitWhenEntry
 
Methods inherited from class com.intellij.psi.PsiElementVisitor
visitBinaryFile, visitComment, visitDirectory, visitElement, visitErrorElement, visitFile, visitOuterLanguageElement, visitPlainText, visitPlainTextFile, visitWhiteSpace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INTEGRAL_RANGES

public static final java.util.Set<DeclarationDescriptor> INTEGRAL_RANGES
Constructor Detail

ExpressionCodegen

public ExpressionCodegen(@NotNull
                         org.jetbrains.asm4.MethodVisitor v,
                         @NotNull
                         FrameMap myMap,
                         @NotNull
                         org.jetbrains.asm4.Type returnType,
                         @NotNull
                         MethodContext context,
                         @NotNull
                         GenerationState state)
Method Detail

generateObjectLiteral

public CalculatedClosure generateObjectLiteral(GenerationState state,
                                               JetObjectLiteralExpression literal)

createInstructionAdapter

protected org.jetbrains.asm4.commons.InstructionAdapter createInstructionAdapter(org.jetbrains.asm4.MethodVisitor mv)

getState

public GenerationState getState()

getBindingContext

public BindingContext getBindingContext()

getLocalVariableNamesForExpression

public java.util.Collection<java.lang.String> getLocalVariableNamesForExpression()

genQualified

public StackValue genQualified(StackValue receiver,
                               JetElement selector)

gen

public StackValue gen(JetElement expr)

gen

public void gen(JetElement expr,
                org.jetbrains.asm4.Type type)

genToJVMStack

public void genToJVMStack(JetExpression expr)

visitClass

public StackValue visitClass(JetClass klass,
                             StackValue data)
Overrides:
visitClass in class JetVisitor<StackValue,StackValue>

visitObjectDeclaration

public StackValue visitObjectDeclaration(JetObjectDeclaration declaration,
                                         StackValue data)
Overrides:
visitObjectDeclaration in class JetVisitor<StackValue,StackValue>

visitExpression

public StackValue visitExpression(JetExpression expression,
                                  StackValue receiver)
Overrides:
visitExpression in class JetVisitor<StackValue,StackValue>

visitSuperExpression

public StackValue visitSuperExpression(JetSuperExpression expression,
                                       StackValue data)
Overrides:
visitSuperExpression in class JetVisitor<StackValue,StackValue>

visitParenthesizedExpression

public StackValue visitParenthesizedExpression(JetParenthesizedExpression expression,
                                               StackValue receiver)
Overrides:
visitParenthesizedExpression in class JetVisitor<StackValue,StackValue>

visitAnnotatedExpression

public StackValue visitAnnotatedExpression(JetAnnotatedExpression expression,
                                           StackValue receiver)
Overrides:
visitAnnotatedExpression in class JetVisitor<StackValue,StackValue>

visitIfExpression

public StackValue visitIfExpression(JetIfExpression expression,
                                    StackValue receiver)
Overrides:
visitIfExpression in class JetVisitor<StackValue,StackValue>

visitWhileExpression

public StackValue visitWhileExpression(JetWhileExpression expression,
                                       StackValue receiver)
Overrides:
visitWhileExpression in class JetVisitor<StackValue,StackValue>

visitDoWhileExpression

public StackValue visitDoWhileExpression(JetDoWhileExpression expression,
                                         StackValue receiver)
Overrides:
visitDoWhileExpression in class JetVisitor<StackValue,StackValue>

visitForExpression

public StackValue visitForExpression(JetForExpression forExpression,
                                     StackValue receiver)
Overrides:
visitForExpression in class JetVisitor<StackValue,StackValue>

visitBreakExpression

public StackValue visitBreakExpression(JetBreakExpression expression,
                                       StackValue receiver)
Overrides:
visitBreakExpression in class JetVisitor<StackValue,StackValue>

visitContinueExpression

public StackValue visitContinueExpression(JetContinueExpression expression,
                                          StackValue receiver)
Overrides:
visitContinueExpression in class JetVisitor<StackValue,StackValue>

visitConstantExpression

public StackValue visitConstantExpression(JetConstantExpression expression,
                                          StackValue receiver)
Overrides:
visitConstantExpression in class JetVisitor<StackValue,StackValue>

visitStringTemplateExpression

public StackValue visitStringTemplateExpression(JetStringTemplateExpression expression,
                                                StackValue receiver)
Overrides:
visitStringTemplateExpression in class JetVisitor<StackValue,StackValue>

visitBlockExpression

public StackValue visitBlockExpression(JetBlockExpression expression,
                                       StackValue receiver)
Overrides:
visitBlockExpression in class JetVisitor<StackValue,StackValue>

visitNamedFunction

public StackValue visitNamedFunction(JetNamedFunction function,
                                     StackValue data)
Overrides:
visitNamedFunction in class JetVisitor<StackValue,StackValue>

visitFunctionLiteralExpression

public StackValue visitFunctionLiteralExpression(JetFunctionLiteralExpression expression,
                                                 StackValue receiver)
Overrides:
visitFunctionLiteralExpression in class JetVisitor<StackValue,StackValue>

visitObjectLiteralExpression

public StackValue visitObjectLiteralExpression(JetObjectLiteralExpression expression,
                                               StackValue receiver)
Overrides:
visitObjectLiteralExpression in class JetVisitor<StackValue,StackValue>

pushClosureOnStack

protected void pushClosureOnStack(CalculatedClosure closure,
                                  boolean ignoreThisAndReceiver)

visitReturnExpression

public StackValue visitReturnExpression(JetReturnExpression expression,
                                        StackValue receiver)
Overrides:
visitReturnExpression in class JetVisitor<StackValue,StackValue>

returnExpression

public void returnExpression(JetExpression expr)

visitSimpleNameExpression

public StackValue visitSimpleNameExpression(JetSimpleNameExpression expression,
                                            StackValue receiver)
Overrides:
visitSimpleNameExpression in class JetVisitor<StackValue,StackValue>

lookupLocal

public boolean lookupLocal(DeclarationDescriptor descriptor)
Specified by:
lookupLocal in interface LocalLookup

lookupLocalIndex

public int lookupLocalIndex(DeclarationDescriptor descriptor)

intermediateValueForProperty

@NotNull
public StackValue intermediateValueForProperty(@NotNull
                                                       PropertyDescriptor propertyDescriptor,
                                                       boolean forceField,
                                                       @Nullable
                                                       JetSuperExpression superExpression)

intermediateValueForProperty

public StackValue.StackValueWithSimpleReceiver intermediateValueForProperty(@NotNull
                                                                            PropertyDescriptor propertyDescriptor,
                                                                            boolean forceField,
                                                                            @Nullable
                                                                            JetSuperExpression superExpression,
                                                                            @NotNull
                                                                            MethodKind methodKind)

visitCallExpression

public StackValue visitCallExpression(JetCallExpression expression,
                                      StackValue receiver)
Overrides:
visitCallExpression in class JetVisitor<StackValue,StackValue>

accessibleFunctionDescriptor

@NotNull
protected FunctionDescriptor accessibleFunctionDescriptor(FunctionDescriptor fd)

invokeFunction

@NotNull
public StackValue invokeFunction(Call call,
                                         StackValue receiver,
                                         ResolvedCall<? extends CallableDescriptor> resolvedCall)

invokeMethodWithArguments

public void invokeMethodWithArguments(@NotNull
                                      CallableMethod callableMethod,
                                      @NotNull
                                      ResolvedCall<? extends CallableDescriptor> resolvedCall,
                                      @Nullable
                                      Call callToGenerateCallee,
                                      @NotNull
                                      StackValue receiver)

generateFromResolvedCall

public void generateFromResolvedCall(@NotNull
                                     ReceiverValue descriptor,
                                     @NotNull
                                     org.jetbrains.asm4.Type type)

generateThisOrOuter

public StackValue generateThisOrOuter(@NotNull
                                      ClassDescriptor calleeContainingClass,
                                      boolean isSuper)

genVarargs

public void genVarargs(ValueParameterDescriptor valueParameterDescriptor,
                       VarargValueArgument valueArgument)

pushMethodArguments

public int pushMethodArguments(JetCallElement expression,
                               java.util.List<org.jetbrains.asm4.Type> valueParameterTypes)

expressionType

@NotNull
public org.jetbrains.asm4.Type expressionType(JetExpression expr)

indexOfLocal

public int indexOfLocal(JetReferenceExpression lhs)

visitCallableReferenceExpression

public StackValue visitCallableReferenceExpression(JetCallableReferenceExpression expression,
                                                   StackValue data)
Overrides:
visitCallableReferenceExpression in class JetVisitor<StackValue,StackValue>

visitDotQualifiedExpression

public StackValue visitDotQualifiedExpression(JetDotQualifiedExpression expression,
                                              StackValue receiver)
Overrides:
visitDotQualifiedExpression in class JetVisitor<StackValue,StackValue>

visitSafeQualifiedExpression

public StackValue visitSafeQualifiedExpression(JetSafeQualifiedExpression expression,
                                               StackValue receiver)
Overrides:
visitSafeQualifiedExpression in class JetVisitor<StackValue,StackValue>

visitBinaryExpression

public StackValue visitBinaryExpression(JetBinaryExpression expression,
                                        StackValue receiver)
Overrides:
visitBinaryExpression in class JetVisitor<StackValue,StackValue>

invokeAppend

public void invokeAppend(JetExpression expr)

visitPrefixExpression

public StackValue visitPrefixExpression(JetPrefixExpression expression,
                                        StackValue receiver)
Overrides:
visitPrefixExpression in class JetVisitor<StackValue,StackValue>

visitPostfixExpression

public StackValue visitPostfixExpression(JetPostfixExpression expression,
                                         StackValue receiver)
Overrides:
visitPostfixExpression in class JetVisitor<StackValue,StackValue>

visitProperty

public StackValue visitProperty(JetProperty property,
                                StackValue receiver)
Overrides:
visitProperty in class JetVisitor<StackValue,StackValue>

visitMultiDeclaration

public StackValue visitMultiDeclaration(JetMultiDeclaration multiDeclaration,
                                        StackValue receiver)
Overrides:
visitMultiDeclaration in class JetVisitor<StackValue,StackValue>

generateNewArray

public void generateNewArray(@NotNull
                             JetCallExpression expression)

visitArrayAccessExpression

public StackValue visitArrayAccessExpression(JetArrayAccessExpression expression,
                                             StackValue receiver)
Overrides:
visitArrayAccessExpression in class JetVisitor<StackValue,StackValue>

visitThrowExpression

public StackValue visitThrowExpression(JetThrowExpression expression,
                                       StackValue receiver)
Overrides:
visitThrowExpression in class JetVisitor<StackValue,StackValue>

visitThisExpression

public StackValue visitThisExpression(JetThisExpression expression,
                                      StackValue receiver)
Overrides:
visitThisExpression in class JetVisitor<StackValue,StackValue>

visitTryExpression

public StackValue visitTryExpression(JetTryExpression expression,
                                     StackValue receiver)
Overrides:
visitTryExpression in class JetVisitor<StackValue,StackValue>

generateTryExpression

public StackValue generateTryExpression(JetTryExpression expression,
                                        boolean isStatement)

visitBinaryWithTypeRHSExpression

public StackValue visitBinaryWithTypeRHSExpression(JetBinaryExpressionWithTypeRHS expression,
                                                   StackValue receiver)
Overrides:
visitBinaryWithTypeRHSExpression in class JetVisitor<StackValue,StackValue>

visitIsExpression

public StackValue visitIsExpression(JetIsExpression expression,
                                    StackValue receiver)
Overrides:
visitIsExpression in class JetVisitor<StackValue,StackValue>

visitWhenExpression

public StackValue visitWhenExpression(JetWhenExpression expression,
                                      StackValue receiver)
Overrides:
visitWhenExpression in class JetVisitor<StackValue,StackValue>

generateWhenExpression

public StackValue generateWhenExpression(JetWhenExpression expression,
                                         boolean isStatement)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object