Changeset 60631 in webkit for trunk/JavaScriptCore/runtime
- Timestamp:
- Jun 3, 2010, 1:00:18 PM (15 years ago)
- Location:
- trunk/JavaScriptCore/runtime
- Files:
-
- 31 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/ArrayConstructor.cpp
r60392 r60631 36 36 ASSERT_CLASS_FITS_IN_CELL(ArrayConstructor); 37 37 38 static JSValue JSC_HOST_CALL arrayConstructorIsArray(ExecState*);38 static EncodedJSValue JSC_HOST_CALL arrayConstructorIsArray(ExecState*); 39 39 40 40 ArrayConstructor::ArrayConstructor(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, ArrayPrototype* arrayPrototype, Structure* prototypeFunctionStructure) … … 77 77 } 78 78 79 static JSValue JSC_HOST_CALL callArrayConstructor(ExecState* exec)79 static EncodedJSValue JSC_HOST_CALL callArrayConstructor(ExecState* exec) 80 80 { 81 81 ArgList args(exec); 82 return constructArrayWithSizeQuirk(exec, args);82 return JSValue::encode(constructArrayWithSizeQuirk(exec, args)); 83 83 } 84 84 … … 91 91 } 92 92 93 JSValue JSC_HOST_CALL arrayConstructorIsArray(ExecState* exec)93 EncodedJSValue JSC_HOST_CALL arrayConstructorIsArray(ExecState* exec) 94 94 { 95 return jsBoolean(exec->argument(0).inherits(&JSArray::info));95 return JSValue::encode(jsBoolean(exec->argument(0).inherits(&JSArray::info))); 96 96 } 97 97 -
trunk/JavaScriptCore/runtime/ArrayPrototype.cpp
r60392 r60631 41 41 ASSERT_CLASS_FITS_IN_CELL(ArrayPrototype); 42 42 43 static JSValue JSC_HOST_CALL arrayProtoFuncToString(ExecState*);44 static JSValue JSC_HOST_CALL arrayProtoFuncToLocaleString(ExecState*);45 static JSValue JSC_HOST_CALL arrayProtoFuncConcat(ExecState*);46 static JSValue JSC_HOST_CALL arrayProtoFuncJoin(ExecState*);47 static JSValue JSC_HOST_CALL arrayProtoFuncPop(ExecState*);48 static JSValue JSC_HOST_CALL arrayProtoFuncPush(ExecState*);49 static JSValue JSC_HOST_CALL arrayProtoFuncReverse(ExecState*);50 static JSValue JSC_HOST_CALL arrayProtoFuncShift(ExecState*);51 static JSValue JSC_HOST_CALL arrayProtoFuncSlice(ExecState*);52 static JSValue JSC_HOST_CALL arrayProtoFuncSort(ExecState*);53 static JSValue JSC_HOST_CALL arrayProtoFuncSplice(ExecState*);54 static JSValue JSC_HOST_CALL arrayProtoFuncUnShift(ExecState*);55 static JSValue JSC_HOST_CALL arrayProtoFuncEvery(ExecState*);56 static JSValue JSC_HOST_CALL arrayProtoFuncForEach(ExecState*);57 static JSValue JSC_HOST_CALL arrayProtoFuncSome(ExecState*);58 static JSValue JSC_HOST_CALL arrayProtoFuncIndexOf(ExecState*);59 static JSValue JSC_HOST_CALL arrayProtoFuncFilter(ExecState*);60 static JSValue JSC_HOST_CALL arrayProtoFuncMap(ExecState*);61 static JSValue JSC_HOST_CALL arrayProtoFuncReduce(ExecState*);62 static JSValue JSC_HOST_CALL arrayProtoFuncReduceRight(ExecState*);63 static JSValue JSC_HOST_CALL arrayProtoFuncLastIndexOf(ExecState*);43 static EncodedJSValue JSC_HOST_CALL arrayProtoFuncToString(ExecState*); 44 static EncodedJSValue JSC_HOST_CALL arrayProtoFuncToLocaleString(ExecState*); 45 static EncodedJSValue JSC_HOST_CALL arrayProtoFuncConcat(ExecState*); 46 static EncodedJSValue JSC_HOST_CALL arrayProtoFuncJoin(ExecState*); 47 static EncodedJSValue JSC_HOST_CALL arrayProtoFuncPop(ExecState*); 48 static EncodedJSValue JSC_HOST_CALL arrayProtoFuncPush(ExecState*); 49 static EncodedJSValue JSC_HOST_CALL arrayProtoFuncReverse(ExecState*); 50 static EncodedJSValue JSC_HOST_CALL arrayProtoFuncShift(ExecState*); 51 static EncodedJSValue JSC_HOST_CALL arrayProtoFuncSlice(ExecState*); 52 static EncodedJSValue JSC_HOST_CALL arrayProtoFuncSort(ExecState*); 53 static EncodedJSValue JSC_HOST_CALL arrayProtoFuncSplice(ExecState*); 54 static EncodedJSValue JSC_HOST_CALL arrayProtoFuncUnShift(ExecState*); 55 static EncodedJSValue JSC_HOST_CALL arrayProtoFuncEvery(ExecState*); 56 static EncodedJSValue JSC_HOST_CALL arrayProtoFuncForEach(ExecState*); 57 static EncodedJSValue JSC_HOST_CALL arrayProtoFuncSome(ExecState*); 58 static EncodedJSValue JSC_HOST_CALL arrayProtoFuncIndexOf(ExecState*); 59 static EncodedJSValue JSC_HOST_CALL arrayProtoFuncFilter(ExecState*); 60 static EncodedJSValue JSC_HOST_CALL arrayProtoFuncMap(ExecState*); 61 static EncodedJSValue JSC_HOST_CALL arrayProtoFuncReduce(ExecState*); 62 static EncodedJSValue JSC_HOST_CALL arrayProtoFuncReduceRight(ExecState*); 63 static EncodedJSValue JSC_HOST_CALL arrayProtoFuncLastIndexOf(ExecState*); 64 64 65 65 } … … 150 150 } 151 151 152 JSValue JSC_HOST_CALL arrayProtoFuncToString(ExecState* exec)152 EncodedJSValue JSC_HOST_CALL arrayProtoFuncToString(ExecState* exec) 153 153 { 154 154 JSValue thisValue = exec->hostThisValue(); 155 155 bool isRealArray = isJSArray(&exec->globalData(), thisValue); 156 156 if (!isRealArray && !thisValue.inherits(&JSArray::info)) 157 return throwError(exec, TypeError);157 return JSValue::encode(throwError(exec, TypeError)); 158 158 JSArray* thisObj = asArray(thisValue); 159 159 … … 161 161 if (arrayVisitedElements.size() >= MaxSmallThreadReentryDepth) { 162 162 if (arrayVisitedElements.size() >= exec->globalData().maxReentryDepth) 163 return throwError(exec, RangeError, "Maximum call stack size exceeded.");163 return JSValue::encode(throwError(exec, RangeError, "Maximum call stack size exceeded.")); 164 164 } 165 165 166 166 bool alreadyVisited = !arrayVisitedElements.add(thisObj).second; 167 167 if (alreadyVisited) 168 return jsEmptyString(exec); // return an empty string, avoiding infinite recursion.168 return JSValue::encode(jsEmptyString(exec)); // return an empty string, avoiding infinite recursion. 169 169 170 170 unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); … … 194 194 arrayVisitedElements.remove(thisObj); 195 195 if (!totalSize) 196 return jsEmptyString(exec);196 return JSValue::encode(jsEmptyString(exec)); 197 197 Vector<UChar> buffer; 198 198 buffer.reserveCapacity(totalSize); 199 199 if (!buffer.data()) 200 return throwOutOfMemoryError(exec);200 return JSValue::encode(throwOutOfMemoryError(exec)); 201 201 202 202 for (unsigned i = 0; i < length; i++) { … … 207 207 } 208 208 ASSERT(buffer.size() == totalSize); 209 return jsString(exec, UString::adopt(buffer));210 } 211 212 JSValue JSC_HOST_CALL arrayProtoFuncToLocaleString(ExecState* exec)209 return JSValue::encode(jsString(exec, UString::adopt(buffer))); 210 } 211 212 EncodedJSValue JSC_HOST_CALL arrayProtoFuncToLocaleString(ExecState* exec) 213 213 { 214 214 JSValue thisValue = exec->hostThisValue(); 215 215 if (!thisValue.inherits(&JSArray::info)) 216 return throwError(exec, TypeError);216 return JSValue::encode(throwError(exec, TypeError)); 217 217 JSObject* thisObj = asArray(thisValue); 218 218 … … 220 220 if (arrayVisitedElements.size() >= MaxSmallThreadReentryDepth) { 221 221 if (arrayVisitedElements.size() >= exec->globalData().maxReentryDepth) 222 return throwError(exec, RangeError, "Maximum call stack size exceeded.");222 return JSValue::encode(throwError(exec, RangeError, "Maximum call stack size exceeded.")); 223 223 } 224 224 225 225 bool alreadyVisited = !arrayVisitedElements.add(thisObj).second; 226 226 if (alreadyVisited) 227 return jsEmptyString(exec); // return an empty string, avoding infinite recursion.227 return JSValue::encode(jsEmptyString(exec)); // return an empty string, avoding infinite recursion. 228 228 229 229 JSStringBuilder strBuffer; … … 239 239 UString str; 240 240 CallData callData; 241 CallType callType = conversionFunction.getCallData(callData);241 CallType callType = getCallData(conversionFunction, callData); 242 242 if (callType != CallTypeNone) 243 243 str = call(exec, conversionFunction, callType, callData, element, exec->emptyList()).toString(exec); … … 248 248 } 249 249 arrayVisitedElements.remove(thisObj); 250 return strBuffer.build(exec);251 } 252 253 JSValue JSC_HOST_CALL arrayProtoFuncJoin(ExecState* exec)250 return JSValue::encode(strBuffer.build(exec)); 251 } 252 253 EncodedJSValue JSC_HOST_CALL arrayProtoFuncJoin(ExecState* exec) 254 254 { 255 255 JSValue thisValue = exec->hostThisValue(); … … 259 259 if (arrayVisitedElements.size() >= MaxSmallThreadReentryDepth) { 260 260 if (arrayVisitedElements.size() >= exec->globalData().maxReentryDepth) 261 return throwError(exec, RangeError, "Maximum call stack size exceeded.");261 return JSValue::encode(throwError(exec, RangeError, "Maximum call stack size exceeded.")); 262 262 } 263 263 264 264 bool alreadyVisited = !arrayVisitedElements.add(thisObj).second; 265 265 if (alreadyVisited) 266 return jsEmptyString(exec); // return an empty string, avoding infinite recursion.266 return JSValue::encode(jsEmptyString(exec)); // return an empty string, avoding infinite recursion. 267 267 268 268 JSStringBuilder strBuffer; … … 320 320 } 321 321 arrayVisitedElements.remove(thisObj); 322 return strBuffer.build(exec);323 } 324 325 JSValue JSC_HOST_CALL arrayProtoFuncConcat(ExecState* exec)322 return JSValue::encode(strBuffer.build(exec)); 323 } 324 325 EncodedJSValue JSC_HOST_CALL arrayProtoFuncConcat(ExecState* exec) 326 326 { 327 327 JSValue thisValue = exec->hostThisValue(); … … 350 350 } 351 351 arr->setLength(n); 352 return arr;353 } 354 355 JSValue JSC_HOST_CALL arrayProtoFuncPop(ExecState* exec)352 return JSValue::encode(arr); 353 } 354 355 EncodedJSValue JSC_HOST_CALL arrayProtoFuncPop(ExecState* exec) 356 356 { 357 357 JSValue thisValue = exec->hostThisValue(); 358 358 if (isJSArray(&exec->globalData(), thisValue)) 359 return asArray(thisValue)->pop();359 return JSValue::encode(asArray(thisValue)->pop()); 360 360 361 361 JSObject* thisObj = thisValue.toThisObject(exec); … … 370 370 putProperty(exec, thisObj, exec->propertyNames().length, jsNumber(exec, length - 1)); 371 371 } 372 return result;373 } 374 375 JSValue JSC_HOST_CALL arrayProtoFuncPush(ExecState* exec)372 return JSValue::encode(result); 373 } 374 375 EncodedJSValue JSC_HOST_CALL arrayProtoFuncPush(ExecState* exec) 376 376 { 377 377 JSValue thisValue = exec->hostThisValue(); … … 379 379 JSArray* array = asArray(thisValue); 380 380 array->push(exec, exec->argument(0)); 381 return jsNumber(exec, array->length());381 return JSValue::encode(jsNumber(exec, array->length())); 382 382 } 383 383 … … 388 388 length += exec->argumentCount(); 389 389 putProperty(exec, thisObj, exec->propertyNames().length, jsNumber(exec, length)); 390 return jsNumber(exec, length);391 } 392 393 JSValue JSC_HOST_CALL arrayProtoFuncReverse(ExecState* exec)390 return JSValue::encode(jsNumber(exec, length)); 391 } 392 393 EncodedJSValue JSC_HOST_CALL arrayProtoFuncReverse(ExecState* exec) 394 394 { 395 395 JSValue thisValue = exec->hostThisValue(); … … 413 413 thisObj->deleteProperty(exec, lk1); 414 414 } 415 return thisObj;416 } 417 418 JSValue JSC_HOST_CALL arrayProtoFuncShift(ExecState* exec)415 return JSValue::encode(thisObj); 416 } 417 418 EncodedJSValue JSC_HOST_CALL arrayProtoFuncShift(ExecState* exec) 419 419 { 420 420 JSValue thisValue = exec->hostThisValue(); … … 437 437 putProperty(exec, thisObj, exec->propertyNames().length, jsNumber(exec, length - 1)); 438 438 } 439 return result;440 } 441 442 JSValue JSC_HOST_CALL arrayProtoFuncSlice(ExecState* exec)439 return JSValue::encode(result); 440 } 441 442 EncodedJSValue JSC_HOST_CALL arrayProtoFuncSlice(ExecState* exec) 443 443 { 444 444 JSValue thisValue = exec->hostThisValue(); … … 483 483 } 484 484 resObj->setLength(n); 485 return result;486 } 487 488 JSValue JSC_HOST_CALL arrayProtoFuncSort(ExecState* exec)485 return JSValue::encode(result); 486 } 487 488 EncodedJSValue JSC_HOST_CALL arrayProtoFuncSort(ExecState* exec) 489 489 { 490 490 JSValue thisValue = exec->hostThisValue(); … … 493 493 JSValue function = exec->argument(0); 494 494 CallData callData; 495 CallType callType = function.getCallData(callData);495 CallType callType = getCallData(function, callData); 496 496 497 497 if (thisObj->classInfo() == &JSArray::info) { … … 502 502 else 503 503 asArray(thisObj)->sort(exec); 504 return thisObj;504 return JSValue::encode(thisObj); 505 505 } 506 506 … … 508 508 509 509 if (!length) 510 return thisObj;510 return JSValue::encode(thisObj); 511 511 512 512 // "Min" sort. Not the fastest, but definitely less code than heapsort … … 542 542 } 543 543 } 544 return thisObj;545 } 546 547 JSValue JSC_HOST_CALL arrayProtoFuncSplice(ExecState* exec)544 return JSValue::encode(thisObj); 545 } 546 547 EncodedJSValue JSC_HOST_CALL arrayProtoFuncSplice(ExecState* exec) 548 548 { 549 549 JSValue thisValue = exec->hostThisValue(); … … 556 556 // FIXME: Firefox returns an empty array. 557 557 if (!exec->argumentCount()) 558 return jsUndefined();558 return JSValue::encode(jsUndefined()); 559 559 560 560 unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); … … 603 603 604 604 putProperty(exec, thisObj, exec->propertyNames().length, jsNumber(exec, length - deleteCount + additionalArgs)); 605 return result;606 } 607 608 JSValue JSC_HOST_CALL arrayProtoFuncUnShift(ExecState* exec)605 return JSValue::encode(result); 606 } 607 608 EncodedJSValue JSC_HOST_CALL arrayProtoFuncUnShift(ExecState* exec) 609 609 { 610 610 JSValue thisValue = exec->hostThisValue(); … … 626 626 JSValue result = jsNumber(exec, length + nrArgs); 627 627 putProperty(exec, thisObj, exec->propertyNames().length, result); 628 return result;629 } 630 631 JSValue JSC_HOST_CALL arrayProtoFuncFilter(ExecState* exec)628 return JSValue::encode(result); 629 } 630 631 EncodedJSValue JSC_HOST_CALL arrayProtoFuncFilter(ExecState* exec) 632 632 { 633 633 JSValue thisValue = exec->hostThisValue(); … … 636 636 JSValue function = exec->argument(0); 637 637 CallData callData; 638 CallType callType = function.getCallData(callData);638 CallType callType = getCallData(function, callData); 639 639 if (callType == CallTypeNone) 640 return throwError(exec, TypeError);640 return JSValue::encode(throwError(exec, TypeError)); 641 641 642 642 JSObject* applyThis = exec->argument(1).isUndefinedOrNull() ? exec->globalThisValue() : exec->argument(1).toObject(exec); … … 664 664 } 665 665 if (k == length) 666 return resultArray;666 return JSValue::encode(resultArray); 667 667 } 668 668 for (; k < length && !exec->hadException(); ++k) { … … 685 685 resultArray->put(exec, filterIndex++, v); 686 686 } 687 return resultArray;688 } 689 690 JSValue JSC_HOST_CALL arrayProtoFuncMap(ExecState* exec)687 return JSValue::encode(resultArray); 688 } 689 690 EncodedJSValue JSC_HOST_CALL arrayProtoFuncMap(ExecState* exec) 691 691 { 692 692 JSValue thisValue = exec->hostThisValue(); … … 695 695 JSValue function = exec->argument(0); 696 696 CallData callData; 697 CallType callType = function.getCallData(callData);697 CallType callType = getCallData(function, callData); 698 698 if (callType == CallTypeNone) 699 return throwError(exec, TypeError);699 return JSValue::encode(throwError(exec, TypeError)); 700 700 701 701 JSObject* applyThis = exec->argument(1).isUndefinedOrNull() ? exec->globalThisValue() : exec->argument(1).toObject(exec); … … 738 738 } 739 739 740 return resultArray;740 return JSValue::encode(resultArray); 741 741 } 742 742 … … 746 746 // http://developer-test.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:some 747 747 748 JSValue JSC_HOST_CALL arrayProtoFuncEvery(ExecState* exec)748 EncodedJSValue JSC_HOST_CALL arrayProtoFuncEvery(ExecState* exec) 749 749 { 750 750 JSValue thisValue = exec->hostThisValue(); … … 753 753 JSValue function = exec->argument(0); 754 754 CallData callData; 755 CallType callType = function.getCallData(callData);755 CallType callType = getCallData(function, callData); 756 756 if (callType == CallTypeNone) 757 return throwError(exec, TypeError);757 return JSValue::encode(throwError(exec, TypeError)); 758 758 759 759 JSObject* applyThis = exec->argument(1).isUndefinedOrNull() ? exec->globalThisValue() : exec->argument(1).toObject(exec); … … 777 777 JSValue result = cachedCall.call(); 778 778 if (!result.toBoolean(cachedCall.newCallFrame(exec))) 779 return jsBoolean(false);779 return JSValue::encode(jsBoolean(false)); 780 780 } 781 781 } … … 800 800 } 801 801 802 return result;803 } 804 805 JSValue JSC_HOST_CALL arrayProtoFuncForEach(ExecState* exec)802 return JSValue::encode(result); 803 } 804 805 EncodedJSValue JSC_HOST_CALL arrayProtoFuncForEach(ExecState* exec) 806 806 { 807 807 JSValue thisValue = exec->hostThisValue(); … … 810 810 JSValue function = exec->argument(0); 811 811 CallData callData; 812 CallType callType = function.getCallData(callData);812 CallType callType = getCallData(function, callData); 813 813 if (callType == CallTypeNone) 814 return throwError(exec, TypeError);814 return JSValue::encode(throwError(exec, TypeError)); 815 815 816 816 JSObject* applyThis = exec->argument(1).isUndefinedOrNull() ? exec->globalThisValue() : exec->argument(1).toObject(exec); … … 846 846 call(exec, function, callType, callData, applyThis, eachArguments); 847 847 } 848 return jsUndefined();849 } 850 851 JSValue JSC_HOST_CALL arrayProtoFuncSome(ExecState* exec)848 return JSValue::encode(jsUndefined()); 849 } 850 851 EncodedJSValue JSC_HOST_CALL arrayProtoFuncSome(ExecState* exec) 852 852 { 853 853 JSValue thisValue = exec->hostThisValue(); … … 856 856 JSValue function = exec->argument(0); 857 857 CallData callData; 858 CallType callType = function.getCallData(callData);858 CallType callType = getCallData(function, callData); 859 859 if (callType == CallTypeNone) 860 return throwError(exec, TypeError);860 return JSValue::encode(throwError(exec, TypeError)); 861 861 862 862 JSObject* applyThis = exec->argument(1).isUndefinedOrNull() ? exec->globalThisValue() : exec->argument(1).toObject(exec); … … 880 880 JSValue result = cachedCall.call(); 881 881 if (result.toBoolean(cachedCall.newCallFrame(exec))) 882 return jsBoolean(true);882 return JSValue::encode(jsBoolean(true)); 883 883 } 884 884 } … … 900 900 } 901 901 } 902 return result;903 } 904 905 JSValue JSC_HOST_CALL arrayProtoFuncReduce(ExecState* exec)902 return JSValue::encode(result); 903 } 904 905 EncodedJSValue JSC_HOST_CALL arrayProtoFuncReduce(ExecState* exec) 906 906 { 907 907 JSValue thisValue = exec->hostThisValue(); … … 910 910 JSValue function = exec->argument(0); 911 911 CallData callData; 912 CallType callType = function.getCallData(callData);912 CallType callType = getCallData(function, callData); 913 913 if (callType == CallTypeNone) 914 return throwError(exec, TypeError);914 return JSValue::encode(throwError(exec, TypeError)); 915 915 916 916 unsigned i = 0; … … 918 918 unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); 919 919 if (!length && exec->argumentCount() == 1) 920 return throwError(exec, TypeError);920 return JSValue::encode(throwError(exec, TypeError)); 921 921 JSArray* array = 0; 922 922 if (isJSArray(&exec->globalData(), thisObj)) … … 935 935 } 936 936 if (!rv) 937 return throwError(exec, TypeError);937 return JSValue::encode(throwError(exec, TypeError)); 938 938 i++; 939 939 } … … 955 955 } 956 956 if (i == length) // only return if we reached the end of the array 957 return rv;957 return JSValue::encode(rv); 958 958 } 959 959 … … 971 971 rv = call(exec, function, callType, callData, jsNull(), eachArguments); 972 972 } 973 return rv;974 } 975 976 JSValue JSC_HOST_CALL arrayProtoFuncReduceRight(ExecState* exec)973 return JSValue::encode(rv); 974 } 975 976 EncodedJSValue JSC_HOST_CALL arrayProtoFuncReduceRight(ExecState* exec) 977 977 { 978 978 JSValue thisValue = exec->hostThisValue(); … … 981 981 JSValue function = exec->argument(0); 982 982 CallData callData; 983 CallType callType = function.getCallData(callData);983 CallType callType = getCallData(function, callData); 984 984 if (callType == CallTypeNone) 985 return throwError(exec, TypeError);985 return JSValue::encode(throwError(exec, TypeError)); 986 986 987 987 unsigned i = 0; … … 989 989 unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); 990 990 if (!length && exec->argumentCount() == 1) 991 return throwError(exec, TypeError);991 return JSValue::encode(throwError(exec, TypeError)); 992 992 JSArray* array = 0; 993 993 if (isJSArray(&exec->globalData(), thisObj)) … … 1006 1006 } 1007 1007 if (!rv) 1008 return throwError(exec, TypeError);1008 return JSValue::encode(throwError(exec, TypeError)); 1009 1009 i++; 1010 1010 } … … 1024 1024 } 1025 1025 if (i == length) // only return if we reached the end of the array 1026 return rv;1026 return JSValue::encode(rv); 1027 1027 } 1028 1028 … … 1041 1041 rv = call(exec, function, callType, callData, jsNull(), eachArguments); 1042 1042 } 1043 return rv;1044 } 1045 1046 JSValue JSC_HOST_CALL arrayProtoFuncIndexOf(ExecState* exec)1043 return JSValue::encode(rv); 1044 } 1045 1046 EncodedJSValue JSC_HOST_CALL arrayProtoFuncIndexOf(ExecState* exec) 1047 1047 { 1048 1048 JSValue thisValue = exec->hostThisValue(); … … 1070 1070 continue; 1071 1071 if (JSValue::strictEqual(exec, searchElement, e)) 1072 return jsNumber(exec, index);1073 } 1074 1075 return jsNumber(exec, -1);1076 } 1077 1078 JSValue JSC_HOST_CALL arrayProtoFuncLastIndexOf(ExecState* exec)1072 return JSValue::encode(jsNumber(exec, index)); 1073 } 1074 1075 return JSValue::encode(jsNumber(exec, -1)); 1076 } 1077 1078 EncodedJSValue JSC_HOST_CALL arrayProtoFuncLastIndexOf(ExecState* exec) 1079 1079 { 1080 1080 JSValue thisValue = exec->hostThisValue(); … … 1091 1091 d += length; 1092 1092 if (d < 0) 1093 return jsNumber(exec, -1);1093 return JSValue::encode(jsNumber(exec, -1)); 1094 1094 } 1095 1095 if (d < length) … … 1102 1102 continue; 1103 1103 if (JSValue::strictEqual(exec, searchElement, e)) 1104 return jsNumber(exec, index);1105 } 1106 1107 return jsNumber(exec, -1);1104 return JSValue::encode(jsNumber(exec, index)); 1105 } 1106 1107 return JSValue::encode(jsNumber(exec, -1)); 1108 1108 } 1109 1109 -
trunk/JavaScriptCore/runtime/BooleanConstructor.cpp
r60392 r60631 58 58 59 59 // ECMA 15.6.1 60 static JSValue JSC_HOST_CALL callBooleanConstructor(ExecState* exec)60 static EncodedJSValue JSC_HOST_CALL callBooleanConstructor(ExecState* exec) 61 61 { 62 return jsBoolean(exec->argument(0).toBoolean(exec));62 return JSValue::encode(jsBoolean(exec->argument(0).toBoolean(exec))); 63 63 } 64 64 -
trunk/JavaScriptCore/runtime/BooleanPrototype.cpp
r60392 r60631 33 33 34 34 // Functions 35 static JSValue JSC_HOST_CALL booleanProtoFuncToString(ExecState*);36 static JSValue JSC_HOST_CALL booleanProtoFuncValueOf(ExecState*);35 static EncodedJSValue JSC_HOST_CALL booleanProtoFuncToString(ExecState*); 36 static EncodedJSValue JSC_HOST_CALL booleanProtoFuncValueOf(ExecState*); 37 37 38 38 // ECMA 15.6.4 … … 52 52 // ECMA 15.6.4.2 + 15.6.4.3 53 53 54 JSValue JSC_HOST_CALL booleanProtoFuncToString(ExecState* exec)54 EncodedJSValue JSC_HOST_CALL booleanProtoFuncToString(ExecState* exec) 55 55 { 56 56 JSValue thisValue = exec->hostThisValue(); 57 57 if (thisValue == jsBoolean(false)) 58 return jsNontrivialString(exec, "false");58 return JSValue::encode(jsNontrivialString(exec, "false")); 59 59 60 60 if (thisValue == jsBoolean(true)) 61 return jsNontrivialString(exec, "true");61 return JSValue::encode(jsNontrivialString(exec, "true")); 62 62 63 63 if (!thisValue.inherits(&BooleanObject::info)) 64 return throwError(exec, TypeError);64 return JSValue::encode(throwError(exec, TypeError)); 65 65 66 66 if (asBooleanObject(thisValue)->internalValue() == jsBoolean(false)) 67 return jsNontrivialString(exec, "false");67 return JSValue::encode(jsNontrivialString(exec, "false")); 68 68 69 69 ASSERT(asBooleanObject(thisValue)->internalValue() == jsBoolean(true)); 70 return jsNontrivialString(exec, "true");70 return JSValue::encode(jsNontrivialString(exec, "true")); 71 71 } 72 72 73 JSValue JSC_HOST_CALL booleanProtoFuncValueOf(ExecState* exec)73 EncodedJSValue JSC_HOST_CALL booleanProtoFuncValueOf(ExecState* exec) 74 74 { 75 75 JSValue thisValue = exec->hostThisValue(); 76 76 if (thisValue.isBoolean()) 77 return thisValue;77 return JSValue::encode(thisValue); 78 78 79 79 if (!thisValue.inherits(&BooleanObject::info)) 80 return throwError(exec, TypeError);80 return JSValue::encode(throwError(exec, TypeError)); 81 81 82 return asBooleanObject(thisValue)->internalValue();82 return JSValue::encode(asBooleanObject(thisValue)->internalValue()); 83 83 } 84 84 -
trunk/JavaScriptCore/runtime/CallData.h
r60392 r60631 30 30 #define CallData_h 31 31 32 #include "JSValue.h" 32 33 #include "NativeFunctionWrapper.h" 33 34 … … 38 39 class FunctionExecutable; 39 40 class JSObject; 40 class JSValue;41 41 class ScopeChainNode; 42 42 … … 47 47 }; 48 48 49 typedef JSValue (JSC_HOST_CALL *NativeFunction)(ExecState*);49 typedef EncodedJSValue (JSC_HOST_CALL *NativeFunction)(ExecState*); 50 50 51 51 union CallData { -
trunk/JavaScriptCore/runtime/DateConstructor.cpp
r60392 r60631 55 55 ASSERT_CLASS_FITS_IN_CELL(DateConstructor); 56 56 57 static JSValue JSC_HOST_CALL dateParse(ExecState*);58 static JSValue JSC_HOST_CALL dateNow(ExecState*);59 static JSValue JSC_HOST_CALL dateUTC(ExecState*);57 static EncodedJSValue JSC_HOST_CALL dateParse(ExecState*); 58 static EncodedJSValue JSC_HOST_CALL dateNow(ExecState*); 59 static EncodedJSValue JSC_HOST_CALL dateUTC(ExecState*); 60 60 61 61 DateConstructor::DateConstructor(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, Structure* prototypeFunctionStructure, DatePrototype* datePrototype) … … 129 129 130 130 // ECMA 15.9.2 131 static JSValue JSC_HOST_CALL callDate(ExecState* exec)131 static EncodedJSValue JSC_HOST_CALL callDate(ExecState* exec) 132 132 { 133 133 time_t localTime = time(0); … … 139 139 formatDate(ts, date); 140 140 formatTime(ts, time); 141 return jsMakeNontrivialString(exec, date, " ", time);141 return JSValue::encode(jsMakeNontrivialString(exec, date, " ", time)); 142 142 } 143 143 … … 148 148 } 149 149 150 static JSValue JSC_HOST_CALL dateParse(ExecState* exec)150 static EncodedJSValue JSC_HOST_CALL dateParse(ExecState* exec) 151 151 { 152 return jsNumber(exec, parseDate(exec, exec->argument(0).toString(exec)));152 return JSValue::encode(jsNumber(exec, parseDate(exec, exec->argument(0).toString(exec)))); 153 153 } 154 154 155 static JSValue JSC_HOST_CALL dateNow(ExecState* exec)155 static EncodedJSValue JSC_HOST_CALL dateNow(ExecState* exec) 156 156 { 157 return jsNumber(exec, jsCurrentTime());157 return JSValue::encode(jsNumber(exec, jsCurrentTime())); 158 158 } 159 159 160 static JSValue JSC_HOST_CALL dateUTC(ExecState* exec)160 static EncodedJSValue JSC_HOST_CALL dateUTC(ExecState* exec) 161 161 { 162 162 int n = exec->argumentCount(); … … 168 168 || (n >= 6 && isnan(exec->argument(5).toNumber(exec))) 169 169 || (n >= 7 && isnan(exec->argument(6).toNumber(exec)))) 170 return jsNaN(exec);170 return JSValue::encode(jsNaN(exec)); 171 171 172 172 GregorianDateTime t; … … 179 179 t.second = exec->argument(5).toInt32(exec); 180 180 double ms = (n >= 7) ? exec->argument(6).toNumber(exec) : 0; 181 return jsNumber(exec, timeClip(gregorianDateTimeToMS(exec, t, ms, true)));181 return JSValue::encode(jsNumber(exec, timeClip(gregorianDateTimeToMS(exec, t, ms, true)))); 182 182 } 183 183 -
trunk/JavaScriptCore/runtime/DatePrototype.cpp
r60392 r60631 74 74 ASSERT_CLASS_FITS_IN_CELL(DatePrototype); 75 75 76 static JSValue JSC_HOST_CALL dateProtoFuncGetDate(ExecState*);77 static JSValue JSC_HOST_CALL dateProtoFuncGetDay(ExecState*);78 static JSValue JSC_HOST_CALL dateProtoFuncGetFullYear(ExecState*);79 static JSValue JSC_HOST_CALL dateProtoFuncGetHours(ExecState*);80 static JSValue JSC_HOST_CALL dateProtoFuncGetMilliSeconds(ExecState*);81 static JSValue JSC_HOST_CALL dateProtoFuncGetMinutes(ExecState*);82 static JSValue JSC_HOST_CALL dateProtoFuncGetMonth(ExecState*);83 static JSValue JSC_HOST_CALL dateProtoFuncGetSeconds(ExecState*);84 static JSValue JSC_HOST_CALL dateProtoFuncGetTime(ExecState*);85 static JSValue JSC_HOST_CALL dateProtoFuncGetTimezoneOffset(ExecState*);86 static JSValue JSC_HOST_CALL dateProtoFuncGetUTCDate(ExecState*);87 static JSValue JSC_HOST_CALL dateProtoFuncGetUTCDay(ExecState*);88 static JSValue JSC_HOST_CALL dateProtoFuncGetUTCFullYear(ExecState*);89 static JSValue JSC_HOST_CALL dateProtoFuncGetUTCHours(ExecState*);90 static JSValue JSC_HOST_CALL dateProtoFuncGetUTCMilliseconds(ExecState*);91 static JSValue JSC_HOST_CALL dateProtoFuncGetUTCMinutes(ExecState*);92 static JSValue JSC_HOST_CALL dateProtoFuncGetUTCMonth(ExecState*);93 static JSValue JSC_HOST_CALL dateProtoFuncGetUTCSeconds(ExecState*);94 static JSValue JSC_HOST_CALL dateProtoFuncGetYear(ExecState*);95 static JSValue JSC_HOST_CALL dateProtoFuncSetDate(ExecState*);96 static JSValue JSC_HOST_CALL dateProtoFuncSetFullYear(ExecState*);97 static JSValue JSC_HOST_CALL dateProtoFuncSetHours(ExecState*);98 static JSValue JSC_HOST_CALL dateProtoFuncSetMilliSeconds(ExecState*);99 static JSValue JSC_HOST_CALL dateProtoFuncSetMinutes(ExecState*);100 static JSValue JSC_HOST_CALL dateProtoFuncSetMonth(ExecState*);101 static JSValue JSC_HOST_CALL dateProtoFuncSetSeconds(ExecState*);102 static JSValue JSC_HOST_CALL dateProtoFuncSetTime(ExecState*);103 static JSValue JSC_HOST_CALL dateProtoFuncSetUTCDate(ExecState*);104 static JSValue JSC_HOST_CALL dateProtoFuncSetUTCFullYear(ExecState*);105 static JSValue JSC_HOST_CALL dateProtoFuncSetUTCHours(ExecState*);106 static JSValue JSC_HOST_CALL dateProtoFuncSetUTCMilliseconds(ExecState*);107 static JSValue JSC_HOST_CALL dateProtoFuncSetUTCMinutes(ExecState*);108 static JSValue JSC_HOST_CALL dateProtoFuncSetUTCMonth(ExecState*);109 static JSValue JSC_HOST_CALL dateProtoFuncSetUTCSeconds(ExecState*);110 static JSValue JSC_HOST_CALL dateProtoFuncSetYear(ExecState*);111 static JSValue JSC_HOST_CALL dateProtoFuncToDateString(ExecState*);112 static JSValue JSC_HOST_CALL dateProtoFuncToGMTString(ExecState*);113 static JSValue JSC_HOST_CALL dateProtoFuncToLocaleDateString(ExecState*);114 static JSValue JSC_HOST_CALL dateProtoFuncToLocaleString(ExecState*);115 static JSValue JSC_HOST_CALL dateProtoFuncToLocaleTimeString(ExecState*);116 static JSValue JSC_HOST_CALL dateProtoFuncToString(ExecState*);117 static JSValue JSC_HOST_CALL dateProtoFuncToTimeString(ExecState*);118 static JSValue JSC_HOST_CALL dateProtoFuncToUTCString(ExecState*);119 static JSValue JSC_HOST_CALL dateProtoFuncToISOString(ExecState*);120 static JSValue JSC_HOST_CALL dateProtoFuncToJSON(ExecState*);76 static EncodedJSValue JSC_HOST_CALL dateProtoFuncGetDate(ExecState*); 77 static EncodedJSValue JSC_HOST_CALL dateProtoFuncGetDay(ExecState*); 78 static EncodedJSValue JSC_HOST_CALL dateProtoFuncGetFullYear(ExecState*); 79 static EncodedJSValue JSC_HOST_CALL dateProtoFuncGetHours(ExecState*); 80 static EncodedJSValue JSC_HOST_CALL dateProtoFuncGetMilliSeconds(ExecState*); 81 static EncodedJSValue JSC_HOST_CALL dateProtoFuncGetMinutes(ExecState*); 82 static EncodedJSValue JSC_HOST_CALL dateProtoFuncGetMonth(ExecState*); 83 static EncodedJSValue JSC_HOST_CALL dateProtoFuncGetSeconds(ExecState*); 84 static EncodedJSValue JSC_HOST_CALL dateProtoFuncGetTime(ExecState*); 85 static EncodedJSValue JSC_HOST_CALL dateProtoFuncGetTimezoneOffset(ExecState*); 86 static EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCDate(ExecState*); 87 static EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCDay(ExecState*); 88 static EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCFullYear(ExecState*); 89 static EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCHours(ExecState*); 90 static EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCMilliseconds(ExecState*); 91 static EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCMinutes(ExecState*); 92 static EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCMonth(ExecState*); 93 static EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCSeconds(ExecState*); 94 static EncodedJSValue JSC_HOST_CALL dateProtoFuncGetYear(ExecState*); 95 static EncodedJSValue JSC_HOST_CALL dateProtoFuncSetDate(ExecState*); 96 static EncodedJSValue JSC_HOST_CALL dateProtoFuncSetFullYear(ExecState*); 97 static EncodedJSValue JSC_HOST_CALL dateProtoFuncSetHours(ExecState*); 98 static EncodedJSValue JSC_HOST_CALL dateProtoFuncSetMilliSeconds(ExecState*); 99 static EncodedJSValue JSC_HOST_CALL dateProtoFuncSetMinutes(ExecState*); 100 static EncodedJSValue JSC_HOST_CALL dateProtoFuncSetMonth(ExecState*); 101 static EncodedJSValue JSC_HOST_CALL dateProtoFuncSetSeconds(ExecState*); 102 static EncodedJSValue JSC_HOST_CALL dateProtoFuncSetTime(ExecState*); 103 static EncodedJSValue JSC_HOST_CALL dateProtoFuncSetUTCDate(ExecState*); 104 static EncodedJSValue JSC_HOST_CALL dateProtoFuncSetUTCFullYear(ExecState*); 105 static EncodedJSValue JSC_HOST_CALL dateProtoFuncSetUTCHours(ExecState*); 106 static EncodedJSValue JSC_HOST_CALL dateProtoFuncSetUTCMilliseconds(ExecState*); 107 static EncodedJSValue JSC_HOST_CALL dateProtoFuncSetUTCMinutes(ExecState*); 108 static EncodedJSValue JSC_HOST_CALL dateProtoFuncSetUTCMonth(ExecState*); 109 static EncodedJSValue JSC_HOST_CALL dateProtoFuncSetUTCSeconds(ExecState*); 110 static EncodedJSValue JSC_HOST_CALL dateProtoFuncSetYear(ExecState*); 111 static EncodedJSValue JSC_HOST_CALL dateProtoFuncToDateString(ExecState*); 112 static EncodedJSValue JSC_HOST_CALL dateProtoFuncToGMTString(ExecState*); 113 static EncodedJSValue JSC_HOST_CALL dateProtoFuncToLocaleDateString(ExecState*); 114 static EncodedJSValue JSC_HOST_CALL dateProtoFuncToLocaleString(ExecState*); 115 static EncodedJSValue JSC_HOST_CALL dateProtoFuncToLocaleTimeString(ExecState*); 116 static EncodedJSValue JSC_HOST_CALL dateProtoFuncToString(ExecState*); 117 static EncodedJSValue JSC_HOST_CALL dateProtoFuncToTimeString(ExecState*); 118 static EncodedJSValue JSC_HOST_CALL dateProtoFuncToUTCString(ExecState*); 119 static EncodedJSValue JSC_HOST_CALL dateProtoFuncToISOString(ExecState*); 120 static EncodedJSValue JSC_HOST_CALL dateProtoFuncToJSON(ExecState*); 121 121 122 122 } … … 438 438 // Functions 439 439 440 JSValue JSC_HOST_CALL dateProtoFuncToString(ExecState* exec)441 { 442 JSValue thisValue = exec->hostThisValue(); 443 if (!thisValue.inherits(&DateInstance::info)) 444 return throwError(exec, TypeError);445 446 DateInstance* thisDateObj = asDateInstance(thisValue); 447 448 const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec); 449 if (!gregorianDateTime) 450 return jsNontrivialString(exec, "Invalid Date");440 EncodedJSValue JSC_HOST_CALL dateProtoFuncToString(ExecState* exec) 441 { 442 JSValue thisValue = exec->hostThisValue(); 443 if (!thisValue.inherits(&DateInstance::info)) 444 return JSValue::encode(throwError(exec, TypeError)); 445 446 DateInstance* thisDateObj = asDateInstance(thisValue); 447 448 const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec); 449 if (!gregorianDateTime) 450 return JSValue::encode(jsNontrivialString(exec, "Invalid Date")); 451 451 DateConversionBuffer date; 452 452 DateConversionBuffer time; 453 453 formatDate(*gregorianDateTime, date); 454 454 formatTime(*gregorianDateTime, time); 455 return jsMakeNontrivialString(exec, date, " ", time);456 } 457 458 JSValue JSC_HOST_CALL dateProtoFuncToUTCString(ExecState* exec)459 { 460 JSValue thisValue = exec->hostThisValue(); 461 if (!thisValue.inherits(&DateInstance::info)) 462 return throwError(exec, TypeError);455 return JSValue::encode(jsMakeNontrivialString(exec, date, " ", time)); 456 } 457 458 EncodedJSValue JSC_HOST_CALL dateProtoFuncToUTCString(ExecState* exec) 459 { 460 JSValue thisValue = exec->hostThisValue(); 461 if (!thisValue.inherits(&DateInstance::info)) 462 return JSValue::encode(throwError(exec, TypeError)); 463 463 464 464 DateInstance* thisDateObj = asDateInstance(thisValue); … … 466 466 const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(exec); 467 467 if (!gregorianDateTime) 468 return jsNontrivialString(exec, "Invalid Date");468 return JSValue::encode(jsNontrivialString(exec, "Invalid Date")); 469 469 DateConversionBuffer date; 470 470 DateConversionBuffer time; 471 471 formatDateUTCVariant(*gregorianDateTime, date); 472 472 formatTimeUTC(*gregorianDateTime, time); 473 return jsMakeNontrivialString(exec, date, " ", time);474 } 475 476 JSValue JSC_HOST_CALL dateProtoFuncToISOString(ExecState* exec)477 { 478 JSValue thisValue = exec->hostThisValue(); 479 if (!thisValue.inherits(&DateInstance::info)) 480 return throwError(exec, TypeError);473 return JSValue::encode(jsMakeNontrivialString(exec, date, " ", time)); 474 } 475 476 EncodedJSValue JSC_HOST_CALL dateProtoFuncToISOString(ExecState* exec) 477 { 478 JSValue thisValue = exec->hostThisValue(); 479 if (!thisValue.inherits(&DateInstance::info)) 480 return JSValue::encode(throwError(exec, TypeError)); 481 481 482 482 DateInstance* thisDateObj = asDateInstance(thisValue); … … 484 484 const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(exec); 485 485 if (!gregorianDateTime) 486 return jsNontrivialString(exec, "Invalid Date");486 return JSValue::encode(jsNontrivialString(exec, "Invalid Date")); 487 487 // Maximum amount of space we need in buffer: 6 (max. digits in year) + 2 * 5 (2 characters each for month, day, hour, minute, second) + 4 (. + 3 digits for milliseconds) 488 488 // 6 for formatting and one for null termination = 27. We add one extra character to allow us to force null termination. … … 490 490 snprintf(buffer, sizeof(buffer) - 1, "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", 1900 + gregorianDateTime->year, gregorianDateTime->month + 1, gregorianDateTime->monthDay, gregorianDateTime->hour, gregorianDateTime->minute, gregorianDateTime->second, static_cast<int>(fmod(thisDateObj->internalNumber(), 1000))); 491 491 buffer[sizeof(buffer) - 1] = 0; 492 return jsNontrivialString(exec, buffer);493 } 494 495 JSValue JSC_HOST_CALL dateProtoFuncToDateString(ExecState* exec)496 { 497 JSValue thisValue = exec->hostThisValue(); 498 if (!thisValue.inherits(&DateInstance::info)) 499 return throwError(exec, TypeError);500 501 DateInstance* thisDateObj = asDateInstance(thisValue); 502 503 const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec); 504 if (!gregorianDateTime) 505 return jsNontrivialString(exec, "Invalid Date");492 return JSValue::encode(jsNontrivialString(exec, buffer)); 493 } 494 495 EncodedJSValue JSC_HOST_CALL dateProtoFuncToDateString(ExecState* exec) 496 { 497 JSValue thisValue = exec->hostThisValue(); 498 if (!thisValue.inherits(&DateInstance::info)) 499 return JSValue::encode(throwError(exec, TypeError)); 500 501 DateInstance* thisDateObj = asDateInstance(thisValue); 502 503 const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec); 504 if (!gregorianDateTime) 505 return JSValue::encode(jsNontrivialString(exec, "Invalid Date")); 506 506 DateConversionBuffer date; 507 507 formatDate(*gregorianDateTime, date); 508 return jsNontrivialString(exec, date);509 } 510 511 JSValue JSC_HOST_CALL dateProtoFuncToTimeString(ExecState* exec)512 { 513 JSValue thisValue = exec->hostThisValue(); 514 if (!thisValue.inherits(&DateInstance::info)) 515 return throwError(exec, TypeError);516 517 DateInstance* thisDateObj = asDateInstance(thisValue); 518 519 const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec); 520 if (!gregorianDateTime) 521 return jsNontrivialString(exec, "Invalid Date");508 return JSValue::encode(jsNontrivialString(exec, date)); 509 } 510 511 EncodedJSValue JSC_HOST_CALL dateProtoFuncToTimeString(ExecState* exec) 512 { 513 JSValue thisValue = exec->hostThisValue(); 514 if (!thisValue.inherits(&DateInstance::info)) 515 return JSValue::encode(throwError(exec, TypeError)); 516 517 DateInstance* thisDateObj = asDateInstance(thisValue); 518 519 const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec); 520 if (!gregorianDateTime) 521 return JSValue::encode(jsNontrivialString(exec, "Invalid Date")); 522 522 DateConversionBuffer time; 523 523 formatTime(*gregorianDateTime, time); 524 return jsNontrivialString(exec, time);525 } 526 527 JSValue JSC_HOST_CALL dateProtoFuncToLocaleString(ExecState* exec)528 { 529 JSValue thisValue = exec->hostThisValue(); 530 if (!thisValue.inherits(&DateInstance::info)) 531 return throwError(exec, TypeError);532 533 DateInstance* thisDateObj = asDateInstance(thisValue); 534 return formatLocaleDate(exec, thisDateObj, thisDateObj->internalNumber(), LocaleDateAndTime);535 } 536 537 JSValue JSC_HOST_CALL dateProtoFuncToLocaleDateString(ExecState* exec)538 { 539 JSValue thisValue = exec->hostThisValue(); 540 if (!thisValue.inherits(&DateInstance::info)) 541 return throwError(exec, TypeError);542 543 DateInstance* thisDateObj = asDateInstance(thisValue); 544 return formatLocaleDate(exec, thisDateObj, thisDateObj->internalNumber(), LocaleDate);545 } 546 547 JSValue JSC_HOST_CALL dateProtoFuncToLocaleTimeString(ExecState* exec)548 { 549 JSValue thisValue = exec->hostThisValue(); 550 if (!thisValue.inherits(&DateInstance::info)) 551 return throwError(exec, TypeError);552 553 DateInstance* thisDateObj = asDateInstance(thisValue); 554 return formatLocaleDate(exec, thisDateObj, thisDateObj->internalNumber(), LocaleTime);555 } 556 557 JSValue JSC_HOST_CALL dateProtoFuncGetTime(ExecState* exec)558 { 559 JSValue thisValue = exec->hostThisValue(); 560 if (!thisValue.inherits(&DateInstance::info)) 561 return throwError(exec, TypeError);562 563 return asDateInstance(thisValue)->internalValue();564 } 565 566 JSValue JSC_HOST_CALL dateProtoFuncGetFullYear(ExecState* exec)567 { 568 JSValue thisValue = exec->hostThisValue(); 569 if (!thisValue.inherits(&DateInstance::info)) 570 return throwError(exec, TypeError);571 572 DateInstance* thisDateObj = asDateInstance(thisValue); 573 574 const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec); 575 if (!gregorianDateTime) 576 return jsNaN(exec);577 return jsNumber(exec, 1900 + gregorianDateTime->year);578 } 579 580 JSValue JSC_HOST_CALL dateProtoFuncGetUTCFullYear(ExecState* exec)581 { 582 JSValue thisValue = exec->hostThisValue(); 583 if (!thisValue.inherits(&DateInstance::info)) 584 return throwError(exec, TypeError);524 return JSValue::encode(jsNontrivialString(exec, time)); 525 } 526 527 EncodedJSValue JSC_HOST_CALL dateProtoFuncToLocaleString(ExecState* exec) 528 { 529 JSValue thisValue = exec->hostThisValue(); 530 if (!thisValue.inherits(&DateInstance::info)) 531 return JSValue::encode(throwError(exec, TypeError)); 532 533 DateInstance* thisDateObj = asDateInstance(thisValue); 534 return JSValue::encode(formatLocaleDate(exec, thisDateObj, thisDateObj->internalNumber(), LocaleDateAndTime)); 535 } 536 537 EncodedJSValue JSC_HOST_CALL dateProtoFuncToLocaleDateString(ExecState* exec) 538 { 539 JSValue thisValue = exec->hostThisValue(); 540 if (!thisValue.inherits(&DateInstance::info)) 541 return JSValue::encode(throwError(exec, TypeError)); 542 543 DateInstance* thisDateObj = asDateInstance(thisValue); 544 return JSValue::encode(formatLocaleDate(exec, thisDateObj, thisDateObj->internalNumber(), LocaleDate)); 545 } 546 547 EncodedJSValue JSC_HOST_CALL dateProtoFuncToLocaleTimeString(ExecState* exec) 548 { 549 JSValue thisValue = exec->hostThisValue(); 550 if (!thisValue.inherits(&DateInstance::info)) 551 return JSValue::encode(throwError(exec, TypeError)); 552 553 DateInstance* thisDateObj = asDateInstance(thisValue); 554 return JSValue::encode(formatLocaleDate(exec, thisDateObj, thisDateObj->internalNumber(), LocaleTime)); 555 } 556 557 EncodedJSValue JSC_HOST_CALL dateProtoFuncGetTime(ExecState* exec) 558 { 559 JSValue thisValue = exec->hostThisValue(); 560 if (!thisValue.inherits(&DateInstance::info)) 561 return JSValue::encode(throwError(exec, TypeError)); 562 563 return JSValue::encode(asDateInstance(thisValue)->internalValue()); 564 } 565 566 EncodedJSValue JSC_HOST_CALL dateProtoFuncGetFullYear(ExecState* exec) 567 { 568 JSValue thisValue = exec->hostThisValue(); 569 if (!thisValue.inherits(&DateInstance::info)) 570 return JSValue::encode(throwError(exec, TypeError)); 571 572 DateInstance* thisDateObj = asDateInstance(thisValue); 573 574 const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec); 575 if (!gregorianDateTime) 576 return JSValue::encode(jsNaN(exec)); 577 return JSValue::encode(jsNumber(exec, 1900 + gregorianDateTime->year)); 578 } 579 580 EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCFullYear(ExecState* exec) 581 { 582 JSValue thisValue = exec->hostThisValue(); 583 if (!thisValue.inherits(&DateInstance::info)) 584 return JSValue::encode(throwError(exec, TypeError)); 585 585 586 586 DateInstance* thisDateObj = asDateInstance(thisValue); … … 588 588 const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(exec); 589 589 if (!gregorianDateTime) 590 return jsNaN(exec);591 return jsNumber(exec, 1900 + gregorianDateTime->year);592 } 593 594 JSValue JSC_HOST_CALL dateProtoFuncToGMTString(ExecState* exec)595 { 596 JSValue thisValue = exec->hostThisValue(); 597 if (!thisValue.inherits(&DateInstance::info)) 598 return throwError(exec, TypeError);590 return JSValue::encode(jsNaN(exec)); 591 return JSValue::encode(jsNumber(exec, 1900 + gregorianDateTime->year)); 592 } 593 594 EncodedJSValue JSC_HOST_CALL dateProtoFuncToGMTString(ExecState* exec) 595 { 596 JSValue thisValue = exec->hostThisValue(); 597 if (!thisValue.inherits(&DateInstance::info)) 598 return JSValue::encode(throwError(exec, TypeError)); 599 599 600 600 DateInstance* thisDateObj = asDateInstance(thisValue); … … 602 602 const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(exec); 603 603 if (!gregorianDateTime) 604 return jsNontrivialString(exec, "Invalid Date");604 return JSValue::encode(jsNontrivialString(exec, "Invalid Date")); 605 605 DateConversionBuffer date; 606 606 DateConversionBuffer time; 607 607 formatDateUTCVariant(*gregorianDateTime, date); 608 608 formatTimeUTC(*gregorianDateTime, time); 609 return jsMakeNontrivialString(exec, date, " ", time);610 } 611 612 JSValue JSC_HOST_CALL dateProtoFuncGetMonth(ExecState* exec)613 { 614 JSValue thisValue = exec->hostThisValue(); 615 if (!thisValue.inherits(&DateInstance::info)) 616 return throwError(exec, TypeError);617 618 DateInstance* thisDateObj = asDateInstance(thisValue); 619 620 const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec); 621 if (!gregorianDateTime) 622 return jsNaN(exec);623 return jsNumber(exec, gregorianDateTime->month);624 } 625 626 JSValue JSC_HOST_CALL dateProtoFuncGetUTCMonth(ExecState* exec)627 { 628 JSValue thisValue = exec->hostThisValue(); 629 if (!thisValue.inherits(&DateInstance::info)) 630 return throwError(exec, TypeError);609 return JSValue::encode(jsMakeNontrivialString(exec, date, " ", time)); 610 } 611 612 EncodedJSValue JSC_HOST_CALL dateProtoFuncGetMonth(ExecState* exec) 613 { 614 JSValue thisValue = exec->hostThisValue(); 615 if (!thisValue.inherits(&DateInstance::info)) 616 return JSValue::encode(throwError(exec, TypeError)); 617 618 DateInstance* thisDateObj = asDateInstance(thisValue); 619 620 const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec); 621 if (!gregorianDateTime) 622 return JSValue::encode(jsNaN(exec)); 623 return JSValue::encode(jsNumber(exec, gregorianDateTime->month)); 624 } 625 626 EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCMonth(ExecState* exec) 627 { 628 JSValue thisValue = exec->hostThisValue(); 629 if (!thisValue.inherits(&DateInstance::info)) 630 return JSValue::encode(throwError(exec, TypeError)); 631 631 632 632 DateInstance* thisDateObj = asDateInstance(thisValue); … … 634 634 const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(exec); 635 635 if (!gregorianDateTime) 636 return jsNaN(exec);637 return jsNumber(exec, gregorianDateTime->month);638 } 639 640 JSValue JSC_HOST_CALL dateProtoFuncGetDate(ExecState* exec)641 { 642 JSValue thisValue = exec->hostThisValue(); 643 if (!thisValue.inherits(&DateInstance::info)) 644 return throwError(exec, TypeError);645 646 DateInstance* thisDateObj = asDateInstance(thisValue); 647 648 const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec); 649 if (!gregorianDateTime) 650 return jsNaN(exec);651 return jsNumber(exec, gregorianDateTime->monthDay);652 } 653 654 JSValue JSC_HOST_CALL dateProtoFuncGetUTCDate(ExecState* exec)655 { 656 JSValue thisValue = exec->hostThisValue(); 657 if (!thisValue.inherits(&DateInstance::info)) 658 return throwError(exec, TypeError);636 return JSValue::encode(jsNaN(exec)); 637 return JSValue::encode(jsNumber(exec, gregorianDateTime->month)); 638 } 639 640 EncodedJSValue JSC_HOST_CALL dateProtoFuncGetDate(ExecState* exec) 641 { 642 JSValue thisValue = exec->hostThisValue(); 643 if (!thisValue.inherits(&DateInstance::info)) 644 return JSValue::encode(throwError(exec, TypeError)); 645 646 DateInstance* thisDateObj = asDateInstance(thisValue); 647 648 const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec); 649 if (!gregorianDateTime) 650 return JSValue::encode(jsNaN(exec)); 651 return JSValue::encode(jsNumber(exec, gregorianDateTime->monthDay)); 652 } 653 654 EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCDate(ExecState* exec) 655 { 656 JSValue thisValue = exec->hostThisValue(); 657 if (!thisValue.inherits(&DateInstance::info)) 658 return JSValue::encode(throwError(exec, TypeError)); 659 659 660 660 DateInstance* thisDateObj = asDateInstance(thisValue); … … 662 662 const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(exec); 663 663 if (!gregorianDateTime) 664 return jsNaN(exec);665 return jsNumber(exec, gregorianDateTime->monthDay);666 } 667 668 JSValue JSC_HOST_CALL dateProtoFuncGetDay(ExecState* exec)669 { 670 JSValue thisValue = exec->hostThisValue(); 671 if (!thisValue.inherits(&DateInstance::info)) 672 return throwError(exec, TypeError);673 674 DateInstance* thisDateObj = asDateInstance(thisValue); 675 676 const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec); 677 if (!gregorianDateTime) 678 return jsNaN(exec);679 return jsNumber(exec, gregorianDateTime->weekDay);680 } 681 682 JSValue JSC_HOST_CALL dateProtoFuncGetUTCDay(ExecState* exec)683 { 684 JSValue thisValue = exec->hostThisValue(); 685 if (!thisValue.inherits(&DateInstance::info)) 686 return throwError(exec, TypeError);664 return JSValue::encode(jsNaN(exec)); 665 return JSValue::encode(jsNumber(exec, gregorianDateTime->monthDay)); 666 } 667 668 EncodedJSValue JSC_HOST_CALL dateProtoFuncGetDay(ExecState* exec) 669 { 670 JSValue thisValue = exec->hostThisValue(); 671 if (!thisValue.inherits(&DateInstance::info)) 672 return JSValue::encode(throwError(exec, TypeError)); 673 674 DateInstance* thisDateObj = asDateInstance(thisValue); 675 676 const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec); 677 if (!gregorianDateTime) 678 return JSValue::encode(jsNaN(exec)); 679 return JSValue::encode(jsNumber(exec, gregorianDateTime->weekDay)); 680 } 681 682 EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCDay(ExecState* exec) 683 { 684 JSValue thisValue = exec->hostThisValue(); 685 if (!thisValue.inherits(&DateInstance::info)) 686 return JSValue::encode(throwError(exec, TypeError)); 687 687 688 688 DateInstance* thisDateObj = asDateInstance(thisValue); … … 690 690 const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(exec); 691 691 if (!gregorianDateTime) 692 return jsNaN(exec);693 return jsNumber(exec, gregorianDateTime->weekDay);694 } 695 696 JSValue JSC_HOST_CALL dateProtoFuncGetHours(ExecState* exec)697 { 698 JSValue thisValue = exec->hostThisValue(); 699 if (!thisValue.inherits(&DateInstance::info)) 700 return throwError(exec, TypeError);701 702 DateInstance* thisDateObj = asDateInstance(thisValue); 703 704 const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec); 705 if (!gregorianDateTime) 706 return jsNaN(exec);707 return jsNumber(exec, gregorianDateTime->hour);708 } 709 710 JSValue JSC_HOST_CALL dateProtoFuncGetUTCHours(ExecState* exec)711 { 712 JSValue thisValue = exec->hostThisValue(); 713 if (!thisValue.inherits(&DateInstance::info)) 714 return throwError(exec, TypeError);692 return JSValue::encode(jsNaN(exec)); 693 return JSValue::encode(jsNumber(exec, gregorianDateTime->weekDay)); 694 } 695 696 EncodedJSValue JSC_HOST_CALL dateProtoFuncGetHours(ExecState* exec) 697 { 698 JSValue thisValue = exec->hostThisValue(); 699 if (!thisValue.inherits(&DateInstance::info)) 700 return JSValue::encode(throwError(exec, TypeError)); 701 702 DateInstance* thisDateObj = asDateInstance(thisValue); 703 704 const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec); 705 if (!gregorianDateTime) 706 return JSValue::encode(jsNaN(exec)); 707 return JSValue::encode(jsNumber(exec, gregorianDateTime->hour)); 708 } 709 710 EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCHours(ExecState* exec) 711 { 712 JSValue thisValue = exec->hostThisValue(); 713 if (!thisValue.inherits(&DateInstance::info)) 714 return JSValue::encode(throwError(exec, TypeError)); 715 715 716 716 DateInstance* thisDateObj = asDateInstance(thisValue); … … 718 718 const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(exec); 719 719 if (!gregorianDateTime) 720 return jsNaN(exec);721 return jsNumber(exec, gregorianDateTime->hour);722 } 723 724 JSValue JSC_HOST_CALL dateProtoFuncGetMinutes(ExecState* exec)725 { 726 JSValue thisValue = exec->hostThisValue(); 727 if (!thisValue.inherits(&DateInstance::info)) 728 return throwError(exec, TypeError);729 730 DateInstance* thisDateObj = asDateInstance(thisValue); 731 732 const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec); 733 if (!gregorianDateTime) 734 return jsNaN(exec);735 return jsNumber(exec, gregorianDateTime->minute);736 } 737 738 JSValue JSC_HOST_CALL dateProtoFuncGetUTCMinutes(ExecState* exec)739 { 740 JSValue thisValue = exec->hostThisValue(); 741 if (!thisValue.inherits(&DateInstance::info)) 742 return throwError(exec, TypeError);720 return JSValue::encode(jsNaN(exec)); 721 return JSValue::encode(jsNumber(exec, gregorianDateTime->hour)); 722 } 723 724 EncodedJSValue JSC_HOST_CALL dateProtoFuncGetMinutes(ExecState* exec) 725 { 726 JSValue thisValue = exec->hostThisValue(); 727 if (!thisValue.inherits(&DateInstance::info)) 728 return JSValue::encode(throwError(exec, TypeError)); 729 730 DateInstance* thisDateObj = asDateInstance(thisValue); 731 732 const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec); 733 if (!gregorianDateTime) 734 return JSValue::encode(jsNaN(exec)); 735 return JSValue::encode(jsNumber(exec, gregorianDateTime->minute)); 736 } 737 738 EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCMinutes(ExecState* exec) 739 { 740 JSValue thisValue = exec->hostThisValue(); 741 if (!thisValue.inherits(&DateInstance::info)) 742 return JSValue::encode(throwError(exec, TypeError)); 743 743 744 744 DateInstance* thisDateObj = asDateInstance(thisValue); … … 746 746 const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(exec); 747 747 if (!gregorianDateTime) 748 return jsNaN(exec);749 return jsNumber(exec, gregorianDateTime->minute);750 } 751 752 JSValue JSC_HOST_CALL dateProtoFuncGetSeconds(ExecState* exec)753 { 754 JSValue thisValue = exec->hostThisValue(); 755 if (!thisValue.inherits(&DateInstance::info)) 756 return throwError(exec, TypeError);757 758 DateInstance* thisDateObj = asDateInstance(thisValue); 759 760 const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec); 761 if (!gregorianDateTime) 762 return jsNaN(exec);763 return jsNumber(exec, gregorianDateTime->second);764 } 765 766 JSValue JSC_HOST_CALL dateProtoFuncGetUTCSeconds(ExecState* exec)767 { 768 JSValue thisValue = exec->hostThisValue(); 769 if (!thisValue.inherits(&DateInstance::info)) 770 return throwError(exec, TypeError);748 return JSValue::encode(jsNaN(exec)); 749 return JSValue::encode(jsNumber(exec, gregorianDateTime->minute)); 750 } 751 752 EncodedJSValue JSC_HOST_CALL dateProtoFuncGetSeconds(ExecState* exec) 753 { 754 JSValue thisValue = exec->hostThisValue(); 755 if (!thisValue.inherits(&DateInstance::info)) 756 return JSValue::encode(throwError(exec, TypeError)); 757 758 DateInstance* thisDateObj = asDateInstance(thisValue); 759 760 const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec); 761 if (!gregorianDateTime) 762 return JSValue::encode(jsNaN(exec)); 763 return JSValue::encode(jsNumber(exec, gregorianDateTime->second)); 764 } 765 766 EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCSeconds(ExecState* exec) 767 { 768 JSValue thisValue = exec->hostThisValue(); 769 if (!thisValue.inherits(&DateInstance::info)) 770 return JSValue::encode(throwError(exec, TypeError)); 771 771 772 772 DateInstance* thisDateObj = asDateInstance(thisValue); … … 774 774 const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(exec); 775 775 if (!gregorianDateTime) 776 return jsNaN(exec);777 return jsNumber(exec, gregorianDateTime->second);778 } 779 780 JSValue JSC_HOST_CALL dateProtoFuncGetMilliSeconds(ExecState* exec)781 { 782 JSValue thisValue = exec->hostThisValue(); 783 if (!thisValue.inherits(&DateInstance::info)) 784 return throwError(exec, TypeError);776 return JSValue::encode(jsNaN(exec)); 777 return JSValue::encode(jsNumber(exec, gregorianDateTime->second)); 778 } 779 780 EncodedJSValue JSC_HOST_CALL dateProtoFuncGetMilliSeconds(ExecState* exec) 781 { 782 JSValue thisValue = exec->hostThisValue(); 783 if (!thisValue.inherits(&DateInstance::info)) 784 return JSValue::encode(throwError(exec, TypeError)); 785 785 786 786 DateInstance* thisDateObj = asDateInstance(thisValue); 787 787 double milli = thisDateObj->internalNumber(); 788 788 if (isnan(milli)) 789 return jsNaN(exec);789 return JSValue::encode(jsNaN(exec)); 790 790 791 791 double secs = floor(milli / msPerSecond); 792 792 double ms = milli - secs * msPerSecond; 793 return jsNumber(exec, ms);794 } 795 796 JSValue JSC_HOST_CALL dateProtoFuncGetUTCMilliseconds(ExecState* exec)797 { 798 JSValue thisValue = exec->hostThisValue(); 799 if (!thisValue.inherits(&DateInstance::info)) 800 return throwError(exec, TypeError);793 return JSValue::encode(jsNumber(exec, ms)); 794 } 795 796 EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCMilliseconds(ExecState* exec) 797 { 798 JSValue thisValue = exec->hostThisValue(); 799 if (!thisValue.inherits(&DateInstance::info)) 800 return JSValue::encode(throwError(exec, TypeError)); 801 801 802 802 DateInstance* thisDateObj = asDateInstance(thisValue); 803 803 double milli = thisDateObj->internalNumber(); 804 804 if (isnan(milli)) 805 return jsNaN(exec);805 return JSValue::encode(jsNaN(exec)); 806 806 807 807 double secs = floor(milli / msPerSecond); 808 808 double ms = milli - secs * msPerSecond; 809 return jsNumber(exec, ms);810 } 811 812 JSValue JSC_HOST_CALL dateProtoFuncGetTimezoneOffset(ExecState* exec)813 { 814 JSValue thisValue = exec->hostThisValue(); 815 if (!thisValue.inherits(&DateInstance::info)) 816 return throwError(exec, TypeError);817 818 DateInstance* thisDateObj = asDateInstance(thisValue); 819 820 const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec); 821 if (!gregorianDateTime) 822 return jsNaN(exec);823 return jsNumber(exec, -gregorianDateTime->utcOffset / minutesPerHour);824 } 825 826 JSValue JSC_HOST_CALL dateProtoFuncSetTime(ExecState* exec)827 { 828 JSValue thisValue = exec->hostThisValue(); 829 if (!thisValue.inherits(&DateInstance::info)) 830 return throwError(exec, TypeError);809 return JSValue::encode(jsNumber(exec, ms)); 810 } 811 812 EncodedJSValue JSC_HOST_CALL dateProtoFuncGetTimezoneOffset(ExecState* exec) 813 { 814 JSValue thisValue = exec->hostThisValue(); 815 if (!thisValue.inherits(&DateInstance::info)) 816 return JSValue::encode(throwError(exec, TypeError)); 817 818 DateInstance* thisDateObj = asDateInstance(thisValue); 819 820 const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec); 821 if (!gregorianDateTime) 822 return JSValue::encode(jsNaN(exec)); 823 return JSValue::encode(jsNumber(exec, -gregorianDateTime->utcOffset / minutesPerHour)); 824 } 825 826 EncodedJSValue JSC_HOST_CALL dateProtoFuncSetTime(ExecState* exec) 827 { 828 JSValue thisValue = exec->hostThisValue(); 829 if (!thisValue.inherits(&DateInstance::info)) 830 return JSValue::encode(throwError(exec, TypeError)); 831 831 832 832 DateInstance* thisDateObj = asDateInstance(thisValue); … … 835 835 JSValue result = jsNumber(exec, milli); 836 836 thisDateObj->setInternalValue(result); 837 return result;837 return JSValue::encode(result); 838 838 } 839 839 … … 915 915 } 916 916 917 JSValue JSC_HOST_CALL dateProtoFuncSetMilliSeconds(ExecState* exec)917 EncodedJSValue JSC_HOST_CALL dateProtoFuncSetMilliSeconds(ExecState* exec) 918 918 { 919 919 const bool inputIsUTC = false; 920 return setNewValueFromTimeArgs(exec, 1, inputIsUTC);921 } 922 923 JSValue JSC_HOST_CALL dateProtoFuncSetUTCMilliseconds(ExecState* exec)920 return JSValue::encode(setNewValueFromTimeArgs(exec, 1, inputIsUTC)); 921 } 922 923 EncodedJSValue JSC_HOST_CALL dateProtoFuncSetUTCMilliseconds(ExecState* exec) 924 924 { 925 925 const bool inputIsUTC = true; 926 return setNewValueFromTimeArgs(exec, 1, inputIsUTC);927 } 928 929 JSValue JSC_HOST_CALL dateProtoFuncSetSeconds(ExecState* exec)926 return JSValue::encode(setNewValueFromTimeArgs(exec, 1, inputIsUTC)); 927 } 928 929 EncodedJSValue JSC_HOST_CALL dateProtoFuncSetSeconds(ExecState* exec) 930 930 { 931 931 const bool inputIsUTC = false; 932 return setNewValueFromTimeArgs(exec, 2, inputIsUTC);933 } 934 935 JSValue JSC_HOST_CALL dateProtoFuncSetUTCSeconds(ExecState* exec)932 return JSValue::encode(setNewValueFromTimeArgs(exec, 2, inputIsUTC)); 933 } 934 935 EncodedJSValue JSC_HOST_CALL dateProtoFuncSetUTCSeconds(ExecState* exec) 936 936 { 937 937 const bool inputIsUTC = true; 938 return setNewValueFromTimeArgs(exec, 2, inputIsUTC);939 } 940 941 JSValue JSC_HOST_CALL dateProtoFuncSetMinutes(ExecState* exec)938 return JSValue::encode(setNewValueFromTimeArgs(exec, 2, inputIsUTC)); 939 } 940 941 EncodedJSValue JSC_HOST_CALL dateProtoFuncSetMinutes(ExecState* exec) 942 942 { 943 943 const bool inputIsUTC = false; 944 return setNewValueFromTimeArgs(exec, 3, inputIsUTC);945 } 946 947 JSValue JSC_HOST_CALL dateProtoFuncSetUTCMinutes(ExecState* exec)944 return JSValue::encode(setNewValueFromTimeArgs(exec, 3, inputIsUTC)); 945 } 946 947 EncodedJSValue JSC_HOST_CALL dateProtoFuncSetUTCMinutes(ExecState* exec) 948 948 { 949 949 const bool inputIsUTC = true; 950 return setNewValueFromTimeArgs(exec, 3, inputIsUTC);951 } 952 953 JSValue JSC_HOST_CALL dateProtoFuncSetHours(ExecState* exec)950 return JSValue::encode(setNewValueFromTimeArgs(exec, 3, inputIsUTC)); 951 } 952 953 EncodedJSValue JSC_HOST_CALL dateProtoFuncSetHours(ExecState* exec) 954 954 { 955 955 const bool inputIsUTC = false; 956 return setNewValueFromTimeArgs(exec, 4, inputIsUTC);957 } 958 959 JSValue JSC_HOST_CALL dateProtoFuncSetUTCHours(ExecState* exec)956 return JSValue::encode(setNewValueFromTimeArgs(exec, 4, inputIsUTC)); 957 } 958 959 EncodedJSValue JSC_HOST_CALL dateProtoFuncSetUTCHours(ExecState* exec) 960 960 { 961 961 const bool inputIsUTC = true; 962 return setNewValueFromTimeArgs(exec, 4, inputIsUTC);963 } 964 965 JSValue JSC_HOST_CALL dateProtoFuncSetDate(ExecState* exec)962 return JSValue::encode(setNewValueFromTimeArgs(exec, 4, inputIsUTC)); 963 } 964 965 EncodedJSValue JSC_HOST_CALL dateProtoFuncSetDate(ExecState* exec) 966 966 { 967 967 const bool inputIsUTC = false; 968 return setNewValueFromDateArgs(exec, 1, inputIsUTC);969 } 970 971 JSValue JSC_HOST_CALL dateProtoFuncSetUTCDate(ExecState* exec)968 return JSValue::encode(setNewValueFromDateArgs(exec, 1, inputIsUTC)); 969 } 970 971 EncodedJSValue JSC_HOST_CALL dateProtoFuncSetUTCDate(ExecState* exec) 972 972 { 973 973 const bool inputIsUTC = true; 974 return setNewValueFromDateArgs(exec, 1, inputIsUTC);975 } 976 977 JSValue JSC_HOST_CALL dateProtoFuncSetMonth(ExecState* exec)974 return JSValue::encode(setNewValueFromDateArgs(exec, 1, inputIsUTC)); 975 } 976 977 EncodedJSValue JSC_HOST_CALL dateProtoFuncSetMonth(ExecState* exec) 978 978 { 979 979 const bool inputIsUTC = false; 980 return setNewValueFromDateArgs(exec, 2, inputIsUTC);981 } 982 983 JSValue JSC_HOST_CALL dateProtoFuncSetUTCMonth(ExecState* exec)980 return JSValue::encode(setNewValueFromDateArgs(exec, 2, inputIsUTC)); 981 } 982 983 EncodedJSValue JSC_HOST_CALL dateProtoFuncSetUTCMonth(ExecState* exec) 984 984 { 985 985 const bool inputIsUTC = true; 986 return setNewValueFromDateArgs(exec, 2, inputIsUTC);987 } 988 989 JSValue JSC_HOST_CALL dateProtoFuncSetFullYear(ExecState* exec)986 return JSValue::encode(setNewValueFromDateArgs(exec, 2, inputIsUTC)); 987 } 988 989 EncodedJSValue JSC_HOST_CALL dateProtoFuncSetFullYear(ExecState* exec) 990 990 { 991 991 const bool inputIsUTC = false; 992 return setNewValueFromDateArgs(exec, 3, inputIsUTC);993 } 994 995 JSValue JSC_HOST_CALL dateProtoFuncSetUTCFullYear(ExecState* exec)992 return JSValue::encode(setNewValueFromDateArgs(exec, 3, inputIsUTC)); 993 } 994 995 EncodedJSValue JSC_HOST_CALL dateProtoFuncSetUTCFullYear(ExecState* exec) 996 996 { 997 997 const bool inputIsUTC = true; 998 return setNewValueFromDateArgs(exec, 3, inputIsUTC);999 } 1000 1001 JSValue JSC_HOST_CALL dateProtoFuncSetYear(ExecState* exec)1002 { 1003 JSValue thisValue = exec->hostThisValue(); 1004 if (!thisValue.inherits(&DateInstance::info)) 1005 return throwError(exec, TypeError);998 return JSValue::encode(setNewValueFromDateArgs(exec, 3, inputIsUTC)); 999 } 1000 1001 EncodedJSValue JSC_HOST_CALL dateProtoFuncSetYear(ExecState* exec) 1002 { 1003 JSValue thisValue = exec->hostThisValue(); 1004 if (!thisValue.inherits(&DateInstance::info)) 1005 return JSValue::encode(throwError(exec, TypeError)); 1006 1006 1007 1007 DateInstance* thisDateObj = asDateInstance(thisValue); … … 1009 1009 JSValue result = jsNaN(exec); 1010 1010 thisDateObj->setInternalValue(result); 1011 return result;1011 return JSValue::encode(result); 1012 1012 } 1013 1013 … … 1032 1032 JSValue result = jsNaN(exec); 1033 1033 thisDateObj->setInternalValue(result); 1034 return result;1034 return JSValue::encode(result); 1035 1035 } 1036 1036 … … 1038 1038 JSValue result = jsNumber(exec, gregorianDateTimeToMS(exec, gregorianDateTime, ms, false)); 1039 1039 thisDateObj->setInternalValue(result); 1040 return result;1041 } 1042 1043 JSValue JSC_HOST_CALL dateProtoFuncGetYear(ExecState* exec)1044 { 1045 JSValue thisValue = exec->hostThisValue(); 1046 if (!thisValue.inherits(&DateInstance::info)) 1047 return throwError(exec, TypeError);1048 1049 DateInstance* thisDateObj = asDateInstance(thisValue); 1050 1051 const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec); 1052 if (!gregorianDateTime) 1053 return jsNaN(exec);1040 return JSValue::encode(result); 1041 } 1042 1043 EncodedJSValue JSC_HOST_CALL dateProtoFuncGetYear(ExecState* exec) 1044 { 1045 JSValue thisValue = exec->hostThisValue(); 1046 if (!thisValue.inherits(&DateInstance::info)) 1047 return JSValue::encode(throwError(exec, TypeError)); 1048 1049 DateInstance* thisDateObj = asDateInstance(thisValue); 1050 1051 const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec); 1052 if (!gregorianDateTime) 1053 return JSValue::encode(jsNaN(exec)); 1054 1054 1055 1055 // NOTE: IE returns the full year even in getYear. 1056 return jsNumber(exec, gregorianDateTime->year);1057 } 1058 1059 JSValue JSC_HOST_CALL dateProtoFuncToJSON(ExecState* exec)1056 return JSValue::encode(jsNumber(exec, gregorianDateTime->year)); 1057 } 1058 1059 EncodedJSValue JSC_HOST_CALL dateProtoFuncToJSON(ExecState* exec) 1060 1060 { 1061 1061 JSValue thisValue = exec->hostThisValue(); 1062 1062 JSObject* object = thisValue.toThisObject(exec); 1063 1063 if (exec->hadException()) 1064 return jsNull();1064 return JSValue::encode(jsNull()); 1065 1065 1066 1066 JSValue toISOValue = object->get(exec, exec->globalData().propertyNames->toISOString); 1067 1067 if (exec->hadException()) 1068 return jsNull();1068 return JSValue::encode(jsNull()); 1069 1069 1070 1070 CallData callData; 1071 CallType callType = toISOValue.getCallData(callData);1071 CallType callType = getCallData(toISOValue, callData); 1072 1072 if (callType == CallTypeNone) 1073 return throwError(exec, TypeError, "toISOString is not a function");1073 return JSValue::encode(throwError(exec, TypeError, "toISOString is not a function")); 1074 1074 1075 1075 JSValue result = call(exec, asObject(toISOValue), callType, callData, object, exec->emptyList()); 1076 1076 if (exec->hadException()) 1077 return jsNull();1077 return JSValue::encode(jsNull()); 1078 1078 if (result.isObject()) 1079 return throwError(exec, TypeError, "toISOString did not return a primitive value");1080 return result;1079 return JSValue::encode(throwError(exec, TypeError, "toISOString did not return a primitive value")); 1080 return JSValue::encode(result); 1081 1081 } 1082 1082 -
trunk/JavaScriptCore/runtime/ErrorConstructor.cpp
r60392 r60631 58 58 } 59 59 60 static JSValue JSC_HOST_CALL callErrorConstructor(ExecState* exec)60 static EncodedJSValue JSC_HOST_CALL callErrorConstructor(ExecState* exec) 61 61 { 62 62 ArgList args(exec); 63 return constructError(exec, args);63 return JSValue::encode(constructError(exec, args)); 64 64 } 65 65 -
trunk/JavaScriptCore/runtime/ErrorPrototype.cpp
r60392 r60631 33 33 ASSERT_CLASS_FITS_IN_CELL(ErrorPrototype); 34 34 35 static JSValue JSC_HOST_CALL errorProtoFuncToString(ExecState*);35 static EncodedJSValue JSC_HOST_CALL errorProtoFuncToString(ExecState*); 36 36 37 37 // ECMA 15.9.4 … … 47 47 } 48 48 49 JSValue JSC_HOST_CALL errorProtoFuncToString(ExecState* exec)49 EncodedJSValue JSC_HOST_CALL errorProtoFuncToString(ExecState* exec) 50 50 { 51 51 JSObject* thisObj = exec->hostThisValue().toThisObject(exec); … … 57 57 if (!name.isUndefined()) { 58 58 if (!message.isUndefined()) 59 return jsMakeNontrivialString(exec, name.toString(exec), ": ", message.toString(exec));60 return jsNontrivialString(exec, name.toString(exec));59 return JSValue::encode(jsMakeNontrivialString(exec, name.toString(exec), ": ", message.toString(exec))); 60 return JSValue::encode(jsNontrivialString(exec, name.toString(exec))); 61 61 } 62 62 if (!message.isUndefined()) 63 return jsMakeNontrivialString(exec, "Error: ", message.toString(exec));64 return jsNontrivialString(exec, "Error");63 return JSValue::encode(jsMakeNontrivialString(exec, "Error: ", message.toString(exec))); 64 return JSValue::encode(jsNontrivialString(exec, "Error")); 65 65 } 66 66 -
trunk/JavaScriptCore/runtime/FunctionConstructor.cpp
r60392 r60631 56 56 } 57 57 58 static JSValue JSC_HOST_CALL callFunctionConstructor(ExecState* exec)58 static EncodedJSValue JSC_HOST_CALL callFunctionConstructor(ExecState* exec) 59 59 { 60 60 ArgList args(exec); 61 return constructFunction(exec, args);61 return JSValue::encode(constructFunction(exec, args)); 62 62 } 63 63 -
trunk/JavaScriptCore/runtime/FunctionPrototype.cpp
r60392 r60631 35 35 ASSERT_CLASS_FITS_IN_CELL(FunctionPrototype); 36 36 37 static JSValue JSC_HOST_CALL functionProtoFuncToString(ExecState*);38 static JSValue JSC_HOST_CALL functionProtoFuncApply(ExecState*);39 static JSValue JSC_HOST_CALL functionProtoFuncCall(ExecState*);37 static EncodedJSValue JSC_HOST_CALL functionProtoFuncToString(ExecState*); 38 static EncodedJSValue JSC_HOST_CALL functionProtoFuncApply(ExecState*); 39 static EncodedJSValue JSC_HOST_CALL functionProtoFuncCall(ExecState*); 40 40 41 41 FunctionPrototype::FunctionPrototype(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure) … … 54 54 } 55 55 56 static JSValue JSC_HOST_CALL callFunctionPrototype(ExecState*)56 static EncodedJSValue JSC_HOST_CALL callFunctionPrototype(ExecState*) 57 57 { 58 return jsUndefined();58 return JSValue::encode(jsUndefined()); 59 59 } 60 60 … … 84 84 } 85 85 86 JSValue JSC_HOST_CALL functionProtoFuncToString(ExecState* exec)86 EncodedJSValue JSC_HOST_CALL functionProtoFuncToString(ExecState* exec) 87 87 { 88 88 JSValue thisValue = exec->hostThisValue(); … … 90 90 JSFunction* function = asFunction(thisValue); 91 91 if (function->isHostFunction()) 92 return jsMakeNontrivialString(exec, "function ", function->name(exec), "() {\n [native code]\n}");92 return JSValue::encode(jsMakeNontrivialString(exec, "function ", function->name(exec), "() {\n [native code]\n}")); 93 93 FunctionExecutable* executable = function->jsExecutable(); 94 94 UString sourceString = executable->source().toString(); 95 95 insertSemicolonIfNeeded(sourceString); 96 return jsMakeNontrivialString(exec, "function ", function->name(exec), "(", executable->paramString(), ") ", sourceString);96 return JSValue::encode(jsMakeNontrivialString(exec, "function ", function->name(exec), "(", executable->paramString(), ") ", sourceString)); 97 97 } 98 98 99 99 if (thisValue.inherits(&InternalFunction::info)) { 100 100 InternalFunction* function = asInternalFunction(thisValue); 101 return jsMakeNontrivialString(exec, "function ", function->name(exec), "() {\n [native code]\n}");101 return JSValue::encode(jsMakeNontrivialString(exec, "function ", function->name(exec), "() {\n [native code]\n}")); 102 102 } 103 103 104 return throwError(exec, TypeError);104 return JSValue::encode(throwError(exec, TypeError)); 105 105 } 106 106 107 JSValue JSC_HOST_CALL functionProtoFuncApply(ExecState* exec)107 EncodedJSValue JSC_HOST_CALL functionProtoFuncApply(ExecState* exec) 108 108 { 109 109 JSValue thisValue = exec->hostThisValue(); 110 110 CallData callData; 111 CallType callType = thisValue.getCallData(callData);111 CallType callType = getCallData(thisValue, callData); 112 112 if (callType == CallTypeNone) 113 return throwError(exec, TypeError);113 return JSValue::encode(throwError(exec, TypeError)); 114 114 115 115 JSValue array = exec->argument(1); … … 118 118 if (!array.isUndefinedOrNull()) { 119 119 if (!array.isObject()) 120 return throwError(exec, TypeError);120 return JSValue::encode(throwError(exec, TypeError)); 121 121 if (asObject(array)->classInfo() == &Arguments::info) 122 122 asArguments(array)->fillArgList(exec, applyArgs); … … 128 128 applyArgs.append(asArray(array)->get(exec, i)); 129 129 } else 130 return throwError(exec, TypeError);130 return JSValue::encode(throwError(exec, TypeError)); 131 131 } 132 132 133 return call(exec, thisValue, callType, callData, exec->argument(0), applyArgs);133 return JSValue::encode(call(exec, thisValue, callType, callData, exec->argument(0), applyArgs)); 134 134 } 135 135 136 JSValue JSC_HOST_CALL functionProtoFuncCall(ExecState* exec)136 EncodedJSValue JSC_HOST_CALL functionProtoFuncCall(ExecState* exec) 137 137 { 138 138 JSValue thisValue = exec->hostThisValue(); 139 139 CallData callData; 140 CallType callType = thisValue.getCallData(callData);140 CallType callType = getCallData(thisValue, callData); 141 141 if (callType == CallTypeNone) 142 return throwError(exec, TypeError);142 return JSValue::encode(throwError(exec, TypeError)); 143 143 144 144 ArgList args(exec); 145 145 ArgList callArgs; 146 146 args.getSlice(1, callArgs); 147 return call(exec, thisValue, callType, callData, exec->argument(0), callArgs);147 return JSValue::encode(call(exec, thisValue, callType, callData, exec->argument(0), callArgs)); 148 148 } 149 149 -
trunk/JavaScriptCore/runtime/JSCell.h
r59941 r60631 24 24 #define JSCell_h 25 25 26 #include "CallData.h" 27 #include "ConstructData.h" 26 28 #include "Collector.h" 27 29 #include "JSImmediate.h" … … 206 208 } 207 209 208 inline CallType JSValue::getCallData(CallData& callData)209 { 210 CallType result = isCell() ? asCell()->getCallData(callData) : CallTypeNone;211 ASSERT(result == CallTypeNone || isValidCallee());210 inline CallType getCallData(JSValue value, CallData& callData) 211 { 212 CallType result = value.isCell() ? asCell(value)->getCallData(callData) : CallTypeNone; 213 ASSERT(result == CallTypeNone || value.isValidCallee()); 212 214 return result; 213 215 } 214 216 215 inline ConstructType JSValue::getConstructData(ConstructData& constructData)216 { 217 ConstructType result = isCell() ? asCell()->getConstructData(constructData) : ConstructTypeNone;218 ASSERT(result == ConstructTypeNone || isValidCallee());217 inline ConstructType getConstructData(JSValue value, ConstructData& constructData) 218 { 219 ConstructType result = value.isCell() ? asCell(value)->getConstructData(constructData) : ConstructTypeNone; 220 ASSERT(result == ConstructTypeNone || value.isValidCallee()); 219 221 return result; 220 222 } -
trunk/JavaScriptCore/runtime/JSFunction.cpp
r60392 r60631 44 44 namespace JSC { 45 45 46 JSValue JSC_HOST_CALL callHostFunctionAsConstructor(ExecState* exec)46 EncodedJSValue JSC_HOST_CALL callHostFunctionAsConstructor(ExecState* exec) 47 47 { 48 48 CodeBlock* codeBlock = exec->callerFrame()->codeBlock(); 49 49 unsigned vPCIndex = codeBlock->bytecodeOffset(exec, exec->returnPC()); 50 50 exec->setException(createNotAConstructorError(exec, exec->callee(), vPCIndex, codeBlock)); 51 return JSValue ();51 return JSValue::encode(JSValue()); 52 52 } 53 53 -
trunk/JavaScriptCore/runtime/JSFunction.h
r60392 r60631 36 36 class NativeExecutable; 37 37 38 JSValue JSC_HOST_CALL callHostFunctionAsConstructor(ExecState*);38 EncodedJSValue JSC_HOST_CALL callHostFunctionAsConstructor(ExecState*); 39 39 40 40 class JSFunction : public JSObjectWithGlobalObject { -
trunk/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp
r60392 r60631 273 273 } 274 274 275 JSValue JSC_HOST_CALL globalFuncEval(ExecState* exec)275 EncodedJSValue JSC_HOST_CALL globalFuncEval(ExecState* exec) 276 276 { 277 277 JSObject* thisObject = exec->hostThisValue().toThisObject(exec); 278 278 JSObject* unwrappedObject = thisObject->unwrappedObject(); 279 279 if (!unwrappedObject->isGlobalObject() || static_cast<JSGlobalObject*>(unwrappedObject)->evalFunction() != exec->callee()) 280 return throwError(exec, EvalError, "The \"this\" value passed to eval must be the global object from which eval originated");280 return JSValue::encode(throwError(exec, EvalError, "The \"this\" value passed to eval must be the global object from which eval originated")); 281 281 282 282 JSValue x = exec->argument(0); 283 283 if (!x.isString()) 284 return x;284 return JSValue::encode(x); 285 285 286 286 UString s = x.toString(exec); … … 288 288 LiteralParser preparser(exec, s, LiteralParser::NonStrictJSON); 289 289 if (JSValue parsedObject = preparser.tryLiteralParse()) 290 return parsedObject;290 return JSValue::encode(parsedObject); 291 291 292 292 RefPtr<EvalExecutable> eval = EvalExecutable::create(exec, makeSource(s)); 293 293 JSObject* error = eval->compile(exec, static_cast<JSGlobalObject*>(unwrappedObject)->globalScopeChain().node()); 294 294 if (error) 295 return throwError(exec, error);296 297 return exec->interpreter()->execute(eval.get(), exec, thisObject, static_cast<JSGlobalObject*>(unwrappedObject)->globalScopeChain().node(), exec->exceptionSlot());298 } 299 300 JSValue JSC_HOST_CALL globalFuncParseInt(ExecState* exec)295 return JSValue::encode(throwError(exec, error)); 296 297 return JSValue::encode(exec->interpreter()->execute(eval.get(), exec, thisObject, static_cast<JSGlobalObject*>(unwrappedObject)->globalScopeChain().node(), exec->exceptionSlot())); 298 } 299 300 EncodedJSValue JSC_HOST_CALL globalFuncParseInt(ExecState* exec) 301 301 { 302 302 JSValue value = exec->argument(0); … … 304 304 305 305 if (radix != 0 && radix != 10) 306 return jsNumber(exec, parseInt(value.toString(exec), radix));306 return JSValue::encode(jsNumber(exec, parseInt(value.toString(exec), radix))); 307 307 308 308 if (value.isInt32()) 309 return value;309 return JSValue::encode(value); 310 310 311 311 if (value.isDouble()) { 312 312 double d = value.asDouble(); 313 313 if (isfinite(d)) 314 return jsNumber(exec, (d > 0) ? floor(d) : ceil(d));314 return JSValue::encode(jsNumber(exec, (d > 0) ? floor(d) : ceil(d))); 315 315 if (isnan(d) || isinf(d)) 316 return jsNaN(exec);317 return jsNumber(exec, 0);318 } 319 320 return jsNumber(exec, parseInt(value.toString(exec), radix));321 } 322 323 JSValue JSC_HOST_CALL globalFuncParseFloat(ExecState* exec)324 { 325 return jsNumber(exec, parseFloat(exec->argument(0).toString(exec)));326 } 327 328 JSValue JSC_HOST_CALL globalFuncIsNaN(ExecState* exec)329 { 330 return jsBoolean(isnan(exec->argument(0).toNumber(exec)));331 } 332 333 JSValue JSC_HOST_CALL globalFuncIsFinite(ExecState* exec)316 return JSValue::encode(jsNaN(exec)); 317 return JSValue::encode(jsNumber(exec, 0)); 318 } 319 320 return JSValue::encode(jsNumber(exec, parseInt(value.toString(exec), radix))); 321 } 322 323 EncodedJSValue JSC_HOST_CALL globalFuncParseFloat(ExecState* exec) 324 { 325 return JSValue::encode(jsNumber(exec, parseFloat(exec->argument(0).toString(exec)))); 326 } 327 328 EncodedJSValue JSC_HOST_CALL globalFuncIsNaN(ExecState* exec) 329 { 330 return JSValue::encode(jsBoolean(isnan(exec->argument(0).toNumber(exec)))); 331 } 332 333 EncodedJSValue JSC_HOST_CALL globalFuncIsFinite(ExecState* exec) 334 334 { 335 335 double n = exec->argument(0).toNumber(exec); 336 return jsBoolean(!isnan(n) && !isinf(n));337 } 338 339 JSValue JSC_HOST_CALL globalFuncDecodeURI(ExecState* exec)336 return JSValue::encode(jsBoolean(!isnan(n) && !isinf(n))); 337 } 338 339 EncodedJSValue JSC_HOST_CALL globalFuncDecodeURI(ExecState* exec) 340 340 { 341 341 static const char do_not_unescape_when_decoding_URI[] = 342 342 "#$&+,/:;=?@"; 343 343 344 return decode(exec, do_not_unescape_when_decoding_URI, true);345 } 346 347 JSValue JSC_HOST_CALL globalFuncDecodeURIComponent(ExecState* exec)348 { 349 return decode(exec, "", true);350 } 351 352 JSValue JSC_HOST_CALL globalFuncEncodeURI(ExecState* exec)344 return JSValue::encode(decode(exec, do_not_unescape_when_decoding_URI, true)); 345 } 346 347 EncodedJSValue JSC_HOST_CALL globalFuncDecodeURIComponent(ExecState* exec) 348 { 349 return JSValue::encode(decode(exec, "", true)); 350 } 351 352 EncodedJSValue JSC_HOST_CALL globalFuncEncodeURI(ExecState* exec) 353 353 { 354 354 static const char do_not_escape_when_encoding_URI[] = … … 358 358 "!#$&'()*+,-./:;=?@_~"; 359 359 360 return encode(exec, do_not_escape_when_encoding_URI);361 } 362 363 JSValue JSC_HOST_CALL globalFuncEncodeURIComponent(ExecState* exec)360 return JSValue::encode(encode(exec, do_not_escape_when_encoding_URI)); 361 } 362 363 EncodedJSValue JSC_HOST_CALL globalFuncEncodeURIComponent(ExecState* exec) 364 364 { 365 365 static const char do_not_escape_when_encoding_URI_component[] = … … 369 369 "!'()*-._~"; 370 370 371 return encode(exec, do_not_escape_when_encoding_URI_component);372 } 373 374 JSValue JSC_HOST_CALL globalFuncEscape(ExecState* exec)371 return JSValue::encode(encode(exec, do_not_escape_when_encoding_URI_component)); 372 } 373 374 EncodedJSValue JSC_HOST_CALL globalFuncEscape(ExecState* exec) 375 375 { 376 376 static const char do_not_escape[] = … … 398 398 } 399 399 400 return builder.build(exec);401 } 402 403 JSValue JSC_HOST_CALL globalFuncUnescape(ExecState* exec)400 return JSValue::encode(builder.build(exec)); 401 } 402 403 EncodedJSValue JSC_HOST_CALL globalFuncUnescape(ExecState* exec) 404 404 { 405 405 StringBuilder builder; … … 425 425 } 426 426 427 return jsString(exec, builder.build());427 return JSValue::encode(jsString(exec, builder.build())); 428 428 } 429 429 430 430 #ifndef NDEBUG 431 JSValue JSC_HOST_CALL globalFuncJSCPrint(ExecState* exec)431 EncodedJSValue JSC_HOST_CALL globalFuncJSCPrint(ExecState* exec) 432 432 { 433 433 CString string = exec->argument(0).toString(exec).UTF8String(); 434 434 puts(string.data()); 435 return jsUndefined();435 return JSValue::encode(jsUndefined()); 436 436 } 437 437 #endif -
trunk/JavaScriptCore/runtime/JSGlobalObjectFunctions.h
r60392 r60631 25 25 #define JSGlobalObjectFunctions_h 26 26 27 #include "JSValue.h" 27 28 #include <wtf/unicode/Unicode.h> 28 29 … … 32 33 class ExecState; 33 34 class JSObject; 34 class JSValue;35 35 36 36 // FIXME: These functions should really be in JSGlobalObject.cpp, but putting them there 37 37 // is a 0.5% reduction. 38 38 39 JSValue JSC_HOST_CALL globalFuncEval(ExecState*);40 JSValue JSC_HOST_CALL globalFuncParseInt(ExecState*);41 JSValue JSC_HOST_CALL globalFuncParseFloat(ExecState*);42 JSValue JSC_HOST_CALL globalFuncIsNaN(ExecState*);43 JSValue JSC_HOST_CALL globalFuncIsFinite(ExecState*);44 JSValue JSC_HOST_CALL globalFuncDecodeURI(ExecState*);45 JSValue JSC_HOST_CALL globalFuncDecodeURIComponent(ExecState*);46 JSValue JSC_HOST_CALL globalFuncEncodeURI(ExecState*);47 JSValue JSC_HOST_CALL globalFuncEncodeURIComponent(ExecState*);48 JSValue JSC_HOST_CALL globalFuncEscape(ExecState*);49 JSValue JSC_HOST_CALL globalFuncUnescape(ExecState*);39 EncodedJSValue JSC_HOST_CALL globalFuncEval(ExecState*); 40 EncodedJSValue JSC_HOST_CALL globalFuncParseInt(ExecState*); 41 EncodedJSValue JSC_HOST_CALL globalFuncParseFloat(ExecState*); 42 EncodedJSValue JSC_HOST_CALL globalFuncIsNaN(ExecState*); 43 EncodedJSValue JSC_HOST_CALL globalFuncIsFinite(ExecState*); 44 EncodedJSValue JSC_HOST_CALL globalFuncDecodeURI(ExecState*); 45 EncodedJSValue JSC_HOST_CALL globalFuncDecodeURIComponent(ExecState*); 46 EncodedJSValue JSC_HOST_CALL globalFuncEncodeURI(ExecState*); 47 EncodedJSValue JSC_HOST_CALL globalFuncEncodeURIComponent(ExecState*); 48 EncodedJSValue JSC_HOST_CALL globalFuncEscape(ExecState*); 49 EncodedJSValue JSC_HOST_CALL globalFuncUnescape(ExecState*); 50 50 #ifndef NDEBUG 51 JSValue JSC_HOST_CALL globalFuncJSCPrint(ExecState*);51 EncodedJSValue JSC_HOST_CALL globalFuncJSCPrint(ExecState*); 52 52 #endif 53 53 -
trunk/JavaScriptCore/runtime/JSONObject.cpp
r60392 r60631 42 42 ASSERT_CLASS_FITS_IN_CELL(JSONObject); 43 43 44 static JSValue JSC_HOST_CALL JSONProtoFuncParse(ExecState*);45 static JSValue JSC_HOST_CALL JSONProtoFuncStringify(ExecState*);44 static EncodedJSValue JSC_HOST_CALL JSONProtoFuncParse(ExecState*); 45 static EncodedJSValue JSC_HOST_CALL JSONProtoFuncStringify(ExecState*); 46 46 47 47 } … … 840 840 841 841 // ECMA-262 v5 15.12.2 842 JSValue JSC_HOST_CALL JSONProtoFuncParse(ExecState* exec)842 EncodedJSValue JSC_HOST_CALL JSONProtoFuncParse(ExecState* exec) 843 843 { 844 844 if (!exec->argumentCount()) 845 return throwError(exec, GeneralError, "JSON.parse requires at least one parameter");845 return JSValue::encode(throwError(exec, GeneralError, "JSON.parse requires at least one parameter")); 846 846 JSValue value = exec->argument(0); 847 847 UString source = value.toString(exec); 848 848 if (exec->hadException()) 849 return jsNull();849 return JSValue::encode(jsNull()); 850 850 851 851 LiteralParser jsonParser(exec, source, LiteralParser::StrictJSON); 852 852 JSValue unfiltered = jsonParser.tryLiteralParse(); 853 853 if (!unfiltered) 854 return throwError(exec, SyntaxError, "Unable to parse JSON string");854 return JSValue::encode(throwError(exec, SyntaxError, "Unable to parse JSON string")); 855 855 856 856 if (exec->argumentCount() < 2) 857 return unfiltered;857 return JSValue::encode(unfiltered); 858 858 859 859 JSValue function = exec->argument(1); 860 860 CallData callData; 861 CallType callType = function.getCallData(callData);861 CallType callType = getCallData(function, callData); 862 862 if (callType == CallTypeNone) 863 return unfiltered;864 return Walker(exec, asObject(function), callType, callData).walk(unfiltered);863 return JSValue::encode(unfiltered); 864 return JSValue::encode(Walker(exec, asObject(function), callType, callData).walk(unfiltered)); 865 865 } 866 866 867 867 // ECMA-262 v5 15.12.3 868 JSValue JSC_HOST_CALL JSONProtoFuncStringify(ExecState* exec)868 EncodedJSValue JSC_HOST_CALL JSONProtoFuncStringify(ExecState* exec) 869 869 { 870 870 if (!exec->argumentCount()) 871 return throwError(exec, GeneralError, "No input to stringify");871 return JSValue::encode(throwError(exec, GeneralError, "No input to stringify")); 872 872 JSValue value = exec->argument(0); 873 873 JSValue replacer = exec->argument(1); 874 874 JSValue space = exec->argument(2); 875 return Stringifier(exec, replacer, space).stringify(value);875 return JSValue::encode(Stringifier(exec, replacer, space).stringify(value)); 876 876 } 877 877 -
trunk/JavaScriptCore/runtime/JSObject.cpp
r60390 r60631 225 225 JSValue function = object->get(exec, propertyName); 226 226 CallData callData; 227 CallType callType = function.getCallData(callData);227 CallType callType = getCallData(function, callData); 228 228 if (callType == CallTypeNone) 229 229 return exec->exception(); -
trunk/JavaScriptCore/runtime/JSValue.h
r59941 r60631 24 24 #define JSValue_h 25 25 26 #include "CallData.h"27 #include "ConstructData.h"28 26 #include <math.h> 29 27 #include <stddef.h> // for size_t … … 36 34 namespace JSC { 37 35 36 class ExecState; 38 37 class Identifier; 39 38 class JSCell; … … 144 143 JSObject* getObject() const; // 0 if not an object 145 144 146 CallType getCallData(CallData&);147 ConstructType getConstructData(ConstructData&);148 149 145 // Extracting integer values. 150 146 bool getUInt32(uint32_t&) const; -
trunk/JavaScriptCore/runtime/MathObject.cpp
r60392 r60631 35 35 ASSERT_CLASS_FITS_IN_CELL(MathObject); 36 36 37 static JSValue JSC_HOST_CALL mathProtoFuncAbs(ExecState*);38 static JSValue JSC_HOST_CALL mathProtoFuncACos(ExecState*);39 static JSValue JSC_HOST_CALL mathProtoFuncASin(ExecState*);40 static JSValue JSC_HOST_CALL mathProtoFuncATan(ExecState*);41 static JSValue JSC_HOST_CALL mathProtoFuncATan2(ExecState*);42 static JSValue JSC_HOST_CALL mathProtoFuncCeil(ExecState*);43 static JSValue JSC_HOST_CALL mathProtoFuncCos(ExecState*);44 static JSValue JSC_HOST_CALL mathProtoFuncExp(ExecState*);45 static JSValue JSC_HOST_CALL mathProtoFuncFloor(ExecState*);46 static JSValue JSC_HOST_CALL mathProtoFuncLog(ExecState*);47 static JSValue JSC_HOST_CALL mathProtoFuncMax(ExecState*);48 static JSValue JSC_HOST_CALL mathProtoFuncMin(ExecState*);49 static JSValue JSC_HOST_CALL mathProtoFuncPow(ExecState*);50 static JSValue JSC_HOST_CALL mathProtoFuncRandom(ExecState*);51 static JSValue JSC_HOST_CALL mathProtoFuncRound(ExecState*);52 static JSValue JSC_HOST_CALL mathProtoFuncSin(ExecState*);53 static JSValue JSC_HOST_CALL mathProtoFuncSqrt(ExecState*);54 static JSValue JSC_HOST_CALL mathProtoFuncTan(ExecState*);37 static EncodedJSValue JSC_HOST_CALL mathProtoFuncAbs(ExecState*); 38 static EncodedJSValue JSC_HOST_CALL mathProtoFuncACos(ExecState*); 39 static EncodedJSValue JSC_HOST_CALL mathProtoFuncASin(ExecState*); 40 static EncodedJSValue JSC_HOST_CALL mathProtoFuncATan(ExecState*); 41 static EncodedJSValue JSC_HOST_CALL mathProtoFuncATan2(ExecState*); 42 static EncodedJSValue JSC_HOST_CALL mathProtoFuncCeil(ExecState*); 43 static EncodedJSValue JSC_HOST_CALL mathProtoFuncCos(ExecState*); 44 static EncodedJSValue JSC_HOST_CALL mathProtoFuncExp(ExecState*); 45 static EncodedJSValue JSC_HOST_CALL mathProtoFuncFloor(ExecState*); 46 static EncodedJSValue JSC_HOST_CALL mathProtoFuncLog(ExecState*); 47 static EncodedJSValue JSC_HOST_CALL mathProtoFuncMax(ExecState*); 48 static EncodedJSValue JSC_HOST_CALL mathProtoFuncMin(ExecState*); 49 static EncodedJSValue JSC_HOST_CALL mathProtoFuncPow(ExecState*); 50 static EncodedJSValue JSC_HOST_CALL mathProtoFuncRandom(ExecState*); 51 static EncodedJSValue JSC_HOST_CALL mathProtoFuncRound(ExecState*); 52 static EncodedJSValue JSC_HOST_CALL mathProtoFuncSin(ExecState*); 53 static EncodedJSValue JSC_HOST_CALL mathProtoFuncSqrt(ExecState*); 54 static EncodedJSValue JSC_HOST_CALL mathProtoFuncTan(ExecState*); 55 55 56 56 } … … 114 114 // ------------------------------ Functions -------------------------------- 115 115 116 JSValue JSC_HOST_CALL mathProtoFuncAbs(ExecState* exec)117 { 118 return jsNumber(exec, fabs(exec->argument(0).toNumber(exec)));119 } 120 121 JSValue JSC_HOST_CALL mathProtoFuncACos(ExecState* exec)122 { 123 return jsDoubleNumber(exec, acos(exec->argument(0).toNumber(exec)));124 } 125 126 JSValue JSC_HOST_CALL mathProtoFuncASin(ExecState* exec)127 { 128 return jsDoubleNumber(exec, asin(exec->argument(0).toNumber(exec)));129 } 130 131 JSValue JSC_HOST_CALL mathProtoFuncATan(ExecState* exec)132 { 133 return jsDoubleNumber(exec, atan(exec->argument(0).toNumber(exec)));134 } 135 136 JSValue JSC_HOST_CALL mathProtoFuncATan2(ExecState* exec)137 { 138 return jsDoubleNumber(exec, atan2(exec->argument(0).toNumber(exec), exec->argument(1).toNumber(exec)));139 } 140 141 JSValue JSC_HOST_CALL mathProtoFuncCeil(ExecState* exec)142 { 143 return jsNumber(exec, ceil(exec->argument(0).toNumber(exec)));144 } 145 146 JSValue JSC_HOST_CALL mathProtoFuncCos(ExecState* exec)147 { 148 return jsDoubleNumber(exec, cos(exec->argument(0).toNumber(exec)));149 } 150 151 JSValue JSC_HOST_CALL mathProtoFuncExp(ExecState* exec)152 { 153 return jsDoubleNumber(exec, exp(exec->argument(0).toNumber(exec)));154 } 155 156 JSValue JSC_HOST_CALL mathProtoFuncFloor(ExecState* exec)157 { 158 return jsNumber(exec, floor(exec->argument(0).toNumber(exec)));159 } 160 161 JSValue JSC_HOST_CALL mathProtoFuncLog(ExecState* exec)162 { 163 return jsDoubleNumber(exec, log(exec->argument(0).toNumber(exec)));164 } 165 166 JSValue JSC_HOST_CALL mathProtoFuncMax(ExecState* exec)116 EncodedJSValue JSC_HOST_CALL mathProtoFuncAbs(ExecState* exec) 117 { 118 return JSValue::encode(jsNumber(exec, fabs(exec->argument(0).toNumber(exec)))); 119 } 120 121 EncodedJSValue JSC_HOST_CALL mathProtoFuncACos(ExecState* exec) 122 { 123 return JSValue::encode(jsDoubleNumber(exec, acos(exec->argument(0).toNumber(exec)))); 124 } 125 126 EncodedJSValue JSC_HOST_CALL mathProtoFuncASin(ExecState* exec) 127 { 128 return JSValue::encode(jsDoubleNumber(exec, asin(exec->argument(0).toNumber(exec)))); 129 } 130 131 EncodedJSValue JSC_HOST_CALL mathProtoFuncATan(ExecState* exec) 132 { 133 return JSValue::encode(jsDoubleNumber(exec, atan(exec->argument(0).toNumber(exec)))); 134 } 135 136 EncodedJSValue JSC_HOST_CALL mathProtoFuncATan2(ExecState* exec) 137 { 138 return JSValue::encode(jsDoubleNumber(exec, atan2(exec->argument(0).toNumber(exec), exec->argument(1).toNumber(exec)))); 139 } 140 141 EncodedJSValue JSC_HOST_CALL mathProtoFuncCeil(ExecState* exec) 142 { 143 return JSValue::encode(jsNumber(exec, ceil(exec->argument(0).toNumber(exec)))); 144 } 145 146 EncodedJSValue JSC_HOST_CALL mathProtoFuncCos(ExecState* exec) 147 { 148 return JSValue::encode(jsDoubleNumber(exec, cos(exec->argument(0).toNumber(exec)))); 149 } 150 151 EncodedJSValue JSC_HOST_CALL mathProtoFuncExp(ExecState* exec) 152 { 153 return JSValue::encode(jsDoubleNumber(exec, exp(exec->argument(0).toNumber(exec)))); 154 } 155 156 EncodedJSValue JSC_HOST_CALL mathProtoFuncFloor(ExecState* exec) 157 { 158 return JSValue::encode(jsNumber(exec, floor(exec->argument(0).toNumber(exec)))); 159 } 160 161 EncodedJSValue JSC_HOST_CALL mathProtoFuncLog(ExecState* exec) 162 { 163 return JSValue::encode(jsDoubleNumber(exec, log(exec->argument(0).toNumber(exec)))); 164 } 165 166 EncodedJSValue JSC_HOST_CALL mathProtoFuncMax(ExecState* exec) 167 167 { 168 168 unsigned argsCount = exec->argumentCount(); … … 177 177 result = val; 178 178 } 179 return jsNumber(exec, result);180 } 181 182 JSValue JSC_HOST_CALL mathProtoFuncMin(ExecState* exec)179 return JSValue::encode(jsNumber(exec, result)); 180 } 181 182 EncodedJSValue JSC_HOST_CALL mathProtoFuncMin(ExecState* exec) 183 183 { 184 184 unsigned argsCount = exec->argumentCount(); … … 193 193 result = val; 194 194 } 195 return jsNumber(exec, result);196 } 197 198 JSValue JSC_HOST_CALL mathProtoFuncPow(ExecState* exec)195 return JSValue::encode(jsNumber(exec, result)); 196 } 197 198 EncodedJSValue JSC_HOST_CALL mathProtoFuncPow(ExecState* exec) 199 199 { 200 200 // ECMA 15.8.2.1.13 … … 204 204 205 205 if (isnan(arg2)) 206 return jsNaN(exec);206 return JSValue::encode(jsNaN(exec)); 207 207 if (isinf(arg2) && fabs(arg) == 1) 208 return jsNaN(exec);209 return jsNumber(exec, pow(arg, arg2));210 } 211 212 JSValue JSC_HOST_CALL mathProtoFuncRandom(ExecState* exec)213 { 214 return jsDoubleNumber(exec, exec->globalData().weakRandom.get());215 } 216 217 JSValue JSC_HOST_CALL mathProtoFuncRound(ExecState* exec)208 return JSValue::encode(jsNaN(exec)); 209 return JSValue::encode(jsNumber(exec, pow(arg, arg2))); 210 } 211 212 EncodedJSValue JSC_HOST_CALL mathProtoFuncRandom(ExecState* exec) 213 { 214 return JSValue::encode(jsDoubleNumber(exec, exec->globalData().weakRandom.get())); 215 } 216 217 EncodedJSValue JSC_HOST_CALL mathProtoFuncRound(ExecState* exec) 218 218 { 219 219 double arg = exec->argument(0).toNumber(exec); 220 220 double integer = ceil(arg); 221 return jsNumber(exec, integer - (integer - arg > 0.5));222 } 223 224 JSValue JSC_HOST_CALL mathProtoFuncSin(ExecState* exec)225 { 226 return exec->globalData().cachedSin(exec, exec->argument(0).toNumber(exec));227 } 228 229 JSValue JSC_HOST_CALL mathProtoFuncSqrt(ExecState* exec)230 { 231 return jsDoubleNumber(exec, sqrt(exec->argument(0).toNumber(exec)));232 } 233 234 JSValue JSC_HOST_CALL mathProtoFuncTan(ExecState* exec)235 { 236 return jsDoubleNumber(exec, tan(exec->argument(0).toNumber(exec)));221 return JSValue::encode(jsNumber(exec, integer - (integer - arg > 0.5))); 222 } 223 224 EncodedJSValue JSC_HOST_CALL mathProtoFuncSin(ExecState* exec) 225 { 226 return JSValue::encode(exec->globalData().cachedSin(exec, exec->argument(0).toNumber(exec))); 227 } 228 229 EncodedJSValue JSC_HOST_CALL mathProtoFuncSqrt(ExecState* exec) 230 { 231 return JSValue::encode(jsDoubleNumber(exec, sqrt(exec->argument(0).toNumber(exec)))); 232 } 233 234 EncodedJSValue JSC_HOST_CALL mathProtoFuncTan(ExecState* exec) 235 { 236 return JSValue::encode(jsDoubleNumber(exec, tan(exec->argument(0).toNumber(exec)))); 237 237 } 238 238 -
trunk/JavaScriptCore/runtime/NativeErrorConstructor.cpp
r60392 r60631 63 63 } 64 64 65 static JSValue JSC_HOST_CALL callNativeErrorConstructor(ExecState* exec)65 static EncodedJSValue JSC_HOST_CALL callNativeErrorConstructor(ExecState* exec) 66 66 { 67 67 ArgList args(exec); 68 return static_cast<NativeErrorConstructor*>(exec->callee())->construct(exec, args);68 return JSValue::encode(static_cast<NativeErrorConstructor*>(exec->callee())->construct(exec, args)); 69 69 } 70 70 -
trunk/JavaScriptCore/runtime/NumberConstructor.cpp
r60392 r60631 116 116 117 117 // ECMA 15.7.2 118 static JSValue JSC_HOST_CALL callNumberConstructor(ExecState* exec)118 static EncodedJSValue JSC_HOST_CALL callNumberConstructor(ExecState* exec) 119 119 { 120 return jsNumber(exec, !exec->argumentCount() ? 0 : exec->argument(0).toNumber(exec));120 return JSValue::encode(jsNumber(exec, !exec->argumentCount() ? 0 : exec->argument(0).toNumber(exec))); 121 121 } 122 122 -
trunk/JavaScriptCore/runtime/NumberPrototype.cpp
r60392 r60631 39 39 ASSERT_CLASS_FITS_IN_CELL(NumberPrototype); 40 40 41 static JSValue JSC_HOST_CALL numberProtoFuncToString(ExecState*);42 static JSValue JSC_HOST_CALL numberProtoFuncToLocaleString(ExecState*);43 static JSValue JSC_HOST_CALL numberProtoFuncValueOf(ExecState*);44 static JSValue JSC_HOST_CALL numberProtoFuncToFixed(ExecState*);45 static JSValue JSC_HOST_CALL numberProtoFuncToExponential(ExecState*);46 static JSValue JSC_HOST_CALL numberProtoFuncToPrecision(ExecState*);41 static EncodedJSValue JSC_HOST_CALL numberProtoFuncToString(ExecState*); 42 static EncodedJSValue JSC_HOST_CALL numberProtoFuncToLocaleString(ExecState*); 43 static EncodedJSValue JSC_HOST_CALL numberProtoFuncValueOf(ExecState*); 44 static EncodedJSValue JSC_HOST_CALL numberProtoFuncToFixed(ExecState*); 45 static EncodedJSValue JSC_HOST_CALL numberProtoFuncToExponential(ExecState*); 46 static EncodedJSValue JSC_HOST_CALL numberProtoFuncToPrecision(ExecState*); 47 47 48 48 // ECMA 15.7.4 … … 138 138 } 139 139 140 JSValue JSC_HOST_CALL numberProtoFuncToString(ExecState* exec)141 { 142 JSValue thisValue = exec->hostThisValue(); 143 JSValue v = thisValue.getJSNumber(); 144 if (!v) 145 return throwError(exec, TypeError);140 EncodedJSValue JSC_HOST_CALL numberProtoFuncToString(ExecState* exec) 141 { 142 JSValue thisValue = exec->hostThisValue(); 143 JSValue v = thisValue.getJSNumber(); 144 if (!v) 145 return JSValue::encode(throwError(exec, TypeError)); 146 146 147 147 JSValue radixValue = exec->argument(0); … … 155 155 156 156 if (radix == 10) 157 return jsString(exec, v.toString(exec));157 return JSValue::encode(jsString(exec, v.toString(exec))); 158 158 159 159 static const char* const digits = "0123456789abcdefghijklmnopqrstuvwxyz"; … … 165 165 if (static_cast<unsigned>(x) < 36) { // Exclude negatives 166 166 JSGlobalData* globalData = &exec->globalData(); 167 return globalData->smallStrings.singleCharacterString(globalData, digits[x]);167 return JSValue::encode(globalData->smallStrings.singleCharacterString(globalData, digits[x])); 168 168 } 169 169 } … … 171 171 172 172 if (radix < 2 || radix > 36) 173 return throwError(exec, RangeError, "toString() radix argument must be between 2 and 36");173 return JSValue::encode(throwError(exec, RangeError, "toString() radix argument must be between 2 and 36")); 174 174 175 175 // INT_MAX results in 1024 characters left of the dot with radix 2 … … 180 180 double x = v.uncheckedGetNumber(); 181 181 if (isnan(x) || isinf(x)) 182 return jsString(exec, UString::from(x));182 return JSValue::encode(jsString(exec, UString::from(x))); 183 183 184 184 bool isNegative = x < 0.0; … … 219 219 ASSERT(p < s + sizeof(s)); 220 220 221 return jsString(exec, startOfResultString);222 } 223 224 JSValue JSC_HOST_CALL numberProtoFuncToLocaleString(ExecState* exec)221 return JSValue::encode(jsString(exec, startOfResultString)); 222 } 223 224 EncodedJSValue JSC_HOST_CALL numberProtoFuncToLocaleString(ExecState* exec) 225 225 { 226 226 JSValue thisValue = exec->hostThisValue(); … … 229 229 JSValue v = thisValue.getJSNumber(); 230 230 if (!v) 231 return throwError(exec, TypeError);232 233 return jsString(exec, v.toString(exec));234 } 235 236 JSValue JSC_HOST_CALL numberProtoFuncValueOf(ExecState* exec)237 { 238 JSValue thisValue = exec->hostThisValue(); 239 JSValue v = thisValue.getJSNumber(); 240 if (!v) 241 return throwError(exec, TypeError);242 243 return v;244 } 245 246 JSValue JSC_HOST_CALL numberProtoFuncToFixed(ExecState* exec)247 { 248 JSValue thisValue = exec->hostThisValue(); 249 JSValue v = thisValue.getJSNumber(); 250 if (!v) 251 return throwError(exec, TypeError);231 return JSValue::encode(throwError(exec, TypeError)); 232 233 return JSValue::encode(jsString(exec, v.toString(exec))); 234 } 235 236 EncodedJSValue JSC_HOST_CALL numberProtoFuncValueOf(ExecState* exec) 237 { 238 JSValue thisValue = exec->hostThisValue(); 239 JSValue v = thisValue.getJSNumber(); 240 if (!v) 241 return JSValue::encode(throwError(exec, TypeError)); 242 243 return JSValue::encode(v); 244 } 245 246 EncodedJSValue JSC_HOST_CALL numberProtoFuncToFixed(ExecState* exec) 247 { 248 JSValue thisValue = exec->hostThisValue(); 249 JSValue v = thisValue.getJSNumber(); 250 if (!v) 251 return JSValue::encode(throwError(exec, TypeError)); 252 252 253 253 JSValue fractionDigits = exec->argument(0); 254 254 double df = fractionDigits.toInteger(exec); 255 255 if (!(df >= 0 && df <= 20)) 256 return throwError(exec, RangeError, "toFixed() digits argument must be between 0 and 20");256 return JSValue::encode(throwError(exec, RangeError, "toFixed() digits argument must be between 0 and 20")); 257 257 int f = static_cast<int>(df); 258 258 259 259 double x = v.uncheckedGetNumber(); 260 260 if (isnan(x)) 261 return jsNontrivialString(exec, "NaN");261 return JSValue::encode(jsNontrivialString(exec, "NaN")); 262 262 263 263 UString s; … … 272 272 273 273 if (x >= pow(10.0, 21.0)) 274 return jsString(exec, makeString(s, UString::from(x)));274 return JSValue::encode(jsString(exec, makeString(s, UString::from(x)))); 275 275 276 276 const double tenToTheF = pow(10.0, f); … … 294 294 295 295 if (kMinusf < static_cast<int>(m.size())) 296 return jsString(exec, makeString(s, m.substr(0, kMinusf), ".", m.substr(kMinusf)));297 return jsString(exec, makeString(s, m.substr(0, kMinusf)));296 return JSValue::encode(jsString(exec, makeString(s, m.substr(0, kMinusf), ".", m.substr(kMinusf)))); 297 return JSValue::encode(jsString(exec, makeString(s, m.substr(0, kMinusf)))); 298 298 } 299 299 … … 336 336 } 337 337 338 JSValue JSC_HOST_CALL numberProtoFuncToExponential(ExecState* exec)339 { 340 JSValue thisValue = exec->hostThisValue(); 341 JSValue v = thisValue.getJSNumber(); 342 if (!v) 343 return throwError(exec, TypeError);338 EncodedJSValue JSC_HOST_CALL numberProtoFuncToExponential(ExecState* exec) 339 { 340 JSValue thisValue = exec->hostThisValue(); 341 JSValue v = thisValue.getJSNumber(); 342 if (!v) 343 return JSValue::encode(throwError(exec, TypeError)); 344 344 345 345 double x = v.uncheckedGetNumber(); 346 346 347 347 if (isnan(x) || isinf(x)) 348 return jsString(exec, UString::from(x));348 return JSValue::encode(jsString(exec, UString::from(x))); 349 349 350 350 JSValue fractionalDigitsValue = exec->argument(0); 351 351 double df = fractionalDigitsValue.toInteger(exec); 352 352 if (!(df >= 0 && df <= 20)) 353 return throwError(exec, RangeError, "toExponential() argument must between 0 and 20");353 return JSValue::encode(throwError(exec, RangeError, "toExponential() argument must between 0 and 20")); 354 354 int fractionalDigits = static_cast<int>(df); 355 355 bool includeAllDigits = fractionalDigitsValue.isUndefined(); … … 372 372 373 373 if (isnan(x)) 374 return jsNontrivialString(exec, "NaN");374 return JSValue::encode(jsNontrivialString(exec, "NaN")); 375 375 376 376 if (x == -0.0) // (-0.0).toExponential() should print as 0 instead of -0 … … 406 406 ASSERT(i <= 80); 407 407 408 return jsString(exec, buf);409 } 410 411 JSValue JSC_HOST_CALL numberProtoFuncToPrecision(ExecState* exec)412 { 413 JSValue thisValue = exec->hostThisValue(); 414 JSValue v = thisValue.getJSNumber(); 415 if (!v) 416 return throwError(exec, TypeError);408 return JSValue::encode(jsString(exec, buf)); 409 } 410 411 EncodedJSValue JSC_HOST_CALL numberProtoFuncToPrecision(ExecState* exec) 412 { 413 JSValue thisValue = exec->hostThisValue(); 414 JSValue v = thisValue.getJSNumber(); 415 if (!v) 416 return JSValue::encode(throwError(exec, TypeError)); 417 417 418 418 double doublePrecision = exec->argument(0).toIntegerPreserveNaN(exec); 419 419 double x = v.uncheckedGetNumber(); 420 420 if (exec->argument(0).isUndefined() || isnan(x) || isinf(x)) 421 return jsString(exec, v.toString(exec));421 return JSValue::encode(jsString(exec, v.toString(exec))); 422 422 423 423 UString s; … … 429 429 430 430 if (!(doublePrecision >= 1 && doublePrecision <= 21)) // true for NaN 431 return throwError(exec, RangeError, "toPrecision() argument must be between 1 and 21");431 return JSValue::encode(throwError(exec, RangeError, "toPrecision() argument must be between 1 and 21")); 432 432 int precision = static_cast<int>(doublePrecision); 433 433 … … 459 459 m = makeString(m.substr(0, 1), ".", m.substr(1)); 460 460 if (e >= 0) 461 return jsMakeNontrivialString(exec, s, m, "e+", UString::from(e));462 return jsMakeNontrivialString(exec, s, m, "e-", UString::from(-e));461 return JSValue::encode(jsMakeNontrivialString(exec, s, m, "e+", UString::from(e))); 462 return JSValue::encode(jsMakeNontrivialString(exec, s, m, "e-", UString::from(-e))); 463 463 } 464 464 } else { … … 468 468 469 469 if (e == precision - 1) 470 return jsString(exec, makeString(s, m));470 return JSValue::encode(jsString(exec, makeString(s, m))); 471 471 if (e >= 0) { 472 472 if (e + 1 < static_cast<int>(m.size())) 473 return jsString(exec, makeString(s, m.substr(0, e + 1), ".", m.substr(e + 1)));474 return jsString(exec, makeString(s, m));475 } 476 return jsMakeNontrivialString(exec, s, "0.", charSequence('0', -(e + 1)), m);473 return JSValue::encode(jsString(exec, makeString(s, m.substr(0, e + 1), ".", m.substr(e + 1)))); 474 return JSValue::encode(jsString(exec, makeString(s, m))); 475 } 476 return JSValue::encode(jsMakeNontrivialString(exec, s, "0.", charSequence('0', -(e + 1)), m)); 477 477 } 478 478 -
trunk/JavaScriptCore/runtime/ObjectConstructor.cpp
r60392 r60631 35 35 ASSERT_CLASS_FITS_IN_CELL(ObjectConstructor); 36 36 37 static JSValue JSC_HOST_CALL objectConstructorGetPrototypeOf(ExecState*);38 static JSValue JSC_HOST_CALL objectConstructorGetOwnPropertyDescriptor(ExecState*);39 static JSValue JSC_HOST_CALL objectConstructorGetOwnPropertyNames(ExecState*);40 static JSValue JSC_HOST_CALL objectConstructorKeys(ExecState*);41 static JSValue JSC_HOST_CALL objectConstructorDefineProperty(ExecState*);42 static JSValue JSC_HOST_CALL objectConstructorDefineProperties(ExecState*);43 static JSValue JSC_HOST_CALL objectConstructorCreate(ExecState*);37 static EncodedJSValue JSC_HOST_CALL objectConstructorGetPrototypeOf(ExecState*); 38 static EncodedJSValue JSC_HOST_CALL objectConstructorGetOwnPropertyDescriptor(ExecState*); 39 static EncodedJSValue JSC_HOST_CALL objectConstructorGetOwnPropertyNames(ExecState*); 40 static EncodedJSValue JSC_HOST_CALL objectConstructorKeys(ExecState*); 41 static EncodedJSValue JSC_HOST_CALL objectConstructorDefineProperty(ExecState*); 42 static EncodedJSValue JSC_HOST_CALL objectConstructorDefineProperties(ExecState*); 43 static EncodedJSValue JSC_HOST_CALL objectConstructorCreate(ExecState*); 44 44 45 45 ObjectConstructor::ObjectConstructor(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, ObjectPrototype* objectPrototype, Structure* prototypeFunctionStructure) … … 81 81 } 82 82 83 static JSValue JSC_HOST_CALL callObjectConstructor(ExecState* exec)83 static EncodedJSValue JSC_HOST_CALL callObjectConstructor(ExecState* exec) 84 84 { 85 85 ArgList args(exec); 86 return constructObject(exec, args);86 return JSValue::encode(constructObject(exec, args)); 87 87 } 88 88 … … 93 93 } 94 94 95 JSValue JSC_HOST_CALL objectConstructorGetPrototypeOf(ExecState* exec)96 { 97 if (!exec->argument(0).isObject()) 98 return throwError(exec, TypeError, "Requested prototype of a value that is not an object.");99 return asObject(exec->argument(0))->prototype();100 } 101 102 JSValue JSC_HOST_CALL objectConstructorGetOwnPropertyDescriptor(ExecState* exec)103 { 104 if (!exec->argument(0).isObject()) 105 return throwError(exec, TypeError, "Requested property descriptor of a value that is not an object.");95 EncodedJSValue JSC_HOST_CALL objectConstructorGetPrototypeOf(ExecState* exec) 96 { 97 if (!exec->argument(0).isObject()) 98 return JSValue::encode(throwError(exec, TypeError, "Requested prototype of a value that is not an object.")); 99 return JSValue::encode(asObject(exec->argument(0))->prototype()); 100 } 101 102 EncodedJSValue JSC_HOST_CALL objectConstructorGetOwnPropertyDescriptor(ExecState* exec) 103 { 104 if (!exec->argument(0).isObject()) 105 return JSValue::encode(throwError(exec, TypeError, "Requested property descriptor of a value that is not an object.")); 106 106 UString propertyName = exec->argument(1).toString(exec); 107 107 if (exec->hadException()) 108 return jsNull();108 return JSValue::encode(jsNull()); 109 109 JSObject* object = asObject(exec->argument(0)); 110 110 PropertyDescriptor descriptor; 111 111 if (!object->getOwnPropertyDescriptor(exec, Identifier(exec, propertyName), descriptor)) 112 return jsUndefined();112 return JSValue::encode(jsUndefined()); 113 113 if (exec->hadException()) 114 return jsUndefined();114 return JSValue::encode(jsUndefined()); 115 115 116 116 JSObject* description = constructEmptyObject(exec); … … 126 126 description->putDirect(exec->propertyNames().configurable, jsBoolean(descriptor.configurable()), 0); 127 127 128 return description;128 return JSValue::encode(description); 129 129 } 130 130 131 131 // FIXME: Use the enumeration cache. 132 JSValue JSC_HOST_CALL objectConstructorGetOwnPropertyNames(ExecState* exec)133 { 134 if (!exec->argument(0).isObject()) 135 return throwError(exec, TypeError, "Requested property names of a value that is not an object.");132 EncodedJSValue JSC_HOST_CALL objectConstructorGetOwnPropertyNames(ExecState* exec) 133 { 134 if (!exec->argument(0).isObject()) 135 return JSValue::encode(throwError(exec, TypeError, "Requested property names of a value that is not an object.")); 136 136 PropertyNameArray properties(exec); 137 137 asObject(exec->argument(0))->getOwnPropertyNames(exec, properties, IncludeDontEnumProperties); … … 140 140 for (size_t i = 0; i < numProperties; i++) 141 141 names->push(exec, jsOwnedString(exec, properties[i].ustring())); 142 return names;142 return JSValue::encode(names); 143 143 } 144 144 145 145 // FIXME: Use the enumeration cache. 146 JSValue JSC_HOST_CALL objectConstructorKeys(ExecState* exec)147 { 148 if (!exec->argument(0).isObject()) 149 return throwError(exec, TypeError, "Requested keys of a value that is not an object.");146 EncodedJSValue JSC_HOST_CALL objectConstructorKeys(ExecState* exec) 147 { 148 if (!exec->argument(0).isObject()) 149 return JSValue::encode(throwError(exec, TypeError, "Requested keys of a value that is not an object.")); 150 150 PropertyNameArray properties(exec); 151 151 asObject(exec->argument(0))->getOwnPropertyNames(exec, properties); … … 154 154 for (size_t i = 0; i < numProperties; i++) 155 155 keys->push(exec, jsOwnedString(exec, properties[i].ustring())); 156 return keys;156 return JSValue::encode(keys); 157 157 } 158 158 … … 202 202 if (!get.isUndefined()) { 203 203 CallData callData; 204 if (get .getCallData(callData) == CallTypeNone) {204 if (getCallData(get, callData) == CallTypeNone) { 205 205 throwError(exec, TypeError, "Getter must be a function."); 206 206 return false; … … 218 218 if (!set.isUndefined()) { 219 219 CallData callData; 220 if ( set.getCallData(callData) == CallTypeNone) {220 if (getCallData(set, callData) == CallTypeNone) { 221 221 throwError(exec, TypeError, "Setter must be a function."); 222 222 return false; … … 243 243 } 244 244 245 JSValue JSC_HOST_CALL objectConstructorDefineProperty(ExecState* exec)246 { 247 if (!exec->argument(0).isObject()) 248 return throwError(exec, TypeError, "Properties can only be defined on Objects.");245 EncodedJSValue JSC_HOST_CALL objectConstructorDefineProperty(ExecState* exec) 246 { 247 if (!exec->argument(0).isObject()) 248 return JSValue::encode(throwError(exec, TypeError, "Properties can only be defined on Objects.")); 249 249 JSObject* O = asObject(exec->argument(0)); 250 250 UString propertyName = exec->argument(1).toString(exec); 251 251 if (exec->hadException()) 252 return jsNull();252 return JSValue::encode(jsNull()); 253 253 PropertyDescriptor descriptor; 254 254 if (!toPropertyDescriptor(exec, exec->argument(2), descriptor)) 255 return jsNull();255 return JSValue::encode(jsNull()); 256 256 ASSERT((descriptor.attributes() & (Getter | Setter)) || (!descriptor.isAccessorDescriptor())); 257 257 ASSERT(!exec->hadException()); 258 258 O->defineOwnProperty(exec, Identifier(exec, propertyName), descriptor, true); 259 return O;259 return JSValue::encode(O); 260 260 } 261 261 … … 294 294 } 295 295 296 JSValue JSC_HOST_CALL objectConstructorDefineProperties(ExecState* exec)297 { 298 if (!exec->argument(0).isObject()) 299 return throwError(exec, TypeError, "Properties can only be defined on Objects.");296 EncodedJSValue JSC_HOST_CALL objectConstructorDefineProperties(ExecState* exec) 297 { 298 if (!exec->argument(0).isObject()) 299 return JSValue::encode(throwError(exec, TypeError, "Properties can only be defined on Objects.")); 300 300 if (!exec->argument(1).isObject()) 301 return throwError(exec, TypeError, "Property descriptor list must be an Object.");302 return defineProperties(exec, asObject(exec->argument(0)), asObject(exec->argument(1)));303 } 304 305 JSValue JSC_HOST_CALL objectConstructorCreate(ExecState* exec)301 return JSValue::encode(throwError(exec, TypeError, "Property descriptor list must be an Object.")); 302 return JSValue::encode(defineProperties(exec, asObject(exec->argument(0)), asObject(exec->argument(1)))); 303 } 304 305 EncodedJSValue JSC_HOST_CALL objectConstructorCreate(ExecState* exec) 306 306 { 307 307 if (!exec->argument(0).isObject() && !exec->argument(0).isNull()) 308 return throwError(exec, TypeError, "Object prototype may only be an Object or null.");308 return JSValue::encode(throwError(exec, TypeError, "Object prototype may only be an Object or null.")); 309 309 JSObject* newObject = constructEmptyObject(exec); 310 310 newObject->setPrototype(exec->argument(0)); 311 311 if (exec->argument(1).isUndefined()) 312 return newObject;312 return JSValue::encode(newObject); 313 313 if (!exec->argument(1).isObject()) 314 return throwError(exec, TypeError, "Property descriptor list must be an Object.");315 return defineProperties(exec, newObject, asObject(exec->argument(1)));314 return JSValue::encode(throwError(exec, TypeError, "Property descriptor list must be an Object.")); 315 return JSValue::encode(defineProperties(exec, newObject, asObject(exec->argument(1)))); 316 316 } 317 317 -
trunk/JavaScriptCore/runtime/ObjectPrototype.cpp
r60392 r60631 32 32 ASSERT_CLASS_FITS_IN_CELL(ObjectPrototype); 33 33 34 static JSValue JSC_HOST_CALL objectProtoFuncValueOf(ExecState*);35 static JSValue JSC_HOST_CALL objectProtoFuncHasOwnProperty(ExecState*);36 static JSValue JSC_HOST_CALL objectProtoFuncIsPrototypeOf(ExecState*);37 static JSValue JSC_HOST_CALL objectProtoFuncDefineGetter(ExecState*);38 static JSValue JSC_HOST_CALL objectProtoFuncDefineSetter(ExecState*);39 static JSValue JSC_HOST_CALL objectProtoFuncLookupGetter(ExecState*);40 static JSValue JSC_HOST_CALL objectProtoFuncLookupSetter(ExecState*);41 static JSValue JSC_HOST_CALL objectProtoFuncPropertyIsEnumerable(ExecState*);42 static JSValue JSC_HOST_CALL objectProtoFuncToLocaleString(ExecState*);34 static EncodedJSValue JSC_HOST_CALL objectProtoFuncValueOf(ExecState*); 35 static EncodedJSValue JSC_HOST_CALL objectProtoFuncHasOwnProperty(ExecState*); 36 static EncodedJSValue JSC_HOST_CALL objectProtoFuncIsPrototypeOf(ExecState*); 37 static EncodedJSValue JSC_HOST_CALL objectProtoFuncDefineGetter(ExecState*); 38 static EncodedJSValue JSC_HOST_CALL objectProtoFuncDefineSetter(ExecState*); 39 static EncodedJSValue JSC_HOST_CALL objectProtoFuncLookupGetter(ExecState*); 40 static EncodedJSValue JSC_HOST_CALL objectProtoFuncLookupSetter(ExecState*); 41 static EncodedJSValue JSC_HOST_CALL objectProtoFuncPropertyIsEnumerable(ExecState*); 42 static EncodedJSValue JSC_HOST_CALL objectProtoFuncToLocaleString(ExecState*); 43 43 44 44 ObjectPrototype::ObjectPrototype(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> stucture, Structure* prototypeFunctionStructure) … … 82 82 // ECMA 15.2.4.2, 15.2.4.4, 15.2.4.5, 15.2.4.7 83 83 84 JSValue JSC_HOST_CALL objectProtoFuncValueOf(ExecState* exec)84 EncodedJSValue JSC_HOST_CALL objectProtoFuncValueOf(ExecState* exec) 85 85 { 86 86 JSValue thisValue = exec->hostThisValue(); 87 return thisValue.toThisObject(exec);87 return JSValue::encode(thisValue.toThisObject(exec)); 88 88 } 89 89 90 JSValue JSC_HOST_CALL objectProtoFuncHasOwnProperty(ExecState* exec)90 EncodedJSValue JSC_HOST_CALL objectProtoFuncHasOwnProperty(ExecState* exec) 91 91 { 92 92 JSValue thisValue = exec->hostThisValue(); 93 return jsBoolean(thisValue.toThisObject(exec)->hasOwnProperty(exec, Identifier(exec, exec->argument(0).toString(exec))));93 return JSValue::encode(jsBoolean(thisValue.toThisObject(exec)->hasOwnProperty(exec, Identifier(exec, exec->argument(0).toString(exec))))); 94 94 } 95 95 96 JSValue JSC_HOST_CALL objectProtoFuncIsPrototypeOf(ExecState* exec)96 EncodedJSValue JSC_HOST_CALL objectProtoFuncIsPrototypeOf(ExecState* exec) 97 97 { 98 98 JSValue thisValue = exec->hostThisValue(); … … 100 100 101 101 if (!exec->argument(0).isObject()) 102 return jsBoolean(false);102 return JSValue::encode(jsBoolean(false)); 103 103 104 104 JSValue v = asObject(exec->argument(0))->prototype(); … … 106 106 while (true) { 107 107 if (!v.isObject()) 108 return jsBoolean(false);108 return JSValue::encode(jsBoolean(false)); 109 109 if (v == thisObj) 110 return jsBoolean(true);110 return JSValue::encode(jsBoolean(true)); 111 111 v = asObject(v)->prototype(); 112 112 } 113 113 } 114 114 115 JSValue JSC_HOST_CALL objectProtoFuncDefineGetter(ExecState* exec)115 EncodedJSValue JSC_HOST_CALL objectProtoFuncDefineGetter(ExecState* exec) 116 116 { 117 117 JSValue thisValue = exec->hostThisValue(); 118 118 CallData callData; 119 if ( exec->argument(1).getCallData(callData) == CallTypeNone)120 return throwError(exec, SyntaxError, "invalid getter usage");119 if (getCallData(exec->argument(1), callData) == CallTypeNone) 120 return JSValue::encode(throwError(exec, SyntaxError, "invalid getter usage")); 121 121 thisValue.toThisObject(exec)->defineGetter(exec, Identifier(exec, exec->argument(0).toString(exec)), asObject(exec->argument(1))); 122 return jsUndefined();122 return JSValue::encode(jsUndefined()); 123 123 } 124 124 125 JSValue JSC_HOST_CALL objectProtoFuncDefineSetter(ExecState* exec)125 EncodedJSValue JSC_HOST_CALL objectProtoFuncDefineSetter(ExecState* exec) 126 126 { 127 127 JSValue thisValue = exec->hostThisValue(); 128 128 CallData callData; 129 if ( exec->argument(1).getCallData(callData) == CallTypeNone)130 return throwError(exec, SyntaxError, "invalid setter usage");129 if (getCallData(exec->argument(1), callData) == CallTypeNone) 130 return JSValue::encode(throwError(exec, SyntaxError, "invalid setter usage")); 131 131 thisValue.toThisObject(exec)->defineSetter(exec, Identifier(exec, exec->argument(0).toString(exec)), asObject(exec->argument(1))); 132 return jsUndefined();132 return JSValue::encode(jsUndefined()); 133 133 } 134 134 135 JSValue JSC_HOST_CALL objectProtoFuncLookupGetter(ExecState* exec)135 EncodedJSValue JSC_HOST_CALL objectProtoFuncLookupGetter(ExecState* exec) 136 136 { 137 137 JSValue thisValue = exec->hostThisValue(); 138 return thisValue.toThisObject(exec)->lookupGetter(exec, Identifier(exec, exec->argument(0).toString(exec)));138 return JSValue::encode(thisValue.toThisObject(exec)->lookupGetter(exec, Identifier(exec, exec->argument(0).toString(exec)))); 139 139 } 140 140 141 JSValue JSC_HOST_CALL objectProtoFuncLookupSetter(ExecState* exec)141 EncodedJSValue JSC_HOST_CALL objectProtoFuncLookupSetter(ExecState* exec) 142 142 { 143 143 JSValue thisValue = exec->hostThisValue(); 144 return thisValue.toThisObject(exec)->lookupSetter(exec, Identifier(exec, exec->argument(0).toString(exec)));144 return JSValue::encode(thisValue.toThisObject(exec)->lookupSetter(exec, Identifier(exec, exec->argument(0).toString(exec)))); 145 145 } 146 146 147 JSValue JSC_HOST_CALL objectProtoFuncPropertyIsEnumerable(ExecState* exec)147 EncodedJSValue JSC_HOST_CALL objectProtoFuncPropertyIsEnumerable(ExecState* exec) 148 148 { 149 149 JSValue thisValue = exec->hostThisValue(); 150 return jsBoolean(thisValue.toThisObject(exec)->propertyIsEnumerable(exec, Identifier(exec, exec->argument(0).toString(exec))));150 return JSValue::encode(jsBoolean(thisValue.toThisObject(exec)->propertyIsEnumerable(exec, Identifier(exec, exec->argument(0).toString(exec))))); 151 151 } 152 152 153 JSValue JSC_HOST_CALL objectProtoFuncToLocaleString(ExecState* exec)153 EncodedJSValue JSC_HOST_CALL objectProtoFuncToLocaleString(ExecState* exec) 154 154 { 155 155 JSValue thisValue = exec->hostThisValue(); 156 return thisValue.toThisJSString(exec);156 return JSValue::encode(thisValue.toThisJSString(exec)); 157 157 } 158 158 159 JSValue JSC_HOST_CALL objectProtoFuncToString(ExecState* exec)159 EncodedJSValue JSC_HOST_CALL objectProtoFuncToString(ExecState* exec) 160 160 { 161 161 JSValue thisValue = exec->hostThisValue(); 162 return jsMakeNontrivialString(exec, "[object ", thisValue.toThisObject(exec)->className(), "]");162 return JSValue::encode(jsMakeNontrivialString(exec, "[object ", thisValue.toThisObject(exec)->className(), "]")); 163 163 } 164 164 -
trunk/JavaScriptCore/runtime/ObjectPrototype.h
r60392 r60631 37 37 }; 38 38 39 JSValue JSC_HOST_CALL objectProtoFuncToString(ExecState*);39 EncodedJSValue JSC_HOST_CALL objectProtoFuncToString(ExecState*); 40 40 41 41 } // namespace JSC -
trunk/JavaScriptCore/runtime/RegExpConstructor.cpp
r60392 r60631 320 320 321 321 // ECMA 15.10.3 322 static JSValue JSC_HOST_CALL callRegExpConstructor(ExecState* exec)322 static EncodedJSValue JSC_HOST_CALL callRegExpConstructor(ExecState* exec) 323 323 { 324 324 ArgList args(exec); 325 return constructRegExp(exec, args);325 return JSValue::encode(constructRegExp(exec, args)); 326 326 } 327 327 -
trunk/JavaScriptCore/runtime/RegExpObject.cpp
r60392 r60631 126 126 } 127 127 128 static JSValue JSC_HOST_CALL callRegExpObject(ExecState* exec)128 static EncodedJSValue JSC_HOST_CALL callRegExpObject(ExecState* exec) 129 129 { 130 return asRegExpObject(exec->callee())->exec(exec);130 return JSValue::encode(asRegExpObject(exec->callee())->exec(exec)); 131 131 } 132 132 -
trunk/JavaScriptCore/runtime/RegExpPrototype.cpp
r60392 r60631 39 39 ASSERT_CLASS_FITS_IN_CELL(RegExpPrototype); 40 40 41 static JSValue JSC_HOST_CALL regExpProtoFuncTest(ExecState*);42 static JSValue JSC_HOST_CALL regExpProtoFuncExec(ExecState*);43 static JSValue JSC_HOST_CALL regExpProtoFuncCompile(ExecState*);44 static JSValue JSC_HOST_CALL regExpProtoFuncToString(ExecState*);41 static EncodedJSValue JSC_HOST_CALL regExpProtoFuncTest(ExecState*); 42 static EncodedJSValue JSC_HOST_CALL regExpProtoFuncExec(ExecState*); 43 static EncodedJSValue JSC_HOST_CALL regExpProtoFuncCompile(ExecState*); 44 static EncodedJSValue JSC_HOST_CALL regExpProtoFuncToString(ExecState*); 45 45 46 46 // ECMA 15.10.5 … … 58 58 59 59 // ------------------------------ Functions --------------------------- 60 61 JSValue JSC_HOST_CALL regExpProtoFuncTest(ExecState* exec)60 61 EncodedJSValue JSC_HOST_CALL regExpProtoFuncTest(ExecState* exec) 62 62 { 63 63 JSValue thisValue = exec->hostThisValue(); 64 64 if (!thisValue.inherits(&RegExpObject::info)) 65 return throwError(exec, TypeError);66 return asRegExpObject(thisValue)->test(exec);65 return JSValue::encode(throwError(exec, TypeError)); 66 return JSValue::encode(asRegExpObject(thisValue)->test(exec)); 67 67 } 68 68 69 JSValue JSC_HOST_CALL regExpProtoFuncExec(ExecState* exec)69 EncodedJSValue JSC_HOST_CALL regExpProtoFuncExec(ExecState* exec) 70 70 { 71 71 JSValue thisValue = exec->hostThisValue(); 72 72 if (!thisValue.inherits(&RegExpObject::info)) 73 return throwError(exec, TypeError);74 return asRegExpObject(thisValue)->exec(exec);73 return JSValue::encode(throwError(exec, TypeError)); 74 return JSValue::encode(asRegExpObject(thisValue)->exec(exec)); 75 75 } 76 76 77 JSValue JSC_HOST_CALL regExpProtoFuncCompile(ExecState* exec)77 EncodedJSValue JSC_HOST_CALL regExpProtoFuncCompile(ExecState* exec) 78 78 { 79 79 JSValue thisValue = exec->hostThisValue(); 80 80 if (!thisValue.inherits(&RegExpObject::info)) 81 return throwError(exec, TypeError);81 return JSValue::encode(throwError(exec, TypeError)); 82 82 83 83 RefPtr<RegExp> regExp; … … 87 87 if (arg0.inherits(&RegExpObject::info)) { 88 88 if (!arg1.isUndefined()) 89 return throwError(exec, TypeError, "Cannot supply flags when constructing one RegExp from another.");89 return JSValue::encode(throwError(exec, TypeError, "Cannot supply flags when constructing one RegExp from another.")); 90 90 regExp = asRegExpObject(arg0)->regExp(); 91 91 } else { … … 96 96 97 97 if (!regExp->isValid()) 98 return throwError(exec, SyntaxError, makeString("Invalid regular expression: ", regExp->errorMessage()));98 return JSValue::encode(throwError(exec, SyntaxError, makeString("Invalid regular expression: ", regExp->errorMessage()))); 99 99 100 100 asRegExpObject(thisValue)->setRegExp(regExp.release()); 101 101 asRegExpObject(thisValue)->setLastIndex(0); 102 return jsUndefined();102 return JSValue::encode(jsUndefined()); 103 103 } 104 104 105 JSValue JSC_HOST_CALL regExpProtoFuncToString(ExecState* exec)105 EncodedJSValue JSC_HOST_CALL regExpProtoFuncToString(ExecState* exec) 106 106 { 107 107 JSValue thisValue = exec->hostThisValue(); 108 108 if (!thisValue.inherits(&RegExpObject::info)) { 109 109 if (thisValue.inherits(&RegExpPrototype::info)) 110 return jsNontrivialString(exec, "//");111 return throwError(exec, TypeError);110 return JSValue::encode(jsNontrivialString(exec, "//")); 111 return JSValue::encode(throwError(exec, TypeError)); 112 112 } 113 113 … … 122 122 UString source = asRegExpObject(thisValue)->get(exec, exec->propertyNames().source).toString(exec); 123 123 // If source is empty, use "/(?:)/" to avoid colliding with comment syntax 124 return jsMakeNontrivialString(exec, "/", source.size() ? source : UString("(?:)"), postfix);124 return JSValue::encode(jsMakeNontrivialString(exec, "/", source.size() ? source : UString("(?:)"), postfix)); 125 125 } 126 126 -
trunk/JavaScriptCore/runtime/StringConstructor.cpp
r60394 r60631 41 41 } 42 42 43 static JSValue JSC_HOST_CALL stringFromCharCode(ExecState* exec)43 static EncodedJSValue JSC_HOST_CALL stringFromCharCode(ExecState* exec) 44 44 { 45 45 if (LIKELY(exec->argumentCount() == 1)) 46 return jsSingleCharacterString(exec, exec->argument(0).toUInt32(exec));47 return stringFromCharCodeSlowCase(exec);46 return JSValue::encode(jsSingleCharacterString(exec, exec->argument(0).toUInt32(exec))); 47 return JSValue::encode(stringFromCharCodeSlowCase(exec)); 48 48 } 49 49 … … 81 81 82 82 // ECMA 15.5.1 83 static JSValue JSC_HOST_CALL callStringConstructor(ExecState* exec)83 static EncodedJSValue JSC_HOST_CALL callStringConstructor(ExecState* exec) 84 84 { 85 85 if (!exec->argumentCount()) 86 return jsEmptyString(exec);87 return jsString(exec, exec->argument(0).toString(exec));86 return JSValue::encode(jsEmptyString(exec)); 87 return JSValue::encode(jsString(exec, exec->argument(0).toString(exec))); 88 88 } 89 89 -
trunk/JavaScriptCore/runtime/StringPrototype.cpp
r60392 r60631 46 46 ASSERT_CLASS_FITS_IN_CELL(StringPrototype); 47 47 48 static JSValue JSC_HOST_CALL stringProtoFuncToString(ExecState*);49 static JSValue JSC_HOST_CALL stringProtoFuncCharAt(ExecState*);50 static JSValue JSC_HOST_CALL stringProtoFuncCharCodeAt(ExecState*);51 static JSValue JSC_HOST_CALL stringProtoFuncConcat(ExecState*);52 static JSValue JSC_HOST_CALL stringProtoFuncIndexOf(ExecState*);53 static JSValue JSC_HOST_CALL stringProtoFuncLastIndexOf(ExecState*);54 static JSValue JSC_HOST_CALL stringProtoFuncMatch(ExecState*);55 static JSValue JSC_HOST_CALL stringProtoFuncReplace(ExecState*);56 static JSValue JSC_HOST_CALL stringProtoFuncSearch(ExecState*);57 static JSValue JSC_HOST_CALL stringProtoFuncSlice(ExecState*);58 static JSValue JSC_HOST_CALL stringProtoFuncSplit(ExecState*);59 static JSValue JSC_HOST_CALL stringProtoFuncSubstr(ExecState*);60 static JSValue JSC_HOST_CALL stringProtoFuncSubstring(ExecState*);61 static JSValue JSC_HOST_CALL stringProtoFuncToLowerCase(ExecState*);62 static JSValue JSC_HOST_CALL stringProtoFuncToUpperCase(ExecState*);63 static JSValue JSC_HOST_CALL stringProtoFuncLocaleCompare(ExecState*);64 static JSValue JSC_HOST_CALL stringProtoFuncBig(ExecState*);65 static JSValue JSC_HOST_CALL stringProtoFuncSmall(ExecState*);66 static JSValue JSC_HOST_CALL stringProtoFuncBlink(ExecState*);67 static JSValue JSC_HOST_CALL stringProtoFuncBold(ExecState*);68 static JSValue JSC_HOST_CALL stringProtoFuncFixed(ExecState*);69 static JSValue JSC_HOST_CALL stringProtoFuncItalics(ExecState*);70 static JSValue JSC_HOST_CALL stringProtoFuncStrike(ExecState*);71 static JSValue JSC_HOST_CALL stringProtoFuncSub(ExecState*);72 static JSValue JSC_HOST_CALL stringProtoFuncSup(ExecState*);73 static JSValue JSC_HOST_CALL stringProtoFuncFontcolor(ExecState*);74 static JSValue JSC_HOST_CALL stringProtoFuncFontsize(ExecState*);75 static JSValue JSC_HOST_CALL stringProtoFuncAnchor(ExecState*);76 static JSValue JSC_HOST_CALL stringProtoFuncLink(ExecState*);77 static JSValue JSC_HOST_CALL stringProtoFuncTrim(ExecState*);78 static JSValue JSC_HOST_CALL stringProtoFuncTrimLeft(ExecState*);79 static JSValue JSC_HOST_CALL stringProtoFuncTrimRight(ExecState*);48 static EncodedJSValue JSC_HOST_CALL stringProtoFuncToString(ExecState*); 49 static EncodedJSValue JSC_HOST_CALL stringProtoFuncCharAt(ExecState*); 50 static EncodedJSValue JSC_HOST_CALL stringProtoFuncCharCodeAt(ExecState*); 51 static EncodedJSValue JSC_HOST_CALL stringProtoFuncConcat(ExecState*); 52 static EncodedJSValue JSC_HOST_CALL stringProtoFuncIndexOf(ExecState*); 53 static EncodedJSValue JSC_HOST_CALL stringProtoFuncLastIndexOf(ExecState*); 54 static EncodedJSValue JSC_HOST_CALL stringProtoFuncMatch(ExecState*); 55 static EncodedJSValue JSC_HOST_CALL stringProtoFuncReplace(ExecState*); 56 static EncodedJSValue JSC_HOST_CALL stringProtoFuncSearch(ExecState*); 57 static EncodedJSValue JSC_HOST_CALL stringProtoFuncSlice(ExecState*); 58 static EncodedJSValue JSC_HOST_CALL stringProtoFuncSplit(ExecState*); 59 static EncodedJSValue JSC_HOST_CALL stringProtoFuncSubstr(ExecState*); 60 static EncodedJSValue JSC_HOST_CALL stringProtoFuncSubstring(ExecState*); 61 static EncodedJSValue JSC_HOST_CALL stringProtoFuncToLowerCase(ExecState*); 62 static EncodedJSValue JSC_HOST_CALL stringProtoFuncToUpperCase(ExecState*); 63 static EncodedJSValue JSC_HOST_CALL stringProtoFuncLocaleCompare(ExecState*); 64 static EncodedJSValue JSC_HOST_CALL stringProtoFuncBig(ExecState*); 65 static EncodedJSValue JSC_HOST_CALL stringProtoFuncSmall(ExecState*); 66 static EncodedJSValue JSC_HOST_CALL stringProtoFuncBlink(ExecState*); 67 static EncodedJSValue JSC_HOST_CALL stringProtoFuncBold(ExecState*); 68 static EncodedJSValue JSC_HOST_CALL stringProtoFuncFixed(ExecState*); 69 static EncodedJSValue JSC_HOST_CALL stringProtoFuncItalics(ExecState*); 70 static EncodedJSValue JSC_HOST_CALL stringProtoFuncStrike(ExecState*); 71 static EncodedJSValue JSC_HOST_CALL stringProtoFuncSub(ExecState*); 72 static EncodedJSValue JSC_HOST_CALL stringProtoFuncSup(ExecState*); 73 static EncodedJSValue JSC_HOST_CALL stringProtoFuncFontcolor(ExecState*); 74 static EncodedJSValue JSC_HOST_CALL stringProtoFuncFontsize(ExecState*); 75 static EncodedJSValue JSC_HOST_CALL stringProtoFuncAnchor(ExecState*); 76 static EncodedJSValue JSC_HOST_CALL stringProtoFuncLink(ExecState*); 77 static EncodedJSValue JSC_HOST_CALL stringProtoFuncTrim(ExecState*); 78 static EncodedJSValue JSC_HOST_CALL stringProtoFuncTrimLeft(ExecState*); 79 static EncodedJSValue JSC_HOST_CALL stringProtoFuncTrimRight(ExecState*); 80 80 81 81 } … … 287 287 } 288 288 289 JSValue JSC_HOST_CALL stringProtoFuncReplace(ExecState* exec)289 EncodedJSValue JSC_HOST_CALL stringProtoFuncReplace(ExecState* exec) 290 290 { 291 291 JSValue thisValue = exec->hostThisValue(); … … 296 296 UString replacementString; 297 297 CallData callData; 298 CallType callType = replacement.getCallData(callData);298 CallType callType = getCallData(replacement, callData); 299 299 if (callType == CallTypeNone) 300 300 replacementString = replacement.toString(exec); … … 303 303 const UString& source = sourceVal->value(exec); 304 304 if (exec->hadException()) 305 return JSValue ();305 return JSValue::encode(JSValue()); 306 306 RegExp* reg = asRegExpObject(pattern)->regExp(); 307 307 bool global = reg->global(); … … 322 322 CachedCall cachedCall(exec, func, argCount, exec->exceptionSlot()); 323 323 if (exec->hadException()) 324 return jsNull();324 return JSValue::encode(jsNull()); 325 325 while (true) { 326 326 int matchIndex; … … 414 414 415 415 if (!lastIndex && replacements.isEmpty()) 416 return sourceVal;416 return JSValue::encode(sourceVal); 417 417 418 418 if (static_cast<unsigned>(lastIndex) < source.size()) 419 419 sourceRanges.append(StringRange(lastIndex, source.size() - lastIndex)); 420 420 421 return jsSpliceSubstringsWithSeparators(exec, sourceVal, source, sourceRanges.data(), sourceRanges.size(), replacements.data(), replacements.size());421 return JSValue::encode(jsSpliceSubstringsWithSeparators(exec, sourceVal, source, sourceRanges.data(), sourceRanges.size(), replacements.data(), replacements.size())); 422 422 } 423 423 … … 426 426 UString patternString = pattern.toString(exec); 427 427 if (patternString.size() == 1 && callType == CallTypeNone) 428 return sourceVal->replaceCharacter(exec, patternString[0], replacementString);428 return JSValue::encode(sourceVal->replaceCharacter(exec, patternString[0], replacementString)); 429 429 430 430 const UString& source = sourceVal->value(exec); … … 432 432 433 433 if (matchPos == UString::NotFound) 434 return sourceVal;434 return JSValue::encode(sourceVal); 435 435 436 436 int matchLen = patternString.size(); … … 446 446 size_t matchEnd = matchPos + matchLen; 447 447 int ovector[2] = { matchPos, matchEnd }; 448 return jsString(exec, source.substr(0, matchPos), substituteBackreferences(replacementString, source, ovector, 0), source.substr(matchEnd));449 } 450 451 JSValue JSC_HOST_CALL stringProtoFuncToString(ExecState* exec)448 return JSValue::encode(jsString(exec, source.substr(0, matchPos), substituteBackreferences(replacementString, source, ovector, 0), source.substr(matchEnd))); 449 } 450 451 EncodedJSValue JSC_HOST_CALL stringProtoFuncToString(ExecState* exec) 452 452 { 453 453 JSValue thisValue = exec->hostThisValue(); … … 455 455 456 456 if (thisValue.isString()) 457 return thisValue;457 return JSValue::encode(thisValue); 458 458 459 459 if (thisValue.inherits(&StringObject::info)) 460 return asStringObject(thisValue)->internalValue();461 462 return throwError(exec, TypeError);463 } 464 465 JSValue JSC_HOST_CALL stringProtoFuncCharAt(ExecState* exec)460 return JSValue::encode(asStringObject(thisValue)->internalValue()); 461 462 return JSValue::encode(throwError(exec, TypeError)); 463 } 464 465 EncodedJSValue JSC_HOST_CALL stringProtoFuncCharAt(ExecState* exec) 466 466 { 467 467 JSValue thisValue = exec->hostThisValue(); … … 472 472 uint32_t i = a0.asUInt32(); 473 473 if (i < len) 474 return jsSingleCharacterSubstring(exec, s, i);475 return jsEmptyString(exec);474 return JSValue::encode(jsSingleCharacterSubstring(exec, s, i)); 475 return JSValue::encode(jsEmptyString(exec)); 476 476 } 477 477 double dpos = a0.toInteger(exec); 478 478 if (dpos >= 0 && dpos < len) 479 return jsSingleCharacterSubstring(exec, s, static_cast<unsigned>(dpos));480 return jsEmptyString(exec);481 } 482 483 JSValue JSC_HOST_CALL stringProtoFuncCharCodeAt(ExecState* exec)479 return JSValue::encode(jsSingleCharacterSubstring(exec, s, static_cast<unsigned>(dpos))); 480 return JSValue::encode(jsEmptyString(exec)); 481 } 482 483 EncodedJSValue JSC_HOST_CALL stringProtoFuncCharCodeAt(ExecState* exec) 484 484 { 485 485 JSValue thisValue = exec->hostThisValue(); … … 490 490 uint32_t i = a0.asUInt32(); 491 491 if (i < len) 492 return jsNumber(exec, s.data()[i]);493 return jsNaN(exec);492 return JSValue::encode(jsNumber(exec, s.data()[i])); 493 return JSValue::encode(jsNaN(exec)); 494 494 } 495 495 double dpos = a0.toInteger(exec); 496 496 if (dpos >= 0 && dpos < len) 497 return jsNumber(exec, s[static_cast<int>(dpos)]);498 return jsNaN(exec);499 } 500 501 JSValue JSC_HOST_CALL stringProtoFuncConcat(ExecState* exec)497 return JSValue::encode(jsNumber(exec, s[static_cast<int>(dpos)])); 498 return JSValue::encode(jsNaN(exec)); 499 } 500 501 EncodedJSValue JSC_HOST_CALL stringProtoFuncConcat(ExecState* exec) 502 502 { 503 503 JSValue thisValue = exec->hostThisValue(); 504 504 if (thisValue.isString() && (exec->argumentCount() == 1)) { 505 505 JSValue v = exec->argument(0); 506 return v.isString()506 return JSValue::encode(v.isString() 507 507 ? jsString(exec, asString(thisValue), asString(v)) 508 : jsString(exec, asString(thisValue), v.toString(exec)) ;509 } 510 511 return jsString(exec, thisValue);512 } 513 514 JSValue JSC_HOST_CALL stringProtoFuncIndexOf(ExecState* exec)508 : jsString(exec, asString(thisValue), v.toString(exec))); 509 } 510 511 return JSValue::encode(jsString(exec, thisValue)); 512 } 513 514 EncodedJSValue JSC_HOST_CALL stringProtoFuncIndexOf(ExecState* exec) 515 515 { 516 516 JSValue thisValue = exec->hostThisValue(); … … 537 537 unsigned result = s.find(u2, pos); 538 538 if (result == UString::NotFound) 539 return jsNumber(exec, -1);540 return jsNumber(exec, result);541 } 542 543 JSValue JSC_HOST_CALL stringProtoFuncLastIndexOf(ExecState* exec)539 return JSValue::encode(jsNumber(exec, -1)); 540 return JSValue::encode(jsNumber(exec, result)); 541 } 542 543 EncodedJSValue JSC_HOST_CALL stringProtoFuncLastIndexOf(ExecState* exec) 544 544 { 545 545 JSValue thisValue = exec->hostThisValue(); … … 564 564 unsigned result = s.rfind(u2, static_cast<unsigned>(dpos)); 565 565 if (result == UString::NotFound) 566 return jsNumber(exec, -1);567 return jsNumber(exec, result);568 } 569 570 JSValue JSC_HOST_CALL stringProtoFuncMatch(ExecState* exec)566 return JSValue::encode(jsNumber(exec, -1)); 567 return JSValue::encode(jsNumber(exec, result)); 568 } 569 570 EncodedJSValue JSC_HOST_CALL stringProtoFuncMatch(ExecState* exec) 571 571 { 572 572 JSValue thisValue = exec->hostThisValue(); … … 595 595 // case without 'g' flag is handled like RegExp.prototype.exec 596 596 if (pos < 0) 597 return jsNull();598 return regExpConstructor->arrayOfMatches(exec);597 return JSValue::encode(jsNull()); 598 return JSValue::encode(regExpConstructor->arrayOfMatches(exec)); 599 599 } 600 600 … … 614 614 // Null instead of an empty array, because this matches 615 615 // other browsers and because Null is a false value. 616 return jsNull();617 } 618 619 return constructArray(exec, list);620 } 621 622 JSValue JSC_HOST_CALL stringProtoFuncSearch(ExecState* exec)616 return JSValue::encode(jsNull()); 617 } 618 619 return JSValue::encode(constructArray(exec, list)); 620 } 621 622 EncodedJSValue JSC_HOST_CALL stringProtoFuncSearch(ExecState* exec) 623 623 { 624 624 JSValue thisValue = exec->hostThisValue(); … … 643 643 int matchLength = 0; 644 644 regExpConstructor->performMatch(reg.get(), u, 0, pos, matchLength); 645 return jsNumber(exec, pos);646 } 647 648 JSValue JSC_HOST_CALL stringProtoFuncSlice(ExecState* exec)645 return JSValue::encode(jsNumber(exec, pos)); 646 } 647 648 EncodedJSValue JSC_HOST_CALL stringProtoFuncSlice(ExecState* exec) 649 649 { 650 650 JSValue thisValue = exec->hostThisValue(); … … 665 665 if (to > len) 666 666 to = len; 667 return jsSubstring(exec, s, static_cast<unsigned>(from), static_cast<unsigned>(to) - static_cast<unsigned>(from));668 } 669 670 return jsEmptyString(exec);671 } 672 673 JSValue JSC_HOST_CALL stringProtoFuncSplit(ExecState* exec)667 return JSValue::encode(jsSubstring(exec, s, static_cast<unsigned>(from), static_cast<unsigned>(to) - static_cast<unsigned>(from))); 668 } 669 670 return JSValue::encode(jsEmptyString(exec)); 671 } 672 673 EncodedJSValue JSC_HOST_CALL stringProtoFuncSplit(ExecState* exec) 674 674 { 675 675 JSValue thisValue = exec->hostThisValue(); … … 687 687 if (s.isEmpty() && reg->match(s, 0) >= 0) { 688 688 // empty string matched by regexp -> empty array 689 return result;689 return JSValue::encode(result); 690 690 } 691 691 unsigned pos = 0; … … 714 714 if (s.isEmpty()) { 715 715 // empty separator matches empty string -> empty array 716 return result;716 return JSValue::encode(result); 717 717 } 718 718 while (i != limit && p0 < s.size() - 1) … … 732 732 result->put(exec, i++, jsSubstring(exec, s, p0, s.size() - p0)); 733 733 734 return result;735 } 736 737 JSValue JSC_HOST_CALL stringProtoFuncSubstr(ExecState* exec)734 return JSValue::encode(result); 735 } 736 737 EncodedJSValue JSC_HOST_CALL stringProtoFuncSubstr(ExecState* exec) 738 738 { 739 739 JSValue thisValue = exec->hostThisValue(); … … 747 747 double length = a1.isUndefined() ? len : a1.toInteger(exec); 748 748 if (start >= len || length <= 0) 749 return jsEmptyString(exec);749 return JSValue::encode(jsEmptyString(exec)); 750 750 if (start < 0) { 751 751 start += len; … … 755 755 if (start + length > len) 756 756 length = len - start; 757 return jsSubstring(exec, s, static_cast<unsigned>(start), static_cast<unsigned>(length));758 } 759 760 JSValue JSC_HOST_CALL stringProtoFuncSubstring(ExecState* exec)757 return JSValue::encode(jsSubstring(exec, s, static_cast<unsigned>(start), static_cast<unsigned>(length))); 758 } 759 760 EncodedJSValue JSC_HOST_CALL stringProtoFuncSubstring(ExecState* exec) 761 761 { 762 762 JSValue thisValue = exec->hostThisValue(); … … 787 787 start = temp; 788 788 } 789 return jsSubstring(exec, s, static_cast<unsigned>(start), static_cast<unsigned>(end) - static_cast<unsigned>(start));790 } 791 792 JSValue JSC_HOST_CALL stringProtoFuncToLowerCase(ExecState* exec)789 return JSValue::encode(jsSubstring(exec, s, static_cast<unsigned>(start), static_cast<unsigned>(end) - static_cast<unsigned>(start))); 790 } 791 792 EncodedJSValue JSC_HOST_CALL stringProtoFuncToLowerCase(ExecState* exec) 793 793 { 794 794 JSValue thisValue = exec->hostThisValue(); … … 798 798 int sSize = s.size(); 799 799 if (!sSize) 800 return sVal;800 return JSValue::encode(sVal); 801 801 802 802 const UChar* sData = s.data(); … … 810 810 } 811 811 if (!(ored & ~0x7f)) 812 return jsString(exec, UString::adopt(buffer));812 return JSValue::encode(jsString(exec, UString::adopt(buffer))); 813 813 814 814 bool error; … … 818 818 length = Unicode::toLower(buffer.data(), length, sData, sSize, &error); 819 819 if (error) 820 return sVal;820 return JSValue::encode(sVal); 821 821 } 822 822 if (length == sSize) { 823 823 if (memcmp(buffer.data(), sData, length * sizeof(UChar)) == 0) 824 return sVal;824 return JSValue::encode(sVal); 825 825 } else 826 826 buffer.resize(length); 827 return jsString(exec, UString::adopt(buffer));828 } 829 830 JSValue JSC_HOST_CALL stringProtoFuncToUpperCase(ExecState* exec)827 return JSValue::encode(jsString(exec, UString::adopt(buffer))); 828 } 829 830 EncodedJSValue JSC_HOST_CALL stringProtoFuncToUpperCase(ExecState* exec) 831 831 { 832 832 JSValue thisValue = exec->hostThisValue(); … … 836 836 int sSize = s.size(); 837 837 if (!sSize) 838 return sVal;838 return JSValue::encode(sVal); 839 839 840 840 const UChar* sData = s.data(); … … 848 848 } 849 849 if (!(ored & ~0x7f)) 850 return jsString(exec, UString::adopt(buffer));850 return JSValue::encode(jsString(exec, UString::adopt(buffer))); 851 851 852 852 bool error; … … 856 856 length = Unicode::toUpper(buffer.data(), length, sData, sSize, &error); 857 857 if (error) 858 return sVal;858 return JSValue::encode(sVal); 859 859 } 860 860 if (length == sSize) { 861 861 if (memcmp(buffer.data(), sData, length * sizeof(UChar)) == 0) 862 return sVal;862 return JSValue::encode(sVal); 863 863 } else 864 864 buffer.resize(length); 865 return jsString(exec, UString::adopt(buffer));866 } 867 868 JSValue JSC_HOST_CALL stringProtoFuncLocaleCompare(ExecState* exec)865 return JSValue::encode(jsString(exec, UString::adopt(buffer))); 866 } 867 868 EncodedJSValue JSC_HOST_CALL stringProtoFuncLocaleCompare(ExecState* exec) 869 869 { 870 870 JSValue thisValue = exec->hostThisValue(); 871 871 if (exec->argumentCount() < 1) 872 return jsNumber(exec, 0);873 874 UString s = thisValue.toThisString(exec); 875 JSValue a0 = exec->argument(0); 876 return jsNumber(exec, localeCompare(s, a0.toString(exec)));877 } 878 879 JSValue JSC_HOST_CALL stringProtoFuncBig(ExecState* exec)880 { 881 JSValue thisValue = exec->hostThisValue(); 882 UString s = thisValue.toThisString(exec); 883 return jsMakeNontrivialString(exec, "<big>", s, "</big>");884 } 885 886 JSValue JSC_HOST_CALL stringProtoFuncSmall(ExecState* exec)887 { 888 JSValue thisValue = exec->hostThisValue(); 889 UString s = thisValue.toThisString(exec); 890 return jsMakeNontrivialString(exec, "<small>", s, "</small>");891 } 892 893 JSValue JSC_HOST_CALL stringProtoFuncBlink(ExecState* exec)894 { 895 JSValue thisValue = exec->hostThisValue(); 896 UString s = thisValue.toThisString(exec); 897 return jsMakeNontrivialString(exec, "<blink>", s, "</blink>");898 } 899 900 JSValue JSC_HOST_CALL stringProtoFuncBold(ExecState* exec)901 { 902 JSValue thisValue = exec->hostThisValue(); 903 UString s = thisValue.toThisString(exec); 904 return jsMakeNontrivialString(exec, "<b>", s, "</b>");905 } 906 907 JSValue JSC_HOST_CALL stringProtoFuncFixed(ExecState* exec)908 { 909 JSValue thisValue = exec->hostThisValue(); 910 UString s = thisValue.toThisString(exec); 911 return jsMakeNontrivialString(exec, "<tt>", s, "</tt>");912 } 913 914 JSValue JSC_HOST_CALL stringProtoFuncItalics(ExecState* exec)915 { 916 JSValue thisValue = exec->hostThisValue(); 917 UString s = thisValue.toThisString(exec); 918 return jsMakeNontrivialString(exec, "<i>", s, "</i>");919 } 920 921 JSValue JSC_HOST_CALL stringProtoFuncStrike(ExecState* exec)922 { 923 JSValue thisValue = exec->hostThisValue(); 924 UString s = thisValue.toThisString(exec); 925 return jsMakeNontrivialString(exec, "<strike>", s, "</strike>");926 } 927 928 JSValue JSC_HOST_CALL stringProtoFuncSub(ExecState* exec)929 { 930 JSValue thisValue = exec->hostThisValue(); 931 UString s = thisValue.toThisString(exec); 932 return jsMakeNontrivialString(exec, "<sub>", s, "</sub>");933 } 934 935 JSValue JSC_HOST_CALL stringProtoFuncSup(ExecState* exec)936 { 937 JSValue thisValue = exec->hostThisValue(); 938 UString s = thisValue.toThisString(exec); 939 return jsMakeNontrivialString(exec, "<sup>", s, "</sup>");940 } 941 942 JSValue JSC_HOST_CALL stringProtoFuncFontcolor(ExecState* exec)943 { 944 JSValue thisValue = exec->hostThisValue(); 945 UString s = thisValue.toThisString(exec); 946 JSValue a0 = exec->argument(0); 947 return jsMakeNontrivialString(exec, "<font color=\"", a0.toString(exec), "\">", s, "</font>");948 } 949 950 JSValue JSC_HOST_CALL stringProtoFuncFontsize(ExecState* exec)872 return JSValue::encode(jsNumber(exec, 0)); 873 874 UString s = thisValue.toThisString(exec); 875 JSValue a0 = exec->argument(0); 876 return JSValue::encode(jsNumber(exec, localeCompare(s, a0.toString(exec)))); 877 } 878 879 EncodedJSValue JSC_HOST_CALL stringProtoFuncBig(ExecState* exec) 880 { 881 JSValue thisValue = exec->hostThisValue(); 882 UString s = thisValue.toThisString(exec); 883 return JSValue::encode(jsMakeNontrivialString(exec, "<big>", s, "</big>")); 884 } 885 886 EncodedJSValue JSC_HOST_CALL stringProtoFuncSmall(ExecState* exec) 887 { 888 JSValue thisValue = exec->hostThisValue(); 889 UString s = thisValue.toThisString(exec); 890 return JSValue::encode(jsMakeNontrivialString(exec, "<small>", s, "</small>")); 891 } 892 893 EncodedJSValue JSC_HOST_CALL stringProtoFuncBlink(ExecState* exec) 894 { 895 JSValue thisValue = exec->hostThisValue(); 896 UString s = thisValue.toThisString(exec); 897 return JSValue::encode(jsMakeNontrivialString(exec, "<blink>", s, "</blink>")); 898 } 899 900 EncodedJSValue JSC_HOST_CALL stringProtoFuncBold(ExecState* exec) 901 { 902 JSValue thisValue = exec->hostThisValue(); 903 UString s = thisValue.toThisString(exec); 904 return JSValue::encode(jsMakeNontrivialString(exec, "<b>", s, "</b>")); 905 } 906 907 EncodedJSValue JSC_HOST_CALL stringProtoFuncFixed(ExecState* exec) 908 { 909 JSValue thisValue = exec->hostThisValue(); 910 UString s = thisValue.toThisString(exec); 911 return JSValue::encode(jsMakeNontrivialString(exec, "<tt>", s, "</tt>")); 912 } 913 914 EncodedJSValue JSC_HOST_CALL stringProtoFuncItalics(ExecState* exec) 915 { 916 JSValue thisValue = exec->hostThisValue(); 917 UString s = thisValue.toThisString(exec); 918 return JSValue::encode(jsMakeNontrivialString(exec, "<i>", s, "</i>")); 919 } 920 921 EncodedJSValue JSC_HOST_CALL stringProtoFuncStrike(ExecState* exec) 922 { 923 JSValue thisValue = exec->hostThisValue(); 924 UString s = thisValue.toThisString(exec); 925 return JSValue::encode(jsMakeNontrivialString(exec, "<strike>", s, "</strike>")); 926 } 927 928 EncodedJSValue JSC_HOST_CALL stringProtoFuncSub(ExecState* exec) 929 { 930 JSValue thisValue = exec->hostThisValue(); 931 UString s = thisValue.toThisString(exec); 932 return JSValue::encode(jsMakeNontrivialString(exec, "<sub>", s, "</sub>")); 933 } 934 935 EncodedJSValue JSC_HOST_CALL stringProtoFuncSup(ExecState* exec) 936 { 937 JSValue thisValue = exec->hostThisValue(); 938 UString s = thisValue.toThisString(exec); 939 return JSValue::encode(jsMakeNontrivialString(exec, "<sup>", s, "</sup>")); 940 } 941 942 EncodedJSValue JSC_HOST_CALL stringProtoFuncFontcolor(ExecState* exec) 943 { 944 JSValue thisValue = exec->hostThisValue(); 945 UString s = thisValue.toThisString(exec); 946 JSValue a0 = exec->argument(0); 947 return JSValue::encode(jsMakeNontrivialString(exec, "<font color=\"", a0.toString(exec), "\">", s, "</font>")); 948 } 949 950 EncodedJSValue JSC_HOST_CALL stringProtoFuncFontsize(ExecState* exec) 951 951 { 952 952 JSValue thisValue = exec->hostThisValue(); … … 961 961 PassRefPtr<UStringImpl> impl = UStringImpl::tryCreateUninitialized(bufferSize, buffer); 962 962 if (!impl) 963 return jsUndefined();963 return JSValue::encode(jsUndefined()); 964 964 buffer[0] = '<'; 965 965 buffer[1] = 'f'; … … 985 985 buffer[20 + stringSize] = 't'; 986 986 buffer[21 + stringSize] = '>'; 987 return jsNontrivialString(exec, impl);988 } 989 990 return jsMakeNontrivialString(exec, "<font size=\"", a0.toString(exec), "\">", s, "</font>");991 } 992 993 JSValue JSC_HOST_CALL stringProtoFuncAnchor(ExecState* exec)994 { 995 JSValue thisValue = exec->hostThisValue(); 996 UString s = thisValue.toThisString(exec); 997 JSValue a0 = exec->argument(0); 998 return jsMakeNontrivialString(exec, "<a name=\"", a0.toString(exec), "\">", s, "</a>");999 } 1000 1001 JSValue JSC_HOST_CALL stringProtoFuncLink(ExecState* exec)987 return JSValue::encode(jsNontrivialString(exec, impl)); 988 } 989 990 return JSValue::encode(jsMakeNontrivialString(exec, "<font size=\"", a0.toString(exec), "\">", s, "</font>")); 991 } 992 993 EncodedJSValue JSC_HOST_CALL stringProtoFuncAnchor(ExecState* exec) 994 { 995 JSValue thisValue = exec->hostThisValue(); 996 UString s = thisValue.toThisString(exec); 997 JSValue a0 = exec->argument(0); 998 return JSValue::encode(jsMakeNontrivialString(exec, "<a name=\"", a0.toString(exec), "\">", s, "</a>")); 999 } 1000 1001 EncodedJSValue JSC_HOST_CALL stringProtoFuncLink(ExecState* exec) 1002 1002 { 1003 1003 JSValue thisValue = exec->hostThisValue(); … … 1012 1012 PassRefPtr<UStringImpl> impl = UStringImpl::tryCreateUninitialized(bufferSize, buffer); 1013 1013 if (!impl) 1014 return jsUndefined();1014 return JSValue::encode(jsUndefined()); 1015 1015 buffer[0] = '<'; 1016 1016 buffer[1] = 'a'; … … 1030 1030 buffer[13 + linkTextSize + stringSize] = 'a'; 1031 1031 buffer[14 + linkTextSize + stringSize] = '>'; 1032 return jsNontrivialString(exec, impl);1032 return JSValue::encode(jsNontrivialString(exec, impl)); 1033 1033 } 1034 1034 … … 1064 1064 } 1065 1065 1066 JSValue JSC_HOST_CALL stringProtoFuncTrim(ExecState* exec)1067 { 1068 JSValue thisValue = exec->hostThisValue(); 1069 return trimString(exec, thisValue, TrimLeft | TrimRight);1070 } 1071 1072 JSValue JSC_HOST_CALL stringProtoFuncTrimLeft(ExecState* exec)1073 { 1074 JSValue thisValue = exec->hostThisValue(); 1075 return trimString(exec, thisValue, TrimLeft);1076 } 1077 1078 JSValue JSC_HOST_CALL stringProtoFuncTrimRight(ExecState* exec)1079 { 1080 JSValue thisValue = exec->hostThisValue(); 1081 return trimString(exec, thisValue, TrimRight);1066 EncodedJSValue JSC_HOST_CALL stringProtoFuncTrim(ExecState* exec) 1067 { 1068 JSValue thisValue = exec->hostThisValue(); 1069 return JSValue::encode(trimString(exec, thisValue, TrimLeft | TrimRight)); 1070 } 1071 1072 EncodedJSValue JSC_HOST_CALL stringProtoFuncTrimLeft(ExecState* exec) 1073 { 1074 JSValue thisValue = exec->hostThisValue(); 1075 return JSValue::encode(trimString(exec, thisValue, TrimLeft)); 1076 } 1077 1078 EncodedJSValue JSC_HOST_CALL stringProtoFuncTrimRight(ExecState* exec) 1079 { 1080 JSValue thisValue = exec->hostThisValue(); 1081 return JSValue::encode(trimString(exec, thisValue, TrimRight)); 1082 1082 } 1083 1083
Note:
See TracChangeset
for help on using the changeset viewer.