Changeset 37408 in webkit for trunk/JavaScriptCore/kjs
- Timestamp:
- Oct 7, 2008, 11:36:41 PM (17 years ago)
- Location:
- trunk/JavaScriptCore/kjs
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/grammar.y
r37405 r37408 1425 1425 static ExpressionNode* makeMultNode(void* globalPtr, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) 1426 1426 { 1427 // these transforms are valid because unary + only does a toNumber1428 // conversion, which * does anyway:1429 expr1 = expr1->stripUnaryPlus(); // +FOO * BAR ==> FOO * BAR1430 expr2 = expr2->stripUnaryPlus(); // FOO * +BAR ==> FOO * BAR1431 1432 1427 if (expr1->isNumber() && expr2->isNumber()) 1433 1428 return makeNumberNode(globalPtr, static_cast<NumberNode*>(expr1)->value() * static_cast<NumberNode*>(expr2)->value()); 1434 1435 // these transforms are valid because multiplying by 1 has no1436 // effect but toNumber conversion1437 if (expr1->isNumber() && static_cast<NumberNode*>(expr1)->value() == 1)1438 return new UnaryPlusNode(GLOBAL_DATA, expr2); // 1 * FOO ==> +FOO1439 if (expr2->isNumber() && static_cast<NumberNode*>(expr2)->value() == 1)1440 return new UnaryPlusNode(GLOBAL_DATA, expr1); // FOO * 1 ==> +FOO1441 1442 1429 return new MultNode(GLOBAL_DATA, expr1, expr2, rightHasAssignments); 1443 1430 } … … 1445 1432 static ExpressionNode* makeDivNode(void* globalPtr, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) 1446 1433 { 1447 // these transforms are valid because unary + only does a toNumber1448 // conversion, which / does anyway:1449 expr1 = expr1->stripUnaryPlus(); // +FOO / BAR ==> FOO / BAR1450 expr2 = expr2->stripUnaryPlus(); // FOO / +BAR ==> FOO / BAR1451 1452 1434 if (expr1->isNumber() && expr2->isNumber()) 1453 1435 return makeNumberNode(globalPtr, static_cast<NumberNode*>(expr1)->value() / static_cast<NumberNode*>(expr2)->value()); … … 1464 1446 static ExpressionNode* makeSubNode(void* globalPtr, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) 1465 1447 { 1466 // these transforms are valid because unary + only does a toNumber1467 // conversion, which - does anyway:1468 expr1 = expr1->stripUnaryPlus(); // +FOO - BAR ==> FOO - BAR1469 expr2 = expr2->stripUnaryPlus(); // FOO - +BAR ==> FOO - BAR1470 1471 1448 if (expr1->isNumber() && expr2->isNumber()) 1472 1449 return makeNumberNode(globalPtr, static_cast<NumberNode*>(expr1)->value() - static_cast<NumberNode*>(expr2)->value()); -
trunk/JavaScriptCore/kjs/nodes.h
r37405 r37408 227 227 virtual bool isDotAccessorNode() const JSC_FAST_CALL { return false; } 228 228 229 virtual ExpressionNode* stripUnaryPlus() { return this; }230 231 229 ResultType resultDescriptor() const JSC_FAST_CALL { return m_resultDesc; } 232 230 … … 1181 1179 { 1182 1180 } 1183 1184 virtual ExpressionNode* stripUnaryPlus() { return m_expr.get(); }1185 1181 1186 1182 virtual OpcodeID opcode() const JSC_FAST_CALL { return op_to_jsnumber; }
Note:
See TracChangeset
for help on using the changeset viewer.