5 #include "src/objects/template-objects.h" 7 #include "src/heap/factory.h" 8 #include "src/isolate.h" 9 #include "src/objects-inl.h" 10 #include "src/property-descriptor.h" 16 Handle<JSArray> TemplateObjectDescription::CreateTemplateObject(
17 Isolate* isolate, Handle<TemplateObjectDescription> description) {
19 Handle<FixedArray> raw_strings(description->raw_strings(), isolate);
20 Handle<JSArray> raw_object = isolate->factory()->NewJSArrayWithElements(
21 raw_strings, PACKED_ELEMENTS, raw_strings->length(), TENURED);
24 Handle<FixedArray> cooked_strings(description->cooked_strings(), isolate);
25 Handle<JSArray> template_object = isolate->factory()->NewJSArrayWithElements(
26 cooked_strings, PACKED_ELEMENTS, cooked_strings->length(), TENURED);
29 JSObject::SetIntegrityLevel(raw_object, FROZEN, kThrowOnError).ToChecked();
32 PropertyDescriptor raw_desc;
33 raw_desc.set_value(raw_object);
34 raw_desc.set_configurable(
false);
35 raw_desc.set_enumerable(
false);
36 raw_desc.set_writable(
false);
37 JSArray::DefineOwnProperty(isolate, template_object,
38 isolate->factory()->raw_string(), &raw_desc,
43 JSObject::SetIntegrityLevel(template_object, FROZEN, kThrowOnError)
46 return template_object;