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, ParentCodegenAware

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


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jetbrains.jet.codegen.context.LocalLookup
LocalLookup.LocalLookupCase
 
Field Summary
 CallGenerator defaultCallGenerator
           
 org.jetbrains.org.objectweb.asm.commons.InstructionAdapter v
           
 
Constructor Summary
ExpressionCodegen(org.jetbrains.org.objectweb.asm.MethodVisitor v, FrameMap myMap, org.jetbrains.org.objectweb.asm.Type returnType, MethodContext context, GenerationState state, MemberCodegen<?> parentCodegen)
           
 
Method Summary
protected  FunctionDescriptor accessibleFunctionDescriptor(FunctionDescriptor fd)
           
 org.jetbrains.org.objectweb.asm.Type expressionType(JetExpression expression)
           
 StackValue findLocalOrCapturedValue(DeclarationDescriptor descriptor)
           
 StackValue gen(JetElement expr)
           
 void gen(JetElement expr, org.jetbrains.org.objectweb.asm.Type type)
           
 void generateFromResolvedCall(ReceiverValue descriptor, org.jetbrains.org.objectweb.asm.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()
           
static CompileTimeConstant getCompileTimeConstant(JetExpression expression, BindingContext bindingContext)
           
 MethodContext getContext()
           
 FrameMap getFrameMap()
           
 NameGenerator getInlineNameGenerator()
           
 MemberCodegen<?> getParentCodegen()
           
 GenerationState getState()
           
 int indexOfLocal(JetReferenceExpression lhs)
           
 org.jetbrains.jet.codegen.StackValue.Property intermediateValueForProperty(PropertyDescriptor propertyDescriptor, boolean forceField, JetSuperExpression superExpression)
           
 org.jetbrains.jet.codegen.StackValue.Property intermediateValueForProperty(PropertyDescriptor propertyDescriptor, boolean forceField, JetSuperExpression superExpression, MethodKind methodKind)
           
 void invokeAppend(JetExpression expr)
           
 StackValue invokeFunction(Call call, StackValue receiver, ResolvedCall<?> resolvedCall)
           
 void invokeMethodWithArguments(Call call, CallableMethod callableMethod, ResolvedCall<?> resolvedCall, StackValue receiver)
           
 boolean lookupLocal(DeclarationDescriptor descriptor)
           
 int lookupLocalIndex(DeclarationDescriptor descriptor)
           
 void pushClosureOnStack(CalculatedClosure closure, boolean ignoreThisAndReceiver, CallGenerator callGenerator)
           
 int pushMethodArgumentsWithCallReceiver(StackValue receiver, ResolvedCall<?> resolvedCall, CallableMethod callableMethod, boolean skipLast, CallGenerator callGenerator)
           
 int pushMethodArgumentsWithoutCallReceiver(ResolvedCall<?> resolvedCall, java.util.List<org.jetbrains.org.objectweb.asm.Type> valueParameterTypes, boolean skipLast, CallGenerator callGenerator)
           
 ResolvedCall<?> resolvedCall(JetExpression expression)
           
 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 unused)
           
 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, visitImportDirective, visitImportList, visitInitializerList, visitJetElement, visitJetFile, visitLabelQualifiedExpression, visitLiteralStringTemplateEntry, visitLoopExpression, visitModifierList, visitMultiDeclarationEntry, visitNamedDeclaration, visitNullableType, visitObjectDeclarationName, visitPackageDirective, visitParameter, visitParameterList, visitPropertyAccessor, visitPropertyDelegate, visitQualifiedExpression, visitReferenceExpression, visitRootPackageExpression, visitScript, visitSelfType, visitSimpleNameStringTemplateEntry, visitStringTemplateEntry, visitStringTemplateEntryWithExpression, visitTypeArgumentList, visitTypeConstraint, visitTypeConstraintList, visitTypedef, visitTypeParameter, visitTypeParameterList, visitTypeProjection, visitTypeReference, visitUnaryExpression, visitUserType, visitValueArgumentList, visitWhenConditionInRange, visitWhenConditionIsPattern, visitWhenConditionWithExpression, 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

v

public final org.jetbrains.org.objectweb.asm.commons.InstructionAdapter v

defaultCallGenerator

public final CallGenerator defaultCallGenerator
Constructor Detail

ExpressionCodegen

public ExpressionCodegen(@NotNull
                         org.jetbrains.org.objectweb.asm.MethodVisitor v,
                         @NotNull
                         FrameMap myMap,
                         @NotNull
                         org.jetbrains.org.objectweb.asm.Type returnType,
                         @NotNull
                         MethodContext context,
                         @NotNull
                         GenerationState state,
                         @Nullable
                         MemberCodegen<?> parentCodegen)
Method Detail

generateObjectLiteral

public CalculatedClosure generateObjectLiteral(GenerationState state,
                                               JetObjectLiteralExpression literal)

getState

public GenerationState getState()

getBindingContext

public BindingContext getBindingContext()

getParentCodegen

@Nullable
public MemberCodegen<?> getParentCodegen()
Specified by:
getParentCodegen in interface ParentCodegenAware

genQualified

public StackValue genQualified(StackValue receiver,
                               JetElement selector)

gen

public StackValue gen(JetElement expr)

gen

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

genToJVMStack

public void genToJVMStack(JetExpression expr)

visitClass

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

visitObjectDeclaration

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

visitExpression

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

visitSuperExpression

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

expressionType

@NotNull
public org.jetbrains.org.objectweb.asm.Type expressionType(JetExpression expression)

resolvedCall

@NotNull
public ResolvedCall<?> resolvedCall(JetExpression expression)

visitParenthesizedExpression

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

visitAnnotatedExpression

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

visitIfExpression

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

visitWhileExpression

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

visitDoWhileExpression

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

visitForExpression

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

visitBreakExpression

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

visitContinueExpression

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

visitConstantExpression

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

getCompileTimeConstant

@Nullable
public static CompileTimeConstant getCompileTimeConstant(@NotNull
                                                                  JetExpression expression,
                                                                  @NotNull
                                                                  BindingContext bindingContext)

visitStringTemplateExpression

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

visitBlockExpression

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

visitNamedFunction

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

visitFunctionLiteralExpression

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

visitObjectLiteralExpression

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

pushClosureOnStack

public void pushClosureOnStack(@Nullable
                               CalculatedClosure closure,
                               boolean ignoreThisAndReceiver,
                               @NotNull
                               CallGenerator callGenerator)

visitReturnExpression

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

returnExpression

public void returnExpression(JetExpression expr)

visitSimpleNameExpression

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

findLocalOrCapturedValue

@Nullable
public StackValue findLocalOrCapturedValue(@NotNull
                                                    DeclarationDescriptor descriptor)

lookupLocal

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

lookupLocalIndex

public int lookupLocalIndex(DeclarationDescriptor descriptor)

intermediateValueForProperty

@NotNull
public org.jetbrains.jet.codegen.StackValue.Property intermediateValueForProperty(@NotNull
                                                                                          PropertyDescriptor propertyDescriptor,
                                                                                          boolean forceField,
                                                                                          @Nullable
                                                                                          JetSuperExpression superExpression)

intermediateValueForProperty

public org.jetbrains.jet.codegen.StackValue.Property intermediateValueForProperty(@NotNull
                                                                                  PropertyDescriptor propertyDescriptor,
                                                                                  boolean forceField,
                                                                                  @Nullable
                                                                                  JetSuperExpression superExpression,
                                                                                  @NotNull
                                                                                  MethodKind methodKind)

visitCallExpression

public StackValue visitCallExpression(@NotNull
                                      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<?> resolvedCall)

invokeMethodWithArguments

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

generateFromResolvedCall

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

generateThisOrOuter

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

pushMethodArgumentsWithCallReceiver

public int pushMethodArgumentsWithCallReceiver(@Nullable
                                               StackValue receiver,
                                               @NotNull
                                               ResolvedCall<?> resolvedCall,
                                               @NotNull
                                               CallableMethod callableMethod,
                                               boolean skipLast,
                                               @NotNull
                                               CallGenerator callGenerator)

pushMethodArgumentsWithoutCallReceiver

public int pushMethodArgumentsWithoutCallReceiver(@NotNull
                                                  ResolvedCall<?> resolvedCall,
                                                  java.util.List<org.jetbrains.org.objectweb.asm.Type> valueParameterTypes,
                                                  boolean skipLast,
                                                  @NotNull
                                                  CallGenerator callGenerator)

genVarargs

public void genVarargs(ValueParameterDescriptor valueParameterDescriptor,
                       VarargValueArgument valueArgument)

indexOfLocal

public int indexOfLocal(JetReferenceExpression lhs)

visitCallableReferenceExpression

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

visitDotQualifiedExpression

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

visitSafeQualifiedExpression

public StackValue visitSafeQualifiedExpression(@NotNull
                                               JetSafeQualifiedExpression expression,
                                               StackValue unused)
Overrides:
visitSafeQualifiedExpression in class JetVisitor<StackValue,StackValue>

visitBinaryExpression

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

invokeAppend

public void invokeAppend(JetExpression expr)

visitPrefixExpression

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

visitPostfixExpression

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

visitProperty

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

visitMultiDeclaration

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

generateNewArray

public void generateNewArray(@NotNull
                             JetCallExpression expression)

visitArrayAccessExpression

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

visitThrowExpression

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

visitThisExpression

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

visitTryExpression

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

generateTryExpression

public StackValue generateTryExpression(JetTryExpression expression,
                                        boolean isStatement)

visitBinaryWithTypeRHSExpression

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

visitIsExpression

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

visitWhenExpression

public StackValue visitWhenExpression(@NotNull
                                      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

getFrameMap

@NotNull
public FrameMap getFrameMap()

getContext

@NotNull
public MethodContext getContext()

getInlineNameGenerator

@NotNull
public NameGenerator getInlineNameGenerator()