File tree 3 files changed +23
-1
lines changed
compiler/src/dotty/tools/backend/sjs
3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -3695,6 +3695,15 @@ class JSCodeGen()(using genCtx: Context) {
3695
3695
// BoxedUnit.UNIT, which is the boxed version of ()
3696
3696
js.Undefined ()
3697
3697
3698
+ case JS_IMPORT =>
3699
+ // js.import(arg)
3700
+ val arg = genArgs1
3701
+ js.JSImportCall (arg)
3702
+
3703
+ case JS_IMPORT_META =>
3704
+ // js.import.meta
3705
+ js.JSImportMeta ()
3706
+
3698
3707
case JS_NATIVE =>
3699
3708
// js.native
3700
3709
report.error(
Original file line number Diff line number Diff line change @@ -145,6 +145,13 @@ final class JSDefinitions()(using Context) {
145
145
@ threadUnsafe lazy val JSConstructorTag_materializeR = JSConstructorTagModule .requiredMethodRef(" materialize" )
146
146
def JSConstructorTag_materialize (using Context ) = JSConstructorTag_materializeR .symbol
147
147
148
+ @ threadUnsafe lazy val JSImportModuleRef = requiredModuleRef(" scala.scalajs.js.import" )
149
+ def JSImportModule (using Context ) = JSImportModuleRef .symbol
150
+ @ threadUnsafe lazy val JSImport_applyR = JSImportModule .requiredMethodRef(nme.apply)
151
+ def JSImport_apply (using Context ) = JSImport_applyR .symbol
152
+ @ threadUnsafe lazy val JSImport_metaR = JSImportModule .requiredMethodRef(" meta" )
153
+ def JSImport_meta (using Context ) = JSImport_metaR .symbol
154
+
148
155
@ threadUnsafe lazy val RuntimePackageVal = requiredPackage(" scala.scalajs.runtime" )
149
156
@ threadUnsafe lazy val RuntimePackageClass = RuntimePackageVal .moduleClass.asClass
150
157
@ threadUnsafe lazy val RuntimePackage_wrapJavaScriptExceptionR = RuntimePackageClass .requiredMethodRef(" wrapJavaScriptException" )
Original file line number Diff line number Diff line change @@ -27,7 +27,10 @@ object JSPrimitives {
27
27
28
28
final val UNITVAL = JS_NATIVE + 1 // () value, which is undefined
29
29
30
- final val CONSTRUCTOROF = UNITVAL + 1 // runtime.constructorOf(clazz)
30
+ final val JS_IMPORT = UNITVAL + 1 // js.import.apply(specifier)
31
+ final val JS_IMPORT_META = JS_IMPORT + 1 // js.import.meta
32
+
33
+ final val CONSTRUCTOROF = JS_IMPORT_META + 1 // runtime.constructorOf(clazz)
31
34
final val CREATE_INNER_JS_CLASS = CONSTRUCTOROF + 1 // runtime.createInnerJSClass
32
35
final val CREATE_LOCAL_JS_CLASS = CREATE_INNER_JS_CLASS + 1 // runtime.createLocalJSClass
33
36
final val WITH_CONTEXTUAL_JS_CLASS_VALUE = CREATE_LOCAL_JS_CLASS + 1 // runtime.withContextualJSClassValue
@@ -106,6 +109,9 @@ class JSPrimitives(ictx: Context) extends DottyPrimitives(ictx) {
106
109
107
110
addPrimitive(defn.BoxedUnit_UNIT , UNITVAL )
108
111
112
+ addPrimitive(jsdefn.JSImport_apply , JS_IMPORT )
113
+ addPrimitive(jsdefn.JSImport_meta , JS_IMPORT_META )
114
+
109
115
addPrimitive(jsdefn.Runtime_constructorOf , CONSTRUCTOROF )
110
116
addPrimitive(jsdefn.Runtime_createInnerJSClass , CREATE_INNER_JS_CLASS )
111
117
addPrimitive(jsdefn.Runtime_createLocalJSClass , CREATE_LOCAL_JS_CLASS )
You can’t perform that action at this time.
0 commit comments