+ typedef JSGlobalObject Base;
+
+ static GlobalObject* create(JSGlobalData& globalData, Structure* structure, const Vector<UString>& arguments)
+ {
+ GlobalObject* object = new (NotNull, allocateCell<GlobalObject>(globalData.heap)) GlobalObject(globalData, structure);
+ object->finishCreation(globalData, arguments);
+ return object;
+ }
+
+ static const ClassInfo s_info;
+
+ static Structure* createStructure(JSGlobalData& globalData, JSValue prototype)
+ {
+ return Structure::create(globalData, 0, prototype, TypeInfo(GlobalObjectType, StructureFlags), &s_info);
+ }
+
+protected:
+ void finishCreation(JSGlobalData& globalData, const Vector<UString>& arguments)
+ {
+ Base::finishCreation(globalData);
+
+ addFunction(globalData, "debug", functionDebug, 1);
+ addFunction(globalData, "print", functionPrint, 1);
+ addFunction(globalData, "quit", functionQuit, 0);
+ addFunction(globalData, "gc", functionGC, 0);
+#ifndef NDEBUG
+ addFunction(globalData, "releaseExecutableMemory", functionReleaseExecutableMemory, 0);
+#endif
+ addFunction(globalData, "version", functionVersion, 1);
+ addFunction(globalData, "run", functionRun, 1);
+ addFunction(globalData, "load", functionLoad, 1);
+ addFunction(globalData, "checkSyntax", functionCheckSyntax, 1);
+ addFunction(globalData, "jscStack", functionJSCStack, 1);
+ addFunction(globalData, "readline", functionReadline, 0);
+ addFunction(globalData, "preciseTime", functionPreciseTime, 0);
+#if ENABLE(SAMPLING_FLAGS)
+ addFunction(globalData, "setSamplingFlags", functionSetSamplingFlags, 1);
+ addFunction(globalData, "clearSamplingFlags", functionClearSamplingFlags, 1);
+#endif
+
+ addConstructableFunction(globalData, "Uint8Array", constructJSUint8Array, 1);
+ addConstructableFunction(globalData, "Uint8ClampedArray", constructJSUint8ClampedArray, 1);
+ addConstructableFunction(globalData, "Uint16Array", constructJSUint16Array, 1);
+ addConstructableFunction(globalData, "Uint32Array", constructJSUint32Array, 1);
+ addConstructableFunction(globalData, "Int8Array", constructJSInt8Array, 1);
+ addConstructableFunction(globalData, "Int16Array", constructJSInt16Array, 1);
+ addConstructableFunction(globalData, "Int32Array", constructJSInt32Array, 1);
+ addConstructableFunction(globalData, "Float32Array", constructJSFloat32Array, 1);
+ addConstructableFunction(globalData, "Float64Array", constructJSFloat64Array, 1);
+
+ JSArray* array = constructEmptyArray(globalExec());
+ for (size_t i = 0; i < arguments.size(); ++i)
+ array->putDirectIndex(globalExec(), i, jsString(globalExec(), arguments[i]), false);
+ putDirect(globalData, Identifier(globalExec(), "arguments"), array);
+ }
+
+ void addFunction(JSGlobalData& globalData, const char* name, NativeFunction function, unsigned arguments)
+ {
+ Identifier identifier(globalExec(), name);
+ putDirect(globalData, identifier, JSFunction::create(globalExec(), this, arguments, identifier, function));
+ }
+
+ void addConstructableFunction(JSGlobalData& globalData, const char* name, NativeFunction function, unsigned arguments)
+ {
+ Identifier identifier(globalExec(), name);
+ putDirect(globalData, identifier, JSFunction::create(globalExec(), this, arguments, identifier, function, NoIntrinsic, function));
+ }