[dart2wasm] Allow JS() to accept a constant template
Change-Id: I1baf01c5a5744251727d7fba2871f0b36a6a6964 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466132 Reviewed-by: Nate Biggs <natebiggs@google.com> Commit-Queue: Mayank Patke <fishythefish@google.com>
This commit is contained in:
committed by
Commit Queue
parent
86ba5040d9
commit
b976f6c69b
@@ -94,9 +94,20 @@ class InlineExpander {
|
||||
}
|
||||
}
|
||||
|
||||
assert(arguments.positional[0] is StringLiteral,
|
||||
"Code template must be a StringLiteral");
|
||||
String codeTemplate = (arguments.positional[0] as StringLiteral).value;
|
||||
Expression templateArgument = arguments.positional.first;
|
||||
String codeTemplate;
|
||||
if (templateArgument is StringLiteral) {
|
||||
codeTemplate = templateArgument.value;
|
||||
} else {
|
||||
assert(templateArgument is ConstantExpression,
|
||||
"Code template must be a StringLiteral or a ConstantExpression");
|
||||
templateArgument as ConstantExpression;
|
||||
Constant constant = templateArgument.constant;
|
||||
assert(constant is StringConstant,
|
||||
"Constant code template must be a StringConstant");
|
||||
constant as StringConstant;
|
||||
codeTemplate = constant.value;
|
||||
}
|
||||
String jsMethodName = _methodCollector.generateMethodName();
|
||||
_inlineJSImportName = 'dart2wasm.$jsMethodName';
|
||||
_replaceProcedureWithInlineJS =
|
||||
|
||||
Reference in New Issue
Block a user