org.jetbrains.kotlin.js.translate.context
Class TranslationContext

java.lang.Object
  extended by org.jetbrains.kotlin.js.translate.context.TranslationContext

public class TranslationContext
extends java.lang.Object

All the info about the state of the translation process.


Method Summary
 void addStatementsToCurrentBlockFrom(JsBlock block)
           
 void addStatementsToCurrentBlockFrom(TranslationContext context)
           
 void addStatementToCurrentBlock(JsStatement statement)
           
 AliasingContext aliasingContext()
           
 void associateExpressionToLazyValue(JsExpression expression, TemporaryConstVariable temporaryConstVariable)
           
 BindingContext bindingContext()
           
 BindingTrace bindingTrace()
           
 JsExpression cacheExpressionIfNeeded(JsExpression expression)
           
 TranslationContext contextWithScope(JsFunction fun)
           
 boolean currentBlockIsEmpty()
           
 JsName declarePropertyOrPropertyAccessorName(DeclarationDescriptor descriptor, java.lang.String name, boolean fresh)
           
 TemporaryVariable declareTemporary(JsExpression initExpression)
           
 void deferConstructorCall(ConstructorDescriptor constructor, java.util.List<JsExpression> invocationArgs)
           
 JsNameRef define(DeclarationDescriptor descriptor, JsExpression expression)
           
 JsExpression defineTemporary(JsExpression initExpression)
           
 DynamicContext dynamicContext()
           
 java.util.List<DeferredCallSite> endDeclaration()
           
 JsExpression getAliasForDescriptor(DeclarationDescriptor descriptor)
           
 JsExpression getArgumentForClosureConstructor(DeclarationDescriptor descriptor)
          Gets an expression to pass to a constructor of a closure function.
 java.util.List<DeclarationDescriptor> getClassOrConstructorClosure(MemberDescriptor classOrConstructor)
           
 JsConfig getConfig()
           
 JsBlock getCurrentBlock()
           
 DeclarationDescriptor getDeclarationDescriptor()
           
 DefinitionPlace getDefinitionPlace()
           
 JsExpression getDispatchReceiver(ReceiverParameterDescriptor descriptor)
           
 JsFunction getFunctionObject(CallableDescriptor descriptor)
           
 java.util.Map<java.lang.String,JsName> getImportedModules()
           
 JsExpression getModuleExpressionFor(DeclarationDescriptor descriptor)
           
 JsName getNameForDescriptor(DeclarationDescriptor descriptor)
           
 JsName getNameForElement(com.intellij.psi.PsiElement element)
           
 JsName getNameForPackage(FqName fqName)
           
 TemporaryConstVariable getOrDeclareTemporaryConstVariable(JsExpression expression)
           
 JsName getOuterClassReference(ClassDescriptor descriptor)
           
 JsNameRef getQualifiedReference(DeclarationDescriptor descriptor)
           
 JsNameRef getQualifiedReference(FqName packageFqName)
           
 JsExpression getQualifierForDescriptor(DeclarationDescriptor descriptor)
           
 JsScope getScopeForDescriptor(DeclarationDescriptor descriptor)
           
 TranslationContext innerBlock()
           
 TranslationContext innerBlock(JsBlock block)
           
 TranslationContext innerContextWithAliased(DeclarationDescriptor correspondingDescriptor, JsExpression alias)
           
 TranslationContext innerContextWithAliasesForExpressions(java.util.Map<KtExpression,JsExpression> aliases)
           
 TranslationContext innerContextWithDescriptorsAliased(java.util.Map<DeclarationDescriptor,JsExpression> aliases)
           
 TranslationContext innerWithUsageTracker(JsScope scope, MemberDescriptor descriptor)
           
 Intrinsics intrinsics()
           
 void moveVarsFrom(TranslationContext context)
           
 Namer namer()
           
 TranslationContext newDeclaration(DeclarationDescriptor descriptor, DefinitionPlace place)
           
 TranslationContext newFunctionBody(JsFunction fun, AliasingContext aliasingContext, DeclarationDescriptor descriptor)
           
 TranslationContext newFunctionBodyWithUsageTracker(JsFunction fun, MemberDescriptor descriptor)
           
 JsProgram program()
           
 void putClassOrConstructorClosure(MemberDescriptor descriptor, java.util.List<DeclarationDescriptor> closure)
           
static TranslationContext rootContext(StaticContext staticContext, JsFunction rootFunction)
           
 JsScope scope()
           
 boolean shouldBeDeferred(ConstructorDescriptor constructor)
           
 void startDeclaration()
           
 UsageTracker usageTracker()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

rootContext

@NotNull
public static TranslationContext rootContext(@NotNull
                                                     StaticContext staticContext,
                                                     JsFunction rootFunction)

getImportedModules

@NotNull
public java.util.Map<java.lang.String,JsName> getImportedModules()

usageTracker

@Nullable
public UsageTracker usageTracker()

dynamicContext

@NotNull
public DynamicContext dynamicContext()

contextWithScope

@NotNull
public TranslationContext contextWithScope(@NotNull
                                                   JsFunction fun)

newFunctionBody

@NotNull
public TranslationContext newFunctionBody(@NotNull
                                                  JsFunction fun,
                                                  @Nullable
                                                  AliasingContext aliasingContext,
                                                  DeclarationDescriptor descriptor)

newFunctionBodyWithUsageTracker

@NotNull
public TranslationContext newFunctionBodyWithUsageTracker(@NotNull
                                                                  JsFunction fun,
                                                                  @NotNull
                                                                  MemberDescriptor descriptor)

innerWithUsageTracker

@NotNull
public TranslationContext innerWithUsageTracker(@NotNull
                                                        JsScope scope,
                                                        @NotNull
                                                        MemberDescriptor descriptor)

innerBlock

@NotNull
public TranslationContext innerBlock(@NotNull
                                             JsBlock block)

innerBlock

@NotNull
public TranslationContext innerBlock()

newDeclaration

@NotNull
public TranslationContext newDeclaration(@NotNull
                                                 DeclarationDescriptor descriptor,
                                                 @Nullable
                                                 DefinitionPlace place)

innerContextWithAliased

@NotNull
public TranslationContext innerContextWithAliased(@NotNull
                                                          DeclarationDescriptor correspondingDescriptor,
                                                          @NotNull
                                                          JsExpression alias)

innerContextWithAliasesForExpressions

@NotNull
public TranslationContext innerContextWithAliasesForExpressions(@NotNull
                                                                        java.util.Map<KtExpression,JsExpression> aliases)

innerContextWithDescriptorsAliased

@NotNull
public TranslationContext innerContextWithDescriptorsAliased(@NotNull
                                                                     java.util.Map<DeclarationDescriptor,JsExpression> aliases)

bindingContext

@NotNull
public BindingContext bindingContext()

bindingTrace

@NotNull
public BindingTrace bindingTrace()

getScopeForDescriptor

@NotNull
public JsScope getScopeForDescriptor(@NotNull
                                             DeclarationDescriptor descriptor)

getNameForElement

@NotNull
public JsName getNameForElement(@NotNull
                                        com.intellij.psi.PsiElement element)

getNameForDescriptor

@NotNull
public JsName getNameForDescriptor(@NotNull
                                           DeclarationDescriptor descriptor)

getNameForPackage

@NotNull
public JsName getNameForPackage(@NotNull
                                        FqName fqName)

declarePropertyOrPropertyAccessorName

@NotNull
public JsName declarePropertyOrPropertyAccessorName(@NotNull
                                                            DeclarationDescriptor descriptor,
                                                            @NotNull
                                                            java.lang.String name,
                                                            boolean fresh)

getQualifiedReference

@NotNull
public JsNameRef getQualifiedReference(@NotNull
                                               DeclarationDescriptor descriptor)

getQualifiedReference

@NotNull
public JsNameRef getQualifiedReference(@NotNull
                                               FqName packageFqName)

getQualifierForDescriptor

@Nullable
public JsExpression getQualifierForDescriptor(@NotNull
                                                       DeclarationDescriptor descriptor)

declareTemporary

@NotNull
public TemporaryVariable declareTemporary(@Nullable
                                                  JsExpression initExpression)

defineTemporary

@NotNull
public JsExpression defineTemporary(@NotNull
                                            JsExpression initExpression)

cacheExpressionIfNeeded

@NotNull
public JsExpression cacheExpressionIfNeeded(@NotNull
                                                    JsExpression expression)

getOrDeclareTemporaryConstVariable

@NotNull
public TemporaryConstVariable getOrDeclareTemporaryConstVariable(@NotNull
                                                                         JsExpression expression)

associateExpressionToLazyValue

public void associateExpressionToLazyValue(JsExpression expression,
                                           TemporaryConstVariable temporaryConstVariable)

namer

@NotNull
public Namer namer()

intrinsics

@NotNull
public Intrinsics intrinsics()

program

@NotNull
public JsProgram program()

getConfig

@NotNull
public JsConfig getConfig()

scope

@NotNull
public JsScope scope()

aliasingContext

@NotNull
public AliasingContext aliasingContext()

getFunctionObject

@NotNull
public JsFunction getFunctionObject(@NotNull
                                            CallableDescriptor descriptor)

addStatementToCurrentBlock

public void addStatementToCurrentBlock(@NotNull
                                       JsStatement statement)

addStatementsToCurrentBlockFrom

public void addStatementsToCurrentBlockFrom(@NotNull
                                            TranslationContext context)

addStatementsToCurrentBlockFrom

public void addStatementsToCurrentBlockFrom(@NotNull
                                            JsBlock block)

currentBlockIsEmpty

public boolean currentBlockIsEmpty()

moveVarsFrom

public void moveVarsFrom(@NotNull
                         TranslationContext context)

getCurrentBlock

@NotNull
public JsBlock getCurrentBlock()

getAliasForDescriptor

@Nullable
public JsExpression getAliasForDescriptor(@NotNull
                                                   DeclarationDescriptor descriptor)

getDispatchReceiver

@NotNull
public JsExpression getDispatchReceiver(@NotNull
                                                ReceiverParameterDescriptor descriptor)

getDefinitionPlace

@NotNull
public DefinitionPlace getDefinitionPlace()

define

@NotNull
public JsNameRef define(DeclarationDescriptor descriptor,
                                JsExpression expression)

getDeclarationDescriptor

@Nullable
public DeclarationDescriptor getDeclarationDescriptor()

putClassOrConstructorClosure

public void putClassOrConstructorClosure(@NotNull
                                         MemberDescriptor descriptor,
                                         @NotNull
                                         java.util.List<DeclarationDescriptor> closure)

getClassOrConstructorClosure

@Nullable
public java.util.List<DeclarationDescriptor> getClassOrConstructorClosure(@NotNull
                                                                                   MemberDescriptor classOrConstructor)

getArgumentForClosureConstructor

@NotNull
public JsExpression getArgumentForClosureConstructor(@NotNull
                                                             DeclarationDescriptor descriptor)
Gets an expression to pass to a constructor of a closure function. I.e. consider the case: ``` fun a(x) { fun b(y) = x + y return b } ``` Here, `x` is a free variable of `b`. Transform `a` into the following form: ``` fun a(x) { fun b0(x0) = { y -> x0 * y } return b0(x) } ``` This function generates arguments passed to newly generated `b0` closure, as well as for the similar case of local class and object expression.

Parameters:
descriptor - represents a free variable or, more generally, free declaration.
Returns:
expression to pass to a closure constructor.

getOuterClassReference

@Nullable
public JsName getOuterClassReference(ClassDescriptor descriptor)

startDeclaration

public void startDeclaration()

endDeclaration

@NotNull
public java.util.List<DeferredCallSite> endDeclaration()

shouldBeDeferred

public boolean shouldBeDeferred(@NotNull
                                ConstructorDescriptor constructor)

deferConstructorCall

public void deferConstructorCall(@NotNull
                                 ConstructorDescriptor constructor,
                                 @NotNull
                                 java.util.List<JsExpression> invocationArgs)

getModuleExpressionFor

@Nullable
public JsExpression getModuleExpressionFor(@NotNull
                                                    DeclarationDescriptor descriptor)