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
This commit is contained in:
Eunji Jeong 2016-12-29 19:14:58 +09:00
commit c8840465d1
17 changed files with 670 additions and 183 deletions

View file

@ -0,0 +1,37 @@
#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)));
}
}