org.jetbrains.kotlin.js.translate.context
Class TranslationContext
java.lang.Object
org.jetbrains.kotlin.js.translate.context.TranslationContext
public class TranslationContext
- extends java.lang.Object
All the info about the state of the translation process.
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
rootContext
@NotNull
public static TranslationContext rootContext(@NotNull
StaticContext staticContext,
@NotNull
JsFunction rootFunction)
getImportedModules
@NotNull
public java.util.Collection<StaticContext.ImportedModule> getImportedModules()
usageTracker
@Nullable
public UsageTracker usageTracker()
dynamicContext
@NotNull
public DynamicContext dynamicContext()
contextWithScope
@NotNull
public TranslationContext contextWithScope(@NotNull
JsFunction fun)
newFunctionBodyWithUsageTracker
@NotNull
public TranslationContext newFunctionBodyWithUsageTracker(@NotNull
JsFunction fun,
@NotNull
MemberDescriptor descriptor)
innerWithUsageTracker
@NotNull
public TranslationContext innerWithUsageTracker(@NotNull
JsScope scope,
@NotNull
MemberDescriptor descriptor)
inner
@NotNull
public TranslationContext inner(@NotNull
MemberDescriptor descriptor)
innerBlock
@NotNull
public TranslationContext innerBlock(@NotNull
JsBlock block)
innerBlock
@NotNull
public TranslationContext innerBlock()
newDeclaration
@NotNull
public TranslationContext newDeclaration(@NotNull
DeclarationDescriptor descriptor)
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)
getClassDescriptor
@Nullable
public ClassDescriptor getClassDescriptor()
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)
getInnerNameForDescriptor
@NotNull
public JsName getInnerNameForDescriptor(@NotNull
DeclarationDescriptor descriptor)
getNameForObjectInstance
@NotNull
public JsName getNameForObjectInstance(@NotNull
ClassDescriptor descriptor)
getQualifiedReference
@NotNull
public JsNameRef getQualifiedReference(@NotNull
DeclarationDescriptor descriptor)
getInnerReference
@NotNull
public JsNameRef getInnerReference(@NotNull
DeclarationDescriptor descriptor)
getNameForBackingField
@NotNull
public JsName getNameForBackingField(@NotNull
PropertyDescriptor property)
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)
addStatementsToCurrentBlock
public void addStatementsToCurrentBlock(@NotNull
java.util.Collection<JsStatement> statements)
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)
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
ClassConstructorDescriptor constructor)
deferConstructorCall
public void deferConstructorCall(@NotNull
ClassConstructorDescriptor constructor,
@NotNull
java.util.List<JsExpression> invocationArgs)
getModuleExpressionFor
@Nullable
public JsExpression getModuleExpressionFor(@NotNull
DeclarationDescriptor descriptor)
addDeclarationStatement
public void addDeclarationStatement(@NotNull
JsStatement statement)
addTopLevelStatement
public void addTopLevelStatement(@NotNull
JsStatement statement)
createGlobalName
@NotNull
public JsName createGlobalName(@NotNull
java.lang.String suggestedName)
createRootScopedFunction
@NotNull
public JsFunction createRootScopedFunction(@NotNull
DeclarationDescriptor descriptor)
createRootScopedFunction
@NotNull
public JsFunction createRootScopedFunction(@NotNull
java.lang.String description)
addClass
public void addClass(@NotNull
ClassDescriptor classDescriptor)
export
public void export(@NotNull
MemberDescriptor descriptor)
isFromCurrentModule
public boolean isFromCurrentModule(@NotNull
DeclarationDescriptor descriptor)
isPublicInlineFunction
public boolean isPublicInlineFunction()
getContinuationParameterDescriptor
@Nullable
public VariableDescriptor getContinuationParameterDescriptor()
getCurrentModule
@NotNull
public ModuleDescriptor getCurrentModule()
getParent
@Nullable
public TranslationContext getParent()