Index: src/factory.cc |
diff --git a/src/factory.cc b/src/factory.cc |
index 9ba48ee5024fa1cb3a59c85864ff88604e8339b0..e48e4b5e31f7116990d80d78f7e0b51d31904130 100644 |
--- a/src/factory.cc |
+++ b/src/factory.cc |
@@ -242,6 +242,50 @@ Handle<String> Factory::NewExternalStringFromTwoByte( |
} |
+static Handle<JSValue> AllocateJSValue(Isolate* isolate, |
+ JSFunction* constructor) { |
+ CALL_HEAP_FUNCTION( |
+ isolate, |
+ isolate->heap()->AllocateJSObject(constructor), |
Vyacheslav Egorov (Chromium)
2011/07/12 20:38:12
constructor will be "dead variable" if GC happens.
zarko
2011/07/12 21:42:06
Done.
|
+ JSValue); |
+} |
+ |
+ |
+static Handle<Object> CreateJSValue(Isolate* isolate, |
+ JSFunction* constructor, |
+ Handle<Object> value) { |
+ Handle<JSValue> raw_value = AllocateJSValue(isolate, constructor); |
+ if (!raw_value.is_null()) { |
+ raw_value->set_value(*value); |
+ } |
+ return raw_value; |
+} |
+ |
+ |
+Handle<Object> Factory::NewBoxedString(Handle<String> value) { |
+ return CreateJSValue(isolate(), |
+ isolate()->global_context()->string_function(), |
+ value); |
+} |
+ |
+ |
+Handle<Object> Factory::NewBoxedBoolean(bool value) { |
+ Handle<Object> boolean(value ? isolate()->heap()->true_value() |
+ : isolate()->heap()->false_value()); |
+ return CreateJSValue(isolate(), |
+ isolate()->global_context()->boolean_function(), |
+ boolean); |
+} |
+ |
+ |
+Handle<Object> Factory::NewBoxedNumber(double value) { |
+ Handle<Object> number = NewNumber(value); |
+ return CreateJSValue(isolate(), |
+ isolate()->global_context()->number_function(), |
+ number); |
+} |
+ |
+ |
Handle<Context> Factory::NewGlobalContext() { |
CALL_HEAP_FUNCTION( |
isolate(), |