Changeset 44923 in webkit for trunk/JavaScriptCore/runtime/JSONObject.cpp
- Timestamp:
- Jun 21, 2009, 4:02:13 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/JSONObject.cpp
r44813 r44923 30 30 #include "ExceptionHelpers.h" 31 31 #include "JSArray.h" 32 #include "LiteralParser.h" 32 33 #include "PropertyNameArray.h" 33 34 #include <wtf/MathExtras.h> … … 37 38 ASSERT_CLASS_FITS_IN_CELL(JSONObject); 38 39 40 static JSValue JSC_HOST_CALL JSONProtoFuncParse(ExecState*, JSObject*, JSValue, const ArgList&); 39 41 static JSValue JSC_HOST_CALL JSONProtoFuncStringify(ExecState*, JSObject*, JSValue, const ArgList&); 40 42 … … 563 565 /* Source for JSONObject.lut.h 564 566 @begin jsonTable 567 parse JSONProtoFuncParse DontEnum|Function 1 565 568 stringify JSONProtoFuncStringify DontEnum|Function 1 566 569 @end … … 583 586 { 584 587 stringifier->mark(); 588 } 589 590 // ECMA-262 v5 15.12.3 591 JSValue JSC_HOST_CALL JSONProtoFuncParse(ExecState* exec, JSObject*, JSValue, const ArgList& args) 592 { 593 if (args.isEmpty()) 594 return throwError(exec, GeneralError, "JSON.parse requires at least one parameter"); 595 JSValue value = args.at(0); 596 UString source = value.toString(exec); 597 if (exec->hadException()) 598 return jsNull(); 599 600 LiteralParser jsonParser(exec, source, LiteralParser::StrictJSON); 601 JSValue parsedObject = jsonParser.tryLiteralParse(); 602 if (!parsedObject) 603 return throwError(exec, SyntaxError, "Unable to parse JSON string"); 604 605 return parsedObject; 585 606 } 586 607
Note:
See TracChangeset
for help on using the changeset viewer.