Skip to content
This repository was archived by the owner on Jul 12, 2024. It is now read-only.

Commit 405ec4a

Browse files
authored
Merge pull request #129 from sjrd/instructions-pascal-case
Use PascalCase for Wasm Instructions.
2 parents 10762f0 + f75bdba commit 405ec4a

File tree

10 files changed

+1344
-1372
lines changed

10 files changed

+1344
-1372
lines changed

Diff for: wasm/src/main/scala/org/scalajs/linker/backend/wasmemitter/ClassEmitter.scala

+123-123
Large diffs are not rendered by default.

Diff for: wasm/src/main/scala/org/scalajs/linker/backend/wasmemitter/CoreWasmLib.scala

+521-521
Large diffs are not rendered by default.

Diff for: wasm/src/main/scala/org/scalajs/linker/backend/wasmemitter/Emitter.scala

+28-28
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ final class Emitter(config: Emitter.Config) {
9999
watpe.RefType(genTypeName.anyArray),
100100
wamod.Expr(
101101
List(
102-
wa.I32_CONST(stringPoolCount),
103-
wa.ARRAY_NEW_DEFAULT(genTypeName.anyArray)
102+
wa.I32Const(stringPoolCount),
103+
wa.ArrayNewDefault(genTypeName.anyArray)
104104
)
105105
),
106106
isMutable = false
@@ -131,13 +131,13 @@ final class Emitter(config: Emitter.Config) {
131131

132132
interfaces.foreach { iface =>
133133
val idx = ctx.getItableIdx(iface)
134-
instrs += wa.GLOBAL_GET(genGlobalName.forITable(className))
135-
instrs += wa.I32_CONST(idx)
134+
instrs += wa.GlobalGet(genGlobalName.forITable(className))
135+
instrs += wa.I32Const(idx)
136136

137137
for (method <- iface.tableEntries)
138138
instrs += ctx.refFuncWithDeclaration(resolvedMethodInfos(method).tableEntryName)
139-
instrs += wa.STRUCT_NEW(genTypeName.forITable(iface.name))
140-
instrs += wa.ARRAY_SET(genTypeName.itables)
139+
instrs += wa.StructNew(genTypeName.forITable(iface.name))
140+
instrs += wa.ArraySet(genTypeName.itables)
141141
}
142142
}
143143

@@ -151,21 +151,21 @@ final class Emitter(config: Emitter.Config) {
151151
// Use getClassInfoOption in case the reachability analysis got rid of those interfaces
152152
interfaceInfo <- ctx.getClassInfoOption(interfaceName)
153153
} {
154-
instrs += wa.GLOBAL_GET(globalName)
155-
instrs += wa.I32_CONST(ctx.getItableIdx(interfaceInfo))
154+
instrs += wa.GlobalGet(globalName)
155+
instrs += wa.I32Const(ctx.getItableIdx(interfaceInfo))
156156

157157
for (method <- interfaceInfo.tableEntries)
158158
instrs += ctx.refFuncWithDeclaration(resolvedMethodInfos(method).tableEntryName)
159-
instrs += wa.STRUCT_NEW(genTypeName.forITable(interfaceName))
160-
instrs += wa.ARRAY_SET(genTypeName.itables)
159+
instrs += wa.StructNew(genTypeName.forITable(interfaceName))
160+
instrs += wa.ArraySet(genTypeName.itables)
161161
}
162162
}
163163

164164
// Initialize the JS private field symbols
165165

166166
for (fieldName <- ctx.getAllJSPrivateFieldNames()) {
167-
instrs += wa.CALL(genFunctionName.newSymbol)
168-
instrs += wa.GLOBAL_SET(genGlobalName.forJSPrivateField(fieldName))
167+
instrs += wa.Call(genFunctionName.newSymbol)
168+
instrs += wa.GlobalSet(genGlobalName.forJSPrivateField(fieldName))
169169
}
170170

171171
// Emit the static initializers
@@ -176,7 +176,7 @@ final class Emitter(config: Emitter.Config) {
176176
className,
177177
StaticInitializerName
178178
)
179-
instrs += wa.CALL(funcName)
179+
instrs += wa.Call(funcName)
180180
}
181181

182182
// Initialize the top-level exports that require it
@@ -185,28 +185,28 @@ final class Emitter(config: Emitter.Config) {
185185
// Load the (initial) exported value on the stack
186186
tle.tree match {
187187
case TopLevelJSClassExportDef(_, exportName) =>
188-
instrs += wa.CALL(genFunctionName.loadJSClass(tle.owningClass))
188+
instrs += wa.Call(genFunctionName.loadJSClass(tle.owningClass))
189189
case TopLevelModuleExportDef(_, exportName) =>
190-
instrs += wa.CALL(genFunctionName.loadModule(tle.owningClass))
190+
instrs += wa.Call(genFunctionName.loadModule(tle.owningClass))
191191
case TopLevelMethodExportDef(_, methodDef) =>
192192
instrs += ctx.refFuncWithDeclaration(genFunctionName.forExport(tle.exportName))
193193
if (methodDef.restParam.isDefined) {
194-
instrs += wa.I32_CONST(methodDef.args.size)
195-
instrs += wa.CALL(genFunctionName.makeExportedDefRest)
194+
instrs += wa.I32Const(methodDef.args.size)
195+
instrs += wa.Call(genFunctionName.makeExportedDefRest)
196196
} else {
197-
instrs += wa.CALL(genFunctionName.makeExportedDef)
197+
instrs += wa.Call(genFunctionName.makeExportedDef)
198198
}
199199
case TopLevelFieldExportDef(_, _, fieldIdent) =>
200200
/* Usually redundant, but necessary if the static field is never
201201
* explicitly set and keeps its default (zero) value instead. In that
202202
* case this initial call is required to publish that zero value (as
203203
* opposed to the default `undefined` value of the JS `let`).
204204
*/
205-
instrs += wa.GLOBAL_GET(genGlobalName.forStaticField(fieldIdent.name))
205+
instrs += wa.GlobalGet(genGlobalName.forStaticField(fieldIdent.name))
206206
}
207207

208208
// Call the export setter
209-
instrs += wa.CALL(genFunctionName.forTopLevelExportSetter(tle.exportName))
209+
instrs += wa.Call(genFunctionName.forTopLevelExportSetter(tle.exportName))
210210
}
211211

212212
// Emit the module initializers
@@ -215,26 +215,26 @@ final class Emitter(config: Emitter.Config) {
215215
def genCallStatic(className: ClassName, methodName: MethodName): Unit = {
216216
val functionName =
217217
genFunctionName.forMethod(MemberNamespace.PublicStatic, className, methodName)
218-
instrs += wa.CALL(functionName)
218+
instrs += wa.Call(functionName)
219219
}
220220

221221
ModuleInitializerImpl.fromInitializer(init) match {
222222
case ModuleInitializerImpl.MainMethodWithArgs(className, encodedMainMethodName, args) =>
223223
// vtable of Array[String]
224-
instrs += wa.GLOBAL_GET(genGlobalName.forVTable(BoxedStringClass))
225-
instrs += wa.I32_CONST(1)
226-
instrs += wa.CALL(genFunctionName.arrayTypeData)
224+
instrs += wa.GlobalGet(genGlobalName.forVTable(BoxedStringClass))
225+
instrs += wa.I32Const(1)
226+
instrs += wa.Call(genFunctionName.arrayTypeData)
227227

228228
// itable of Array[String]
229-
instrs += wa.GLOBAL_GET(genGlobalName.arrayClassITable)
229+
instrs += wa.GlobalGet(genGlobalName.arrayClassITable)
230230

231231
// underlying array of args
232232
args.foreach(arg => instrs ++= ctx.getConstantStringInstr(arg))
233-
instrs += wa.ARRAY_NEW_FIXED(genTypeName.anyArray, args.size)
233+
instrs += wa.ArrayNewFixed(genTypeName.anyArray, args.size)
234234

235235
// array object
236236
val stringArrayTypeRef = ArrayTypeRef(ClassRef(BoxedStringClass), 1)
237-
instrs += wa.STRUCT_NEW(genTypeName.forArrayClass(stringArrayTypeRef))
237+
instrs += wa.StructNew(genTypeName.forArrayClass(stringArrayTypeRef))
238238

239239
// call
240240
genCallStatic(className, encodedMainMethodName)
@@ -265,7 +265,7 @@ final class Emitter(config: Emitter.Config) {
265265
* introduce these declarations.
266266
*/
267267
val exprs = funcDeclarations.map { name =>
268-
wamod.Expr(List(wa.REF_FUNC(name)))
268+
wamod.Expr(List(wa.RefFunc(name)))
269269
}
270270
ctx.moduleBuilder.addElement(
271271
wamod.Element(watpe.RefType.funcref, exprs, wamod.Element.Mode.Declarative)

0 commit comments

Comments
 (0)