зеркало из https://github.com/mozilla/gecko-dev.git
Bug 864600 - OdinMonkey: change doublish to double in overload set of ~~ and - (r=sstangl)
--HG-- extra : rebase_source : 4e49e0f060e752049bee8fb8b24fc2bdc91d6c5a
This commit is contained in:
Родитель
b6eb99321f
Коммит
1a13eccebb
|
@ -3514,14 +3514,14 @@ CheckCoerceToInt(FunctionCompiler &f, ParseNode *expr, MDefinition **def, Type *
|
|||
if (!CheckExpr(f, operand, Use::ToInt32, &operandDef, &operandType))
|
||||
return false;
|
||||
|
||||
if (operandType.isDoublish()) {
|
||||
if (operandType.isDouble()) {
|
||||
*def = f.unary<MTruncateToInt32>(operandDef);
|
||||
*type = Type::Signed;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!operandType.isIntish())
|
||||
return f.fail("Operand to ~ must be intish or doublish", operand);
|
||||
return f.fail("Operand to ~ must be intish or double", operand);
|
||||
|
||||
*def = operandDef;
|
||||
*type = Type::Signed;
|
||||
|
@ -3708,19 +3708,14 @@ CheckAddOrSub(FunctionCompiler &f, ParseNode *expr, Use use, MDefinition **def,
|
|||
return true;
|
||||
}
|
||||
|
||||
if (expr->isKind(PNK_ADD) && lhsType.isDouble() && rhsType.isDouble()) {
|
||||
*def = f.binary<MAdd>(lhsDef, rhsDef, MIRType_Double);
|
||||
*type = Type::Double;
|
||||
return true;
|
||||
}
|
||||
if (!lhsType.isDouble() || !rhsType.isDouble())
|
||||
return f.fail("Arguments to + or - must both be ints or doubles", expr);
|
||||
|
||||
if (expr->isKind(PNK_SUB) && lhsType.isDoublish() && rhsType.isDoublish()) {
|
||||
*def = f.binary<MSub>(lhsDef, rhsDef, MIRType_Double);
|
||||
*type = Type::Double;
|
||||
return true;
|
||||
}
|
||||
|
||||
return f.fail("Arguments to + or - must both be ints or doubles", expr);
|
||||
*def = expr->isKind(PNK_ADD)
|
||||
? f.binary<MAdd>(lhsDef, rhsDef, MIRType_Double)
|
||||
: f.binary<MSub>(lhsDef, rhsDef, MIRType_Double);
|
||||
*type = Type::Double;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
|
@ -247,8 +247,8 @@ assertEq(f(-5,false), 1);
|
|||
|
||||
assertAsmTypeFail('glob','imp','b', USE_ASM + HEAP_IMPORTS + "function f() { return (i32[0]+1)|0 } return f");
|
||||
assertAsmTypeFail('glob','imp','b', USE_ASM + HEAP_IMPORTS + "function f() { return +(f64[0] + 1.0); } return f");
|
||||
assertAsmTypeFail('glob','imp','b', USE_ASM + HEAP_IMPORTS + "function f() { return +(f64[0] - 1.0); } return f");
|
||||
new Float64Array(BUF_64KB)[0] = 2.3;
|
||||
assertEq(asmLink(asmCompile('glob','imp','b', USE_ASM + HEAP_IMPORTS + "function f() { return +(f64[0] - 1.0) } return f"), this, null, BUF_64KB)(), 2.3-1);
|
||||
assertEq(asmLink(asmCompile('glob','imp','b', USE_ASM + HEAP_IMPORTS + "function f() { return +(f64[0] * 2.0) } return f"), this, null, BUF_64KB)(), 2.3*2);
|
||||
assertEq(asmLink(asmCompile('glob','imp','b', USE_ASM + HEAP_IMPORTS + "function f() { return +(f64[0] / 2.0) } return f"), this, null, BUF_64KB)(), 2.3/2);
|
||||
assertEq(asmLink(asmCompile('glob','imp','b', USE_ASM + HEAP_IMPORTS + "function f() { return +(f64[0] % 2.0) } return f"), this, null, BUF_64KB)(), 2.3%2);
|
||||
|
|
|
@ -82,7 +82,7 @@ assertEq(f(0x7f),0x7f);
|
|||
assertEq(f(0xff),0xff);
|
||||
assertEq(f(0x100),0);
|
||||
|
||||
var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i,j) {i=i|0;j=+j; f64[i>>3] = j; return (~~f64[i>>3])|0}; return f');
|
||||
var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i,j) {i=i|0;j=+j; f64[i>>3] = j; return (~~+f64[i>>3])|0}; return f');
|
||||
var f = asmLink(code, this, null, new ArrayBuffer(4096));
|
||||
assertEq(f(0, 1.3), 1);
|
||||
assertEq(f(4088, 2.5), 2);
|
||||
|
|
Загрузка…
Ссылка в новой задаче