escargot/src/runtime/GlobalObjectBuiltinJSON.cpp
Eunji Jeong c8840465d1 Pass tests in es5 test262 ch15.2.3.3 (except for URI-related features)
- Add every builtin function templates in es5
- Modification on Makefile target "check" should not trigger rebuild
- Add JSON object
- Implement some toString functions
- Initialize m_value properly in ObjectPropertyDescriptor constructor
2016-12-29 22:39:02 +09:00

37 lines
2 KiB
C++

#include "Escargot.h"
#include "GlobalObject.h"
#include "Context.h"
#include "StringObject.h"
namespace Escargot {
static Value builtinJSONParse(ExecutionState& state, Value thisValue, size_t argc, Value* argv, bool isNewExpression)
{
state.throwException(new ASCIIString(errorMessage_NotImplemented));
RELEASE_ASSERT_NOT_REACHED();
}
static Value builtinJSONStringify(ExecutionState& state, Value thisValue, size_t argc, Value* argv, bool isNewExpression)
{
state.throwException(new ASCIIString(errorMessage_NotImplemented));
RELEASE_ASSERT_NOT_REACHED();
}
void GlobalObject::installJSON(ExecutionState& state)
{
m_json = new Object(state);
m_json->giveInternalClassProperty("JSON");
m_json->markThisObjectDontNeedStructureTransitionTable(state);
defineOwnProperty(state, ObjectPropertyName(state.context()->staticStrings().JSON),
ObjectPropertyDescriptor(m_json, (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::WritablePresent | ObjectPropertyDescriptor::ConfigurablePresent)));
m_json->defineOwnProperty(state, ObjectPropertyName(state.context()->staticStrings().parse),
ObjectPropertyDescriptor(new FunctionObject(state, NativeFunctionInfo(state.context()->staticStrings().parse, builtinJSONParse, 1, nullptr, NativeFunctionInfo::Strict)),
(ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::WritablePresent | ObjectPropertyDescriptor::ConfigurablePresent)));
m_json->defineOwnProperty(state, ObjectPropertyName(state.context()->staticStrings().stringify),
ObjectPropertyDescriptor(new FunctionObject(state, NativeFunctionInfo(state.context()->staticStrings().stringify, builtinJSONStringify, 1, nullptr, NativeFunctionInfo::Strict)),
(ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::WritablePresent | ObjectPropertyDescriptor::ConfigurablePresent)));
}
}