Changeset 1024 in webkit for trunk/JavaScriptCore/kjs
- Timestamp:
- Apr 15, 2002, 4:43:21 PM (23 years ago)
- Location:
- trunk/JavaScriptCore/kjs
- Files:
-
- 51 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/array_object.cpp
r798 r1024 59 59 for (unsigned int u = newLen; u < oldLen; u++) { 60 60 UString p = UString::from(u); 61 if (has Property(exec, p, false))61 if (hasOwnProperty(exec, p)) 62 62 deleteProperty(exec, p); 63 63 } … … 75 75 76 76 // do we need to update/create the length property ? 77 if (has Property(exec, "length", false)) {77 if (hasOwnProperty(exec, "length")) { 78 78 Value len = get(exec, "length"); 79 79 if (idx < len.toUInt32(exec)) … … 88 88 ObjectImp::put(exec,propertyName,value,attr); 89 89 } 90 91 bool ArrayInstanceImp::hasOwnProperty(ExecState *exec, 92 const UString &propertyName) 93 { 94 // disable this object's prototype temporarily for the hasProperty() call 95 Value protoBackup = prototype(); 96 setPrototype(Undefined()); 97 bool b = hasProperty(exec, propertyName); 98 setPrototype(protoBackup); 99 return b; 100 } 101 90 102 // ------------------------------ ArrayPrototypeImp ---------------------------- 91 103 -
trunk/JavaScriptCore/kjs/array_object.h
r798 r1024 18 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 * 20 * $Id$21 20 */ 22 21 … … 35 34 virtual void put(ExecState *exec, const UString &propertyName, const Value &value, int attr = None); 36 35 virtual void putDirect(ExecState *exec, const UString &propertyName, const Value &value, int attr = None); 36 /** 37 * A shallow hasProperty() variant that doesn't look at the prototype's 38 * properties. 39 */ 40 virtual bool hasOwnProperty(ExecState *exec, const UString &propertyName); 37 41 38 42 virtual const ClassInfo *classInfo() const { return &info; } -
trunk/JavaScriptCore/kjs/bool_object.h
r798 r1024 18 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 * 20 * $Id$21 20 */ 22 21 -
trunk/JavaScriptCore/kjs/collector.cpp
r798 r1024 19 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 20 * 21 * $Id$22 21 */ 23 22 -
trunk/JavaScriptCore/kjs/collector.h
r798 r1024 19 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 20 * 21 * $Id$22 21 */ 23 22 … … 81 80 82 81 #ifdef KJS_DEBUG_MEM 83 /** Check that nothing is left when the last interpreter gets deleted */ 82 /** 83 * Check that nothing is left when the last interpreter gets deleted 84 */ 84 85 static void finalCheck(); 85 86 /** -
trunk/JavaScriptCore/kjs/date_object.cpp
r798 r1024 18 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 * 20 * $Id$21 20 */ 22 21 … … 175 174 const int bufsize=100; 176 175 char timebuffer[bufsize]; 177 char *oldlocale = setlocale(LC_TIME,NULL);178 if (!oldlocale )176 CString oldlocale = setlocale(LC_TIME,NULL); 177 if (!oldlocale.c_str()) 179 178 oldlocale = setlocale(LC_ALL, NULL); 180 179 Value v = thisObj.internalValue(); … … 206 205 strftime(timebuffer, bufsize, "%a, %d-%b-%y %H:%M:%S %Z", t); 207 206 } 208 setlocale(LC_TIME,oldlocale );207 setlocale(LC_TIME,oldlocale.c_str()); 209 208 result = String(timebuffer); 210 209 break; -
trunk/JavaScriptCore/kjs/date_object.h
r798 r1024 18 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 * 20 * $Id$21 20 */ 22 21 … … 26 25 #include "internal.h" 27 26 #include "function_object.h" 27 28 #include <sys/time.h> 28 29 29 30 namespace KJS { … … 120 121 // helper functions 121 122 Value parseDate(const String &s); 122 time_t KRFCDate_parseDate(const UString &_date); 123 time_t KRFCDate_parseDate(const UString &_date); 123 124 Value timeClip(const Value &t); 124 125 -
trunk/JavaScriptCore/kjs/debugger.cpp
r798 r1024 19 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 20 * 21 * $Id$22 21 */ 23 22 -
trunk/JavaScriptCore/kjs/debugger.h
r798 r1024 19 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 20 * 21 * $Id$22 21 */ 23 22 -
trunk/JavaScriptCore/kjs/error_object.h
r798 r1024 18 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 * 20 * $Id$21 20 */ 22 21 -
trunk/JavaScriptCore/kjs/function.cpp
r798 r1024 58 58 Value protect(this); 59 59 argStack = new ListImp(); 60 Value protectArgStack( argStack ); // this also calls setGcAllowed on argStack 61 //fprintf(stderr,"FunctionImp::FunctionImp this=%p argStack=%p\n"); 60 62 put(exec,"arguments",Null(),ReadOnly|DontDelete|DontEnum); 61 63 } … … 63 65 FunctionImp::~FunctionImp() 64 66 { 65 argStack->setGcAllowed();66 67 // The function shouldn't be deleted while it is still executed; argStack 67 68 // should be set to 0 by the last call to popArgs() 68 assert(argStack->isEmpty()); 69 //assert(argStack->isEmpty()); 70 // Accessing argStack from here is a problem though. 71 // When the function isn't used anymore, it's not marked, and neither is the 72 // argStack, so both can be deleted - in any order! 69 73 delete param; 70 74 } … … 170 174 171 175 *p = new Parameter(n); 176 } 177 178 UString FunctionImp::parameterString() const 179 { 180 UString s; 181 const Parameter * const *p = ¶m; 182 while (*p) { 183 if (!s.isEmpty()) 184 s += ", "; 185 s += (*p)->name; 186 p = &(*p)->next; 187 } 188 189 return s; 172 190 } 173 191 -
trunk/JavaScriptCore/kjs/function.h
r798 r1024 19 19 * Boston, MA 02111-1307, USA. 20 20 * 21 * $Id$22 21 */ 23 22 … … 47 46 48 47 void addParameter(const UString &n); 48 // parameters in string representation, e.g. (a, b, c) 49 UString parameterString() const; 49 50 virtual CodeType codeType() const = 0; 50 51 -
trunk/JavaScriptCore/kjs/function_object.cpp
r798 r1024 84 84 case ToString: { 85 85 // ### also make this work for internal functions 86 // ### return the text of the function body (see 15.3.4.2)87 86 if (thisObj.isNull() || !thisObj.inherits(&InternalFunctionImp::info)) { 88 87 #ifndef NDEBUG … … 93 92 return err; 94 93 } 95 if (thisObj.inherits(&FunctionImp::info) && 94 if (thisObj.inherits(&DeclaredFunctionImp::info)) { 95 DeclaredFunctionImp *fi = static_cast<DeclaredFunctionImp*> 96 (thisObj.imp()); 97 return String("function " + fi->name() + "(" + 98 fi->parameterString() + ") " + fi->body->toString()); 99 } else if (thisObj.inherits(&FunctionImp::info) && 96 100 !static_cast<FunctionImp*>(thisObj.imp())->name().isNull()) { 97 101 result = String("function " + static_cast<FunctionImp*>(thisObj.imp())->name() + "()"); … … 127 131 Object argArrayObj = Object::dynamicCast(argArray); 128 132 unsigned int length = argArrayObj.get(exec,"length").toUInt32(exec); 129 for (u int i = 0; i < length; i++)133 for (unsigned int i = 0; i < length; i++) 130 134 applyArgs.append(argArrayObj.get(exec,UString::from(i))); 131 135 } -
trunk/JavaScriptCore/kjs/function_object.h
r798 r1024 18 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 * 20 * $Id$21 20 */ 22 21 -
trunk/JavaScriptCore/kjs/grammar.cpp
r903 r1024 318 318 180, 181, 182, 183, 186, 188, 189, 192, 194, 198, 319 319 200, 203, 205, 208, 210, 214, 217, 218, 221, 223, 320 224, 225, 227, 230, 232, 235, 237, 238, 239, 24 2,321 24 4, 247, 249, 252, 254, 257, 259, 260, 263, 265,322 26 6, 267, 268, 269, 270, 271, 272, 273, 274, 275,323 27 8, 280, 281, 282, 285, 287, 288, 291, 293, 294,324 29 5, 298, 300, 302, 304, 306, 308, 310, 314, 316,325 31 7, 318, 319, 322, 324, 327, 329, 332, 334, 337,326 3 39, 343, 345, 349, 351, 355, 357, 361, 363, 364,327 36 5, 366, 367, 368, 369, 370, 371, 372, 373, 376,328 37 8, 381, 383, 384, 385, 386, 387, 388, 389, 390,329 39 1, 392, 393, 394, 395, 398, 400, 403, 405, 408,330 41 1, 420, 422, 426, 428, 431, 435, 439, 442, 449,331 45 1, 455, 457, 458, 461, 464, 467, 471, 477, 479,332 48 2, 484, 488, 490, 497, 499, 503, 505, 513, 515,333 5 19, 520, 526, 531, 536, 538, 542, 544, 547, 549,334 55 2, 554, 557, 559, 562, 568, 572, 574, 575, 578,335 58 2, 586, 589, 593, 595, 600, 602, 606, 609, 613,336 61 6, 620, 622, 625, 627320 224, 225, 227, 230, 232, 235, 237, 238, 239, 243, 321 245, 248, 250, 253, 255, 258, 260, 261, 264, 266, 322 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 323 279, 281, 282, 283, 286, 288, 289, 292, 294, 295, 324 296, 299, 301, 303, 305, 307, 309, 311, 315, 317, 325 318, 319, 320, 323, 325, 328, 330, 333, 335, 338, 326 340, 344, 346, 350, 352, 356, 358, 362, 364, 365, 327 366, 367, 368, 369, 370, 371, 372, 373, 374, 377, 328 379, 382, 384, 385, 386, 387, 388, 389, 390, 391, 329 392, 393, 394, 395, 396, 399, 401, 404, 406, 409, 330 412, 421, 423, 427, 429, 432, 436, 440, 443, 450, 331 452, 456, 458, 459, 462, 465, 468, 472, 478, 480, 332 483, 485, 489, 491, 498, 500, 504, 506, 514, 516, 333 520, 521, 527, 532, 537, 539, 543, 545, 548, 550, 334 553, 555, 558, 560, 563, 569, 573, 575, 576, 579, 335 583, 587, 590, 594, 596, 601, 603, 607, 610, 614, 336 617, 621, 623, 626, 628 337 337 }; 338 338 #endif … … 1467 1467 case 39: 1468 1468 #line 239 "grammar.y" 1469 { yyval.node = new AccessorNode2(yyvsp[-2].node, yyvsp[0].ustr); ; 1469 { yyval.node = new AccessorNode2(yyvsp[-2].node, yyvsp[0].ustr); 1470 delete yyvsp[0].ustr; ; 1470 1471 break;} 1471 1472 case 40: 1472 #line 24 3"grammar.y"1473 #line 244 "grammar.y" 1473 1474 { yyval.args = new ArgumentsNode(0L); ; 1474 1475 break;} 1475 1476 case 41: 1476 #line 24 4"grammar.y"1477 #line 245 "grammar.y" 1477 1478 { yyval.args = new ArgumentsNode(yyvsp[-1].alist); ; 1478 1479 break;} 1479 1480 case 42: 1480 #line 24 8"grammar.y"1481 #line 249 "grammar.y" 1481 1482 { yyval.alist = new ArgumentListNode(yyvsp[0].node); ; 1482 1483 break;} 1483 1484 case 43: 1484 #line 2 49"grammar.y"1485 #line 250 "grammar.y" 1485 1486 { yyval.alist = new ArgumentListNode(yyvsp[-2].alist, yyvsp[0].node); ; 1486 1487 break;} 1487 1488 case 47: 1488 #line 2 59"grammar.y"1489 #line 260 "grammar.y" 1489 1490 { yyval.node = new PostfixNode(yyvsp[-1].node, OpPlusPlus); ; 1490 1491 break;} 1491 1492 case 48: 1492 #line 26 0"grammar.y"1493 #line 261 "grammar.y" 1493 1494 { yyval.node = new PostfixNode(yyvsp[-1].node, OpMinusMinus); ; 1494 1495 break;} 1495 1496 case 50: 1496 #line 26 5"grammar.y"1497 #line 266 "grammar.y" 1497 1498 { yyval.node = new DeleteNode(yyvsp[0].node); ; 1498 1499 break;} 1499 1500 case 51: 1500 #line 26 6"grammar.y"1501 #line 267 "grammar.y" 1501 1502 { yyval.node = new VoidNode(yyvsp[0].node); ; 1502 1503 break;} 1503 1504 case 52: 1504 #line 26 7"grammar.y"1505 #line 268 "grammar.y" 1505 1506 { yyval.node = new TypeOfNode(yyvsp[0].node); ; 1506 1507 break;} 1507 1508 case 53: 1508 #line 268 "grammar.y"1509 { yyval.node = new PrefixNode(OpPlusPlus, yyvsp[0].node); ;1510 break;}1511 case 54:1512 1509 #line 269 "grammar.y" 1513 1510 { yyval.node = new PrefixNode(OpPlusPlus, yyvsp[0].node); ; 1514 1511 break;} 1512 case 54: 1513 #line 270 "grammar.y" 1514 { yyval.node = new PrefixNode(OpPlusPlus, yyvsp[0].node); ; 1515 break;} 1515 1516 case 55: 1516 #line 270 "grammar.y"1517 { yyval.node = new PrefixNode(OpMinusMinus, yyvsp[0].node); ;1518 break;}1519 case 56:1520 1517 #line 271 "grammar.y" 1521 1518 { yyval.node = new PrefixNode(OpMinusMinus, yyvsp[0].node); ; 1522 1519 break;} 1520 case 56: 1521 #line 272 "grammar.y" 1522 { yyval.node = new PrefixNode(OpMinusMinus, yyvsp[0].node); ; 1523 break;} 1523 1524 case 57: 1524 #line 27 2"grammar.y"1525 #line 273 "grammar.y" 1525 1526 { yyval.node = new UnaryPlusNode(yyvsp[0].node); ; 1526 1527 break;} 1527 1528 case 58: 1528 #line 27 3"grammar.y"1529 #line 274 "grammar.y" 1529 1530 { yyval.node = new NegateNode(yyvsp[0].node); ; 1530 1531 break;} 1531 1532 case 59: 1532 #line 27 4"grammar.y"1533 #line 275 "grammar.y" 1533 1534 { yyval.node = new BitwiseNotNode(yyvsp[0].node); ; 1534 1535 break;} 1535 1536 case 60: 1536 #line 27 5"grammar.y"1537 #line 276 "grammar.y" 1537 1538 { yyval.node = new LogicalNotNode(yyvsp[0].node); ; 1538 1539 break;} 1539 1540 case 62: 1540 #line 28 0"grammar.y"1541 #line 281 "grammar.y" 1541 1542 { yyval.node = new MultNode(yyvsp[-2].node, yyvsp[0].node, '*'); ; 1542 1543 break;} 1543 1544 case 63: 1544 #line 28 1"grammar.y"1545 #line 282 "grammar.y" 1545 1546 { yyval.node = new MultNode(yyvsp[-2].node, yyvsp[0].node, '/'); ; 1546 1547 break;} 1547 1548 case 64: 1548 #line 28 2"grammar.y"1549 #line 283 "grammar.y" 1549 1550 { yyval.node = new MultNode(yyvsp[-2].node,yyvsp[0].node,'%'); ; 1550 1551 break;} 1551 1552 case 66: 1552 #line 28 7"grammar.y"1553 #line 288 "grammar.y" 1553 1554 { yyval.node = new AddNode(yyvsp[-2].node, yyvsp[0].node, '+'); ; 1554 1555 break;} 1555 1556 case 67: 1556 #line 28 8"grammar.y"1557 #line 289 "grammar.y" 1557 1558 { yyval.node = new AddNode(yyvsp[-2].node, yyvsp[0].node, '-'); ; 1558 1559 break;} 1559 1560 case 69: 1560 #line 29 3"grammar.y"1561 #line 294 "grammar.y" 1561 1562 { yyval.node = new ShiftNode(yyvsp[-2].node, OpLShift, yyvsp[0].node); ; 1562 1563 break;} 1563 1564 case 70: 1564 #line 29 4"grammar.y"1565 #line 295 "grammar.y" 1565 1566 { yyval.node = new ShiftNode(yyvsp[-2].node, OpRShift, yyvsp[0].node); ; 1566 1567 break;} 1567 1568 case 71: 1568 #line 29 5"grammar.y"1569 #line 296 "grammar.y" 1569 1570 { yyval.node = new ShiftNode(yyvsp[-2].node, OpURShift, yyvsp[0].node); ; 1570 1571 break;} 1571 1572 case 73: 1572 #line 30 1"grammar.y"1573 #line 302 "grammar.y" 1573 1574 { yyval.node = new RelationalNode(yyvsp[-2].node, OpLess, yyvsp[0].node); ; 1574 1575 break;} 1575 1576 case 74: 1576 #line 30 3"grammar.y"1577 #line 304 "grammar.y" 1577 1578 { yyval.node = new RelationalNode(yyvsp[-2].node, OpGreater, yyvsp[0].node); ; 1578 1579 break;} 1579 1580 case 75: 1580 #line 30 5"grammar.y"1581 #line 306 "grammar.y" 1581 1582 { yyval.node = new RelationalNode(yyvsp[-2].node, OpLessEq, yyvsp[0].node); ; 1582 1583 break;} 1583 1584 case 76: 1584 #line 30 7"grammar.y"1585 #line 308 "grammar.y" 1585 1586 { yyval.node = new RelationalNode(yyvsp[-2].node, OpGreaterEq, yyvsp[0].node); ; 1586 1587 break;} 1587 1588 case 77: 1588 #line 3 09"grammar.y"1589 #line 310 "grammar.y" 1589 1590 { yyval.node = new RelationalNode(yyvsp[-2].node, OpInstanceOf, yyvsp[0].node); ; 1590 1591 break;} 1591 1592 case 78: 1592 #line 31 1"grammar.y"1593 #line 312 "grammar.y" 1593 1594 { yyval.node = new RelationalNode(yyvsp[-2].node, OpIn, yyvsp[0].node); ; 1594 1595 break;} 1595 1596 case 80: 1596 #line 31 6"grammar.y"1597 #line 317 "grammar.y" 1597 1598 { yyval.node = new EqualNode(yyvsp[-2].node, OpEqEq, yyvsp[0].node); ; 1598 1599 break;} 1599 1600 case 81: 1600 #line 31 7"grammar.y"1601 #line 318 "grammar.y" 1601 1602 { yyval.node = new EqualNode(yyvsp[-2].node, OpNotEq, yyvsp[0].node); ; 1602 1603 break;} 1603 1604 case 82: 1604 #line 31 8"grammar.y"1605 #line 319 "grammar.y" 1605 1606 { yyval.node = new EqualNode(yyvsp[-2].node, OpStrEq, yyvsp[0].node); ; 1606 1607 break;} 1607 1608 case 83: 1608 #line 3 19"grammar.y"1609 #line 320 "grammar.y" 1609 1610 { yyval.node = new EqualNode(yyvsp[-2].node, OpStrNEq, yyvsp[0].node);; 1610 1611 break;} 1611 1612 case 85: 1612 #line 32 4"grammar.y"1613 #line 325 "grammar.y" 1613 1614 { yyval.node = new BitOperNode(yyvsp[-2].node, OpBitAnd, yyvsp[0].node); ; 1614 1615 break;} 1615 1616 case 87: 1616 #line 3 29"grammar.y"1617 #line 330 "grammar.y" 1617 1618 { yyval.node = new BitOperNode(yyvsp[-2].node, OpBitXOr, yyvsp[0].node); ; 1618 1619 break;} 1619 1620 case 89: 1620 #line 33 4"grammar.y"1621 #line 335 "grammar.y" 1621 1622 { yyval.node = new BitOperNode(yyvsp[-2].node, OpBitOr, yyvsp[0].node); ; 1622 1623 break;} 1623 1624 case 91: 1624 #line 34 0"grammar.y"1625 #line 341 "grammar.y" 1625 1626 { yyval.node = new BinaryLogicalNode(yyvsp[-2].node, OpAnd, yyvsp[0].node); ; 1626 1627 break;} 1627 1628 case 93: 1628 #line 34 6"grammar.y"1629 #line 347 "grammar.y" 1629 1630 { yyval.node = new BinaryLogicalNode(yyvsp[-2].node, OpOr, yyvsp[0].node); ; 1630 1631 break;} 1631 1632 case 95: 1632 #line 35 2"grammar.y"1633 #line 353 "grammar.y" 1633 1634 { yyval.node = new ConditionalNode(yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ; 1634 1635 break;} 1635 1636 case 97: 1636 #line 35 8"grammar.y"1637 #line 359 "grammar.y" 1637 1638 { yyval.node = new AssignNode(yyvsp[-2].node, yyvsp[-1].op, yyvsp[0].node);; 1638 1639 break;} 1639 1640 case 98: 1640 #line 36 2"grammar.y"1641 #line 363 "grammar.y" 1641 1642 { yyval.op = OpEqual; ; 1642 1643 break;} 1643 1644 case 99: 1644 #line 36 3"grammar.y"1645 #line 364 "grammar.y" 1645 1646 { yyval.op = OpPlusEq; ; 1646 1647 break;} 1647 1648 case 100: 1648 #line 36 4"grammar.y"1649 #line 365 "grammar.y" 1649 1650 { yyval.op = OpMinusEq; ; 1650 1651 break;} 1651 1652 case 101: 1652 #line 36 5"grammar.y"1653 #line 366 "grammar.y" 1653 1654 { yyval.op = OpMultEq; ; 1654 1655 break;} 1655 1656 case 102: 1656 #line 36 6"grammar.y"1657 #line 367 "grammar.y" 1657 1658 { yyval.op = OpDivEq; ; 1658 1659 break;} 1659 1660 case 103: 1660 #line 36 7"grammar.y"1661 #line 368 "grammar.y" 1661 1662 { yyval.op = OpLShift; ; 1662 1663 break;} 1663 1664 case 104: 1664 #line 36 8"grammar.y"1665 #line 369 "grammar.y" 1665 1666 { yyval.op = OpRShift; ; 1666 1667 break;} 1667 1668 case 105: 1668 #line 3 69"grammar.y"1669 #line 370 "grammar.y" 1669 1670 { yyval.op = OpURShift; ; 1670 1671 break;} 1671 1672 case 106: 1672 #line 37 0"grammar.y"1673 #line 371 "grammar.y" 1673 1674 { yyval.op = OpAndEq; ; 1674 1675 break;} 1675 1676 case 107: 1676 #line 37 1"grammar.y"1677 #line 372 "grammar.y" 1677 1678 { yyval.op = OpXOrEq; ; 1678 1679 break;} 1679 1680 case 108: 1680 #line 37 2"grammar.y"1681 #line 373 "grammar.y" 1681 1682 { yyval.op = OpOrEq; ; 1682 1683 break;} 1683 1684 case 109: 1684 #line 37 3"grammar.y"1685 #line 374 "grammar.y" 1685 1686 { yyval.op = OpModEq; ; 1686 1687 break;} 1687 1688 case 111: 1688 #line 37 8"grammar.y"1689 #line 379 "grammar.y" 1689 1690 { yyval.node = new CommaNode(yyvsp[-2].node, yyvsp[0].node); ; 1690 1691 break;} 1691 1692 case 126: 1692 #line 399"grammar.y"1693 #line 400 "grammar.y" 1693 1694 { yyval.stat = new BlockNode(0L); DBG(yyval.stat, yylsp[0], yylsp[0]); ; 1694 1695 break;} 1695 1696 case 127: 1696 #line 40 0"grammar.y"1697 #line 401 "grammar.y" 1697 1698 { yyval.stat = new BlockNode(yyvsp[-1].srcs); DBG(yyval.stat, yylsp[0], yylsp[0]); ; 1698 1699 break;} 1699 1700 case 128: 1700 #line 40 4"grammar.y"1701 #line 405 "grammar.y" 1701 1702 { yyval.slist = new StatListNode(yyvsp[0].stat); ; 1702 1703 break;} 1703 1704 case 129: 1704 #line 40 5"grammar.y"1705 #line 406 "grammar.y" 1705 1706 { yyval.slist = new StatListNode(yyvsp[-1].slist, yyvsp[0].stat); ; 1706 1707 break;} 1707 1708 case 130: 1708 #line 4 09"grammar.y"1709 #line 410 "grammar.y" 1709 1710 { yyval.stat = new VarStatementNode(yyvsp[-1].vlist); 1710 1711 DBG(yyval.stat, yylsp[-2], yylsp[0]); ; 1711 1712 break;} 1712 1713 case 131: 1713 #line 41 1"grammar.y"1714 #line 412 "grammar.y" 1714 1715 { if (automatic()) { 1715 1716 yyval.stat = new VarStatementNode(yyvsp[-1].vlist); … … 1721 1722 break;} 1722 1723 case 132: 1723 #line 42 1"grammar.y"1724 #line 422 "grammar.y" 1724 1725 { yyval.vlist = new VarDeclListNode(yyvsp[0].decl); ; 1725 1726 break;} 1726 1727 case 133: 1727 #line 42 3"grammar.y"1728 #line 424 "grammar.y" 1728 1729 { yyval.vlist = new VarDeclListNode(yyvsp[-2].vlist, yyvsp[0].decl); ; 1729 1730 break;} 1730 1731 case 134: 1731 #line 42 7"grammar.y"1732 #line 428 "grammar.y" 1732 1733 { yyval.decl = new VarDeclNode(yyvsp[0].ustr, 0); delete yyvsp[0].ustr; ; 1733 1734 break;} 1734 1735 case 135: 1735 #line 42 8"grammar.y"1736 #line 429 "grammar.y" 1736 1737 { yyval.decl = new VarDeclNode(yyvsp[-1].ustr, yyvsp[0].init); delete yyvsp[-1].ustr; ; 1737 1738 break;} 1738 1739 case 136: 1739 #line 43 2"grammar.y"1740 #line 433 "grammar.y" 1740 1741 { yyval.init = new AssignExprNode(yyvsp[0].node); ; 1741 1742 break;} 1742 1743 case 137: 1743 #line 43 6"grammar.y"1744 #line 437 "grammar.y" 1744 1745 { yyval.stat = new EmptyStatementNode(); ; 1745 1746 break;} 1746 1747 case 138: 1747 #line 44 0"grammar.y"1748 #line 441 "grammar.y" 1748 1749 { yyval.stat = new ExprStatementNode(yyvsp[-1].node); 1749 1750 DBG(yyval.stat, yylsp[-1], yylsp[0]); ; 1750 1751 break;} 1751 1752 case 139: 1752 #line 44 2"grammar.y"1753 #line 443 "grammar.y" 1753 1754 { if (automatic()) { 1754 1755 yyval.stat = new ExprStatementNode(yyvsp[-1].node); … … 1758 1759 break;} 1759 1760 case 140: 1760 #line 45 0"grammar.y"1761 #line 451 "grammar.y" 1761 1762 { yyval.stat = new IfNode(yyvsp[-2].node,yyvsp[0].stat,0L);DBG(yyval.stat,yylsp[-4],yylsp[-1]); ; 1762 1763 break;} 1763 1764 case 141: 1764 #line 45 2"grammar.y"1765 #line 453 "grammar.y" 1765 1766 { yyval.stat = new IfNode(yyvsp[-4].node,yyvsp[-2].stat,yyvsp[0].stat);DBG(yyval.stat,yylsp[-6],yylsp[-3]); ; 1766 1767 break;} 1767 1768 case 142: 1768 #line 45 6"grammar.y"1769 #line 457 "grammar.y" 1769 1770 { yyval.stat=new DoWhileNode(yyvsp[-4].stat,yyvsp[-1].node);DBG(yyval.stat,yylsp[-5],yylsp[-3]);; 1770 1771 break;} 1771 1772 case 143: 1772 #line 45 7"grammar.y"1773 #line 458 "grammar.y" 1773 1774 { yyval.stat = new WhileNode(yyvsp[-2].node,yyvsp[0].stat);DBG(yyval.stat,yylsp[-4],yylsp[-1]); ; 1774 1775 break;} 1775 1776 case 144: 1776 #line 4 59"grammar.y"1777 #line 460 "grammar.y" 1777 1778 { yyval.stat = new ForNode(yyvsp[-6].node,yyvsp[-4].node,yyvsp[-2].node,yyvsp[0].stat); 1778 1779 DBG(yyval.stat,yylsp[-8],yylsp[-1]); ; 1779 1780 break;} 1780 1781 case 145: 1781 #line 46 2"grammar.y"1782 #line 463 "grammar.y" 1782 1783 { yyval.stat = new ForNode(yyvsp[-6].vlist,yyvsp[-4].node,yyvsp[-2].node,yyvsp[0].stat); 1783 1784 DBG(yyval.stat,yylsp[-9],yylsp[-1]); ; 1784 1785 break;} 1785 1786 case 146: 1786 #line 46 5"grammar.y"1787 #line 466 "grammar.y" 1787 1788 { yyval.stat = new ForInNode(yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].stat); 1788 1789 DBG(yyval.stat,yylsp[-6],yylsp[-1]); ; 1789 1790 break;} 1790 1791 case 147: 1791 #line 46 8"grammar.y"1792 #line 469 "grammar.y" 1792 1793 { yyval.stat = new ForInNode(yyvsp[-4].ustr,0L,yyvsp[-2].node,yyvsp[0].stat); 1793 1794 DBG(yyval.stat,yylsp[-7],yylsp[-1]); … … 1795 1796 break;} 1796 1797 case 148: 1797 #line 47 2"grammar.y"1798 #line 473 "grammar.y" 1798 1799 { yyval.stat = new ForInNode(yyvsp[-5].ustr,yyvsp[-4].init,yyvsp[-2].node,yyvsp[0].stat); 1799 1800 DBG(yyval.stat,yylsp[-8],yylsp[-1]); … … 1801 1802 break;} 1802 1803 case 149: 1803 #line 47 8"grammar.y"1804 #line 479 "grammar.y" 1804 1805 { yyval.node = 0L; ; 1805 1806 break;} 1806 1807 case 151: 1807 #line 48 3"grammar.y"1808 #line 484 "grammar.y" 1808 1809 { yyval.stat = new ContinueNode(); DBG(yyval.stat,yylsp[-1],yylsp[0]); ; 1809 1810 break;} 1810 1811 case 152: 1811 #line 48 4"grammar.y"1812 #line 485 "grammar.y" 1812 1813 { if (automatic()) { 1813 1814 yyval.stat = new ContinueNode(); DBG(yyval.stat,yylsp[-1],yylsp[0]); … … 1816 1817 break;} 1817 1818 case 153: 1818 #line 48 8"grammar.y"1819 #line 489 "grammar.y" 1819 1820 { yyval.stat = new ContinueNode(yyvsp[-1].ustr); DBG(yyval.stat,yylsp[-2],yylsp[0]); 1820 1821 delete yyvsp[-1].ustr; ; 1821 1822 break;} 1822 1823 case 154: 1823 #line 49 0"grammar.y"1824 #line 491 "grammar.y" 1824 1825 { if (automatic()) { 1825 1826 yyval.stat = new ContinueNode(yyvsp[-1].ustr);DBG(yyval.stat,yylsp[-2],yylsp[-1]); … … 1829 1830 break;} 1830 1831 case 155: 1831 #line 49 8"grammar.y"1832 #line 499 "grammar.y" 1832 1833 { yyval.stat = new BreakNode();DBG(yyval.stat,yylsp[-1],yylsp[0]); ; 1833 1834 break;} 1834 1835 case 156: 1835 #line 499"grammar.y"1836 #line 500 "grammar.y" 1836 1837 { if (automatic()) { 1837 1838 yyval.stat = new BreakNode(); DBG(yyval.stat,yylsp[-1],yylsp[-1]); … … 1840 1841 break;} 1841 1842 case 157: 1842 #line 50 3"grammar.y"1843 #line 504 "grammar.y" 1843 1844 { yyval.stat = new BreakNode(yyvsp[-1].ustr); DBG(yyval.stat,yylsp[-2],yylsp[0]); 1844 1845 delete yyvsp[-1].ustr; ; 1845 1846 break;} 1846 1847 case 158: 1847 #line 50 5"grammar.y"1848 #line 506 "grammar.y" 1848 1849 { if (automatic()) { 1849 1850 yyval.stat = new BreakNode(yyvsp[-1].ustr); DBG(yyval.stat,yylsp[-2],yylsp[-1]); … … 1854 1855 break;} 1855 1856 case 159: 1856 #line 51 4"grammar.y"1857 #line 515 "grammar.y" 1857 1858 { yyval.stat = new ReturnNode(0L); DBG(yyval.stat,yylsp[-1],yylsp[0]); ; 1858 1859 break;} 1859 1860 case 160: 1860 #line 51 5"grammar.y"1861 #line 516 "grammar.y" 1861 1862 { if (automatic()) { 1862 1863 yyval.stat = new ReturnNode(0L); DBG(yyval.stat,yylsp[-1],yylsp[-1]); … … 1865 1866 break;} 1866 1867 case 161: 1867 #line 5 19"grammar.y"1868 #line 520 "grammar.y" 1868 1869 { yyval.stat = new ReturnNode(yyvsp[-1].node); ; 1869 1870 break;} 1870 1871 case 162: 1871 #line 52 0"grammar.y"1872 #line 521 "grammar.y" 1872 1873 { if (automatic()) 1873 1874 yyval.stat = new ReturnNode(yyvsp[-1].node); … … 1876 1877 break;} 1877 1878 case 163: 1878 #line 52 7"grammar.y"1879 #line 528 "grammar.y" 1879 1880 { yyval.stat = new WithNode(yyvsp[-2].node,yyvsp[0].stat); 1880 1881 DBG(yyval.stat, yylsp[-4], yylsp[-1]); ; 1881 1882 break;} 1882 1883 case 164: 1883 #line 53 2"grammar.y"1884 #line 533 "grammar.y" 1884 1885 { yyval.stat = new SwitchNode(yyvsp[-2].node, yyvsp[0].cblk); 1885 1886 DBG(yyval.stat, yylsp[-4], yylsp[-1]); ; 1886 1887 break;} 1887 1888 case 165: 1888 #line 53 7"grammar.y"1889 #line 538 "grammar.y" 1889 1890 { yyval.cblk = new CaseBlockNode(yyvsp[-1].clist, 0L, 0L); ; 1890 1891 break;} 1891 1892 case 166: 1892 #line 5 39"grammar.y"1893 #line 540 "grammar.y" 1893 1894 { yyval.cblk = new CaseBlockNode(yyvsp[-3].clist, yyvsp[-2].ccl, yyvsp[-1].clist); ; 1894 1895 break;} 1895 1896 case 167: 1896 #line 54 3"grammar.y"1897 #line 544 "grammar.y" 1897 1898 { yyval.clist = 0L; ; 1898 1899 break;} 1899 1900 case 169: 1900 #line 54 8"grammar.y"1901 #line 549 "grammar.y" 1901 1902 { yyval.clist = new ClauseListNode(yyvsp[0].ccl); ; 1902 1903 break;} 1903 1904 case 170: 1904 #line 5 49"grammar.y"1905 #line 550 "grammar.y" 1905 1906 { yyval.clist = yyvsp[-1].clist->append(yyvsp[0].ccl); ; 1906 1907 break;} 1907 1908 case 171: 1908 #line 55 3"grammar.y"1909 #line 554 "grammar.y" 1909 1910 { yyval.ccl = new CaseClauseNode(yyvsp[-1].node, 0L); ; 1910 1911 break;} 1911 1912 case 172: 1912 #line 55 4"grammar.y"1913 #line 555 "grammar.y" 1913 1914 { yyval.ccl = new CaseClauseNode(yyvsp[-2].node, yyvsp[0].slist); ; 1914 1915 break;} 1915 1916 case 173: 1916 #line 55 8"grammar.y"1917 #line 559 "grammar.y" 1917 1918 { yyval.ccl = new CaseClauseNode(0L, 0L);; ; 1918 1919 break;} 1919 1920 case 174: 1920 #line 5 59"grammar.y"1921 #line 560 "grammar.y" 1921 1922 { yyval.ccl = new CaseClauseNode(0L, yyvsp[0].slist); ; 1922 1923 break;} 1923 1924 case 175: 1924 #line 56 3"grammar.y"1925 #line 564 "grammar.y" 1925 1926 { yyvsp[0].stat->pushLabel(yyvsp[-2].ustr); 1926 1927 yyval.stat = new LabelNode(yyvsp[-2].ustr, yyvsp[0].stat); … … 1928 1929 break;} 1929 1930 case 176: 1930 #line 5 69"grammar.y"1931 #line 570 "grammar.y" 1931 1932 { yyval.stat = new ThrowNode(yyvsp[-1].node); ; 1932 1933 break;} 1933 1934 case 177: 1934 #line 57 3"grammar.y"1935 #line 574 "grammar.y" 1935 1936 { yyval.stat = new TryNode(yyvsp[-1].stat, yyvsp[0].node); ; 1936 1937 break;} 1937 1938 case 178: 1938 #line 57 4"grammar.y"1939 #line 575 "grammar.y" 1939 1940 { yyval.stat = new TryNode(yyvsp[-1].stat, 0L, yyvsp[0].node); ; 1940 1941 break;} 1941 1942 case 179: 1942 #line 57 5"grammar.y"1943 #line 576 "grammar.y" 1943 1944 { yyval.stat = new TryNode(yyvsp[-2].stat, yyvsp[-1].node, yyvsp[0].node); ; 1944 1945 break;} 1945 1946 case 180: 1946 #line 5 79"grammar.y"1947 #line 580 "grammar.y" 1947 1948 { yyval.node = new CatchNode(yyvsp[-2].ustr, yyvsp[0].stat); delete yyvsp[-2].ustr; ; 1948 1949 break;} 1949 1950 case 181: 1950 #line 58 3"grammar.y"1951 #line 584 "grammar.y" 1951 1952 { yyval.node = new FinallyNode(yyvsp[0].stat); ; 1952 1953 break;} 1953 1954 case 182: 1954 #line 58 7"grammar.y"1955 #line 588 "grammar.y" 1955 1956 { yyval.func = new FuncDeclNode(yyvsp[-3].ustr, 0L, yyvsp[0].body); 1956 1957 delete yyvsp[-3].ustr; ; 1957 1958 break;} 1958 1959 case 183: 1959 #line 59 0"grammar.y"1960 #line 591 "grammar.y" 1960 1961 { yyval.func = new FuncDeclNode(yyvsp[-4].ustr, yyvsp[-2].param, yyvsp[0].body); 1961 1962 delete yyvsp[-4].ustr; ; 1962 1963 break;} 1963 1964 case 184: 1964 #line 59 4"grammar.y"1965 #line 595 "grammar.y" 1965 1966 { yyval.node = new FuncExprNode(0L, yyvsp[0].body); ; 1966 1967 break;} 1967 1968 case 185: 1968 #line 59 6"grammar.y"1969 #line 597 "grammar.y" 1969 1970 { yyval.node = new FuncExprNode(yyvsp[-2].param, yyvsp[0].body); ; 1970 1971 break;} 1971 1972 case 186: 1972 #line 60 1"grammar.y"1973 #line 602 "grammar.y" 1973 1974 { yyval.param = new ParameterNode(yyvsp[0].ustr); delete yyvsp[0].ustr; ; 1974 1975 break;} 1975 1976 case 187: 1976 #line 60 2"grammar.y"1977 #line 603 "grammar.y" 1977 1978 { yyval.param = yyvsp[-2].param->append(yyvsp[0].ustr); 1978 1979 delete yyvsp[0].ustr; ; 1979 1980 break;} 1980 1981 case 188: 1981 #line 60 7"grammar.y"1982 #line 608 "grammar.y" 1982 1983 { yyval.body = new FunctionBodyNode(0L); 1983 1984 DBG(yyval.body, yylsp[-1], yylsp[0]);; 1984 1985 break;} 1985 1986 case 189: 1986 #line 6 09"grammar.y"1987 #line 610 "grammar.y" 1987 1988 { yyval.body = new FunctionBodyNode(yyvsp[-1].srcs); 1988 1989 DBG(yyval.body, yylsp[-2], yylsp[0]);; 1989 1990 break;} 1990 1991 case 190: 1991 #line 61 4"grammar.y"1992 #line 615 "grammar.y" 1992 1993 { yyval.prog = new ProgramNode(0L); 1993 1994 Parser::progNode = yyval.prog; ; 1994 1995 break;} 1995 1996 case 191: 1996 #line 61 6"grammar.y"1997 #line 617 "grammar.y" 1997 1998 { yyval.prog = new ProgramNode(yyvsp[0].srcs); 1998 1999 Parser::progNode = yyval.prog; ; 1999 2000 break;} 2000 2001 case 192: 2001 #line 62 1"grammar.y"2002 #line 622 "grammar.y" 2002 2003 { yyval.srcs = new SourceElementsNode(yyvsp[0].src); ; 2003 2004 break;} 2004 2005 case 193: 2005 #line 62 2"grammar.y"2006 #line 623 "grammar.y" 2006 2007 { yyval.srcs = new SourceElementsNode(yyvsp[-1].srcs, yyvsp[0].src); ; 2007 2008 break;} 2008 2009 case 194: 2009 #line 62 6"grammar.y"2010 #line 627 "grammar.y" 2010 2011 { yyval.src = new SourceElementNode(yyvsp[0].stat); ; 2011 2012 break;} 2012 2013 case 195: 2013 #line 62 7"grammar.y"2014 #line 628 "grammar.y" 2014 2015 { yyval.src = new SourceElementNode(yyvsp[0].func); ; 2015 2016 break;} … … 2237 2238 return 1; 2238 2239 } 2239 #line 63 0"grammar.y"2240 #line 631 "grammar.y" 2240 2241 2241 2242 -
trunk/JavaScriptCore/kjs/grammar.y
r903 r1024 237 237 | CallExpr Arguments { $$ = new FunctionCallNode($1, $2); } 238 238 | CallExpr '[' Expr ']' { $$ = new AccessorNode1($1, $3); } 239 | CallExpr '.' IDENT { $$ = new AccessorNode2($1, $3); } 239 | CallExpr '.' IDENT { $$ = new AccessorNode2($1, $3); 240 delete $3; } 240 241 ; 241 242 -
trunk/JavaScriptCore/kjs/internal.cpp
r931 r1024 22 22 */ 23 23 24 #include <config.h>25 26 24 #include <stdio.h> 27 25 #include <math.h> … … 475 473 clear(); 476 474 delete hook; 475 476 if ( emptyList == this ) 477 emptyList = 0L; 477 478 } 478 479 … … 758 759 BooleanImp::staticFalse->setGcAllowed(); 759 760 BooleanImp::staticFalse = 0L; 760 #ifdef APPLE_CHANGES761 ListImp::emptyList->setGcAllowed();762 ListImp::emptyList->deref();763 ListImp::emptyList = 0;764 #endif765 761 } 766 762 … … 787 783 788 784 // initialize properties of the global object 789 785 initGlobalObject(); 786 787 recursion = 0; 788 } 789 790 void InterpreterImp::initGlobalObject() 791 { 790 792 // Contructor prototype objects (Object.prototype, Array.prototype etc) 791 793 … … 910 912 // built-in objects 911 913 global.put(globExec,"Math", Object(new MathObjectImp(globExec,objProto)), DontEnum); 912 913 recursion = 0;914 914 } 915 915 -
trunk/JavaScriptCore/kjs/internal.h
r798 r1024 350 350 Interpreter* interpreter() const { return m_interpreter; } 351 351 352 void initGlobalObject(); 353 352 354 void mark(); 353 355 -
trunk/JavaScriptCore/kjs/interpreter.cpp
r798 r1024 20 20 * Boston, MA 02111-1307, USA. 21 21 * 22 * $Id$23 22 */ 24 23 … … 113 112 { 114 113 return rep->globalObject(); 114 } 115 116 void Interpreter::initGlobalObject() 117 { 118 rep->initGlobalObject(); 115 119 } 116 120 … … 365 369 } 366 370 371 void Interpreter::virtual_hook( int, void* ) 372 { /*BASE::virtual_hook( id, data );*/ } -
trunk/JavaScriptCore/kjs/interpreter.h
r798 r1024 20 20 * Boston, MA 02111-1307, USA. 21 21 * 22 * $Id$23 22 */ 24 23 … … 115 114 * interpreter has a global object which is used for the purposes of code 116 115 * evaluation, and also provides access to built-in properties such as 117 " Object" and "Number".116 * " Object" and "Number". 118 117 */ 119 118 class Interpreter { … … 149 148 Object globalObject() const; 150 149 150 void initGlobalObject(); 151 151 152 /** 152 153 * Returns the execution state object which can be used to execute … … 205 206 Object builtinObject() const; 206 207 207 /** Returns the builtin "Function" object. */ 208 /** 209 * Returns the builtin "Function" object. 210 */ 208 211 Object builtinFunction() const; 209 212 210 /** Returns the builtin "Array" object. */ 213 /** 214 * Returns the builtin "Array" object. 215 */ 211 216 Object builtinArray() const; 212 217 213 218 214 /** Returns the builtin "Boolean" object. */ 219 /** 220 * Returns the builtin "Boolean" object. 221 */ 215 222 Object builtinBoolean() const; 216 223 217 /** Returns the builtin "String" object. */ 224 /** 225 * Returns the builtin "String" object. 226 */ 218 227 Object builtinString() const; 219 228 220 /** Returns the builtin "Number" object. */ 229 /** 230 * Returns the builtin "Number" object. 231 */ 221 232 Object builtinNumber() const; 222 233 223 /** Returns the builtin "Date" object. */ 234 /** 235 * Returns the builtin "Date" object. 236 */ 224 237 Object builtinDate() const; 225 238 226 /** Returns the builtin "RegExp" object. */ 239 /** 240 * Returns the builtin "RegExp" object. 241 */ 227 242 Object builtinRegExp() const; 228 243 229 /** Returns the builtin "Error" object. */ 244 /** 245 * Returns the builtin "Error" object. 246 */ 230 247 Object builtinError() const; 231 248 232 /** Returns the builtin "Object.prototype" object. */ 249 /** 250 * Returns the builtin "Object.prototype" object. 251 */ 233 252 Object builtinObjectPrototype() const; 234 253 235 /** Returns the builtin "Function.prototype" object. */ 254 /** 255 * Returns the builtin "Function.prototype" object. 256 */ 236 257 Object builtinFunctionPrototype() const; 237 258 238 /** Returns the builtin "Array.prototype" object. */ 259 /** 260 * Returns the builtin "Array.prototype" object. 261 */ 239 262 Object builtinArrayPrototype() const; 240 263 241 /** Returns the builtin "Boolean.prototype" object. */ 264 /** 265 * Returns the builtin "Boolean.prototype" object. 266 */ 242 267 Object builtinBooleanPrototype() const; 243 268 244 /** Returns the builtin "String.prototype" object. */ 269 /** 270 * Returns the builtin "String.prototype" object. 271 */ 245 272 Object builtinStringPrototype() const; 246 273 247 /** Returns the builtin "Number.prototype" object. */ 274 /** 275 * Returns the builtin "Number.prototype" object. 276 */ 248 277 Object builtinNumberPrototype() const; 249 278 250 /** Returns the builtin "Date.prototype" object. */ 279 /** 280 * Returns the builtin "Date.prototype" object. 281 */ 251 282 Object builtinDatePrototype() const; 252 283 253 /** Returns the builtin "RegExp.prototype" object. */ 284 /** 285 * Returns the builtin "RegExp.prototype" object. 286 */ 254 287 Object builtinRegExpPrototype() const; 255 288 256 /** Returns the builtin "Error.prototype" object. */ 289 /** 290 * Returns the builtin "Error.prototype" object. 291 */ 257 292 Object builtinErrorPrototype() const; 258 293 259 /** The initial value of "Error" global property */ 294 /** 295 * The initial value of "Error" global property 296 */ 260 297 Object builtinEvalError() const; 261 298 Object builtinRangeError() const; … … 318 355 */ 319 356 Interpreter operator=(const Interpreter&); 357 protected: 358 virtual void virtual_hook( int id, void* data ); 320 359 }; 321 360 -
trunk/JavaScriptCore/kjs/lexer.cpp
r798 r1024 19 19 * Boston, MA 02111-1307, USA. 20 20 * 21 * $Id$22 21 */ 23 22 … … 53 52 #include "lexer.lut.h" 54 53 55 extern YYLTYPE yylloc; 54 extern YYLTYPE yylloc; // global bison variable holding token info 56 55 57 56 // a bridge for yacc from the C world to C++ … … 62 61 63 62 Lexer::Lexer() 64 : yylineno( 0),63 : yylineno(1), 65 64 size8(128), size16(128), restrKeyword(false), 66 65 eatNextIdentifier(false), stackToken(-1), lastToken(-1), pos(0), … … 95 94 void Lexer::setCode(const UChar *c, unsigned int len) 96 95 { 97 yylineno = 0;96 yylineno = 1; 98 97 restrKeyword = false; 99 98 delimited = false; … … 126 125 next3 = (pos + 3 < length) ? code[pos+3].unicode() : 0; 127 126 } 127 } 128 129 // called on each new line 130 void Lexer::nextLine() 131 { 132 yylineno++; 133 #ifndef KJS_PURE_ECMA 134 bol = true; 135 #endif 128 136 } 129 137 … … 167 175 case Start: 168 176 if (isWhiteSpace()) { 169 177 // do nothing 170 178 } else if (current == '/' && next1 == '/') { 171 172 179 shift(1); 180 state = InSingleLineComment; 173 181 } else if (current == '/' && next1 == '*') { 174 175 182 shift(1); 183 state = InMultiLineComment; 176 184 } else if (current == 0) { 177 178 179 180 181 182 183 185 if (!terminator && !delimited) { 186 // automatic semicolon insertion if program incomplete 187 token = ';'; 188 stackToken = 0; 189 setDone(Other); 190 } else 191 setDone(Eof); 184 192 } else if (isLineTerminator()) { 185 yylineno++; 193 nextLine(); 194 terminator = true; 195 if (restrKeyword) { 196 token = ';'; 197 setDone(Other); 198 } 199 } else if (current == '"' || current == '\'') { 200 state = InString; 201 stringType = current; 202 } else if (isIdentLetter(current)) { 203 record16(current); 204 state = InIdentifier; 205 } else if (current == '0') { 206 record8(current); 207 state = InNum0; 208 } else if (isDecimalDigit(current)) { 209 record8(current); 210 state = InNum; 211 } else if (current == '.' && isDecimalDigit(next1)) { 212 record8(current); 213 state = InDecimal; 186 214 #ifndef KJS_PURE_ECMA 187 bol = true; 188 #endif 189 terminator = true; 190 if (restrKeyword) { 191 token = ';'; 192 setDone(Other); 193 } 194 } else if (current == '"' || current == '\'') { 195 state = InString; 196 stringType = current; 197 } else if (isIdentLetter(current)) { 198 record16(current); 199 state = InIdentifier; 200 } else if (current == '0') { 201 record8(current); 202 state = InNum0; 203 } else if (isDecimalDigit(current)) { 204 record8(current); 205 state = InNum; 206 } else if (current == '.' && isDecimalDigit(next1)) { 207 record8(current); 208 state = InDecimal; 209 #ifndef KJS_PURE_ECMA 210 // <!-- marks the beginning of a line comment (for www usage) 211 } else if (bol && current == '<' && next1 == '!' && 212 next2 == '-' && next3 == '-') { 213 shift(3); 214 state = InSingleLineComment; 215 // same of --> 215 // <!-- marks the beginning of a line comment (for www usage) 216 } else if (current == '<' && next1 == '!' && 217 next2 == '-' && next3 == '-') { 218 shift(3); 219 state = InSingleLineComment; 220 // same for --> 216 221 } else if (bol && current == '-' && next1 == '-' && next2 == '>') { 217 218 222 shift(2); 223 state = InSingleLineComment; 219 224 #endif 220 225 } else { 221 222 223 224 225 //cerr << "encountered unknown character" << endl;226 227 226 token = matchPunctuator(current, next1, next2, next3); 227 if (token != -1) { 228 setDone(Other); 229 } else { 230 // cerr << "encountered unknown character" << endl; 231 setDone(Bad); 232 } 228 233 } 229 234 break; 230 235 case InString: 231 236 if (current == stringType) { 232 233 237 shift(1); 238 setDone(String); 234 239 } else if (current == 0 || isLineTerminator()) { 235 240 setDone(Bad); 236 241 } else if (current == '\\') { 237 242 state = InEscapeSequence; 238 243 } else { 239 244 record16(current); 240 245 } 241 246 break; … … 243 248 case InEscapeSequence: 244 249 if (isOctalDigit(current)) { 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 250 if (current >= '0' && current <= '3' && 251 isOctalDigit(next1) && isOctalDigit(next2)) { 252 record16(convertOctal(current, next1, next2)); 253 shift(2); 254 state = InString; 255 } else if (isOctalDigit(current) && isOctalDigit(next1)) { 256 record16(convertOctal('0', current, next1)); 257 shift(1); 258 state = InString; 259 } else if (isOctalDigit(current)) { 260 record16(convertOctal('0', '0', current)); 261 state = InString; 262 } else { 263 setDone(Bad); 264 } 260 265 } else if (current == 'x') 261 266 state = InHexEscape; 262 267 else if (current == 'u') 263 268 state = InUnicodeEscape; 264 269 else { 265 266 270 record16(singleEscape(current)); 271 state = InString; 267 272 } 268 273 break; 269 274 case InHexEscape: 270 275 if (isHexDigit(current) && isHexDigit(next1)) { 271 272 273 276 state = InString; 277 record16(convertHex(current, next1)); 278 shift(1); 274 279 } else if (current == stringType) { 275 276 277 280 record16('x'); 281 shift(1); 282 setDone(String); 278 283 } else { 279 280 281 284 record16('x'); 285 record16(current); 286 state = InString; 282 287 } 283 288 break; 284 289 case InUnicodeEscape: 285 290 if (isHexDigit(current) && isHexDigit(next1) && 286 287 288 289 291 isHexDigit(next2) && isHexDigit(next3)) { 292 record16(convertUnicode(current, next1, next2, next3)); 293 shift(3); 294 state = InString; 290 295 } else if (current == stringType) { 291 292 293 296 record16('u'); 297 shift(1); 298 setDone(String); 294 299 } else { 295 300 setDone(Bad); 296 301 } 297 302 break; 298 303 case InSingleLineComment: 299 304 if (isLineTerminator()) { 300 yylineno++; 301 terminator = true; 302 #ifndef KJS_PURE_ECMA 303 bol = true; 304 #endif 305 if (restrKeyword) { 306 token = ';'; 307 setDone(Other); 308 } else 309 state = Start; 305 nextLine(); 306 terminator = true; 307 if (restrKeyword) { 308 token = ';'; 309 setDone(Other); 310 } else 311 state = Start; 310 312 } else if (current == 0) { 311 313 setDone(Eof); 312 314 } 313 315 break; 314 316 case InMultiLineComment: 315 317 if (current == 0) { 316 318 setDone(Bad); 317 319 } else if (isLineTerminator()) { 318 yylineno++;320 nextLine(); 319 321 } else if (current == '*' && next1 == '/') { 320 321 322 state = Start; 323 shift(1); 322 324 } 323 325 break; 324 326 case InIdentifier: 325 327 if (isIdentLetter(current) || isDecimalDigit(current)) { 326 327 328 record16(current); 329 break; 328 330 } 329 331 setDone(Identifier); … … 331 333 case InNum0: 332 334 if (current == 'x' || current == 'X') { 333 334 335 record8(current); 336 state = InHex; 335 337 } else if (current == '.') { 336 337 338 record8(current); 339 state = InDecimal; 338 340 } else if (current == 'e' || current == 'E') { 339 340 341 record8(current); 342 state = InExponentIndicator; 341 343 } else if (isOctalDigit(current)) { 342 343 344 record8(current); 345 state = InOctal; 344 346 } else if (isDecimalDigit(current)) { 345 347 record8(current); 346 348 state = InDecimal; 347 349 } else { 348 350 setDone(Number); 349 351 } 350 352 break; 351 353 case InHex: 352 354 if (isHexDigit(current)) { 353 355 record8(current); 354 356 } else { 355 357 setDone(Hex); 356 358 } 357 359 break; 358 360 case InOctal: 359 361 if (isOctalDigit(current)) { 360 362 record8(current); 361 363 } 362 364 else if (isDecimalDigit(current)) { … … 364 366 state = InDecimal; 365 367 } else 366 368 setDone(Octal); 367 369 break; 368 370 case InNum: 369 371 if (isDecimalDigit(current)) { 370 372 record8(current); 371 373 } else if (current == '.') { 372 373 374 record8(current); 375 state = InDecimal; 374 376 } else if (current == 'e' || current == 'E') { 375 376 377 record8(current); 378 state = InExponentIndicator; 377 379 } else 378 380 setDone(Number); 379 381 break; 380 382 case InDecimal: 381 383 if (isDecimalDigit(current)) { 382 384 record8(current); 383 385 } else if (current == 'e' || current == 'E') { 384 385 386 record8(current); 387 state = InExponentIndicator; 386 388 } else 387 389 setDone(Number); 388 390 break; 389 391 case InExponentIndicator: 390 392 if (current == '+' || current == '-') { 391 393 record8(current); 392 394 } else if (isDecimalDigit(current)) { 393 394 395 record8(current); 396 state = InExponent; 395 397 } else 396 398 setDone(Bad); 397 399 break; 398 400 case InExponent: 399 401 if (isDecimalDigit(current)) { 400 402 record8(current); 401 403 } else 402 404 setDone(Number); 403 405 break; 404 406 default: … … 506 508 507 509 if (token == CONTINUE || token == BREAK || 508 510 token == RETURN || token == THROW) 509 511 restrKeyword = true; 510 512 break; … … 531 533 { 532 534 return (current == ' ' || current == '\t' || 533 535 current == 0x0b || current == 0x0c); 534 536 } 535 537 … … 549 551 /* TODO: allow other legitimate unicode chars */ 550 552 return (c >= 'a' && c <= 'z' || 551 552 553 c >= 'A' && c <= 'Z' || 554 c == '$' || c == '_'); 553 555 } 554 556 … … 561 563 { 562 564 return (c >= '0' && c <= '9' || 563 564 565 c >= 'a' && c <= 'f' || 566 c >= 'A' && c <= 'F'); 565 567 } 566 568 … … 571 573 572 574 int Lexer::matchPunctuator(unsigned short c1, unsigned short c2, 573 575 unsigned short c3, unsigned short c4) 574 576 { 575 577 if (c1 == '>' && c2 == '>' && c3 == '>' && c4 == '=') { … … 736 738 { 737 739 return UChar((convertHex(c1) << 4) + convertHex(c2), 738 740 (convertHex(c3) << 4) + convertHex(c4)); 739 741 } 740 742 -
trunk/JavaScriptCore/kjs/lexer.h
r798 r1024 19 19 * Boston, MA 02111-1307, USA. 20 20 * 21 * $Id$22 21 */ 23 22 … … 45 44 46 45 enum State { Start, 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 46 Identifier, 47 InIdentifier, 48 InSingleLineComment, 49 InMultiLineComment, 50 InNum, 51 InNum0, 52 InHex, 53 InOctal, 54 InDecimal, 55 InExponentIndicator, 56 InExponent, 57 Hex, 58 Octal, 59 Number, 60 String, 61 Eof, 62 InString, 63 InEscapeSequence, 64 InHexEscape, 65 InUnicodeEscape, 66 Other, 67 Bad }; 69 68 70 69 bool scanRegExp(); … … 92 91 unsigned int pos; 93 92 void shift(unsigned int p); 93 void nextLine(); 94 94 int lookupKeyword(const char *); 95 95 … … 100 100 101 101 int matchPunctuator(unsigned short c1, unsigned short c2, 102 102 unsigned short c3, unsigned short c4); 103 103 unsigned short singleEscape(unsigned short c) const; 104 104 unsigned short convertOctal(unsigned short c1, unsigned short c2, … … 108 108 static unsigned char convertHex(unsigned short c1, unsigned short c2); 109 109 static UChar convertUnicode(unsigned short c1, unsigned short c2, 110 110 unsigned short c3, unsigned short c4); 111 111 static bool isIdentLetter(unsigned short c); 112 112 static bool isDecimalDigit(unsigned short c); -
trunk/JavaScriptCore/kjs/lookup.cpp
r798 r1024 18 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 * 20 * $Id$21 20 */ 22 21 -
trunk/JavaScriptCore/kjs/lookup.h
r798 r1024 18 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 * 20 * $Id$21 20 */ 22 21 … … 34 33 */ 35 34 struct HashEntry { 36 /** s is the key (e.g. a property name) */ 35 /** 36 * s is the key (e.g. a property name) 37 */ 37 38 const char *s; 38 /** value is the result value (usually an enum value) */ 39 /** 40 * value is the result value (usually an enum value) 41 */ 39 42 int value; 40 /** attr is a set for flags (e.g. the property flags, see object.h) */ 43 /** 44 * attr is a set for flags (e.g. the property flags, see object.h) 45 */ 41 46 short int attr; 42 /** params is another number. For property hashtables, it is used to 43 denote the number of argument of the function */ 47 /** 48 * params is another number. For property hashtables, it is used to 49 * denote the number of argument of the function 50 */ 44 51 short int params; 45 /** next is the pointer to the next entry for the same hash value */ 52 /** 53 * next is the pointer to the next entry for the same hash value 54 */ 46 55 const HashEntry *next; 47 56 }; … … 59 68 */ 60 69 struct HashTable { 61 /** type is a version number. Currently always 2 */ 70 /** 71 * type is a version number. Currently always 2 72 */ 62 73 int type; 63 /** size is the total number of entries in the hashtable, including the null entries, 74 /** 75 * size is the total number of entries in the hashtable, including the null entries, 64 76 * i.e. the size of the "entries" array. 65 * Used to iterate over all entries in the table */ 77 * Used to iterate over all entries in the table 78 */ 66 79 int size; 67 /** pointer to the array of entries 68 * Mind that some entries in the array are null (0,0,0,0). */ 80 /** 81 * pointer to the array of entries 82 * Mind that some entries in the array are null (0,0,0,0). 83 */ 69 84 const HashEntry *entries; 70 /** the maximum value for the hash. Always smaller than size. */ 85 /** 86 * the maximum value for the hash. Always smaller than size. 87 */ 71 88 int hashSize; 72 89 }; … … 77 94 class Lookup { 78 95 public: 79 /** Find an entry in the table, and return its value (i.e. the value field of HashEntry) */ 96 /** 97 * Find an entry in the table, and return its value (i.e. the value field of HashEntry) 98 */ 80 99 static int find(const struct HashTable *table, const UString &s); 81 100 static int find(const struct HashTable *table, … … 92 111 const UChar *c, unsigned int len); 93 112 94 /** Calculate the hash value for a given key */ 113 /** 114 * Calculate the hash value for a given key 115 */ 95 116 static unsigned int hash(const UString &key); 96 117 static unsigned int hash(const UChar *c, unsigned int len); … … 100 121 class ExecState; 101 122 class UString; 102 /** @internal 103 * Helper for lookupFunction and lookupValueOrFunction */ 123 /** 124 * @internal 125 * Helper for lookupFunction and lookupValueOrFunction 126 */ 104 127 template <class FuncImp> 105 128 inline Value lookupOrCreateFunction(ExecState *exec, const UString &propertyName, -
trunk/JavaScriptCore/kjs/math_object.cpp
r798 r1024 18 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 * 20 * $Id$21 20 */ 22 21 … … 35 34 #include "math_object.lut.h" 36 35 36 #ifndef M_PI 37 #define M_PI 3.14159265358979323846 38 #endif /* M_PI */ 39 37 40 using namespace KJS; 38 41 … … 43 46 /* Source for math_object.lut.h 44 47 @begin mathTable 21 45 E MathObjectImp::Euler DontEnum46 LN2 MathObjectImp::Ln2 DontEnum47 LN10 MathObjectImp::Ln10 DontEnum48 LOG2E MathObjectImp::Log2E DontEnum49 LOG10E MathObjectImp::Log10E DontEnum50 PI MathObjectImp::Pi DontEnum51 SQRT1_2 MathObjectImp::Sqrt1_2 DontEnum52 SQRT2 MathObjectImp::Sqrt2 DontEnum53 abs MathObjectImp::AbsDontEnum|Function 154 acos MathObjectImp::ACosDontEnum|Function 155 asin MathObjectImp::ASinDontEnum|Function 156 atan MathObjectImp::ATanDontEnum|Function 157 atan2 MathObjectImp::ATan2DontEnum|Function 258 ceil MathObjectImp::CeilDontEnum|Function 159 cos MathObjectImp::CosDontEnum|Function 160 exp MathObjectImp::ExpDontEnum|Function 161 floor MathObjectImp::FloorDontEnum|Function 162 log MathObjectImp::LogDontEnum|Function 163 max MathObjectImp::MaxDontEnum|Function 264 min MathObjectImp::MinDontEnum|Function 265 pow MathObjectImp::PowDontEnum|Function 266 random MathObjectImp::RandomDontEnum|Function 067 round MathObjectImp::RoundDontEnum|Function 168 sin MathObjectImp::SinDontEnum|Function 169 sqrt MathObjectImp::SqrtDontEnum|Function 170 tan MathObjectImp::TanDontEnum|Function 148 E MathObjectImp::Euler DontEnum|DontDelete|ReadOnly 49 LN2 MathObjectImp::Ln2 DontEnum|DontDelete|ReadOnly 50 LN10 MathObjectImp::Ln10 DontEnum|DontDelete|ReadOnly 51 LOG2E MathObjectImp::Log2E DontEnum|DontDelete|ReadOnly 52 LOG10E MathObjectImp::Log10E DontEnum|DontDelete|ReadOnly 53 PI MathObjectImp::Pi DontEnum|DontDelete|ReadOnly 54 SQRT1_2 MathObjectImp::Sqrt1_2 DontEnum|DontDelete|ReadOnly 55 SQRT2 MathObjectImp::Sqrt2 DontEnum|DontDelete|ReadOnly 56 abs MathObjectImp::Abs DontEnum|Function 1 57 acos MathObjectImp::ACos DontEnum|Function 1 58 asin MathObjectImp::ASin DontEnum|Function 1 59 atan MathObjectImp::ATan DontEnum|Function 1 60 atan2 MathObjectImp::ATan2 DontEnum|Function 2 61 ceil MathObjectImp::Ceil DontEnum|Function 1 62 cos MathObjectImp::Cos DontEnum|Function 1 63 exp MathObjectImp::Exp DontEnum|Function 1 64 floor MathObjectImp::Floor DontEnum|Function 1 65 log MathObjectImp::Log DontEnum|Function 1 66 max MathObjectImp::Max DontEnum|Function 2 67 min MathObjectImp::Min DontEnum|Function 2 68 pow MathObjectImp::Pow DontEnum|Function 2 69 random MathObjectImp::Random DontEnum|Function 0 70 round MathObjectImp::Round DontEnum|Function 1 71 sin MathObjectImp::Sin DontEnum|Function 1 72 sqrt MathObjectImp::Sqrt DontEnum|Function 1 73 tan MathObjectImp::Tan DontEnum|Function 1 71 74 @end 72 75 */ … … 104 107 break; 105 108 case Pi: 106 d = 2.0 * asin(1.0);109 d = M_PI; 107 110 break; 108 111 case Sqrt1_2: -
trunk/JavaScriptCore/kjs/math_object.h
r798 r1024 18 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 * 20 * $Id$21 20 */ 22 21 -
trunk/JavaScriptCore/kjs/math_object.lut.h
r901 r1024 8 8 { "atan", MathObjectImp::ATan, DontEnum|Function, 1, &mathTableEntries[25] }, 9 9 { 0, 0, 0, 0, 0 }, 10 { "SQRT2", MathObjectImp::Sqrt2, DontEnum , 0, &mathTableEntries[23] },10 { "SQRT2", MathObjectImp::Sqrt2, DontEnum|DontDelete|ReadOnly, 0, &mathTableEntries[23] }, 11 11 { 0, 0, 0, 0, 0 }, 12 12 { 0, 0, 0, 0, 0 }, 13 13 { 0, 0, 0, 0, 0 }, 14 { "E", MathObjectImp::Euler, DontEnum , 0, &mathTableEntries[21] },14 { "E", MathObjectImp::Euler, DontEnum|DontDelete|ReadOnly, 0, &mathTableEntries[21] }, 15 15 { "asin", MathObjectImp::ASin, DontEnum|Function, 1, &mathTableEntries[26] }, 16 16 { "atan2", MathObjectImp::ATan2, DontEnum|Function, 2, &mathTableEntries[32] }, 17 { "LOG2E", MathObjectImp::Log2E, DontEnum , 0, &mathTableEntries[27] },17 { "LOG2E", MathObjectImp::Log2E, DontEnum|DontDelete|ReadOnly, 0, &mathTableEntries[27] }, 18 18 { "cos", MathObjectImp::Cos, DontEnum|Function, 1, 0 }, 19 19 { "max", MathObjectImp::Max, DontEnum|Function, 2, &mathTableEntries[29] }, 20 20 { 0, 0, 0, 0, 0 }, 21 21 { 0, 0, 0, 0, 0 }, 22 { "LOG10E", MathObjectImp::Log10E, DontEnum , 0, &mathTableEntries[24] },23 { "LN2", MathObjectImp::Ln2, DontEnum , 0, &mathTableEntries[31] },22 { "LOG10E", MathObjectImp::Log10E, DontEnum|DontDelete|ReadOnly, 0, &mathTableEntries[24] }, 23 { "LN2", MathObjectImp::Ln2, DontEnum|DontDelete|ReadOnly, 0, &mathTableEntries[31] }, 24 24 { "abs", MathObjectImp::Abs, DontEnum|Function, 1, 0 }, 25 25 { "sqrt", MathObjectImp::Sqrt, DontEnum|Function, 1, 0 }, 26 26 { "exp", MathObjectImp::Exp, DontEnum|Function, 1, 0 }, 27 27 { 0, 0, 0, 0, 0 }, 28 { "LN10", MathObjectImp::Ln10, DontEnum , 0, &mathTableEntries[22] },29 { "PI", MathObjectImp::Pi, DontEnum , 0, &mathTableEntries[28] },30 { "SQRT1_2", MathObjectImp::Sqrt1_2, DontEnum , 0, 0 },28 { "LN10", MathObjectImp::Ln10, DontEnum|DontDelete|ReadOnly, 0, &mathTableEntries[22] }, 29 { "PI", MathObjectImp::Pi, DontEnum|DontDelete|ReadOnly, 0, &mathTableEntries[28] }, 30 { "SQRT1_2", MathObjectImp::Sqrt1_2, DontEnum|DontDelete|ReadOnly, 0, 0 }, 31 31 { "acos", MathObjectImp::ACos, DontEnum|Function, 1, 0 }, 32 32 { "ceil", MathObjectImp::Ceil, DontEnum|Function, 1, 0 }, -
trunk/JavaScriptCore/kjs/nodes.cpp
r941 r1024 24 24 #include "nodes.h" 25 25 26 //#include <iostream> 27 #include <math.h> 26 28 #include <assert.h> 27 #ifdef APPLE_CHANGES 28 #include <iostream> 29 #else 30 #include <iostream.h> 31 #endif 32 #include <math.h> 29 #ifdef KJS_DEBUG_MEM 33 30 #include <stdio.h> 34 #ifdef KJS_DEBUG_MEM35 31 #include <typeinfo> 36 32 #endif … … 2542 2538 CaseClauseNode *clause; 2543 2539 2544 if (a) {2545 2540 while (a) { 2546 2541 clause = a->clause(); … … 2561 2556 } 2562 2557 } 2563 }2564 2558 2565 2559 while (b) { … … 2947 2941 /* TODO: workaround for empty body which I don't see covered by the spec */ 2948 2942 if (!source) 2949 return Completion( ReturnValue, Undefined());2943 return Completion(Normal); 2950 2944 2951 2945 source->processFuncDecl(exec); -
trunk/JavaScriptCore/kjs/nodes.h
r798 r1024 20 20 * Boston, MA 02111-1307, USA. 21 21 * 22 * $Id$23 22 */ 24 23 … … 39 38 class SourceElementsNode; 40 39 class ProgramNode; 40 class SourceStream; 41 41 42 42 enum Operator { OpEqual, … … 76 76 virtual ~Node(); 77 77 virtual Value evaluate(ExecState *exec) = 0; 78 UString toString() const; 79 virtual void streamTo(SourceStream &s) const = 0; 78 80 virtual void processVarDecls(ExecState */*exec*/) {} 79 81 int lineNo() const { return line; } … … 134 136 NullNode() {} 135 137 Value evaluate(ExecState *exec); 138 virtual void streamTo(SourceStream &s) const; 136 139 }; 137 140 … … 140 143 BooleanNode(bool v) : value(v) {} 141 144 Value evaluate(ExecState *exec); 145 virtual void streamTo(SourceStream &s) const; 142 146 private: 143 147 bool value; … … 148 152 NumberNode(double v) : value(v) { } 149 153 Value evaluate(ExecState *exec); 154 virtual void streamTo(SourceStream &s) const; 150 155 private: 151 156 double value; … … 156 161 StringNode(const UString *v) { value = *v; } 157 162 Value evaluate(ExecState *exec); 163 virtual void streamTo(SourceStream &s) const; 158 164 private: 159 165 UString value; … … 165 171 : pattern(p), flags(f) { } 166 172 Value evaluate(ExecState *exec); 173 virtual void streamTo(SourceStream &s) const; 167 174 private: 168 175 UString pattern, flags; … … 173 180 ThisNode() {} 174 181 Value evaluate(ExecState *exec); 182 virtual void streamTo(SourceStream &s) const; 175 183 }; 176 184 … … 179 187 ResolveNode(const UString *s) : ident(*s) { } 180 188 Value evaluate(ExecState *exec); 189 virtual void streamTo(SourceStream &s) const; 181 190 private: 182 191 UString ident; … … 190 199 virtual ~GroupNode(); 191 200 Value evaluate(ExecState *exec); 201 virtual void streamTo(SourceStream &s) const { group->streamTo(s); } 192 202 private: 193 203 Node *group; … … 201 211 virtual ~ElisionNode(); 202 212 Value evaluate(ExecState *exec); 213 virtual void streamTo(SourceStream &s) const; 203 214 private: 204 215 ElisionNode *elision; … … 207 218 class ElementNode : public Node { 208 219 public: 209 ElementNode(ElisionNode *e, Node *n) : list(0 l), elision(e), node(n) { }220 ElementNode(ElisionNode *e, Node *n) : list(0L), elision(e), node(n) { } 210 221 ElementNode(ElementNode *l, ElisionNode *e, Node *n) 211 222 : list(l), elision(e), node(n) { } … … 214 225 virtual ~ElementNode(); 215 226 Value evaluate(ExecState *exec); 227 virtual void streamTo(SourceStream &s) const; 216 228 private: 217 229 ElementNode *list; … … 231 243 virtual ~ArrayNode(); 232 244 Value evaluate(ExecState *exec); 245 virtual void streamTo(SourceStream &s) const; 233 246 private: 234 247 ElementNode *element; … … 244 257 virtual ~ObjectLiteralNode(); 245 258 Value evaluate(ExecState *exec); 259 virtual void streamTo(SourceStream &s) const; 246 260 private: 247 261 Node *list; … … 256 270 virtual ~PropertyValueNode(); 257 271 Value evaluate(ExecState *exec); 272 virtual void streamTo(SourceStream &s) const; 258 273 private: 259 274 Node *name, *assign, *list; … … 265 280 PropertyNode(const UString *s) : str(*s) { } 266 281 Value evaluate(ExecState *exec); 282 virtual void streamTo(SourceStream &s) const; 267 283 private: 268 284 double numeric; … … 277 293 virtual ~AccessorNode1(); 278 294 Value evaluate(ExecState *exec); 295 virtual void streamTo(SourceStream &s) const; 279 296 private: 280 297 Node *expr1; … … 289 306 virtual ~AccessorNode2(); 290 307 Value evaluate(ExecState *exec); 308 virtual void streamTo(SourceStream &s) const; 291 309 private: 292 310 Node *expr; … … 303 321 Value evaluate(ExecState *exec); 304 322 List evaluateList(ExecState *exec); 323 virtual void streamTo(SourceStream &s) const; 305 324 private: 306 325 ArgumentListNode *list; … … 316 335 Value evaluate(ExecState *exec); 317 336 List evaluateList(ExecState *exec); 337 virtual void streamTo(SourceStream &s) const; 318 338 private: 319 339 ArgumentListNode *list; … … 328 348 virtual ~NewExprNode(); 329 349 Value evaluate(ExecState *exec); 350 virtual void streamTo(SourceStream &s) const; 330 351 private: 331 352 Node *expr; … … 340 361 virtual ~FunctionCallNode(); 341 362 Value evaluate(ExecState *exec); 363 virtual void streamTo(SourceStream &s) const; 342 364 private: 343 365 Node *expr; … … 352 374 virtual ~PostfixNode(); 353 375 Value evaluate(ExecState *exec); 376 virtual void streamTo(SourceStream &s) const; 354 377 private: 355 378 Node *expr; … … 364 387 virtual ~DeleteNode(); 365 388 Value evaluate(ExecState *exec); 389 virtual void streamTo(SourceStream &s) const; 366 390 private: 367 391 Node *expr; … … 375 399 virtual ~VoidNode(); 376 400 Value evaluate(ExecState *exec); 401 virtual void streamTo(SourceStream &s) const; 377 402 private: 378 403 Node *expr; … … 386 411 virtual ~TypeOfNode(); 387 412 Value evaluate(ExecState *exec); 413 virtual void streamTo(SourceStream &s) const; 388 414 private: 389 415 Node *expr; … … 397 423 virtual ~PrefixNode(); 398 424 Value evaluate(ExecState *exec); 425 virtual void streamTo(SourceStream &s) const; 399 426 private: 400 427 Operator oper; … … 409 436 virtual ~UnaryPlusNode(); 410 437 Value evaluate(ExecState *exec); 438 virtual void streamTo(SourceStream &s) const; 411 439 private: 412 440 Node *expr; … … 420 448 virtual ~NegateNode(); 421 449 Value evaluate(ExecState *exec); 450 virtual void streamTo(SourceStream &s) const; 422 451 private: 423 452 Node *expr; … … 431 460 virtual ~BitwiseNotNode(); 432 461 Value evaluate(ExecState *exec); 462 virtual void streamTo(SourceStream &s) const; 433 463 private: 434 464 Node *expr; … … 442 472 virtual ~LogicalNotNode(); 443 473 Value evaluate(ExecState *exec); 474 virtual void streamTo(SourceStream &s) const; 444 475 private: 445 476 Node *expr; … … 453 484 virtual ~MultNode(); 454 485 Value evaluate(ExecState *exec); 486 virtual void streamTo(SourceStream &s) const; 455 487 private: 456 488 Node *term1, *term2; … … 465 497 virtual ~AddNode(); 466 498 Value evaluate(ExecState *exec); 499 virtual void streamTo(SourceStream &s) const; 467 500 private: 468 501 Node *term1, *term2; … … 478 511 virtual ~ShiftNode(); 479 512 Value evaluate(ExecState *exec); 513 virtual void streamTo(SourceStream &s) const; 480 514 private: 481 515 Node *term1, *term2; … … 491 525 virtual ~RelationalNode(); 492 526 Value evaluate(ExecState *exec); 527 virtual void streamTo(SourceStream &s) const; 493 528 private: 494 529 Node *expr1, *expr2; … … 504 539 virtual ~EqualNode(); 505 540 Value evaluate(ExecState *exec); 541 virtual void streamTo(SourceStream &s) const; 506 542 private: 507 543 Node *expr1, *expr2; … … 517 553 virtual ~BitOperNode(); 518 554 Value evaluate(ExecState *exec); 555 virtual void streamTo(SourceStream &s) const; 519 556 private: 520 557 Node *expr1, *expr2; … … 522 559 }; 523 560 524 /** expr1 && expr2, expr1 || expr2 */ 561 /** 562 * expr1 && expr2, expr1 || expr2 563 */ 525 564 class BinaryLogicalNode : public Node { 526 565 public: … … 531 570 virtual ~BinaryLogicalNode(); 532 571 Value evaluate(ExecState *exec); 572 virtual void streamTo(SourceStream &s) const; 533 573 private: 534 574 Node *expr1, *expr2; … … 536 576 }; 537 577 538 /** The ternary operator, "logical ? expr1 : expr2" */ 578 /** 579 * The ternary operator, "logical ? expr1 : expr2" 580 */ 539 581 class ConditionalNode : public Node { 540 582 public: … … 545 587 virtual ~ConditionalNode(); 546 588 Value evaluate(ExecState *exec); 589 virtual void streamTo(SourceStream &s) const; 547 590 private: 548 591 Node *logical, *expr1, *expr2; … … 556 599 virtual ~AssignNode(); 557 600 Value evaluate(ExecState *exec); 601 virtual void streamTo(SourceStream &s) const; 558 602 private: 559 603 Node *left; … … 569 613 virtual ~CommaNode(); 570 614 Value evaluate(ExecState *exec); 615 virtual void streamTo(SourceStream &s) const; 571 616 private: 572 617 Node *expr1, *expr2; … … 582 627 virtual Completion execute(ExecState *exec); 583 628 virtual void processVarDecls(ExecState *exec); 629 virtual void streamTo(SourceStream &s) const; 584 630 private: 585 631 StatementNode *statement; … … 594 640 virtual ~AssignExprNode(); 595 641 Value evaluate(ExecState *exec); 642 virtual void streamTo(SourceStream &s) const; 596 643 private: 597 644 Node *expr; … … 606 653 Value evaluate(ExecState *exec); 607 654 virtual void processVarDecls(ExecState *exec); 655 virtual void streamTo(SourceStream &s) const; 608 656 private: 609 657 UString ident; … … 620 668 Value evaluate(ExecState *exec); 621 669 virtual void processVarDecls(ExecState *exec); 670 virtual void streamTo(SourceStream &s) const; 622 671 private: 623 672 Node *list; … … 633 682 virtual Completion execute(ExecState *exec); 634 683 virtual void processVarDecls(ExecState *exec); 684 virtual void streamTo(SourceStream &s) const; 635 685 private: 636 686 VarDeclListNode *list; … … 645 695 virtual Completion execute(ExecState *exec); 646 696 virtual void processVarDecls(ExecState *exec); 697 virtual void streamTo(SourceStream &s) const; 647 698 private: 648 699 SourceElementsNode *source; … … 653 704 EmptyStatementNode() { } // debug 654 705 virtual Completion execute(ExecState *exec); 706 virtual void streamTo(SourceStream &s) const; 655 707 }; 656 708 … … 662 714 virtual ~ExprStatementNode(); 663 715 virtual Completion execute(ExecState *exec); 716 virtual void streamTo(SourceStream &s) const; 664 717 private: 665 718 Node *expr; … … 675 728 virtual Completion execute(ExecState *exec); 676 729 virtual void processVarDecls(ExecState *exec); 730 virtual void streamTo(SourceStream &s) const; 677 731 private: 678 732 Node *expr; … … 688 742 virtual Completion execute(ExecState *exec); 689 743 virtual void processVarDecls(ExecState *exec); 744 virtual void streamTo(SourceStream &s) const; 690 745 private: 691 746 StatementNode *statement; … … 701 756 virtual Completion execute(ExecState *exec); 702 757 virtual void processVarDecls(ExecState *exec); 758 virtual void streamTo(SourceStream &s) const; 703 759 private: 704 760 Node *expr; … … 715 771 virtual Completion execute(ExecState *exec); 716 772 virtual void processVarDecls(ExecState *exec); 773 virtual void streamTo(SourceStream &s) const; 717 774 private: 718 775 Node *expr1, *expr2, *expr3; … … 729 786 virtual Completion execute(ExecState *exec); 730 787 virtual void processVarDecls(ExecState *exec); 788 virtual void streamTo(SourceStream &s) const; 731 789 private: 732 790 UString ident; … … 742 800 ContinueNode(const UString *i) : ident(*i) { } 743 801 virtual Completion execute(ExecState *exec); 802 virtual void streamTo(SourceStream &s) const; 744 803 private: 745 804 UString ident; … … 751 810 BreakNode(const UString *i) : ident(*i) { } 752 811 virtual Completion execute(ExecState *exec); 812 virtual void streamTo(SourceStream &s) const; 753 813 private: 754 814 UString ident; … … 762 822 virtual ~ReturnNode(); 763 823 virtual Completion execute(ExecState *exec); 824 virtual void streamTo(SourceStream &s) const; 764 825 private: 765 826 Node *value; … … 774 835 virtual Completion execute(ExecState *exec); 775 836 virtual void processVarDecls(ExecState *exec); 837 virtual void streamTo(SourceStream &s) const; 776 838 private: 777 839 Node *expr; … … 788 850 Completion evalStatements(ExecState *exec); 789 851 virtual void processVarDecls(ExecState *exec); 852 virtual void streamTo(SourceStream &s) const; 790 853 private: 791 854 Node *expr; … … 804 867 ClauseListNode *next() const { return nx; } 805 868 virtual void processVarDecls(ExecState *exec); 869 virtual void streamTo(SourceStream &s) const; 806 870 private: 807 871 CaseClauseNode *cl; … … 819 883 Completion evalBlock(ExecState *exec, const Value& input); 820 884 virtual void processVarDecls(ExecState *exec); 885 virtual void streamTo(SourceStream &s) const; 821 886 private: 822 887 ClauseListNode *list1; … … 833 898 virtual Completion execute(ExecState *exec); 834 899 virtual void processVarDecls(ExecState *exec); 900 virtual void streamTo(SourceStream &s) const; 835 901 private: 836 902 Node *expr; … … 846 912 virtual Completion execute(ExecState *exec); 847 913 virtual void processVarDecls(ExecState *exec); 914 virtual void streamTo(SourceStream &s) const; 848 915 private: 849 916 UString label; … … 858 925 virtual ~ThrowNode(); 859 926 virtual Completion execute(ExecState *exec); 927 virtual void streamTo(SourceStream &s) const; 860 928 private: 861 929 Node *expr; … … 871 939 Completion execute(ExecState *exec, const Value &arg); 872 940 virtual void processVarDecls(ExecState *exec); 941 virtual void streamTo(SourceStream &s) const; 873 942 private: 874 943 UString ident; … … 884 953 virtual Completion execute(ExecState *exec); 885 954 virtual void processVarDecls(ExecState *exec); 955 virtual void streamTo(SourceStream &s) const; 886 956 private: 887 957 StatementNode *block; … … 897 967 virtual Completion execute(ExecState *exec); 898 968 virtual void processVarDecls(ExecState *exec); 969 virtual void streamTo(SourceStream &s) const; 899 970 private: 900 971 StatementNode *block; … … 913 984 UString ident() { return id; } 914 985 ParameterNode *nextParam() { return next; } 986 virtual void streamTo(SourceStream &s) const; 915 987 private: 916 988 UString id; … … 928 1000 virtual void processFuncDecl(ExecState *exec); 929 1001 virtual void processVarDecls(ExecState *exec); 1002 void streamTo(SourceStream &s) const; 930 1003 protected: 931 1004 SourceElementsNode *source; … … 942 1015 { /* empty */ return Completion(); } 943 1016 void processFuncDecl(ExecState *exec); 1017 virtual void streamTo(SourceStream &s) const; 944 1018 private: 945 1019 UString ident; … … 956 1030 virtual ~FuncExprNode(); 957 1031 Value evaluate(ExecState *exec); 1032 virtual void streamTo(SourceStream &s) const; 958 1033 private: 959 1034 ParameterNode *param; … … 963 1038 class SourceElementNode : public StatementNode { 964 1039 public: 965 SourceElementNode(StatementNode *s) { statement = s; function = 0L;}966 SourceElementNode(FuncDeclNode *f) { function = f; statement = 0L;}1040 SourceElementNode(StatementNode *s) : statement(s), function(0L) { } 1041 SourceElementNode(FuncDeclNode *f) : statement(0L), function(f) { } 967 1042 virtual void ref(); 968 1043 virtual bool deref(); … … 971 1046 virtual void processFuncDecl(ExecState *exec); 972 1047 virtual void processVarDecls(ExecState *exec); 1048 virtual void streamTo(SourceStream &s) const; 973 1049 private: 974 1050 StatementNode *statement; … … 988 1064 virtual void processFuncDecl(ExecState *exec); 989 1065 virtual void processVarDecls(ExecState *exec); 1066 virtual void streamTo(SourceStream &s) const; 990 1067 private: 991 1068 SourceElementNode *element; // 'this' element -
trunk/JavaScriptCore/kjs/number_object.cpp
r798 r1024 18 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 * 20 * $Id$21 20 */ 22 21 -
trunk/JavaScriptCore/kjs/number_object.h
r798 r1024 18 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 * 20 * $Id$21 20 */ 22 21 -
trunk/JavaScriptCore/kjs/object.cpp
r910 r1024 20 20 * Boston, MA 02111-1307, USA. 21 21 * 22 * $Id$23 22 */ 24 23 … … 109 108 } 110 109 111 bool Object::hasProperty(ExecState *exec, const UString &propertyName , bool recursive) const112 { 113 return static_cast<ObjectImp*>(rep)->hasProperty(exec, propertyName,recursive);110 bool Object::hasProperty(ExecState *exec, const UString &propertyName) const 111 { 112 return static_cast<ObjectImp*>(rep)->hasProperty(exec, propertyName); 114 113 } 115 114 … … 184 183 : _prop(0), _proto(static_cast<ObjectImp*>(proto.imp())), _internalValue(0L), _scope(0) 185 184 { 186 //fprintf(stderr,"ObjectImp::ObjectImp %p %s\n",(void*)this);185 //fprintf(stderr,"ObjectImp::ObjectImp %p\n",(void*)this); 187 186 _scope = ListImp::empty(); 188 187 _prop = new PropertyMap(); … … 191 190 ObjectImp::ObjectImp() 192 191 { 193 //fprintf(stderr,"ObjectImp::ObjectImp %p %s\n",(void*)this);192 //fprintf(stderr,"ObjectImp::ObjectImp %p\n",(void*)this); 194 193 _prop = 0; 195 194 _proto = NullImp::staticNull; … … 357 356 358 357 // ECMA 8.6.2.4 359 bool ObjectImp::hasProperty(ExecState *exec, const UString &propertyName , bool recursive) const358 bool ObjectImp::hasProperty(ExecState *exec, const UString &propertyName) const 360 359 { 361 360 if (propertyName == "__proto__") … … 370 369 // Look in the prototype 371 370 Object proto = Object::dynamicCast(prototype()); 372 if (proto.isNull() || !recursive) 373 return false; 374 375 return proto.hasProperty(exec,propertyName); 371 return !proto.isNull() && proto.hasProperty(exec,propertyName); 376 372 } 377 373 … … 388 384 389 385 // Look in the static hashtable of properties 390 if (findPropertyHashEntry(propertyName)) 391 return false; // No builtin property can be deleted 386 const HashEntry* entry = findPropertyHashEntry(propertyName); 387 if (entry && entry->attr & DontDelete) 388 return false; // this builtin property can't be deleted 392 389 return true; 393 390 } -
trunk/JavaScriptCore/kjs/object.h
r798 r1024 42 42 // Attributes (only applicable to the Object type) 43 43 enum Attribute { None = 0, 44 45 46 47 48 44 ReadOnly = 1 << 1, // property can be only read, not written 45 DontEnum = 1 << 2, // property doesn't appear in (for .. in ..) 46 DontDelete = 1 << 3, // property can't be deleted 47 Internal = 1 << 4, // an internal property, set to by pass checks 48 Function = 1 << 5 }; // property is a function - only used by static hashtables 49 49 50 50 /** … … 164 164 * @return true if the object has the property, otherwise false 165 165 */ 166 bool hasProperty(ExecState *exec, const UString &propertyName, 167 bool recursive = true) const; 166 bool hasProperty(ExecState *exec, const UString &propertyName) const; 168 167 169 168 /** … … 488 487 * @see Object::hasProperty() 489 488 */ 490 virtual bool hasProperty(ExecState *exec, const UString &propertyName,491 bool recursive = true) const;489 virtual bool hasProperty(ExecState *exec, 490 const UString &propertyName) const; 492 491 493 492 /** … … 579 578 */ 580 579 enum ErrorType { GeneralError = 0, 581 582 583 584 585 586 580 EvalError = 1, 581 RangeError = 2, 582 ReferenceError = 3, 583 SyntaxError = 4, 584 TypeError = 5, 585 URIError = 6}; 587 586 588 587 /** -
trunk/JavaScriptCore/kjs/object_object.cpp
r798 r1024 18 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 * 20 * $Id$21 20 */ 22 21 -
trunk/JavaScriptCore/kjs/object_object.h
r798 r1024 18 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 * 20 * $Id$21 20 */ 22 21 -
trunk/JavaScriptCore/kjs/operations.h
r798 r1024 19 19 * Boston, MA 02111-1307, USA. 20 20 * 21 * $Id$22 21 */ 23 22 -
trunk/JavaScriptCore/kjs/property_map.cpp
r936 r1024 19 19 * Boston, MA 02111-1307, USA. 20 20 * 21 * $Id$22 21 */ 23 22 24 23 25 24 #include "property_map.h" 26 27 #include <config.h>28 25 29 26 #include <string.h> … … 129 126 PropertyMap::~PropertyMap() 130 127 { 131 #ifdef APPLE_CHANGES132 128 clear(); 133 #endif134 129 } 135 130 -
trunk/JavaScriptCore/kjs/property_map.h
r798 r1024 19 19 * Boston, MA 02111-1307, USA. 20 20 * 21 * $Id$22 21 */ 23 22 -
trunk/JavaScriptCore/kjs/regexp.cpp
r798 r1024 18 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 * 20 * $Id$21 20 */ 22 21 -
trunk/JavaScriptCore/kjs/regexp.h
r798 r1024 18 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 * 20 * $Id$21 20 */ 22 21 -
trunk/JavaScriptCore/kjs/regexp_object.cpp
r798 r1024 18 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 * 20 * $Id$21 20 */ 22 21 -
trunk/JavaScriptCore/kjs/regexp_object.h
r798 r1024 18 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 * 20 * $Id$21 20 */ 22 21 -
trunk/JavaScriptCore/kjs/string_object.cpp
r798 r1024 203 203 reg = imp->regExp(); 204 204 } 205 else if (a0.isA(StringType)) 206 { 205 else 206 { /* 207 * ECMA 15.5.4.12 String.prototype.search (regexp) 208 * If regexp is not an object whose [[Class]] property is "RegExp", it is 209 * replaced with the result of the expression new RegExp(regexp). 210 */ 207 211 reg = new RegExp(a0.toString(exec), RegExp::None); 208 }209 else210 {211 #ifndef NDEBUG212 printf("KJS: Match/Search. Argument is not a RegExp nor a String - returning Undefined\n");213 #endif214 result = Undefined();215 break;216 212 } 217 213 RegExpObjectImp* regExpObj = static_cast<RegExpObjectImp*>(exec->interpreter()->builtinRegExp().imp()); … … 241 237 242 238 RegExpObjectImp* regExpObj = static_cast<RegExpObjectImp*>(exec->interpreter()->builtinRegExp().imp()); 243 int **ovector = regExpObj->registerRegexp( reg, u );244 239 int lastIndex = 0; 245 240 u3 = a1.toString(exec); // replacement string 246 241 // This is either a loop (if global is set) or a one-way (if not). 247 242 do { 243 int **ovector = regExpObj->registerRegexp( reg, u ); 248 244 UString mstr = reg->match(u, lastIndex, &pos, ovector); 249 245 len = mstr.size(); 250 lastIndex = pos + u3.size(); 246 UString rstr(u3); 247 bool ok; 248 // check if u3 matches $1 or $2 etc 249 for (int i = 0; (i = rstr.find(UString("$"), i)) != -1; i++) { 250 if (i+1<rstr.size() && rstr[i+1] == '$') { // "$$" -> "$" 251 rstr = rstr.substr(0,i) + "$" + rstr.substr(i+2); 252 continue; 253 } 254 // Assume number part is one char exactly 255 unsigned long pos = rstr.substr(i+1,1).toULong(&ok); 256 if (ok && pos <= (unsigned)reg->subPatterns()) { 257 rstr = rstr.substr(0,i) 258 + u.substr((*ovector)[2*pos], 259 (*ovector)[2*pos+1]-(*ovector)[2*pos]) 260 + rstr.substr(i+2); 261 i += (*ovector)[2*pos+1]-(*ovector)[2*pos] - 1; // -1 offsets i++ 262 } 263 } 264 lastIndex = pos + rstr.size(); 251 265 if ( pos != -1 ) 252 u = u.substr(0, pos) + u3+ u.substr(pos + len);266 u = u.substr(0, pos) + rstr + u.substr(pos + len); 253 267 //fprintf(stderr,"pos=%d,len=%d,lastIndex=%d,u=%s\n",pos,len,lastIndex,u.ascii()); 254 268 } while ( global && pos != -1 ); … … 321 335 } 322 336 } 323 delete ovector;337 delete [] ovector; 324 338 } else if (a0.type() != UndefinedType) { 325 339 u2 = a0.toString(exec); -
trunk/JavaScriptCore/kjs/string_object.h
r798 r1024 18 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 * 20 * $Id$21 20 */ 22 21 -
trunk/JavaScriptCore/kjs/testkjs.cpp
r798 r1024 19 19 * Boston, MA 02111-1307, USA. 20 20 * 21 * $Id$22 21 */ 23 22 … … 64 63 // create interpreter 65 64 Interpreter interp(global); 65 // add debug() function 66 66 global.put(interp.globalExec(),"debug", Object(new TestFunctionImp())); 67 67 // add "print" for compatibility with the mozilla js shell 68 68 global.put(interp.globalExec(),"print", Object(new TestFunctionImp())); 69 70 // add debug() function71 // kjs->enableDebug();72 69 73 70 const int BufferSize = 200000; … … 79 76 if (!f) { 80 77 fprintf(stderr, "Error opening %s.\n", file); 81 return -1;78 return 2; 82 79 } 83 80 int num = fread(code, 1, BufferSize, f); … … 113 110 } 114 111 115 // delete kjs;116 112 } // end block, so that Interpreter and global get deleted 117 113 … … 122 118 Interpreter::finalCheck(); 123 119 #endif 124 return ret ;120 return ret ? 0 : 1; 125 121 } -
trunk/JavaScriptCore/kjs/types.cpp
r798 r1024 20 20 * Boston, MA 02111-1307, USA. 21 21 * 22 * $Id$23 22 */ 24 23 -
trunk/JavaScriptCore/kjs/types.h
r798 r1024 20 20 * Boston, MA 02111-1307, USA. 21 21 * 22 * $Id$23 22 */ 24 23 -
trunk/JavaScriptCore/kjs/ustring.cpp
r798 r1024 19 19 * Boston, MA 02111-1307, USA. 20 20 * 21 * $Id$22 21 */ 23 22 … … 182 181 UString::UString(char c) 183 182 { 184 rep = Rep::create(new UChar(0, c), 1); 183 UChar *d = new UChar[1]; 184 d[0] = UChar(0, c); 185 rep = Rep::create(d, 1); 185 186 } 186 187 … … 524 525 bool KJS::operator<(const UString& s1, const UString& s2) 525 526 { 526 int l1 = s1.size(); 527 int l2 = s2.size(); 527 const int l1 = s1.size(); 528 const int l2 = s2.size(); 529 const int lmin = l1 < l2 ? l1 : l2; 528 530 const UChar *c1 = s1.data(); 529 531 const UChar *c2 = s2.data(); 530 532 int l = 0; 531 int le = l1 < l2 ? l1 : l2; 532 while (l < le && *c1 == *c2) { 533 while (l < lmin && *c1 == *c2) { 533 534 c1++; 534 535 c2++; 535 536 l++; 536 537 } 537 if (l != le)538 if (l < lmin) 538 539 return (c1->unicode() < c2->unicode()); 539 540 540 return (l1 < l2 && !(*c1 == *c2));541 return (l1 < l2); 541 542 } 542 543 -
trunk/JavaScriptCore/kjs/ustring.h
r918 r1024 19 19 * Boston, MA 02111-1307, USA. 20 20 * 21 * $Id$22 21 */ 23 22 24 23 #ifndef _KJS_USTRING_H_ 25 24 #define _KJS_USTRING_H_ 26 27 #ifdef HAVE_CONFIG_H28 #include <config.h>29 #endif30 25 31 26 #ifdef APPLE_CHANGES … … 110 105 friend bool operator<(const UString& s1, const UString& s2); 111 106 112 u short uc;107 unsigned short uc; 113 108 }; 114 109 -
trunk/JavaScriptCore/kjs/value.cpp
r798 r1024 42 42 // ------------------------------ ValueImp ------------------------------------- 43 43 44 ValueImp::ValueImp() : refcount(0), _flags(0)45 { 44 ValueImp::ValueImp() : 45 refcount(0), 46 46 // Tell the garbage collector that this memory block corresponds to a real object now 47 _flags |= VI_CREATED; 47 _flags(VI_CREATED) 48 { 48 49 //fprintf(stderr,"ValueImp::ValueImp %p\n",(void*)this); 49 50 } … … 67 68 void ValueImp::setGcAllowed() 68 69 { 70 //fprintf(stderr,"ValueImp::setGcAllowed %p\n",(void*)this); 69 71 _flags |= VI_GCALLOWED; 70 72 } -
trunk/JavaScriptCore/kjs/value.h
r798 r1024 34 34 #endif 35 35 36 #include <stdlib.h> // Needed for size_t 37 36 38 #include "ustring.h" 37 38 #if APPLE_CHANGES39 #include <stdlib.h>40 #endif41 39 42 40 // Primitive data types … … 219 217 * Performs the ToUint32 type conversion operation on this value (ECMA 9.6) 220 218 */ 221 u int toUInt32(ExecState *exec) const;219 unsigned int toUInt32(ExecState *exec) const; 222 220 223 221 /**
Note:
See TracChangeset
for help on using the changeset viewer.