mirror of
https://github.com/Samsung/escargot.git
synced 2026-06-22 10:01:50 +00:00
- 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
37 lines
2 KiB
C++
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)));
|
|
}
|
|
}
|