JS: minor fixes after rebasing

Multiple minor fixes after rebasing incremental compilation related
branch to actual master
This commit is contained in:
Alexey Andreev
2017-03-29 16:27:37 +03:00
parent 1c2120d7e2
commit a055a038a8
12 changed files with 75 additions and 33 deletions
@@ -249,10 +249,10 @@ fun JsBlock.replaceLocalVariables(context: CoroutineTransformationContext, local
val wrapperFunction = JsFunction(x.scope.parent, JsBlock(), "")
val wrapperInvocation = JsInvocation(wrapperFunction)
wrapperFunction.body.statements += JsReturn(x)
val nameMap = freeVars.associate { it to wrapperFunction.scope.declareTemporaryName(it.ident) }
val nameMap = freeVars.associate { it to JsScope.declareTemporaryName(it.ident) }
for (freeVar in freeVars) {
wrapperFunction.parameters += JsParameter(nameMap[freeVar]!!)
wrapperInvocation.arguments += JsNameRef(scope.getFieldName(freeVar), JsLiteral.THIS)
wrapperInvocation.arguments += JsNameRef(context.getFieldName(freeVar), JsLiteral.THIS)
}
x.body = replaceNames(x.body, nameMap.mapValues { it.value.makeRef() })
ctx.replaceMe(wrapperInvocation)
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.builtins.isFunctionTypeOrSubtype
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.js.backend.ast.*
import org.jetbrains.kotlin.js.backend.ast.metadata.inlineStrategy
import org.jetbrains.kotlin.js.config.JsConfig
import org.jetbrains.kotlin.js.inline.util.IdentitySet
import org.jetbrains.kotlin.js.inline.util.isCallInvocation
import org.jetbrains.kotlin.js.parser.parseFunction
@@ -46,7 +47,7 @@ private val JS_IDENTIFIER="[$JS_IDENTIFIER_START][$JS_IDENTIFIER_PART]*"
private val DEFINE_MODULE_PATTERN = ("($JS_IDENTIFIER)\\.defineModule\\(\\s*(['\"])([^'\"]+)\\2\\s*,\\s*(\\w+)\\s*\\)").toRegex().toPattern()
private val DEFINE_MODULE_FIND_PATTERN = ".defineModule("
class FunctionReader(private val config: LibrarySourcesConfig, private val currentModuleName: JsName, fragments: List<JsProgramFragment>) {
class FunctionReader(private val config: JsConfig, private val currentModuleName: JsName, fragments: List<JsProgramFragment>) {
/**
* fileContent: .js file content, that contains this module definition.
* One file can contain more than one module definition.
@@ -29,7 +29,6 @@ import org.jetbrains.kotlin.diagnostics.Errors;
import org.jetbrains.kotlin.js.backend.ast.*;
import org.jetbrains.kotlin.js.backend.ast.metadata.MetadataProperties;
import org.jetbrains.kotlin.js.config.JsConfig;
import org.jetbrains.kotlin.js.config.LibrarySourcesConfig;
import org.jetbrains.kotlin.js.inline.clean.FunctionPostProcessor;
import org.jetbrains.kotlin.js.inline.clean.RemoveUnusedFunctionDefinitionsKt;
import org.jetbrains.kotlin.js.inline.clean.RemoveUnusedLocalFunctionDeclarationsKt;
@@ -76,7 +75,7 @@ public class JsInliner extends JsVisitorWithContextImpl {
accessorInvocationTransformer.accept(fragment.getDeclarationBlock());
accessorInvocationTransformer.accept(fragment.getInitializerBlock());
}
FunctionReader functionReader = new FunctionReader((LibrarySourcesConfig) config, currentModuleName, fragments);
FunctionReader functionReader = new FunctionReader(config, currentModuleName, fragments);
JsInliner inliner = new JsInliner(functions, accessors, functionReader, trace);
for (JsProgramFragment fragment : fragmentsToProcess) {
inliner.inliningContexts.push(inliner.new JsInliningContext());