JS: avoid repeated export of the same declaration
This commit is contained in:
+186
-108
@@ -26189,6 +26189,15 @@ public final class DebugJsAstProtoBuf {
|
|||||||
* <code>required .org.jetbrains.kotlin.serialization.js.ast.Expression expression = 1;</code>
|
* <code>required .org.jetbrains.kotlin.serialization.js.ast.Expression expression = 1;</code>
|
||||||
*/
|
*/
|
||||||
org.jetbrains.kotlin.serialization.js.ast.DebugJsAstProtoBuf.ExpressionOrBuilder getExpressionOrBuilder();
|
org.jetbrains.kotlin.serialization.js.ast.DebugJsAstProtoBuf.ExpressionOrBuilder getExpressionOrBuilder();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <code>optional int32 exported_tag_id = 2;</code>
|
||||||
|
*/
|
||||||
|
boolean hasExportedTagId();
|
||||||
|
/**
|
||||||
|
* <code>optional int32 exported_tag_id = 2;</code>
|
||||||
|
*/
|
||||||
|
int getExportedTagId();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Protobuf type {@code org.jetbrains.kotlin.serialization.js.ast.ExpressionStatement}
|
* Protobuf type {@code org.jetbrains.kotlin.serialization.js.ast.ExpressionStatement}
|
||||||
@@ -26255,6 +26264,11 @@ public final class DebugJsAstProtoBuf {
|
|||||||
bitField0_ |= 0x00000001;
|
bitField0_ |= 0x00000001;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 16: {
|
||||||
|
bitField0_ |= 0x00000002;
|
||||||
|
exportedTagId_ = input.readInt32();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) {
|
} catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) {
|
||||||
@@ -26316,8 +26330,24 @@ public final class DebugJsAstProtoBuf {
|
|||||||
return expression_;
|
return expression_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final int EXPORTED_TAG_ID_FIELD_NUMBER = 2;
|
||||||
|
private int exportedTagId_;
|
||||||
|
/**
|
||||||
|
* <code>optional int32 exported_tag_id = 2;</code>
|
||||||
|
*/
|
||||||
|
public boolean hasExportedTagId() {
|
||||||
|
return ((bitField0_ & 0x00000002) == 0x00000002);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* <code>optional int32 exported_tag_id = 2;</code>
|
||||||
|
*/
|
||||||
|
public int getExportedTagId() {
|
||||||
|
return exportedTagId_;
|
||||||
|
}
|
||||||
|
|
||||||
private void initFields() {
|
private void initFields() {
|
||||||
expression_ = org.jetbrains.kotlin.serialization.js.ast.DebugJsAstProtoBuf.Expression.getDefaultInstance();
|
expression_ = org.jetbrains.kotlin.serialization.js.ast.DebugJsAstProtoBuf.Expression.getDefaultInstance();
|
||||||
|
exportedTagId_ = 0;
|
||||||
}
|
}
|
||||||
private byte memoizedIsInitialized = -1;
|
private byte memoizedIsInitialized = -1;
|
||||||
public final boolean isInitialized() {
|
public final boolean isInitialized() {
|
||||||
@@ -26343,6 +26373,9 @@ public final class DebugJsAstProtoBuf {
|
|||||||
if (((bitField0_ & 0x00000001) == 0x00000001)) {
|
if (((bitField0_ & 0x00000001) == 0x00000001)) {
|
||||||
output.writeMessage(1, expression_);
|
output.writeMessage(1, expression_);
|
||||||
}
|
}
|
||||||
|
if (((bitField0_ & 0x00000002) == 0x00000002)) {
|
||||||
|
output.writeInt32(2, exportedTagId_);
|
||||||
|
}
|
||||||
getUnknownFields().writeTo(output);
|
getUnknownFields().writeTo(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26356,6 +26389,10 @@ public final class DebugJsAstProtoBuf {
|
|||||||
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
|
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
|
||||||
.computeMessageSize(1, expression_);
|
.computeMessageSize(1, expression_);
|
||||||
}
|
}
|
||||||
|
if (((bitField0_ & 0x00000002) == 0x00000002)) {
|
||||||
|
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
|
||||||
|
.computeInt32Size(2, exportedTagId_);
|
||||||
|
}
|
||||||
size += getUnknownFields().getSerializedSize();
|
size += getUnknownFields().getSerializedSize();
|
||||||
memoizedSerializedSize = size;
|
memoizedSerializedSize = size;
|
||||||
return size;
|
return size;
|
||||||
@@ -26480,6 +26517,8 @@ public final class DebugJsAstProtoBuf {
|
|||||||
expressionBuilder_.clear();
|
expressionBuilder_.clear();
|
||||||
}
|
}
|
||||||
bitField0_ = (bitField0_ & ~0x00000001);
|
bitField0_ = (bitField0_ & ~0x00000001);
|
||||||
|
exportedTagId_ = 0;
|
||||||
|
bitField0_ = (bitField0_ & ~0x00000002);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26516,6 +26555,10 @@ public final class DebugJsAstProtoBuf {
|
|||||||
} else {
|
} else {
|
||||||
result.expression_ = expressionBuilder_.build();
|
result.expression_ = expressionBuilder_.build();
|
||||||
}
|
}
|
||||||
|
if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
|
||||||
|
to_bitField0_ |= 0x00000002;
|
||||||
|
}
|
||||||
|
result.exportedTagId_ = exportedTagId_;
|
||||||
result.bitField0_ = to_bitField0_;
|
result.bitField0_ = to_bitField0_;
|
||||||
onBuilt();
|
onBuilt();
|
||||||
return result;
|
return result;
|
||||||
@@ -26535,6 +26578,9 @@ public final class DebugJsAstProtoBuf {
|
|||||||
if (other.hasExpression()) {
|
if (other.hasExpression()) {
|
||||||
mergeExpression(other.getExpression());
|
mergeExpression(other.getExpression());
|
||||||
}
|
}
|
||||||
|
if (other.hasExportedTagId()) {
|
||||||
|
setExportedTagId(other.getExportedTagId());
|
||||||
|
}
|
||||||
this.mergeUnknownFields(other.getUnknownFields());
|
this.mergeUnknownFields(other.getUnknownFields());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -26686,6 +26732,38 @@ public final class DebugJsAstProtoBuf {
|
|||||||
return expressionBuilder_;
|
return expressionBuilder_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int exportedTagId_ ;
|
||||||
|
/**
|
||||||
|
* <code>optional int32 exported_tag_id = 2;</code>
|
||||||
|
*/
|
||||||
|
public boolean hasExportedTagId() {
|
||||||
|
return ((bitField0_ & 0x00000002) == 0x00000002);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* <code>optional int32 exported_tag_id = 2;</code>
|
||||||
|
*/
|
||||||
|
public int getExportedTagId() {
|
||||||
|
return exportedTagId_;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* <code>optional int32 exported_tag_id = 2;</code>
|
||||||
|
*/
|
||||||
|
public Builder setExportedTagId(int value) {
|
||||||
|
bitField0_ |= 0x00000002;
|
||||||
|
exportedTagId_ = value;
|
||||||
|
onChanged();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* <code>optional int32 exported_tag_id = 2;</code>
|
||||||
|
*/
|
||||||
|
public Builder clearExportedTagId() {
|
||||||
|
bitField0_ = (bitField0_ & ~0x00000002);
|
||||||
|
exportedTagId_ = 0;
|
||||||
|
onChanged();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
// @@protoc_insertion_point(builder_scope:org.jetbrains.kotlin.serialization.js.ast.ExpressionStatement)
|
// @@protoc_insertion_point(builder_scope:org.jetbrains.kotlin.serialization.js.ast.ExpressionStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48467,117 +48545,117 @@ public final class DebugJsAstProtoBuf {
|
|||||||
"\"Q\n\005Throw\022H\n\texception\030\001 \002(\01325.org.jetbr" +
|
"\"Q\n\005Throw\022H\n\texception\030\001 \002(\01325.org.jetbr" +
|
||||||
"ains.kotlin.serialization.js.ast.Express" +
|
"ains.kotlin.serialization.js.ast.Express" +
|
||||||
"ion\"\031\n\005Break\022\020\n\010label_id\030\001 \001(\005\"\034\n\010Contin" +
|
"ion\"\031\n\005Break\022\020\n\010label_id\030\001 \001(\005\"\034\n\010Contin" +
|
||||||
"ue\022\020\n\010label_id\030\001 \001(\005\"\n\n\010Debugger\"`\n\023Expr" +
|
"ue\022\020\n\010label_id\030\001 \001(\005\"\n\n\010Debugger\"y\n\023Expr" +
|
||||||
"essionStatement\022I\n\nexpression\030\001 \002(\01325.or",
|
"essionStatement\022I\n\nexpression\030\001 \002(\01325.or",
|
||||||
"g.jetbrains.kotlin.serialization.js.ast." +
|
"g.jetbrains.kotlin.serialization.js.ast." +
|
||||||
"Expression\"\215\001\n\004Vars\022N\n\013declaration\030\001 \003(\013" +
|
"Expression\022\027\n\017exported_tag_id\030\002 \001(\005\"\215\001\n\004" +
|
||||||
"29.org.jetbrains.kotlin.serialization.js" +
|
"Vars\022N\n\013declaration\030\001 \003(\01329.org.jetbrain" +
|
||||||
".ast.VarDeclaration\022\030\n\tmultiline\030\002 \001(\010:\005" +
|
"s.kotlin.serialization.js.ast.VarDeclara" +
|
||||||
"false\022\033\n\023exported_package_id\030\003 \001(\005\"o\n\016Va" +
|
"tion\022\030\n\tmultiline\030\002 \001(\010:\005false\022\033\n\023export" +
|
||||||
"rDeclaration\022\017\n\007name_id\030\001 \002(\005\022L\n\rinitial" +
|
"ed_package_id\030\003 \001(\005\"o\n\016VarDeclaration\022\017\n" +
|
||||||
"_value\030\002 \001(\01325.org.jetbrains.kotlin.seri" +
|
"\007name_id\030\001 \002(\005\022L\n\rinitial_value\030\002 \001(\01325." +
|
||||||
"alization.js.ast.Expression\"P\n\005Block\022G\n\t" +
|
"org.jetbrains.kotlin.serialization.js.as" +
|
||||||
"statement\030\001 \003(\01324.org.jetbrains.kotlin.s" +
|
"t.Expression\"P\n\005Block\022G\n\tstatement\030\001 \003(\013" +
|
||||||
"erialization.js.ast.Statement\"V\n\013GlobalB",
|
"24.org.jetbrains.kotlin.serialization.js",
|
||||||
"lock\022G\n\tstatement\030\001 \003(\01324.org.jetbrains." +
|
".ast.Statement\"V\n\013GlobalBlock\022G\n\tstateme" +
|
||||||
"kotlin.serialization.js.ast.Statement\"f\n" +
|
"nt\030\001 \003(\01324.org.jetbrains.kotlin.serializ" +
|
||||||
"\005Label\022\016\n\006nameId\030\001 \002(\005\022M\n\017inner_statemen" +
|
"ation.js.ast.Statement\"f\n\005Label\022\016\n\006nameI" +
|
||||||
"t\030\002 \002(\01324.org.jetbrains.kotlin.serializa" +
|
"d\030\001 \002(\005\022M\n\017inner_statement\030\002 \002(\01324.org.j" +
|
||||||
"tion.js.ast.Statement\"\352\001\n\002If\022H\n\tconditio" +
|
|
||||||
"n\030\001 \002(\01325.org.jetbrains.kotlin.serializa" +
|
|
||||||
"tion.js.ast.Expression\022L\n\016then_statement" +
|
|
||||||
"\030\002 \002(\01324.org.jetbrains.kotlin.serializat" +
|
|
||||||
"ion.js.ast.Statement\022L\n\016else_statement\030\003" +
|
|
||||||
" \001(\01324.org.jetbrains.kotlin.serializatio",
|
|
||||||
"n.js.ast.Statement\"\232\001\n\006Switch\022I\n\nexpress" +
|
|
||||||
"ion\030\001 \002(\01325.org.jetbrains.kotlin.seriali" +
|
|
||||||
"zation.js.ast.Expression\022E\n\005entry\030\002 \003(\0132" +
|
|
||||||
"6.org.jetbrains.kotlin.serialization.js." +
|
|
||||||
"ast.SwitchEntry\"\234\001\n\013SwitchEntry\022D\n\005label" +
|
|
||||||
"\030\001 \001(\01325.org.jetbrains.kotlin.serializat" +
|
|
||||||
"ion.js.ast.Expression\022G\n\tstatement\030\002 \003(\013" +
|
|
||||||
"24.org.jetbrains.kotlin.serialization.js" +
|
|
||||||
".ast.Statement\"\225\001\n\005While\022H\n\tcondition\030\001 " +
|
|
||||||
"\002(\01325.org.jetbrains.kotlin.serialization",
|
|
||||||
".js.ast.Expression\022B\n\004body\030\002 \002(\01324.org.j" +
|
|
||||||
"etbrains.kotlin.serialization.js.ast.Sta" +
|
"etbrains.kotlin.serialization.js.ast.Sta" +
|
||||||
"tement\"\227\001\n\007DoWhile\022H\n\tcondition\030\001 \002(\01325." +
|
"tement\"\352\001\n\002If\022H\n\tcondition\030\001 \002(\01325.org.j" +
|
||||||
"org.jetbrains.kotlin.serialization.js.as" +
|
"etbrains.kotlin.serialization.js.ast.Exp" +
|
||||||
"t.Expression\022B\n\004body\030\002 \002(\01324.org.jetbrai" +
|
"ression\022L\n\016then_statement\030\002 \002(\01324.org.je" +
|
||||||
|
"tbrains.kotlin.serialization.js.ast.Stat" +
|
||||||
|
"ement\022L\n\016else_statement\030\003 \001(\01324.org.jetb",
|
||||||
|
"rains.kotlin.serialization.js.ast.Statem" +
|
||||||
|
"ent\"\232\001\n\006Switch\022I\n\nexpression\030\001 \002(\01325.org" +
|
||||||
|
".jetbrains.kotlin.serialization.js.ast.E" +
|
||||||
|
"xpression\022E\n\005entry\030\002 \003(\01326.org.jetbrains" +
|
||||||
|
".kotlin.serialization.js.ast.SwitchEntry" +
|
||||||
|
"\"\234\001\n\013SwitchEntry\022D\n\005label\030\001 \001(\01325.org.je" +
|
||||||
|
"tbrains.kotlin.serialization.js.ast.Expr" +
|
||||||
|
"ession\022G\n\tstatement\030\002 \003(\01324.org.jetbrain" +
|
||||||
|
"s.kotlin.serialization.js.ast.Statement\"" +
|
||||||
|
"\225\001\n\005While\022H\n\tcondition\030\001 \002(\01325.org.jetbr",
|
||||||
|
"ains.kotlin.serialization.js.ast.Express" +
|
||||||
|
"ion\022B\n\004body\030\002 \002(\01324.org.jetbrains.kotlin" +
|
||||||
|
".serialization.js.ast.Statement\"\227\001\n\007DoWh" +
|
||||||
|
"ile\022H\n\tcondition\030\001 \002(\01325.org.jetbrains.k" +
|
||||||
|
"otlin.serialization.js.ast.Expression\022B\n" +
|
||||||
|
"\004body\030\002 \002(\01324.org.jetbrains.kotlin.seria" +
|
||||||
|
"lization.js.ast.Statement\"\277\003\n\003For\022D\n\tvar" +
|
||||||
|
"iables\030\001 \001(\0132/.org.jetbrains.kotlin.seri" +
|
||||||
|
"alization.js.ast.VarsH\000\022K\n\nexpression\030\002 " +
|
||||||
|
"\001(\01325.org.jetbrains.kotlin.serialization",
|
||||||
|
".js.ast.ExpressionH\000\022E\n\005empty\030\003 \001(\01324.or" +
|
||||||
|
"g.jetbrains.kotlin.serialization.js.ast." +
|
||||||
|
"EmptyInitH\000\022H\n\tcondition\030\004 \001(\01325.org.jet" +
|
||||||
|
"brains.kotlin.serialization.js.ast.Expre" +
|
||||||
|
"ssion\022H\n\tincrement\030\005 \001(\01325.org.jetbrains" +
|
||||||
|
".kotlin.serialization.js.ast.Expression\022" +
|
||||||
|
"B\n\004body\030\006 \002(\01324.org.jetbrains.kotlin.ser" +
|
||||||
|
"ialization.js.ast.StatementB\006\n\004init\"\013\n\tE" +
|
||||||
|
"mptyInit\"\374\001\n\005ForIn\022\020\n\006nameId\030\001 \001(\005H\000\022K\n\n" +
|
||||||
|
"expression\030\002 \001(\01325.org.jetbrains.kotlin.",
|
||||||
|
"serialization.js.ast.ExpressionH\000\022G\n\010ite" +
|
||||||
|
"rable\030\003 \002(\01325.org.jetbrains.kotlin.seria" +
|
||||||
|
"lization.js.ast.Expression\022B\n\004body\030\004 \002(\013" +
|
||||||
|
"24.org.jetbrains.kotlin.serialization.js" +
|
||||||
|
".ast.StatementB\007\n\005value\"\337\001\n\003Try\022F\n\010tryBl" +
|
||||||
|
"ock\030\001 \002(\01324.org.jetbrains.kotlin.seriali" +
|
||||||
|
"zation.js.ast.Statement\022D\n\ncatchBlock\030\002 " +
|
||||||
|
"\001(\01320.org.jetbrains.kotlin.serialization" +
|
||||||
|
".js.ast.Catch\022J\n\014finallyBlock\030\003 \001(\01324.or" +
|
||||||
|
"g.jetbrains.kotlin.serialization.js.ast.",
|
||||||
|
"Statement\"\224\001\n\005Catch\022G\n\tparameter\030\001 \002(\01324" +
|
||||||
|
".org.jetbrains.kotlin.serialization.js.a" +
|
||||||
|
"st.Parameter\022B\n\004body\030\002 \002(\01324.org.jetbrai" +
|
||||||
"ns.kotlin.serialization.js.ast.Statement" +
|
"ns.kotlin.serialization.js.ast.Statement" +
|
||||||
"\"\277\003\n\003For\022D\n\tvariables\030\001 \001(\0132/.org.jetbra" +
|
"\"\007\n\005Empty\"\327\005\n\010Fragment\022R\n\017imported_modul" +
|
||||||
"ins.kotlin.serialization.js.ast.VarsH\000\022K" +
|
"e\030\001 \003(\01329.org.jetbrains.kotlin.serializa" +
|
||||||
"\n\nexpression\030\002 \001(\01325.org.jetbrains.kotli" +
|
"tion.js.ast.ImportedModule\022G\n\014import_ent" +
|
||||||
"n.serialization.js.ast.ExpressionH\000\022E\n\005e",
|
"ry\030\002 \003(\01321.org.jetbrains.kotlin.serializ" +
|
||||||
"mpty\030\003 \001(\01324.org.jetbrains.kotlin.serial" +
|
"ation.js.ast.Import\022Q\n\021declaration_block" +
|
||||||
"ization.js.ast.EmptyInitH\000\022H\n\tcondition\030" +
|
"\030\003 \001(\01326.org.jetbrains.kotlin.serializat",
|
||||||
"\004 \001(\01325.org.jetbrains.kotlin.serializati" +
|
"ion.js.ast.GlobalBlock\022L\n\014export_block\030\004" +
|
||||||
"on.js.ast.Expression\022H\n\tincrement\030\005 \001(\0132" +
|
" \001(\01326.org.jetbrains.kotlin.serializatio" +
|
||||||
"5.org.jetbrains.kotlin.serialization.js." +
|
"n.js.ast.GlobalBlock\022Q\n\021initializer_bloc" +
|
||||||
"ast.Expression\022B\n\004body\030\006 \002(\01324.org.jetbr" +
|
"k\030\005 \001(\01326.org.jetbrains.kotlin.serializa" +
|
||||||
"ains.kotlin.serialization.js.ast.Stateme" +
|
"tion.js.ast.GlobalBlock\022L\n\014name_binding\030" +
|
||||||
"ntB\006\n\004init\"\013\n\tEmptyInit\"\374\001\n\005ForIn\022\020\n\006nam" +
|
"\006 \003(\01326.org.jetbrains.kotlin.serializati" +
|
||||||
"eId\030\001 \001(\005H\000\022K\n\nexpression\030\002 \001(\01325.org.je" +
|
"on.js.ast.NameBinding\022J\n\013class_model\030\007 \003" +
|
||||||
"tbrains.kotlin.serialization.js.ast.Expr",
|
"(\01325.org.jetbrains.kotlin.serialization." +
|
||||||
"essionH\000\022G\n\010iterable\030\003 \002(\01325.org.jetbrai" +
|
"js.ast.ClassModel\022P\n\021module_expression\030\010" +
|
||||||
"ns.kotlin.serialization.js.ast.Expressio" +
|
" \003(\01325.org.jetbrains.kotlin.serializatio",
|
||||||
"n\022B\n\004body\030\004 \002(\01324.org.jetbrains.kotlin.s" +
|
"n.js.ast.Expression\022N\n\rinline_module\030\t \003" +
|
||||||
"erialization.js.ast.StatementB\007\n\005value\"\337" +
|
"(\01327.org.jetbrains.kotlin.serialization." +
|
||||||
"\001\n\003Try\022F\n\010tryBlock\030\001 \002(\01324.org.jetbrains" +
|
"js.ast.InlineModule\"\224\001\n\016ImportedModule\022\030" +
|
||||||
".kotlin.serialization.js.ast.Statement\022D" +
|
"\n\020external_name_id\030\001 \002(\005\022\030\n\020internal_nam" +
|
||||||
"\n\ncatchBlock\030\002 \001(\01320.org.jetbrains.kotli" +
|
"e_id\030\002 \002(\005\022N\n\017plain_reference\030\003 \001(\01325.or" +
|
||||||
"n.serialization.js.ast.Catch\022J\n\014finallyB" +
|
"g.jetbrains.kotlin.serialization.js.ast." +
|
||||||
"lock\030\003 \001(\01324.org.jetbrains.kotlin.serial" +
|
"Expression\"i\n\006Import\022\024\n\014signature_id\030\001 \002" +
|
||||||
"ization.js.ast.Statement\"\224\001\n\005Catch\022G\n\tpa",
|
"(\005\022I\n\nexpression\030\002 \002(\01325.org.jetbrains.k" +
|
||||||
"rameter\030\001 \002(\01324.org.jetbrains.kotlin.ser" +
|
"otlin.serialization.js.ast.Expression\"3\n" +
|
||||||
"ialization.js.ast.Parameter\022B\n\004body\030\002 \002(" +
|
"\013NameBinding\022\024\n\014signature_id\030\001 \002(\005\022\016\n\006na",
|
||||||
"\01324.org.jetbrains.kotlin.serialization.j" +
|
"meId\030\002 \002(\005\"\214\001\n\nClassModel\022\017\n\007name_id\030\001 \002" +
|
||||||
"s.ast.Statement\"\007\n\005Empty\"\327\005\n\010Fragment\022R\n" +
|
"(\005\022\025\n\rsuper_name_id\030\002 \001(\005\022V\n\026post_declar" +
|
||||||
"\017imported_module\030\001 \003(\01329.org.jetbrains.k" +
|
"ation_block\030\003 \001(\01326.org.jetbrains.kotlin" +
|
||||||
"otlin.serialization.js.ast.ImportedModul" +
|
".serialization.js.ast.GlobalBlock\";\n\014Inl" +
|
||||||
"e\022G\n\014import_entry\030\002 \003(\01321.org.jetbrains." +
|
"ineModule\022\024\n\014signature_id\030\001 \002(\005\022\025\n\rexpre" +
|
||||||
"kotlin.serialization.js.ast.Import\022Q\n\021de" +
|
"ssion_id\030\002 \002(\005\"\034\n\013StringTable\022\r\n\005entry\030\001" +
|
||||||
"claration_block\030\003 \001(\01326.org.jetbrains.ko" +
|
" \003(\t\"K\n\tNameTable\022>\n\005entry\030\001 \003(\0132/.org.j" +
|
||||||
"tlin.serialization.js.ast.GlobalBlock\022L\n",
|
"etbrains.kotlin.serialization.js.ast.Nam" +
|
||||||
"\014export_block\030\004 \001(\01326.org.jetbrains.kotl" +
|
"e\"-\n\004Name\022\021\n\ttemporary\030\001 \002(\010\022\022\n\nidentifi" +
|
||||||
"in.serialization.js.ast.GlobalBlock\022Q\n\021i" +
|
"er\030\002 \001(\005\"\346\001\n\005Chunk\022L\n\014string_table\030\001 \002(\013",
|
||||||
"nitializer_block\030\005 \001(\01326.org.jetbrains.k" +
|
"26.org.jetbrains.kotlin.serialization.js" +
|
||||||
"otlin.serialization.js.ast.GlobalBlock\022L" +
|
".ast.StringTable\022H\n\nname_table\030\002 \002(\01324.o" +
|
||||||
"\n\014name_binding\030\006 \003(\01326.org.jetbrains.kot" +
|
"rg.jetbrains.kotlin.serialization.js.ast" +
|
||||||
"lin.serialization.js.ast.NameBinding\022J\n\013" +
|
".NameTable\022E\n\010fragment\030\003 \002(\01323.org.jetbr" +
|
||||||
"class_model\030\007 \003(\01325.org.jetbrains.kotlin" +
|
"ains.kotlin.serialization.js.ast.Fragmen" +
|
||||||
".serialization.js.ast.ClassModel\022P\n\021modu" +
|
"t*@\n\013SideEffects\022\021\n\rAFFECTS_STATE\020\001\022\024\n\020D" +
|
||||||
"le_expression\030\010 \003(\01325.org.jetbrains.kotl" +
|
"EPENDS_ON_STATE\020\002\022\010\n\004PURE\020\003*?\n\016InlineStr" +
|
||||||
"in.serialization.js.ast.Expression\022N\n\rin",
|
"ategy\022\017\n\013AS_FUNCTION\020\000\022\014\n\010IN_PLACE\020\001\022\016\n\n" +
|
||||||
"line_module\030\t \003(\01327.org.jetbrains.kotlin" +
|
"NOT_INLINE\020\002B\024B\022DebugJsAstProtoBuf"
|
||||||
".serialization.js.ast.InlineModule\"\224\001\n\016I" +
|
|
||||||
"mportedModule\022\030\n\020external_name_id\030\001 \002(\005\022" +
|
|
||||||
"\030\n\020internal_name_id\030\002 \002(\005\022N\n\017plain_refer" +
|
|
||||||
"ence\030\003 \001(\01325.org.jetbrains.kotlin.serial" +
|
|
||||||
"ization.js.ast.Expression\"i\n\006Import\022\024\n\014s" +
|
|
||||||
"ignature_id\030\001 \002(\005\022I\n\nexpression\030\002 \002(\01325." +
|
|
||||||
"org.jetbrains.kotlin.serialization.js.as" +
|
|
||||||
"t.Expression\"3\n\013NameBinding\022\024\n\014signature" +
|
|
||||||
"_id\030\001 \002(\005\022\016\n\006nameId\030\002 \002(\005\"\214\001\n\nClassModel",
|
|
||||||
"\022\017\n\007name_id\030\001 \002(\005\022\025\n\rsuper_name_id\030\002 \001(\005" +
|
|
||||||
"\022V\n\026post_declaration_block\030\003 \001(\01326.org.j" +
|
|
||||||
"etbrains.kotlin.serialization.js.ast.Glo" +
|
|
||||||
"balBlock\";\n\014InlineModule\022\024\n\014signature_id" +
|
|
||||||
"\030\001 \002(\005\022\025\n\rexpression_id\030\002 \002(\005\"\034\n\013StringT" +
|
|
||||||
"able\022\r\n\005entry\030\001 \003(\t\"K\n\tNameTable\022>\n\005entr" +
|
|
||||||
"y\030\001 \003(\0132/.org.jetbrains.kotlin.serializa" +
|
|
||||||
"tion.js.ast.Name\"-\n\004Name\022\021\n\ttemporary\030\001 " +
|
|
||||||
"\002(\010\022\022\n\nidentifier\030\002 \001(\005\"\346\001\n\005Chunk\022L\n\014str" +
|
|
||||||
"ing_table\030\001 \002(\01326.org.jetbrains.kotlin.s",
|
|
||||||
"erialization.js.ast.StringTable\022H\n\nname_" +
|
|
||||||
"table\030\002 \002(\01324.org.jetbrains.kotlin.seria" +
|
|
||||||
"lization.js.ast.NameTable\022E\n\010fragment\030\003 " +
|
|
||||||
"\002(\01323.org.jetbrains.kotlin.serialization" +
|
|
||||||
".js.ast.Fragment*@\n\013SideEffects\022\021\n\rAFFEC" +
|
|
||||||
"TS_STATE\020\001\022\024\n\020DEPENDS_ON_STATE\020\002\022\010\n\004PURE" +
|
|
||||||
"\020\003*?\n\016InlineStrategy\022\017\n\013AS_FUNCTION\020\000\022\014\n" +
|
|
||||||
"\010IN_PLACE\020\001\022\016\n\nNOT_INLINE\020\002B\024B\022DebugJsAs" +
|
|
||||||
"tProtoBuf"
|
|
||||||
};
|
};
|
||||||
org.jetbrains.kotlin.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
|
org.jetbrains.kotlin.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
|
||||||
new org.jetbrains.kotlin.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() {
|
new org.jetbrains.kotlin.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() {
|
||||||
@@ -48764,7 +48842,7 @@ public final class DebugJsAstProtoBuf {
|
|||||||
internal_static_org_jetbrains_kotlin_serialization_js_ast_ExpressionStatement_fieldAccessorTable = new
|
internal_static_org_jetbrains_kotlin_serialization_js_ast_ExpressionStatement_fieldAccessorTable = new
|
||||||
org.jetbrains.kotlin.protobuf.GeneratedMessage.FieldAccessorTable(
|
org.jetbrains.kotlin.protobuf.GeneratedMessage.FieldAccessorTable(
|
||||||
internal_static_org_jetbrains_kotlin_serialization_js_ast_ExpressionStatement_descriptor,
|
internal_static_org_jetbrains_kotlin_serialization_js_ast_ExpressionStatement_descriptor,
|
||||||
new java.lang.String[] { "Expression", });
|
new java.lang.String[] { "Expression", "ExportedTagId", });
|
||||||
internal_static_org_jetbrains_kotlin_serialization_js_ast_Vars_descriptor =
|
internal_static_org_jetbrains_kotlin_serialization_js_ast_Vars_descriptor =
|
||||||
getDescriptor().getMessageTypes().get(29);
|
getDescriptor().getMessageTypes().get(29);
|
||||||
internal_static_org_jetbrains_kotlin_serialization_js_ast_Vars_fieldAccessorTable = new
|
internal_static_org_jetbrains_kotlin_serialization_js_ast_Vars_fieldAccessorTable = new
|
||||||
|
|||||||
@@ -54,6 +54,8 @@ var JsInvocation.boxing: Boolean by MetadataProperty(default = false)
|
|||||||
|
|
||||||
var JsVars.exportedPackage: String? by MetadataProperty(default = null)
|
var JsVars.exportedPackage: String? by MetadataProperty(default = null)
|
||||||
|
|
||||||
|
var JsExpressionStatement.exportedTag: String? by MetadataProperty(default = null)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For function and lambda bodies indicates what declaration corresponds to.
|
* For function and lambda bodies indicates what declaration corresponds to.
|
||||||
* When absent (`null`) on body of a named function, this function is from external JS module.
|
* When absent (`null`) on body of a named function, this function is from external JS module.
|
||||||
|
|||||||
@@ -270,6 +270,7 @@ message Debugger {
|
|||||||
|
|
||||||
message ExpressionStatement {
|
message ExpressionStatement {
|
||||||
required Expression expression = 1;
|
required Expression expression = 1;
|
||||||
|
optional int32 exported_tag_id = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message Vars {
|
message Vars {
|
||||||
|
|||||||
@@ -142,7 +142,11 @@ class JsAstDeserializer(private val program: JsProgram) {
|
|||||||
|
|
||||||
StatementCase.EXPRESSION -> {
|
StatementCase.EXPRESSION -> {
|
||||||
val expressionProto = proto.expression
|
val expressionProto = proto.expression
|
||||||
JsExpressionStatement(deserialize(expressionProto.expression))
|
JsExpressionStatement(deserialize(expressionProto.expression)).also {
|
||||||
|
if (expressionProto.hasExportedTagId()) {
|
||||||
|
it.exportedTag = deserializeString(expressionProto.exportedTagId)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StatementCase.VARS -> {
|
StatementCase.VARS -> {
|
||||||
|
|||||||
@@ -19331,6 +19331,15 @@ public final class JsAstProtoBuf {
|
|||||||
* <code>required .org.jetbrains.kotlin.serialization.js.ast.Expression expression = 1;</code>
|
* <code>required .org.jetbrains.kotlin.serialization.js.ast.Expression expression = 1;</code>
|
||||||
*/
|
*/
|
||||||
org.jetbrains.kotlin.serialization.js.ast.JsAstProtoBuf.Expression getExpression();
|
org.jetbrains.kotlin.serialization.js.ast.JsAstProtoBuf.Expression getExpression();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <code>optional int32 exported_tag_id = 2;</code>
|
||||||
|
*/
|
||||||
|
boolean hasExportedTagId();
|
||||||
|
/**
|
||||||
|
* <code>optional int32 exported_tag_id = 2;</code>
|
||||||
|
*/
|
||||||
|
int getExportedTagId();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Protobuf type {@code org.jetbrains.kotlin.serialization.js.ast.ExpressionStatement}
|
* Protobuf type {@code org.jetbrains.kotlin.serialization.js.ast.ExpressionStatement}
|
||||||
@@ -19395,6 +19404,11 @@ public final class JsAstProtoBuf {
|
|||||||
bitField0_ |= 0x00000001;
|
bitField0_ |= 0x00000001;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 16: {
|
||||||
|
bitField0_ |= 0x00000002;
|
||||||
|
exportedTagId_ = input.readInt32();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) {
|
} catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) {
|
||||||
@@ -19444,8 +19458,24 @@ public final class JsAstProtoBuf {
|
|||||||
return expression_;
|
return expression_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final int EXPORTED_TAG_ID_FIELD_NUMBER = 2;
|
||||||
|
private int exportedTagId_;
|
||||||
|
/**
|
||||||
|
* <code>optional int32 exported_tag_id = 2;</code>
|
||||||
|
*/
|
||||||
|
public boolean hasExportedTagId() {
|
||||||
|
return ((bitField0_ & 0x00000002) == 0x00000002);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* <code>optional int32 exported_tag_id = 2;</code>
|
||||||
|
*/
|
||||||
|
public int getExportedTagId() {
|
||||||
|
return exportedTagId_;
|
||||||
|
}
|
||||||
|
|
||||||
private void initFields() {
|
private void initFields() {
|
||||||
expression_ = org.jetbrains.kotlin.serialization.js.ast.JsAstProtoBuf.Expression.getDefaultInstance();
|
expression_ = org.jetbrains.kotlin.serialization.js.ast.JsAstProtoBuf.Expression.getDefaultInstance();
|
||||||
|
exportedTagId_ = 0;
|
||||||
}
|
}
|
||||||
private byte memoizedIsInitialized = -1;
|
private byte memoizedIsInitialized = -1;
|
||||||
public final boolean isInitialized() {
|
public final boolean isInitialized() {
|
||||||
@@ -19471,6 +19501,9 @@ public final class JsAstProtoBuf {
|
|||||||
if (((bitField0_ & 0x00000001) == 0x00000001)) {
|
if (((bitField0_ & 0x00000001) == 0x00000001)) {
|
||||||
output.writeMessage(1, expression_);
|
output.writeMessage(1, expression_);
|
||||||
}
|
}
|
||||||
|
if (((bitField0_ & 0x00000002) == 0x00000002)) {
|
||||||
|
output.writeInt32(2, exportedTagId_);
|
||||||
|
}
|
||||||
output.writeRawBytes(unknownFields);
|
output.writeRawBytes(unknownFields);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19484,6 +19517,10 @@ public final class JsAstProtoBuf {
|
|||||||
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
|
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
|
||||||
.computeMessageSize(1, expression_);
|
.computeMessageSize(1, expression_);
|
||||||
}
|
}
|
||||||
|
if (((bitField0_ & 0x00000002) == 0x00000002)) {
|
||||||
|
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
|
||||||
|
.computeInt32Size(2, exportedTagId_);
|
||||||
|
}
|
||||||
size += unknownFields.size();
|
size += unknownFields.size();
|
||||||
memoizedSerializedSize = size;
|
memoizedSerializedSize = size;
|
||||||
return size;
|
return size;
|
||||||
@@ -19580,6 +19617,8 @@ public final class JsAstProtoBuf {
|
|||||||
super.clear();
|
super.clear();
|
||||||
expression_ = org.jetbrains.kotlin.serialization.js.ast.JsAstProtoBuf.Expression.getDefaultInstance();
|
expression_ = org.jetbrains.kotlin.serialization.js.ast.JsAstProtoBuf.Expression.getDefaultInstance();
|
||||||
bitField0_ = (bitField0_ & ~0x00000001);
|
bitField0_ = (bitField0_ & ~0x00000001);
|
||||||
|
exportedTagId_ = 0;
|
||||||
|
bitField0_ = (bitField0_ & ~0x00000002);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19607,6 +19646,10 @@ public final class JsAstProtoBuf {
|
|||||||
to_bitField0_ |= 0x00000001;
|
to_bitField0_ |= 0x00000001;
|
||||||
}
|
}
|
||||||
result.expression_ = expression_;
|
result.expression_ = expression_;
|
||||||
|
if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
|
||||||
|
to_bitField0_ |= 0x00000002;
|
||||||
|
}
|
||||||
|
result.exportedTagId_ = exportedTagId_;
|
||||||
result.bitField0_ = to_bitField0_;
|
result.bitField0_ = to_bitField0_;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -19616,6 +19659,9 @@ public final class JsAstProtoBuf {
|
|||||||
if (other.hasExpression()) {
|
if (other.hasExpression()) {
|
||||||
mergeExpression(other.getExpression());
|
mergeExpression(other.getExpression());
|
||||||
}
|
}
|
||||||
|
if (other.hasExportedTagId()) {
|
||||||
|
setExportedTagId(other.getExportedTagId());
|
||||||
|
}
|
||||||
setUnknownFields(
|
setUnknownFields(
|
||||||
getUnknownFields().concat(other.unknownFields));
|
getUnknownFields().concat(other.unknownFields));
|
||||||
return this;
|
return this;
|
||||||
@@ -19712,6 +19758,38 @@ public final class JsAstProtoBuf {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int exportedTagId_ ;
|
||||||
|
/**
|
||||||
|
* <code>optional int32 exported_tag_id = 2;</code>
|
||||||
|
*/
|
||||||
|
public boolean hasExportedTagId() {
|
||||||
|
return ((bitField0_ & 0x00000002) == 0x00000002);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* <code>optional int32 exported_tag_id = 2;</code>
|
||||||
|
*/
|
||||||
|
public int getExportedTagId() {
|
||||||
|
return exportedTagId_;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* <code>optional int32 exported_tag_id = 2;</code>
|
||||||
|
*/
|
||||||
|
public Builder setExportedTagId(int value) {
|
||||||
|
bitField0_ |= 0x00000002;
|
||||||
|
exportedTagId_ = value;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* <code>optional int32 exported_tag_id = 2;</code>
|
||||||
|
*/
|
||||||
|
public Builder clearExportedTagId() {
|
||||||
|
bitField0_ = (bitField0_ & ~0x00000002);
|
||||||
|
exportedTagId_ = 0;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
// @@protoc_insertion_point(builder_scope:org.jetbrains.kotlin.serialization.js.ast.ExpressionStatement)
|
// @@protoc_insertion_point(builder_scope:org.jetbrains.kotlin.serialization.js.ast.ExpressionStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -144,6 +144,11 @@ class JsAstSerializer {
|
|||||||
override fun visitExpressionStatement(x: JsExpressionStatement) {
|
override fun visitExpressionStatement(x: JsExpressionStatement) {
|
||||||
val statementBuilder = ExpressionStatement.newBuilder()
|
val statementBuilder = ExpressionStatement.newBuilder()
|
||||||
statementBuilder.expression = serialize(x.expression)
|
statementBuilder.expression = serialize(x.expression)
|
||||||
|
val tag = x.exportedTag
|
||||||
|
if (tag != null) {
|
||||||
|
statementBuilder.exportedTagId = serialize(tag)
|
||||||
|
}
|
||||||
|
|
||||||
builder.expression = statementBuilder.build()
|
builder.expression = statementBuilder.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3467,6 +3467,12 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("multipleExport.kt")
|
||||||
|
public void testMultipleExport() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/incremental/multipleExport.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("simple.kt")
|
@TestMetadata("simple.kt")
|
||||||
public void testSimple() throws Exception {
|
public void testSimple() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/incremental/simple.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/incremental/simple.kt");
|
||||||
|
|||||||
@@ -76,6 +76,13 @@ public class DirectiveTestUtils {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static final DirectiveHandler PROPERTY_WRITE_COUNT = new DirectiveHandler("PROPERTY_WRITE_COUNT") {
|
||||||
|
@Override
|
||||||
|
void processEntry(@NotNull JsNode ast, @NotNull ArgumentsHelper arguments) throws Exception {
|
||||||
|
checkPropertyWriteCount(ast, arguments.getNamedArgument("name"), Integer.parseInt(arguments.getNamedArgument("count")));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private static final DirectiveHandler FUNCTION_CALLED_IN_SCOPE = new DirectiveHandler("CHECK_CALLED_IN_SCOPE") {
|
private static final DirectiveHandler FUNCTION_CALLED_IN_SCOPE = new DirectiveHandler("CHECK_CALLED_IN_SCOPE") {
|
||||||
@Override
|
@Override
|
||||||
void processEntry(@NotNull JsNode ast, @NotNull ArgumentsHelper arguments) throws Exception {
|
void processEntry(@NotNull JsNode ast, @NotNull ArgumentsHelper arguments) throws Exception {
|
||||||
@@ -292,6 +299,7 @@ public class DirectiveTestUtils {
|
|||||||
PROPERTY_NOT_USED,
|
PROPERTY_NOT_USED,
|
||||||
PROPERTY_NOT_READ_FROM,
|
PROPERTY_NOT_READ_FROM,
|
||||||
PROPERTY_NOT_WRITTEN_TO,
|
PROPERTY_NOT_WRITTEN_TO,
|
||||||
|
PROPERTY_WRITE_COUNT,
|
||||||
FUNCTION_CALLED_IN_SCOPE,
|
FUNCTION_CALLED_IN_SCOPE,
|
||||||
FUNCTION_NOT_CALLED_IN_SCOPE,
|
FUNCTION_NOT_CALLED_IN_SCOPE,
|
||||||
FUNCTIONS_HAVE_SAME_LINES,
|
FUNCTIONS_HAVE_SAME_LINES,
|
||||||
@@ -332,6 +340,11 @@ public class DirectiveTestUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void checkPropertyWriteCount(JsNode node, String propertyName, int expectedCount) throws Exception {
|
||||||
|
PropertyReferenceCollector counter = PropertyReferenceCollector.Companion.collect(node);
|
||||||
|
assertEquals("Property write count: " + propertyName, expectedCount, counter.unqualifiedWriteCount(propertyName));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void checkFunctionNotCalled(@NotNull JsNode node, @NotNull String functionName, @Nullable String exceptFunction)
|
public static void checkFunctionNotCalled(@NotNull JsNode node, @NotNull String functionName, @Nullable String exceptFunction)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|||||||
@@ -25,10 +25,12 @@ import org.jetbrains.kotlin.js.translate.utils.JsAstUtils
|
|||||||
class PropertyReferenceCollector : RecursiveJsVisitor() {
|
class PropertyReferenceCollector : RecursiveJsVisitor() {
|
||||||
|
|
||||||
private val identReadSet = hashSetOf<String>()
|
private val identReadSet = hashSetOf<String>()
|
||||||
private val identWriteSet = hashSetOf<String>()
|
private val identWriteMap = hashMapOf<String, Int>()
|
||||||
|
|
||||||
fun hasUnqualifiedReads(expectedIdent: String) = expectedIdent in identReadSet
|
fun hasUnqualifiedReads(expectedIdent: String) = expectedIdent in identReadSet
|
||||||
fun hasUnqualifiedWrites(expectedIdent: String) = expectedIdent in identWriteSet
|
fun hasUnqualifiedWrites(expectedIdent: String) = expectedIdent in identWriteMap
|
||||||
|
|
||||||
|
fun unqualifiedWriteCount(expectedIdent: String): Int = identWriteMap[expectedIdent] ?: 0
|
||||||
|
|
||||||
override fun visitNameRef(nameRef: JsNameRef) {
|
override fun visitNameRef(nameRef: JsNameRef) {
|
||||||
super.visitNameRef(nameRef)
|
super.visitNameRef(nameRef)
|
||||||
@@ -40,7 +42,7 @@ class PropertyReferenceCollector : RecursiveJsVisitor() {
|
|||||||
JsAstUtils.decomposeAssignment(x)?.let { (left, right) ->
|
JsAstUtils.decomposeAssignment(x)?.let { (left, right) ->
|
||||||
(left as? JsNameRef)?.let { nameRef ->
|
(left as? JsNameRef)?.let { nameRef ->
|
||||||
assignmentToProperty = true
|
assignmentToProperty = true
|
||||||
identWriteSet.add(nameRef.ident)
|
identWriteMap[nameRef.ident] = 1 + unqualifiedWriteCount(nameRef.ident)
|
||||||
nameRef.qualifier?.accept(this)
|
nameRef.qualifier?.accept(this)
|
||||||
right.accept(this)
|
right.accept(this)
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-12
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.descriptors.*
|
|||||||
import org.jetbrains.kotlin.descriptors.annotations.isInlineOnlyOrReifiable
|
import org.jetbrains.kotlin.descriptors.annotations.isInlineOnlyOrReifiable
|
||||||
import org.jetbrains.kotlin.js.backend.ast.*
|
import org.jetbrains.kotlin.js.backend.ast.*
|
||||||
import org.jetbrains.kotlin.js.backend.ast.metadata.exportedPackage
|
import org.jetbrains.kotlin.js.backend.ast.metadata.exportedPackage
|
||||||
|
import org.jetbrains.kotlin.js.backend.ast.metadata.exportedTag
|
||||||
import org.jetbrains.kotlin.js.backend.ast.metadata.staticRef
|
import org.jetbrains.kotlin.js.backend.ast.metadata.staticRef
|
||||||
import org.jetbrains.kotlin.js.translate.utils.AnnotationsUtils
|
import org.jetbrains.kotlin.js.translate.utils.AnnotationsUtils
|
||||||
import org.jetbrains.kotlin.js.translate.utils.AnnotationsUtils.isLibraryObject
|
import org.jetbrains.kotlin.js.translate.utils.AnnotationsUtils.isLibraryObject
|
||||||
@@ -70,25 +71,26 @@ internal class DeclarationExporter(val context: StaticContext) {
|
|||||||
exportProperty(descriptor, qualifier)
|
exportProperty(descriptor, qualifier)
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
assign(descriptor, qualifier, context.getInnerNameForDescriptor(descriptor).makeRef())
|
assign(descriptor, qualifier)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun assign(descriptor: DeclarationDescriptor, qualifier: JsExpression, expression: JsExpression) {
|
private fun assign(descriptor: DeclarationDescriptor, qualifier: JsExpression) {
|
||||||
|
val exportedName = context.getInnerNameForDescriptor(descriptor)
|
||||||
|
val expression = exportedName.makeRef()
|
||||||
val propertyName = context.getNameForDescriptor(descriptor)
|
val propertyName = context.getNameForDescriptor(descriptor)
|
||||||
if (propertyName.staticRef == null) {
|
if (propertyName.staticRef == null && exportedName != propertyName) {
|
||||||
if (expression !is JsNameRef || expression.name !== propertyName) {
|
propertyName.staticRef = expression
|
||||||
propertyName.staticRef = expression
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
statements += assignment(JsNameRef(propertyName, qualifier), expression).makeStmt()
|
statements += assignment(JsNameRef(propertyName, qualifier), expression).exportStatement(descriptor)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun exportObject(declaration: ClassDescriptor, qualifier: JsExpression) {
|
private fun exportObject(declaration: ClassDescriptor, qualifier: JsExpression) {
|
||||||
val name = context.getNameForDescriptor(declaration)
|
val name = context.getNameForDescriptor(declaration)
|
||||||
statements += JsAstUtils.defineGetter(context.program, qualifier, name.ident,
|
val expression = JsAstUtils.defineGetter(context.program, qualifier, name.ident,
|
||||||
context.getNameForObjectInstance(declaration).makeRef())
|
context.getNameForObjectInstance(declaration).makeRef())
|
||||||
|
statements += expression.exportStatement(declaration)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun exportProperty(declaration: PropertyDescriptor, qualifier: JsExpression) {
|
private fun exportProperty(declaration: PropertyDescriptor, qualifier: JsExpression) {
|
||||||
@@ -98,12 +100,15 @@ internal class DeclarationExporter(val context: StaticContext) {
|
|||||||
val simpleProperty = JsDescriptorUtils.isSimpleFinalProperty(declaration) &&
|
val simpleProperty = JsDescriptorUtils.isSimpleFinalProperty(declaration) &&
|
||||||
!TranslationUtils.shouldAccessViaFunctions(declaration)
|
!TranslationUtils.shouldAccessViaFunctions(declaration)
|
||||||
|
|
||||||
|
val exportedName: JsName
|
||||||
val getterBody: JsExpression = if (simpleProperty) {
|
val getterBody: JsExpression = if (simpleProperty) {
|
||||||
val accessToField = JsReturn(context.getInnerNameForDescriptor(declaration).makeRef())
|
exportedName = context.getInnerNameForDescriptor(declaration)
|
||||||
|
val accessToField = JsReturn(exportedName.makeRef())
|
||||||
JsFunction(context.fragment.scope, JsBlock(accessToField), "$declaration getter")
|
JsFunction(context.fragment.scope, JsBlock(accessToField), "$declaration getter")
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
context.getInnerNameForDescriptor(declaration.getter!!).makeRef()
|
exportedName = context.getInnerNameForDescriptor(declaration.getter!!)
|
||||||
|
exportedName.makeRef()
|
||||||
}
|
}
|
||||||
propertyLiteral.propertyInitializers += JsPropertyInitializer(JsNameRef("get"), getterBody)
|
propertyLiteral.propertyInitializers += JsPropertyInitializer(JsNameRef("get"), getterBody)
|
||||||
|
|
||||||
@@ -122,7 +127,7 @@ internal class DeclarationExporter(val context: StaticContext) {
|
|||||||
propertyLiteral.propertyInitializers += JsPropertyInitializer(JsNameRef("set"), setterBody)
|
propertyLiteral.propertyInitializers += JsPropertyInitializer(JsNameRef("set"), setterBody)
|
||||||
}
|
}
|
||||||
|
|
||||||
statements += JsAstUtils.defineProperty(qualifier, name, propertyLiteral, context.program).makeStmt()
|
statements += JsAstUtils.defineProperty(qualifier, name, propertyLiteral, context.program).exportStatement(declaration)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getLocalPackageReference(packageName: FqName): JsExpression {
|
private fun getLocalPackageReference(packageName: FqName): JsExpression {
|
||||||
@@ -142,6 +147,10 @@ internal class DeclarationExporter(val context: StaticContext) {
|
|||||||
}
|
}
|
||||||
return name.makeRef()
|
return name.makeRef()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun JsExpression.exportStatement(declaration: DeclarationDescriptor) = JsExpressionStatement(this).also {
|
||||||
|
it.exportedTag = context.getTag(declaration)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun MemberDescriptor.shouldBeExported(force: Boolean) =
|
private fun MemberDescriptor.shouldBeExported(force: Boolean) =
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ public final class StaticContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private String getTag(@NotNull DeclarationDescriptor descriptor) {
|
public String getTag(@NotNull DeclarationDescriptor descriptor) {
|
||||||
String tag;
|
String tag;
|
||||||
if (!tagCache.containsKey(descriptor)) {
|
if (!tagCache.containsKey(descriptor)) {
|
||||||
tag = SignatureUtilsKt.generateSignature(descriptor);
|
tag = SignatureUtilsKt.generateSignature(descriptor);
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
|||||||
import org.jetbrains.kotlin.js.backend.ast.*
|
import org.jetbrains.kotlin.js.backend.ast.*
|
||||||
import org.jetbrains.kotlin.js.backend.ast.metadata.coroutineMetadata
|
import org.jetbrains.kotlin.js.backend.ast.metadata.coroutineMetadata
|
||||||
import org.jetbrains.kotlin.js.backend.ast.metadata.exportedPackage
|
import org.jetbrains.kotlin.js.backend.ast.metadata.exportedPackage
|
||||||
|
import org.jetbrains.kotlin.js.backend.ast.metadata.exportedTag
|
||||||
import org.jetbrains.kotlin.js.translate.context.Namer
|
import org.jetbrains.kotlin.js.translate.context.Namer
|
||||||
import org.jetbrains.kotlin.js.translate.utils.JsAstUtils
|
import org.jetbrains.kotlin.js.translate.utils.JsAstUtils
|
||||||
|
|
||||||
@@ -35,6 +36,7 @@ class Merger(private val rootFunction: JsFunction, val internalModuleName: JsNam
|
|||||||
private val classes = mutableMapOf<JsName, JsClassModel>()
|
private val classes = mutableMapOf<JsName, JsClassModel>()
|
||||||
private val importedModulesImpl = mutableListOf<JsImportedModule>()
|
private val importedModulesImpl = mutableListOf<JsImportedModule>()
|
||||||
private val exportedPackages = mutableMapOf<String, JsName>()
|
private val exportedPackages = mutableMapOf<String, JsName>()
|
||||||
|
private val exportedTags = mutableSetOf<String>()
|
||||||
|
|
||||||
// Add declaration and initialization statements from program fragment to resulting single program
|
// Add declaration and initialization statements from program fragment to resulting single program
|
||||||
fun addFragment(fragment: JsProgramFragment) {
|
fun addFragment(fragment: JsProgramFragment) {
|
||||||
@@ -100,6 +102,10 @@ class Merger(private val rootFunction: JsFunction, val internalModuleName: JsNam
|
|||||||
exportedPackages[exportedPackage] = localName
|
exportedPackages[exportedPackage] = localName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (statement is JsExpressionStatement) {
|
||||||
|
val exportedTag = statement.exportedTag
|
||||||
|
if (exportedTag != null && !exportedTags.add(exportedTag)) continue
|
||||||
|
}
|
||||||
exportBlock.statements += nameMap.rename(statement)
|
exportBlock.statements += nameMap.rename(statement)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -553,7 +553,7 @@ public final class JsAstUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static JsStatement defineGetter(
|
public static JsExpression defineGetter(
|
||||||
@NotNull JsProgram program,
|
@NotNull JsProgram program,
|
||||||
@NotNull JsExpression receiver,
|
@NotNull JsExpression receiver,
|
||||||
@NotNull String name,
|
@NotNull String name,
|
||||||
@@ -561,7 +561,7 @@ public final class JsAstUtils {
|
|||||||
) {
|
) {
|
||||||
JsObjectLiteral propertyLiteral = new JsObjectLiteral(true);
|
JsObjectLiteral propertyLiteral = new JsObjectLiteral(true);
|
||||||
propertyLiteral.getPropertyInitializers().add(new JsPropertyInitializer(new JsNameRef("get"), body));
|
propertyLiteral.getPropertyInitializers().add(new JsPropertyInitializer(new JsNameRef("get"), body));
|
||||||
return defineProperty(receiver, name, propertyLiteral, program).makeStmt();
|
return defineProperty(receiver, name, propertyLiteral, program);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
// PROPERTY_WRITE_COUNT: name=foo_61zpoe$ count=1
|
||||||
|
// FILE: a.kt
|
||||||
|
fun foo(x: String): String = x
|
||||||
|
|
||||||
|
inline fun o() = foo("O")
|
||||||
|
|
||||||
|
// FILE: b.kt
|
||||||
|
inline fun k() = foo("K")
|
||||||
|
|
||||||
|
// FILE: c.kt
|
||||||
|
// RECOMPILE
|
||||||
|
fun box() = o() + k()
|
||||||
Reference in New Issue
Block a user