Fixing exception when evaluate regualr exceptions.

This commit is contained in:
Xiaoyi Shi 2013-06-06 22:57:34 +08:00
parent b9fea8e7e9
commit 1bc9ddea7e

View File

@ -168,7 +168,9 @@ merge(Compressor.prototype, {
return make_node(AST_Null, orig).optimize(compressor);
}
if (val instanceof RegExp) {
return make_node(AST_RegExp, orig).optimize(compressor);
return make_node(AST_RegExp, orig, {
value: val
}).optimize(compressor);
}
throw new Error(string_template("Can't handle constant of type: {type}", {
type: typeof val
@ -909,7 +911,11 @@ merge(Compressor.prototype, {
var value = def.value.evaluate(compressor, true);
def.value = value[0];
if (value.length > 1) {
if (!(typeof value[1] === 'string' && value[1].length >= inlineStringThreshold))
if (typeof value[1] === 'string' && value[1].length < inlineStringThreshold
|| typeof value[1] === 'number'
|| typeof value[1] === 'boolean'
|| value[1] === null
)
definitions[def.name.name] = value[1];
}
}