mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 08:07:11 +00:00
[dart2wasm] Improve wasm:class-id pragma error messages
Change-Id: Id9d073557738548d41e6fd90d8973d8e5d5c0748 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/318920 Reviewed-by: Joshua Litt <joshualitt@google.com> Commit-Queue: Ömer Ağacan <omersa@google.com>
This commit is contained in:
parent
b53e0b31ca
commit
e61c6dc620
1 changed files with 10 additions and 6 deletions
|
@ -547,14 +547,18 @@ class Intrinsifier {
|
||||||
Member target = node.target;
|
Member target = node.target;
|
||||||
|
|
||||||
// ClassID getters
|
// ClassID getters
|
||||||
String? className = translator.getPragma(target, "wasm:class-id");
|
String? libAndClassName = translator.getPragma(target, "wasm:class-id");
|
||||||
if (className != null) {
|
if (libAndClassName != null) {
|
||||||
List<String> libAndClass = className.split("#");
|
List<String> libAndClassNameParts = libAndClassName.split("#");
|
||||||
|
final String lib = libAndClassNameParts[0];
|
||||||
|
final String className = libAndClassNameParts[1];
|
||||||
Class cls = translator.libraries
|
Class cls = translator.libraries
|
||||||
.firstWhere(
|
.firstWhere((l) => l.name == lib && l.importUri.scheme == 'dart',
|
||||||
(l) => l.name == libAndClass[0] && l.importUri.scheme == 'dart')
|
orElse: () => throw 'Library $lib not found (${target.location})')
|
||||||
.classes
|
.classes
|
||||||
.firstWhere((c) => c.name == libAndClass[1]);
|
.firstWhere((c) => c.name == className,
|
||||||
|
orElse: () => throw 'Class $className not found in library $lib '
|
||||||
|
'(${target.location})');
|
||||||
int classId = translator.classInfo[cls]!.classId;
|
int classId = translator.classInfo[cls]!.classId;
|
||||||
b.i64_const(classId);
|
b.i64_const(classId);
|
||||||
return w.NumType.i64;
|
return w.NumType.i64;
|
||||||
|
|
Loading…
Reference in a new issue