chore: use CompositeBlock instead of GlobalBlock.
This commit is contained in:
@@ -243,7 +243,7 @@ message Statement {
|
||||
ExpressionStatement expression = 26;
|
||||
Vars vars = 27;
|
||||
Block block = 28;
|
||||
GlobalBlock global_block = 29;
|
||||
CompositeBlock composite_block = 29;
|
||||
Label label = 30;
|
||||
If if_statement = 31;
|
||||
Switch switch_statement = 32;
|
||||
@@ -254,7 +254,6 @@ message Statement {
|
||||
Try try_statement = 37;
|
||||
Empty empty = 38;
|
||||
SingleLineComment single_line_comment = 39;
|
||||
VirtualBlock virtual_block = 40;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -299,11 +298,7 @@ message Block {
|
||||
repeated Statement statement = 1;
|
||||
}
|
||||
|
||||
message GlobalBlock {
|
||||
repeated Statement statement = 1;
|
||||
}
|
||||
|
||||
message VirtualBlock {
|
||||
message CompositeBlock {
|
||||
repeated Statement statement = 1;
|
||||
}
|
||||
|
||||
@@ -394,9 +389,9 @@ enum InlineStrategy {
|
||||
message Fragment {
|
||||
repeated ImportedModule imported_module = 1;
|
||||
repeated Import import_entry = 2;
|
||||
optional GlobalBlock declaration_block = 3;
|
||||
optional GlobalBlock export_block = 4;
|
||||
optional GlobalBlock initializer_block = 5;
|
||||
optional CompositeBlock declaration_block = 3;
|
||||
optional CompositeBlock export_block = 4;
|
||||
optional CompositeBlock initializer_block = 5;
|
||||
repeated NameBinding name_binding = 6;
|
||||
repeated ClassModel class_model = 7;
|
||||
repeated Expression module_expression = 8;
|
||||
@@ -409,12 +404,12 @@ message Fragment {
|
||||
optional string dts = 15;
|
||||
optional int32 suite_function = 16;
|
||||
repeated int32 definitions = 17;
|
||||
optional GlobalBlock polyfills = 18;
|
||||
optional CompositeBlock polyfills = 18;
|
||||
}
|
||||
|
||||
message InlinedLocalDeclarations {
|
||||
required int32 tag = 1;
|
||||
required GlobalBlock block = 2;
|
||||
required CompositeBlock block = 2;
|
||||
}
|
||||
|
||||
message ImportedModule {
|
||||
@@ -437,14 +432,14 @@ message ClassModel {
|
||||
required int32 name_id = 1;
|
||||
optional int32 super_name_id = 2;
|
||||
repeated int32 interface_name_id = 4;
|
||||
optional GlobalBlock post_declaration_block = 3;
|
||||
optional CompositeBlock post_declaration_block = 3;
|
||||
}
|
||||
|
||||
message IrClassModel {
|
||||
required int32 name_id = 1;
|
||||
repeated int32 super_classes = 2;
|
||||
optional GlobalBlock pre_declaration_block = 3;
|
||||
optional GlobalBlock post_declaration_block = 4;
|
||||
optional CompositeBlock pre_declaration_block = 3;
|
||||
optional CompositeBlock post_declaration_block = 4;
|
||||
}
|
||||
|
||||
message InlineModule {
|
||||
|
||||
+5
-10
@@ -19,17 +19,12 @@ package org.jetbrains.kotlin.serialization.js.ast
|
||||
import org.jetbrains.kotlin.js.backend.ast.*
|
||||
import org.jetbrains.kotlin.js.backend.ast.JsImportedModule
|
||||
import org.jetbrains.kotlin.js.backend.ast.metadata.*
|
||||
import org.jetbrains.kotlin.js.backend.ast.metadata.LocalAlias
|
||||
import org.jetbrains.kotlin.js.backend.ast.metadata.SpecialFunction
|
||||
import org.jetbrains.kotlin.protobuf.CodedInputStream
|
||||
import org.jetbrains.kotlin.serialization.js.ast.JsAstProtoBuf.*
|
||||
import org.jetbrains.kotlin.serialization.js.ast.JsAstProtoBuf.Expression.ExpressionCase
|
||||
import org.jetbrains.kotlin.serialization.js.ast.JsAstProtoBuf.Statement.StatementCase
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.io.InputStream
|
||||
import java.io.InputStreamReader
|
||||
import java.util.*
|
||||
|
||||
class JsAstDeserializer(program: JsProgram, private val sourceRoots: Iterable<File>) : JsAstDeserializerBase() {
|
||||
|
||||
@@ -68,13 +63,13 @@ class JsAstDeserializer(program: JsProgram, private val sourceRoots: Iterable<Fi
|
||||
}
|
||||
|
||||
if (proto.hasDeclarationBlock()) {
|
||||
fragment.declarationBlock.statements += deserializeGlobalBlock(proto.declarationBlock).statements
|
||||
fragment.declarationBlock.statements += deserializeCompositeBlock(proto.declarationBlock).statements
|
||||
}
|
||||
if (proto.hasInitializerBlock()) {
|
||||
fragment.initializerBlock.statements += deserializeGlobalBlock(proto.initializerBlock).statements
|
||||
fragment.initializerBlock.statements += deserializeCompositeBlock(proto.initializerBlock).statements
|
||||
}
|
||||
if (proto.hasExportBlock()) {
|
||||
fragment.exportBlock.statements += deserializeGlobalBlock(proto.exportBlock).statements
|
||||
fragment.exportBlock.statements += deserializeCompositeBlock(proto.exportBlock).statements
|
||||
}
|
||||
|
||||
fragment.nameBindings += proto.nameBindingList.map { nameBindingProto ->
|
||||
@@ -103,7 +98,7 @@ class JsAstDeserializer(program: JsProgram, private val sourceRoots: Iterable<Fi
|
||||
}
|
||||
|
||||
proto.inlinedLocalDeclarationsList.forEach {
|
||||
fragment.inlinedLocalDeclarations[deserializeString(it.tag)] = deserializeGlobalBlock(it.block)
|
||||
fragment.inlinedLocalDeclarations[deserializeString(it.tag)] = deserializeCompositeBlock(it.block)
|
||||
}
|
||||
|
||||
return fragment
|
||||
@@ -114,7 +109,7 @@ class JsAstDeserializer(program: JsProgram, private val sourceRoots: Iterable<Fi
|
||||
return JsClassModel(deserializeName(proto.nameId), superName).apply {
|
||||
proto.interfaceNameIdList.mapTo(interfaces) { deserializeName(it) }
|
||||
if (proto.hasPostDeclarationBlock()) {
|
||||
postDeclarationBlock.statements += deserializeGlobalBlock(proto.postDeclarationBlock).statements
|
||||
postDeclarationBlock.statements += deserializeCompositeBlock(proto.postDeclarationBlock).statements
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-8
@@ -73,12 +73,8 @@ abstract class JsAstDeserializerBase {
|
||||
block
|
||||
}
|
||||
|
||||
JsAstProtoBuf.Statement.StatementCase.VIRTUAL_BLOCK -> {
|
||||
JsVirtualBlock(proto.virtualBlock.statementList.map { deserialize(it) })
|
||||
}
|
||||
|
||||
JsAstProtoBuf.Statement.StatementCase.GLOBAL_BLOCK -> {
|
||||
deserializeGlobalBlock(proto.globalBlock)
|
||||
JsAstProtoBuf.Statement.StatementCase.COMPOSITE_BLOCK -> {
|
||||
deserializeCompositeBlock(proto.compositeBlock)
|
||||
}
|
||||
|
||||
JsAstProtoBuf.Statement.StatementCase.LABEL -> {
|
||||
@@ -340,8 +336,9 @@ abstract class JsAstDeserializerBase {
|
||||
return vars
|
||||
}
|
||||
|
||||
protected fun deserializeGlobalBlock(proto: JsAstProtoBuf.GlobalBlock): JsGlobalBlock {
|
||||
return JsGlobalBlock().apply { statements += proto.statementList.map { deserialize(it) } }
|
||||
protected fun deserializeCompositeBlock(proto: JsAstProtoBuf.CompositeBlock): JsCompositeBlock {
|
||||
return JsCompositeBlock()
|
||||
.apply { statements += proto.statementList.map { deserialize(it) } }
|
||||
}
|
||||
|
||||
protected fun deserializeParameter(proto: JsAstProtoBuf.Parameter): JsParameter {
|
||||
|
||||
+289
-913
File diff suppressed because it is too large
Load Diff
+3
-11
@@ -7,7 +7,6 @@ package org.jetbrains.kotlin.serialization.js.ast
|
||||
|
||||
import org.jetbrains.kotlin.js.backend.ast.*
|
||||
import org.jetbrains.kotlin.js.backend.ast.metadata.*
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
|
||||
abstract class JsAstSerializerBase {
|
||||
@@ -68,14 +67,7 @@ abstract class JsAstSerializerBase {
|
||||
|
||||
override fun visitBlock(x: JsBlock) {
|
||||
when (x) {
|
||||
is JsGlobalBlock -> { builder.globalBlock = serializeBlock(x) }
|
||||
is JsVirtualBlock -> {
|
||||
val virtualBlockBuilder = JsAstProtoBuf.VirtualBlock.newBuilder()
|
||||
for (part in x.statements) {
|
||||
virtualBlockBuilder.addStatement(serialize(part))
|
||||
}
|
||||
builder.virtualBlock = virtualBlockBuilder.build()
|
||||
}
|
||||
is JsCompositeBlock -> { builder.compositeBlock = serializeBlock(x) }
|
||||
else -> {
|
||||
val blockBuilder = JsAstProtoBuf.Block.newBuilder()
|
||||
for (part in x.statements) {
|
||||
@@ -384,8 +376,8 @@ abstract class JsAstSerializerBase {
|
||||
return parameterBuilder.build()
|
||||
}
|
||||
|
||||
protected fun serializeBlock(block: JsGlobalBlock): JsAstProtoBuf.GlobalBlock {
|
||||
val blockBuilder = JsAstProtoBuf.GlobalBlock.newBuilder()
|
||||
protected fun serializeBlock(block: JsCompositeBlock): JsAstProtoBuf.CompositeBlock {
|
||||
val blockBuilder = JsAstProtoBuf.CompositeBlock.newBuilder()
|
||||
for (part in block.statements) {
|
||||
blockBuilder.addStatement(serialize(part))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user