2017-03-21 10:16:54 +01:00
|
|
|
// Copyright 2016 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2017-08-01 11:36:44 -05:00
|
|
|
#ifndef V8_UNITTESTS_TEST_HELPERS_H_
|
|
|
|
#define V8_UNITTESTS_TEST_HELPERS_H_
|
2017-03-21 10:16:54 +01:00
|
|
|
|
2017-06-06 10:28:14 +02:00
|
|
|
#include <memory>
|
|
|
|
|
2021-10-10 11:10:43 +02:00
|
|
|
#include "include/v8-primitive.h"
|
2023-10-05 08:46:07 +02:00
|
|
|
#include "src/common/globals.h"
|
2017-06-06 10:28:14 +02:00
|
|
|
|
2017-03-21 10:16:54 +01:00
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
|
2022-01-29 08:33:07 +01:00
|
|
|
class SharedFunctionInfo;
|
|
|
|
class Utf16CharacterStream;
|
2017-06-06 10:28:14 +02:00
|
|
|
|
|
|
|
namespace test {
|
|
|
|
|
|
|
|
class ScriptResource : public v8::String::ExternalOneByteStringResource {
|
|
|
|
public:
|
2024-08-14 20:41:00 +02:00
|
|
|
ScriptResource(const char* data, size_t length, uint16_t parameter_count)
|
|
|
|
: data_(data), length_(length), parameter_count_(parameter_count) {}
|
2017-06-06 10:28:14 +02:00
|
|
|
~ScriptResource() override = default;
|
2021-02-11 19:03:35 +01:00
|
|
|
ScriptResource(const ScriptResource&) = delete;
|
|
|
|
ScriptResource& operator=(const ScriptResource&) = delete;
|
2017-06-06 10:28:14 +02:00
|
|
|
|
|
|
|
const char* data() const override { return data_; }
|
|
|
|
size_t length() const override { return length_; }
|
2024-08-14 20:41:00 +02:00
|
|
|
uint16_t parameter_count() const { return parameter_count_; }
|
2017-06-06 10:28:14 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
const char* data_;
|
|
|
|
size_t length_;
|
2024-08-14 20:41:00 +02:00
|
|
|
uint16_t parameter_count_;
|
2017-06-06 10:28:14 +02:00
|
|
|
};
|
|
|
|
|
2024-08-14 20:41:00 +02:00
|
|
|
test::ScriptResource* CreateSource(test::ScriptResource* maybe_resource);
|
2017-06-06 10:28:14 +02:00
|
|
|
Handle<SharedFunctionInfo> CreateSharedFunctionInfo(
|
2024-08-14 20:41:00 +02:00
|
|
|
Isolate* isolate, ScriptResource* maybe_resource);
|
2022-01-29 08:33:07 +01:00
|
|
|
std::unique_ptr<Utf16CharacterStream> SourceCharacterStreamForShared(
|
2024-08-14 20:41:00 +02:00
|
|
|
Isolate* isolate, DirectHandle<SharedFunctionInfo> shared);
|
2017-03-21 10:16:54 +01:00
|
|
|
|
2017-06-06 10:28:14 +02:00
|
|
|
} // namespace test
|
2017-03-21 10:16:54 +01:00
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|
|
|
|
|
2017-08-01 11:36:44 -05:00
|
|
|
#endif // V8_UNITTESTS_TEST_HELPERS_H_
|