Skip to content

Commit 03e6b54

Browse files
committed
WIP: deserialize JSLinkingInfo to LinkTimeProperty
1 parent bea1c76 commit 03e6b54

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

ir/shared/src/main/scala/org/scalajs/ir/Serializers.scala

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,7 +1263,27 @@ object Serializers {
12631263

12641264
case TagJSNew => JSNew(readTree(), readTreeOrJSSpreads())
12651265
case TagJSPrivateSelect => JSPrivateSelect(readTree(), readFieldIdent())
1266-
case TagJSSelect => JSSelect(readTree(), readTree())
1266+
case TagJSSelect =>
1267+
readTree() match {
1268+
case qualifier: JSLinkingInfo if hacks.use16 =>
1269+
readTree() match {
1270+
case StringLiteral("productionMode") =>
1271+
LinkTimeProperty("core/productionMode")(BooleanType)
1272+
case StringLiteral("esVersion") =>
1273+
LinkTimeProperty("core/esVersion")(IntType)
1274+
case StringLiteral("assumingES6") =>
1275+
LinkTimeProperty("core/assumingES6")(BooleanType)
1276+
case StringLiteral("isWebAssembly") =>
1277+
LinkTimeProperty("core/isWebAssembly")(BooleanType)
1278+
case StringLiteral("version") =>
1279+
LinkTimeProperty("core/linkerVersion")(StringType)
1280+
case item =>
1281+
throw new IOException(
1282+
s"Found invalid field access ${item.show} on JSLinkingInfo.")
1283+
}
1284+
case qualifier =>
1285+
JSSelect(qualifier, readTree())
1286+
}
12671287
case TagJSFunctionApply => JSFunctionApply(readTree(), readTreeOrJSSpreads())
12681288
case TagJSMethodApply => JSMethodApply(readTree(), readTree(), readTreeOrJSSpreads())
12691289
case TagJSSuperSelect => JSSuperSelect(readTree(), readTree(), readTree())
@@ -1283,8 +1303,19 @@ object Serializers {
12831303
JSObjectConstr(List.fill(readInt())((readTree(), readTree())))
12841304
case TagJSGlobalRef => JSGlobalRef(readString())
12851305
case TagJSTypeOfGlobalRef => JSTypeOfGlobalRef(readTree().asInstanceOf[JSGlobalRef])
1286-
case TagJSLinkingInfo => JSLinkingInfo()
1287-
1306+
case TagJSLinkingInfo =>
1307+
if (hacks.use16) {
1308+
JSObjectConstr(List(
1309+
(StringLiteral("productionMode"), LinkTimeProperty("core/productionMode")(BooleanType)),
1310+
(StringLiteral("esVersion"), LinkTimeProperty("core/esVersion")(IntType)),
1311+
(StringLiteral("assumingES6"), LinkTimeProperty("core/assumingES6")(BooleanType)),
1312+
(StringLiteral("isWebAssembly"), LinkTimeProperty("core/isWebAssembly")(BooleanType)),
1313+
(StringLiteral("version"), LinkTimeProperty("core/linkerVersion")(StringType))
1314+
))
1315+
} else {
1316+
throw new IOException(
1317+
s"Found invalid pre-1.16 JSLinkingInfo def at ${pos}")
1318+
}
12881319
case TagUndefined => Undefined()
12891320
case TagNull => Null()
12901321
case TagBooleanLiteral => BooleanLiteral(readBoolean())

0 commit comments

Comments
 (0)