});
def(AST_Await, function(compressor) {
if (!compressor.option("awaits")) return this;
- var exp = this.expression.drop_side_effect_free(compressor);
- if (exp === this.expression) return this;
+ var exp = this.expression;
+ if (!is_primitive(compressor, exp)) return this;
var node = this.clone();
- node.expression = exp || make_node(AST_Number, this, { value: 0 });
+ node.expression = exp.drop_side_effect_free(compressor) || make_node(AST_Number, this, { value: 0 });
return node;
});
def(AST_Binary, function(compressor, first_in_statement) {
|| node instanceof AST_Object;
}
+ function is_primitive(compressor, node) {
+ if (node.is_constant()) return true;
+ if (node instanceof AST_Assign) return node.operator != "=" || is_primitive(compressor, node.right);
+ if (node instanceof AST_Binary) {
+ return !lazy_op[node.operator]
+ || is_primitive(compressor, node.left) && is_primitive(compressor, node.right);
+ }
+ if (node instanceof AST_Conditional) {
+ return is_primitive(compressor, node.consequent) && is_primitive(compressor, node.alternative);
+ }
+ if (node instanceof AST_Sequence) return is_primitive(compressor, node.tail_node());
+ if (node instanceof AST_SymbolRef) {
+ var fixed = node.fixed_value();
+ return fixed && is_primitive(compressor, fixed);
+ }
+ if (node instanceof AST_Template) return !node.tag || is_raw_tag(compressor, node.tag);
+ if (node instanceof AST_Unary) return true;
+ }
+
function repeatable(compressor, node) {
if (node instanceof AST_Dot) return repeatable(compressor, node.expression);
if (node instanceof AST_Sub) {