1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-24 19:07:35 +00:00

LibJS: Remove js_string(Interpreter&, ...)

This commit is contained in:
Andreas Kling 2020-09-27 20:03:42 +02:00
parent adf0a537af
commit 591b7b7031
8 changed files with 9 additions and 16 deletions

View file

@ -157,7 +157,7 @@ JS::Value Cell::js_data()
if (kind == Formula) if (kind == Formula)
return evaluated_data; return evaluated_data;
return JS::js_string(sheet->interpreter(), data); return JS::js_string(sheet->interpreter().heap(), data);
} }
String Cell::source() const String Cell::source() const

View file

@ -51,7 +51,7 @@ String StringCell::display(Cell& cell, const CellTypeMetadata& metadata) const
JS::Value StringCell::js_value(Cell& cell, const CellTypeMetadata& metadata) const JS::Value StringCell::js_value(Cell& cell, const CellTypeMetadata& metadata) const
{ {
auto string = display(cell, metadata); auto string = display(cell, metadata);
return JS::js_string(cell.sheet->interpreter(), string); return JS::js_string(cell.sheet->interpreter().heap(), string);
} }
} }

View file

@ -248,7 +248,7 @@ RefPtr<Sheet> Sheet::from_json(const JsonObject& object, Workbook& workbook)
break; break;
case Cell::Formula: { case Cell::Formula: {
auto& interpreter = sheet->interpreter(); auto& interpreter = sheet->interpreter();
auto value = interpreter.call(parse_function, json, JS::js_string(interpreter, obj.get("value").as_string())); auto value = interpreter.call(parse_function, json, JS::js_string(interpreter.heap(), obj.get("value").as_string()));
cell = make<Cell>(obj.get("source").to_string(), move(value), sheet->make_weak_ptr()); cell = make<Cell>(obj.get("source").to_string(), move(value), sheet->make_weak_ptr());
break; break;
} }

View file

@ -1513,7 +1513,7 @@ Value ObjectExpression::execute(Interpreter& interpreter, GlobalObject& global_o
auto& str_to_spread = key.as_string().string(); auto& str_to_spread = key.as_string().string();
for (size_t i = 0; i < str_to_spread.length(); i++) { for (size_t i = 0; i < str_to_spread.length(); i++) {
object->define_property(i, js_string(interpreter, str_to_spread.substring(i, 1))); object->define_property(i, js_string(interpreter.heap(), str_to_spread.substring(i, 1)));
if (interpreter.exception()) if (interpreter.exception())
return {}; return {};
} }
@ -1613,7 +1613,7 @@ Value MemberExpression::execute(Interpreter& interpreter, GlobalObject& global_o
Value StringLiteral::execute(Interpreter& interpreter, GlobalObject&) const Value StringLiteral::execute(Interpreter& interpreter, GlobalObject&) const
{ {
return js_string(interpreter, m_value); return js_string(interpreter.heap(), m_value);
} }
Value NumericLiteral::execute(Interpreter&, GlobalObject&) const Value NumericLiteral::execute(Interpreter&, GlobalObject&) const
@ -1706,7 +1706,7 @@ Value TemplateLiteral::execute(Interpreter& interpreter, GlobalObject& global_ob
string_builder.append(string); string_builder.append(string);
} }
return js_string(interpreter, string_builder.build()); return js_string(interpreter.heap(), string_builder.build());
} }
void TaggedTemplateLiteral::dump(int indent) const void TaggedTemplateLiteral::dump(int indent) const

View file

@ -24,9 +24,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <LibJS/Heap/Heap.h>
#include <LibJS/Interpreter.h>
#include <LibJS/Runtime/PrimitiveString.h> #include <LibJS/Runtime/PrimitiveString.h>
#include <LibJS/Runtime/VM.h>
namespace JS { namespace JS {
@ -46,11 +45,6 @@ PrimitiveString* js_string(Heap& heap, String string)
return heap.allocate_without_global_object<PrimitiveString>(move(string)); return heap.allocate_without_global_object<PrimitiveString>(move(string));
} }
PrimitiveString* js_string(Interpreter& interpreter, String string)
{
return js_string(interpreter.heap(), move(string));
}
PrimitiveString* js_string(VM& vm, String string) PrimitiveString* js_string(VM& vm, String string)
{ {
return js_string(vm.heap(), move(string)); return js_string(vm.heap(), move(string));

View file

@ -45,7 +45,6 @@ private:
}; };
PrimitiveString* js_string(Heap&, String); PrimitiveString* js_string(Heap&, String);
PrimitiveString* js_string(Interpreter&, String);
PrimitiveString* js_string(VM&, String); PrimitiveString* js_string(VM&, String);
} }

View file

@ -52,7 +52,7 @@ RegExpObject::~RegExpObject()
Value RegExpObject::to_string() const Value RegExpObject::to_string() const
{ {
return js_string(interpreter(), String::format("/%s/%s", content().characters(), flags().characters())); return js_string(heap(), String::format("/%s/%s", content().characters(), flags().characters()));
} }
} }

View file

@ -61,7 +61,7 @@ static String ak_string_from(VM& vm, GlobalObject& global_object)
} }
StringPrototype::StringPrototype(GlobalObject& global_object) StringPrototype::StringPrototype(GlobalObject& global_object)
: StringObject(*js_string(interpreter(), String::empty()), *global_object.object_prototype()) : StringObject(*js_string(global_object.heap(), String::empty()), *global_object.object_prototype())
{ {
} }